final static String REF_NAME = "refName";
final static String VOCAB_TYPE = "vocabType";
final static String CSID = "csid";
+ final static String REV = "rev";
}
//
// Update the record's revision number on both CREATE and UPDATE actions
//
+ updateRevNumbers(wrapDoc);
+ }
+
+ protected void updateRevNumbers(DocumentWrapper<DocumentModel> wrapDoc) {
DocumentModel documentModel = wrapDoc.getWrappedObject();
- Integer rev = (Integer)documentModel.getProperty(authorityCommonSchemaName, AuthorityItemJAXBSchema.REV);
+ Long rev = (Long)documentModel.getProperty(authorityCommonSchemaName, AuthorityJAXBSchema.REV);
if (rev == null) {
- rev = 0;
+ rev = (long)0;
} else {
rev++;
}
- documentModel.setProperty(authorityCommonSchemaName, AuthorityItemJAXBSchema.REV, rev);
+ documentModel.setProperty(authorityCommonSchemaName, AuthorityJAXBSchema.REV, rev);
}
-
@Override
public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
super.handleCreate(wrapDoc);
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
public AuthorityItemDocumentModelHandler(String authorityItemCommonSchemaName) {
this.authorityItemCommonSchemaName = authorityItemCommonSchemaName;
}
+
+ abstract public String getParentCommonSchemaName();
@Override
protected String getRefnameDisplayName(DocumentWrapper<DocumentModel> docWrapper) {
}
}
+ public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
+ super.fillAllParts(wrapDoc, action);
+ //
+ // Update the record's revision number on both CREATE and UPDATE actions
+ //
+ updateRevNumbers(wrapDoc);
+ }
+
+ protected void updateRevNumbers(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ DocumentModel documentModel = wrapDoc.getWrappedObject();
+ Long rev = (Long)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV);
+ if (rev == null) {
+ rev = (long)0;
+ } else {
+ rev++;
+ }
+ documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV, rev);
+ //
+ // Next, update the inAuthority (the parent's) rev number
+ //
+ DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), getInAuthority());
+ Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV);
+ parentRev++;
+ inAuthorityDocModel.setProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV, parentRev);
+ getRepositorySession().saveDocument(inAuthorityDocModel);
+ }
+
/**
* If no short identifier was provided in the input payload, generate a
* short identifier from the preferred term display name or term name.
super.extractAllParts(wrapDoc);
}
- @Override
- public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
- //
- // We currently don't override this method with any AuthorityItemDocumentModelHandler specific functionality, so
- // we could remove this method.
- //
- super.fillAllParts(wrapDoc, action);
- }
-
protected List<RelationsCommonList.RelationListItem> cloneList(List<RelationsCommonList.RelationListItem> inboundList) {
List<RelationsCommonList.RelationListItem> result = newRelationsCommonList();
for (RelationsCommonList.RelationListItem item : inboundList) {
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "citationauthorities_common";
+ static final String COMMON_PART_LABEL = "citationauthorities_common";
public CitationAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return CitationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return CitationAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "conceptauthorities_common";
+ static final String COMMON_PART_LABEL = "conceptauthorities_common";
public ConceptAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return ConceptConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return ConceptAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
+
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "locationauthorities_common";
+ static final String COMMON_PART_LABEL = "locationauthorities_common";
public LocationAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return LocationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return LocationAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
+
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "materialauthorities_common";
+ static final String COMMON_PART_LABEL = "materialauthorities_common";
public MaterialAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return MaterialConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return MaterialAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
+
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "orgauthorities_common";
+ static final String COMMON_PART_LABEL = "orgauthorities_common";
public OrgAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
return OrganizationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return OrgAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
+
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "personauthorities_common";
+ static final String COMMON_PART_LABEL = "personauthorities_common";
public PersonAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return PersonConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return PersonAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
+
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "placeauthorities_common";
+ static final String COMMON_PART_LABEL = "placeauthorities_common";
public PlaceAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return PlaceConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return PlaceAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
}
public String getQProperty(String prop) {
return TaxonConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return TaxonomyAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "taxonomyauthority_common";
+ static final String COMMON_PART_LABEL = "taxonomyauthority_common";
public TaxonomyAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "vocabularies_common";
+ static final String COMMON_PART_LABEL = "vocabularies_common";
public VocabularyDocumentModelHandler() {
super(COMMON_PART_LABEL);
return result;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return VocabularyDocumentModelHandler.COMMON_PART_LABEL;
+ }
}
/**
* Common part schema label
*/
- private static final String COMMON_PART_LABEL = "workauthorities_common";
+ static final String COMMON_PART_LABEL = "workauthorities_common";
public WorkAuthorityDocumentModelHandler() {
super(COMMON_PART_LABEL);
public String getQProperty(String prop) {
return WorkConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ @Override
+ public String getParentCommonSchemaName() {
+ // TODO Auto-generated method stub
+ return WorkAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+ }
}