Search in sources :

Example 11 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class AdminDimBinding method extractCategories.

@Override
public DimensionCategory[] extractCategories(Activity activity, ColumnSet columnSet) {
    DimensionCategory[] c = new DimensionCategory[columnSet.getNumRows()];
    if (columnSet.getColumns().containsKey(labelColumn)) {
        ColumnView idView = columnSet.getColumnView(idColumn);
        ColumnView labelView = columnSet.getColumnView(labelColumn);
        for (int i = 0; i < columnSet.getNumRows(); i++) {
            String id = idView.getString(i);
            if (id != null) {
                int entityId = getLegacyIdFromCuid(id);
                String label = labelView.getString(i);
                c[i] = new EntityCategory(entityId, label);
            }
        }
    }
    return c;
}
Also used : DimensionCategory(org.activityinfo.legacy.shared.reports.content.DimensionCategory) ColumnView(org.activityinfo.model.query.ColumnView) EntityCategory(org.activityinfo.legacy.shared.reports.content.EntityCategory)

Example 12 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class ProjectDimBinding method extractFieldData.

@Override
public BaseModelData[] extractFieldData(BaseModelData[] dataArray, ColumnSet columnSet) {
    ColumnView id = columnSet.getColumnView(PROJECT_ID_COLUMN);
    ColumnView label = columnSet.getColumnView(PROJECT_LABEL_COLUMN);
    for (int i = 0; i < columnSet.getNumRows(); i++) {
        String projectId = id.getString(i);
        String projectLabel = Strings.nullToEmpty(label.getString(i));
        if (projectId != null && !Strings.isNullOrEmpty(projectLabel)) {
            ProjectDTO project = new ProjectDTO(CuidAdapter.getLegacyIdFromCuid(projectId), projectLabel);
            dataArray[i].set(PROJECT_FIELD, project);
        }
    }
    return dataArray;
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ColumnView(org.activityinfo.model.query.ColumnView)

Example 13 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class SiteDimBinding method extractCategories.

@Override
public DimensionCategory[] extractCategories(Activity activity, ColumnSet columnSet) {
    ColumnView id = columnSet.getColumnView(ID_COLUMN);
    ColumnView label = columnSet.getColumnView(LABEL_COLUMN);
    int numRows = columnSet.getNumRows();
    DimensionCategory[] categories = new DimensionCategory[numRows];
    for (int i = 0; i < numRows; i++) {
        String idString = id.getString(i);
        String labelString = label.getString(i);
        // Note that we try to gracefully handle an empty location label because not all forms
        // will have a location in the new data model
        // Legacy activities with "nullary" location types, when represented in the new data model,
        // have *no* location field, so we just have to treat it as a blank.
        categories[i] = new EntityCategory(CuidAdapter.getLegacyIdFromCuid(idString), Strings.nullToEmpty(labelString));
    }
    return categories;
}
Also used : DimensionCategory(org.activityinfo.legacy.shared.reports.content.DimensionCategory) ColumnView(org.activityinfo.model.query.ColumnView) EntityCategory(org.activityinfo.legacy.shared.reports.content.EntityCategory)

Example 14 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class SiteDimBinding method extractFieldData.

@Override
public BaseModelData[] extractFieldData(BaseModelData[] dataArray, ColumnSet columnSet) {
    ColumnView id = columnSet.getColumnView(ID_COLUMN);
    ColumnView label = columnSet.getColumnView(LABEL_COLUMN);
    for (int i = 0; i < columnSet.getNumRows(); i++) {
        dataArray[i].set(ID_FIELD, CuidAdapter.getLegacyIdFromCuid(id.getString(i)));
        dataArray[i].set(NAME_FIELD, Strings.nullToEmpty(label.getString(i)));
    }
    return dataArray;
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView)

Example 15 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class GeoAreaFieldBinding method extractFieldData.

@Override
public AdminEntityDTO[] extractFieldData(AdminEntityDTO[] dataArray, ColumnSet columnSet) {
    ColumnView xmin = columnSet.getColumnView(XMIN_COLUMN.asExpression());
    ColumnView xmax = columnSet.getColumnView(XMAX_COLUMN.asExpression());
    ColumnView ymin = columnSet.getColumnView(YMIN_COLUMN.asExpression());
    ColumnView ymax = columnSet.getColumnView(YMAX_COLUMN.asExpression());
    for (int i = 0; i < columnSet.getNumRows(); i++) {
        if (allDefinedForRow(xmin, xmax, ymin, ymax, i)) {
            Extents bounds = Extents.create(xmin.getDouble(i), ymin.getDouble(i), xmax.getDouble(i), ymax.getDouble(i));
            dataArray[i].setBounds(bounds);
        }
    }
    return dataArray;
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) Extents(org.activityinfo.model.type.geo.Extents)

Aggregations

ColumnView (org.activityinfo.model.query.ColumnView)67 ColumnSet (org.activityinfo.model.query.ColumnSet)22 Test (org.junit.Test)22 QueryModel (org.activityinfo.model.query.QueryModel)21 ColumnSetBuilder (org.activityinfo.store.query.server.ColumnSetBuilder)8 ResourceId (org.activityinfo.model.resource.ResourceId)7 NullFormSupervisor (org.activityinfo.store.query.shared.NullFormSupervisor)7 DoubleArrayColumnView (org.activityinfo.model.query.DoubleArrayColumnView)6 NullFormScanCache (org.activityinfo.store.query.shared.NullFormScanCache)6 DimensionCategory (org.activityinfo.legacy.shared.reports.content.DimensionCategory)5 FormClass (org.activityinfo.model.form.FormClass)5 FormTree (org.activityinfo.model.formTree.FormTree)5 FormulaNode (org.activityinfo.model.formula.FormulaNode)4 Nullable (javax.annotation.Nullable)3 FormulaSyntaxException (org.activityinfo.model.formula.diagnostic.FormulaSyntaxException)3 ColumnModel (org.activityinfo.model.query.ColumnModel)3 RecordRef (org.activityinfo.model.type.RecordRef)3 PrintWriter (java.io.PrintWriter)2 HashSet (java.util.HashSet)2 EntityCategory (org.activityinfo.legacy.shared.reports.content.EntityCategory)2