import java.util.ArrayList;
import java.util.List;
+import org.collectionspace.services.client.*;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
/**
* The Class AuthorityResource.
}
public abstract String getItemServiceName();
+
+ public abstract String getItemTermInfoGroupXPathBase();
@Override
protected String getVersionString() {
docHandler = (AuthorityItemDocumentModelHandler<?>) createDocumentHandler(ctx,
ctx.getCommonPartLabel(getItemServiceName()),
authCommonClass);
+ // FIXME - Richard and Aron think the following three lines should
+ // be in the constructor for the AuthorityItemDocumentModelHandler
+ // because all three are required fields.
docHandler.setInAuthority(inAuthority);
docHandler.setAuthorityRefNameBase(authorityRefNameBase);
-
+ docHandler.setItemTermInfoGroupXPathBase(getItemTermInfoGroupXPathBase());
return docHandler;
}
if (sortBy == null || sortBy.isEmpty()) {
// String qualifiedDisplayNameField = authorityCommonSchemaName + ":"
// + AuthorityItemJAXBSchema.DISPLAY_NAME;
- String qualifiedDisplayNameField = AuthorityItemJAXBSchema.TERM_INFO_GROUP_SCHEMA_NAME + ":"
- + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME;
+ String qualifiedDisplayNameField = getQualifiedDisplayNameField();
myFilter.setOrderByClause(qualifiedDisplayNameField);
}
String nameQ = queryParams.getFirst("refName");
throw bigReThrow(e, ServiceMessages.GET_FAILED);
}
}
+
+ protected String getQualifiedDisplayNameField() {
+ return NuxeoUtils.getPrimaryXPathPropertyName(authorityCommonSchemaName,
+ getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+ }
/**
* Update authority.
String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS);
- String qualifiedDisplayNameField = authorityItemCommonSchemaName + ":"
- + AuthorityItemJAXBSchema.DISPLAY_NAME;
+ String qualifiedDisplayNameField = getQualifiedDisplayNameField();
// Note that docType defaults to the ServiceName, so we're fine with that.
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class);
private String authorityItemCommonSchemaName;
+ private String authorityItemTermGroupXPathBase;
/**
* inVocabulary is the parent Authority for this context
*/
for (int i = 0; i < nFields; i++) {
ListResultField field = list.get(i);
String elName = field.getElement();
- if (AuthorityItemJAXBSchema.DISPLAY_NAME.equals(elName)) {
+ if (AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName)) {
hasDisplayName = true;
} else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) {
hasShortId = true;
ListResultField field;
if (!hasDisplayName) {
field = new ListResultField();
- field.setElement(AuthorityItemJAXBSchema.DISPLAY_NAME);
+ field.setElement(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
field.setXpath(AuthorityItemJAXBSchema.DISPLAY_NAME);
list.add(field);
}
// First, get a copy of the old displayName
// oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
// AuthorityItemJAXBSchema.DISPLAY_NAME);
- oldDisplayNameOnUpdate = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(),
- authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
+ oldDisplayNameOnUpdate = (String) getStringValueInPrimaryRepeatingComplexProperty(
+ wrapDoc.getWrappedObject(), authorityItemCommonSchemaName,
+ this.authorityItemTermGroupXPathBase,
+ AuthorityItemJAXBSchema.TERM_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);
- String newDisplayName = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(),
- authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
+ String newDisplayName = (String) getStringValueInPrimaryRepeatingComplexProperty(
+ wrapDoc.getWrappedObject(), authorityItemCommonSchemaName,
+ this.authorityItemTermGroupXPathBase,
+ AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
if (newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) {
// Need to update the refName, and then fix all references.
newRefNameOnUpdate = handleItemRefNameUpdateForDisplayName(wrapDoc.getWrappedObject(), newDisplayName);
private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception {
String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
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);
+ (String) getStringValueInPrimaryRepeatingComplexProperty(
+ docModel, authorityItemCommonSchemaName,
+ this.authorityItemTermGroupXPathBase,
+ AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+ String termName =
+ (String) getStringValueInPrimaryRepeatingComplexProperty(
+ docModel, authorityItemCommonSchemaName,
+ this.authorityItemTermGroupXPathBase,
+ AuthorityItemJAXBSchema.TERM_NAME);
if (Tools.isEmpty(shortIdentifier)) {
String generatedShortIdentifier =
AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(termDisplayName, termName);
DocumentModel docModel = wrapDoc.getWrappedObject();
String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
String displayName =
- RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel, schemaName,
- AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH);
+ (String) getStringValueInPrimaryRepeatingComplexProperty(
+ docModel, authorityItemCommonSchemaName,
+ this.authorityItemTermGroupXPathBase,
+ AuthorityItemJAXBSchema.TERM_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.");
}
return relationsCommonList;
}
//============================= END TODO refactor ==========================
+
+ public String getItemTermInfoGroupXPathBase() {
+ return this.authorityItemTermGroupXPathBase;
+ }
+
+ public void setItemTermInfoGroupXPathBase(String itemTermInfoGroupXPathBase) {
+ this.authorityItemTermGroupXPathBase = itemTermInfoGroupXPathBase;
+ }
}