//import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
-import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
import org.collectionspace.services.taxonomy.TaxonCommonList;
import org.collectionspace.services.client.TaxonomyAuthorityProxy;
@Override
public String getItemCommonPartName() {
- return getCommonPartName(SERVICE_ITEM_NAME);
+ return getCommonPartName(SERVICE_ITEM_PAYLOAD_NAME);
}
@Override
import javax.ws.rs.core.Response;
import org.apache.commons.io.FileUtils;
-import org.collectionspace.services.TaxonomyJAXBSchema;
+import org.collectionspace.services.TaxonJAXBSchema;
import org.collectionspace.services.client.test.ServiceRequestType;
import org.collectionspace.services.taxonomy.TaxonCommon;
import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
String taxonomyAuthRefName, Map<String, String> taxonInfo,
String headerLabel) {
TaxonCommon taxon = new TaxonCommon();
- String shortId = taxonInfo.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER);
- String displayName = taxonInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME);
+ String shortId = taxonInfo.get(TaxonJAXBSchema.SHORT_IDENTIFIER);
+ String displayName = taxonInfo.get(TaxonJAXBSchema.DISPLAY_NAME);
taxon.setShortIdentifier(shortId);
String taxonomyRefName = createTaxonomyRefName(taxonomyAuthRefName, shortId, displayName);
taxon.setRefName(taxonomyRefName);
String value = null;
- value = taxonInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED);
+ value = taxonInfo.get(TaxonJAXBSchema.DISPLAY_NAME_COMPUTED);
boolean displayNameComputed = (value == null) || value.equalsIgnoreCase("true");
taxon.setDisplayNameComputed(displayNameComputed);
- if ((value = (String) taxonInfo.get(TaxonomyJAXBSchema.NAME)) != null) {
+ if ((value = (String) taxonInfo.get(TaxonJAXBSchema.NAME)) != null) {
taxon.setTaxonFullName(value);
}
- if ((value = (String) taxonInfo.get(TaxonomyJAXBSchema.RANK)) != null) {
+ if ((value = (String) taxonInfo.get(TaxonJAXBSchema.RANK)) != null) {
taxon.setTaxonRank(value);
}
- if ((value = (String) taxonInfo.get(TaxonomyJAXBSchema.TERM_STATUS)) != null) {
+ if ((value = (String) taxonInfo.get(TaxonJAXBSchema.TERM_STATUS)) != null) {
taxon.setTermStatus(value);
}
// FIXME: Add additional fields in the Taxon record here.
/**
* @param vcsid CSID of the authority to create a new taxon in
* @param TaxonomyauthorityRefName The refName for the authority
- * @param taxonMap the properties for the new Taxonomy
+ * @param taxonMap the properties for the new Taxon
* @param client the service client
* @return the CSID of the new item
*/
// Type of service request being tested
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
- String displayName = taxonMap.get(TaxonomyJAXBSchema.DISPLAY_NAME);
- String displayNameComputedStr = taxonMap.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED);
+ String displayName = taxonMap.get(TaxonJAXBSchema.DISPLAY_NAME);
+ String displayNameComputedStr = taxonMap.get(TaxonJAXBSchema.DISPLAY_NAME_COMPUTED);
boolean displayNameComputed = (displayNameComputedStr == null) || displayNameComputedStr.equalsIgnoreCase("true");
if (displayName == null) {
if (!displayNameComputed) {
}
displayName =
prepareDefaultDisplayName(
- taxonMap.get(TaxonomyJAXBSchema.NAME));
+ taxonMap.get(TaxonJAXBSchema.NAME));
}
if (logger.isDebugEnabled()) {
if (!REQUEST_TYPE.isValidStatusCode(statusCode)) {
throw new RuntimeException("Could not create Item: \""
- + taxonMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER)
+ + taxonMap.get(TaxonJAXBSchema.SHORT_IDENTIFIER)
+ "\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName
+ "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
}
if (statusCode != EXPECTED_STATUS_CODE) {
throw new RuntimeException("Unexpected Status when creating Item: \""
- + taxonMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER)
+ + taxonMap.get(TaxonJAXBSchema.SHORT_IDENTIFIER)
+ "\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName + "\", Status:" + statusCode);
}
newID = extractId(res);
return newID;
}
- public static PoxPayloadOut createTaxonomyInstance(
+ public static PoxPayloadOut createTaxonInstance(
String commonPartXML, String headerLabel) throws DocumentException {
PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
PayloadOutputPart commonPart = multipart.addPart(commonPartXML,
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
PoxPayloadOut multipart =
- createTaxonomyInstance(commonPartXML, client.getItemCommonPartName());
+ createTaxonInstance(commonPartXML, client.getItemCommonPartName());
String newID = null;
ClientResponse<Response> res = client.createItem(vcsid, multipart);
try {
import java.util.List;
import java.util.Map;
-import org.collectionspace.services.TaxonomyJAXBSchema;
+import org.collectionspace.services.TaxonJAXBSchema;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.ContactClient;
-import org.collectionspace.services.client.ContactClientUtils;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.TaxonomyAuthorityClient;
import org.collectionspace.services.client.TaxonomyAuthorityClientUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
Map<String, String> taxonMap = new HashMap<String, String>();
// TODO Make loc type and status be controlled vocabs.
- taxonMap.put(TaxonomyJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
- taxonMap.put(TaxonomyJAXBSchema.NAME, TEST_NAME);
- taxonMap.put(TaxonomyJAXBSchema.RANK, TEST_RANK);
- taxonMap.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS);
+ taxonMap.put(TaxonJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
+ taxonMap.put(TaxonJAXBSchema.NAME, TEST_NAME);
+ taxonMap.put(TaxonJAXBSchema.RANK, TEST_RANK);
+ taxonMap.put(TaxonJAXBSchema.TERM_STATUS, TEST_STATUS);
// FIXME: Add additional fields in the Taxon record here.
String newID = TaxonomyAuthorityClientUtils.createItemInAuthority(vcsid,
if (knownItemResourceId == null) {
setKnownItemResource(newID, TEST_SHORTID);
if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownItemResourceId=" + newID);
+ logger.debug(testName + ": knownItemResourceId=" + newID + " inAuthority=" + vcsid);
}
}
// The only relevant ID may be the one used in update(), below.
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
Map<String, String> nonexMap = new HashMap<String, String>();
- nonexMap.put(TaxonomyJAXBSchema.NAME, TEST_NAME);
- nonexMap.put(TaxonomyJAXBSchema.SHORT_IDENTIFIER, "nonEx");
- nonexMap.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS);
+ nonexMap.put(TaxonJAXBSchema.NAME, TEST_NAME);
+ nonexMap.put(TaxonJAXBSchema.SHORT_IDENTIFIER, "nonEx");
+ nonexMap.put(TaxonJAXBSchema.TERM_STATUS, TEST_STATUS);
PoxPayloadOut multipart =
TaxonomyAuthorityClientUtils.createTaxonInstance(
TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"),
--- /dev/null
+/**
+ *
+ */
+package org.collectionspace.services;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+
+public interface TaxonJAXBSchema extends AuthorityItemJAXBSchema {
+ final static String TAXON_COMMON = "taxon_common";
+ final static String NAME = "taxonFullName";
+ final static String RANK = "taxonRank";
+
+}
+
import org.collectionspace.services.client.TaxonomyAuthorityClient;
import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
-import org.collectionspace.services.TaxonomyJAXBSchema;
+import org.collectionspace.services.TaxonJAXBSchema;
import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
@Path(TaxonomyAuthorityClient.SERVICE_PATH)
@Consumes("application/xml")
@Produces("application/xml")
-public class TaxonomyAuthorityResource
- extends AuthorityResource<TaxonomyauthorityCommon, TaxonomyauthorityCommonList,
- TaxonCommon, TaxonDocumentModelHandler> {
+public class TaxonomyAuthorityResource
+ extends AuthorityResource<TaxonomyauthorityCommon, TaxonomyauthorityCommonList, TaxonCommon, TaxonDocumentModelHandler> {
private final static String taxonomyAuthorityServiceName = "taxonomyauthorities";
- private final static String TAXONOMYAUTHORITY_COMMON = "taxonomyauthority_common";
-
- // FIXME: May be desirable to change this to the plural form 'taxa',
- // both here and in related config.
+ private final static String TAXONOMYAUTHORITY_COMMON = "taxonomyauthority_common";
private final static String taxonomyItemServiceName = "taxon";
- private final static String TAXON_COMMON = "taxon_common";
-
+ private final static String TAXONOMYITEM_COMMON = "taxon_common";
/** The logger. */
final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityResource.class);
//FIXME retrieve client type from configuration
/** The Constant CLIENT_TYPE. */
final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
-
+
/**
* Instantiates a new taxonomy authority resource.
*/
public TaxonomyAuthorityResource() {
- super(TaxonomyauthorityCommon.class, TaxonomyAuthorityResource.class,
- TAXONOMYAUTHORITY_COMMON, TAXON_COMMON);
+ super(TaxonomyauthorityCommon.class, TaxonomyAuthorityResource.class,
+ TAXONOMYAUTHORITY_COMMON, TAXONOMYITEM_COMMON);
}
/* (non-Javadoc)
@Override
public Class<TaxonomyauthorityCommon> getCommonPartClass() {
- return TaxonomyauthorityCommon.class;
+ return TaxonomyauthorityCommon.class;
}
}
import java.util.List;
import java.util.Map;
-import org.collectionspace.services.TaxonomyJAXBSchema;
+import org.collectionspace.services.TaxonJAXBSchema;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.service.ObjectPartType;
* Common part schema label
*/
private static final String COMMON_PART_LABEL = "taxon_common";
-
+
public TaxonDocumentModelHandler() {
- super(COMMON_PART_LABEL);
+ super(COMMON_PART_LABEL);
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
*/
@Override
public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- // first fill all the parts of the document
- super.handleCreate(wrapDoc);
- handleDisplayNames(wrapDoc.getWrappedObject());
+ // first fill all the parts of the document
+ super.handleCreate(wrapDoc);
+ handleDisplayNames(wrapDoc.getWrappedObject());
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper)
*/
@Override
public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- super.handleUpdate(wrapDoc);
- handleDisplayNames(wrapDoc.getWrappedObject());
+ super.handleUpdate(wrapDoc);
+ handleDisplayNames(wrapDoc.getWrappedObject());
}
/**
* @throws Exception the exception
*/
private void handleDisplayNames(DocumentModel docModel) throws Exception {
- String commonPartLabel = getServiceContext().getCommonPartLabel("taxon");
- Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
- TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED);
- Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
- TaxonomyJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
- if(displayNameComputed==null)
- displayNameComputed = true;
- if(shortDisplayNameComputed==null)
- shortDisplayNameComputed = true;
- if (displayNameComputed || shortDisplayNameComputed) {
- String displayName = prepareDefaultDisplayName(
- (String)docModel.getProperty(commonPartLabel, TaxonomyJAXBSchema.NAME ));
- if (displayNameComputed) {
- docModel.setProperty(commonPartLabel, TaxonomyJAXBSchema.DISPLAY_NAME,
- displayName);
- }
- if (shortDisplayNameComputed) {
- docModel.setProperty(commonPartLabel, TaxonomyJAXBSchema.SHORT_DISPLAY_NAME,
- displayName);
- }
- }
+ String commonPartLabel = getServiceContext().getCommonPartLabel("taxon");
+ Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+ TaxonJAXBSchema.DISPLAY_NAME_COMPUTED);
+ Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+ TaxonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
+ if (displayNameComputed == null) {
+ displayNameComputed = true;
+ }
+ if (shortDisplayNameComputed == null) {
+ shortDisplayNameComputed = true;
+ }
+ if (displayNameComputed || shortDisplayNameComputed) {
+ String displayName = prepareDefaultDisplayName(
+ (String) docModel.getProperty(commonPartLabel, TaxonJAXBSchema.NAME));
+ if (displayNameComputed) {
+ docModel.setProperty(commonPartLabel, TaxonJAXBSchema.DISPLAY_NAME,
+ displayName);
+ }
+ if (shortDisplayNameComputed) {
+ docModel.setProperty(commonPartLabel, TaxonJAXBSchema.SHORT_DISPLAY_NAME,
+ displayName);
+ }
+ }
}
-
+
/**
* Produces a default displayName from the basic name and dates fields.
* @see TaxonomyAuthorityClientUtils.prepareDefaultDisplayName() which
* duplicates this logic, until we define a service-general utils package
* that is neither client nor service specific.
- * @param foreName
- * @param middleName
- * @param surName
- * @param birthDate
- * @param deathDate
+ * @param name
* @return
* @throws Exception
*/
private static String prepareDefaultDisplayName(
- String name ) throws Exception {
- StringBuilder newStr = new StringBuilder();
- newStr.append(name);
- return newStr.toString();
+ String name) throws Exception {
+ StringBuilder newStr = new StringBuilder();
+ newStr.append(name);
+ return newStr.toString();
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
*/
@Override
- public TaxonCommonList extractCommonPartList(
- DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- TaxonCommonList coList = extractPagingInfo(new TaxonCommonList(), wrapDoc);
+ public TaxonCommonList extractCommonPartList(
+ DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ TaxonCommonList coList = extractPagingInfo(new TaxonCommonList(), wrapDoc);
AbstractCommonList commonList = (AbstractCommonList) coList;
commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
- List<TaxonCommonList.TaxonListItem> list = coList.getTaxonListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String commonPartLabel = getServiceContext().getCommonPartLabel("taxon");
- while (iter.hasNext()) {
- DocumentModel docModel = iter.next();
- TaxonListItem ilistItem = new TaxonListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(
- commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.REF_NAME));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/taxonomyauthorities/" + inAuthority + "/items/"
- + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
+ List<TaxonCommonList.TaxonListItem> list = coList.getTaxonListItem();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+ String commonPartLabel = getServiceContext().getCommonPartLabel("taxon");
+ while (iter.hasNext()) {
+ DocumentModel docModel = iter.next();
+ TaxonListItem ilistItem = new TaxonListItem();
+ ilistItem.setDisplayName((String) docModel.getProperty(
+ commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME));
+ ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
+ AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
+ ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
+ AuthorityItemJAXBSchema.REF_NAME));
+ String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
+ ilistItem.setUri("/taxonomyauthorities/" + inAuthority + "/items/"
+ + id);
+ ilistItem.setCsid(id);
+ list.add(ilistItem);
+ }
+
+ return coList;
+ }
/**
* getQProperty converts the given property to qualified schema property
*/
public class TaxonomyConstants {
- public final static String NUXEO_DOCTYPE = "Taxonomy";
- public final static String NUXEO_SCHEMA_NAME = "taxonomy";
- public final static String NUXEO_DC_TITLE = "CollectionSpace-Taxonomy";
+ public final static String NUXEO_DOCTYPE = "Taxon";
+ public final static String NUXEO_SCHEMA_NAME = "taxon";
+ public final static String NUXEO_DC_TITLE = "CollectionSpace-Taxon";
}