use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class ServiceBindingsGeneration method getFullyQualifiedFieldPath.
/*
* Returns the fully qualified path of a field name
*/
private String getFullyQualifiedFieldPath(FieldSet in) {
String tail = null;
// Start by assuming it's just a plain scalar field, so we would just return the name
String name = in.getServicesTag();
//
// Debug info
//
String[] fullName = in.getIDPath();
boolean isPartOfGroup = in.getParent() instanceof Group;
boolean isGroup = in instanceof Group;
boolean isGroupField = in.isAGroupField();
//
if (in.getParent().isTrueRepeatField() == true) {
name = "";
FieldSet fst = in;
while (fst.getParent().isTrueRepeatField() == true) {
// Fields that are part of a repeatable structured group have a form like this 'titleGroupList/[0]/title'
tail = "/";
if (isScalarRepeat(fst) == true) {
// Scalar-repeats (aka, multi-valued fields) look like 'responsibleDepartments/[0]' and *not* 'responsibleDepartments/[0]/responsibleDepartment'
tail = "";
}
fst = (FieldSet) fst.getParent();
if (fst instanceof Repeat) {
Repeat rt = (Repeat) fst;
if (rt.hasServicesParent()) {
name += rt.getServicesParent()[0];
} else {
name += rt.getServicesTag();
}
} else {
// REM - This 'else' clause is not necessary and should be removed.
Group gp = (Group) fst;
if (gp.hasServicesParent()) {
name += gp.getServicesParent()[0];
} else {
name += gp.getServicesTag();
}
}
name += GROUP_LIST_SUFFIX + tail;
}
if (name.contains(GROUP_LIST_SUFFIX) && name.endsWith("/")) {
name += in.getServicesTag();
}
}
return name;
}
use of org.collectionspace.chain.csp.schema.FieldSet 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