MMI Acquisition schema extension notes

Basic info:

Server: collectionspace.movingimage.us
Version: 1.9
Tenant: mmi
Tenant ID: 42
Tenant string name: AcquisitionTenant42
XML namespace: http://collectionspace.org/services/acquisition/local/mmi
Built using mini-build tool: /tmp/tenant-customizations-v1.9/

Acquisition record

file paths:

/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/src/main/resources/schemas/acquisitions_mmi.xsd
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/src/main/resources/META-INF/MANIFEST.MF
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/src/main/resources/OSGI-INF/core-types-contrib.xml
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/src/main/resources/OSGI-INF/ecm-types-contrib.xml
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/src/main/resources/OSGI-INF/layouts-contrib.xml
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/src/main/resources/OSGI-INF/life-cycle-contrib.xml
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/build.xml
/tmp/v1.9/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition-mmi/pom.xml
/tmp/v1.9/services/acquisition/3rdparty/build.xml
/tmp/v1.9/services/acquisition/3rdparty/pom.xml
-/tmp/v1.9/services/common/src/main/cspace/config/services/tenants/mmi/tenant-bindings.delta.xml-
/usr/local/share/1.9/jboss-4.2.3.GA/server/cspace/cspace/config/services/tenants/mmi/tenant-bindings.delta.xml
/tmp/tenant-customizations-v1.9/ui/our-tenant/bundle/core-messages.properties
/tmp/tenant-customizations-v1.9/ui/our-tenant/html/pages/AcquisitionTemplate.html
/tmp/tenant-customizations-v1.9/application/our-tenant/base-procedure-acquisition.xml
/tmp/tenant-customizations-v1.9/application/our-tenant/domain-procedure-acquisition.xml
Changed Acquisition method into a controlled list field

1. changed the <options> ... </options> section to the acquisitionMethod definition in base-procedure-acquisition.xml

<field id="acquisitionMethod" seperate_ui_container="true">
	<selector>acquisition-acquisition-method</selector>
	<options>
		<option id="gift" default="yes">Gift</option>
		<option id="purchase">Purchase</option>
		<option id="bequest">Bequest</option>
		<option id="loan">Loan</option>
		<option id="restrictedgifts">Restricted Gifts</option>
	</options>
</field>

Note the string structure for the term list options: all lower-case and no space between words.

2. build using mini-build script

cd /tmp/tenant-customizations-v1.9/application
ant deploy

Then restart cspace server.

Add new text field:
Extent

1. This is a new field that will be added as a schema extension for the acquisition procedure. Since there is no current sub-module for our custom schema the first step is to add an acquisition sub-module nuxeo-platform-cs-acquisition-mmi that defines the custom mmi schema. The following steps have been adapted from Rick's helpful How to add an extension schema page.

  • a. add a custom acquisition schema file acquisitions_mmi.xsd with new field name acquisitionExtent

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <!--
        MMI Acquisition schema (XSD)
        Entity  : Acquisition
        Part    : Local - Museum of the Moving Image (MMI)
        Used for: Nuxeo EP core document type
        $LastChangedRevision: $
        $LastChangedDate: $
    -->
    <xs:schema
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:ns="http://collectionspace.org/services/acquisition/local/mmi"
        xmlns="http://collectionspace.org/services/acquisition/local/mmi"
        targetNamespace="http://collectionspace.org/services/acquisition/local/mmi"
        version="0.1">
        <xs:element name="acquisitionExtent" type="xs:string"/>
    </xs:schema>
    
  • b. edit MANIFEST.MF to reference new mmi module

    Note references to lowercase mmi tenant string name on lines 3, 4, and 18.

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 1
    Bundle-Name: org.collectionspace.acquisitiontenant42
    Bundle-SymbolicName: org.collectionspace.acquisitiontenant42;singleton:=true
    Bundle-Version: 1.0.0
    Bundle-Localization: plugin
    Bundle-Vendor: Nuxeo
    Require-Bundle: org.nuxeo.runtime,
     org.nuxeo.ecm.core.api,
     org.nuxeo.ecm.core,
     org.nuxeo.ecm.core.api,
     org.nuxeo.ecm.platform.types.api,
     org.nuxeo.ecm.platform.versioning.api,
     org.nuxeo.ecm.platform.ui,
     org.nuxeo.ecm.platform.forms.layout.client,
     org.nuxeo.ecm.platform.ws,
     org.collectionspace.collectionspace_core
    Provide-Package: org.collectionspace.acquisitiontenant42
    Nuxeo-Component: OSGI-INF/core-types-contrib.xml,
      OSGI-INF/life-cycle-contrib.xml,
      OSGI-INF/ecm-types-contrib.xml,
      OSGI-INF/layouts-contrib.xml
    
  • c. add a custom schema to parent document type core-types-contrib.xml and reference new acquisition schema

    Note reference to mmi schema names and tenant string names on line 2, 4, 7 and 16.

    <?xml version="1.0"?>
    <component name="org.collectionspace.AcquisitionTenant42.coreTypes">
      <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
        <schema name="acquisitions_mmi" prefix="acquisitions_mmi" src="schemas/acquisitions_mmi.xsd"/>
      </extension>
      <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
        <doctype name="AcquisitionTenant42" extends="Acquisition">
          <schema name="common"/>
          <schema name="dublincore"/>
          <schema name="collectionspace_core"/>
          <schema name="acquisitions_common"/>
          <schema name="acquisitions_mmi"/>
          <prefetch>
            acquisitions_common:acquisitionReferenceNumber
            acquisitions_common:acquisitionSources
            acquisitions_common:owners</prefetch>      
        </doctype>
      </extension>
    </component>
    
  • d. edit ecm-types-contrib.xml to reference new mmi component

    Note reference to mmi tenant string name on lines 2, 4, 5, 11, 17 and 23.

    <?xml version="1.0"?>
    <component name="org.collectionspace.AcquisitionTenant42.ecm.types">
      <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
        <type id="AcquisitionTenant42" coretype="AcquisitionTenant42">
          <label>org.collectionspace.AcquisitionTenant42</label>
          <!--icon>/icons/file.gif</icon-->
          <default-view>view_documents</default-view>
    
          <layouts mode="any">
            <layout>heading</layout>
            <layout>collectionspace_core</layout>
            <layout>AcquisitionTenant42</layout>
          </layouts>
        </type>
    
        <type id="Folder" coretype="Folder">
          <subtypes>
            <type>AcquisitionTenant42</type>
          </subtypes>
        </type>
    
        <type id="Workspace" coretype="Workspace">
          <subtypes>
            <type>AcquisitionTenant42</type>
          </subtypes>
        </type>
    
      </extension>
    </component>
    
  • e. edit layouts-contrib.xml to reference new mmi component

    Note reference to mmi tenant string name on lines 3 and 8.

    <?xml version="1.0"?>
    
    <component name="org.collectionspace.AcquisitionTenant42.layouts.webapp">
    
      <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
        point="layouts">
    
        <layout name="AcquisitionTenant42">
          <templates>
    
    ...
    
  • f. edit life-cycle-contrib.xml to reference new mmi component

    Note reference to mmi tenant string name on lines 2 and 7.

    <?xml version="1.0"?>
    <component name="org.collectionspace.ecm.platform.AcquisitionTenant42.LifeCycleManagerExtensions">
    
      <extension target="org.nuxeo.ecm.core.lifecycle.LifeCycleService"
                 point="types">
        <types>
          <type name="AcquisitionTenant42">default</type>
        </types>
      </extension>
    
    </component>
    
  • g. edit 3rdparty/nuxeo-platform-cs-acquisition-mmi/build.xml so to build the custom sub-module

    Note reference to mmi project name on line 1, and tenant string name on lines 13 and 15.

    <project name="nuxeo-platform-cs-acquisition-mmi" default="package" basedir=".">
        <description>
            acquisition nuxeo document type
        </description>
        <!-- set global properties for this build -->
        <property name="services.trunk" value="../../../.."/>
        <!-- environment should be declared before reading build.properties -->
        <property environment="env" />
        <property file="${services.trunk}/build.properties" />
        <property name="mvn.opts" value="" />
        <property name="src" location="src"/>
        <property name="nuxeo.acquisition.jar"
            value="org.collectionspace.services.AcquisitionTenant42.3rdparty.nuxeo-${cspace.release}.jar"/>
        <property name="nuxeo.acquisition.jars.all"
            value="org.collectionspace.services.AcquisitionTenant42.3rdparty.nuxeo-*.jar"/>
    
    ...
    
  • h. edit 3rdparty/nuxeo-platform-cs-acquisition-mmi/pom.xml to reference new mmi component

    Note reference to mmi tenant string name on lines 12, 13, and description on line 15.

    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <parent>
            <groupId>org.collectionspace.services</groupId>
            <artifactId>org.collectionspace.services.acquisition.3rdparty</artifactId>
            <version>1.9-SNAPSHOT</version>
        </parent>
    
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.collectionspace.services</groupId>
        <artifactId>org.collectionspace.services.AcquisitionTenant42.3rdparty.nuxeo</artifactId>
        <name>services.AcquisitionTenant42.3rdparty.nuxeo</name>
        <packaging>jar</packaging>
        <description> MMI Acquisition Nuxeo Document Type </description>
    
    ...
    
  • i. edit 3rdparty/build.xml so to build the custom sub-module

    Note reference to mmi custom module on lines 11, 116, 122 and 128.

    <project name="acquisition.3rdparty" default="package" basedir=".">
        <description>
            acquisition service 3rdparty
        </description>
      <!-- set global properties for this build -->
        <property name="services.trunk" value="../../.."/>
        <!-- enviornment should be declared before reading build.properties -->
        <property environment="env" />
        <property file="${services.trunk}/build.properties" />
        <property name="nuxeo-platform-acquisition" value="nuxeo-platform-acquisition"/>
        <property name="nuxeo-platform-acquisition-mmi" value="nuxeo-platform-acquisition-mmi"/>
    
    ...
    

    and further down the file

        <target name="deploy" depends="install"
            description="deploy acquisition in ${jboss.server.nuxeo}">
            <ant antfile="nuxeo-platform-cs-acquisition/build.xml" target="deploy" inheritall="false"/>
            <ant antfile="nuxeo-platform-cs-acquisition-mmi/build.xml" target="deploy" inheritall="false"/>
        </target>
    
        <target name="undeploy"
            description="undeploy acquisition from ${jboss.server.nuxeo}">
            <ant antfile="nuxeo-platform-cs-acquisition/build.xml" target="undeploy" inheritall="false"/>
            <ant antfile="nuxeo-platform-cs-acquisition-mmi/build.xml" target="undeploy" inheritall="false"/>
        </target>
    
        <target name="dist"
            description="generate distribution for acquisition" depends="package">
            <ant antfile="nuxeo-platform-cs-acquisition/build.xml" target="dist" inheritall="false"/>
            <ant antfile="nuxeo-platform-cs-acquisition-mmi/build.xml" target="dist" inheritall="false"/>
        </target>
    
    
    </project>
    
  • j. edit 3rdparty/pom.xml to reference new mmi component

    Note reference to mmi custom module on line 21.

    <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <parent>
            <groupId>org.collectionspace.services</groupId>
            <artifactId>org.collectionspace.services.acquisition</artifactId>
            <version>1.9-SNAPSHOT</version>
        </parent>
    
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.collectionspace.services</groupId>
        <artifactId>org.collectionspace.services.acquisition.3rdparty</artifactId>
        <packaging>pom</packaging>
        <name>services.acquisition.3rdparty</name>
        <description>
            3rd party build for acquisition service
        </description>
    
        <modules>
            <module>nuxeo-platform-cs-acquisition</module>
            <module>nuxeo-platform-cs-acquisition-mmi</module>
        </modules>
    </project>
    
  • k. add schema extension to tenant binding tenant-bindings-delta.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <tenant:TenantBindingConfig
            xmlns:merge='http://xmlmerge.el4j.elca.ch'
            xmlns:tenant='http://collectionspace.org/services/common/tenant'>
                     
        <tenant:tenantBinding id="42" name="movingimage.us" displayName="MovingImage CollectionSpace Tenant" version="0.1">
            <tenant:repositoryDomain name="default-domain" storageName="mmi-domain" repositoryClient="nuxeo-java" />
                     <!-- Acquisition -->
    		 <tenant:serviceBindings merge:matcher="id" id="Acquisitions">
                    <service:object xmlns:service="http://collectionspace.org/services/common/service" >
                            <service:part id="42" merge:matcher="skip" merge:action="insert" control_group="Managed" versionable="true" auditable="false" label="acquisitions_mmi" updated="" order="42">
                              <service:content contentType="application/xml">
                                    <service:xmlContent namespaceURI="http://collectionspace.org/services/acquisition/local/mmi" schemaLocation="http://collectionspace.org/services/acquisition/local/mmi http://collectionspace.org/services/acquisition/local/acquisitions_mmi.xsd" />
                              </service:content>
                            </service:part>
                    </service:object>
            </tenant:serviceBindings>
    		
        </tenant:tenantBinding>
                           
    </tenant:TenantBindingConfig>
    

2. add field id and selector to domain-procedure-acquisition.xml

Note the section attribute for the new field. Every new field will have this identifying attribute.

<section id="domaindata">
        <field id="acquisitionExtent" section="mmi">
                <selector>acquisition-acquisitionExtent</selector>
        </field>
</section>

3. edit base-procedure-acquisition.xml to point to new schema

Note the id attribute on line 5. This connects with the section attribute from the domain-procedure-acquisition.xml file.

<record id="acquisition" in-findedit="yes" type="record,procedure">
     <services-url>acquisitions</services-url>
     <services-tenant-singular>Acquisition</services-tenant-singular>
     <services-list-path>abstract-common-list/list-item</services-list-path>
     <services-record-path id="mmi">acquisitions_mmi:http://collectionspace.org/services/acquisition/local/mmi,acquisitions_mmi</services-record-path>
     <services-record-path>acquisitions_common:http://collectionspace.org/services/acquisition,acquisitions_common</services-record-path>
     <services-record-path id="collectionspace_core">collectionspace_core:http://collectionspace.org/collectionspace_core/,collectionspace_core</services-record-path>

...

4. add field label to core-messages.properties

acquisition-acquisitionExtentLabel: Extent

5. add html for new field to AcquisitionTemplate.html

<div class="info-pair">
   <div class="header">
       <div class="label csc-acquisition-acquisitionExtent-label">Extent</div>
   </div>
   <div class="content">
        <input type="text" class="csc-acquisition-acquisitionExtent" />
   </div>
</div>

6. run mini-build scripts to deploy changes across all layers and then build & deploy updated services module from source

cd /tmp/tenant-customizations-v1.9/application
ant deploy
cd /tmp/tenant-customizations-v1.9/ui
ant deploy
cd /tmp/v1.9/services/acquisition
mvn clean install -DskipTests
cd /tmp/v1.9/services/
ant undeploy deploy

7. Testing new field with payload

sample.xml

<?xml version="1.0" encoding="utf-8"?>
<document name="acquisitions">
 <ns2:acquisitions_common
xmlns:ns2="http://collectionspace.org/services/acquisition"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <titleGroupList>
     <titleGroup>
       <title>A title</title>
     </titleGroup>
   </titleGroupList>
   <acquisitionReferenceNumber>2011.2.5</acquisitionReferenceNumber>
 </ns2:acquisitions_common>
 <ns2:acquisitions_mmi xmlns:ns2="http://collectionspace.org/services/acquisition/local/mmi"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <acquisitionExtent>foobar</acquisitionExtent>
 </ns2:acquisitions_mmi>
</document>

use cURL command to send sample.xml payload

curl -i -u admin@movingimage.us:Administrator -X POST \
-H "Content-Type: application/xml" \
http://localhost:8180/cspace-services/acquisitions \
-T sample.xml
Removed two fields:
Transfer of title number and Field Collection event name

1. Commented out references in base-procedure-acquisition.xml

<section id="objectCollectionInformation">
        <!--<repeat id="fieldCollectionEventNames">
             <selector>acquisition-fieldCollectionEventName</selector>
             <field id="fieldCollectionEventName"></field>
        </repeat>-->
</section>
<!--<field id="transferOfTitleNumber" datatype="largetext">
          <selector>acquisition-transfer-of-title-number</selector>
</field>-->

2. Removed references in core-messages.properties

#acquisition-fieldCollectionEventNamesLabel: Field collection event name
#acquisition-transferOfTitleNumberLabel: Transfer of Title Number

3. Removed reference in AcquisitionTemplate.html

4. run mini-build scripts to deploy changes across app and ui layers

cd /tmp/tenant-customizations-v1.9/application
ant deploy
cd /tmp/tenant-customizations-v1.9/ui
ant deploy

re-init application layer: collectionspace/chain/init