use of org.collectionspace.chain.csp.schema.Field in project application by collectionspace.
the class SchemaStructure method makeAGroupField.
/**
* Do all the magic to make a GroupField
*
* @param fs
* @param context
* @throws JSONException
*/
protected JSONObject makeAGroupField(FieldSet fs, UISpecRunContext context) throws JSONException {
JSONObject out = new JSONObject();
if (fs instanceof Field || fs instanceof Repeat) {
JSONObject subexpander = new JSONObject();
JSONObject options = new JSONObject();
String[] parts = fs.getUIType().split("/");
Record subitems = fs.getRecord().getSpec().getRecordByServicesUrl(parts[1]);
UISpecRunContext sub = context.createChild();
sub.setUIPrefix(fs.getID());
sub.setPad(false);
if (isAStructureDate(fs)) {
makeAStructureDate(fs, out, subexpander, options, subitems, sub, context);
} else if (fs.isASelfRenderer()) {
makeASelfRenderer(fs, context, out, subexpander, options, subitems, sub);
} else {
makeAOtherGroup(fs, out, subexpander, options, subitems, sub);
}
}
return out;
}
use of org.collectionspace.chain.csp.schema.Field in project application by collectionspace.
the class ServicesXsd method generateDataEntry.
private void generateDataEntry(Element ele, FieldSet fs, Namespace ns, Element root, Boolean isRepeat) {
if (fs instanceof Field) {
// <xs:element name="csid" type="xs:string"/>
Element field = ele.addElement(new QName("element", ns));
field.addAttribute("name", fs.getServicesTag());
field.addAttribute("type", "xs:string");
if (isRepeat) {
field.addAttribute("minOccurs", "0");
field.addAttribute("maxOccurs", "unbounded");
}
}
if (fs instanceof Repeat) {
Repeat rfs = (Repeat) fs;
String listName = rfs.getServicesTag();
if (rfs.hasServicesParent()) {
// group repeatable
// <xs:element name="objectNameList" type="ns:objectNameList"/>
Element field = ele.addElement(new QName("element", ns));
field.addAttribute("name", rfs.getServicesParent()[0]);
Namespace groupns = new Namespace("ns", "");
field.addAttribute("type", "ns:" + rfs.getServicesParent()[0]);
} else {
// single repeatable
// <xs:element name="responsibleDepartments"
// type="responsibleDepartmentList"/>
Element field = ele.addElement(new QName("element", ns));
field.addAttribute("name", rfs.getServicesTag());
listName = rfs.getChildren("")[0].getServicesTag() + "List";
field.addAttribute("type", listName);
}
generateRepeat(rfs, root, ns, listName);
}
}
use of org.collectionspace.chain.csp.schema.Field in project application by collectionspace.
the class UISpec method actualRichText.
/**
* Generate UISpec JSON needed by the UI to show a rich text editor
* @param f
* @param context
* @return
* @throws JSONException
*/
private JSONObject actualRichText(FieldSet fs, UISpecRunContext context, JSONArray decorators) throws JSONException {
JSONObject out = new JSONObject();
Field f = (Field) fs;
JSONObject decorator = getDecorator("fluid", null, "cspace.richTextEditor", null, f.isReadOnly());
if (!f.isRefactored()) {
if (f.hasContainer()) {
decorator.put("container", getSelector(f, context));
}
}
if (decorators == null) {
decorators = new JSONArray();
}
decorators.put(decorator);
out.put(DECORATORS_KEY, decorators);
out.put("value", actualFieldEntry(f, context));
return out;
}
use of org.collectionspace.chain.csp.schema.Field in project application by collectionspace.
the class UISpec method actualDate.
/**
* This is a bit of JSON needed by the UI so they display dates in the UIspec
* @param f
* @param context
* @return
* @throws JSONException
*/
private JSONObject actualDate(FieldSet fs, UISpecRunContext context, JSONArray decorators) throws JSONException {
JSONObject out = new JSONObject();
Field f = (Field) fs;
JSONObject decorator = getDecorator("fluid", null, "cspace.datePicker", null, f.isReadOnly());
if (!f.isRefactored()) {
if (f.hasContainer()) {
decorator.put("container", getSelector(f, context));
}
}
if (decorators == null) {
decorators = new JSONArray();
}
decorators.put(decorator);
out.put(DECORATORS_KEY, decorators);
out.put("value", actualFieldEntry(f, context));
return out;
}
use of org.collectionspace.chain.csp.schema.Field in project application by collectionspace.
the class UISpec method actualRepeatNonSiblingEntry.
/**
* Overwrite with the output you need for the thing you are doing.
* @param out
* @param r
* @param context
* @param preProtoTree
* @throws JSONException
*/
@Override
protected void actualRepeatNonSiblingEntry(JSONObject out, Repeat r, UISpecRunContext context, JSONObject preProtoTree) throws JSONException {
JSONArray decorators = new JSONArray();
JSONObject content = new JSONObject();
JSONObject options = new JSONObject();
JSONObject expander = new JSONObject();
expander.put("type", "fluid.noexpand");
expander.put("tree", preProtoTree);
JSONObject repeatTree = new JSONObject();
repeatTree.put("expander", expander);
if (r.getParent() instanceof Record) {
options.put("elPath", displayAsveryplainWithoutEnclosure(r, context));
} else {
options.put("elPath", r.getID());
options.put("root", "{row}");
}
options.put("repeatTree", repeatTree);
// is this a uispec for search - if so no primary tags wanted
if (r.getSearchType().startsWith("repeator") && this.spectype.equals("search")) {
options.put("hidePrimary", true);
}
JSONObject decorator = getDecorator("fluid", null, "cspace.makeRepeatable", options, r.isReadOnly());
decorators.put(decorator);
content.put(DECORATORS_KEY, decorators);
String selector = getSelector(r, context);
// CSPACE-2619 scalar repeatables are different from group repeats
if (r.getChildren("").length == 1) {
FieldSet child = getFirstChild(r);
if (child instanceof Field || child instanceof Group) {
selector = getSelector(child, context);
}
}
if (r.isExpander()) {
JSONArray expanders = out.getJSONArray("expander");
makeExpander(out, expanders);
} else {
out.put(selector, content);
}
}
Aggregations