final public AssignmentExpression assignmentExpression() throws ParseException { ExpressionItem item = null; ExpressionItem item2 = null; item = expression_leaf(); jj_consume_token(SYM_ASSIGNMENT); item2 = expression_leaf(); {if (true) return new AssignmentExpression((Variable) item, item2);} throw new Error("Missing return statement in function"); }
private static void addGTCodesInWrites(ExpressionItem expressionItem, Set<String> gtCodes) { if (expressionItem instanceof CreateInstanceExpression) { MultipleAssignmentExpression multipleAssignmentExpression = ((CreateInstanceExpression) expressionItem).getAssignment(); for (AssignmentExpression assignmentExpression : multipleAssignmentExpression.getAssignmentExpressions()) { addGTCodesInWrites(assignmentExpression, gtCodes); } } else if (expressionItem instanceof AssignmentExpression) { gtCodes.add(((AssignmentExpression) expressionItem).getVariable().getCode()); } else { throw new RuntimeException("Unknown expression '" + expressionItem.getClass().getName() + "'"); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof GuideAssignmentExpression)) { return false; } GuideAssignmentExpression that = (GuideAssignmentExpression) obj; return assignmentExpression.equals(that.assignmentExpression) && guideId.equals(that.guideId); }
throw new InternalErrorException(new Exception("Element for binary expression " + guideAssignmentExpression + " not found!")); gtCode = guideAssignmentExpression.getAssignmentExpression().getVariable().getCode(); ruleReference = new RuleReference(guideAssignmentExpression.getGuideId(), gtCode); ElementInstance assignmentElementInstance = getElementInstanceByRuleReferenceMap().get(ruleReference); return false; ExpressionItem assignmentExpressionItem = guideAssignmentExpression.getAssignmentExpression().getAssignment(); if (assignmentExpressionItem instanceof ConstantExpression) { ConstantExpression constantExpression = (ConstantExpression) assignmentExpressionItem;
private static void addGTCodesInReads(ExpressionItem expressionItem, Set<String> gtCodes) { if (expressionItem instanceof BinaryExpression) { BinaryExpression binaryExpression = (BinaryExpression) expressionItem; addGTCodesInReads(binaryExpression.getLeft(), gtCodes); addGTCodesInReads(binaryExpression.getRight(), gtCodes); } else if (expressionItem instanceof UnaryExpression) { UnaryExpression unaryExpression = (UnaryExpression) expressionItem; addGTCodesInReads(unaryExpression.getOperand(), gtCodes); } else if (expressionItem instanceof FunctionalExpression) { FunctionalExpression functionalExpression = (FunctionalExpression) expressionItem; for (ExpressionItem expressionItemAux : functionalExpression.getItems()) { addGTCodesInReads(expressionItemAux, gtCodes); } } else if (expressionItem instanceof AssignmentExpression) { AssignmentExpression assignmentExpression = (AssignmentExpression) expressionItem; addGTCodesInReads(assignmentExpression.getAssignment(), gtCodes); } else if (expressionItem instanceof MultipleAssignmentExpression) { MultipleAssignmentExpression multipleAssignmentExpression = (MultipleAssignmentExpression) expressionItem; for (AssignmentExpression assignmentExpression : multipleAssignmentExpression.getAssignmentExpressions()) { addGTCodesInReads(assignmentExpression, gtCodes); } } else if (expressionItem instanceof Variable) { Variable variable = (Variable) expressionItem; gtCodes.add(variable.getCode()); } else if (expressionItem instanceof ConstantExpression) { //Do nothing } else { throw new RuntimeException("Unkown expression '" + expressionItem.getClass().getName() + "'"); } }
@Override public int hashCode() { int result = guideId.hashCode(); result = 31 * result + assignmentExpression.hashCode(); return result; }
protected void processAssignmentExpression( RuleLineCollection ruleLines, AssignmentExpression assignmentExpression) { String gtCode = assignmentExpression.getVariable().getCode(); ExpressionItem expressionItemAux = assignmentExpression.getAssignment(); String attribute = assignmentExpression.getVariable().getAttribute(); GTCodeRuleLineElement gtCodeRuleLineElement = gtCodeElementMap.get(gtCode).getGTCodeRuleLineElement();
private void addSimpleConditionsFromExpressionItems(ExpressionItem expressionItem, Collection<BinaryExpression> simpleConditionsExpressionItems) { if (expressionItem instanceof BinaryExpression) { BinaryExpression binaryExpression = (BinaryExpression) expressionItem; if (OperatorKind.AND.equals(binaryExpression.getOperator()) || OperatorKind.OR.equals(binaryExpression.getOperator())) { addSimpleConditionsFromExpressionItems(binaryExpression.getLeft(), simpleConditionsExpressionItems); addSimpleConditionsFromExpressionItems(binaryExpression.getRight(), simpleConditionsExpressionItems); return; } else { if (isArithmeticOperator(binaryExpression.getOperator())) { addSimpleConditionsFromComplexExpressions(binaryExpression.getLeft(), simpleConditionsExpressionItems); addSimpleConditionsFromComplexExpressions(binaryExpression.getRight(), simpleConditionsExpressionItems); } if (!(binaryExpression.getLeft() instanceof Variable) || !(binaryExpression.getRight() instanceof ConstantExpression)) { return; //Skip conditions that are not like format 'variable op constant' } } simpleConditionsExpressionItems.add(binaryExpression); } else if (expressionItem instanceof AssignmentExpression) { AssignmentExpression assignmentExpression = (AssignmentExpression) expressionItem; addSimpleConditionsFromExpressionItems(assignmentExpression.getAssignment(), simpleConditionsExpressionItems); } }
public AssignmentExpression toAssignmentExpression() throws IllegalStateException { if (archetypeElementRuleLineElement.getValue() == null) { throw new IllegalStateException("No variable set"); } Variable var = new Variable( archetypeElementRuleLineElement.getValue().getValue(), null, null, OpenEHRConst.NULL_FLAVOR_ATTRIBUTE); DvCodedText nullValue = nullValueRuleLineElement.getValue(); if (nullValue == null) { throw new IllegalStateException("No null value set"); } String dataValueStr = nullValue.toString(); LoggerFactory.getLogger(SetElementAttributeActionRuleLine.class).debug("dataValueStr: " + dataValueStr); return new AssignmentExpression( var, new ConstantExpression(dataValueStr)); } }
private void addExpressionNodes(String guideId, ExpressionItem currentExpressionItem, GraphNode graphNode) throws InternalErrorException { if (currentExpressionItem instanceof BinaryExpression) { BinaryExpression binaryExpression = (BinaryExpression) currentExpressionItem; if (OperatorKind.OR.equals(binaryExpression.getOperator()) || OperatorKind.AND.equals(binaryExpression.getOperator())) { addExpressionNodes(guideId, binaryExpression.getLeft(), graphNode); addExpressionNodes(guideId, binaryExpression.getRight(), graphNode); return; } else if (isArithmeticOperator(binaryExpression.getOperator())) { addSimpleConditionsFromComplexExpressions(guideId, binaryExpression.getLeft(), graphNode); addSimpleConditionsFromComplexExpressions(guideId, binaryExpression.getRight(), graphNode); } } else if (currentExpressionItem instanceof AssignmentExpression) { AssignmentExpression assignmentExpression = (AssignmentExpression) currentExpressionItem; addExpressionNodes(guideId, assignmentExpression.getAssignment(), graphNode); } addExpressionToNode(guideId, currentExpressionItem, graphNode); }
private Map<String, Collection<GuideAssignmentExpression>> generateAllAssignmentsByElementIdMap() { Map<String, Collection<GuideAssignmentExpression>> allAssignmentsByElementId = new HashMap<>(); for (Guide guide : guideMap.values()) { if (guide.getDefinition() != null) { for (Rule rule : guide.getDefinition().getRules().values()) { Collection<AssignmentExpression> simpleAssignmentsFromExpressionItems = getSimpleAssignmentsFromExpressionItems(rule.getThenStatements()); for (AssignmentExpression assignmentExpression : simpleAssignmentsFromExpressionItems) { Variable variable = assignmentExpression.getVariable(); RuleReference ruleReference = new RuleReference(guide.getId(), variable.getCode()); ElementInstance elementInstance = getElementInstanceByRuleReferenceMap().get(ruleReference); if (elementInstance == null) { logger.warn("ElementInstance not found for " + ruleReference); } else { Collection<GuideAssignmentExpression> guideAssignmentExpression = allAssignmentsByElementId.computeIfAbsent(elementInstance.getId(), k -> new ArrayList<>()); guideAssignmentExpression.add(new GuideAssignmentExpression(guide.getId(), assignmentExpression)); } } } } } return allAssignmentsByElementId; }
public AssignmentExpression toAssignmentExpression() throws IllegalStateException { if (archetypeElementAttributeRuleLineElement.getValue() == null || archetypeElementAttributeRuleLineElement.getValue().getValue() == null) { throw new IllegalStateException("No variable set"); } Variable var = new Variable( archetypeElementAttributeRuleLineElement.getValue().getValue().getValue(), null, null, archetypeElementAttributeRuleLineElement.getAttribute()); return new AssignmentExpression( var, expressionRuleLineElement.getValue()); }
public AssignmentExpression toAssignmentExpression() throws IllegalStateException { ArchetypeElementVO archetypeElementVO = getArchetypeElementRuleLineElement().getArchetypeElementVO(); if (archetypeElementVO == null) { log.debug("No variable set on assignment expression"); return null; } String name = getArchetypeManager().getArchetypeElements().getText(archetypeElementVO, getLanguage()); Variable var = new Variable( archetypeElementRuleLineElement.getValue().getValue(), null, name); DataValue dataValue = archetypeDataValueRuleLineElement.getValue(); ConstantExpression constantExpression; if (dataValue != null) { constantExpression = DVUtil.convertToExpression(dataValue); } else { log.debug("No data value set"); return null; } return new AssignmentExpression( var, constantExpression); } }
public AssignmentExpression toAssignmentExpression() throws IllegalStateException { ArchetypeElementVO archetypeElementVO = getArchetypeElementRuleLineElement().getArchetypeElementVO(); if (archetypeElementVO == null) { throw new IllegalStateException("No variable set"); } String name = getArchetypeManager().getArchetypeElements().getText(archetypeElementVO, getLanguage()); Variable var = new Variable( archetypeElementRuleLineElement.getValue().getValue(), null, name); ArchetypeElementVO archetypeElementVO2 = getSecondArchetypeElementRuleLineElement().getArchetypeElementVO(); if (archetypeElementVO2 == null) { throw new IllegalStateException("No variable to assign set"); } Variable varAux = new Variable( archetypeElementRuleLineElement2.getValue().getValue(), null, name); return new AssignmentExpression(var, varAux);//TODO }
op = OperatorKind.ASSIGNMENT; item2 = expression_leaf(); {if (true) return new AssignmentExpression((Variable) item, item2);} } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {