use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class AttachmentType method parseJsonValue.
@Override
public AttachmentValue parseJsonValue(JsonValue value) {
if (value.isJsonObject()) {
value = value.get("values");
}
AttachmentValue fieldValue = new AttachmentValue();
JsonValue array = value;
for (JsonValue attachmentItem : array.values()) {
JsonValue attachmentObject = (JsonValue) attachmentItem;
String mimeType = attachmentObject.get("mimeType").asString();
String filename = attachmentObject.get("filename").asString();
String blobId = attachmentObject.get("blobId").asString();
Attachment attachment = new Attachment(mimeType, filename, blobId);
attachment.setWidth(attachmentObject.get("width").asInt());
attachment.setHeight(attachmentObject.get("height").asInt());
fieldValue.getValues().add(attachment);
}
return fieldValue;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class AttachmentType method getParametersAsJson.
@Override
public JsonValue getParametersAsJson() {
JsonValue object = createObject();
object.put("cardinality", cardinality.name().toLowerCase());
object.put("kind", kind.name().toLowerCase());
return object;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class AttachmentValue method fromJson.
public static AttachmentValue fromJson(String json) {
org.activityinfo.json.JsonParser jsonParser = new org.activityinfo.json.JsonParser();
JsonValue array;
JsonValue root = jsonParser.parse(json);
if (root.isJsonObject()) {
array = root.get("values");
} else {
array = root;
}
List<Attachment> list = new ArrayList<>();
for (JsonValue value : array.values()) {
list.add(Attachment.fromJson(value));
}
return new AttachmentValue(list);
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class QueryModel method toJson.
@Override
public JsonValue toJson() {
JsonValue object = createObject();
object.put("rowSources", Json.toJson(rowSources));
object.put("columns", Json.toJson(columns));
if (filter != null) {
object.put("filter", filter.asExpression());
}
return object;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class QueryModel method fromJson.
public static QueryModel fromJson(JsonValue jsonObject) {
QueryModel queryModel = new QueryModel();
JsonValue rowSources = jsonObject.get("rowSources");
for (JsonValue rowSource : rowSources.values()) {
queryModel.getRowSources().add(RowSource.fromJson(rowSource));
}
for (JsonValue column : jsonObject.get("columns").values()) {
queryModel.getColumns().add(ColumnModel.fromJson(column));
}
String filter = jsonObject.getString("filter");
if (!Strings.isNullOrEmpty(filter)) {
queryModel.setFilter(filter);
}
return queryModel;
}
Aggregations