Search in sources :

Example 81 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class AttributeValueTableUpdater method add.

public void add(FieldValue value) {
    EnumValue enumValue = (EnumValue) value;
    if (enumValue != null) {
        for (ResourceId resourceId : enumValue.getResourceIds()) {
            Preconditions.checkArgument(resourceId.getDomain() == CuidAdapter.ATTRIBUTE_DOMAIN);
            int attributeId = CuidAdapter.getLegacyIdFromCuid(resourceId);
            attributesToSet.add(attributeId);
            attributesToClear.remove(attributeId);
        }
    }
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) EnumValue(org.activityinfo.model.type.enumerated.EnumValue)

Example 82 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class MySqlUpdateTest method updateGeometry.

@Test
public void updateGeometry() throws SQLException {
    userId = 3;
    ResourceId formId = CuidAdapter.adminLevelFormClass(1);
    ResourceId recordId = entity(1);
    ResourceId fieldId = CuidAdapter.field(formId, CuidAdapter.GEOMETRY_FIELD);
    Optional<FormStorage> storage = catalog.getForm(formId);
    GeometryFactory factory = new GeometryFactory();
    Polygon polygon = new Polygon(new LinearRing(new CoordinateArraySequence(new Coordinate[] { new Coordinate(100, 0), new Coordinate(101, 0), new Coordinate(101, 1), new Coordinate(100, 1), new Coordinate(100, 0) }), factory), new LinearRing[0], factory);
    storage.get().updateGeometry(recordId, fieldId, polygon);
    query(formId, "_id", "ST_XMIN(boundary)", "ST_XMAX(boundary)");
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) FormStorage(org.activityinfo.store.spi.FormStorage) ResourceId(org.activityinfo.model.resource.ResourceId) Coordinate(com.vividsolutions.jts.geom.Coordinate) Polygon(com.vividsolutions.jts.geom.Polygon) LinearRing(com.vividsolutions.jts.geom.LinearRing) CoordinateArraySequence(com.vividsolutions.jts.geom.impl.CoordinateArraySequence) Test(org.junit.Test)

Example 83 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class ColumnSetBuilder method enqueue.

public Slot<ColumnSet> enqueue(QueryModel queryModel, FormScanBatch batch) {
    ResourceId formId = queryModel.getRowSources().get(0).getRootFormId();
    FormTree tree = formTreeBuilder.queryTree(formId);
    if (tree.getRootState() == FormTree.State.VALID) {
        return enqueue(tree, queryModel, batch);
    } else {
        return emptySet(queryModel);
    }
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) ResourceId(org.activityinfo.model.resource.ResourceId)

Example 84 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class AttributeConverter method toParameters.

@Override
public Collection<?> toParameters(FieldValue value) {
    EnumValue enumValue = (EnumValue) value;
    ResourceId enumItemId = enumValue.getValueId();
    Preconditions.checkArgument(enumItemId.getDomain() == CuidAdapter.ATTRIBUTE_DOMAIN);
    return Collections.singleton(CuidAdapter.getLegacyIdFromCuid(enumItemId));
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) EnumValue(org.activityinfo.model.type.enumerated.EnumValue)

Example 85 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class TableViewModel method getEffectiveSubTable.

public Observable<EffectiveTableModel> getEffectiveSubTable(final ResourceId subFormId) {
    Observable<EffectiveTableModel> effectiveSubTable = effectiveSubTables.get(subFormId);
    if (effectiveSubTable == null) {
        final TableModel subModel = ImmutableTableModel.builder().formId(subFormId).build();
        effectiveSubTable = formTree.transform(tree -> tree.subTree(subFormId)).transform(subTree -> new EffectiveTableModel(formStore, subTree, subModel, Optional.of(getSelectedRecordRef())));
        effectiveSubTables.put(subFormId, effectiveSubTable);
    }
    return effectiveSubTable;
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) FormSource(org.activityinfo.store.query.shared.FormSource) ParsedFormula(org.activityinfo.analysis.ParsedFormula) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ResourceId(org.activityinfo.model.resource.ResourceId) TableModel(org.activityinfo.model.analysis.TableModel) Optional(com.google.common.base.Optional) ColumnModel(org.activityinfo.model.query.ColumnModel) Map(java.util.Map) RecordTree(org.activityinfo.model.formTree.RecordTree) RecordRef(org.activityinfo.model.type.RecordRef) Nullable(javax.annotation.Nullable) SymbolNode(org.activityinfo.model.formula.SymbolNode) Function(com.google.common.base.Function) StatefulValue(org.activityinfo.observable.StatefulValue) ImmutableTableModel(org.activityinfo.model.analysis.ImmutableTableModel) TableColumn(org.activityinfo.model.analysis.TableColumn) Logger(java.util.logging.Logger) FormulaNode(org.activityinfo.model.formula.FormulaNode) List(java.util.List) ColumnSet(org.activityinfo.model.query.ColumnSet) Observable(org.activityinfo.observable.Observable) ImmutableTableColumn(org.activityinfo.model.analysis.ImmutableTableColumn) FormTree(org.activityinfo.model.formTree.FormTree) TableModel(org.activityinfo.model.analysis.TableModel) ImmutableTableModel(org.activityinfo.model.analysis.ImmutableTableModel)

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