use of org.openforis.idm.metamodel.BooleanAttributeDefinition in project collect by openforis.
the class BooleanAttributeDefinitionPR method onStartDefinition.
@Override
protected void onStartDefinition() throws XmlParseException, XmlPullParserException, IOException {
super.onStartDefinition();
BooleanAttributeDefinition defn = (BooleanAttributeDefinition) getDefinition();
Boolean affirmativeOnly = getBooleanAttribute(AFFIRMATIVE_ONLY, false);
defn.setAffirmativeOnly(affirmativeOnly == null ? false : affirmativeOnly);
}
use of org.openforis.idm.metamodel.BooleanAttributeDefinition in project collect by openforis.
the class NewMondrianSchemaGenerator method generateLevel.
private Level generateLevel(AttributeDefinition nodeDef) {
DataTable dataTable = rdbSchema.getDataTable(nodeDef.getParentDefinition());
Level level = new Level(determineDimensionName(nodeDef), determineLevelCaption(nodeDef));
level.levelType = "Regular";
if (nodeDef instanceof NumericAttributeDefinition) {
level.type = ((NumericAttributeDefinition) nodeDef).getType() == Type.INTEGER ? INTEGER_DATATYPE : NUMERIC_DATATYPE;
} else if (nodeDef instanceof BooleanAttributeDefinition) {
level.type = BOOLEAN_DATATYPE;
} else if (nodeDef instanceof CodeAttributeDefinition) {
level.type = ((CodeAttributeDefinition) nodeDef).getList().isExternal() ? STRING_DATATYPE : INTEGER_DATATYPE;
} else {
level.type = STRING_DATATYPE;
}
if (nodeDef instanceof CodeAttributeDefinition && !((CodeAttributeDefinition) nodeDef).getList().isExternal()) {
CodeAttributeDefinition codeDef = (CodeAttributeDefinition) nodeDef;
CodeTable codeListTable = rdbSchema.getCodeListTable(codeDef);
level.table = codeListTable.getName();
level.column = codeListTable.getPrimaryKeyConstraint().getPrimaryKeyColumn().getName();
level.nameColumn = CodeListTables.getLabelColumnName(rdbConfig, codeDef.getList(), codeDef.getLevelIndex(), language);
} else if (nodeDef instanceof TaxonAttributeDefinition) {
DataColumn dataColumn = dataTable.getDataColumn(((TaxonAttributeDefinition) nodeDef).getCodeFieldDefinition());
level.column = dataColumn.getName();
} else if (nodeDef.isMultiple()) {
// TODO skip multiple attributes?
level.column = nodeDef.getName();
} else {
DataColumn dataColumn = dataTable.getDataColumn(nodeDef.getMainFieldDefinition());
level.column = dataColumn.getName();
}
return level;
}
use of org.openforis.idm.metamodel.BooleanAttributeDefinition in project collect by openforis.
the class CollectEarthGridTemplateGenerator method getDummyValue.
private String getDummyValue(AttributeDefinition attrDef, Integer ord) {
String attrName = attrDef.getName();
String value;
if (attrDef instanceof NumericAttributeDefinition || attrDef instanceof BooleanAttributeDefinition) {
value = "0";
if (ord != null) {
value = ord + "";
}
} else if (attrDef instanceof DateAttributeDefinition) {
value = "1/1/2000";
} else if (attrDef instanceof CodeAttributeDefinition) {
CodeListItem firstAvailableItem = getFirstAvailableCodeItem(attrDef);
value = firstAvailableItem == null ? "0" : firstAvailableItem.getCode();
} else {
value = attrName;
if (ord != null) {
value += "_" + ord;
}
}
return value;
}
use of org.openforis.idm.metamodel.BooleanAttributeDefinition in project collect by openforis.
the class RecordUpdater method applyInitialValue.
private Value applyInitialValue(Attribute<?, ?> attr) {
Value value = null;
if (!attr.getDefinition().isCalculated()) {
if (attr.isEmpty() && isDefaultValueToBeApplied(attr)) {
value = performDefaultValueApply(attr);
}
if (attr instanceof BooleanAttribute && ((BooleanAttributeDefinition) attr.getDefinition()).isAffirmativeOnly() && attr.isEmpty()) {
BooleanAttribute boolAttr = (BooleanAttribute) attr;
value = new BooleanValue(false);
boolAttr.setValue((BooleanValue) value);
boolAttr.updateSummaryInfo();
}
}
return value;
}
use of org.openforis.idm.metamodel.BooleanAttributeDefinition in project collect by openforis.
the class NodeDefinitionProxy method fromList.
static List<NodeDefinitionProxy> fromList(EntityDefinitionProxy parent, List<? extends NodeDefinition> list) {
List<NodeDefinitionProxy> proxies = new ArrayList<NodeDefinitionProxy>();
if (list != null) {
for (NodeDefinition n : list) {
NodeDefinitionProxy p = null;
CollectSurvey survey = (CollectSurvey) n.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
boolean hidden = uiOptions.isHidden(n);
if (!hidden) {
if (n instanceof AttributeDefinition) {
if (n instanceof BooleanAttributeDefinition) {
p = new BooleanAttributeDefinitionProxy(parent, (BooleanAttributeDefinition) n);
} else if (n instanceof CodeAttributeDefinition) {
p = new CodeAttributeDefinitionProxy(parent, (CodeAttributeDefinition) n);
} else if (n instanceof CoordinateAttributeDefinition) {
p = new CoordinateAttributeDefinitionProxy(parent, (CoordinateAttributeDefinition) n);
} else if (n instanceof DateAttributeDefinition) {
p = new DateAttributeDefinitionProxy(parent, (DateAttributeDefinition) n);
} else if (n instanceof FileAttributeDefinition) {
p = new FileAttributeDefinitionProxy(parent, (FileAttributeDefinition) n);
} else if (n instanceof NumberAttributeDefinition) {
p = new NumberAttributeDefinitionProxy(parent, (NumberAttributeDefinition) n);
} else if (n instanceof RangeAttributeDefinition) {
p = new RangeAttributeDefinitionProxy(parent, (RangeAttributeDefinition) n);
} else if (n instanceof TaxonAttributeDefinition) {
p = new TaxonAttributeDefinitionProxy(parent, (TaxonAttributeDefinition) n);
} else if (n instanceof TextAttributeDefinition) {
p = new TextAttributeDefinitionProxy(parent, (TextAttributeDefinition) n);
} else if (n instanceof TimeAttributeDefinition) {
p = new TimeAttributeDefinitionProxy(parent, (TimeAttributeDefinition) n);
} else {
throw new RuntimeException("AttributeDefinition not supported: " + n.getClass().getSimpleName());
}
} else if (n instanceof EntityDefinition) {
p = new EntityDefinitionProxy(parent, (EntityDefinition) n);
}
if (p != null) {
proxies.add(p);
}
}
}
}
return proxies;
}
Aggregations