Search in sources :

Example 31 with Spec

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;
}
Also used : FieldSet(org.collectionspace.chain.csp.schema.FieldSet) Record(org.collectionspace.chain.csp.schema.Record) TenantSpec(org.collectionspace.chain.csp.persistence.services.TenantSpec) Spec(org.collectionspace.chain.csp.schema.Spec)

Aggregations

Spec (org.collectionspace.chain.csp.schema.Spec)31 ConfigRoot (org.collectionspace.chain.csp.config.ConfigRoot)12 TenantSpec (org.collectionspace.chain.csp.persistence.services.TenantSpec)10 CSPManager (org.collectionspace.csp.api.container.CSPManager)8 CSPManagerImpl (org.collectionspace.csp.container.impl.CSPManagerImpl)8 CoreConfig (org.collectionspace.chain.csp.inner.CoreConfig)7 Record (org.collectionspace.chain.csp.schema.Record)7 ConfigFinder (org.collectionspace.csp.helper.core.ConfigFinder)7 FieldSet (org.collectionspace.chain.csp.schema.FieldSet)5 WebUI (org.collectionspace.chain.csp.webui.main.WebUI)5 CSPDependencyException (org.collectionspace.csp.api.core.CSPDependencyException)5 UI (org.collectionspace.csp.api.ui.UI)4 TestConfigFinder (org.collectionspace.csp.helper.test.TestConfigFinder)4 Element (org.dom4j.Element)4 JSONObject (org.json.JSONObject)4 ServicesStorageGenerator (org.collectionspace.chain.csp.persistence.services.ServicesStorageGenerator)3 QName (org.dom4j.QName)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 StringWriter (java.io.StringWriter)2