protected void processCriteria(List<Criterion> criteria, String type, CmmnModel model, ArrayNode elementArray) { for (Criterion criterion : criteria) { ObjectNode criterionNode = objectMapper.createObjectNode(); criterionNode.put("id", criterion.getId()); criterionNode.put("name", criterion.getName()); criterionNode.put("type", type); GraphicInfo criterionGraphicInfo = model.getGraphicInfo(criterion.getId()); if (criterionGraphicInfo != null) { fillGraphicInfo(criterionNode, criterionGraphicInfo, true); } elementArray.add(criterionNode); } }
protected void processCriteria(List<Criterion> criteria, String type, CmmnModel model, ArrayNode elementArray) { for (Criterion criterion : criteria) { ObjectNode criterionNode = objectMapper.createObjectNode(); criterionNode.put("id", criterion.getId()); criterionNode.put("name", criterion.getName()); criterionNode.put("type", type); GraphicInfo criterionGraphicInfo = model.getGraphicInfo(criterion.getId()); if (criterionGraphicInfo != null) { fillGraphicInfo(criterionNode, criterionGraphicInfo, true); } elementArray.add(criterionNode); } }
public static void writeCriteriaElements(String criteriaElementLabel, List<Criterion> criterionList, XMLStreamWriter xtw) throws Exception { for (Criterion criterion : criterionList) { // start entry criterion element xtw.writeStartElement(criteriaElementLabel); xtw.writeAttribute(ATTRIBUTE_ID, criterion.getId()); if (StringUtils.isNotEmpty(criterion.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, criterion.getName()); } if (StringUtils.isNotEmpty(criterion.getSentryRef())) { xtw.writeAttribute(ATTRIBUTE_SENTRY_REF, criterion.getSentryRef()); } // end entry criterion element xtw.writeEndElement(); } } }
public void addEntryCriterionToCurrentElement(Criterion entryCriterion) { addEntryCriterion(entryCriterion); ListIterator<CmmnElement> iterator = currentCmmnElements.listIterator(currentCmmnElements.size()); HasEntryCriteria hasEntryCriteria = null; while (hasEntryCriteria == null && iterator.hasPrevious()) { CmmnElement cmmnElement = iterator.previous(); if (cmmnElement instanceof HasEntryCriteria) { hasEntryCriteria = (HasEntryCriteria) cmmnElement; } } if (hasEntryCriteria != null) { if (StringUtils.isEmpty(entryCriterion.getId())) { // An id is expected by the evaluation algorithm, so setting an internal one if there isn't one entryCriterion.setId("entryCriterion_" + (hasEntryCriteria.getEntryCriteria().size() + 1)); } entryCriterion.setAttachedToRefId(hasEntryCriteria.getId()); hasEntryCriteria.getEntryCriteria().add(entryCriterion); } else { throw new FlowableException("Cannot add an entry criteria " + entryCriterion.getId() + " no matching plan item found to attach it to"); } }
protected static void writePlanItem(PlanItem planItem, CmmnModel model, XMLStreamWriter xtw) throws Exception { createCmmnShape(model, planItem.getId(), xtw); for (Criterion criterion : planItem.getEntryCriteria()) { createCmmnShape(model, criterion.getId(), xtw); } for (Criterion criterion : planItem.getExitCriteria()) { createCmmnShape(model, criterion.getId(), xtw); } }
public void addExitCriteriaToCurrentElement(Criterion exitCriterion) { addExitCriterion(exitCriterion); ListIterator<CmmnElement> iterator = currentCmmnElements.listIterator(currentCmmnElements.size()); HasExitCriteria hasExitCriteria = null; while (hasExitCriteria == null && iterator.hasPrevious()) { CmmnElement cmmnElement = iterator.previous(); if (cmmnElement instanceof HasExitCriteria) { hasExitCriteria = (HasExitCriteria) cmmnElement; } } if (hasExitCriteria == null) { hasExitCriteria = getCurrentCase().getPlanModel(); } if (StringUtils.isEmpty(exitCriterion.getId())) { // An id is expected by the evaluation algorithm, so setting an internal one if there isn't one exitCriterion.setId("exitCriterion_" + (hasExitCriteria.getExitCriteria().size() + 1)); } exitCriterion.setAttachedToRefId(hasExitCriteria.getId()); hasExitCriteria.getExitCriteria().add(exitCriterion); }
protected static void writePlanModel(Stage stage, CmmnModel model, XMLStreamWriter xtw) throws Exception { createCmmnShape(model, stage.getId(), xtw); for (Criterion criterion : stage.getExitCriteria()) { createCmmnShape(model, criterion.getId(), xtw); } }
public BaseElement convertToCmmnModel(XMLStreamReader xtr, ConversionHelper conversionHelper) { BaseElement baseElement = convert(xtr, conversionHelper); if (baseElement != null) { baseElement.setId(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_ID)); Location location = xtr.getLocation(); baseElement.setXmlRowNumber(location.getLineNumber()); baseElement.setXmlRowNumber(location.getColumnNumber()); if (baseElement instanceof CmmnElement) { CmmnElement cmmnElement = (CmmnElement) baseElement; conversionHelper.setCurrentCmmnElement(cmmnElement); } if (baseElement instanceof Criterion) { Criterion criterion = (Criterion) baseElement; conversionHelper.getCmmnModel().addCriterion(criterion.getId(), criterion); } } return baseElement; }
protected void resolveExitCriteriaSentry(HasExitCriteria hasExitCriteria) { for (Criterion exitCriterion : hasExitCriteria.getExitCriteria()) { Sentry sentry = exitCriterion.getParent().findSentry(exitCriterion.getSentryRef()); if (sentry != null) { exitCriterion.setSentry(sentry); } else { throw new FlowableException("No sentry found for reference " + exitCriterion.getSentryRef() + " of exit criterion " + exitCriterion.getId()); } } }
protected void resolveEntryCriteria(HasEntryCriteria hasEntryCriteria) { for (Criterion entryCriterion : hasEntryCriteria.getEntryCriteria()) { Sentry sentry = entryCriterion.getParent().findSentry(entryCriterion.getSentryRef()); if (sentry != null) { entryCriterion.setSentry(sentry); } else { throw new FlowableException("No sentry found for reference " + entryCriterion.getSentryRef() + " of entry criterion " + entryCriterion.getId()); } } }
protected String evaluateDependentPlanItemEntryCriteria(PlanItem entryDependentPlanItem) { List<Criterion> entryCriteria = entryDependentPlanItem.getEntryCriteria(); if (!entryCriteria.isEmpty()) { for (Criterion criterion : entryCriteria) { // According to the spec, only the sentries that actually reference the planitem of which the event happens should be evaluated if (CriterionUtil.criterionHasOnPartDependingOnPlanItem(criterion, planItemLifeCycleEvent.getPlanItem(), planItemLifeCycleEvent.getTransition())) { boolean criterionSatisfied = true; List<SentryOnPart> onParts = criterion.getSentry().getOnParts(); for (SentryOnPart onPart : onParts) { if (!sentryOnPartMatchesCurrentLifeCycleEvent(onPart)) { criterionSatisfied = false; } } if (criterion.getSentry().getSentryIfPart() != null) { if (!evaluateSentryIfPart(criterion.getSentry(), caseInstanceEntity)) { // Resolved against case entity as there's no plan item instance yet criterionSatisfied = false; } } if (criterionSatisfied) { return criterion.getId(); } } } } return null; }