How to change a field's data type - DRAFT

This is an older document that requires substantial revision to be brought up to current documentation standards. Some of the instructions in this document may be outdated and require modification, while others may be missing outright.

This document is included here as a placeholder, even prior to being revised, as an experienced CollectionSpace implementer may yet be able to obtain some of the information they need to perform this task by carefully parsing this document.

How to change a field's data type

A field's data type is configured in (at least) two places:

  • In the system's main configuration file, cspace-config.xml.
  • In the mark-up for that field, in an HTML template file.

CollectionSpace provides HTML templates used for each different data type, including plain text input, date pickers, drop-down lists, autocomplete fields, among others. The HTML required for each of these different field types is different, so changing the data type of a field means you will have to change the associated HTML for that field.

Task Description

In the user interface (UI), the process includes finding the correct file, finding the field within that filed, and editing the HTML as necessary. The cspace-config.xml file is used by UI and App layer to define relationships between the service layer and the UI. In the app layer code it is located in the /tomcat-main/src/main/resources/default.xml directory. When the app Layer is deployed it is exported to $JBOSS/server/cspace/lib/cspace-config.xml directory.

Prerequisites

The tasks associated with this document can be done by a system administrator with experience editing HTML and XML.

Procedure

To edit the cspace-config.xml file to change a field's data type, follow the next steps:

Editing the cspace-config.xml file is covered in the document cspace-config Add Field, Group, Repeat.

To change the HTML mark-up for a field to support the change of the field's data type, follow the next steps:

  • To change the data type for plain text fields, navigate to the HTML template for that data type and locate the "text" template, as illustrated next:

    <input type="text" class="styling-classname csc-{recordid}-{fieldid}" />

    * cspace-config.xml - simple field fine

    <field id="{fieldid}"></field>
  • To change the data type for multi-line text fields, navigate to the HTML template for that data type and locate the "textarea" template, as illustrated next:

    <textarea class="input-textarea csc-{recordid}-{fieldid}"/>

    * cspace-config.xml - simple field fine

    <field id="{fieldid}"></field>
  • To change the data type for a drop-down list fields, navigate to the HTML template for that data type and locate the "select" template, as illustrated next:

    <select class="input-select csc-{recordid}-{fieldid}" />

    * cspace-config.xml requires either to be associated with a controlled list or added in options

    <field id="currentLocationFitness">
      <options>
        <option id="" default="yes">Please select a value</option>
        <option id="dangerous">Dangerous</option>
        <option id="suitable">Suitable</option>
        <option id="temporary">Temporary</option>
        <option id="unsuitable">Unsuitable</option>
      </options>
    </field>
    

    or

    <field id="contentLanguage" autocomplete="vocab-languages" ui-type="enum">
    	<enum>
    		<default>eng</default>
    		<blank-value>Please select a value</blank-value>
    	</enum>
    </field>
    

    whcih assumes an instance in record id="vocab"

    <instance id="vocab-languages">
    	<web-url>languages</web-url>
    	<title-ref>languages</title-ref>
    	<title>My first list</title>
    	<options>
    		<option id="eng">English</option>
    		<option id="spn">Spanish</option>
    		<option>French</option>
    		<option>Italian</option>
    		<option>Portuguese</option>
    	</options>
    </instance>
    
  • To change the data type for a date picker fields, navigate to the HTML template for that data type and locate the "date picker" template, as illustrated next:

    <input type="text" disabled="disabled" class="input-date csc-identifying-classname csc-calendar-date" />
    <a href="#_bottom" class="csc-calendar-button" > <img src="../images/cal.png" alt="calendar" height="16" width="18" /></a>

    * cspace-config.xml You must add the attribute ui=type="date"

    <field id="plannedRemovalDate" ui-type="date"></field>
    
  • To change the data type for an autocomplete field (for Authority terms), navigate to the HTML template for that data type and locate the "text" class, as illustrated next:

    <input type="text" class="csc-identifying-classname" name="acquisition-authorizer" />
    <div class="csc-identifying-classname-autocomplete"></div>

     Note: For this field type, the div must use the same classname as the input, with "-autocomplete" appended.

  • cspace-config.xml must add the attribute autocomplete with a comma delimited list of authorities

    <field id="movementContact" autocomplete="person-person"></field>
    
  • To change the data type for a number pattern chooser field, navigate tothe HTML template for that data type and locate the "number pattern chooser" template, as illustrated next:

    <div class="content csc-identifying-classname-container">
        <input type="text" class="input-numeric-long pattern-chooser-input csc-identifying-classname" /></div>

    Note: For this field type, the csc- classname on the containing div must match that used in the XML configuration file.

  • cspace-config.xml set attribute choose="yes", include the options

    <field id="objectNumber" chooser="yes" seperate_ui_container="true">
    	<title-selector>.csc-titleBar-object-identification-object-number</title-selector>
    	<options>
    		<option id="intake" sample="IN2009.1.1">Intake</option>
    		<option id="objects" sample="2009.1.1">Accession</option>
    		<option id="loans-in" sample="LI2009.1.1">Loans In</option>
    	</options>
    </field>
    

    you also must make sure that the option id names exist in the <Record id="id"> fields
    e.g.

    <record id="id" type="id">
    	<authorization-view>false</authorization-view>
    	<field id="accession-activity"><selector>1a67470b-19b1-4ae3-88d4-2a0aa936270e</selector></field>
    	<field id="objects"><selector>9dd92952-c384-44dc-a736-95e435c1759c</selector></field>
    	<field id="accession"><selector>9dd92952-c384-44dc-a736-95e435c1759c</selector></field>
    ...
    </record>
    

Test

In this section describe how the changes can be viewed or tested as correctly made.

Summary

This document has explained how to change a field's data type. These changes include how to define a field as an authority, as a controlled vocabularised list, as a basic controlled list, or as a structured date, and then explain to system administrators how to change these data types from one to another.

Important Note

After modifying the UI or App layer, the Cspace server (only) needs to be restarted. After modifying the service layer, both the CollectionSpace and Nuxeo servers must be restarted for the changes to be deployed.

See Starting up - Collection Space Servers and Shutting Down - Collection Space Servers for details.

NOTE: Any section that is blank once the configuration task is completely described should be removed.

See Also

For more details about how to change the behavior of fields in cspace-config.xml, see:
http://wiki.collectionspace.org/display/collectionspace/cspace-config+Fields
http://wiki.collectionspace.org/display/collectionspace/cspace-config+Add+Field%2C+Group%2C+Repeat

For a description of different field data types, see:
http://wiki.collectionspace.org/display/collectionspace/HTML+field+level+templates

List of references