use of org.collectionspace.chain.csp.schema.Record in project application by collectionspace.
the class ServiceBindingsGeneration method doLists.
// defines fields to show in list results
private void doLists(Record record, Element el, Namespace thisns, boolean isAuthority) {
Record r = record;
//
if (isAuthority == true) {
Spec recordSpec = r.getSpec();
r = recordSpec.getRecord(BASE_AUTHORITY_RECORD);
}
FieldSet[] allMiniSummaryList = r.getAllMiniSummaryList();
if (allMiniSummaryList == null) {
log.error(String.format("Config Generation: '%s' - allMiniSummaryList for record '%s' is null.", getConfigFile().getName(), r.getRecordName()));
}
String section;
for (FieldSet fs : allMiniSummaryList) {
if ((fs.isInServices() && !fs.excludeFromServicesList()) || fs.isServicesDerived()) {
String fieldNamePath = this.getFullyQualifiedFieldPath(fs);
section = fs.getSection();
//
// Add the <ListResultField> element
//
Element lrf = el.addElement(new QName("ListResultField", thisns));
// the field is from the common part.)
if (!section.equals(Record.COLLECTIONSPACE_COMMON_PART_NAME)) {
Element slrf = lrf.addElement(new QName("schema", thisns));
slrf.addText(r.getServicesSchemaName(fs.getSection()));
} else {
log.isDebugEnabled();
}
Element elrf = lrf.addElement(new QName("element", thisns));
elrf.addText(fs.getServicesTag());
Element xlrf = lrf.addElement(new QName("xpath", thisns));
xlrf.addText(fieldNamePath);
String setter = fs.getServicesSetter();
if (setter != null && setter.trim().isEmpty() == false) {
Element slrf = lrf.addElement(new QName("setter", thisns));
slrf.addText(setter);
}
}
}
}
use of org.collectionspace.chain.csp.schema.Record in project application by collectionspace.
the class ServiceBindingsGeneration method doAuthorityInstanceList.
private void doAuthorityInstanceList(Record r, Element el, Namespace nsservices2) {
Instance[] allInstances = r.getAllInstances();
if (r.getID().equalsIgnoreCase(RECORD_ID_TERMLIST) == true) {
//
// Records "termlist" and "vocab" have special relationship, so we need to do things a little differently.
//
Record vocabRecord = this.spec.getRecord(RECORD_ID_VOCAB);
allInstances = vocabRecord.getAllInstances();
}
if (allInstances.length > 0) {
Element authorityInstanceList = el.addElement(new QName("AuthorityInstanceList", nsservices2));
for (Instance instance : allInstances) {
Element authorityInstance = authorityInstanceList.addElement(new QName("AuthorityInstance", nsservices2));
doAuthorityInstance(instance, r, authorityInstance, nsservices2);
}
}
}
use of org.collectionspace.chain.csp.schema.Record in project application by collectionspace.
the class ServiceBindingsGeneration method doInitHandler.
/**
* Define fields that needs to have indexes created in the Nuxeo DB
* @param r
* @param el
* @param thisns
* @param section
* @param isAuthority
*/
private void doInitHandler(Record record, Element el, Namespace thisns, Boolean isAuthority) {
Record r = record;
//
if (isAuthority == true) {
Spec spec = r.getSpec();
r = spec.getRecord(BASE_AUTHORITY_RECORD);
// Since all the authorities share the same "baseAuthority" record, we need to set the actual authority record; e.g., Person, Organization, etc...
r.setLastAuthorityProxy(record);
}
Element dhele = el.addElement(new QName("initHandler", thisns));
Element cele = dhele.addElement(new QName("classname", thisns));
cele.addText(this.tenantSpec.getIndexHandler());
Element paramsElement = dhele.addElement(new QName("params", thisns));
boolean createdIndexedFields = createInitFieldList(paramsElement, thisns, r, isAuthority);
if (createdIndexedFields == false) {
// Since there were no fields to index, we don't need this empty <initHandler> element
el.remove(dhele);
}
}
use of org.collectionspace.chain.csp.schema.Record in project application by collectionspace.
the class ServiceBindingsGeneration method doAuthRefsAndTermRefs.
/*
* Creates a set of Service binding authRefs and termRefs similar in form to these examples:
* <types:item>
* <types:key>authRef</types:key>
* <types:value>currentOwner</types:value>
* </types:item>
* <types:item>
* <types:key>termRef</types:key>
* <types:value>termLanguage</types:value>
* </types:item>
*
* If we don't create any entries then we'll return 'false' to the caller;
*/
private boolean doAuthRefsAndTermRefs(Element auth, Namespace types, Record r, String section) {
boolean result = false;
for (FieldSet in : r.getAllFieldFullList("")) {
// for debugging only
String fieldName = in.getID() + ":" + in.getLabel();
if (in.isASelfRenderer() == true) {
if (in.getSection().equals(section)) {
String fieldSetServicesType = in.getServicesType(false);
Spec recordSpec = in.getRecord().getSpec();
// find a record that corresponds to the fieldset's service type
Record subRecord = recordSpec.getRecord(fieldSetServicesType);
// the fields in an included subrecord should always be in the "common" section
String subSection = "common";
//
// Iterate through each field of the subrecord
//
// Recursive call
boolean createdAuths = doAuthRefsAndTermRefs(auth, types, subRecord, subSection);
if (createdAuths == true) {
// Let the caller know we created at least one auth/term reference
result = true;
}
}
} else {
boolean createdAuths = createAuthRefOrTermRef(auth, types, r, section, in);
if (createdAuths == true) {
// Let the caller know we created at least one auth/term reference
result = true;
}
}
}
return result;
}
Aggregations