use of org.activityinfo.model.resource.ResourceId 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;
}
use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.
the class SimpleConditionParser method parseBinary.
private static SimpleCondition parseBinary(FunctionCallNode call) {
ResourceId fieldId = parseFieldId(call.getArgument(0));
SimpleOperator op = parseOp(call.getFunction());
FieldValue fieldValue = parseFieldValue(call.getArgument(1));
return new SimpleCondition(fieldId, op, fieldValue);
}
use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.
the class SimpleConditionParser method parseEnumCondition.
private static SimpleCondition parseEnumCondition(CompoundExpr node) {
ResourceId fieldId = parseFieldId(node.getValue());
ResourceId enumItem = node.getField().asResourceId();
return new SimpleCondition(fieldId, SimpleOperator.INCLUDES, new EnumValue(enumItem));
}
use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.
the class GcsBlobFieldStorageService method put.
public void put(AuthenticatedUser user, String contentDisposition, String mimeType, BlobId blobId, ResourceId formId, InputStream inputStream) throws IOException {
ResourceId userId = CuidAdapter.userId(user.getUserId());
assertNotAnonymousUser(user);
if (!hasAccessToResource(userId, formId)) {
throw new WebApplicationException(UNAUTHORIZED);
}
GcsFileOptions gcsFileOptions = new Builder().contentDisposition(contentDisposition).mimeType(mimeType).addUserMetadata(GcsUploadCredentialBuilder.X_CREATOR, userId.asString()).addUserMetadata(GcsUploadCredentialBuilder.X_OWNER, formId.asString()).build();
GcsOutputChannel channel = GcsServiceFactory.createGcsService().createOrReplace(new GcsFilename(bucketName, blobId.asString()), gcsFileOptions);
try (OutputStream outputStream = Channels.newOutputStream(channel)) {
IOUtils.copy(inputStream, outputStream);
}
}
use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.
the class QueryFilter method siteIdField.
private String siteIdField(FormTree formTree) {
Preconditions.checkNotNull(formTree, "formTree");
Preconditions.checkNotNull(formTree.getRootFormClass(), "formTree.rootFormClass");
ResourceId rootFormClassId = formTree.getRootFormId();
if (rootFormClassId.getDomain() == CuidAdapter.ACTIVITY_DOMAIN) {
// Root form class is the site, we need to compare against the ID
return ColumnModel.ID_SYMBOL;
} else {
// ROot form class is monhtly report, filter against the site id
return CuidAdapter.field(rootFormClassId, CuidAdapter.SITE_FIELD).asString();
}
}
Aggregations