]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5540: Relationships in relations-payloads to structured objects only differing...
authorRichard Millet <remillet@berkeley.edu>
Mon, 24 Sep 2012 23:22:21 +0000 (16:22 -0700)
committerRichard Millet <remillet@berkeley.edu>
Mon, 24 Sep 2012 23:22:21 +0000 (16:22 -0700)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-hierarchy-csid.xml
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java

index b9c62eff260df56de04db17496da893e028ab8fa..173931fb63214a9386fb85535d248995c2ccfcba 100644 (file)
             <expectedCodes>200</expectedCodes>
         </test>
         
+        <!-- Verify that the value of the relationshipMetaType field was set -->
+        <!-- correctly and can be successfully retrieved -->
+        <test ID="GetRelationshipMetaTypeWithSetValue">
+            <method>GET</method>
+            <uri>/cspace-services/relations?sbj=${CreateBlackRook.CSID}&amp;obj=${CreateBagOfBlackChessPieces.CSID}</uri>
+            <expectedCodes>200</expectedCodes>
+            <response>
+                <expected level="ADDOK" />
+                <filename>collectionobject/hierarchy/res/relationship-metatype.res.xml</filename>
+                <vars>
+                    <var ID="relationshipMetaType">${UpdateBlackRookWithRelations.relationshipMetaType}</var>
+                    <var ID="parentCSID">${CreateBagOfBlackChessPieces.CSID}</var>
+                    <var ID="childCSID">${CreateBlackRook.CSID}</var>
+                </vars>
+            </response>
+        </test>
+        
+        <!-- Update the relationship metatype with a different value, but keep the relationships the same -->
+        <test ID="UpdateBlackRooksRelationsWithDiffMetatype">
+            <method>PUT</method>
+            <uri>/cspace-services/collectionobjects/${CreateBlackRook.CSID}</uri>
+            <filename>collectionobject/hierarchy/4-collectionobject-update-with-parent-child-csids.xml</filename>
+            <vars>
+                <var ID="distinguishingFeatures">This black rook is nearly intact, save for two tiny fragments.</var>
+                <var ID="currentItemCSID">${CreateBlackRook.CSID}</var>
+                <var ID="parentCSID">${CreateBagOfBlackChessPieces.CSID}</var>
+                <var ID="child1CSID">${CreateBlackRookFragment1.CSID}</var>
+                <var ID="child2CSID">${CreateBlackRookFragment2.CSID}</var>
+                <var ID="relationshipMetaType">derivative</var>
+            </vars>
+            <expectedCodes>200</expectedCodes>
+        </test>
+        
+        <!-- Verify that the value of the relationshipMetaType field was set -->
+        <!-- correctly and can be successfully retrieved -->
+        <test ID="GetRelationshipMetaTypeWithDerivativeValue">
+            <method>GET</method>
+            <uri>/cspace-services/relations?sbj=${CreateBlackRook.CSID}&amp;obj=${CreateBagOfBlackChessPieces.CSID}</uri>
+            <expectedCodes>200</expectedCodes>
+            <response>
+                <expected level="ADDOK" />
+                <filename>collectionobject/hierarchy/res/relationship-metatype.res.xml</filename>
+                <vars>
+                    <var ID="relationshipMetaType">${UpdateBlackRooksRelationsWithDiffMetatype.relationshipMetaType}</var>
+                    <var ID="parentCSID">${CreateBagOfBlackChessPieces.CSID}</var>
+                    <var ID="childCSID">${CreateBlackRook.CSID}</var>
+                </vars>
+            </response>
+        </test>
     
         <!--
             Read hierarchical relations via three query parameters now
         </test>
         
           
-        <!-- Verify that the value of the relationshipMetaType field was set -->
-        <!-- correctly and can be successfully retrieved -->
-        <test ID="GetRelationshipMetaType">
-            <method>GET</method>
-            <uri>/cspace-services/relations?sbj=${CreateBlackQueen.CSID}&amp;obj=${CreateBagOfBlackChessPieces.CSID}</uri>
-            <expectedCodes>200</expectedCodes>
-            <response>
-                <expected level="ADDOK" />
-                <filename>collectionobject/hierarchy/res/relationship-metatype.res.xml</filename>
-                <vars>
-                    <var ID="relationshipMetaType">${CreateBagOfBlackChessPieces.relationshipMetaType}</var>
-                    <var ID="parentCSID">${CreateBagOfBlackChessPieces.CSID}</var>
-                    <var ID="childCSID">${CreateBlackQueen.CSID}</var>
-                </vars>
-            </response>
-        </test>
     
         <!-- Clean up any remaining records that were NOT automatically deleted by autoDeletePOSTS -->
         
index fa70a28f6dacea4bdd7f4f4ba5ca97c7947b6f8b..5af6540c670af4a70690284b324abc19a659203f 100644 (file)
@@ -104,6 +104,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
     /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(RemoteDocumentModelHandlerImpl.class);
     private final static String CR = "\r\n";
+    private final static String EMPTYSTR = "";
     
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.AbstractDocumentHandlerImpl#setServiceContext(org.collectionspace.services.common.context.ServiceContext)
@@ -1082,6 +1083,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         RelationsDocListItem subj2 = item2.getSubject();
         RelationsDocListItem obj1 = item1.getObject();
         RelationsDocListItem obj2 = item2.getObject();
+        
         String subj1Csid = subj1.getCsid();
         String subj2Csid = subj2.getCsid();
         String subj1RefName = subj1.getRefName();
@@ -1091,16 +1093,22 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         String obj2Csid = obj2.getCsid();
         String obj1RefName = obj1.getRefName();
         String obj2RefName = obj2.getRefName();
-
-        boolean isEqual = 
-                          (subj1Csid.equals(subj2Csid) || ((subj2Csid==null)  && subj1RefName.equals(subj2RefName)))
+        
+        String item1Metatype = item1.getRelationshipMetaType();
+        item1Metatype = item1Metatype != null ? item1Metatype : EMPTYSTR;
+        
+        String item2Metatype = item2.getRelationshipMetaType();
+        item2Metatype = item2Metatype != null ? item2Metatype : EMPTYSTR;
+        
+        boolean isEqual = (subj1Csid.equals(subj2Csid) || ((subj2Csid==null)  && subj1RefName.equals(subj2RefName)))
                 && (obj1Csid.equals(obj1Csid)   || ((obj2Csid==null)   && obj1RefName.equals(obj2RefName)))
                 // predicate is proper, but still allow relationshipType
                 && (item1.getPredicate().equals(item2.getPredicate())
                        ||  ((item2.getPredicate()==null)  && item1.getRelationshipType().equals(item2.getRelationshipType())))
                 // Allow missing docTypes, so long as they do not conflict
                 && (obj1.getDocumentType().equals(obj2.getDocumentType()) || obj2.getDocumentType()==null)
-                && (subj1.getDocumentType().equals(subj2.getDocumentType()) || subj2.getDocumentType()==null);
+                && (subj1.getDocumentType().equals(subj2.getDocumentType()) || subj2.getDocumentType()==null)
+                && (item1Metatype.equalsIgnoreCase(item2Metatype));
         return isEqual;
     }