use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class NewDimensionDialog method onForestUpdated.
private void onForestUpdated(Observable<FormForest> forest) {
store.clear();
if (forest.isLoaded()) {
// The Form Name can be a dimension
store.add(new FormNode());
// Add root fields...
for (FormTree.Node node : forest.get().getRootNodes()) {
if (isEligible(node.getType())) {
store.add(new RootFieldNode(node.getDefiningFormClass().getId(), node.getField()));
}
}
// Add reference forms with eligible fields
for (FormClass formClass : forest.get().getReferencedForms()) {
List<DimensionNode> children = new ArrayList<>();
for (FormField field : formClass.getFields()) {
if (isEligible(field.getType())) {
children.add(new ReferencedNode(formClass, field));
}
}
if (!children.isEmpty()) {
ReferenceFormNode refNode = new ReferenceFormNode(formClass, children.get(0));
store.add(refNode);
store.add(refNode, children);
}
}
}
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class LookupKeySetTest method multipleTextKeysTest.
@Test
public void multipleTextKeysTest() {
TestingStorageProvider catalog = setup.getCatalog();
SimpleReferenceForm refForm = catalog.getSimpleReferenceForm();
MultipleTextKeysForm multTextKeyForm = catalog.getMultipleTextKeysForm();
FormField refField = refForm.getRefField();
CompoundExpr pathToKey1 = new CompoundExpr(refField.getId(), MultipleTextKeysForm.FIRST_TEXT_KEY_ID.asString());
CompoundExpr pathToKey2 = new CompoundExpr(refField.getId(), MultipleTextKeysForm.SECOND_TEXT_KEY_ID.asString());
FormTree formTree = catalog.getFormTree(multTextKeyForm.getFormId());
LookupKeySet lookupKeySet = new LookupKeySet(formTree, refField);
Map<LookupKey, FormulaNode> formulas = lookupKeySet.getKeyFormulas(refField.getId());
assertThat(formulas.values(), containsInAnyOrder(pathToKey1, pathToKey2));
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class QueryRunner method addField.
@Override
public void addField(ResourceId fieldId, CursorObserver<FieldValue> observer) {
if (fieldId.asString().equals("@parent")) {
recordObservers.add(new ParentObserver(formClass.getParentFormId().get(), observer));
} else {
FormField field = formClass.getField(fieldId);
FieldObserver fieldObserver = new FieldObserver(field.getName(), field.getType(), observer);
recordObservers.add(fieldObserver);
}
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class SimpleFormPanel method setValue.
public Promise<Void> setValue(FormInstance instance) {
model.setWorkingRootInstance(instance);
List<Promise<Void>> tasks = Lists.newArrayList();
for (FieldContainer container : widgetCreator.getContainers().values()) {
FormField field = container.getField();
FieldValue value = model.getWorkingRootInstance().get(field.getId(), field.getType());
if (value != null && value.getTypeClass() == field.getType().getTypeClass()) {
tasks.add(container.getFieldWidget().setValue(value));
} else {
container.getFieldWidget().clearValue();
}
container.setValid();
}
return Promise.waitAll(tasks).then(new Function<Void, Void>() {
@Override
public Void apply(Void input) {
// invoke relevance handler once values are set
relevanceHandler.onValueChange();
return null;
}
});
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class ColumnMappingPage method collectNotMappedMandatoryColumns.
/**
* @param mandatory if true - then only mandatory, if false then ALL
* @return
*/
public List<ImportTarget> collectNotMappedMandatoryColumns(boolean mandatory) {
List<ImportTarget> list = Lists.newArrayList();
for (final MapExistingAction action : actions) {
final FormField formField = action.getTarget().getFormField();
if (mandatory && !formField.isRequired()) {
continue;
}
final Map<TargetSiteId, ColumnAccessor> mappedColumns = importModel.getMappedColumns(formField.getId());
if (mappedColumns.isEmpty()) {
list.add(action.getTarget());
}
}
return list;
}
Aggregations