Search in sources :

Example 31 with ResourceId

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;
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) JsonValue(org.activityinfo.json.JsonValue)

Example 32 with ResourceId

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);
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FieldValue(org.activityinfo.model.type.FieldValue)

Example 33 with ResourceId

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));
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) EnumValue(org.activityinfo.model.type.enumerated.EnumValue)

Example 34 with ResourceId

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);
    }
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) Builder(com.google.appengine.tools.cloudstorage.GcsFileOptions.Builder) OutputStream(java.io.OutputStream)

Example 35 with ResourceId

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();
    }
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId)

Aggregations

ResourceId (org.activityinfo.model.resource.ResourceId)198 Test (org.junit.Test)42 FormClass (org.activityinfo.model.form.FormClass)41 FormField (org.activityinfo.model.form.FormField)34 RecordRef (org.activityinfo.model.type.RecordRef)30 JsonValue (org.activityinfo.json.JsonValue)21 FormTree (org.activityinfo.model.formTree.FormTree)18 ReferenceValue (org.activityinfo.model.type.ReferenceValue)17 FieldValue (org.activityinfo.model.type.FieldValue)16 FormInstance (org.activityinfo.model.form.FormInstance)15 HashMap (java.util.HashMap)14 QuantityType (org.activityinfo.model.type.number.QuantityType)13 ColumnSet (org.activityinfo.model.query.ColumnSet)12 QueryModel (org.activityinfo.model.query.QueryModel)12 EnumValue (org.activityinfo.model.type.enumerated.EnumValue)11 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)11 ReferenceType (org.activityinfo.model.type.ReferenceType)10 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)10 FormStorage (org.activityinfo.store.spi.FormStorage)10 ArrayList (java.util.ArrayList)9