use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class SchemaStructure method makeASubRecord.
/**
* Do all the real magic to make a sub record thing
*
* @param subr
* @param out
* @param repeated
* @param context
* @param parent
* @throws JSONException
*/
protected void makeASubRecord(Record subr, JSONObject out, Boolean repeated, UISpecRunContext context, JSONObject parent) throws JSONException {
for (FieldSet fs2 : subr.getAllFieldTopLevel("")) {
if (repeated) {
fs2.setRepeatSubRecord(true);
}
whatIsThisFieldSet(out, fs2, context);
fs2.setRepeatSubRecord(false);
}
Structure s = subr.getStructure(this.structureview);
if (s.showMessageKey()) {
makeAllRecordMessageKey(context, parent, subr);
}
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class SchemaStructure method makeARepeatNonSiblingEntry.
/**
* Do all the magic for a Repeat that wants to be rendered like siblings
*
* @param out
* @param r
* @param context
* @throws JSONException
*/
protected void makeARepeatNonSiblingEntry(JSONObject out, Repeat r, UISpecRunContext context) throws JSONException {
if (isExpander(r)) {
actualRepeatExpanderEntry(out, r, context);
} else {
JSONObject preProtoTree = new JSONObject();
if (isARepeatingSubRecord(r)) {
makeASubRecordEntry(preProtoTree, r, context, out);
} else {
for (FieldSet child : r.getChildren("")) {
whatIsThisFieldSet(preProtoTree, child, context);
}
}
actualRepeatNonSiblingEntry(out, r, context, preProtoTree);
}
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class ServicesXsd method serviceschema.
private String serviceschema(Storage s, String path) throws UIException {
if (path != null) {
section = path;
}
Document doc = DocumentFactory.getInstance().createDocument();
Namespace ns = new Namespace("xs", "http://www.w3.org/2001/XMLSchema");
String[] parts = record.getServicesRecordPath(section).split(":", 2);
String[] rootel = parts[1].split(",");
Element root = doc.addElement(new QName("schema", new Namespace("xs", "http://www.w3.org/2001/XMLSchema")));
root.addAttribute("xmlns:ns", rootel[0]);
root.addAttribute("xmlns", rootel[0]);
root.addAttribute("targetNamespace", rootel[0]);
root.addAttribute("version", "0.1");
for (FieldSet fs : record.getAllFieldTopLevel("")) {
generateDataEntry(root, fs, ns, root, false);
}
generateSearchList(root, ns);
return doc.asXML();
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class UISchema method UISchemaRepeatItem.
/**
* UISchema specific idea of a repeatable item
* @param out
* @param r
* @param context
* @throws JSONException
*/
private void UISchemaRepeatItem(JSONObject out, Repeat r, UISpecRunContext context) throws JSONException {
JSONObject items = new JSONObject();
JSONObject structuredate = new JSONObject();
String selector = getSelector(r, context);
JSONObject preProtoTree = new JSONObject();
if (isARepeatingSubRecord(r)) {
makeASubRecordEntry(preProtoTree, r, context, out);
preProtoTree = preProtoTree.getJSONObject(selector).getJSONObject("properties");
} else {
Integer numChild = r.getChildren("").length;
for (FieldSet child : r.getChildren("")) {
whatIsThisFieldSet(preProtoTree, child, context);
if (isAStructureDate(child)) {
Boolean truerepeat = isATrueRepeat(r);
if (!truerepeat) {
structuredate = preProtoTree.getJSONObject(getSelector(child, context)).getJSONObject("properties");
preProtoTree.remove(getSelector(child, context));
Iterator<?> rit = structuredate.keys();
while (rit.hasNext()) {
String key = (String) rit.next();
preProtoTree.put(key, structuredate.get(key));
}
} else if (numChild != 1 && preProtoTree.has("properties")) {
structuredate.put("properties", preProtoTree.getJSONObject("properties"));
if (preProtoTree.has("type")) {
structuredate.put("type", preProtoTree.getString("type"));
preProtoTree.remove("type");
} else {
structuredate.put("type", "object");
}
preProtoTree.remove("properties");
preProtoTree.put(getSelector(child, context), structuredate);
}
}
}
}
// actualRepeatNonSiblingEntry(out, r, context, preProtoTree);//XXX ??? do I need this?
if (preProtoTree.has("properties")) {
preProtoTree = preProtoTree.getJSONObject("properties");
}
if (r.hasPrimary()) {
JSONObject output = new JSONObject();
actualSchemaObject("boolean", true, null, null, output);
preProtoTree.put("_primary", output);
}
actualSchemaObject("object", null, preProtoTree, null, items);
JSONObject output = new JSONObject();
actualSchemaObject("array", null, null, items, output);
out.put(selector, output);
}
use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.
the class UISpec method generateUISpecListSection.
protected JSONObject generateUISpecListSection(Structure s, UISpecRunContext context) throws JSONException {
JSONObject out = new JSONObject();
String id = s.getListSectionName();
if (s.getFieldTopLevel(id) != null) {
FieldSet fs = s.getFieldTopLevel(id);
whatIsThisFieldSet(out, fs, context);
}
return out;
}
Aggregations