*\r
*/\r
public interface AuthorityItemJAXBSchema {\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
- final static String SHORT_DISPLAY_NAME = "shortDisplayName";\r
- final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed";\r
- final static String IN_AUTHORITY = "inAuthority";\r
+ final static String IN_AUTHORITY = "inAuthority";\r
final static String REF_NAME = "refName";\r
final static String ORDER = "order";\r
final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String TERM_STATUS = "termStatus";\r
final static String CSID = "csid";\r
+ final static String TERM_DISPLAY_NAME = "termDisplayName";\r
+ final static String TERM_NAME = "termName";\r
+ final static String TERM_STATUS = "termStatus";\r
+ final static String PREFERRED_TERM_DISPLAY_NAME_XPATH ="termGroupList/0/termDisplayName";\r
+ final static String PREFERRED_TERM_NAME_XPATH ="termGroupList/0/termName";\r
+ final static String PREFERRED_TERM_STATUS_XPATH ="termGroupList/0/termStatus";\r
+ // CSPACE-4813\r
+ /*\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
+ final static String SHORT_DISPLAY_NAME = "shortDisplayName";\r
+ final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed";\r
+ final static String TERM_STATUS = "termStatus";\r
+ *\r
+ */\r
}\r
\r
\r
import org.collectionspace.services.config.service.ListResultField;
import org.collectionspace.services.config.service.ObjectPartType;
import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.relation.RelationResource;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
//import org.collectionspace.services.common.authority.AuthorityItemRelations;
/**
// Ensure we have required fields set properly
handleInAuthority(wrapDoc.getWrappedObject());
+ // CSPACE-4813
+ /*
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);
+ // handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName);
// refName includes displayName, so we force a correct value here.
updateRefnameForAuthorityItem(wrapDoc, authorityItemCommonSchemaName, getAuthorityRefNameBase());
}
@Override
public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
// First, get a copy of the old displayName
- oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
- AuthorityItemJAXBSchema.DISPLAY_NAME);
+ // oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
+ // AuthorityItemJAXBSchema.DISPLAY_NAME);
+ oldDisplayNameOnUpdate = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(),
+ authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
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);
+ // handleComputedDisplayNames(wrapDoc.getWrappedObject());
+ // String newDisplayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
+ // AuthorityItemJAXBSchema.DISPLAY_NAME);
+ String newDisplayName = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(),
+ authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
if (newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) {
// Need to update the refName, and then fix all references.
newRefNameOnUpdate = handleItemRefNameUpdateForDisplayName(wrapDoc.getWrappedObject(), newDisplayName);
}
/**
- * If no short identifier was provided in the input payload,
- * generate a short identifier from the display name.
+ * If no short identifier was provided in the input payload, generate a
+ * short identifier from the preferred term display name or term 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);
- String shortDisplayName = "";
- try {
- shortDisplayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_DISPLAY_NAME);
- } catch (PropertyNotFoundException pnfe) {
- // Do nothing on exception. Some vocabulary schemas may not include a short display name.
- }
+ String termDisplayName =
+ (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel,
+ schemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
+ String termName = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel,
+ schemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_NAME_XPATH);
if (Tools.isEmpty(shortIdentifier)) {
String generatedShortIdentifier =
- AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(displayName, shortDisplayName);
+ AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(termDisplayName, termName);
docModel.setProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER, generatedShortIdentifier);
}
}
String authorityRefBaseName) throws Exception {
DocumentModel docModel = wrapDoc.getWrappedObject();
String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
- String displayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME);
+ String displayName =
+ RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel, schemaName,
+ AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
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.");
}