Search in sources :

Example 26 with Spec

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

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

use of org.collectionspace.chain.csp.schema.Spec in project application by collectionspace.

the class ServiceConfigGeneration method createSpec.

private Spec createSpec(CSPManager cspm) {
    ConfigRoot root = cspm.getConfigRoot();
    Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
    return spec;
}
Also used : ConfigRoot(org.collectionspace.chain.csp.config.ConfigRoot) TenantSpec(org.collectionspace.chain.csp.persistence.services.TenantSpec) Spec(org.collectionspace.chain.csp.schema.Spec)

Example 29 with Spec

use of org.collectionspace.chain.csp.schema.Spec in project application by collectionspace.

the class TestServices method getSpec.

private Spec getSpec(CSPManager cspm) {
    ConfigRoot root = cspm.getConfigRoot();
    Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
    assertNotNull(spec);
    return spec;
}
Also used : ConfigRoot(org.collectionspace.chain.csp.config.ConfigRoot) TenantSpec(org.collectionspace.chain.csp.persistence.services.TenantSpec) Spec(org.collectionspace.chain.csp.schema.Spec)

Example 30 with Spec

use of org.collectionspace.chain.csp.schema.Spec in project application by collectionspace.

the class TestServices method getServiceManager.

private CSPManager getServiceManager(String filename) {
    CSPManager cspm = new CSPManagerImpl();
    cspm.register(new CoreConfig());
    cspm.register(new Spec());
    cspm.register(new ServicesStorageGenerator());
    try {
        cspm.go();
        cspm.configure(getSource(filename), new ConfigFinder(null), false);
    } catch (CSPDependencyException e) {
        log.error("CSPManagerImpl failed");
        log.error(e.getLocalizedMessage());
    }
    return cspm;
}
Also used : ServicesStorageGenerator(org.collectionspace.chain.csp.persistence.services.ServicesStorageGenerator) CSPManager(org.collectionspace.csp.api.container.CSPManager) CoreConfig(org.collectionspace.chain.csp.inner.CoreConfig) CSPDependencyException(org.collectionspace.csp.api.core.CSPDependencyException) CSPManagerImpl(org.collectionspace.csp.container.impl.CSPManagerImpl) TenantSpec(org.collectionspace.chain.csp.persistence.services.TenantSpec) Spec(org.collectionspace.chain.csp.schema.Spec) ConfigFinder(org.collectionspace.csp.helper.core.ConfigFinder) TestConfigFinder(org.collectionspace.csp.helper.test.TestConfigFinder)

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