Search in sources :

Example 21 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class FormMetadata method toJson.

@Override
public JsonValue toJson() {
    JsonValue object = createObject();
    object.put("id", id.asString());
    if (!visible) {
        object.put("visible", false);
    }
    if (deleted) {
        object.put("deleted", true);
    }
    if (schema != null) {
        object.put("schema", schema.toJson());
    }
    if (!locks.isEmpty()) {
        object.put("locks", locks.toJson());
    }
    if (visible) {
        object.put("version", version);
        object.put("schemaVersion", schemaVersion);
        object.put("permissions", permissions.toJson());
    }
    return object;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 22 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class CatalogEntry method fromJson.

public static CatalogEntry fromJson(JsonValue jsonElement) {
    JsonValue jsonObject = jsonElement;
    CatalogEntry model = new CatalogEntry();
    model.id = jsonObject.get("id").asString();
    model.type = CatalogEntryType.valueOf(jsonObject.get("type").asString().toUpperCase());
    model.label = jsonObject.get("label").asString();
    model.leaf = jsonObject.getBoolean("leaf");
    return model;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 23 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class ReferenceType method getParametersAsJson.

@Override
public JsonValue getParametersAsJson() {
    JsonValue object = createObject();
    object.put("cardinality", cardinality.name().toLowerCase());
    JsonValue rangeArray = Json.createArray();
    for (ResourceId formId : range) {
        JsonValue rangeObject = createObject();
        rangeObject.put("formId", formId.asString());
        rangeArray.add(rangeObject);
    }
    object.put("range", rangeArray);
    return object;
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) JsonValue(org.activityinfo.json.JsonValue)

Example 24 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class SerialNumber method toJson.

@Override
public JsonValue toJson() {
    if (prefix == null) {
        return Json.create(number);
    } else {
        JsonValue object = createObject();
        object.put("prefix", prefix);
        object.put("number", number);
        return object;
    }
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 25 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class Attachment method toJsonElement.

public JsonValue toJsonElement() {
    JsonValue object = createObject();
    object.put("mimeType", mimeType);
    object.put("width", width);
    object.put("height", height);
    object.put("filename", filename);
    object.put("blobId", blobId);
    return object;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Aggregations

JsonValue (org.activityinfo.json.JsonValue)117 Test (org.junit.Test)24 ResourceId (org.activityinfo.model.resource.ResourceId)19 FormClass (org.activityinfo.model.form.FormClass)13 FormField (org.activityinfo.model.form.FormField)9 FieldValue (org.activityinfo.model.type.FieldValue)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 QuantityType (org.activityinfo.model.type.number.QuantityType)5 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Annotation (java.lang.annotation.Annotation)3 ArrayList (java.util.ArrayList)3 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)3 JaxRsJsonReader (org.activityinfo.server.endpoint.rest.JaxRsJsonReader)3 TypedRecordUpdate (org.activityinfo.store.spi.TypedRecordUpdate)3 EmbeddedEntity (com.google.appengine.api.datastore.EmbeddedEntity)2 URL (java.net.URL)2 JsonException (org.activityinfo.json.JsonException)2 JsonMappingException (org.activityinfo.json.JsonMappingException)2