talk@lists.collectionspace.org

WE HAVE SUNSET THIS LISTSERV - Join us at collectionspace@lyrasislists.org

View all threads

Overriding an existing field with a repeating version

JS
Joe Slag
Thu, Jun 9, 2011 9:08 PM

Now that I've had success adding fields to catalog objects, I'm turning
to the next task on my list, which is modifying our local schema so that
a few existing single fields can repeat. I'm starting with the
'collection' field.

My assumption was that defining a repeating field named 'collection' and
referring to it in our schema extension, and then modifying the UI
appropriately, would do the trick, but it isn't exactly. The controls
show up appropriately, but data for the repeating collection field isn't
getting saved.

Here's what I've done. Preview: my greatest confusion came in step 4,
though I certainly may have missed something before then.

  1. Define the field in the same collectionobjects_wac.xsd I've been
    using for previous, successful field additions:

     <xs:complexType name="collectionList">
    

    xs:sequence
    <xs:element name="collection" type="xs:string" minOccurs="0"
    maxOccurs="unbounded" />
    </xs:sequence>
    </xs:complexType>

  2. That schema is already referred to in core-types-contrib and
    tenant-bindings, so no changes there. I followed the standard server
    stopping, mvn and ant running steps, and after starting the server up
    again, I had success creating a test object with multiple collections
    via XML:

$ curl -i -u admin@collectionspace.org:Administrator -X POST -H
"Content-Type: application/xml"
http://localhost:8180/cspace-services/collectionobjects -T mysamplefile.xml

where mysamplefile.xml is:

<?xml version="1.0" encoding="utf-8"?> <document name="collectionobjects"> <ns2:collectionobjects_common xmlns:ns2="http://collectionspace.org/services/collectionobject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <titleGroupList> <titleGroup> <title>from XML</title> </titleGroup> </titleGroupList> <objectNumber>2011.1.58</objectNumber> </ns2:collectionobjects_common> <ns2:collectionobjects_wac xmlns:ns2="http://walkerart.org/collectionobject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <collectionList> <collection>library-collection</collection> <collection>study-collection</collection> </collectionList> </ns2:collectionobjects_wac> </document>

When requested via the URL returned by cspace, the collections are both
present.

  1. Moving on to the UI, I left the collection tag unchanged, as it seems
    consistent with the other repeating fields:
<div class="info-pair-select"> <div class="header"> <div class="label">Collection</div> </div> <div class="content"> <select class="csc-object-identification-collection input-select"><option value="">Options not loaded</option></select> </div> </div>
  1. Finally, cspace-config.xml, which is where I experienced the most
    confusion. I've tried a few variations on this:
<repeat id="collectionList" has-primary="yes" section="wac"> <selector>object-identification-collectionList</selector> <field id="collection" seperate_ui_container="true" section="wac"> <selector>object-identification-collection</selector> <options> <option id="">Please select a value</option> <option id="library-collection">Library collection</option> <option id="permanent-collection">Permanent collection</option> <option id="study-collection">Study collection</option> <option id="teaching-collection">Teaching collection</option> </options> </field> </repeat>

One thing that isn't clear to me is where the section="wac" attributes
belong. On the field, yes; but how about on the repeat?

Also, looking at the other repeating fields, what to put in the
child-of-repeat selector isn't clear; sometimes it seems to be the same
as the child-of-field selector, sometimes it isn't.

Anyhow, after the above,
http://myhost:8180/collectionspace/chain/cataloging/uischema seems
reasonable:

"collectionList": {
"items": {
"properties": {
"_primary": {
"type": "boolean"
},
"collection": {
"default": "",
"type": "string"
}
},
"type": "object"
},
"type": "array"
},

I haven't made as much headway understanding the contents of
http://myhost:8180/collectionspace/chain/cataloging/uispec, but for what
it's worth, here are relevant sections:

".csc-collection-object-collectionList-label": {
"messagekey": "collection-object-collectionListLabel"
},
. . .
".csc-object-identification-collection": {
"decorators": [
{
"func": "cspace.makeRepeatable",
"options": {
"elPath": "fields.collectionList",
"protoTree": {
"expander": {
"tree": {
"expander": {
"controlledBy": "fields.collectionList",
"pathAs": "row",
"repeatID": "repeat:",
"tree": {
".csc-object-identification-collection":
{
"optionlist": [
"",
"library-collection",
"permanent-collection",
"study-collection",
"teaching-collection"
],
"optionnames": [
"Please select a value",
"Library collection",
"Permanent collection",
"Study collection",
"Teaching collection"
],
"selection": "${{row}.collection}"
}
},
"type": "fluid.renderer.repeat"
}
},
"type": "fluid.noexpand"
}
}
},
"type": "fluid"
}
]
},

Does anything jump out at folks?

thanks,
Joe

Now that I've had success adding fields to catalog objects, I'm turning to the next task on my list, which is modifying our local schema so that a few existing single fields can repeat. I'm starting with the 'collection' field. My assumption was that defining a repeating field named 'collection' and referring to it in our schema extension, and then modifying the UI appropriately, would do the trick, but it isn't exactly. The controls show up appropriately, but data for the repeating collection field isn't getting saved. Here's what I've done. Preview: my greatest confusion came in step 4, though I certainly may have missed something before then. 1. Define the field in the same collectionobjects_wac.xsd I've been using for previous, successful field additions: <xs:complexType name="collectionList"> <xs:sequence> <xs:element name="collection" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> 2. That schema is already referred to in core-types-contrib and tenant-bindings, so no changes there. I followed the standard server stopping, mvn and ant running steps, and after starting the server up again, I had success creating a test object with multiple collections via XML: $ curl -i -u admin@collectionspace.org:Administrator -X POST -H "Content-Type: application/xml" http://localhost:8180/cspace-services/collectionobjects -T mysamplefile.xml where mysamplefile.xml is: <?xml version="1.0" encoding="utf-8"?> <document name="collectionobjects"> <ns2:collectionobjects_common xmlns:ns2="http://collectionspace.org/services/collectionobject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <titleGroupList> <titleGroup> <title>from XML</title> </titleGroup> </titleGroupList> <objectNumber>2011.1.58</objectNumber> </ns2:collectionobjects_common> <ns2:collectionobjects_wac xmlns:ns2="http://walkerart.org/collectionobject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <collectionList> <collection>library-collection</collection> <collection>study-collection</collection> </collectionList> </ns2:collectionobjects_wac> </document> When requested via the URL returned by cspace, the collections are both present. 3. Moving on to the UI, I left the collection tag unchanged, as it seems consistent with the other repeating fields: <div class="info-pair-select"> <div class="header"> <div class="label">Collection</div> </div> <div class="content"> <select class="csc-object-identification-collection input-select"><option value="">Options not loaded</option></select> </div> </div> 4. Finally, cspace-config.xml, which is where I experienced the most confusion. I've tried a few variations on this: <repeat id="collectionList" has-primary="yes" section="wac"> <selector>object-identification-collectionList</selector> <field id="collection" seperate_ui_container="true" section="wac"> <selector>object-identification-collection</selector> <options> <option id="">Please select a value</option> <option id="library-collection">Library collection</option> <option id="permanent-collection">Permanent collection</option> <option id="study-collection">Study collection</option> <option id="teaching-collection">Teaching collection</option> </options> </field> </repeat> One thing that isn't clear to me is where the section="wac" attributes belong. On the field, yes; but how about on the repeat? Also, looking at the other repeating fields, what to put in the child-of-repeat selector isn't clear; sometimes it seems to be the same as the child-of-field selector, sometimes it isn't. Anyhow, after the above, http://myhost:8180/collectionspace/chain/cataloging/uischema seems reasonable: "collectionList": { "items": { "properties": { "_primary": { "type": "boolean" }, "collection": { "default": "", "type": "string" } }, "type": "object" }, "type": "array" }, I haven't made as much headway understanding the contents of http://myhost:8180/collectionspace/chain/cataloging/uispec, but for what it's worth, here are relevant sections: ".csc-collection-object-collectionList-label": { "messagekey": "collection-object-collectionListLabel" }, . . . ".csc-object-identification-collection": { "decorators": [ { "func": "cspace.makeRepeatable", "options": { "elPath": "fields.collectionList", "protoTree": { "expander": { "tree": { "expander": { "controlledBy": "fields.collectionList", "pathAs": "row", "repeatID": "repeat:", "tree": { ".csc-object-identification-collection": { "optionlist": [ "", "library-collection", "permanent-collection", "study-collection", "teaching-collection" ], "optionnames": [ "Please select a value", "Library collection", "Permanent collection", "Study collection", "Teaching collection" ], "selection": "${{row}.collection}" } }, "type": "fluid.renderer.repeat" } }, "type": "fluid.noexpand" } } }, "type": "fluid" } ] }, Does anything jump out at folks? thanks, Joe