Search in sources :

Example 6 with UISpecRunContext

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);
    }
}
Also used : UISpecRunContext(org.collectionspace.chain.csp.schema.UISpecRunContext) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) UIException(org.collectionspace.csp.api.ui.UIException) JSONObject(org.json.JSONObject)

Aggregations

UISpecRunContext (org.collectionspace.chain.csp.schema.UISpecRunContext)6 JSONObject (org.json.JSONObject)5 UIException (org.collectionspace.csp.api.ui.UIException)3 JSONException (org.json.JSONException)3 Record (org.collectionspace.chain.csp.schema.Record)2 Repeat (org.collectionspace.chain.csp.schema.Repeat)2 Field (org.collectionspace.chain.csp.schema.Field)1 Group (org.collectionspace.chain.csp.schema.Group)1 Structure (org.collectionspace.chain.csp.schema.Structure)1