protected void setupVisibility() { Constraint item = getItem(); asList(groovyScript, groovyScriptLabel) .forEach(component -> component.setVisible(item.getCheckType().memory())); asList(joinClause, joinClauseLabel, whereClause, whereClauseLabel) .forEach(component -> component.setVisible(item.getCheckType().database() && item.getOperationType() != ConstraintOperationType.CREATE && item.getOperationType() != ConstraintOperationType.DELETE && item.getOperationType() != ConstraintOperationType.UPDATE)); asList(code, codeLabel) .forEach(component -> component.setVisible(item.getOperationType() == ConstraintOperationType.CUSTOM)); if (item.getOperationType() != ConstraintOperationType.ALL && item.getOperationType() != ConstraintOperationType.CUSTOM && item.getOperationType() != ConstraintOperationType.READ) { item.setCheckType(ConstraintCheckType.MEMORY); type.setEnabled(false); } else { type.setEnabled(true); } if (!item.getCheckType().database()) { item.setJoinClause(null); item.setWhereClause(null); } }
public ConstraintData(Constraint constraint) { this.id = constraint.getId(); this.code = constraint.getCode(); this.join = constraint.getJoinClause(); this.whereClause = constraint.getWhereClause(); this.groovyScript = constraint.getGroovyScript(); this.operationType = constraint.getOperationType(); this.checkType = constraint.getCheckType(); }
params.put("conditions", conditionsTree); params.put("useShortConditionForm", true); params.put("hideDynamicAttributes", constraint.getCheckType() != ConstraintCheckType.DATABASE); params.put("hideCustomConditions", constraint.getCheckType() != ConstraintCheckType.DATABASE); if (item.getCheckType().database()) { String jpql = new SecurityJpqlGenerator().generateJpql(filterParser.getRoot()); constraint.setWhereClause(jpql); if (item.getCheckType().memory()) { String groovy = new GroovyGenerator().generateGroovy(filterParser.getRoot()); constraint.setGroovyScript(groovy);
protected Constraint cloneConstraint(Constraint constraint, Group group) { Constraint resultConstraint = metadata.create(Constraint.class); resultConstraint.setEntityName(constraint.getEntityName()); resultConstraint.setCode(constraint.getCode()); resultConstraint.setCheckType(constraint.getCheckType()); resultConstraint.setOperationType(constraint.getOperationType()); resultConstraint.setJoinClause(constraint.getJoinClause()); resultConstraint.setWhereClause(constraint.getWhereClause()); resultConstraint.setGroovyScript(constraint.getGroovyScript()); resultConstraint.setFilterXml(constraint.getFilterXml()); resultConstraint.setIsActive(constraint.getIsActive()); resultConstraint.setGroup(group); return resultConstraint; }