From 61432ce980e657188730003dcfc02d998cf692f8 Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Thu, 17 Nov 2011 06:56:32 +0000 Subject: [PATCH] CSPACE-4041 Cleaned up duplicate fields in relations. Cleaned up the associated test files. --- .../test/CollectionSpaceIntegrationTest.java | 22 +++--- .../test/RelationIntegrationTest.java | 8 +- .../test-data/xmlreplay/person/person.xml | 16 ++-- .../person/persons_common_w_relations.xml | 8 +- .../person/persons_common_w_relations_2.xml | 4 +- .../person/persons_common_w_relations_3.xml | 8 +- .../test-data/xmlreplay/relation/r-1.xml | 8 +- .../test-data/xmlreplay/relation/r-2.xml | 14 ++-- .../test-data/xmlreplay/relation/relation.xml | 32 ++++---- .../test/CollectionSpacePerformanceTest.java | 20 ++--- .../AuthorityItemDocumentModelHandler.java | 6 -- .../nuxeo/CreateAndLinkLoanOutBatchJob.java | 8 +- .../tenants/tenant-bindings-proto.xml | 4 +- .../query/nuxeo/QueryManagerNuxeoImpl.java | 8 +- .../common/relation/RelationJAXBSchema.java | 28 ++----- .../common/relation/nuxeo/RelationsUtils.java | 10 ++- .../src/main/resources/relations_common.xsd | 4 - .../resources/OSGI-INF/layouts-contrib.xml | 32 ++++---- .../resources/schemas/relations_common.xsd | 4 - .../client/test/RelationServiceTest.java | 30 ++++---- .../nuxeo/RelationDocumentModelHandler.java | 75 ++++++------------- .../nuxeo/RelationValidatorHandler.java | 22 +----- 22 files changed, 151 insertions(+), 220 deletions(-) diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java index b3fc2ca00..ecd4b2fa9 100755 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java @@ -112,19 +112,21 @@ public abstract class CollectionSpaceIntegrationTest { * Fill relation. * * @param relation the relation - * @param documentId1 the document id1 - * @param documentType1 the document type1 - * @param documentId2 the document id2 - * @param documentType2 the document type2 + * @param subjectCsid the document id1 + * @param subjectDocumentType the document type1 + * @param objectCsid the document id2 + * @param objectDocumentType the document type2 * @param rt the rt */ - void fillRelation(RelationsCommon relation, String documentId1, String documentType1, - String documentId2, String documentType2, String rt) + void fillRelation(RelationsCommon relation, + String subjectCsid, String subjectDocumentType, + String objectCsid, String objectDocumentType, + String rt) { - relation.setDocumentId1(documentId1); - relation.setDocumentType1(documentType1); - relation.setDocumentId2(documentId2); - relation.setDocumentType2(documentType2); + relation.setSubjectCsid(subjectCsid); + relation.setSubjectDocumentType(subjectDocumentType); + relation.setObjectCsid(objectCsid); + relation.setObjectDocumentType(objectDocumentType); relation.setRelationshipType(rt); } diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java index c4eb6f383..8736756a8 100755 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java @@ -179,9 +179,9 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { multiPartResponse.releaseConnection(); } - Assert.assertEquals(resultRelation.getDocumentId1(), collectionObjectCsid); + Assert.assertEquals(resultRelation.getSubjectCsid(), collectionObjectCsid); Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString()); - Assert.assertEquals(resultRelation.getDocumentId2(), intakeCsid); + Assert.assertEquals(resultRelation.getObjectCsid(), intakeCsid); System.out.println(); i++; } @@ -308,9 +308,9 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { multiPartResponse.releaseConnection(); } - Assert.assertEquals(resultRelation.getDocumentId1(), intakeCsid); + Assert.assertEquals(resultRelation.getSubjectCsid(), intakeCsid); Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString()); - Assert.assertEquals(resultRelation.getDocumentId2(), collectionObjectCsid); + Assert.assertEquals(resultRelation.getObjectCsid(), collectionObjectCsid); System.out.println(); i++; } 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 fd72e30e7..3be5d13b0 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 @@ -60,10 +60,10 @@ /cspace-services/relations/ relation/r-1.xml - ${Person1.CSID} - ${Person2.CSID} - Persons - Persons + ${Person1.CSID} + ${Person2.CSID} + Persons + Persons hasBroader @@ -76,10 +76,10 @@ - ${Person2.CSID} - ${Person1.CSID} - Persons - Persons + ${Person2.CSID} + ${Person1.CSID} + Persons + Persons hasNarrower diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations.xml index f4be7468d..2934776f4 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations.xml @@ -30,8 +30,8 @@ subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object ${myCSID} - Person - Person + Person + Person hasBroader hasBroader hasBroader @@ -49,8 +49,8 @@ ${childCSID} - Person - Person + Person + Person hasBroader hasBroader hasBroader diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_2.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_2.xml index 85f01c6de..c332ccac2 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_2.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_2.xml @@ -30,8 +30,8 @@ subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object ${myCSID} - Person - Person + Person + Person hasBroader hasBroader hasBroader diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_3.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_3.xml index 37916fa93..a573e0f7d 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_3.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/persons_common_w_relations_3.xml @@ -30,8 +30,8 @@ subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object ${childCSID} - Person - Person + Person + Person hasBroader hasBroader hasBroader @@ -49,8 +49,8 @@ ${child2CSID} - Person - Person + Person + Person hasBroader hasBroader hasBroader diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-1.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-1.xml index bf6119112..f96366b8a 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-1.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/relation/r-1.xml @@ -3,10 +3,10 @@ - ${documentId1} - ${documentType1} - ${documentId2} - ${documentType1} + ${subjectCsid} + ${subjectDocumentType} + ${objectCsid} + ${objectDocumentType} ${relationshipType} ${relationshipType} 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 index 6ddcf829a..540692a92 100644 --- 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 @@ -1,16 +1,14 @@ - ${documentId1} - ${documentType1} - ${documentId2} - ${documentType2} + ${subjectCsid} + ${subjectDocumentType} + /my/long/uri/${subjectCsid} + ${objectCsid} + ${objectDocumentType} + /my/long/uri/${objectCsid} ${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 52f010414..b085b3251 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 @@ -21,10 +21,10 @@ /cspace-services/relations/ relation/r-1.xml - ${oe1.CSID} - ${oe2.CSID} - objectexit - objectexit + ${oe1.CSID} + ${oe2.CSID} + objectexit + objectexit hasBroader @@ -34,10 +34,10 @@ relation/r-1.xml - ${oe2.CSID} - ${oe1.CSID} - objectexit - objectexit + ${oe2.CSID} + ${oe1.CSID} + objectexit + objectexit hasBroader @@ -70,10 +70,10 @@ /cspace-services/relations/ relation/r-2.xml - ${oe1.CSID} - ${itemCSID} - ObjectExit - ObjectExit + ${oe1.CSID} + ${itemCSID} + ObjectExit + ObjectExit hasBroader @@ -89,10 +89,10 @@ /cspace-services/relations/ relation/r-2.xml - 1234-5678 - ${itemCSID} - ObjectExit - ObjectExit + 1234-5678 + ${itemCSID} + ObjectExit + ObjectExit hasBroader diff --git a/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java b/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java index 74d161446..ae9cf2115 100644 --- a/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java +++ b/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java @@ -112,19 +112,19 @@ public abstract class CollectionSpacePerformanceTest { * Fill relation. * * @param relation the relation - * @param documentId1 the document id1 - * @param documentType1 the document type1 - * @param documentId2 the document id2 - * @param documentType2 the document type2 + * @param subjectCsid the document id1 + * @param subjectDocumentType the document type1 + * @param objectCsid the document id2 + * @param objectDocumentType the document type2 * @param rt the rt */ - void fillRelation(RelationsCommon relation, String documentId1, String documentType1, - String documentId2, String documentType2, RelationshipType rt) + void fillRelation(RelationsCommon relation, String subjectCsid, String subjectDocumentType, + String objectCsid, String objectDocumentType, RelationshipType rt) { - relation.setDocumentId1(documentId1); - relation.setDocumentType1(documentType1); - relation.setDocumentId2(documentId2); - relation.setDocumentType2(documentType2); + relation.setSubjectCsid(subjectCsid); + relation.setSubjectDocumentType(subjectDocumentType); + relation.setSubjectCsid(objectCsid); + relation.setObjectDocumentType(objectDocumentType); relation.setRelationshipType(rt.toString()); } diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index a41a6451b..40f0b1249 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -787,11 +787,9 @@ public abstract class AuthorityItemDocumentModelHandler // Either value might be null for for each of Subject and Object String subjectCsid = itemSubject.getCsid(); rc.setSubjectCsid(subjectCsid); - rc.setDocumentId1(subjectCsid); // populate legacy field for backward compatibility String objCsid = itemObject.getCsid(); rc.setObjectCsid(objCsid); - rc.setDocumentId2(objCsid); // populate legacy field for backward compatibility rc.setSubjectRefName(itemSubject.getRefName()); rc.setObjectRefName(itemObject.getRefName()); @@ -803,9 +801,6 @@ public abstract class AuthorityItemDocumentModelHandler // This is superfluous, since it will be fetched by the Relations Create logic. rc.setSubjectDocumentType(itemSubject.getDocumentType()); rc.setObjectDocumentType(itemObject.getDocumentType()); - // populate legacy fields for backward compatibility - rc.setDocumentType1(itemSubject.getDocumentType()); - rc.setDocumentType2(itemObject.getDocumentType()); // This is superfluous, since it will be fetched by the Relations Create logic. rc.setSubjectUri(itemSubject.getUri()); @@ -817,7 +812,6 @@ public abstract class AuthorityItemDocumentModelHandler PoxPayloadOut payloadOut = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart outputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMONPART_NAME, rc); payloadOut.addPart(outputPart); - //System.out.println("\r\n==== TO CREATE: "+rc.getDocumentId1()+"==>"+rc.getPredicate()+"==>"+rc.getDocumentId2()); RelationResource relationResource = new RelationResource(); Object res = relationResource.create(ctx.getResourceMap(), ctx.getUriInfo(), payloadOut.toXML()); //NOTE ui recycled from above to pass in unknown query params. diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java index fcaa5e616..808976073 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java @@ -153,10 +153,10 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable { String relationPayload = "" + "" - + ""+loanCSID+"" - + ""+LOAN_DOCTYPE+"" - + ""+toCSID+"" - + ""+context.getDocType()+"" + + ""+loanCSID+"" + + ""+LOAN_DOCTYPE+"" + + ""+toCSID+"" + + ""+context.getDocType()+"" + ""+RELATION_TYPE+"" + ""+RELATION_PREDICATE_DISP+"" + ""; diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml index 4bdeb869c..756036359 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml @@ -2398,7 +2398,7 @@ objectNameProperty - documentId1 + subjectCsid objectNumberProperty @@ -2417,7 +2417,7 @@ relations_common - documentid1,documentid2 + subjectcsid,objectcsid diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java b/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java index e7a8282c8..a2b50118a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java @@ -98,7 +98,7 @@ public class QueryManagerNuxeoImpl implements IQueryManager { RepositoryInstance repoSession = client.openRepository(); DocumentModelList docModelList = repoSession - .query("SELECT * FROM Relation WHERE relation:relationtype.documentId1='updated-Subject-1'"); + .query("SELECT * FROM Relation WHERE relations_common:subjectCsid='updated-Subject-1'"); // DocumentModelList docModelList = // repoSession.query("SELECT * FROM Relation"); // DocumentModelList docModelList = @@ -109,9 +109,9 @@ public class QueryManagerNuxeoImpl implements IQueryManager { System.out.println(docModel.getPathAsString()); System.out.println(docModel.getName()); System.out.println(docModel.getPropertyValue("dc:title")); - // System.out.println("documentId1=" + - // docModel.getProperty("relation", - // "relationtype/documentId1").toString()); + // System.out.println("subjectCsid=" + + // docModel.getProperty("relations_common", + // "subjectCsid").toString()); } } catch (Exception e) { 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 f5c8e2f34..c28d367c5 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 @@ -39,33 +39,21 @@ public interface RelationJAXBSchema { /** The Constant CSID. */ final static String CSID = "csid"; - /** The Constant DOCUMENT_ID_1. */ - final static String DOCUMENT_ID_1 = "documentId1"; - - /** The Constant DOCUMENT_TYPE_1. */ - final static String DOCUMENT_TYPE_1 = "documentType1"; - - /** The Constant DOCUMENT_ID_2. */ - final static String DOCUMENT_ID_2 = "documentId2"; - - /** The Constant DOCUMENT_TYPE_2. */ - final static String DOCUMENT_TYPE_2 = "documentType2"; - /** The Constant RELATIONSHIP_TYPE. */ final static String RELATIONSHIP_TYPE = "relationshipType"; /** The Constant RELATIONSHIP_TYPE_DISPLAYNAME. */ final static String RELATIONSHIP_TYPE_DISPLAYNAME = "predicateDisplayName"; - final static String SUBJECT_URI = "subjectUri"; - final static String SUBJECT_CSID = "subjectCsid"; - final static String SUBJECT_REFNAME = "subjectRefName"; - final static String SUBJECT_DOCTYPE = "subjectDocumentType"; + final static String SUBJECT_URI = "subjectUri"; + final static String SUBJECT_CSID = "subjectCsid"; + final static String SUBJECT_REFNAME = "subjectRefName"; + final static String SUBJECT_DOCTYPE = "subjectDocumentType"; - final static String OBJECT_URI = "objectUri"; - final static String OBJECT_CSID = "objectCsid"; - final static String OBJECT_REFNAME = "objectRefName"; - final static String OBJECT_DOCTYPE = "objectDocumentType"; + final static String OBJECT_URI = "objectUri"; + final static String OBJECT_CSID = "objectCsid"; + final static String OBJECT_REFNAME = "objectRefName"; + final static String OBJECT_DOCTYPE = "objectDocumentType"; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/relation/nuxeo/RelationsUtils.java b/services/common/src/main/java/org/collectionspace/services/common/relation/nuxeo/RelationsUtils.java index 2d4240b0d..3c1b66424 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/relation/nuxeo/RelationsUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/relation/nuxeo/RelationsUtils.java @@ -58,15 +58,16 @@ public class RelationsUtils { StringBuilder stringBuilder = new StringBuilder(); if (subject != null) { stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" + - RelationJAXBSchema.DOCUMENT_ID_1 + " = " + "'" + subject + "'"); + RelationJAXBSchema.SUBJECT_CSID + " = " + "'" + subject + "'"); } if (subjectType != null) { if (stringBuilder.length() > 0) { stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND); } + // BUG - this should use the new field RelationJAXBSchema.SUBJECT_DOCTYPE stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" + - RelationJAXBSchema.DOCUMENT_TYPE_1 + " = " + "'" + subjectType + "'"); + RelationJAXBSchema.SUBJECT_DOCTYPE + " = " + "'" + subjectType + "'"); } if (predicate != null) { @@ -82,15 +83,16 @@ public class RelationsUtils { stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND); } stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" + - RelationJAXBSchema.DOCUMENT_ID_2 + " = " + "'" + object + "'"); + RelationJAXBSchema.OBJECT_CSID + " = " + "'" + object + "'"); } if (objectType != null) { if (stringBuilder.length() > 0) { stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND); } + // BUG - this should use the new field RelationJAXBSchema.OBJECT_DOCTYPE stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" + - RelationJAXBSchema.DOCUMENT_TYPE_2 + " = " + "'" + objectType + "'"); + RelationJAXBSchema.OBJECT_DOCTYPE + " = " + "'" + objectType + "'"); } if (stringBuilder.length() > 0) { diff --git a/services/jaxb/src/main/resources/relations_common.xsd b/services/jaxb/src/main/resources/relations_common.xsd index bccb241b7..48e5fe1f3 100644 --- a/services/jaxb/src/main/resources/relations_common.xsd +++ b/services/jaxb/src/main/resources/relations_common.xsd @@ -24,10 +24,6 @@ - - - - diff --git a/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/OSGI-INF/layouts-contrib.xml index ff58c8e36..57e5f09a8 100644 --- a/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/OSGI-INF/layouts-contrib.xml +++ b/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -25,10 +25,10 @@ relationshipType - documentId1 - documentType1 - documentId2 - documentType2 + subjectCsid + subjectDocumentType + objectCsid + objectDocumentType @@ -44,52 +44,52 @@ - + - + true - documentId1 + subjectCsid dataInputText - + - + true - documentType1 + subjectDocumentType dataInputText - + - + true - documentId2 + objectCsid dataInputText - + - + true - documentType2 + objectDocumentType dataInputText diff --git a/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/schemas/relations_common.xsd b/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/schemas/relations_common.xsd index 6c28e5cea..765417009 100644 --- a/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/schemas/relations_common.xsd +++ b/services/relation/3rdparty/nuxeo-platform-cs-relation/src/main/resources/schemas/relations_common.xsd @@ -34,14 +34,10 @@ - - - - diff --git a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java index 76f0254c0..37309dded 100644 --- a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java +++ b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java @@ -229,7 +229,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { String identifier = createIdentifier(); RelationsCommon relationsCommon = createRelationsCommon(identifier); // Make the subject ID equal to the object ID - relationsCommon.setDocumentId1(relationsCommon.getDocumentId2()); + relationsCommon.setSubjectCsid(relationsCommon.getObjectCsid()); PoxPayloadOut multipart = createRelationInstance(relationsCommon); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -618,13 +618,13 @@ public class RelationServiceTest extends AbstractServiceTestImpl { final String msg2 = "Data in updated object was not correctly computed."; Assert.assertEquals( - updatedRelationCommon.getDocumentId1(), newSubjectId, msg); + updatedRelationCommon.getSubjectCsid(), newSubjectId, msg); Assert.assertEquals( - updatedRelationCommon.getDocumentType1(), newSubjectDocType, msg2); + updatedRelationCommon.getSubjectDocumentType(), newSubjectDocType, msg2); Assert.assertEquals( - updatedRelationCommon.getDocumentId2(), newObjectId, msg); + updatedRelationCommon.getObjectCsid(), newObjectId, msg); Assert.assertEquals( - updatedRelationCommon.getDocumentType2(), newObjectDocType, msg2); + updatedRelationCommon.getObjectDocumentType(), newObjectDocType, msg2); Assert.assertEquals( updatedRelationCommon.getPredicateDisplayName(), relationCommon.getPredicateDisplayName(), msg); @@ -936,21 +936,21 @@ public class RelationServiceTest extends AbstractServiceTestImpl { * Fills the relation. * * @param relationCommon the relation - * @param documentId1 the document id1 - * @param documentType1 the document type1 - * @param documentId2 the document id2 - * @param documentType2 the document type2 + * @param subjectCsid the subject document id + * @param subjectDocumentType the subject document type + * @param objectCsid the object document id + * @param objectDocumentType the object document type * @param rt the rt */ private void fillRelation(RelationsCommon relationCommon, - String documentId1, String documentType1, - String documentId2, String documentType2, + String subjectCsid, String subjectDocumentType, + String objectCsid, String objectDocumentType, String rt, String rtDisplayName) { - relationCommon.setDocumentId1(documentId1); - relationCommon.setDocumentType1(documentType1); - relationCommon.setDocumentId2(documentId2); - relationCommon.setDocumentType2(documentType2); + relationCommon.setSubjectCsid(subjectCsid); + relationCommon.setSubjectDocumentType(subjectDocumentType); + relationCommon.setObjectCsid(objectCsid); + relationCommon.setObjectDocumentType(objectDocumentType); relationCommon.setRelationshipType(rt); relationCommon.setPredicateDisplayName(rtDisplayName); 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 dc38d6e6d..9c9827691 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 @@ -197,38 +197,45 @@ public class RelationDocumentModelHandler String id = getCsid(docModel); relationListItem.setCsid(id); - relationListItem.setSubjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_1)); + relationListItem.setSubjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.SUBJECT_CSID)); - String predicate = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.RELATIONSHIP_TYPE); + String predicate = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.RELATIONSHIP_TYPE); relationListItem.setRelationshipType(predicate); relationListItem.setPredicate(predicate); //predicate is new name for relationshipType. - relationListItem.setPredicateDisplayName((String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.RELATIONSHIP_TYPE_DISPLAYNAME)); + relationListItem.setPredicateDisplayName((String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.RELATIONSHIP_TYPE_DISPLAYNAME)); - relationListItem.setObjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_2)); + relationListItem.setObjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.OBJECT_CSID)); relationListItem.setUri(serviceContextPath + id); //Now fill in summary info for the related docs: subject and object. String subjectCsid = relationListItem.getSubjectCsid(); - String documentType = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_1); - RelationsDocListItem subject = createRelationsDocListItem(ctx, sbt, subjectCsid, tReader, documentType); + String subjectDocumentType = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.SUBJECT_DOCTYPE); + RelationsDocListItem subject = createRelationsDocListItem(ctx, sbt, subjectCsid, tReader, subjectDocumentType); - //Object o1 = docModel.getProperty(ctx.getCommonPartLabel(), "subject"); - //Object o2 = docModel.getProperty(ctx.getCommonPartLabel(), "object"); - - String subjectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_URI); + String subjectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.SUBJECT_URI); subject.setUri(subjectUri); - String subjectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_REFNAME); + String subjectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.SUBJECT_REFNAME); subject.setRefName(subjectRefName); relationListItem.setSubject(subject); String objectCsid = relationListItem.getObjectCsid(); - String documentType2 = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_2); - RelationsDocListItem object = createRelationsDocListItem(ctx, sbt, objectCsid, tReader, documentType2); + String objectDocumentType = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.OBJECT_DOCTYPE); + RelationsDocListItem object = createRelationsDocListItem(ctx, sbt, objectCsid, tReader, objectDocumentType); - String objectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_URI); + String objectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.OBJECT_URI); object.setUri(objectUri); - String objectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_REFNAME); + String objectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), + RelationJAXBSchema.OBJECT_REFNAME); object.setRefName(objectRefName); relationListItem.setObject(object); @@ -242,33 +249,16 @@ public class RelationDocumentModelHandler TenantBindingConfigReaderImpl tReader, String documentType) throws Exception { RelationsDocListItem item = new RelationsDocListItem(); - item.setDocumentType(documentType);//this one comes from the record, as documentType1, documentType2. - // CSPACE-4037 REMOVING: item.setService(documentType);//this one comes from the record, as documentType1, documentType2. Current app seems to use servicename for this. + item.setDocumentType(documentType);//this one comes from the record, as subjectDocumentType, objectDocumentType. item.setCsid(itemCsid); DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, itemCsid); //null if not found. if (itemDocModel != null) { String itemDocType = itemDocModel.getDocumentType().getName(); - // CSPACE-4037 REMOVING: item.setDocumentTypeFromModel(itemDocType); //this one comes from the nuxeo documentType - - //DEBUG: System.out.println("\r\n******** AuthorityItemDocumentModelHandlder documentType **************\r\n\tdocModel: "+itemDocType+"\r\n\tpayload: "+documentType); - //boolean usedDocumentTypeFromPayload = true; - /*if ( ! Tools.isBlank(documentType)){ - if (documentType.equals(itemDocType)){ - //usedDocumentTypeFromPayload = true; - } else { - // Laramie20110510 CSPACE-3739 throw the exception for 3739, otherwise, don't throw it. - //throw new Exception("documentType supplied was wrong. supplied: "+documentType+" required: "+itemDocType+ " itemCsid: "+itemCsid ); - } - } else { - //usedDocumentTypeFromPayload = false; - item.setDocumentType(itemDocType); - } */ if (Tools.isBlank(documentType)) { item.setDocumentType(itemDocType); } - // TODO: clean all the output statements out of here when CSPACE-4037 is done. //TODO: ensure that itemDocType is really the entry point, i.e. servicename==doctype //ServiceBindingType itemSbt2 = tReader.getServiceBinding(ctx.getTenantId(), itemDocType); String propName = "ERROR-FINDING-PROP-VALUE"; @@ -277,13 +267,11 @@ public class RelationDocumentModelHandler propName = ServiceBindingUtils.getPropertyValue(itemSbt, ServiceBindingUtils.OBJ_NAME_PROP); String itemDocname = ServiceBindingUtils.getMappedFieldInDoc(itemSbt, ServiceBindingUtils.OBJ_NAME_PROP, itemDocModel); if (propName == null || itemDocname == null) { - //System.out.println("=== prop NOT found: "+ServiceBindingUtils.OBJ_NAME_PROP+"::"+propName+"="+itemDocname+" documentType: "+documentType); } else { item.setName(itemDocname); - //System.out.println("=== found prop : "+ServiceBindingUtils.OBJ_NAME_PROP+"::"+propName+"="+itemDocname+" documentType: "+documentType); } } catch (Throwable t) { - System.out.println("====Error finding objectNameProperty: " + itemDocModel + " field " + ServiceBindingUtils.OBJ_NAME_PROP + "=" + propName + logger.error("====Error finding objectNameProperty: " + itemDocModel + " field " + ServiceBindingUtils.OBJ_NAME_PROP + "=" + propName + " not found in itemDocType: " + itemDocType + " inner: " + t.getMessage()); } propName = "ERROR-FINDING-PROP-VALUE"; @@ -292,12 +280,8 @@ public class RelationDocumentModelHandler String itemDocnumber = ServiceBindingUtils.getMappedFieldInDoc(itemSbt, ServiceBindingUtils.OBJ_NUMBER_PROP, itemDocModel); if (propName == null || itemDocnumber == null) { - //System.out.println("=== prop NOT found: "+ServiceBindingUtils.OBJ_NUMBER_PROP+"::"+propName+"="+itemDocnumber - // +" documentType: "+documentType); } else { item.setNumber(itemDocnumber); - //System.out.println("============ found prop : "+ServiceBindingUtils.OBJ_NUMBER_PROP+"::"+propName+"="+itemDocnumber - // +" documentType: "+documentType); } } catch (Throwable t) { logger.error("====Error finding objectNumberProperty: " + ServiceBindingUtils.OBJ_NUMBER_PROP + "=" + propName @@ -331,11 +315,6 @@ public class RelationDocumentModelHandler try { csid = (String) relationDocModel.getProperty(commonPartLabel, (fSubject?RelationJAXBSchema.SUBJECT_CSID:RelationJAXBSchema.OBJECT_CSID)); - // FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record: - if (Tools.isBlank(csid)) { - csid = (String) relationDocModel.getProperty(commonPartLabel, - (fSubject?RelationJAXBSchema.DOCUMENT_ID_1:RelationJAXBSchema.DOCUMENT_ID_2)); - } } catch (PropertyException pe) { // Per CSPACE-4468, ignore any property exception here. // The objectCsid and/or subjectCsid field in a relation record @@ -373,16 +352,10 @@ public class RelationDocumentModelHandler String doctype = (String) subjectOrObjectDocModel.getType(); properties.put((fSubject?RelationJAXBSchema.SUBJECT_DOCTYPE:RelationJAXBSchema.OBJECT_DOCTYPE), doctype); - // FIXME: Remove the line below when legacy fields are removed from the Relation record: - properties.put((fSubject?RelationJAXBSchema.DOCUMENT_TYPE_1:RelationJAXBSchema.DOCUMENT_TYPE_2), - doctype); String csid = (String) subjectOrObjectDocModel.getName(); properties.put((fSubject?RelationJAXBSchema.SUBJECT_CSID:RelationJAXBSchema.OBJECT_CSID), csid); - // FIXME: Remove the two lines immediately below when legacy fields are removed from the Relation record: - properties.put((fSubject?RelationJAXBSchema.DOCUMENT_ID_1:RelationJAXBSchema.DOCUMENT_ID_2), - csid); String uri = (String) subjectOrObjectDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, COLLECTIONSPACE_CORE_URI); diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationValidatorHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationValidatorHandler.java index af72ae538..532fdc031 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationValidatorHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationValidatorHandler.java @@ -41,8 +41,8 @@ public class RelationValidatorHandler extends ValidatorHandlerImpl