use of org.collectionspace.chain.csp.schema.Spec 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