Array index start at 1 for ReDBox form data and the Curation process

10 views
Skip to first unread message

Jay van Schyndel

unread,
Oct 11, 2012, 2:06:07 AM10/11/12
to redbo...@googlegroups.com
Hi Everyone,

For the last week or so I have been modifying the input forms for JCU and today I have been investigating issues with the Curation Process.

I have found a need to ensure that any array based data starts with an index of 1 when harvesting so that the forms display the data properly.
Today while reviewing data through to the 'Published' stage, I have found that the CurationManager.java insists on array based data starting at an index of 1.

CurationManager calls FormDataParser.getObject. GetObject has the restriction.
    /**
     * Get a child JSON Object from an incoming JSON array. If the child does
     * not exist it will be created, along with any smaller index values. The
     * index is expected to be 1 based (like form data).
     *
     * It is only valid for form arrays to hold JSON Objects.
     *
     * @param array The incoming array we are to look inside
     * @param index The child index we are looking for (1 based)
     * @return JsonObject The child we found or created
     * @throws IOException if anything other than an object is found, or an
     * invalid index is provided
     */
    private static JsonObject getObject(JSONArray array, int index)
            throws IOException {
        // We can't just jam an entry into the array without
        //  checking that earlier indexes exist. Also we need
        //  to account for 0 versus 1 based indexing.

        // Index changed to 0 based
        if (index < 1) {
            throw new IOException("Invalid index value provided in form data.");
        }
        index -= 1;

        // Nice and easy, it already exists

I would like to know why ReDBox has this requirement when most array processing starts with an index of 0.
I think it's something to do with the Velocity Templates but haven't been able to track it down.
It's been a cause for confusion and errors.

I just want to highlight this requirement so other people can implement ReDBox more efficiently.

Thanks,
              Jay.

Duncan Dickinson

unread,
Oct 11, 2012, 3:38:02 AM10/11/12
to redbo...@googlegroups.com
Hi Jay,

The forms use the 0 index as a prototype for list items. This causes the actual data to sit in at index 1. 

It's not great and I'm really hoping that Andrew and I will be able to really overhaul the forms interface in the coming months. At this point though we're very pushed for time.

Cheers,

Duncan


--
You received this message because you are subscribed to the Google Groups "ReDBox Development" group.
To post to this group, send an email to redbo...@googlegroups.com.
To unsubscribe from this group, send email to redbox-dev+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msg/redbox-dev/-/ABHDK91ZvNkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Cheers, 


Duncan 


Duncan Dickinson 

QCIF Project Manager 

Central Queensland University 

My contact details:

ph: 07 3138 2084

m: 0432 402 511

skype: de.dickinson

website calendar | LinkedIn

Project involvement

ReDBox (Research Data Box)

TERN Central Portal

Tropical Data Hub


Developer? Check out dev8D-AU at 
 http://dev8dau.info/



Greg Pendlebury

unread,
Oct 11, 2012, 3:38:15 AM10/11/12
to redbo...@googlegroups.com
Hi Jay,

You should find an explanation here: http://code.google.com/p/redbox-mint/wiki/FormFieldsReMap

"Jaffa (our Javascript form library) allows lists of fields (eg. a list of creators) to be generated from a template. The template is provided as the ZEROth item of a list, and real data then comes back from the form submission as 1, 2, 3 etc... This is why you will see xxx.0.xxx is field names. "

So it is a constraint that comes from Jaffa, based on how it does form rendering.

Ta,
Greg


--

Jay van Schyndel

unread,
Oct 11, 2012, 7:12:28 PM10/11/12
to redbo...@googlegroups.com
Hi Duncan and Greg.

Thanks for this additional information.

Cheers,
              Jay.
Reply all
Reply to author
Forward
0 new messages