<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}&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}&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}&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 -->
/** 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)
RelationsDocListItem subj2 = item2.getSubject();
RelationsDocListItem obj1 = item1.getObject();
RelationsDocListItem obj2 = item2.getObject();
+
String subj1Csid = subj1.getCsid();
String subj2Csid = subj2.getCsid();
String subj1RefName = subj1.getRefName();
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;
}