use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class ServicesXsd method generateRepeat.
private void generateRepeat(Repeat r, Element root, Namespace ns, String listName) {
if (r.hasServicesParent()) {
Element sequenced = null;
for (String path : r.getServicesParent()) {
if (path != null) {
if (null != sequenced) {
Element dele = sequenced.addElement(new QName("element", ns));
dele.addAttribute("name", path);
dele.addAttribute("type", path);
dele.addAttribute("minOccurs", "0");
dele.addAttribute("maxOccurs", "unbounded");
}
Element ele = root.addElement(new QName("complexType", ns));
ele.addAttribute("name", path);
sequenced = ele.addElement(new QName("sequence", ns));
}
}
if (sequenced != null) {
Element dele = sequenced.addElement(new QName("element", ns));
dele.addAttribute("name", r.getServicesTag());
dele.addAttribute("type", r.getServicesTag());
dele.addAttribute("minOccurs", "0");
dele.addAttribute("maxOccurs", "unbounded");
}
}
Element ele = root.addElement(new QName("complexType", ns));
ele.addAttribute("name", listName);
Element sele = ele.addElement(new QName("sequence", ns));
for (FieldSet fs : r.getChildren("")) {
generateDataEntry(sele, fs, ns, root, true);
}
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class UISchema method makeAOtherGroup.
@Override
protected void makeAOtherGroup(FieldSet fs, JSONObject out, JSONObject subexpander, JSONObject options, Record subitems, UISpecRunContext sub) throws JSONException {
JSONObject protoTree = new JSONObject();
for (FieldSet fs2 : subitems.getAllFieldTopLevel("")) {
whatIsThisFieldSet(protoTree, fs2, sub);
}
JSONObject output = new JSONObject();
actualSchemaObject("boolean", true, null, null, output);
protoTree.put("_primary", output);
actualSchemaObject("object", null, protoTree, null, out);
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class UISpec method actualHierarchyEntry.
/**
* Create hierarchy specific output for uispec
* @param out
* @param f
* @param context
* @throws JSONException
*/
private void actualHierarchyEntry(JSONObject out, FieldSet f, UISpecRunContext context) throws JSONException {
String condition = "cspace.hierarchy.assertEquivalentContexts";
Record thisr = f.getRecord();
JSONObject cond = new JSONObject();
if (f instanceof Field) {
FieldSet fs = (FieldSet) f.getParent();
JSONObject args = new JSONObject();
args.put(fs.getID(), displayAsveryplain(fs, context));
cond.put("args", args);
cond.put("funcName", condition);
}
JSONObject ttree = new JSONObject();
actualMessageKey(ttree, thisr.getUILabelSelector(f.getID()), f.getLabel());
// This looks wrong - a single decorator is being set as the value of the
// plural decorators key, which usually holds an array of decorators.
// However, it turns out that UI is forgiving, and handles either Object or Array
JSONObject decorator = getDecorator("addClass", "hidden", null, null, f.isReadOnly());
JSONObject decorators = new JSONObject();
decorators.put(DECORATORS_KEY, decorator);
JSONObject ftree = new JSONObject();
ftree.put(thisr.getUILabelSelector(f.getID()), decorators);
JSONObject cexpander = new JSONObject();
cexpander.put("type", "fluid.renderer.condition");
cexpander.put("condition", cond);
cexpander.put("trueTree", ttree);
cexpander.put("falseTree", ftree);
actualTrueTreeSub(out, cexpander);
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class UISpec method actualUploaderEntry.
/**
* Overwrite with the output you need for the thing you are doing.
* @param out
* @param fs
* @param context
* @throws JSONException
*/
@Override
protected void actualUploaderEntry(JSONObject out, FieldSet fs, UISpecRunContext context) throws JSONException {
String condition = "cspace.mediaUploader.assertBlob";
JSONObject cond = new JSONObject();
if (fs instanceof Group) {
Group gp = (Group) fs;
String test = gp.usesRecordValidator();
FieldSet tester = record.getFieldTopLevel(test);
if (tester instanceof Field) {
cond.put("args", displayAsplain((Field) tester, context));
}
cond.put("funcName", condition);
}
JSONObject ttree = new JSONObject();
ttree.put(getSelector(fs, context), new JSONObject());
JSONObject decorator = getDecorator("addClass", "hidden", null, null, fs.isReadOnly());
JSONObject decorators = new JSONObject();
decorators.put(DECORATORS_KEY, decorator);
JSONObject ftree = new JSONObject();
ftree.put(getSelector(fs, context), decorators);
JSONObject cexpander = new JSONObject();
cexpander.put("type", "fluid.renderer.condition");
cexpander.put("condition", cond);
cexpander.put("trueTree", ttree);
cexpander.put("falseTree", ftree);
actualTrueTreeSub(out, cexpander);
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class UISpec method actualRepeatExpanderEntry.
/**
* Overwrite with output you need for this thing you are doing
* @param out
* @param r
* @param context
* @throws JSONException
*/
@Override
protected void actualRepeatExpanderEntry(JSONObject out, Repeat r, UISpecRunContext context) throws JSONException {
JSONArray expanders = new JSONArray();
JSONObject siblingexpander = new JSONObject();
JSONObject expander = new JSONObject();
expander.put("type", "fluid.renderer.repeat");
// "fields."+r.getID());
expander.put("controlledBy", displayAsveryplainWithoutEnclosure(r, context));
expander.put("pathAs", "row");
expander.put("repeatID", getSelector(r, context) + ":");
if (r.getChildren("").length > 0) {
JSONObject tree = new JSONObject();
for (FieldSet child : r.getChildren("")) {
if (!this.spectype.equals("search") || (this.spectype.equals("search") && !child.getSearchType().equals(""))) {
if (child.getUIType().equals("hierarchy")) {
expander.put("repeatID", getSelector(child, context) + ":");
actualHierarchyEntry(siblingexpander, child, context);
expanders.put(siblingexpander.getJSONObject("expander"));
if (child instanceof Field) {
String classes = getDecoratorSelector(child, context);
JSONObject decorator = getDecorator("addClass", classes, null, null, child.isReadOnly());
tree.put("value", actualFieldEntry((Field) child, context));
JSONArray decorators = new JSONArray();
decorators.put(decorator);
decorator = getDecorator("fluid", null, "cspace.externalURL", null, child.isReadOnly());
decorators.put(decorator);
tree.put(DECORATORS_KEY, decorators);
}
} else if (child.getUIType().equals("decorated")) {
expander.put("repeatID", getSelector(child, context) + ":");
if (child instanceof Field) {
String classes = getDecoratorSelector(child, context);
JSONObject decorator = getDecorator("addClass", classes, null, null, child.isReadOnly());
tree.put("value", actualFieldEntry((Field) child, context));
tree.put(DECORATORS_KEY, decorator);
}
} else {
whatIsThisFieldSet(tree, child, context);
}
}
}
if (r.isConditionExpander()) {
expander.put("valueAs", "rowValue");
JSONObject cexpander = new JSONObject();
JSONObject texpander = new JSONObject();
cexpander.put("type", "fluid.renderer.condition");
JSONObject condpander = new JSONObject();
condpander.put("funcName", "cspace.admin.assertRoleDisplay");
condpander.put("args", "{rowValue}.display");
cexpander.put("condition", condpander);
cexpander.put("trueTree", tree);
actualTrueTreeSub(texpander, cexpander);
expander.put("tree", texpander);
} else {
expander.put("tree", tree);
}
}
expanders.put(expander);
makeExpander(out, expanders);
}
Aggregations