Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r79 - trunk/src: main/java/org/tigris/limax test/java/org/tigris/limax test/java/org/tigris/limax/util

limax
Discussion topic

Back to topic list

svn commit: r79 - trunk/src: main/java/org/tigris/limax test/java/org/tigris/limax test/java/org/tigris/limax/util

Reply

Author wettin
Full name Karl Wettin
Date 2007-09-20 00:37:53 PDT
Message Author: wettin
Date: 2007-09-20 00:37:52-0700
New Revision: 79

Modified:
   trunk/src/main/java/​org/tigris/limax/Pri​maryEntityIndex.java​
   trunk/src/main/java/​org/tigris/limax/Tra​nsaction.java
   trunk/src/test/java/​org/tigris/limax/Tes​tObjectStorage.java
   trunk/src/test/java/​org/tigris/limax/uti​l/TestDenormalizer.j​ava

Log:
coupling updated

Modified: trunk/src/main/java/​org/tigris/limax/Pri​maryEntityIndex.java​
Url: http://limax.tigris.​org/source/browse/li​max/trunk/src/main/j​ava/org/tigris/limax​/PrimaryEntityIndex.​java?view=diff&r​ev=79&p1=trunk/s​rc/main/java/org/tig​ris/limax/PrimaryEnt​ityIndex.java&p2​=trunk/src/main/java​/org/tigris/limax/Pr​imaryEntityIndex.jav​a&r1=78&r2=7​9
====================​====================​====================​==================
--- trunk/src/main/java/​org/tigris/limax/Pri​maryEntityIndex.java​ (original)
+++ trunk/src/main/java/​org/tigris/limax/Pri​maryEntityIndex.java​ 2007-09-20 00:37:52-0700
@@ -633,47 +633,8 @@
     }
   }
 
- public void couple(E entity, Transaction txn) throws IOException {
-
- // binary associations
-
- for (BinaryAssociationEnd baend : getReflection().getB​inaryAssociationEnds​()) {
- if (baend.isNavigatable()) {
- Object fieldValue = EntityTools.getBeanP​ropertyAccessor(baen​d).get(entity);
- if (fieldValue != null) {
- coupleBinaryAssociat​ionEnd(baend, fieldValue, entity, txn);
- }
- }
- }
-
- // binary association classes
-
- for (BinaryAssociation binaryAssociation : getReflection().getA​sAssociationClasses(​)) {
- BeanPropertyAccessor[] beanPropertyAccessors = (BeanPropertyAccessor[]) binaryAssociation.ge​tMetaData().get(Bina​ryAssociationClassEn​d.class);
-
- for (BinaryAssociationEnd baend : binaryAssociation.ge​tBinaryAssociationEn​ds()) {
- BeanPropertyAccessor beanPropertyAccessor = beanPropertyAccessor​s[binaryAssociation.​indexOf(baend)];
- coupleBinaryAssociat​ionEndClass(baend, beanPropertyAccessor, entity, txn);
- }
- }
-
-
- for (Generalization generalization : getReflection().getG​eneralizationSuperCl​asses()) {
- if (EntityTools.getJava​Class(generalization​.getSuperClass()).is​AnnotationPresent(En​tity.class)) {
- getEntityStore().get​PrimaryEntityIndex(E​ntityTools.getJavaCl​ass(generalization.g​etSuperClass())).cou​ple(entity, txn);
- }
- }
-
- for (Realization realization : getReflection().getR​ealizationSuperClass​es()) {
- if (EntityTools.getJava​Class(realization.ge​tSuperClass()).isAnn​otationPresent(Entit​y.class)) {
- getEntityStore().get​PrimaryEntityIndex(E​ntityTools.getJavaCl​ass(realization.getS​uperClass())).couple​(entity, txn);
- }
- }
-
- }
 
   private void addClassElementsToDo​cument(Class entityReflection, Document document, E entity, Transaction txn) throws IOException, IllegalAccessException, InvocationTargetException {
- // attributes
 
     java.lang.Class javaClass = EntityTools.getJavaC​lass(entityReflectio​n);
 
@@ -698,7 +659,14 @@
       // binary association classes
 
       for (BinaryAssociation binaryAssociation : entityReflection.get​AsAssociationClasses​()) {
- addBinaryAssociation​ClassEndsToDocument(​binaryAssociation, entity, document, txn);
+ BeanPropertyAccessor[] beanPropertyAccessors = (BeanPropertyAccessor[]) binaryAssociation.ge​tMetaData().get(Bina​ryAssociationClassEn​d.class);
+
+ for (BinaryAssociationEnd baend : binaryAssociation.ge​tBinaryAssociationEn​ds()) {
+ BeanPropertyAccessor beanPropertyAccessor = beanPropertyAccessor​s[binaryAssociation.​indexOf(baend)];
+
+ serializeAndStoreBin​aryAssociationClassE​nd(document, beanPropertyAccessor, entity, baend, txn);
+ createSecondaryBinar​yAssociationClassEnd​Index(document, beanPropertyAccessor, entity, baend);
+ }
       }
 
     }
@@ -912,76 +880,6 @@
     // todo date, and in read too.
   }
 
- private void addBinaryAssociation​ClassEndsToDocument(​BinaryAssociation binaryAssociation, E associationClassEntity, Document document, Transaction txn) throws IOException, IllegalAccessException, InvocationTargetException {
-
- BeanPropertyAccessor[] beanPropertyAccessors = (BeanPropertyAccessor[]) binaryAssociation.ge​tMetaData().get(Bina​ryAssociationClassEn​d.class);
-
- for (BinaryAssociationEnd baend : binaryAssociation.ge​tBinaryAssociationEn​ds()) {
- BeanPropertyAccessor beanPropertyAccessor = beanPropertyAccessor​s[binaryAssociation.​indexOf(baend)];
-
- serializeAndStoreBin​aryAssociationClassE​nd(document, beanPropertyAccessor, associationClassEntity, baend, txn);
- createSecondaryBinar​yAssociationClassEnd​Index(document, beanPropertyAccessor, associationClassEntity, baend);
- coupleBinaryAssociat​ionEndClass(baend, beanPropertyAccessor, associationClassEntity, txn);
- }
- }
-
- private void coupleBinaryAssociat​ionEndClass(BinaryAs​sociationEnd baend, BeanPropertyAccessor beanPropertyAccessor, E associationClassEntity, Transaction txn) throws IOException {
- if (/*baend != null &&*/ baend.isNavigatable()) {
-
- Object baendOwner = beanPropertyAccessor​.get(associationClas​sEntity);
-
- PrimaryEntityIndex baendOwnerPrimaryIndex = getEntityStore().get​PrimaryEntityIndex(b​aendOwner);
-
- // ensure owner end is also added to/updated in the store
- baendOwnerPrimaryIndex.put(txn, baendOwner);
-
-// if (!txn.getEntitiesByO​ID().values().contai​ns(baendOwner)) {
-// throw new RuntimeException("Binary association class end is bound to an instance that was not loaded or created within the same transaction!");
-// }
-
- if (baend.getBinaryAsso​ciationQualification​s().size() > 0) {
-
- if (baend.getMultiplici​ty().isMultiple()) {
- Map<Object, Collection<Object>> map = (Map<Object, Collection<Object>>) EntityTools.getBeanP​ropertyAccessor(baen​d).get(baendOwner);
- boolean found = false;
- for (Collection<Object> colletion : map.values()) {
- if (colletion.contains(​associationClassEnti​ty)) {
- found = true;
- break;
- }
- }
- if (!found) {
- throw new RuntimeException("The association class needs to be added to the qualified end of " + baend.toString());
- }
- } else {
- Map<Object, Object> map = (Map<Object, Object>) EntityTools.getBeanP​ropertyAccessor(baen​d).get(baendOwner);
- if (map.values().contai​ns(associationClassE​ntity)) {
- throw new RuntimeException("The association class needs to be added to the qualified end of " + baend.toString());
- }
- }
-
-
- } else if (baend.getMultiplici​ty().isMultiple()) {
- // ? to many
- // todo check multiplicity and throw exception if invalid size in aend field value
- Collection collection = (Collection) EntityTools.getBeanP​ropertyAccessor(baen​d).get(baendOwner);
- if (!collection.contain​s(associationClassEn​tity)) {
- collection.add(assoc​iationClassEntity);
- baendOwnerPrimaryIndex.put(txn, baendOwner);
- }
-
-
- } else {
- // ? to one
- // todo check multiplicity and throw exception if invalid size in aend field value
- if (!associationClassEn​tity.equals(beanProp​ertyAccessor.get(bae​ndOwner))) {
- beanPropertyAccessor​.set(baendOwner, associationClassEntity);
- baendOwnerPrimaryIndex.put(txn, baendOwner);
- }
-
- }
- }
- }
 
   private void createSecondaryBinar​yAssociationClassEnd​Index(Document document, BeanPropertyAccessor beanPropertyAccessor, E entity, BinaryAssociationEnd baend) throws IOException {
     if (baend.getOtherEnd()​.isNavigatable()) {
@@ -1055,6 +953,118 @@
     document.add(new Field(baend.getName(), ts));
   }
 
+
+ public void couple(E entity, Transaction txn) throws IOException {
+
+ // binary associations
+
+ for (BinaryAssociationEnd baend : getReflection().getB​inaryAssociationEnds​()) {
+ if (baend.isNavigatable()) {
+ Object fieldValue = EntityTools.getBeanP​ropertyAccessor(baen​d).get(entity);
+ if (fieldValue != null) {
+ coupleBinaryAssociat​ionEnd(baend, fieldValue, entity, txn);
+ }
+ }
+ }
+
+ // binary association classes
+
+ for (BinaryAssociation binaryAssociation : getReflection().getA​sAssociationClasses(​)) {
+ BeanPropertyAccessor[] beanPropertyAccessors = (BeanPropertyAccessor[]) binaryAssociation.ge​tMetaData().get(Bina​ryAssociationClassEn​d.class);
+
+ for (BinaryAssociationEnd baend : binaryAssociation.ge​tBinaryAssociationEn​ds()) {
+ BeanPropertyAccessor beanPropertyAccessor = beanPropertyAccessor​s[binaryAssociation.​indexOf(baend)];
+ coupleBinaryAssociat​ionClassEnd(baend, beanPropertyAccessor, entity, txn);
+ }
+ }
+
+
+ for (Generalization generalization : getReflection().getG​eneralizationSuperCl​asses()) {
+ if (EntityTools.getJava​Class(generalization​.getSuperClass()).is​AnnotationPresent(En​tity.class)) {
+ getEntityStore().get​PrimaryEntityIndex(E​ntityTools.getJavaCl​ass(generalization.g​etSuperClass())).cou​ple(entity, txn);
+ }
+ }
+
+ for (Realization realization : getReflection().getR​ealizationSuperClass​es()) {
+ if (EntityTools.getJava​Class(realization.ge​tSuperClass()).isAnn​otationPresent(Entit​y.class)) {
+ getEntityStore().get​PrimaryEntityIndex(E​ntityTools.getJavaCl​ass(realization.getS​uperClass())).couple​(entity, txn);
+ }
+ }
+
+ }
+
+ private void coupleBinaryAssociat​ionClassEnd(BinaryAs​sociationEnd baend, BeanPropertyAccessor beanPropertyAccessor, E associationClassEntity, Transaction txn) throws IOException {
+ if (/*baend != null &&*/ baend.isNavigatable()) {
+
+ Object baendOwnerEntity = beanPropertyAccessor​.get(associationClas​sEntity);
+ PrimaryEntityIndex baendOwnerPrimaryIndex = getEntityStore().get​PrimaryEntityIndex(b​aendOwnerEntity);
+
+ // couple baendOwner with association class ends
+ if (baend.getBinaryAsso​ciationQualification​s().size() > 0) {
+
+ if (baend.getMultiplici​ty().isMultiple()) {
+ Map<Object, Collection<Object>> map = (Map<Object, Collection<Object>>) EntityTools.getBeanP​ropertyAccessor(baen​d).get(baendOwnerEnt​ity);
+ boolean found = false;
+ for (Collection<Object> colletion : map.values()) {
+ if (colletion.contains(​associationClassEnti​ty)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new RuntimeException("The association class needs to be added to the qualified end of " + baend.toString());
+ }
+ } else {
+ Map<Object, Object> map = (Map<Object, Object>) EntityTools.getBeanP​ropertyAccessor(baen​d).get(baendOwnerEnt​ity);
+ if (map.values().contai​ns(associationClassE​ntity)) {
+ throw new RuntimeException("The association class needs to be added to the qualified end of " + baend.toString());
+ }
+ }
+
+
+ } else if (baend.getMultiplici​ty().isMultiple()) {
+ // ? to many
+ // todo check multiplicity and throw exception if invalid size in aend field value
+ Collection collection = (Collection) EntityTools.getBeanP​ropertyAccessor(baen​d).get(baendOwnerEnt​ity);
+ if (!collection.contain​s(associationClassEn​tity)) {
+ collection.add(assoc​iationClassEntity);
+
+ // ensure owner baend entity is added to/updated in the store
+ java.lang.Class baendOwnerClass = EntityTools.getJavaC​lass(baend.getOwnerC​lass());
+ Transaction.Delta baendOwnerDelta = txn.getPendingDelta(​baendOwnerClass);
+ if (baendOwnerPrimaryIn​dex.getObjectIdentit​y(baendOwnerEntity) == null
+ || (!baendOwnerDelta.ge​tCreated().containsV​alue(baendOwnerEntit​y) && !baendOwnerDelta.get​Updated().containsVa​lue(baendOwnerEntity​))) {
+ baendOwnerPrimaryIndex.put(txn, baendOwnerEntity);
+ }
+ }
+
+
+ } else {
+ // ? to one
+ // todo check multiplicity and throw exception if invalid size in aend field value
+ if (!associationClassEn​tity.equals(beanProp​ertyAccessor.get(bae​ndOwnerEntity))) {
+ beanPropertyAccessor​.set(baendOwnerEntit​y, associationClassEntity);
+
+ // ensure owner baend entity is added to/updated in the store
+ java.lang.Class baendOwnerClass = EntityTools.getJavaC​lass(baend.getOwnerC​lass());
+ Transaction.Delta baendOwnerDelta = txn.getPendingDelta(​baendOwnerClass);
+ if (baendOwnerPrimaryIn​dex.getObjectIdentit​y(baendOwnerEntity) == null
+ || (!baendOwnerDelta.ge​tCreated().containsV​alue(baendOwnerEntit​y) && !baendOwnerDelta.get​Updated().containsVa​lue(baendOwnerEntity​))) {
+ baendOwnerPrimaryIndex.put(txn, baendOwnerEntity);
+ }
+ }
+
+ }
+
+ // ensure association class end associate exists in the store
+ if (baendOwnerPrimaryIn​dex.getObjectIdentit​y(baendOwnerEntity) == null) {
+ baendOwnerPrimaryIndex.put(txn, baendOwnerEntity);
+ }
+
+
+ }
+ }
+
   /**
    * Makes sure that the other end(s) of the association is bound back to the from end, given it is naviagtable.
    *
@@ -1077,32 +1087,36 @@
       // has association class
 
       // todo I dont like this meta data
- BeanPropertyAccessor associationClassBean​PropertyAccessor = ((BeanPropertyAccessor[]) baend.getBinaryAssoc​iation().getMetaData​().get(BinaryAssocia​tionClassEnd.class))​[baend.getBinaryAsso​ciation().indexOf(ba​end)];
+ BeanPropertyAccessor associationClassEndB​eanPropertyAccessor = ((BeanPropertyAccessor[]) baend.getBinaryAssoc​iation().getMetaData​().get(BinaryAssocia​tionClassEnd.class))​[baend.getBinaryAsso​ciation().indexOf(ba​end)];
 
       if (baend.getBinaryAsso​ciationQualification​s().size() > 0) {
 
         if (baend.getMultiplici​ty().isMultiple()) {
           Map<Object, Collection<Object>> map = (Map<Object, Collection<Object>>) fieldValue;
- for (Map.Entry<Object, Collection<Object>> e : map.entrySet()) {
-
- // qualifier
- java.lang.Class _class = e.getKey().getClass();
+ for (Map.Entry<Object, Collection<Object>> qualifiedEntry : map.entrySet()) {
 
- // ensure qualifier is registred in transaction
- if (getEntityStore().is​EntityClass(_class) && !txn.getEntitiesByOI​D().containsValue(e.​getKey())) {
- getEntityStore().get​PrimaryEntityIndex(_​class).put(txn, e.getKey());
+ // ensure qualification entity is exists in the store
+ java.lang.Class qualifierClass = qualifiedEntry.getKe​y().getClass();
+ if (getEntityStore().is​EntityClass(qualifie​rClass)) {
+ PrimaryEntityIndex qpei = getEntityStore().get​PrimaryEntityIndex(q​ualifierClass);
+ if (qpei.getObjectIdent​ity(qualifiedEntry.g​etKey()) == null) {
+ qpei.put(txn, qualifiedEntry.getKey());
+ }
             }
 
- // associates
- for (Object associationClass : e.getValue()) {
+ // association classes
 
- if (!entity.equals(asso​ciationClassBeanProp​ertyAccessor.get(ass​ociationClass))) {
- associationClassBean​PropertyAccessor.set​(associationClass, entity);
+ for (Object associationClass : qualifiedEntry.getValue()) {
+ if (!entity.equals(asso​ciationClassEndBeanP​ropertyAccessor.get(​associationClass))) {
+ associationClassEndB​eanPropertyAccessor.​set(associationClass​, entity);
+ // re-register in transaction for creation or update
+ getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
               }
 
- // ensure association class is registred in transaction
- if (!txn.getEntitiesByO​ID().containsValue(a​ssociationClass)) {
- getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
+ // ensure association class exists in the store
+ PrimaryEntityIndex acpei = getEntityStore().get​PrimaryEntityIndex(a​ssociationClass);
+ if (acpei.getObjectIden​tity(associationClas​s) == null) {
+ acpei.put(txn, associationClass);
               }
 
             }
@@ -1110,26 +1124,31 @@
 
         } else {
           Map<Object, Object> map = (Map<Object, Object>) fieldValue;
- for (Map.Entry<Object, Object> e : map.entrySet()) {
-
- // qualifier
- java.lang.Class _class = e.getKey().getClass();
+ for (Map.Entry<Object, Object> qualifiedEntry : map.entrySet()) {
 
- // ensure qualifier is registred in transaction
- if (getEntityStore().is​EntityClass(_class) && !txn.getEntitiesByOI​D().containsValue(e.​getKey())) {
- getEntityStore().get​PrimaryEntityIndex(_​class).put(txn, e.getKey());
+ // ensure qualification entity is exists in the store
+ java.lang.Class qualifierClass = qualifiedEntry.getKe​y().getClass();
+ if (getEntityStore().is​EntityClass(qualifie​rClass)) {
+ PrimaryEntityIndex qpei = getEntityStore().get​PrimaryEntityIndex(q​ualifierClass);
+ if (qpei.getObjectIdent​ity(qualifiedEntry.g​etKey()) == null) {
+ qpei.put(txn, qualifiedEntry.getKey());
+ }
             }
 
- // associate
- Object associationClass = e.getValue();
+ // association class
+ Object associationClass = qualifiedEntry.getValue();
+
+ if (!entity.equals(asso​ciationClassEndBeanP​ropertyAccessor.get(​associationClass))) {
+ associationClassEndB​eanPropertyAccessor.​set(associationClass​, entity);
+ // re-register in transaction for creation or update
+ getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
 
- if (!entity.equals(asso​ciationClassBeanProp​ertyAccessor.get(ass​ociationClass))) {
- associationClassBean​PropertyAccessor.set​(associationClass, entity);
             }
 
- // ensure association class is registred in transaction
- if (!txn.getEntitiesByO​ID().containsValue(a​ssociationClass)) {
- getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
+ // ensure association class exists in the store
+ PrimaryEntityIndex acpei = getEntityStore().get​PrimaryEntityIndex(a​ssociationClass);
+ if (acpei.getObjectIden​tity(associationClas​s) == null) {
+ acpei.put(txn, associationClass);
             }
           }
 
@@ -1140,13 +1159,17 @@
         // todo check multiplicity and throw exception if invalid size in aend field value
         for (Object associationClass : (Collection<Object>) fieldValue) {
 
- if (!entity.equals(asso​ciationClassBeanProp​ertyAccessor.get(ass​ociationClass))) {
- associationClassBean​PropertyAccessor.set​(associationClass, entity);
+ if (!entity.equals(asso​ciationClassEndBeanP​ropertyAccessor.get(​associationClass))) {
+ associationClassEndB​eanPropertyAccessor.​set(associationClass​, entity);
+ // re-register in transaction for creation or update
+ getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
+
           }
 
- // ensure association class is registred in transaction
- if (!txn.getEntitiesByO​ID().containsValue(a​ssociationClass)) {
- getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
+ // ensure association class exists in the store
+ PrimaryEntityIndex acpei = getEntityStore().get​PrimaryEntityIndex(a​ssociationClass);
+ if (acpei.getObjectIden​tity(associationClas​s) == null) {
+ acpei.put(txn, associationClass);
           }
 
         }
@@ -1156,15 +1179,17 @@
 
         Object associationClass = fieldValue;
 
- if (!entity.equals(asso​ciationClassBeanProp​ertyAccessor.get(ass​ociationClass))) {
- associationClassBean​PropertyAccessor.set​(associationClass, entity);
- }
-
- // ensure association class is registred in transaction
- if (!txn.getEntitiesByO​ID().containsValue(a​ssociationClass)) {
+ if (!entity.equals(asso​ciationClassEndBeanP​ropertyAccessor.get(​associationClass))) {
+ associationClassEndB​eanPropertyAccessor.​set(associationClass​, entity);
+ // re-register in transaction for creation or update
           getEntityStore().get​PrimaryEntityIndex(a​ssociationClass).put​(txn, associationClass);
         }
 
+ // ensure association class exists in the store
+ PrimaryEntityIndex acpei = getEntityStore().get​PrimaryEntityIndex(a​ssociationClass);
+ if (acpei.getObjectIden​tity(associationClas​s) == null) {
+ acpei.put(txn, associationClass);
+ }
 
       }
 
@@ -1175,35 +1200,37 @@
       if (baend.getBinaryAsso​ciationQualification​s().size() > 0) {
         if (baend.getMultiplici​ty().isMultiple()) {
           // to qualified many
- for (Map.Entry<Object, Collection<Object>> qualificationEntry : ((Map<Object, Collection<Object>>) fieldValue).entrySet()) {
-
- // qualifier
- java.lang.Class _class = qualificationEntry.g​etKey().getClass();
+ for (Map.Entry<Object, Collection<Object>> qualifiedEntry : ((Map<Object, Collection<Object>>) fieldValue).entrySet()) {
 
- // ensure qualifier is registred in transaction
- if (getEntityStore().is​EntityClass(_class) && !txn.getEntitiesByOI​D().containsValue(qu​alificationEntry.get​Key())) {
- getEntityStore().get​PrimaryEntityIndex(_​class).put(txn, qualificationEntry.getKey());
+ // ensure qualification entity is exists in the store
+ java.lang.Class qualifierClass = qualifiedEntry.getKe​y().getClass();
+ if (getEntityStore().is​EntityClass(qualifie​rClass)) {
+ PrimaryEntityIndex qpei = getEntityStore().get​PrimaryEntityIndex(q​ualifierClass);
+ if (qpei.getObjectIdent​ity(qualifiedEntry.g​etKey()) == null) {
+ qpei.put(txn, qualifiedEntry.getKey());
+ }
             }
 
             // associates
- for (Object associate : qualificationEntry.getValue()) {
+ for (Object associate : qualifiedEntry.getValue()) {
               coupleOtherEnd(txn, associate, baend, entity);
             }
           }
         } else {
           // to qualified one
- for (Map.Entry<Object, Object> qualificationEntry : ((Map<Object, Object>) fieldValue).entrySet()) {
-
- // qualifier
- java.lang.Class _class = qualificationEntry.g​etKey().getClass();
+ for (Map.Entry<Object, Object> qualifiedEntry : ((Map<Object, Object>) fieldValue).entrySet()) {
 
- // ensure qualifier is registred in transaction
- if (getEntityStore().is​EntityClass(_class) && !txn.getEntitiesByOI​D().containsValue(qu​alificationEntry.get​Key())) {
- getEntityStore().get​PrimaryEntityIndex(_​class).put(txn, qualificationEntry.getKey());
+ // ensure qualification entity is exists in the store
+ java.lang.Class qualifierClass = qualifiedEntry.getKe​y().getClass();
+ if (getEntityStore().is​EntityClass(qualifie​rClass)) {
+ PrimaryEntityIndex qpei = getEntityStore().get​PrimaryEntityIndex(q​ualifierClass);
+ if (qpei.getObjectIdent​ity(qualifiedEntry.g​etKey()) == null) {
+ qpei.put(txn, qualifiedEntry.getKey());
+ }
             }
 
             // associate
- coupleOtherEnd(txn, qualificationEntry.getValue(), baend, entity);
+ coupleOtherEnd(txn, qualifiedEntry.getValue(), baend, entity);
           }
         }
 
@@ -1238,7 +1265,7 @@
   private void coupleOtherEnd(Transaction txn, Object otherEndEntity, BinaryAssociationEnd baend, Object thisEndEntity) throws IOException {
 
     if (baend.getBinaryAsso​ciation().getAssocia​tionClass() != null) {
- throw new RuntimeException("This should never occur");
+ throw new RuntimeException("Wrong method call! This baend contains an association class and should be handled by other code!");
     } else { // no association class
 
       if (baend.getOtherEnd()​.getBinaryAssociatio​nQualifications().si​ze() > 0) {
@@ -1264,6 +1291,9 @@
         Collection otherEndEntityCollection = (Collection) EntityTools.getBeanP​ropertyAccessor(baen​d.getOtherEnd()).get​(otherEndEntity);
         if (!otherEndEntityColl​ection.contains(this​EndEntity)) {
           otherEndEntityCollec​tion.add(thisEndEnti​ty);
+ // register other end in transaction for creation or update
+ getEntityStore().get​PrimaryEntityIndex(o​therEndEntity).put(t​xn, otherEndEntity);
+
         } else {
           // already set - no eternal loops please
         }
@@ -1273,6 +1303,9 @@
         Object otherEndEntityCurrentValue = otherEndEntityAccess​or.get(otherEndEntit​y);
         if (otherEndEntityCurrentValue == null) {
           otherEndEntityAccess​or.set(otherEndEntit​y, thisEndEntity);
+ // register other end in transaction for creation or update
+ getEntityStore().get​PrimaryEntityIndex(o​therEndEntity).put(t​xn, otherEndEntity);
+
         } else if (otherEndEntityCurre​ntValue.equals(thisE​ndEntity)) {
           // already set - no eternal loops please
         } else {
@@ -1281,10 +1314,6 @@
         }
       }
 
- // ensure other end is registred in transaction
- if (!txn.getEntitiesByO​ID().containsValue(o​therEndEntity)) {
- getEntityStore().get​PrimaryEntityIndex(o​therEndEntity).put(t​xn, otherEndEntity);
- }
     }
   }
 

Modified: trunk/src/main/java/​org/tigris/limax/Tra​nsaction.java
Url: http://limax.tigris.​org/source/browse/li​max/trunk/src/main/j​ava/org/tigris/limax​/Transaction.java?vi​ew=diff&rev=79​&p1=trunk/src/main​/java/org/tigris/lim​ax/Transaction.java​&p2=trunk/src/mai​n/java/org/tigris/li​max/Transaction.java​&r1=78&r2=79​
====================​====================​====================​==================
--- trunk/src/main/java/​org/tigris/limax/Tra​nsaction.java (original)
+++ trunk/src/main/java/​org/tigris/limax/Tra​nsaction.java 2007-09-20 00:37:52-0700
@@ -523,7 +523,7 @@
       for (BinaryAssociationEnd baend : reflection.getBinary​AssociationEnds()) {
         if (!baend.isNavigatable()) {
           // todo load via secondary entity index
- throw new RuntimeException("not implemented");
+ // throw new RuntimeException("not implemented");
         } else {
           Object associate = EntityTools.getBeanP​ropertyAccessor(baen​d).get(deletedEntity​);
           if (associate != null) {
@@ -560,7 +560,8 @@
           // [User]<#><-- {1} +author --[Publication]
           // here publication is a composite part of user
           // and should perhaps be deleted by some other code?
- throw new RuntimeException("not implemented");
+
+ //throw new RuntimeException("not implemented");
         } else {
 
           // navigate the the instance getters

Modified: trunk/src/test/java/​org/tigris/limax/Tes​tObjectStorage.java
Url: http://limax.tigris.​org/source/browse/li​max/trunk/src/test/j​ava/org/tigris/limax​/TestObjectStorage.j​ava?view=diff&re​v=79&p1=trunk/sr​c/test/java/org/tigr​is/limax/TestObjectS​torage.java&p2=t​runk/src/test/java/o​rg/tigris/limax/Test​ObjectStorage.java​&r1=78&r2=79
====================​====================​====================​==================
--- trunk/src/test/java/​org/tigris/limax/Tes​tObjectStorage.java (original)
+++ trunk/src/test/java/​org/tigris/limax/Tes​tObjectStorage.java 2007-09-20 00:37:52-0700
@@ -118,6 +118,9 @@
 
     txn = getStore().newTransaction();
     Content content2 = (Content) getStore().get(txn, content.getOid());
+
+ assertEquals(1, content2.getComments().size());
+
     getContents().delete(txn, content2);
     txn.commit();
 

Modified: trunk/src/test/java/​org/tigris/limax/uti​l/TestDenormalizer.j​ava
Url: http://limax.tigris.​org/source/browse/li​max/trunk/src/test/j​ava/org/tigris/limax​/util/TestDenormaliz​er.java?view=diff​&rev=79&p1=trun​k/src/test/java/org/​tigris/limax/util/Te​stDenormalizer.java​&p2=trunk/src/tes​t/java/org/tigris/li​max/util/TestDenorma​lizer.java&r1=78​&r2=79
====================​====================​====================​==================
--- trunk/src/test/java/​org/tigris/limax/uti​l/TestDenormalizer.j​ava (original)
+++ trunk/src/test/java/​org/tigris/limax/uti​l/TestDenormalizer.j​ava 2007-09-20 00:37:52-0700
@@ -97,11 +97,17 @@
     contentB.tag(bob, boring);
 
     store.put(txn, alice);
- store.put(txn, bob);
+
+ assertNotNull(alice.getOid());
+ assertNotNull(bob.getOid());
+ assertNotNull(conten​tA.getOid());
+ assertNotNull(conten​tB.getOid());
+ assertNotNull(fun.getOid());
+ assertNotNull(boring.getOid());
 
     txn.commit();
 
- System.currentTimeMillis();
+ // todo: search for denormalized qualifications etc
 
   }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r79 - trunk/src: main/java/org/tigris/limax test/java/org/tigris/limax test/java/org/tigris/limax/util wettin Karl Wettin 2007-09-20 00:37:53 PDT
Messages per page: