Search in sources :

Example 56 with Record

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

Example 57 with Record

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);
        }
    }
}
Also used : Instance(org.collectionspace.chain.csp.schema.Instance) QName(org.dom4j.QName) Element(org.dom4j.Element) Record(org.collectionspace.chain.csp.schema.Record)

Example 58 with Record

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

Example 59 with Record

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;
}
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

Record (org.collectionspace.chain.csp.schema.Record)59 JSONObject (org.json.JSONObject)33 FieldSet (org.collectionspace.chain.csp.schema.FieldSet)23 JSONArray (org.json.JSONArray)19 UnderlyingStorageException (org.collectionspace.csp.api.persistence.UnderlyingStorageException)14 JSONException (org.json.JSONException)14 Field (org.collectionspace.chain.csp.schema.Field)12 Group (org.collectionspace.chain.csp.schema.Group)12 Instance (org.collectionspace.chain.csp.schema.Instance)11 UnimplementedException (org.collectionspace.csp.api.persistence.UnimplementedException)11 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)10 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)10 Document (org.dom4j.Document)10 HashMap (java.util.HashMap)9 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)9 ExistException (org.collectionspace.csp.api.persistence.ExistException)9 Element (org.dom4j.Element)9 UIException (org.collectionspace.csp.api.ui.UIException)8 IOException (java.io.IOException)7 Repeat (org.collectionspace.chain.csp.schema.Repeat)7