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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations