From: Aron Roberts Date: Sat, 20 Nov 2010 02:10:23 +0000 (+0000) Subject: CSPACE-1826: Added a Lender repeatable group of four fields to Loan In records, in... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=d0490d7c3f1391ec3c1fedae2f81d707c0c84174;p=tmp%2Fjakarta-migration.git CSPACE-1826: Added a Lender repeatable group of four fields to Loan In records, in the services layer. --- diff --git a/services/common/src/main/config/services/tenant-bindings.xml b/services/common/src/main/config/services/tenant-bindings.xml index ceb8c364f..e273acddd 100644 --- a/services/common/src/main/config/services/tenant-bindings.xml +++ b/services/common/src/main/config/services/tenant-bindings.xml @@ -203,9 +203,10 @@ versionable="true" auditable="false" label="loansin_common" updated="" order="1"> - authReflender - authReflendersAuthorizer - authReflendersContact + + + + authRefloanInContact authRefborrowersAuthorizer @@ -1396,9 +1397,10 @@ versionable="true" auditable="false" label="loansin_common" updated="" order="1"> - authReflender - authReflendersAuthorizer - authReflendersContact + + + + authRefloanInContact authRefborrowersAuthorizer diff --git a/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/OSGI-INF/core-types-contrib.xml index 534214b10..16661d86b 100644 --- a/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/OSGI-INF/core-types-contrib.xml +++ b/services/loanin/3rdparty/nuxeo-platform-cs-loanin/src/main/resources/OSGI-INF/core-types-contrib.xml @@ -9,9 +9,10 @@ + + loansin_common:loanInNumber - loansin_common:lender loansin_common:loanReturnDate 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 da97dd42b..b6ec0d882 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 @@ -22,10 +22,7 @@ - - - - + @@ -34,5 +31,21 @@ - + + + + + + + + + + + + + + + + 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 365e7c22d..fb2a82bdc 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 @@ -38,6 +38,8 @@ import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.common.authorityref.AuthorityRefList; //import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.loanin.LenderGroup; +import org.collectionspace.services.loanin.LenderGroupList; import org.collectionspace.services.loanin.LoansinCommon; //import org.collectionspace.services.loanin.LoansinCommonList; @@ -77,9 +79,9 @@ public class LoaninAuthRefsTest extends BaseServiceTest { private String lendersContactRefName = null; private String loanInContactRefName = null; private String borrowersAuthorizerRefName = null; - // FIXME: May change when repeatable / multivalue 'lenders' field is added - // to tenant-bindings.xml - private final int NUM_AUTH_REFS_EXPECTED = 5; + // 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; /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -258,9 +260,9 @@ public class LoaninAuthRefsTest extends BaseServiceTest { logger.debug(objectAsXmlString(loanin, LoansinCommon.class)); } // Check a couple of fields - Assert.assertEquals(loanin.getLender(), lenderRefName); - Assert.assertEquals(loanin.getLendersAuthorizer(), lendersAuthorizerRefName); - Assert.assertEquals(loanin.getLendersContact(), lendersContactRefName); +// Assert.assertEquals(loanin.getLender(), lenderRefName); +// Assert.assertEquals(loanin.getLendersAuthorizer(), lendersAuthorizerRefName); +// Assert.assertEquals(loanin.getLendersContact(), lendersContactRefName); Assert.assertEquals(loanin.getLoanInContact(), loanInContactRefName); Assert.assertEquals(loanin.getBorrowersAuthorizer(), borrowersAuthorizerRefName); @@ -375,9 +377,13 @@ public class LoaninAuthRefsTest extends BaseServiceTest { LoansinCommon loanin = new LoansinCommon(); loanin.setLoanInNumber(loaninNumber); loanin.setLoanInNumber(returnDate); - loanin.setLender(lender); - loanin.setLendersAuthorizer(lendersAuthorizer); - loanin.setLendersContact(lendersContact); + LenderGroupList lenderGroupList = new LenderGroupList(); + LenderGroup lenderGroup = new LenderGroup(); + lenderGroup.setLender(lender); + lenderGroup.setLendersAuthorizer(lendersAuthorizer); + lenderGroup.setLendersContact(lendersContact); + lenderGroupList.getLenderGroup().add(lenderGroup); + loanin.setLenderGroupList(lenderGroupList); loanin.setLoanInContact(loaninContact); loanin.setBorrowersAuthorizer(borrowersAuthorizer); MultipartOutput multipart = new MultipartOutput(); 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 93d22ec17..44da361ee 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 @@ -30,6 +30,8 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.LoaninClient; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.loanin.LenderGroup; +import org.collectionspace.services.loanin.LenderGroupList; import org.collectionspace.services.loanin.LoansinCommon; import org.collectionspace.services.loanin.LoansinCommonList; @@ -64,6 +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'"; + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() */ @@ -311,6 +316,15 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { LoansinCommon loanin = (LoansinCommon) extractPart(input, client.getCommonPartName(), LoansinCommon.class); Assert.assertNotNull(loanin); + + LenderGroupList lenderGroupList = loanin.getLenderGroupList(); + Assert.assertNotNull(lenderGroupList); + List lenderGroups = lenderGroupList.getLenderGroup(); + Assert.assertNotNull(lenderGroups); + Assert.assertTrue(lenderGroups.size() > 0); + String lender = lenderGroups.get(0).getLender(); + Assert.assertEquals(lender, LENDER_REF_NAME); + } // Failure outcomes @@ -773,7 +787,11 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { LoansinCommon loanin = new LoansinCommon(); loanin.setLoanInNumber(loaninNumber); loanin.setLoanReturnDate(returnDate); - loanin.setLender("urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Harry Lender)'Harry Lender'"); + LenderGroupList lenderGroupList = new LenderGroupList(); + LenderGroup lenderGroup = new LenderGroup(); + lenderGroup.setLender(LENDER_REF_NAME); + lenderGroupList.getLenderGroup().add(lenderGroup); + loanin.setLenderGroupList(lenderGroupList); loanin.setLoanPurpose("For Surfboards of the 1960s exhibition."); MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = diff --git a/services/loanin/jaxb/src/main/java/org/collectionspace/services/LoaninListItemJAXBSchema.java b/services/loanin/jaxb/src/main/java/org/collectionspace/services/LoaninListItemJAXBSchema.java index 7fa960175..3cb5db8f4 100644 --- a/services/loanin/jaxb/src/main/java/org/collectionspace/services/LoaninListItemJAXBSchema.java +++ b/services/loanin/jaxb/src/main/java/org/collectionspace/services/LoaninListItemJAXBSchema.java @@ -2,6 +2,7 @@ package org.collectionspace.services; public interface LoaninListItemJAXBSchema { final static String LOAN_IN_NUMBER = "loaninNumber"; + final static String LENDER_GROUP_LIST = "lenderGroupList"; final static String LENDER = "lender"; final static String LOAN_RETURN_DATE = "loanReturnDate"; final static String CSID = "csid"; diff --git a/services/loanin/jaxb/src/main/resources/loansin-common.xsd b/services/loanin/jaxb/src/main/resources/loansin-common.xsd index 26e3095c6..a5b742ab5 100644 --- a/services/loanin/jaxb/src/main/resources/loansin-common.xsd +++ b/services/loanin/jaxb/src/main/resources/loansin-common.xsd @@ -33,10 +33,7 @@ - - - - + @@ -48,7 +45,23 @@ - + + + + + + + + + + + + + + + + diff --git a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java index 4632d3230..17a4e84fa 100644 --- a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java +++ b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java @@ -25,11 +25,13 @@ package org.collectionspace.services.loanin.nuxeo; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.collectionspace.services.LoaninJAXBSchema; import org.collectionspace.services.LoaninListItemJAXBSchema; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.loanin.LenderGroup; import org.collectionspace.services.loanin.LoansinCommon; import org.collectionspace.services.loanin.LoansinCommonList; import org.collectionspace.services.loanin.LoansinCommonList.LoaninListItem; @@ -121,7 +123,7 @@ public class LoaninDocumentModelHandler public LoansinCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { LoansinCommonList coList = extractPagingInfo(new LoansinCommonList(), wrapDoc); AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("loanInNumber|lender|loanReturnDate|uri|csid"); + commonList.setFieldsReturned("loanInNumber|lenderList|loanReturnDate|uri|csid"); List list = coList.getLoaninListItem(); Iterator iter = wrapDoc.getWrappedObject().iterator(); String label = getServiceContext().getCommonPartLabel(); @@ -130,8 +132,17 @@ public class LoaninDocumentModelHandler LoaninListItem ilistItem = new LoaninListItem(); ilistItem.setLoanInNumber((String) docModel.getProperty(label, LoaninJAXBSchema.LOAN_IN_NUMBER)); - ilistItem.setLender((String) docModel.getProperty(label, - LoaninListItemJAXBSchema.LENDER)); + + // ilistItem.setLender((String) docModel.getProperty(label, + // LoaninListItemJAXBSchema.LENDER)); + + List lenders = + (List) docModel.getProperty(label, + LoaninListItemJAXBSchema.LENDER_GROUP_LIST); + String primaryLender = primaryValueFromMultivalue(lenders, + LoaninListItemJAXBSchema.LENDER); + ilistItem.setLender(primaryLender); + ilistItem.setLoanReturnDate((String) docModel.getProperty(label, LoaninJAXBSchema.LOAN_RETURN_DATE)); String id = NuxeoUtils.extractId(docModel.getPathAsString());