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;
}
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);
}
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);
}
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;
}
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);
}
}
Aggregations