use of org.activityinfo.model.formula.SymbolNode in project activityinfo by bedatadriven.
the class PartnerDimBinding method getColumnQuery.
private List<ColumnModel> getColumnQuery(ResourceId formId) {
SymbolNode partnerField = new SymbolNode(CuidAdapter.field(formId, CuidAdapter.PARTNER_FIELD));
ColumnModel partnerId = new ColumnModel();
partnerId.setFormula(partnerField);
partnerId.setId(PARTNER_ID_COLUMN);
ColumnModel partnerLabel = new ColumnModel();
partnerLabel.setFormula(new CompoundExpr(partnerField, new SymbolNode("label")));
partnerLabel.setId(PARTNER_LABEL_COLUMN);
return Arrays.asList(partnerId, partnerLabel);
}
use of org.activityinfo.model.formula.SymbolNode in project activityinfo by bedatadriven.
the class ProjectDimBinding method getTargetColumnQuery.
@Override
public List<ColumnModel> getTargetColumnQuery(ResourceId targetFormId) {
SymbolNode projectField = new SymbolNode(CuidAdapter.field(targetFormId, CuidAdapter.PROJECT_FIELD));
ColumnModel projectId = new ColumnModel();
projectId.setFormula(projectField);
projectId.setId(PROJECT_ID_COLUMN);
ColumnModel projectLabel = new ColumnModel();
projectLabel.setFormula(new CompoundExpr(projectField, new SymbolNode("label")));
projectLabel.setId(PROJECT_LABEL_COLUMN);
return Arrays.asList(projectId, projectLabel);
}
use of org.activityinfo.model.formula.SymbolNode in project activityinfo by bedatadriven.
the class NodeMatcherTest method resolve.
private Collection<String> resolve(String exprString) {
FormTree tree = tree();
symbolTable = new NodeMatcher(tree);
FormulaNode expr = FormulaParser.parse(exprString);
Collection<NodeMatch> matches;
if (expr instanceof SymbolNode) {
matches = symbolTable.resolveSymbol((SymbolNode) expr);
} else if (expr instanceof CompoundExpr) {
matches = symbolTable.resolveCompoundExpr((CompoundExpr) expr);
} else {
throw new IllegalArgumentException(exprString);
}
// Create a string that we can match against easily
List<String> strings = Lists.newArrayList();
for (NodeMatch match : matches) {
strings.add(match.toDebugString());
}
System.out.println("Resolved " + exprString + " => " + strings);
return strings;
}
use of org.activityinfo.model.formula.SymbolNode in project activityinfo by bedatadriven.
the class NodeMatch method forEnumItem.
public static NodeMatch forEnumItem(FormTree.Node fieldNode, EnumItem item) {
NodeMatch match = forField(fieldNode, Optional.<StatFunction>absent());
match.fieldExpr = new CompoundExpr(match.fieldExpr, new SymbolNode(item.getId()));
match.enumItem = item;
return match;
}
use of org.activityinfo.model.formula.SymbolNode in project activityinfo by bedatadriven.
the class SiteFormStorage method getPermissions.
@Override
public FormPermissions getPermissions(int userId) {
if (activity.getOwnerUserId() == userId) {
return FormPermissions.owner();
} else {
UserPermission databasePermission = permissionsCache.getPermission(userId, activity.getDatabaseId());
FormPermissions.Builder permissions = FormPermissions.builder();
FormulaNode partnerFilter = Formulas.equals(new SymbolNode(CuidAdapter.partnerField(activity.getId())), new ConstantNode(CuidAdapter.partnerRecordId(databasePermission.getPartnerId()).asString()));
if (databasePermission.isViewAll()) {
permissions.allowView();
} else if (databasePermission.isView()) {
permissions.allowFilteredView(partnerFilter.asExpression());
}
if (databasePermission.isEditAll()) {
permissions.allowEdit();
} else if (databasePermission.isEdit()) {
permissions.allowFilteredEdit(partnerFilter.asExpression());
}
if (databasePermission.isDesign()) {
permissions.allowSchemaUpdate();
}
// published property of activity overrides user permissions
if (activity.isPublished()) {
permissions.allowUnfilteredView();
}
return permissions.build();
}
}
Aggregations