From: Laramie Crocker Date: Sat, 23 Apr 2011 10:05:17 +0000 (+0000) Subject: CSPACE-3739 Updated Relations schema to store new fields, including subjectUri and... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=4218026425d4023191f54e82d20f23d26a9dbb52;p=tmp%2Fjakarta-migration.git CSPACE-3739 Updated Relations schema to store new fields, including subjectUri and objectUri, in nuxeo; Made dochandlers for Relations and AuthorityItem shuffle the new uri fields around correctly; modified DocumentModelHandler and AuthorityItemDocumentModelHandler to provide getUri(DocumentModel docModel); Installed XmlReplay tests for hierarchic authority work; Moved ITEMS to AuthorityClient, from various AuthorityClient impls. --- diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlReplayMasterTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlReplayMasterTest.java index a1508953d..eed0cfe65 100755 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlReplayMasterTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlReplayMasterTest.java @@ -14,7 +14,7 @@ import java.util.List; */ public class XmlReplayMasterTest extends XmlReplayTest { -// @Test + @Test public void runMaster() throws Exception { XmlReplay replay = createXmlReplayUsingIntegrationTestsModule(".."); List> list = replay.runMaster(XmlReplay.DEFAULT_MASTER_CONTROL); diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml index dfd9c1c4b..417a01dd6 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml @@ -66,15 +66,18 @@ - + - - + + + + --> - - + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml index e26e11267..c48d38088 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml @@ -285,8 +285,11 @@ johnWayneActor ${itemCSID} ${PersonParent.CSID} + /cspace-services/personauthorities/urn:cspace:name(CSPACE3739PersonAuthority)/items/${PersonParent.CSID} ${PersonChild.CSID} + /cspace-services/personauthorities/urn:cspace:name(CSPACE3739PersonAuthority)/items/${PersonChild.CSID} ${PersonChild2.CSID} + /cspace-services/personauthorities/urn:cspace:name(CSPACE3739PersonAuthority)/items/${PersonChild2.CSID} diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_POST.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_POST.xml index 7d75d8be4..b37fc2b58 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_POST.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_POST.xml @@ -37,6 +37,7 @@ ${parentCSID} + ${parentUri} Person John Wayne 2, the evil twin, Parent @@ -45,6 +46,7 @@ hasBroader ${childCSID} + ${childUri} Person John Wayne 2, the evil twin, child @@ -57,6 +59,7 @@ hasBroader + ${child2Uri} ${child2CSID} Person John Wayne 2, the evil twin, child diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-2.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-2.xml new file mode 100644 index 000000000..6ddcf829a --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-2.xml @@ -0,0 +1,16 @@ + + + + ${documentId1} + ${documentType1} + ${documentId2} + ${documentType2} + ${relationshipType} + ${relationshipType} + ${documentId1} + ${documentId2} + /my/long/uri/${documentId1} + /my/long/uri/${documentId2} + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/relation.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/relation.xml index 70d3d1535..0ce0f6dec 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/relation.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/relation.xml @@ -53,6 +53,54 @@ --> + + + + POST + /cspace-services/objectexit/ + relation/oe1.xml + + + POST + /cspace-services/objectexit/ + relation/oe1.xml + + + POST + /cspace-services/relations/ + relation/r-2.xml + + ${oe1.CSID} + ${itemCSID} + ObjectExit + ObjectExit + hasBroader + + + + GET + /cspace-services/relations/ + + + + + + POST + /cspace-services/relations/ + relation/r-2.xml + + 1234-5678 + ${itemCSID} + ObjectExit + ObjectExit + hasBroader + + + + GET + /cspace-services/relations/ + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml index 19568b721..4eb550625 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml @@ -34,8 +34,13 @@ File below this line have been ported. --> - + + + + diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index 6ca1012de..50231e04d 100644 --- a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +import org.collectionspace.services.client.AuthorityClient; import org.collectionspace.services.client.PayloadInputPart; import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; @@ -101,6 +102,12 @@ public abstract class AuthorityItemDocumentModelHandler this.inAuthority = inAuthority; } + @Override + public String getUri(DocumentModel docModel) { + return getServiceContextPath()+inAuthority+"/"+ AuthorityClient.ITEMS+"/"+getCsid(docModel); + } + + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) */ @@ -236,8 +243,9 @@ public abstract class AuthorityItemDocumentModelHandler DocumentModel documentModel = (wrapDoc.getWrappedObject()); String itemCsid = documentModel.getName(); - //TODO: create all relations.... UPDATE and CREATE will call. Updates AuthorityItem part - RelationsCommonList relationsCommonList = updateRelations(itemCsid, input); + //UPDATE and CREATE will call. Updates relations part + RelationsCommonList relationsCommonList = updateRelations(itemCsid, input, wrapDoc); + PayloadOutputPart payloadOutputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMON_LIST_NAME, relationsCommonList); ctx.setProperty(RelationClient.SERVICE_COMMON_LIST_NAME, payloadOutputPart); } @@ -250,28 +258,11 @@ public abstract class AuthorityItemDocumentModelHandler ((PoxPayloadOut)ctx.getOutput()).addPart(foo); } - //=================================================================== - /* - for (RelationsCommonList.RelationListItem parentListItem : parentList.getRelationListItem()) { - System.out.println(" parentListItems " + parentListItem); - //todo: if num-parents > 1 then complain. - //todo: if not found in update list, remove from system - //todo: if update list item not found in parent list, add to system. - } - for (RelationsCommonList.RelationListItem childListItem : childList.getRelationListItem()) { - System.out.println(" childListItem: " + childListItem); - //todo: if not found in update list, remove from system - //todo: if update list item not found in child list, add to system. - } - - - - */ - public RelationsCommonList updateRelations(String itemCSID, PoxPayloadIn input) throws Exception { + public RelationsCommonList updateRelations(String itemCSID, PoxPayloadIn input, DocumentWrapper wrapDoc) + throws Exception { PayloadInputPart part = input.getPart(RelationClient.SERVICE_COMMON_LIST_NAME); //input.getPart("relations_common"); if (part == null) { - //System.out.println("Nothing to do in updateRelations: " + input); - return null; + return null; //nothing to do--they didn't send a list of relations. } RelationsCommonList relationsCommonListBody = (RelationsCommonList) part.getBody(); @@ -316,14 +307,18 @@ public abstract class AuthorityItemDocumentModelHandler List childList = childListOuter.getRelationListItem(); List parentList = parentListOuter.getRelationListItem(); + DocumentModel docModel = wrapDoc.getWrappedObject(); + for (RelationsCommonList.RelationListItem inboundItem : inboundList) { if (inboundItem.getObject().getCsid().equalsIgnoreCase(CommonAPI.AuthorityItemCSID_REPLACE)){ inboundItem.setObjectCsid(itemCSID); inboundItem.getObject().setCsid(itemCSID); + inboundItem.getObject().setUri(getUri(docModel)); } if (inboundItem.getSubject().getCsid().equalsIgnoreCase(CommonAPI.AuthorityItemCSID_REPLACE)){ inboundItem.setSubjectCsid(itemCSID); inboundItem.getSubject().setCsid(itemCSID); + inboundItem.getSubject().setUri(getUri(docModel)); } if (inboundItem.getObject().getCsid().equals(itemCSID) && inboundItem.getPredicate().equals(HAS_BROADER)) { //then this is an item that says we have a child. @@ -350,17 +345,23 @@ public abstract class AuthorityItemDocumentModelHandler deleteRelations(parentList, ctx); //todo: there are items appearing on both lists....april 20. deleteRelations(childList, ctx); createRelations(actionList, ctx); - + //We return all elements on the inbound list, since we have just worked to make them exist in the system + // and be non-redundant, etc. That list came from relationsCommonListBody, so it is still attached to it, just pass that back. return relationsCommonListBody; } + // this method calls the RelationResource to have it create the relations and persist them. private void createRelations(List inboundList, ServiceContext ctx){ for (RelationsCommonList.RelationListItem item : inboundList) { RelationsCommon rc = new RelationsCommon(); //rc.setCsid(item.getCsid()); - String itemCsid = item.getSubject().getCsid(); - rc.setDocumentId1(itemCsid); - rc.setSubjectCsid(itemCsid); + //todo: assignTo(item, rc); + RelationsDocListItem itemSubject = item.getSubject(); + RelationsDocListItem itemObject = item.getObject(); + + String subjectCsid = itemSubject.getCsid(); + rc.setDocumentId1(subjectCsid); + rc.setSubjectCsid(subjectCsid); String objCsid = item.getObject().getCsid(); rc.setDocumentId2(objCsid); @@ -368,10 +369,14 @@ public abstract class AuthorityItemDocumentModelHandler rc.setRelationshipType(item.getPredicate()); //RelationshipType foo = (RelationshipType.valueOf(item.getPredicate())) ; - //rc.setPredicate(foo); + //rc.setPredicate(foo); //this must be one of the type found in the enum in services/jaxb/src/main/resources/relations_common.xsd + + rc.setDocumentType1(itemSubject.getDocumentType()); + rc.setDocumentType2(itemObject.getDocumentType()); + + rc.setSubjectUri(itemSubject.getUri()); + rc.setObjectUri(itemObject.getUri()); - rc.setDocumentType1(item.getSubject().getDocumentType()); - rc.setDocumentType2(item.getObject().getDocumentType()); PoxPayloadOut payloadOut = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart outputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMONPART_NAME, rc); diff --git a/services/client/src/main/java/org/collectionspace/services/client/AuthorityClient.java b/services/client/src/main/java/org/collectionspace/services/client/AuthorityClient.java index b2df0df55..4fe239ced 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/AuthorityClient.java +++ b/services/client/src/main/java/org/collectionspace/services/client/AuthorityClient.java @@ -14,6 +14,10 @@ import org.jboss.resteasy.client.ClientResponse; */ public interface AuthorityClient> extends CollectionSpacePoxClient { + + /** The uri path element for items in an authority */ + public static String ITEMS = "items"; //used to construct uri's in service paths for authorities. + /* * Basic CRUD operations */ diff --git a/services/common/src/main/java/org/collectionspace/services/common/relation/RelationJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/relation/RelationJAXBSchema.java index d8725f76c..73e2fe88e 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/relation/RelationJAXBSchema.java +++ b/services/common/src/main/java/org/collectionspace/services/common/relation/RelationJAXBSchema.java @@ -56,6 +56,11 @@ public interface RelationJAXBSchema { /** The Constant RELATIONSHIP_TYPE_DISPLAYNAME. */ final static String RELATIONSHIP_TYPE_DISPLAYNAME = "predicateDisplayName"; + + final static String subjectUri = "subjectUri"; + + final static String objectUri = "objectUri"; + } diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java index 977605cdc..2fd29648a 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java @@ -68,6 +68,10 @@ public abstract class DocumentModelHandler public String getCsid(DocumentModel docModel) { return NuxeoUtils.getCsid(docModel); } + + public String getUri(DocumentModel docModel) { + return getServiceContextPath()+getCsid(docModel); + } /** * getRepositorySession returns Nuxeo Repository Session * @return diff --git a/services/jaxb/src/main/resources/relations_common.xsd b/services/jaxb/src/main/resources/relations_common.xsd index 32e60ad90..e3e3cff63 100644 --- a/services/jaxb/src/main/resources/relations_common.xsd +++ b/services/jaxb/src/main/resources/relations_common.xsd @@ -35,6 +35,8 @@ + + diff --git a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java index 21714f5f3..ba2636870 100644 --- a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java +++ b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java @@ -54,7 +54,6 @@ public class LocationAuthorityClient extends AuthorityClientImpl - +` @@ -41,11 +41,15 @@ - + + + + + @@ -58,6 +62,7 @@ + diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java index c17d4379d..e6d08e973 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java @@ -159,11 +159,20 @@ public class RelationDocumentModelHandler String subjectCsid = relationListItem.getSubjectCsid(); String documentType = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_1); RelationsDocListItem subject = createRelationsDocListItem(ctx, sbt, subjectCsid, tReader, documentType); + + //Object o1 = docModel.getProperty(ctx.getCommonPartLabel(), "subject"); + //Object o2 = docModel.getProperty(ctx.getCommonPartLabel(), "object"); + + String subjectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.subjectUri); + subject.setUri(subjectUri); relationListItem.setSubject(subject); String objectCsid = relationListItem.getObjectCsid(); documentType = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_2); RelationsDocListItem object = createRelationsDocListItem(ctx, sbt, objectCsid, tReader, documentType); + + String objectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.objectUri); + object.setUri(objectUri); relationListItem.setObject(object); return relationListItem; diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java index e3f04d088..d8646d5b9 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java @@ -44,7 +44,6 @@ public class VocabularyClient extends AuthorityClientImpl