Search in sources :

Example 1 with Field

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

the class RecordRead method getUsedBy.

private JSONArray getUsedBy(String id) throws JSONException {
    String instanceid = "vocab-" + id;
    JSONArray usedByNames = new JSONArray();
    if (spec.hasTermlist(instanceid)) {
        Field[] fs = spec.getTermlist(instanceid);
        for (Field f : fs) {
            JSONObject jo = new JSONObject();
            jo.put("usedBy", f.getRecord().getWebURL() + ":" + f.getSelector());
            usedByNames.put(jo);
        }
    }
    return usedByNames;
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Example 2 with Field

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

the class UISchema method actualComputedField.

@Override
protected void actualComputedField(JSONObject out, FieldSet fs, UISpecRunContext context) throws JSONException {
    String datatype = ((Field) fs).getDataType();
    if (datatype.equals("")) {
        datatype = "string";
    }
    JSONObject computed = new JSONObject();
    actualSchemaObject(datatype, null, null, null, computed);
    out.put(getSelector(fs, context), computed);
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject)

Example 3 with Field

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

the class UISchema method actualValidatedField.

@Override
protected void actualValidatedField(JSONObject out, FieldSet fs, UISpecRunContext context) throws JSONException {
    String datatype = ((Field) fs).getDataType();
    if (datatype.equals("")) {
        datatype = "string";
    }
    JSONObject validator = new JSONObject();
    actualSchemaObject(datatype, null, null, null, validator);
    out.put(getSelector(fs, context), validator);
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject)

Example 4 with Field

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

the class UISpec method actualChooser.

/**
 * The UISpec mark up for Chooser elements
 * @param f
 * @param context
 * @return
 * @throws JSONException
 */
private JSONObject actualChooser(FieldSet fs, UISpecRunContext context, JSONArray decorators) throws JSONException {
    Field f = (Field) fs;
    JSONObject out = new JSONObject();
    JSONObject options = new JSONObject();
    JSONObject selectors = new JSONObject();
    selectors.put("numberField", getSelector(f, context));
    options.put("selectors", selectors);
    JSONObject model = new JSONObject();
    JSONArray ids = new JSONArray();
    JSONArray samples = new JSONArray();
    JSONArray names = new JSONArray();
    for (Option opt : f.getAllOptions()) {
        ids.put(opt.getID());
        samples.put(opt.getSample());
        names.put(opt.getName());
    }
    model.put("list", ids);
    model.put("samples", samples);
    model.put("names", names);
    options.put("model", model);
    JSONObject decorator = getDecorator("fluid", null, "cspace.numberPatternChooser", options, f.isReadOnly());
    if (!f.isRefactored()) {
        if (f.hasContainer()) {
            decorator.put("container", getContainerSelector(f, context));
        }
    }
    if (decorators == null) {
        decorators = new JSONArray();
    }
    decorators.put(decorator);
    out.put(DECORATORS_KEY, decorators);
    if (f.isRefactored()) {
        out.put("valuebinding", actualFieldEntry(f, context));
    }
    return out;
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Option(org.collectionspace.chain.csp.schema.Option)

Example 5 with Field

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

the class UISpec method actualFieldExpanderEntry.

/**
 * Overwrite with output you need for this thing you are doing
 * @param out
 * @param fs
 * @param context
 * @throws JSONException
 */
@Override
protected void actualFieldExpanderEntry(JSONObject out, FieldSet fs, UISpecRunContext context) throws JSONException {
    if ("radio".equals(fs.getUIType())) {
        JSONObject expander = new JSONObject();
        expander.put("type", "fluid.renderer.selection.inputs");
        expander.put("rowID", getSelector(fs, context) + "-row:");
        expander.put("labelID", getSelector(fs, context) + "-label");
        expander.put("inputID", getSelector(fs, context) + "-input");
        expander.put("selectID", fs.getID());
        JSONObject tree = new JSONObject();
        Field f = (Field) fs;
        tree = (JSONObject) actualOptionField(f, context);
        expander.put("tree", tree);
        out.put("expander", expander);
    }
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject)

Aggregations

Field (org.collectionspace.chain.csp.schema.Field)45 JSONObject (org.json.JSONObject)37 JSONArray (org.json.JSONArray)26 FieldSet (org.collectionspace.chain.csp.schema.FieldSet)22 UnderlyingStorageException (org.collectionspace.csp.api.persistence.UnderlyingStorageException)14 Group (org.collectionspace.chain.csp.schema.Group)12 Record (org.collectionspace.chain.csp.schema.Record)12 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)9 Repeat (org.collectionspace.chain.csp.schema.Repeat)9 JSONException (org.json.JSONException)9 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)7 Document (org.dom4j.Document)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)6 Element (org.dom4j.Element)6 ArrayList (java.util.ArrayList)5 Instance (org.collectionspace.chain.csp.schema.Instance)5 UnimplementedException (org.collectionspace.csp.api.persistence.UnimplementedException)5 HashMap (java.util.HashMap)4 Option (org.collectionspace.chain.csp.schema.Option)4