Search in sources :

Example 1 with FieldSet

use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.

the class DataGenerator method repeatItem.

/**
 * Data generator specific code for repeats
 * @param out
 * @param r
 * @param context
 * @throws JSONException
 */
private void repeatItem(JSONObject out, Repeat r, UISpecRunContext context) throws JSONException {
    String selector = getSelector(r, context);
    JSONArray arr = new JSONArray();
    for (Integer i = 0; i < repeatnum; i++) {
        repeataffix = i.toString() + " - ";
        JSONObject protoTree = new JSONObject();
        for (FieldSet child : r.getChildren("POST")) {
            whatIsThisFieldSet(protoTree, child, context);
        }
        arr.put(protoTree);
        repeataffix = "";
    }
    out.put(selector, arr);
}
Also used : FieldSet(org.collectionspace.chain.csp.schema.FieldSet) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Example 2 with FieldSet

use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.

the class SchemaStructure method actualSelfRenderer.

/**
 * render the mark up needed by the UISpec for self renderers
 *
 * @param fs
 * @param context
 * @param subexpander
 * @param subitems
 * @param options
 * @throws JSONException
 */
protected void actualSelfRenderer(FieldSet fs, UISpecRunContext context, JSONObject subexpander, Record subitems) throws JSONException {
    Boolean truerepeat = false;
    FieldParent fsp = fs.getParent();
    if (fsp instanceof Repeat && !(fsp instanceof Group)) {
        // remove bogus repeats used in search
        Repeat rp = (Repeat) fsp;
        if (isATrueRepeat(rp)) {
            truerepeat = true;
            for (FieldSet fs2 : subitems.getAllFieldTopLevel("")) {
                whatIsThisFieldSet(subexpander, fs2, context);
            }
            makeAllRecordMessageKey(context, subexpander, subitems);
        }
    }
    if (!truerepeat) {
        for (FieldSet fs2 : subitems.getAllFieldTopLevel("")) {
            whatIsThisFieldSet(subexpander, fs2, context);
        }
        makeAllRecordMessageKey(context, subexpander, subitems);
    }
}
Also used : Group(org.collectionspace.chain.csp.schema.Group) FieldParent(org.collectionspace.chain.csp.schema.FieldParent) FieldSet(org.collectionspace.chain.csp.schema.FieldSet) Repeat(org.collectionspace.chain.csp.schema.Repeat)

Example 3 with FieldSet

use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.

the class SchemaStructure method makeAGroupEntry.

/**
 * Do all the magic to make a Group thing
 *
 * @param out
 * @param fs
 * @param contexts
 * @throws JSONException
 */
protected void makeAGroupEntry(JSONObject out, FieldSet fs, UISpecRunContext context) throws JSONException {
    Group g = (Group) fs;
    JSONObject contents = new JSONObject();
    for (FieldSet child : g.getChildren("")) {
        whatIsThisFieldSet(contents, child, context);
    }
    // make the item
    if (fs.isASelfRenderer()) {
        JSONObject renderedcontents = new JSONObject();
        actualSelfRenderer(renderedcontents, contents);
        contents = renderedcontents;
    } else if (isAGroupField(fs)) {
        contents = makeAGroupField(g, context);
    }
    actualGroupEntry(fs, out, context, contents);
}
Also used : Group(org.collectionspace.chain.csp.schema.Group) FieldSet(org.collectionspace.chain.csp.schema.FieldSet) JSONObject(org.json.JSONObject)

Example 4 with FieldSet

use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.

the class SchemaStructure method makeARepeatSiblingEntry.

/**
 * @param out
 * @param context
 * @param r
 * @param row
 * @param children
 * @throws JSONException
 */
protected void makeARepeatSiblingEntry(JSONObject out, Repeat r, UISpecRunContext context) throws JSONException {
    JSONObject contents = new JSONObject();
    for (FieldSet child : r.getChildren("")) {
        whatIsThisFieldSet(contents, child, context);
    }
    JSONArray children = new JSONArray();
    children.put(contents);
    actualRepeatSiblingEntry(out, r, context, children);
}
Also used : FieldSet(org.collectionspace.chain.csp.schema.FieldSet) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Example 5 with FieldSet

use of org.collectionspace.chain.csp.schema.FieldSet in project application by collectionspace.

the class ServicesXsd method generateSearchList.

@SuppressWarnings("null")
private void generateSearchList(Element root, Namespace ns) {
    Element ele = root.addElement(new QName("complexType", ns));
    ele.addAttribute("name", "abstractCommonList");
    Element aele = ele.addElement(new QName("annotation", ns));
    Element appele = aele.addElement(new QName("appinfo", ns));
    Element jxb = appele.addElement(new QName("class", new Namespace("jaxb", "")));
    jxb.addAttribute("ref", "org.collectionspace.services.jaxb.AbstractCommonList");
    String[] listpath = record.getServicesListPath().split("/");
    Element lele = root.addElement(new QName("element", ns));
    lele.addAttribute("name", listpath[0]);
    Element clele = lele.addElement(new QName("complexType", ns));
    Element cplele = clele.addElement(new QName("complexContent", ns));
    Element exlele = cplele.addElement(new QName("extension", ns));
    exlele.addAttribute("base", "abstractCommmonList");
    Element sexlele = exlele.addElement(new QName("sequence", ns));
    Element slele = sexlele.addElement(new QName("element", ns));
    slele.addAttribute("name", listpath[1]);
    slele.addAttribute("maxOccurs", "unbounded");
    Element cslele = slele.addElement(new QName("complexType", ns));
    Element scslele = cslele.addElement(new QName("sequence", ns));
    Set<String> searchflds = new HashSet();
    for (String minis : record.getAllMiniDataSets()) {
        if (minis != null && !minis.equals("")) {
            for (FieldSet flds : record.getMiniDataSetByName(minis)) {
                searchflds.add(flds.getServicesTag());
                log.info(flds.getServicesTag());
            }
        }
    }
    Iterator iter = searchflds.iterator();
    while (iter.hasNext()) {
        Element sfld = scslele.addElement(new QName("element", ns));
        sfld.addAttribute("name", (String) iter.next());
        sfld.addAttribute("type", "xs:string");
        sfld.addAttribute("minOccurs", "1");
    }
    /*standard fields */
    Element stfld1 = scslele.addElement(new QName("element", ns));
    stfld1.addAttribute("name", "uri");
    stfld1.addAttribute("type", "xs:string");
    stfld1.addAttribute("minOccurs", "1");
    Element stfld2 = scslele.addElement(new QName("element", ns));
    stfld2.addAttribute("name", "csid");
    stfld2.addAttribute("type", "xs:string");
    stfld2.addAttribute("minOccurs", "1");
}
Also used : FieldSet(org.collectionspace.chain.csp.schema.FieldSet) QName(org.dom4j.QName) Element(org.dom4j.Element) Iterator(java.util.Iterator) Namespace(org.dom4j.Namespace) HashSet(java.util.HashSet)

Aggregations

FieldSet (org.collectionspace.chain.csp.schema.FieldSet)62 JSONObject (org.json.JSONObject)36 Record (org.collectionspace.chain.csp.schema.Record)23 Field (org.collectionspace.chain.csp.schema.Field)22 JSONArray (org.json.JSONArray)22 Element (org.dom4j.Element)19 Group (org.collectionspace.chain.csp.schema.Group)17 UnderlyingStorageException (org.collectionspace.csp.api.persistence.UnderlyingStorageException)17 JSONException (org.json.JSONException)13 Repeat (org.collectionspace.chain.csp.schema.Repeat)11 Document (org.dom4j.Document)11 QName (org.dom4j.QName)11 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)10 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)9 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 ArrayList (java.util.ArrayList)6 UnimplementedException (org.collectionspace.csp.api.persistence.UnimplementedException)6 TenantSpec (org.collectionspace.chain.csp.persistence.services.TenantSpec)5 Spec (org.collectionspace.chain.csp.schema.Spec)5