use of org.activityinfo.model.type.RecordFieldType in project activityinfo by bedatadriven.
the class FormTreeBuilder method queryTree.
public FormTree queryTree(ResourceId rootFormId) {
FormTree tree = new FormTree(rootFormId);
FormMetadata root = metadataProvider.getFormMetadata(rootFormId);
if (root.isDeleted()) {
tree.setRootState(FormTree.State.DELETED);
return tree;
}
if (!root.isVisible()) {
tree.setRootState(FormTree.State.FORBIDDEN);
return tree;
}
FormClass rootSchema = root.getSchema();
List<ResourceId> stack = Lists.newArrayList(rootFormId);
Optional<FormField> parentField = rootSchema.getParentField();
if (parentField.isPresent()) {
if (!stack.contains(parentField.get().getId())) {
tree.addFormMetadata(root);
FormTree.Node node = tree.addRootField(root, parentField.get());
fetchChildren(stack, tree, node, rootSchema.getParentFormId().asSet());
}
}
// Add fields defined by this FormClass
for (FormField field : rootSchema.getFields()) {
tree.addFormMetadata(root);
FormTree.Node node = tree.addRootField(root, field);
if (node.isReference()) {
fetchChildren(stack, tree, node, node.getRange());
} else if (field.getType() instanceof RecordFieldType) {
addChildren(stack, tree, node, embeddedForm(node));
}
}
return tree;
}
use of org.activityinfo.model.type.RecordFieldType in project activityinfo by bedatadriven.
the class FormTreeBuilder method embeddedForm.
private FormMetadata embeddedForm(FormTree.Node childNode) {
FormClass embeddedFormSchema = ((RecordFieldType) childNode.getType()).getFormClass();
long formVersion = 1L;
return FormMetadata.of(formVersion, embeddedFormSchema, FormPermissions.readonly());
}
Aggregations