From 7191cc8fbdbd7d97de336d6541fe8faf7920ff9f Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Tue, 22 Nov 2011 05:26:57 +0000 Subject: [PATCH] CSPACE-4256: Merged services trunk changes from r5918 through r6056 into the Apache 6 / Nuxeo 5.4.2 services branch. All tests ran successfully, except for two individual test cases in an authRefs-related XmlReplay test group, which have been commented out for now: afterUpdateGetLoan5 and afterUpdateGetLoan9. (Both appear to test if changes to a display name in a Person record are propagated to the display name in authRef-containing field(s) in Loan In.) --- .../test/CollectionSpaceIntegrationTest.java | 27 +- .../test/RelationIntegrationTest.java | 8 +- .../test-data/xmlreplay/acquisitions/ac1.xml | 4 +- .../test-data/xmlreplay/acquisitions/ac2.xml | 4 +- .../xmlreplay/acquisitions/res/ac1.res.xml | 4 +- .../xmlreplay/acquisitions/res/ac2.res.xml | 4 +- .../xmlreplay/acquisitions/res/ac3.res.xml | 4 +- .../test-data/xmlreplay/authrefs/authrefs.xml | 224 ++++++++++++ .../test-data/xmlreplay/authrefs/loanout.xml | 15 + .../xmlreplay/authrefs/newPerson1.xml | 9 + .../xmlreplay/authrefs/newPerson2.xml | 9 + .../xmlreplay/authrefs/newPersonAuthority.xml | 13 +- .../xmlreplay/authrefs/res/loanout.res.xml | 7 + .../xmlreplay/authrefs/updatePerson1.xml | 9 + .../xmlreplay/authrefs/updatePerson2.xml | 9 + .../test-data/xmlreplay/person/person.xml | 16 +- .../person/personTermStatusSearch.xml | 83 +++++ .../xmlreplay/person/person_pmadry.xml | 2 +- .../xmlreplay/person/person_pschmitz.xml | 2 +- .../person/persons_common_w_relations.xml | 8 +- .../person/persons_common_w_relations_2.xml | 4 +- .../person/persons_common_w_relations_3.xml | 8 +- .../person/res/personlistActive.res.xml | 11 + .../person/res/personlistAll.res.xml | 14 + .../person/res/personlistNone.res.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 +- .../vocabulary/res/GetVocabularyItems.res.xml | 11 +- .../test-data/xmlreplay/xml-replay-master.xml | 2 + .../test/CollectionSpacePerformanceTest.java | 20 +- .../resources/schemas/acquisitions_common.xsd | 6 +- .../client/test/AcquisitionServiceTest.java | 26 +- .../common/vocabulary/AuthorityResource.java | 20 +- .../vocabulary/RefNameServiceUtils.java | 222 +++++++++--- .../nuxeo/AuthorityDocumentModelHandler.java | 45 ++- .../AuthorityItemDocumentModelHandler.java | 336 ++++++++++-------- .../nuxeo/CreateAndLinkLoanOutBatchJob.java | 8 +- .../main/resources/schemas/blobs_common.xsd | 29 +- .../services/client/IQueryManager.java | 13 + .../collectionobjects_naturalhistory.xsd | 184 +++++----- .../schemas/collectionobjects_common.xsd | 168 +++++---- .../test/CollectionObjectServiceTest.java | 148 +++++--- .../resources/collectionobjects_common.xsd | 158 ++++---- .../services/common/api/Tools.java | 1 + services/common/build.xml | 13 +- .../tenants/tenant-bindings-proto.xml | 138 +++---- .../config/TenantBindingConfigReaderImpl.java | 4 +- .../common/context/ServiceBindingUtils.java | 3 + .../common/datetime/DateTimeFormatUtils.java | 16 +- .../GregorianCalendarDateTimeUtils.java | 10 + .../common/document/DocumentUtils.java | 4 +- .../common/imaging/nuxeo/NuxeoImageUtils.java | 61 ++-- .../services/common/query/QueryManager.java | 13 + .../query/nuxeo/QueryManagerNuxeoImpl.java | 40 ++- .../common/relation/RelationJAXBSchema.java | 28 +- .../common/relation/nuxeo/RelationsUtils.java | 10 +- .../common/repository/RepositoryClient.java | 6 +- .../nuxeo/client/java/DocHandlerBase.java | 14 +- .../java/RemoteDocumentModelHandlerImpl.java | 12 +- .../client/java/RepositoryJavaClientImpl.java | 74 ++++ .../AuthorityResourceWithContacts.java | 5 +- .../requests/collectionobject-request.xml | 6 +- .../main/resources/schemas/intakes_common.xsd | 10 +- .../client/test/IntakeAuthRefsTest.java | 5 +- .../client/test/IntakeServiceTest.java | 9 +- .../test/OrganizationAuthRefDocsTest.java | 5 +- .../client/test/PersonAuthRefDocsTest.java | 5 +- .../src/main/resources/authorityrefdocs.xsd | 1 + .../jaxb/src/main/resources/blobs_common.xsd | 29 +- .../src/main/resources/relations_common.xsd | 4 - .../main/resources/schemas/loansin_common.xsd | 26 +- .../client/test/LoaninAuthRefsTest.java | 5 +- .../client/test/LoaninServiceTest.java | 12 +- .../src/main/resources/loansin-common.xsd | 41 ++- .../resources/schemas/loansout_common.xsd | 24 +- .../client/test/LoanoutAuthRefsTest.java | 6 +- .../client/test/LoanoutServiceTest.java | 66 ++-- .../src/main/resources/loansout-common.xsd | 17 +- .../resources/schemas/locations_common.xsd | 2 +- .../test/LocationAuthorityServiceTest.java | 5 +- .../main/resources/schemas/media_common.xsd | 27 +- .../jaxb/src/main/resources/media_common.xsd | 28 +- .../resources/schemas/movements_common.xsd | 6 +- .../client/test/MovementServiceTest.java | 69 +--- .../resources/schemas/objectexit_common.xsd | 4 +- .../client/test/ObjectExitAuthRefsTest.java | 7 +- .../src/main/resources/objectexit_common.xsd | 2 +- .../PersonAuthorityValidatorHandler.java | 26 +- .../nuxeo/PersonDocumentModelHandler.java | 18 - .../person/nuxeo/PersonValidatorHandler.java | 40 ++- .../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 +- .../nuxeo/TaxonDocumentModelHandler.java | 5 + 97 files changed, 1933 insertions(+), 1148 deletions(-) create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/authrefs.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/loanout.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson1.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson2.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/res/loanout.res.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson1.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson2.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/personTermStatusSearch.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistActive.res.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistAll.res.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistNone.res.xml 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 7b3cf3715..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 @@ -39,6 +39,7 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.TitleGroup; import org.collectionspace.services.collectionobject.TitleGroupList; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.relation.RelationsCommon; import org.collectionspace.services.relation.RelationshipType; @@ -91,8 +92,8 @@ public abstract class CollectionSpaceIntegrationTest { * @param identifier the identifier */ void fillIntake(IntakesCommon theIntake, String identifier) { - fillIntake(theIntake, "entryNumber-" + identifier, "entryDate-" - + identifier); + String CURRENT_DATE_UTC = GregorianCalendarDateTimeUtils.currentDateUTC(); + fillIntake(theIntake, "entryNumber-" + identifier, CURRENT_DATE_UTC); } /** @@ -111,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/acquisitions/ac1.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac1.xml index 31de83477..ae8665103 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac1.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac1.xml @@ -4,8 +4,8 @@ xmlns:ns2="http://collectionspace.org/services/jaxb" xmlns:ns3="http://collectionspace.org/services/acquisition"> - NEW First Acquisition Date-334 - Second Acquisition Date-1292275630222 + 2010-11-15T07:30:24Z + 2009-10-15T07:30:24Z acquisitionReferenceNumber-1 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac2.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac2.xml index 81287aba8..dfa99178c 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac2.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/ac2.xml @@ -4,8 +4,8 @@ xmlns:ns2="http://collectionspace.org/services/jaxb" xmlns:ns3="http://collectionspace.org/services/acquisition"> - Second Acquisition Date-1292275631503 - First Acquisition Date -1292275631503 + 2010-11-15T07:30:24Z + 2009-10-15T07:30:24Z acquisitionReferenceNumber-1292275631503 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac1.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac1.res.xml index 7187217b2..da16a0e14 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac1.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac1.res.xml @@ -4,8 +4,8 @@ acquisitionReferenceNumber-1 -NEW First Acquisition Date-334 -Second Acquisition Date-1292275630222 +2010-11-15T07:30:24Z +2009-10-15T07:30:24Z Donor Acquisition Source-1292275630222 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac2.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac2.res.xml index 21d1a9364..9fa704a36 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac2.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac2.res.xml @@ -4,8 +4,8 @@ acquisitionReferenceNumber-1292275631503 -Second Acquisition Date-1292275631503 -First Acquisition Date -1292275631503 +2010-11-15T07:30:24Z +2009-10-15T07:30:24Z Museum Acquisition Source-1292275631503 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac3.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac3.res.xml index dd7b7a580..ebe0bbfe8 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac3.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/acquisitions/res/ac3.res.xml @@ -4,8 +4,8 @@ acquisitionReferenceNumber-1292275630222 -First Acquisition Date -1292275630222 -Second Acquisition Date-1292275630222 +2010-11-15T07:30:24Z +2009-10-15T07:30:24Z Donor Acquisition Source-1292275630222 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/authrefs.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/authrefs.xml new file mode 100644 index 000000000..56ee91e0c --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/authrefs.xml @@ -0,0 +1,224 @@ + + + + + + POST + /cspace-services/personauthorities/ + authrefs/newPersonAuthority.xml + + + POST + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/ + authrefs/newPerson1.xml + + + POST + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/ + authrefs/newPerson2.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/${Person1.CSID} + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/${Person2.CSID} + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 42 + ${GetPerson1.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 102 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 103 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 104 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 105 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 106 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 107 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 108 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 109 + ${GetPerson2.got("//refName")} + + + + + POST + /cspace-services/loansout/ + authrefs/loanout.xml + + 110 + ${GetPerson2.got("//refName")} + + + + + PUT + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/${Person1.CSID} + authrefs/updatePerson1.xml + + + + PUT + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/${Person2.CSID} + authrefs/updatePerson2.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/${Person1.CSID} + + + authrefs/updatePerson1.xml + + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/${Person2.CSID} + + + authrefs/updatePerson2.xml + + + + + GET + /cspace-services/loansout/${loanout1.CSID} + + + + authrefs/res/loanout.res.xml + + ${GetFirstUpdatedPerson.got("//refName")} + + + + + + GET + /cspace-services/loansout/${loanout2.CSID} + + + + authrefs/res/loanout.res.xml + + ${GetSecondUpdatedPerson.got("//refName")} + + + + + + + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/loanout.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/loanout.xml new file mode 100644 index 000000000..2ab7824b3 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/loanout.xml @@ -0,0 +1,15 @@ + + + + loanoutNumber-${loannum} + ${person} + + + returned + Left under the front mat. + + + Allow people in cold climes to share the magic of Surfboards of the 1960s. + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson1.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson1.xml new file mode 100644 index 000000000..ee80f561a --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson1.xml @@ -0,0 +1,9 @@ + + + + connieContactPerson + true + Connie + ContactPerson + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson2.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson2.xml new file mode 100644 index 000000000..7fc57fadc --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPerson2.xml @@ -0,0 +1,9 @@ + + + + debbieDoNothingPerson + true + Debbie + DoNothingPerson + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPersonAuthority.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPersonAuthority.xml index 7809ec478..86f4d56be 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPersonAuthority.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/newPersonAuthority.xml @@ -1,7 +1,8 @@ - -TestPersonAuth -TestPersonAuth -urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth)'TestPersonAuth' -PersonAuthority - \ No newline at end of file + + + TestPersonAuth + TestPersonAuth + PersonAuthority + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/res/loanout.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/res/loanout.res.xml new file mode 100644 index 000000000..ee63091ca --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/res/loanout.res.xml @@ -0,0 +1,7 @@ + + + + ${person} + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson1.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson1.xml new file mode 100644 index 000000000..7d3103a31 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson1.xml @@ -0,0 +1,9 @@ + + + + connieContactPerson + true + Connie + ContactPersonlity + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson2.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson2.xml new file mode 100644 index 000000000..73cc9431b --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/updatePerson2.xml @@ -0,0 +1,9 @@ + + + + debbieDoNothingPerson + true + Debbie + Do Nothing Personality + + 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/personTermStatusSearch.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/personTermStatusSearch.xml new file mode 100644 index 000000000..499951824 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/personTermStatusSearch.xml @@ -0,0 +1,83 @@ + + + + + + POST + /cspace-services/personauthorities/ + person/personauthorities_common.xml + + TermStatusTestAuth + + + + POST + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/ + person/person_pschmitz.xml + + Approved + + + + POST + /cspace-services/personauthorities/${PersonAuth1.CSID}/items/ + person/person_pmadry.xml + + Inactive + + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items + + + person/res/personlistAll.res.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items?ts=Inactive + + + person/res/personlistActive.res.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items?ts=Garbage + + + person/res/personlistAll.res.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items?ts=Inactive%7CApproved + + + person/res/personlistNone.res.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items?pt=Patrick + + + person/res/personlistActive.res.xml + + + + GET + /cspace-services/personauthorities/${PersonAuth1.CSID}/items?pt=Patrick&ts=Approved + + + person/res/personlistNone.res.xml + + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pmadry.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pmadry.xml index 6e4b9731e..b6b8a196f 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pmadry.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pmadry.xml @@ -2,11 +2,11 @@ pmadry - urn:cspace:org.collectionspace.demo:personauthority:name(testpersonauth):person:name(pmadry)'Penelope Madry' false false Penelope Madry Penelope Madry, New York + ${termStatus} Project Manager for CollectionSpace diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pschmitz.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pschmitz.xml index 585a15d30..ee908b055 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pschmitz.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person_pschmitz.xml @@ -2,11 +2,11 @@ pschmitz - urn:cspace:org.collectionspace.demo:personauthority:name(testpersonauth):person:name(pschmitz)'Patrick Schmitz' false false Patrick Schmitz Patrick Schmitz, Berkeley + ${termStatus} Technical Lead for CollectionSpace This is a test PersonAuthority item Some mythical book 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/person/res/personlistActive.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistActive.res.xml new file mode 100644 index 000000000..9fe8400f4 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistActive.res.xml @@ -0,0 +1,11 @@ + + + 0 + 40 + 1 + csid|uri|updatedAt|displayName|shortIdentifier|refName|termStatus + + pschmitz + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistAll.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistAll.res.xml new file mode 100644 index 000000000..322dbe506 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistAll.res.xml @@ -0,0 +1,14 @@ + + + 0 + 40 + 2 + csid|uri|updatedAt|displayName|shortIdentifier|refName|termStatus + + pschmitz + + + pmadry + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistNone.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistNone.res.xml new file mode 100644 index 000000000..8f085a324 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/res/personlistNone.res.xml @@ -0,0 +1,8 @@ + + + 0 + 40 + 0 + csid|uri|updatedAt|displayName|shortIdentifier|refName|termStatus + + 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/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml index fe7ab95e3..4a130df47 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml @@ -6,26 +6,29 @@ 0 3 3 - csid|uri|updatedAt|displayName|shortIdentifier|refName|order + csid|uri|updatedAt|order|displayName|shortIdentifier|refName|termStatus ${Item3DupeOrder.displayName} ${Item3DupeOrder.itemID} ${Item3DupeOrder.order} /vocabularies/${Vocabulary1.CSID}/items/${Item3DupeOrder.CSID} - ${Item3DupeOrder.CSID} + ${Item3DupeOrder.CSID} + ${Item2.displayName} ${Item2.itemID} ${Item2.order} /vocabularies/${Vocabulary1.CSID}/items/${Item2.CSID} - ${Item2.CSID} + ${Item2.CSID} + ${Item1.displayName} ${Item1.itemID} ${Item1.order} /vocabularies/${Vocabulary1.CSID}/items/${Item1.CSID} - ${Item1.CSID} + ${Item1.CSID} + 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 e78cd5c63..686cb68e3 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 @@ -53,6 +53,8 @@ + + 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/acquisition/3rdparty/nuxeo-platform-cs-acquisition/src/main/resources/schemas/acquisitions_common.xsd b/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/src/main/resources/schemas/acquisitions_common.xsd index 5046ade10..ebba7a018 100644 --- a/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/src/main/resources/schemas/acquisitions_common.xsd +++ b/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/src/main/resources/schemas/acquisitions_common.xsd @@ -21,13 +21,13 @@ - + - + - + diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index c43ef9ec7..3147e8a15 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -32,6 +32,7 @@ import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.AbstractCommonListUtils; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.acquisition.AcquisitionsCommon; @@ -62,17 +63,20 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.timestampUTC(); - @Override - public String getServicePathComponent() { - return AcquisitionClient.SERVICE_PATH_COMPONENT; - } + + @Override + public String getServicePathComponent() { + return AcquisitionClient.SERVICE_PATH_COMPONENT; + } - @Override - protected String getServiceName() { - return AcquisitionClient.SERVICE_NAME; - } + @Override + protected String getServiceName() { + return AcquisitionClient.SERVICE_NAME; + } /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -797,10 +801,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { AcquisitionDateList acqDatesList = new AcquisitionDateList(); List acqDates = acqDatesList.getAcquisitionDate(); - // FIXME Use properly timestamps for representative acquisition - // dates in this example test record. The following are mere placeholders. - acqDates.add("First Acquisition Date -" + identifier); - acqDates.add("Second Acquisition Date-" + identifier); + acqDates.add(CURRENT_DATE_UTC); + acqDates.add(CURRENT_DATE_UTC); acquisition.setAcquisitionDates(acqDatesList); OwnerList ownersList = new OwnerList(); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 2764731c5..f72d750c5 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -103,6 +103,8 @@ import java.util.List; @Produces("application/xml") public abstract class AuthorityResource extends ResourceBase { + + final static String SEARCH_TYPE_TERMSTATUS = "ts"; protected Class authCommonClass; protected Class resourceClass; @@ -638,6 +640,7 @@ public abstract class AuthorityResource try { MultivaluedMap queryParams = ui.getQueryParameters(); String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM); + String termStatus = queryParams.getFirst(SEARCH_TYPE_TERMSTATUS); String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW); String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS); @@ -660,12 +663,21 @@ public abstract class AuthorityResource if (sortBy == null || sortBy.isEmpty()) { myFilter.setOrderByClause(qualifiedDisplayNameField); } - + myFilter.appendWhereClause(authorityItemCommonSchemaName + ":" + AuthorityItemJAXBSchema.IN_AUTHORITY + "=" + "'" + parentcsid + "'", IQueryManager.SEARCH_QUALIFIER_AND); + if (Tools.notBlank(termStatus)) { + // Start with the qualified termStatus field + String qualifiedTermStatusField = authorityItemCommonSchemaName + ":" + + AuthorityItemJAXBSchema.TERM_STATUS; + String[] filterTerms = termStatus.trim().split("\\|"); + String tsClause = QueryManager.createWhereClauseToFilterFromStringList(qualifiedTermStatusField, filterTerms, IQueryManager.FILTER_EXCLUDE); + myFilter.appendWhereClause(tsClause, IQueryManager.SEARCH_QUALIFIER_AND); + } + // AND vocabularyitems_common:displayName LIKE '%partialTerm%' // NOTE: Partial terms searches are mutually exclusive to keyword and advanced-search, but // the PT query param trumps the KW and AS query params. @@ -740,9 +752,13 @@ public abstract class AuthorityResource DocumentModel docModel = docWrapper.getWrappedObject(); String refName = (String) docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME); + // Could be smarter about using the list from above, and/or allowing multiple + ArrayList serviceTypes = new ArrayList(1); + serviceTypes.add(serviceType); + authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(ctx, repoClient, - serviceType, + serviceTypes, refName, getRefPropName(), myFilter.getPageSize(), myFilter.getStartPage(), true /*computeTotal*/); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index 56fb51779..5e22beb2a 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -33,11 +33,15 @@ import java.util.Map; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; +import org.nuxeo.ecm.core.api.model.Property; +import org.nuxeo.ecm.core.api.model.PropertyException; +import org.nuxeo.ecm.core.api.model.impl.primitives.StringProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.context.ServiceContext; +import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; @@ -47,6 +51,8 @@ import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.repository.RepositoryClient; +import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.util.NuxeoUtils; @@ -60,10 +66,12 @@ import org.collectionspace.services.nuxeo.util.NuxeoUtils; public class RefNameServiceUtils { private static final Logger logger = LoggerFactory.getLogger(RefNameServiceUtils.class); + + private static ArrayList refNameServiceTypes = null; public static AuthorityRefDocList getAuthorityRefDocs(ServiceContext ctx, RepositoryClient repoClient, - String serviceType, + List serviceTypes, String refName, String refPropName, int pageSize, int pageNum, boolean computeTotal) throws DocumentException, DocumentNotFoundException { @@ -73,11 +81,96 @@ public class RefNameServiceUtils { commonList.setPageSize(pageSize); List list = wrapperList.getAuthorityRefDocItem(); + + Map queriedServiceBindings = new HashMap(); + Map> authRefFieldsByService = new HashMap>(); + + DocumentModelList docList = findAuthorityRefDocs(ctx, repoClient, serviceTypes, refName, refPropName, + queriedServiceBindings, authRefFieldsByService, pageSize, pageNum, computeTotal); + + if (docList == null) { // found no authRef fields - nothing to process + return wrapperList; + } + // Set num of items in list. this is useful to our testing framework. + commonList.setItemsInPage(docList.size()); + // set the total result size + commonList.setTotalItems(docList.totalSize()); + + int nRefsFound = processRefObjsDocList(docList, refName, queriedServiceBindings, authRefFieldsByService, + list, null); + if(logger.isDebugEnabled() && (nRefsFound < docList.size())) { + logger.debug("Internal curiosity: got fewer matches of refs than # docs matched..."); + } + return wrapperList; + } + + private static ArrayList getRefNameServiceTypes() { + if(refNameServiceTypes == null) { + refNameServiceTypes = new ArrayList(); + refNameServiceTypes.add(ServiceBindingUtils.SERVICE_TYPE_AUTHORITY); + refNameServiceTypes.add(ServiceBindingUtils.SERVICE_TYPE_OBJECT); + refNameServiceTypes.add(ServiceBindingUtils.SERVICE_TYPE_PROCEDURE); + } + return refNameServiceTypes; + } + + public static int updateAuthorityRefDocs(ServiceContext ctx, + RepositoryClient repoClient, + String oldRefName, + String newRefName, + String refPropName ) { + Map queriedServiceBindings = new HashMap(); + Map> authRefFieldsByService = new HashMap>(); + int nRefsFound = 0; + if(!(repoClient instanceof RepositoryJavaClientImpl)) { + throw new InternalError("updateAuthorityRefDocs() called with unknown repoClient type!"); + } + try { + final int pageSize = 100; // Seems like a good value - no real data to set this well. + int pageNumProcessed = 1; + while(true) { // Keep looping until we find all the refs. + logger.debug("updateAuthorityRefDocs working on page: "+pageNumProcessed); + // Note that we always ask the Repo for the first page, since each page we process + // should not be found in successive searches. + DocumentModelList docList = findAuthorityRefDocs(ctx, repoClient, getRefNameServiceTypes(), oldRefName, refPropName, + queriedServiceBindings, authRefFieldsByService, pageSize, 0, false); + + if((docList == null) // found no authRef fields - nothing to do + || (docList.size() == 0)) { // No more to handle + logger.debug("updateAuthorityRefDocs no more results"); + break; + } + logger.debug("updateAuthorityRefDocs curr page result list size: "+docList.size()); + int nRefsFoundThisPage = processRefObjsDocList(docList, oldRefName, queriedServiceBindings, authRefFieldsByService, + null, newRefName); + if(nRefsFoundThisPage>0) { + ((RepositoryJavaClientImpl)repoClient).saveDocListWithoutHandlerProcessing(ctx, docList, true); + nRefsFound += nRefsFoundThisPage; + } + pageNumProcessed++; + } + } catch(Exception e) { + logger.error("Internal error updating the AuthorityRefDocs: " + e.getLocalizedMessage()); + logger.debug(Tools.errorToString(e, true)); + } + logger.debug("updateAuthorityRefDocs replaced a total of: "+nRefsFound); + return nRefsFound; + } + + private static DocumentModelList findAuthorityRefDocs(ServiceContext ctx, + RepositoryClient repoClient, + List serviceTypes, + String refName, + String refPropName, + Map queriedServiceBindings, + Map> authRefFieldsByService, + int pageSize, int pageNum, boolean computeTotal) throws DocumentException, DocumentNotFoundException { // Get the service bindings for this tenant TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader(); - List servicebindings = tReader.getServiceBindingsByType(ctx.getTenantId(), serviceType); + // We need to get all the procedures, authorities, and objects. + List servicebindings = tReader.getServiceBindingsByType(ctx.getTenantId(), serviceTypes); if (servicebindings == null || servicebindings.isEmpty()) { logger.error("RefNameServiceUtils.getAuthorityRefDocs: No services bindings found, cannot proceed!"); return null; @@ -87,28 +180,18 @@ public class RefNameServiceUtils { // TODO What if they are already escaped? String escapedRefName = refName.replaceAll("'", "\\\\'"); ArrayList docTypes = new ArrayList(); - Map queriedServiceBindings = new HashMap(); - Map> authRefFieldsByService = new HashMap>(); String query = computeWhereClauseForAuthorityRefDocs(escapedRefName, refPropName, docTypes, servicebindings, queriedServiceBindings, authRefFieldsByService ); if (query == null) { // found no authRef fields - nothing to query - return wrapperList; + return null; } // Now we have to issue the search DocumentWrapper docListWrapper = repoClient.findDocs(ctx, docTypes, query, pageSize, pageNum, computeTotal); // Now we gather the info for each document into the list and return DocumentModelList docList = docListWrapper.getWrappedObject(); - // Set num of items in list. this is useful to our testing framework. - commonList.setItemsInPage(docList.size()); - // set the total result size - commonList.setTotalItems(docList.totalSize()); - - processRefObjsDocList(docList, refName, servicebindings, - queriedServiceBindings, authRefFieldsByService, - list, null); - return wrapperList; + return docList; } private static String computeWhereClauseForAuthorityRefDocs( @@ -173,16 +256,28 @@ public class RefNameServiceUtils { /* * Runs through the list of found docs, processing them. * If list is non-null, then processing means gather the info for items. - * If list is null, and newRefName is non-null, then processing means replacing and updating. + * If list is null, and newRefName is non-null, then processing means replacing and updating. + * If processing/updating, this must be called in teh context of an open session, and caller + * must release Session after calling this. + * */ - private static void processRefObjsDocList(DocumentModelList docList, + private static int processRefObjsDocList( + DocumentModelList docList, String refName, - List servicebindings, Map queriedServiceBindings, Map> authRefFieldsByService, List list, String newAuthorityRefName) { + if(newAuthorityRefName==null) { + if(list==null) { + throw new InternalError("processRefObjsDocList() called with neither an itemList nor a new RefName!"); + } + } else if(list!=null) { + throw new InternalError("processRefObjsDocList() called with both an itemList and a new RefName!"); + } + Iterator iter = docList.iterator(); + int nRefsFoundTotal = 0; while (iter.hasNext()) { DocumentModel docModel = iter.next(); AuthorityRefDocList.AuthorityRefDocItem ilistItem; @@ -202,6 +297,11 @@ public class RefNameServiceUtils { String csid = NuxeoUtils.getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); ilistItem.setDocId(csid); ilistItem.setUri(serviceContextPath + csid); + try { + ilistItem.setUpdatedAt(DocHandlerBase.getUpdatedAtAsString(docModel)); + } catch(Exception e) { + logger.error("Error getting udpatedAt value for doc ["+csid+"]: "+e.getLocalizedMessage()); + } // The id and URI are the same on all doctypes ilistItem.setDocType(docType); ilistItem.setDocNumber( @@ -210,7 +310,7 @@ public class RefNameServiceUtils { ServiceBindingUtils.getMappedFieldInDoc(sb, ServiceBindingUtils.OBJ_NAME_PROP, docModel)); } // Now, we have to loop over the authRefFieldsByService to figure - // out which field matched this. Ignore multiple matches. + // out which field(s) matched this. Map matchingAuthRefFields = authRefFieldsByService.get(docType); if (matchingAuthRefFields == null || matchingAuthRefFields.isEmpty()) { throw new RuntimeException( @@ -219,20 +319,21 @@ public class RefNameServiceUtils { String authRefAncestorField = ""; String authRefDescendantField = ""; String sourceField = ""; - boolean fRefFound = false; + int nRefsFoundInDoc = 0; // Use this if we go to qualified field names for (String path : matchingAuthRefFields.keySet()) { try { // This is the field name we show in the return info + // Returned as a schema-qualified property path authRefAncestorField = (String) matchingAuthRefFields.get(path); // This is the qualified field we have to get from the doc model authRefDescendantField = DocumentUtils.getDescendantOrAncestor(path); // The ancestor field is part-schema (tablename) qualified - String[] strings = authRefAncestorField.split(":"); - if (strings.length != 2) { - throw new RuntimeException( - "getAuthorityRefDocs: Bad configuration of path to authority reference field."); - } + //String[] strings = authRefAncestorField.split(":"); + //if (strings.length != 2) { + // throw new RuntimeException( + // "getAuthorityRefDocs: Bad configuration of path to authority reference field."); + //} // strings[0] holds a schema name, such as "intakes_common" // // strings[1] holds: @@ -243,13 +344,19 @@ public class RefNameServiceUtils { // field, such as "fieldCollector". // TODO - if the value is not simple, or repeating scalar, need a more // sophisticated fetch. - Object fieldValue = docModel.getProperty(strings[0], strings[1]); - // We cannot be sure why we have this doc, so look for matches - boolean fRefMatches = refNameFoundInField(refName, fieldValue); - if (fRefMatches) { + // Change this to an XPath model + //Object fieldValue = docModel.getProperty(strings[0], strings[1]); + // This will have to handle repeating complex fields by iterating over the possibilities + // and finding the one that matches. + Property fieldValue = docModel.getProperty(authRefAncestorField); + // We know this doc should have a match somewhere, but it may not be in this field + // If we are just building up the refItems, then it is enough to know we found a match. + // If we are patching refName values, then we have to replace each match. + int nRefsMatchedInField = refNameFoundInField(refName, fieldValue, newAuthorityRefName); + if (nRefsMatchedInField > 0) { sourceField = authRefDescendantField; // Handle multiple fields matching in one Doc. See CSPACE-2863. - if(fRefFound) { + if(nRefsFoundInDoc > 0) { // We already added ilistItem, so we need to clone that and add again if(ilistItem != null) { ilistItem = cloneAuthRefDocItem(ilistItem, sourceField); @@ -258,11 +365,11 @@ public class RefNameServiceUtils { if(ilistItem != null) { ilistItem.setSourceField(sourceField); } - fRefFound = true; } if(ilistItem != null) { list.add(ilistItem); } + nRefsFoundInDoc += nRefsMatchedInField; } } catch (ClientException ce) { @@ -270,13 +377,14 @@ public class RefNameServiceUtils { "getAuthorityRefDocs: Problem fetching: " + sourceField, ce); } } - if (!fRefFound) { + if (nRefsFoundInDoc == 0) { throw new RuntimeException( "getAuthorityRefDocs: Could not find refname in object:" + docType + ":" + NuxeoUtils.getCsid(docModel)); } + nRefsFoundTotal += nRefsFoundInDoc; } - + return nRefsFoundTotal; } private static AuthorityRefDocList.AuthorityRefDocItem cloneAuthRefDocItem( @@ -293,6 +401,7 @@ public class RefNameServiceUtils { /* * Identifies whether the refName was found in the supplied field. + * If passed a new RefName, will set that into fields in which the old one was found. * * Only works for: * * Scalar fields @@ -302,24 +411,37 @@ public class RefNameServiceUtils { * * Structured fields (complexTypes) * * Repeatable structured fields (repeatable complexTypes) */ - private static boolean refNameFoundInField(String refName, Object fieldValue) { - - boolean result = false; - if (fieldValue instanceof List) { - List fieldValueList = (List) fieldValue; - for (String listItemValue : fieldValueList) { - if (refName.equalsIgnoreCase(listItemValue)) { - result = true; - break; - } - - } - } else if (fieldValue instanceof String){ - if (refName.equalsIgnoreCase((String)fieldValue)) { - result = true; - } - } - return result; + private static int refNameFoundInField(String oldRefName, Property fieldValue, String newRefName) { + int nFound = 0; + if (fieldValue instanceof List) { + List fieldValueList = (List) fieldValue; + for (Property listItemValue : fieldValueList) { + try { + if ((listItemValue instanceof StringProperty) + && oldRefName.equalsIgnoreCase((String)listItemValue.getValue())) { + nFound++; + if(newRefName!=null) { + fieldValue.setValue(newRefName); + } else { + // We cannot quit after the first, if we are replacing values. + // If we are just looking (not replacing), finding one is enough. + break; + } + } + } catch( PropertyException pe ) {} + } + } else { + try { + if ((fieldValue instanceof StringProperty) + && oldRefName.equalsIgnoreCase((String)fieldValue.getValue())) { + nFound++; + if(newRefName!=null) { + fieldValue.setValue(newRefName); + } + } + } catch( PropertyException pe ) {} + } + return nFound; } } diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index 9235008b3..84cb9cfa1 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -80,6 +80,10 @@ public abstract class AuthorityDocumentModelHandler updateRefnameForAuthority(wrapDoc, authorityCommonSchemaName);//CSPACE-3178 } + /** + * If no short identifier was provided in the input payload, + * generate a short identifier from the display name. + */ private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception { String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER); String displayName = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.DISPLAY_NAME); @@ -89,24 +93,29 @@ public abstract class AuthorityDocumentModelHandler docModel.setProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER, generatedShortIdentifier); } } - + + /** + * Generate a refName for the authority from the short identifier + * and display name. + * + * All refNames for authorities are generated. If a client supplies + * a refName, it will be overwritten during create (per this method) + * or discarded during update (per filterReadOnlyPropertiesForPart). + * + * @see #filterReadOnlyPropertiesForPart(Map, org.collectionspace.services.common.service.ObjectPartType) + * + */ protected void updateRefnameForAuthority(DocumentWrapper wrapDoc, String schemaName) throws Exception { DocumentModel docModel = wrapDoc.getWrappedObject(); - String suppliedRefName = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.REF_NAME); - // CSPACE-3178: - // Temporarily accept client-supplied refName values, rather than always generating such values, - // Remove the surrounding 'if' statement when clients should no longer supply refName values. - if (suppliedRefName == null || suppliedRefName.isEmpty()) { - String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER); - String displayName = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.DISPLAY_NAME); - MultipartServiceContext ctx = (MultipartServiceContext) getServiceContext(); - RefName.Authority authority = RefName.buildAuthority(ctx.getTenantName(), - ctx.getServiceName(), - shortIdentifier, - displayName); - String refName = authority.toString(); - docModel.setProperty(schemaName, AuthorityJAXBSchema.REF_NAME, refName); - } + String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER); + String displayName = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.DISPLAY_NAME); + MultipartServiceContext ctx = (MultipartServiceContext) getServiceContext(); + RefName.Authority authority = RefName.buildAuthority(ctx.getTenantName(), + ctx.getServiceName(), + shortIdentifier, + displayName); + String refName = authority.toString(); + docModel.setProperty(schemaName, AuthorityJAXBSchema.REF_NAME, refName); } public String getShortIdentifier(DocumentWrapper wrapDoc, String schemaName) { @@ -134,9 +143,7 @@ public abstract class AuthorityDocumentModelHandler if (partMeta.getLabel().equalsIgnoreCase(commonPartLabel)) { objectProps.remove(AuthorityJAXBSchema.CSID); objectProps.remove(AuthorityJAXBSchema.SHORT_IDENTIFIER); - // Enable when clients should no longer supply refName values - // objectProps.remove(AuthorityItemJAXBSchema.REF_NAME); // CSPACE-3178 - + objectProps.remove(AuthorityJAXBSchema.REF_NAME); } } } 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 29dbd50c2..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 @@ -33,7 +33,9 @@ import org.collectionspace.services.common.api.CommonAPI; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.context.MultipartServiceContext; +import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.common.context.ServiceContext; +import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.document.DocumentWrapperImpl; import org.collectionspace.services.common.relation.IRelationsManager; @@ -44,6 +46,7 @@ import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.common.service.ListResultField; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.relation.RelationResource; import org.collectionspace.services.relation.RelationsCommon; @@ -80,7 +83,6 @@ public abstract class AuthorityItemDocumentModelHandler */ protected String inAuthority; protected String authorityRefNameBase; - // Used to determine when the displayName changes as part of the update. protected String oldDisplayNameOnUpdate = null; protected String oldRefNameOnUpdate = null; @@ -118,6 +120,58 @@ public abstract class AuthorityItemDocumentModelHandler this.authorityRefNameBase = value; } + @Override + public List getListItemsArray() throws DocumentException { + List list = super.getListItemsArray(); + int nFields = list.size(); + // Ensure some common fields so do not depend upon config for general logic + boolean hasDisplayName = false; + boolean hasShortId = false; + boolean hasRefName = false; + boolean hasTermStatus = false; + for (int i = 0; i < nFields; i++) { + ListResultField field = list.get(i); + String elName = field.getElement(); + if (AuthorityItemJAXBSchema.DISPLAY_NAME.equals(elName)) { + hasDisplayName = true; + } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) { + hasShortId = true; + } else if (AuthorityItemJAXBSchema.REF_NAME.equals(elName)) { + hasRefName = true; + } else if (AuthorityItemJAXBSchema.TERM_STATUS.equals(elName)) { + hasTermStatus = true; + } + } + ListResultField field; + if (!hasDisplayName) { + field = new ListResultField(); + field.setElement(AuthorityItemJAXBSchema.DISPLAY_NAME); + field.setXpath(AuthorityItemJAXBSchema.DISPLAY_NAME); + list.add(field); + } + if (!hasShortId) { + field = new ListResultField(); + field.setElement(AuthorityItemJAXBSchema.SHORT_IDENTIFIER); + field.setXpath(AuthorityItemJAXBSchema.SHORT_IDENTIFIER); + list.add(field); + } + if (!hasRefName) { + field = new ListResultField(); + field.setElement(AuthorityItemJAXBSchema.REF_NAME); + field.setXpath(AuthorityItemJAXBSchema.REF_NAME); + list.add(field); + } + if (!hasTermStatus) { + field = new ListResultField(); + field.setElement(AuthorityItemJAXBSchema.TERM_STATUS); + field.setXpath(AuthorityItemJAXBSchema.TERM_STATUS); + list.add(field); + } + return list; + + } + + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) */ @@ -127,41 +181,41 @@ public abstract class AuthorityItemDocumentModelHandler super.handleCreate(wrapDoc); // Ensure we have required fields set properly handleInAuthority(wrapDoc.getWrappedObject()); - - handleComputedDisplayNames(wrapDoc.getWrappedObject()); - String displayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, - AuthorityItemJAXBSchema.DISPLAY_NAME); - if(Tools.isEmpty(displayName)) { - logger.warn("Creating Authority Item with no displayName!"); - } + + handleComputedDisplayNames(wrapDoc.getWrappedObject()); + String displayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, + AuthorityItemJAXBSchema.DISPLAY_NAME); + if (Tools.isEmpty(displayName)) { + logger.warn("Creating Authority Item with no displayName!"); + } // CSPACE-3178: handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName); // refName includes displayName, so we force a correct value here. updateRefnameForAuthorityItem(wrapDoc, authorityItemCommonSchemaName, getAuthorityRefNameBase()); } - + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) */ @Override public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { - // First, get a copy of the old displayName - oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, - AuthorityItemJAXBSchema.DISPLAY_NAME); - oldRefNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, - AuthorityItemJAXBSchema.REF_NAME); - super.handleUpdate(wrapDoc); - handleComputedDisplayNames(wrapDoc.getWrappedObject()); - String newDisplayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, - AuthorityItemJAXBSchema.DISPLAY_NAME); - if(newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) { - // Need to update the refName, and then fix all references. - newRefNameOnUpdate = handleItemRefNameUpdateForDisplayName(wrapDoc.getWrappedObject(), newDisplayName); - } else { - // Mark as not needing attention in completeUpdate phase. - newRefNameOnUpdate = null; - oldRefNameOnUpdate = null; - } + // First, get a copy of the old displayName + oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, + AuthorityItemJAXBSchema.DISPLAY_NAME); + oldRefNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, + AuthorityItemJAXBSchema.REF_NAME); + super.handleUpdate(wrapDoc); + handleComputedDisplayNames(wrapDoc.getWrappedObject()); + String newDisplayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, + AuthorityItemJAXBSchema.DISPLAY_NAME); + if (newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) { + // Need to update the refName, and then fix all references. + newRefNameOnUpdate = handleItemRefNameUpdateForDisplayName(wrapDoc.getWrappedObject(), newDisplayName); + } else { + // Mark as not needing attention in completeUpdate phase. + newRefNameOnUpdate = null; + oldRefNameOnUpdate = null; + } } /** @@ -171,7 +225,7 @@ public abstract class AuthorityItemDocumentModelHandler * @throws Exception the exception */ protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { - // Do nothing by default. + // Do nothing by default. } /** @@ -179,17 +233,16 @@ public abstract class AuthorityItemDocumentModelHandler * Assumes refName is already correct. Just ensures it is right. * * @param docModel the doc model + * @param newDisplayName the new display name * @throws Exception the exception */ protected String handleItemRefNameUpdateForDisplayName(DocumentModel docModel, String newDisplayName) throws Exception { - //String suppliedRefName = (String) docModel.getProperty(authorityItemCommonSchemaName, - // AuthorityItemJAXBSchema.REF_NAME); RefName.AuthorityItem authItem = RefName.AuthorityItem.parse(oldRefNameOnUpdate); - if(authItem == null) { - String err = "Authority Item has illegal refName: "+oldRefNameOnUpdate; - logger.debug(err); - throw new IllegalArgumentException(err); + if (authItem == null) { + String err = "Authority Item has illegal refName: " + oldRefNameOnUpdate; + logger.debug(err); + throw new IllegalArgumentException(err); } authItem.displayName = newDisplayName; String updatedRefName = authItem.toString(); @@ -197,21 +250,37 @@ public abstract class AuthorityItemDocumentModelHandler return updatedRefName; } - /** * Checks to see if the refName has changed, and if so, * uses utilities to find all references and update them. */ protected void handleItemRefNameReferenceUpdate() { - if(newRefNameOnUpdate != null && oldRefNameOnUpdate!= null) { - // We have work to do. - logger.debug("Need to find and update references to Item."); - logger.debug("Old refName" + oldRefNameOnUpdate); - logger.debug("New refName" + newRefNameOnUpdate); - } + if (newRefNameOnUpdate != null && oldRefNameOnUpdate != null) { + // We have work to do. + if (logger.isDebugEnabled()) { + String eol = System.getProperty("line.separator"); + logger.debug("Need to find and update references to Item." + eol + + " Old refName" + oldRefNameOnUpdate + eol + + " New refName" + newRefNameOnUpdate); + } + ServiceContext ctx = getServiceContext(); + RepositoryClient repoClient = getRepositoryClient(ctx); + // FIXME HACK - this should be defined for each handler, as with + // AuthorityResource.getRefPropName() + String refNameProp = ServiceBindingUtils.AUTH_REF_PROP; + + int nUpdated = RefNameServiceUtils.updateAuthorityRefDocs(ctx, repoClient, + oldRefNameOnUpdate, newRefNameOnUpdate, refNameProp); + if (logger.isDebugEnabled()) { + logger.debug("Updated " + nUpdated + " instances of oldRefName to newRefName"); + } + } } - + /** + * If no short identifier was provided in the input payload, + * generate a short identifier from the display name. + */ private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception { String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); String displayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); @@ -222,38 +291,35 @@ public abstract class AuthorityItemDocumentModelHandler // Do nothing on exception. Some vocabulary schemas may not include a short display name. } if (Tools.isEmpty(shortIdentifier)) { - String generatedShortIdentifier = AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(displayName, shortDisplayName); + String generatedShortIdentifier = + AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(displayName, shortDisplayName); docModel.setProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER, generatedShortIdentifier); } } + /** + * Generate a refName for the authority item from the short identifier + * and display name. + * + * All refNames for authority items are generated. If a client supplies + * a refName, it will be overwritten during create (per this method) + * or discarded during update (per filterReadOnlyPropertiesForPart). + * + * @see #filterReadOnlyPropertiesForPart(Map, org.collectionspace.services.common.service.ObjectPartType) + * + */ protected void updateRefnameForAuthorityItem(DocumentWrapper wrapDoc, String schemaName, String authorityRefBaseName) throws Exception { DocumentModel docModel = wrapDoc.getWrappedObject(); - String suppliedRefName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.REF_NAME); - // CSPACE-3178: - // Temporarily accept client-supplied refName values, rather than always generating such values. - // Remove first block and the surrounding 'if' statement when clients should no longer supply refName values. - if(!Tools.isEmpty(suppliedRefName) ) { - // Supplied refName must at least be legal - RefName.AuthorityItem item = RefName.AuthorityItem.parse(suppliedRefName); - if(item==null) { - logger.error("Passed refName for authority item not legal: "+suppliedRefName); - suppliedRefName = null; // Clear this and compute a new one below. - } - } - // Recheck, in case we cleared it for being illegal - if(Tools.isEmpty(suppliedRefName) ) { - String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); - String displayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); - if (Tools.isEmpty(authorityRefBaseName)) { - throw new Exception("Could not create the refName for this authority term, because the refName for its authority parent was empty."); - } - RefName.Authority authority = RefName.Authority.parse(authorityRefBaseName); - String refName = RefName.buildAuthorityItem(authority, shortIdentifier, displayName).toString(); - docModel.setProperty(schemaName, AuthorityItemJAXBSchema.REF_NAME, refName); + String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); + String displayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); + if (Tools.isEmpty(authorityRefBaseName)) { + throw new Exception("Could not create the refName for this authority term, because the refName for its authority parent was empty."); } + RefName.Authority authority = RefName.Authority.parse(authorityRefBaseName); + String refName = RefName.buildAuthorityItem(authority, shortIdentifier, displayName).toString(); + docModel.setProperty(schemaName, AuthorityItemJAXBSchema.REF_NAME, refName); } /** @@ -278,7 +344,7 @@ public abstract class AuthorityItemDocumentModelHandler throws Exception { Map unQObjectProperties = super.extractPart(docModel, schema, partMeta); - // Add the CSID to the common part + // Add the CSID to the common part, since they may have fetched via the shortId. if (partMeta.getLabel().equalsIgnoreCase(authorityItemCommonSchemaName)) { String csid = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); unQObjectProperties.put("csid", csid); @@ -305,9 +371,7 @@ public abstract class AuthorityItemDocumentModelHandler objectProps.remove(AuthorityItemJAXBSchema.IN_AUTHORITY); objectProps.remove(AuthorityItemJAXBSchema.CSID); objectProps.remove(AuthorityJAXBSchema.SHORT_IDENTIFIER); - // Enable when clients should no longer supply refName values - // objectProps.remove(AuthorityItemJAXBSchema.REF_NAME); // CSPACE-3178 - + objectProps.remove(AuthorityItemJAXBSchema.REF_NAME); } } @@ -447,13 +511,13 @@ public abstract class AuthorityItemDocumentModelHandler PoxPayloadIn input = (PoxPayloadIn) ctx.getInput(); DocumentModel documentModel = (wrapDoc.getWrappedObject()); String itemCsid = documentModel.getName(); - + //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); - */ + */ } public void completeCreate(DocumentWrapper wrapDoc) throws Exception { @@ -466,7 +530,7 @@ public abstract class AuthorityItemDocumentModelHandler handleRelationsPayload(wrapDoc, true); handleItemRefNameReferenceUpdate(); } - + // Note that we must do this after we have completed the Update, so that the repository has the // info for the item itself. The relations code must call into the repo to get info for each end. // This could be optimized to pass in the parent docModel, since it will often be one end. @@ -508,10 +572,10 @@ public abstract class AuthorityItemDocumentModelHandler parent-a */ private RelationsCommonList updateRelations( - String itemCSID, PoxPayloadIn input, DocumentWrapper wrapDoc, boolean fUpdate) + String itemCSID, PoxPayloadIn input, DocumentWrapper wrapDoc, boolean fUpdate) throws Exception { - if(logger.isTraceEnabled()) { - logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID); + if (logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: " + itemCSID); } PayloadInputPart part = input.getPart(RelationClient.SERVICE_COMMON_LIST_NAME); //input.getPart("relations_common"); if (part == null) { @@ -532,44 +596,44 @@ public abstract class AuthorityItemDocumentModelHandler UriInfo uriInfo = ctx.getUriInfo(); MultivaluedMap queryParams = uriInfo.getQueryParameters(); - if(fUpdate) { - //Run getList() once as sent to get childListOuter: - String predicate = RelationshipType.HAS_BROADER.value(); - queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); - queryParams.putSingle(IRelationsManager.SUBJECT_QP, null); - queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null); - queryParams.putSingle(IRelationsManager.OBJECT_QP, itemCSID); - queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null); - RelationsCommonList childListOuter = (new RelationResource()).getList(ctx.getUriInfo()); //magically knows all query params because they are in the context. - - //Now run getList() again, leaving predicate, swapping subject and object, to get parentListOuter. - queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); - queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemCSID); - queryParams.putSingle(IRelationsManager.OBJECT_QP, null); - RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo()); - - - childList = childListOuter.getRelationListItem(); - parentList = parentListOuter.getRelationListItem(); - - if (parentList.size() > 1) { - throw new Exception("Too many parents for object: " + itemCSID + " list: " + dumpList(parentList, "parentList")); - } - - if(logger.isTraceEnabled()) { - logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" got existing relations."); - } + if (fUpdate) { + //Run getList() once as sent to get childListOuter: + String predicate = RelationshipType.HAS_BROADER.value(); + queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); + queryParams.putSingle(IRelationsManager.SUBJECT_QP, null); + queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null); + queryParams.putSingle(IRelationsManager.OBJECT_QP, itemCSID); + queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null); + RelationsCommonList childListOuter = (new RelationResource()).getList(ctx.getUriInfo()); //magically knows all query params because they are in the context. + + //Now run getList() again, leaving predicate, swapping subject and object, to get parentListOuter. + queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); + queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemCSID); + queryParams.putSingle(IRelationsManager.OBJECT_QP, null); + RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo()); + + + childList = childListOuter.getRelationListItem(); + parentList = parentListOuter.getRelationListItem(); + + if (parentList.size() > 1) { + throw new Exception("Too many parents for object: " + itemCSID + " list: " + dumpList(parentList, "parentList")); + } + + if (logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: " + itemCSID + " got existing relations."); + } } for (RelationsCommonList.RelationListItem inboundItem : inboundList) { - // Note that the relations may specify the other (non-item) bit with a refName, not a CSID, - // and so the CSID for those may be null - if (itemCSID.equals(inboundItem.getObject().getCsid()) - && inboundItem.getPredicate().equals(HAS_BROADER)) { + // Note that the relations may specify the other (non-item) bit with a refName, not a CSID, + // and so the CSID for those may be null + if (itemCSID.equals(inboundItem.getObject().getCsid()) + && inboundItem.getPredicate().equals(HAS_BROADER)) { //then this is an item that says we have a child. That child is inboundItem - RelationsCommonList.RelationListItem childItem = - (childList==null)?null:findInList(childList, inboundItem); + RelationsCommonList.RelationListItem childItem = + (childList == null) ? null : findInList(childList, inboundItem); if (childItem != null) { removeFromList(childList, childItem); //exists, just take it off delete list } else { @@ -578,10 +642,10 @@ public abstract class AuthorityItemDocumentModelHandler ensureChildHasNoOtherParents(ctx, queryParams, inboundItem.getSubject().getCsid()); } else if (itemCSID.equals(inboundItem.getSubject().getCsid()) - && inboundItem.getPredicate().equals(HAS_BROADER)) { + && inboundItem.getPredicate().equals(HAS_BROADER)) { //then this is an item that says we have a parent. inboundItem is that parent. - RelationsCommonList.RelationListItem parentItem = - (parentList==null)?null:findInList(parentList, inboundItem); + RelationsCommonList.RelationListItem parentItem = + (parentList == null) ? null : findInList(parentList, inboundItem); if (parentItem != null) { removeFromList(parentList, parentItem); //exists, just take it off delete list } else { @@ -592,26 +656,26 @@ public abstract class AuthorityItemDocumentModelHandler //not dealing with: hasNarrower or any other predicate. } } - if(logger.isTraceEnabled()) { - String dump = dumpLists(itemCSID, parentList, childList, actionList); - //System.out.println("====dump====="+CR+dump); - logger.trace("~~~~~~~~~~~~~~~~~~~~~~dump~~~~~~~~~~~~~~~~~~~~~~~~" + CR + dump); + if (logger.isTraceEnabled()) { + String dump = dumpLists(itemCSID, parentList, childList, actionList); + //System.out.println("====dump====="+CR+dump); + logger.trace("~~~~~~~~~~~~~~~~~~~~~~dump~~~~~~~~~~~~~~~~~~~~~~~~" + CR + dump); } - if(fUpdate) { - if(logger.isTraceEnabled()) { - logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" deleting " - +parentList.size()+" existing parents and "+childList.size()+" existing children."); + if (fUpdate) { + if (logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: " + itemCSID + " deleting " + + parentList.size() + " existing parents and " + childList.size() + " existing children."); } - deleteRelations(parentList, ctx, "parentList"); //todo: there are items appearing on both lists....april 20. - deleteRelations(childList, ctx, "childList"); + deleteRelations(parentList, ctx, "parentList"); //todo: there are items appearing on both lists....april 20. + deleteRelations(childList, ctx, "childList"); } - if(logger.isTraceEnabled()) { - logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" adding " - +actionList.size()+" new parents and children."); + if (logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: " + itemCSID + " adding " + + actionList.size() + " new parents and children."); } createRelations(actionList, ctx); - if(logger.isTraceEnabled()) { - logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" done."); + if (logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: " + itemCSID + " done."); } //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. @@ -682,13 +746,13 @@ public abstract class AuthorityItemDocumentModelHandler inboundItemObject.setCsid(itemCSID); //inboundItemObject.setUri(getUri(docModel)); } else { - /* + /* String objectCsid = inboundItemObject.getCsid(); DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, objectCsid); //null if not found. DocumentWrapper wrapper = new DocumentWrapperImpl(itemDocModel); String uri = this.getRepositoryClient(ctx).getDocURI(wrapper); inboundItemObject.setUri(uri); //CSPACE-4037 - */ + */ } //uriPointsToSameAuthority(thisURI, inboundItemObject.getUri()); //CSPACE-4042 @@ -697,13 +761,13 @@ public abstract class AuthorityItemDocumentModelHandler inboundItemSubject.setCsid(itemCSID); //inboundItemSubject.setUri(getUri(docModel)); } else { - /* + /* String subjectCsid = inboundItemSubject.getCsid(); DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, subjectCsid); //null if not found. DocumentWrapper wrapper = new DocumentWrapperImpl(itemDocModel); String uri = this.getRepositoryClient(ctx).getDocURI(wrapper); inboundItemSubject.setUri(uri); //CSPACE-4037 - */ + */ } //uriPointsToSameAuthority(thisURI, inboundItemSubject.getUri()); //CSPACE-4042 @@ -723,12 +787,10 @@ 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()); @@ -739,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()); @@ -753,10 +812,9 @@ 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. + 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/blob/3rdparty/nuxeo-platform-cs-blob/src/main/resources/schemas/blobs_common.xsd b/services/blob/3rdparty/nuxeo-platform-cs-blob/src/main/resources/schemas/blobs_common.xsd index eb029c315..cbc5707d2 100644 --- a/services/blob/3rdparty/nuxeo-platform-cs-blob/src/main/resources/schemas/blobs_common.xsd +++ b/services/blob/3rdparty/nuxeo-platform-cs-blob/src/main/resources/schemas/blobs_common.xsd @@ -27,27 +27,42 @@ - + + - + + - + - + + + + + + + + + + + + + + - + - + diff --git a/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java b/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java index 493d5fa3a..ceac6ee94 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java +++ b/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java @@ -56,6 +56,19 @@ public interface IQueryManager { public String createWhereClauseFromAdvancedSearch(String advancedSearch); + final static boolean FILTER_EXCLUDE = true; + final static boolean FILTER_INCLUDE = false; + + /** + * Creates a query to filter a qualified (string) field according to a list of string values. + * @param qualifiedField The schema-qualified field to filter on + * @param filterTerms the list of one or more strings to filter on + * @param fExclude If true, will require qualifiedField NOT match the filters strings. + * If false, will require qualifiedField does match one of the filters strings. + * @return queryString + */ + public String createWhereClauseToFilterFromStringList(String qualifiedField, String[] filterTerms, boolean fExclude); + /** * Creates the where clause for partial term match. * diff --git a/services/collectionobject/3rdparty/nuxeo-platform-collectionobject-lifesci/src/main/resources/schemas/collectionobjects_naturalhistory.xsd b/services/collectionobject/3rdparty/nuxeo-platform-collectionobject-lifesci/src/main/resources/schemas/collectionobjects_naturalhistory.xsd index 40118113d..895a69a7d 100644 --- a/services/collectionobject/3rdparty/nuxeo-platform-collectionobject-lifesci/src/main/resources/schemas/collectionobjects_naturalhistory.xsd +++ b/services/collectionobject/3rdparty/nuxeo-platform-collectionobject-lifesci/src/main/resources/schemas/collectionobjects_naturalhistory.xsd @@ -33,111 +33,111 @@ --> - - + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + - - - - - - - - - - - + + + + + + + + + + + - - - + + - - - - - - - - - - - + + + + + + + + + + + - - - + + - - - - - - - - - + + + + + + + + + diff --git a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd index c715c883a..feeb20232 100644 --- a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd +++ b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd @@ -82,12 +82,7 @@ - - - - - - + @@ -143,18 +138,8 @@ - - - - - - - - - - - - + + @@ -213,9 +198,7 @@ - - - + @@ -326,7 +309,7 @@ - + @@ -394,13 +377,13 @@ - - - - - - - + + + + + + + @@ -432,7 +415,7 @@ - + @@ -457,7 +440,7 @@ - + @@ -473,21 +456,35 @@ - + + - - + + + + + + + + + + + + + + - + @@ -508,11 +505,11 @@ - - - - - + + + + + @@ -541,28 +538,10 @@ - + - - - - - - - - - - - - - - - - - - - - + @@ -702,7 +681,7 @@ - + @@ -774,29 +753,48 @@ - - - - - + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index f6317738a..09c7b32ef 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -39,15 +39,19 @@ import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.BriefDescriptionList; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory; -import org.collectionspace.services.collectionobject.ResponsibleDepartmentList; -import org.collectionspace.services.collectionobject.DimensionGroup; -import org.collectionspace.services.collectionobject.DimensionList; +import org.collectionspace.services.collectionobject.DimensionSubGroup; +import org.collectionspace.services.collectionobject.DimensionSubGroupList; +import org.collectionspace.services.collectionobject.MeasuredPartGroup; +import org.collectionspace.services.collectionobject.MeasuredPartGroupList; import org.collectionspace.services.collectionobject.ObjectNameGroup; import org.collectionspace.services.collectionobject.ObjectNameList; import org.collectionspace.services.collectionobject.OtherNumber; import org.collectionspace.services.collectionobject.OtherNumberList; +import org.collectionspace.services.collectionobject.ResponsibleDepartmentList; import org.collectionspace.services.collectionobject.TitleGroup; import org.collectionspace.services.collectionobject.TitleGroupList; +import org.collectionspace.services.collectionobject.TitleTranslationSubGroup; +import org.collectionspace.services.collectionobject.TitleTranslationSubGroupList; import org.collectionspace.services.common.AbstractCommonListUtils; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -77,9 +81,10 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { private final String OBJECT_NAME_VALUE = "an object name"; private final BigInteger AGE_VALUE = new BigInteger("55"); + private final String MEASURED_PART = "light box frame"; private final BigDecimal DIMENSION_VALUE_LENGTH = new BigDecimal("0.009"); private final BigDecimal DIMENSION_VALUE_WIDTH = new BigDecimal("3087.56"); - private final String UPDATED_MEASURED_PART_VALUE = "updated measured part value"; + private final String UPDATED_MEASUREMENT_UNIT = "Angstroms"; private final String UTF8_DATA_SAMPLE = "Audiorecording album cover signed by Lech " + "Wa" + '\u0142' + '\u0119' + "sa"; @@ -628,14 +633,26 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Verify the number and contents of values in repeatable fields, // as created in the instance record used for testing. - DimensionList dimensionList = collectionobjectCommon.getDimensions(); - Assert.assertNotNull(dimensionList); - List dimensionsGroups = dimensionList.getDimensionGroup(); - Assert.assertNotNull(dimensionsGroups); - Assert.assertTrue(dimensionsGroups.size() > 0); - Assert.assertNotNull(dimensionsGroups.get(0)); - Assert.assertNotNull(dimensionsGroups.get(0).getMeasuredPart()); - + MeasuredPartGroupList measuredPartGroupList = collectionobjectCommon.getMeasuredPartGroupList(); + Assert.assertNotNull(measuredPartGroupList, "Measured part group list was null"); + List measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup(); + Assert.assertNotNull(measuredPartGroups, "Measured part groups were null"); + Assert.assertTrue(measuredPartGroups.size() > 0, "No measured part groups were returned"); + MeasuredPartGroup mpGroup = measuredPartGroups.get(0); + Assert.assertNotNull(mpGroup.getMeasuredPart(), "Measured part was null"); + Assert.assertEquals(mpGroup.getMeasuredPart(), MEASURED_PART, + "Measured part value returned didn't match expected value"); + + DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList(); + Assert.assertNotNull(dimensionSubGroupList, "Dimension subgroup list was null"); + List dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup(); + Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups were null"); + Assert.assertTrue(dimensionSubGroups.size() > 0, "No dimension subgroups were returned"); + DimensionSubGroup lengthDimension = dimensionSubGroups.get(0); + Assert.assertNotNull(lengthDimension, "Length dimension was null"); + Assert.assertTrue(lengthDimension.getValue().compareTo(DIMENSION_VALUE_LENGTH) == 0, + "Dimension length value returned didn't match expected value"); + /* No longer part of the "default" domain service tests for the CollectionObject record. if (logger.isDebugEnabled()) { logger.debug(testName + ": Reading Natural History part ..."); @@ -762,21 +779,32 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Replace the existing value instances in the dimensions repeatable group // with entirely new value instances, also changing the number of such instances. - DimensionList dimensionList = collectionObjectCommon.getDimensions(); - Assert.assertNotNull(dimensionList); - List dimensionGroups = dimensionList.getDimensionGroup(); - Assert.assertNotNull(dimensionGroups); - int originalDimensionGroupSize = dimensionGroups.size(); - Assert.assertTrue(originalDimensionGroupSize >= 1); - - DimensionGroup updatedDimensionGroup = new DimensionGroup(); - updatedDimensionGroup.setMeasuredPart(UPDATED_MEASURED_PART_VALUE); - dimensionGroups.clear(); - dimensionGroups.add(updatedDimensionGroup); - int updatedDimensionGroupSize = dimensionGroups.size(); - Assert.assertTrue(updatedDimensionGroupSize >= 1); - Assert.assertTrue(updatedDimensionGroupSize != originalDimensionGroupSize); - collectionObjectCommon.setDimensions(dimensionList); + MeasuredPartGroupList measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList(); + Assert.assertNotNull(measuredPartGroupList); + List measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup(); + Assert.assertNotNull(measuredPartGroups); + Assert.assertTrue(measuredPartGroups.size() > 0); + MeasuredPartGroup mpGroup = measuredPartGroups.get(0); + Assert.assertNotNull(mpGroup.getMeasuredPart()); + + DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList(); + Assert.assertNotNull(dimensionSubGroupList); + List dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup(); + Assert.assertNotNull(dimensionSubGroups); + int originalDimensionSubGroupSize = dimensionSubGroups.size(); + Assert.assertTrue(dimensionSubGroups.size() > 0); + dimensionSubGroups.clear(); + + DimensionSubGroup heightDimension = new DimensionSubGroup(); + heightDimension.setDimension("height"); + heightDimension.setMeasurementUnit(UPDATED_MEASUREMENT_UNIT); + dimensionSubGroups.add(heightDimension); + + int updatedDimensionGroupSize = dimensionSubGroups.size(); + Assert.assertTrue(updatedDimensionGroupSize > 0); + Assert.assertTrue(updatedDimensionGroupSize != originalDimensionSubGroupSize); + + collectionObjectCommon.setMeasuredPartGroupList(measuredPartGroupList); if (logger.isDebugEnabled()) { logger.debug("sparse update that will be sent in update request:"); @@ -801,13 +829,22 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { objNameGroups.get(0).getObjectName(), "Data in updated object did not match submitted data."); - dimensionList = updatedCollectionobjectCommon.getDimensions(); - Assert.assertNotNull(dimensionList); - dimensionGroups = dimensionList.getDimensionGroup(); - Assert.assertNotNull(dimensionGroups); - Assert.assertTrue(dimensionGroups.size() == updatedDimensionGroupSize); - Assert.assertEquals(UPDATED_MEASURED_PART_VALUE, - dimensionGroups.get(0).getMeasuredPart(), + measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList(); + Assert.assertNotNull(measuredPartGroupList); + measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup(); + Assert.assertNotNull(measuredPartGroups); + Assert.assertTrue(measuredPartGroups.size() > 0); + mpGroup = measuredPartGroups.get(0); + Assert.assertNotNull(mpGroup.getMeasuredPart()); + + dimensionSubGroupList = mpGroup.getDimensionSubGroupList(); + Assert.assertNotNull(dimensionSubGroupList); + dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup(); + Assert.assertNotNull(dimensionSubGroups); + Assert.assertTrue(dimensionSubGroups.size() > 0); + Assert.assertTrue(dimensionSubGroups.size() == updatedDimensionGroupSize); + Assert.assertEquals(UPDATED_MEASUREMENT_UNIT, + dimensionSubGroups.get(0).getMeasurementUnit(), "Data in updated object did not match submitted data."); } @@ -1237,6 +1274,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { TitleGroupList titleGroupList = new TitleGroupList(); List titleGroups = titleGroupList.getTitleGroup(); + Assert.assertNotNull(titleGroups); TitleGroup titleGroup = new TitleGroup(); titleGroup.setTitle("a title"); titleGroups.add(titleGroup); @@ -1249,22 +1287,32 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { objNameGroups.add(objectNameGroup); collectionObject.setObjectNameList(objNameList); - DimensionList dimensionList = new DimensionList(); - List dimensionGroups = dimensionList.getDimensionGroup(); - DimensionGroup dimensionGroup1 = new DimensionGroup(); - dimensionGroup1.setMeasuredPart("head"); - dimensionGroup1.setDimension("length"); - dimensionGroup1.setValue(DIMENSION_VALUE_LENGTH); - dimensionGroup1.setMeasurementUnit("cm"); - DimensionGroup dimensionGroup2 = new DimensionGroup(); - dimensionGroup2.setMeasuredPart("leg"); - dimensionGroup2.setDimension("width"); - dimensionGroup2.setValue(DIMENSION_VALUE_WIDTH); - dimensionGroup2.setMeasurementUnit("m"); - dimensionGroup2.setValueQualifier(""); // test null string - dimensionGroups.add(dimensionGroup1); - dimensionGroups.add(dimensionGroup2); - collectionObject.setDimensions(dimensionList); + MeasuredPartGroupList measuredPartGroupList = new MeasuredPartGroupList(); + List measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup(); + Assert.assertNotNull(measuredPartGroups, "Measured part groups are null"); + MeasuredPartGroup measuredPartGroup = new MeasuredPartGroup(); + measuredPartGroup.setMeasuredPart(MEASURED_PART); + + DimensionSubGroupList dimensionSubGroupList = new DimensionSubGroupList(); + List dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup(); + Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups are null"); + + DimensionSubGroup lengthDimension = new DimensionSubGroup(); + lengthDimension.setDimension("length"); + lengthDimension.setValue(DIMENSION_VALUE_LENGTH); + lengthDimension.setMeasurementUnit("cm"); + dimensionSubGroups.add(lengthDimension); + + DimensionSubGroup widthDimension = new DimensionSubGroup(); + widthDimension.setDimension("width"); + widthDimension.setValue(DIMENSION_VALUE_WIDTH); + widthDimension.setMeasurementUnit("m"); + widthDimension.setValueQualifier(""); // test empty string + dimensionSubGroups.add(widthDimension); + + measuredPartGroup.setDimensionSubGroupList(dimensionSubGroupList); + measuredPartGroups.add(measuredPartGroup); + collectionObject.setMeasuredPartGroupList(measuredPartGroupList); // Repeatable scalar fields diff --git a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd index 1101a1a4a..08d00c9fb 100644 --- a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd +++ b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd @@ -63,7 +63,7 @@ - + @@ -77,18 +77,8 @@ - - - - - - - - - - - - + + @@ -133,9 +123,7 @@ - - - + @@ -232,13 +220,13 @@ - - - - - - - + + + + + + + @@ -270,9 +258,9 @@ - + - + @@ -295,7 +283,7 @@ - + @@ -388,22 +376,36 @@ - - + + + - - + + + + + + + + + + + + + + - + @@ -430,11 +432,11 @@ - - - - - + + + + + @@ -469,34 +471,10 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -539,7 +517,7 @@ - + @@ -666,7 +644,7 @@ - + @@ -756,18 +734,18 @@ - - - - - + + + + + - - - - - - + + + + + + @@ -792,6 +770,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java b/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java index dff7526a1..c1bac1fa8 100755 --- a/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java +++ b/services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java @@ -171,6 +171,7 @@ public class Tools { } StringBuffer sb = new StringBuffer(); int i = 0; + // BUG - \n is not the separator on all systems. Have to use the system line separator. String[] foo = result.split("\n"); for (String line: foo){ i++; diff --git a/services/common/build.xml b/services/common/build.xml index 98d9ac8bd..c1e94aa76 100644 --- a/services/common/build.xml +++ b/services/common/build.xml @@ -138,6 +138,13 @@ + + + + + + @@ -154,11 +161,7 @@ - - - - - + localeLanguageda --> - + - + + /blobs/*/workflow/ default-domain @@ -852,13 +853,10 @@ authRef borrowersAuthorizer - - - + + /media/*/workflow/ default-domain org.collectionspace.services.media.nuxeo.MediaDocumentModelHandler @@ -1432,7 +1431,7 @@ - + /vocabularies/*/workflow/ /vocabularies/*/items/*/workflow/ @@ -1497,7 +1496,7 @@ Note there is no Vocabularyitem service, but there is a Repository workspace so we have to configure that. --> - + /vocabularyitems/*/workflow/ order order @@ -1570,7 +1558,7 @@ - + /orgauthorities/*/workflow/ /orgauthorities/*/items/*/workflow/ @@ -1638,7 +1626,7 @@ Note there is no Organization service, but there is a Repository workspace so we have to configure that. --> - + @@ -1753,7 +1730,7 @@ - + /personauthorities/*/workflow/ /personauthorities/*/items/*/workflow/ @@ -1824,7 +1801,7 @@ Note there is no Person service, but there is a Repository workspace so we have to configure that. --> - + @@ -1880,6 +1846,14 @@ + + + + + + + + @@ -1954,14 +1928,6 @@ --> - - - - - - - - @@ -1972,7 +1938,7 @@ - + /locationauthorities/*/workflow/ /locationauthorities/*/items/*/workflow/ @@ -2039,24 +2005,13 @@ Note there is no Location service, but there is a Repository workspace so we have to configure that. --> - + default-domain org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler - - displayName - displayName - - - shortIdentifier - shortIdentifier - - - refName - refName - + @@ -2120,7 +2075,7 @@ - + /taxonomyauthority/*/workflow/ /taxonomyauthority/*/items/*/workflow/ @@ -2187,24 +2142,13 @@ Note there is no Taxon service, but there is a Repository workspace so we have to configure that. --> - + default-domain org.collectionspace.services.taxonomy.nuxeo.TaxonDocumentModelHandler - - displayName - displayName - - - shortIdentifier - shortIdentifier - - - refName - refName - + @@ -2397,7 +2341,7 @@ - + /relations/*/workflow/ default-domain @@ -2454,7 +2398,7 @@ objectNameProperty - documentId1 + subjectCsid objectNumberProperty @@ -2473,7 +2417,7 @@ relations_common - documentid1,documentid2 + subjectcsid,objectcsid @@ -2497,7 +2441,7 @@ - + org.collectionspace.services.account.storage.AccountDocumentHandler @@ -2543,7 +2487,7 @@ - + /dimensions/*/workflow/ default-domain @@ -2568,7 +2512,7 @@ - + - + default-domain org.collectionspace.services.note.nuxeo.NoteDocumentModelHandler @@ -2677,7 +2621,7 @@ - + org.collectionspace.services.authorization.storage.RoleDocumentHandler org.collectionspace.services.authorization.storage.RoleValidatorHandler @@ -2696,7 +2640,7 @@ - + org.collectionspace.services.authorization.storage.PermissionDocumentHandler org.collectionspace.services.authorization.storage.PermissionValidatorHandler @@ -2717,7 +2661,7 @@ - + - + - + - + @@ -81,7 +81,7 @@ - + @@ -94,11 +94,11 @@ - + - + diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java index eb826ced6..c2c377d18 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java @@ -39,6 +39,7 @@ import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.intake.ConditionCheckerOrAssessorList; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.intake.InsurerList; @@ -81,6 +82,8 @@ public class IntakeAuthRefsTest extends BaseServiceTest { private String insurerRefName = null; private String valuerRefName = null; private final int NUM_AUTH_REFS_EXPECTED = 5; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); @Override protected String getServiceName() { @@ -126,7 +129,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { IntakeClient intakeClient = new IntakeClient(); PoxPayloadOut multipart = createIntakeInstance( "entryNumber-" + identifier, - "entryDate-" + identifier, + CURRENT_DATE_UTC, currentOwnerRefName, depositorRefName, conditionCheckerOrAssessorRefName, diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index 4a5fbbfc1..055323dad 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -65,6 +65,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { private final Logger logger = LoggerFactory.getLogger(IntakeServiceTest.class); /** The known resource id. */ private String knownResourceId = null; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); @Override protected CollectionSpaceClient getClientInstance() { @@ -465,7 +467,6 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Update the content of this resource. intakeCommons.setEntryNumber("updated-" + intakeCommons.getEntryNumber()); - intakeCommons.setEntryDate("updated-" + intakeCommons.getEntryDate()); if (logger.isDebugEnabled()) { logger.debug("to be updated object"); logger.debug(objectAsXmlString(intakeCommons, IntakesCommon.class)); @@ -507,8 +508,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(updatedIntake); - Assert.assertEquals(updatedIntake.getEntryDate(), - intakeCommons.getEntryDate(), + Assert.assertEquals(updatedIntake.getEntryNumber(), + intakeCommons.getEntryNumber(), "Data in updated object did not match submitted data."); currentLocationGroupList = updatedIntake.getCurrentLocationGroupList(); @@ -908,7 +909,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { protected PoxPayloadOut createInstance(String identifier) { return createIntakeInstance( "entryNumber-" + identifier, - "entryDate-" + identifier, + CURRENT_DATE_UTC, "depositor-" + identifier); } diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java index 51b062e45..03cf89909 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java @@ -38,6 +38,7 @@ import org.collectionspace.services.client.OrgAuthorityClientUtils; import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.intake.ConditionCheckerOrAssessorList; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.intake.InsurerList; @@ -82,6 +83,8 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { private String insurerRefName = null; private String valuerRefName = null; private final int NUM_AUTH_REF_DOCS_EXPECTED = 1; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); @Override protected String getServiceName() { @@ -126,7 +129,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { IntakeClient intakeClient = new IntakeClient(); PoxPayloadOut multipart = createIntakeInstance( "entryNumber-" + identifier, - "entryDate-" + identifier, + CURRENT_DATE_UTC, currentOwnerRefName, // Use currentOwnerRefName twice to test fix for CSPACE-2863 currentOwnerRefName, //depositorRefName, diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java index 8d99147c6..0cbb97b3e 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java @@ -38,6 +38,7 @@ import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.intake.ConditionCheckerOrAssessorList; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.intake.InsurerList; @@ -84,6 +85,8 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { private String valuerRefName = null; private String valuerShortId = null; private final int NUM_AUTH_REF_DOCS_EXPECTED = 1; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); @Override public String getServiceName() { @@ -128,7 +131,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { IntakeClient intakeClient = new IntakeClient(); PoxPayloadOut multipart = createIntakeInstance( "entryNumber-" + identifier, - "entryDate-" + identifier, + CURRENT_DATE_UTC, currentOwnerRefName, depositorRefName, conditionCheckerAssessorRefName, diff --git a/services/jaxb/src/main/resources/authorityrefdocs.xsd b/services/jaxb/src/main/resources/authorityrefdocs.xsd index 76f5c4f17..6b555c176 100644 --- a/services/jaxb/src/main/resources/authorityrefdocs.xsd +++ b/services/jaxb/src/main/resources/authorityrefdocs.xsd @@ -47,6 +47,7 @@ + diff --git a/services/jaxb/src/main/resources/blobs_common.xsd b/services/jaxb/src/main/resources/blobs_common.xsd index 1ac4adc5b..252865557 100644 --- a/services/jaxb/src/main/resources/blobs_common.xsd +++ b/services/jaxb/src/main/resources/blobs_common.xsd @@ -37,28 +37,41 @@ - + - + - + - + - - + + + + + + + + + + + + + + + - + 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/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/schemas/loansin_common.xsd b/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/schemas/loansin_common.xsd index b6ec0d882..6503d151b 100644 --- a/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/schemas/loansin_common.xsd +++ b/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/schemas/loansin_common.xsd @@ -24,13 +24,16 @@ + + - - - + + + + @@ -43,9 +46,24 @@ - + + + + + + + + + + + + + + + diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java index f6e2dcf3c..c21b3a400 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java @@ -41,6 +41,7 @@ import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.loanin.LenderGroup; import org.collectionspace.services.loanin.LenderGroupList; @@ -83,6 +84,8 @@ public class LoaninAuthRefsTest extends BaseServiceTest { // FIXME: Value changed from 5 to 2 when repeatable / multivalue 'lenders' // group was added to tenant-bindings.xml private final int NUM_AUTH_REFS_EXPECTED = 2; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -126,7 +129,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { LoaninClient loaninClient = new LoaninClient(); PoxPayloadOut multipart = createLoaninInstance( "loanInNumber-" + identifier, - "returnDate-" + identifier, + CURRENT_DATE_UTC, lenderRefName, lendersAuthorizerRefName, lendersContactRefName, diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java index a101f8823..a2820ff57 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java @@ -34,6 +34,7 @@ import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.AbstractCommonListUtils; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.loanin.LenderGroup; import org.collectionspace.services.loanin.LenderGroupList; @@ -65,7 +66,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { /** The known resource id. */ private String knownResourceId = null; private String LENDER_REF_NAME = - "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Harry Lender)'Harry Lender'"; + "urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(HarryLender)'Harry Lender'"; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -477,7 +480,6 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { // Update the content of this resource. loaninCommon.setLoanInNumber("updated-" + loaninCommon.getLoanInNumber()); - loaninCommon.setLoanReturnDate("updated-" + loaninCommon.getLoanReturnDate()); loaninCommon.setLoanInNote("updated-" + loaninCommon.getLoanInNote()); if (logger.isDebugEnabled()) { logger.debug("to be updated object"); @@ -513,8 +515,8 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(updatedLoaninCommon); // Check selected fields in the updated common part. - Assert.assertEquals(updatedLoaninCommon.getLoanReturnDate(), - loaninCommon.getLoanReturnDate(), + Assert.assertEquals(updatedLoaninCommon.getLoanInNumber(), + loaninCommon.getLoanInNumber(), "Data in updated object did not match submitted data."); if (logger.isDebugEnabled()) { @@ -831,7 +833,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { LoansinCommon loaninCommon = new LoansinCommon(); loaninCommon.setLoanInNumber(loaninNumber); - loaninCommon.setLoanReturnDate(returnDate); + loaninCommon.setLoanReturnDate(CURRENT_DATE_UTC); LenderGroupList lenderGroupList = new LenderGroupList(); LenderGroup lenderGroup = new LenderGroup(); lenderGroup.setLender(LENDER_REF_NAME); diff --git a/services/loanin/jaxb/src/main/resources/loansin-common.xsd b/services/loanin/jaxb/src/main/resources/loansin-common.xsd index 9fe86ee67..f330feae4 100644 --- a/services/loanin/jaxb/src/main/resources/loansin-common.xsd +++ b/services/loanin/jaxb/src/main/resources/loansin-common.xsd @@ -27,39 +27,56 @@ --> - + - - + + + + - - + - + - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd index 428076085..beee4fe49 100644 --- a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd +++ b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd @@ -23,31 +23,33 @@ + + - + - + - - - + + + - + - + - + - - - + + + diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java index dd96fe9cc..543f355d9 100644 --- a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java +++ b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java @@ -40,6 +40,7 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; //import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.loanout.LoansoutCommon; //import org.collectionspace.services.loanout.LoansoutCommonList; @@ -82,6 +83,9 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { // authority - as an authRef to tests below, and increase the // number of expected authRefs to 4. private final int NUM_AUTH_REFS_EXPECTED = 4; + + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -125,7 +129,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { LoanoutClient loanoutClient = new LoanoutClient(); PoxPayloadOut multipart = createLoanoutInstance( "loanOutNumber-" + identifier, - "returnDate-" + identifier, + CURRENT_DATE_UTC, borrowerRefName, borrowersContactRefName, lendersAuthorizerRefName, diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java index 960397b64..346b757f1 100644 --- a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java +++ b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java @@ -33,9 +33,10 @@ import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.AbstractCommonListUtils; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.loanout.LoanedObjectStatusGroup; -import org.collectionspace.services.loanout.LoanedObjectStatusGroupList; +import org.collectionspace.services.loanout.LoanStatusGroup; +import org.collectionspace.services.loanout.LoanStatusGroupList; import org.collectionspace.services.loanout.LoansoutCommon; import org.jboss.resteasy.client.ClientResponse; @@ -60,6 +61,8 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); /** The known resource id. */ private String knownResourceId = null; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -303,14 +306,14 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { // Check selected fields in the common part. Assert.assertNotNull(loanoutCommon.getLoanOutNumber()); - LoanedObjectStatusGroupList statusGroupList = loanoutCommon.getLoanedObjectStatusGroupList(); + LoanStatusGroupList statusGroupList = loanoutCommon.getLoanStatusGroupList(); Assert.assertNotNull(statusGroupList); - List statusGroups = statusGroupList.getLoanedObjectStatusGroup(); + List statusGroups = statusGroupList.getLoanStatusGroup(); Assert.assertNotNull(statusGroups); Assert.assertTrue(statusGroups.size() > 0); - LoanedObjectStatusGroup statusGroup = statusGroups.get(0); + LoanStatusGroup statusGroup = statusGroups.get(0); Assert.assertNotNull(statusGroup); - Assert.assertNotNull(statusGroup.getLoanedObjectStatus()); + Assert.assertNotNull(statusGroup.getLoanStatus()); // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters. if (logger.isDebugEnabled()) { @@ -436,19 +439,18 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { // Update the content of this resource. loanoutCommon.setLoanOutNumber("updated-" + loanoutCommon.getLoanOutNumber()); - loanoutCommon.setLoanReturnDate("updated-" + loanoutCommon.getLoanReturnDate()); - LoanedObjectStatusGroupList statusGroupList = loanoutCommon.getLoanedObjectStatusGroupList(); + LoanStatusGroupList statusGroupList = loanoutCommon.getLoanStatusGroupList(); Assert.assertNotNull(statusGroupList); - List statusGroups = statusGroupList.getLoanedObjectStatusGroup(); + List statusGroups = statusGroupList.getLoanStatusGroup(); Assert.assertNotNull(statusGroups); Assert.assertTrue(statusGroups.size() > 0); - LoanedObjectStatusGroup statusGroup = statusGroups.get(0); + LoanStatusGroup statusGroup = statusGroups.get(0); Assert.assertNotNull(statusGroup); - String loanedObjectStatus = statusGroup.getLoanedObjectStatus(); - Assert.assertNotNull(loanedObjectStatus); - String updatedLoanedObjectStatus = "updated-" + loanedObjectStatus; - statusGroups.get(0).setLoanedObjectStatus(updatedLoanedObjectStatus); - loanoutCommon.setLoanedObjectStatusGroupList(statusGroupList); + String loanStatus = statusGroup.getLoanStatus(); + Assert.assertNotNull(loanStatus); + String updatedLoanStatus = "updated-" + loanStatus; + statusGroups.get(0).setLoanStatus(updatedLoanStatus); + loanoutCommon.setLoanStatusGroupList(statusGroupList); if (logger.isDebugEnabled()) { logger.debug("to be updated object"); logger.debug(objectAsXmlString(loanoutCommon, LoansoutCommon.class)); @@ -480,20 +482,20 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(updatedLoanoutCommon); // Check selected fields in the updated resource. - Assert.assertEquals(updatedLoanoutCommon.getLoanReturnDate(), - loanoutCommon.getLoanReturnDate(), + Assert.assertEquals(updatedLoanoutCommon.getLoanOutNumber(), + loanoutCommon.getLoanOutNumber(), "Data in updated object did not match submitted data."); - LoanedObjectStatusGroupList updatedStatusGroupList = - updatedLoanoutCommon.getLoanedObjectStatusGroupList(); + LoanStatusGroupList updatedStatusGroupList = + updatedLoanoutCommon.getLoanStatusGroupList(); Assert.assertNotNull(updatedStatusGroupList); - List updatedStatusGroups = - updatedStatusGroupList.getLoanedObjectStatusGroup(); + List updatedStatusGroups = + updatedStatusGroupList.getLoanStatusGroup(); Assert.assertNotNull(updatedStatusGroups); Assert.assertTrue(updatedStatusGroups.size() > 0); Assert.assertNotNull(updatedStatusGroups.get(0)); - Assert.assertEquals(updatedLoanedObjectStatus, - updatedStatusGroups.get(0).getLoanedObjectStatus(), + Assert.assertEquals(updatedLoanStatus, + updatedStatusGroups.get(0).getLoanStatus(), "Data in updated object did not match submitted data."); // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters. @@ -773,7 +775,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { private PoxPayloadOut createLoanoutInstance(String identifier) { return createLoanoutInstance( "loanoutNumber-" + identifier, - "returnDate-" + identifier); + CURRENT_DATE_UTC); } /** @@ -789,17 +791,17 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { loanoutCommon.setLoanOutNumber(loanOutNumber); loanoutCommon.setLoanReturnDate(returnDate); loanoutCommon.setBorrower( - "urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'"); + "urn:cspace:org.collectionspace.demo:orgauthorities:name(TestOrgAuth):item:name(NorthernClimesMuseum)'Northern Climes Museum'"); loanoutCommon.setBorrowersContact( - "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Chris Contact)'Chris Contact'"); + "urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(ChrisContact)'Chris Contact'"); loanoutCommon.setLoanPurpose("Allow people in cold climes to share the magic of Surfboards of the 1960s."); - LoanedObjectStatusGroupList statusGroupList = new LoanedObjectStatusGroupList(); - List statusGroups = statusGroupList.getLoanedObjectStatusGroup(); - LoanedObjectStatusGroup statusGroup = new LoanedObjectStatusGroup(); - statusGroup.setLoanedObjectStatus("returned"); - statusGroup.setLoanedObjectStatusNote("Left under the front mat."); + LoanStatusGroupList statusGroupList = new LoanStatusGroupList(); + List statusGroups = statusGroupList.getLoanStatusGroup(); + LoanStatusGroup statusGroup = new LoanStatusGroup(); + statusGroup.setLoanStatus("returned"); + statusGroup.setLoanStatusNote("Left under the front mat."); statusGroups.add(statusGroup); - loanoutCommon.setLoanedObjectStatusGroupList(statusGroupList); + loanoutCommon.setLoanStatusGroupList(statusGroupList); loanoutCommon.setLoanOutNote(getUTF8DataFragment()); // For UTF-8 tests PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); diff --git a/services/loanout/jaxb/src/main/resources/loansout-common.xsd b/services/loanout/jaxb/src/main/resources/loansout-common.xsd index 6f69e019f..0bbb9b50e 100644 --- a/services/loanout/jaxb/src/main/resources/loansout-common.xsd +++ b/services/loanout/jaxb/src/main/resources/loansout-common.xsd @@ -34,12 +34,14 @@ + + - + @@ -51,20 +53,19 @@ - + - + - + - - - + + + - diff --git a/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd b/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd index 738bf80ab..d0c24796d 100644 --- a/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd +++ b/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd @@ -49,7 +49,7 @@ - + diff --git a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java index 0f4e44fc3..e6df03a94 100644 --- a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java +++ b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java @@ -34,6 +34,7 @@ import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.AbstractCommonListUtils; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.client.LocationAuthorityClient; import org.collectionspace.services.client.LocationAuthorityClientUtils; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -65,6 +66,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI private final Logger logger = LoggerFactory.getLogger(LocationAuthorityServiceTest.class); private final String REFNAME = "refName"; private final String DISPLAYNAME = "displayName"; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); @Override public String getServicePathComponent() { @@ -94,7 +97,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI final String TEST_NAME = "Shelf 1"; final String TEST_SHORTID = "shelf1"; final String TEST_CONDITION_NOTE = "Basically clean"; - final String TEST_CONDITION_NOTE_DATE = "June 11, 1979"; + final String TEST_CONDITION_NOTE_DATE = CURRENT_DATE_UTC; final String TEST_SECURITY_NOTE = "Kind of safe"; final String TEST_ACCESS_NOTE = "Only right-thinkers may see"; final String TEST_ADDRESS = "123 Main Street, Anytown USA"; diff --git a/services/media/3rdparty/nuxeo-platform-cs-media/src/main/resources/schemas/media_common.xsd b/services/media/3rdparty/nuxeo-platform-cs-media/src/main/resources/schemas/media_common.xsd index 74e1265db..d3b9f05dc 100644 --- a/services/media/3rdparty/nuxeo-platform-cs-media/src/main/resources/schemas/media_common.xsd +++ b/services/media/3rdparty/nuxeo-platform-cs-media/src/main/resources/schemas/media_common.xsd @@ -36,8 +36,9 @@ - - + + + @@ -78,21 +79,35 @@ - + + - - + + + + + + + + + + + + + + - + diff --git a/services/media/jaxb/src/main/resources/media_common.xsd b/services/media/jaxb/src/main/resources/media_common.xsd index 8150912dc..2040536da 100644 --- a/services/media/jaxb/src/main/resources/media_common.xsd +++ b/services/media/jaxb/src/main/resources/media_common.xsd @@ -40,8 +40,8 @@ - - + + @@ -50,8 +50,8 @@ - - + + @@ -67,15 +67,29 @@ - + + - - + + + + + + + + + + + + + + diff --git a/services/movement/3rdparty/nuxeo-platform-cs-movement/src/main/resources/schemas/movements_common.xsd b/services/movement/3rdparty/nuxeo-platform-cs-movement/src/main/resources/schemas/movements_common.xsd index 5cdf43fcb..21261a2bf 100644 --- a/services/movement/3rdparty/nuxeo-platform-cs-movement/src/main/resources/schemas/movements_common.xsd +++ b/services/movement/3rdparty/nuxeo-platform-cs-movement/src/main/resources/schemas/movements_common.xsd @@ -24,7 +24,7 @@ - + @@ -38,8 +38,8 @@ - - + + diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java index 2a1065698..e2cd068b5 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java @@ -69,7 +69,8 @@ public class MovementServiceTest extends AbstractServiceTestImpl { // Instance variables specific to this test. private String knownResourceId = null; - private final static String TIMESTAMP_UTC = GregorianCalendarDateTimeUtils.timestampUTC(); + private final static String TIMESTAMP_UTC = + GregorianCalendarDateTimeUtils.timestampUTC(); /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -824,70 +825,4 @@ public class MovementServiceTest extends AbstractServiceTestImpl { return multipart; } - // FIXME Should be moved to a common class, as these are general utilities. - // FIXME Should be refactored to become a convenience variant of a - // general method to return a current datestamp or timestamp in any - // provided time zone. - - /** - * Returns an ISO 8601 formatted timestamp of the - * current time instance in the UTC time zone. - */ - public String datestampUTC() { - final String ISO_8601_DATE_FORMAT_PATTERN = "yyyy-MM-dd"; - final DateFormat ISO_8601_DATE_FORMAT = - new SimpleDateFormat(ISO_8601_DATE_FORMAT_PATTERN); - - final String UTC_TIMEZONE_IDENTIFIER = "UTC"; - final TimeZone UTC_TIMEZONE = TimeZone.getTimeZone(UTC_TIMEZONE_IDENTIFIER); - - Date timestamp = new Date(); - return formatDate(timestamp, UTC_TIMEZONE, ISO_8601_DATE_FORMAT); - } - - /** - * Returns an ISO 8601 formatted timestamp of the - * current time instance in the UTC time zone. - */ - public String timestampUTC() { - final String ISO_8601_FORMAT_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - final DateFormat ISO_8601_FORMAT = - new SimpleDateFormat(ISO_8601_FORMAT_PATTERN); - - final String UTC_TIMEZONE_IDENTIFIER = "UTC"; - final TimeZone UTC_TIMEZONE = TimeZone.getTimeZone(UTC_TIMEZONE_IDENTIFIER); - - Date timestamp = new Date(); - return formatDate(timestamp, UTC_TIMEZONE, ISO_8601_FORMAT); - } - - /** - * Formats a provided date using a provided date formatter, - * in the default system time zone. - * - * @param date A date to format. - * @param df A date formatter to apply. - * @return A formatted date string. - */ - public String formatDate(Date date, DateFormat df) { - return formatDate(date, TimeZone.getDefault(), df); - } - - // FIXME Add error handling. - - /** - * Formats a provided date using a provided date formatter, - * in a provided time zone. - * - * @param date A date to format. - * @param tz The time zone qualifier for the date to format. - * @param df A date formatter to apply. - * - * @return A formatted date string. - */ - public String formatDate(Date date, TimeZone tz, DateFormat df) { - df.setTimeZone(tz); - return df.format(date); - } - } diff --git a/services/objectexit/3rdparty/nuxeo-platform-cs-objectexit/src/main/resources/schemas/objectexit_common.xsd b/services/objectexit/3rdparty/nuxeo-platform-cs-objectexit/src/main/resources/schemas/objectexit_common.xsd index 1aef98e8d..d2045e3c5 100644 --- a/services/objectexit/3rdparty/nuxeo-platform-cs-objectexit/src/main/resources/schemas/objectexit_common.xsd +++ b/services/objectexit/3rdparty/nuxeo-platform-cs-objectexit/src/main/resources/schemas/objectexit_common.xsd @@ -1,7 +1,7 @@ - + diff --git a/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java b/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java index 9edd7371b..6f55f6b10 100644 --- a/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java +++ b/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java @@ -40,6 +40,7 @@ import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.objectexit.ObjectexitCommon; @@ -70,6 +71,8 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest { private String depositorRefName = null; private String exitDate = null; private String exitNumber = null; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); @Override public String getServicePathComponent() { @@ -116,7 +119,8 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest { // Create a new Loans In resource. One or more fields in this resource will be PersonAuthority // references, and will refer to Person resources by their refNames. ObjectExitClient objectexitClient = new ObjectExitClient(); - PoxPayloadOut multipart = createObjectExitInstance(depositorRefName, "exitNumber-" + identifier, "exitDate-" + identifier); + PoxPayloadOut multipart = createObjectExitInstance(depositorRefName, + "exitNumber-" + identifier, CURRENT_DATE_UTC); ClientResponse res = objectexitClient.create(multipart); assertStatusCode(res, testName); if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below. @@ -171,7 +175,6 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest { // Check a couple of fields Assert.assertEquals(objectexit.getDepositor(), depositorRefName); - Assert.assertEquals(objectexit.getExitDate(), exitDate); Assert.assertEquals(objectexit.getExitNumber(), exitNumber); // Get the auth refs and check them diff --git a/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd b/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd index c82c14a5c..0fb56d740 100644 --- a/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd +++ b/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd @@ -1,7 +1,7 @@ - - - - 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 048da5ab6..c93a8bc1e 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 @@ -38,8 +38,8 @@ public class RelationValidatorHandler extends ValidatorHandlerImpl