use of org.collectionspace.chain.csp.schema.UISpecRunContext in project application by collectionspace.
the class UISchema method uirecordschema.
/**
* Create the generic UI record schemas
* @param storage
* @param record
* @return
* @throws UIException
*/
private JSONObject uirecordschema(Storage storage, Record record) throws UIException {
UISpecRunContext context = new UISpecRunContext();
this.storage = storage;
this.record = record;
this.tenantname = this.record.getSpec().getAdminData().getTenantName();
try {
JSONObject out = new JSONObject();
JSONObject details = new JSONObject();
JSONObject properties = new JSONObject();
if (record.hasTermsUsed()) {
properties.put("termsUsed", actualSchemaTermsUsed(context));
}
if (record.hasRefObjUsed()) {
properties.put("relations", actualSchemaRelations());
}
JSONObject fields = actualSchemaFields(record, context);
JSONObject prop = fields.getJSONObject("properties");
if (record.hasHierarchyUsed("screen")) {
JSONObject temp = actualSchemaFields(record.getSpec().getRecord("hierarchy"), context);
JSONObject prop2 = temp.getJSONObject("properties");
Iterator<?> rit = prop2.keys();
while (rit.hasNext()) {
String key = (String) rit.next();
Object value = prop2.get(key);
prop.put(key, value);
}
}
fields.put("properties", prop);
properties.put("fields", fields);
JSONObject output = new JSONObject();
actualSchemaObject("string", null, null, null, output);
properties.put("csid", output);
actualSchemaObject("object", null, properties, null, details);
out.put(record.getWebURL(), details);
return out;
} catch (JSONException e) {
throw new UIException("Cannot generate UISpec due to JSONException", e);
}
}
Aggregations