Example usage for javax.xml.stream XMLStreamWriter writeEndElement

List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeEndElement.

Prototype

public void writeEndElement() throws XMLStreamException;

Source Link

Document

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

Usage

From source file:org.flowable.cmmn.converter.export.CriteriaExport.java

public static void writeCriteriaElements(PlanItem planItem, XMLStreamWriter xtw) throws Exception {
    for (Criterion criterion : planItem.getEntryCriteria()) {
        // start entry criterion element
        xtw.writeStartElement(ELEMENT_ENTRY_CRITERION);
        xtw.writeAttribute(ATTRIBUTE_ID, criterion.getId());

        if (StringUtils.isNotEmpty(criterion.getName())) {
            xtw.writeAttribute(ATTRIBUTE_NAME, criterion.getName());
        }//from w w  w . j a  v a 2s.  c om

        if (StringUtils.isNotEmpty(criterion.getSentryRef())) {
            xtw.writeAttribute(ATTRIBUTE_SENTRY_REF, criterion.getSentryRef());
        }

        // end entry criterion element
        xtw.writeEndElement();
    }

    for (Criterion criterion : planItem.getExitCriteria()) {
        // start entry criterion element
        xtw.writeStartElement(ELEMENT_EXIT_CRITERION);
        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();
    }
}

From source file:org.flowable.cmmn.converter.export.DecisionTaskExport.java

public static void writeDecisionTask(DecisionTask decisionTask, XMLStreamWriter xtw) throws Exception {
    // start decision task element
    xtw.writeStartElement(ELEMENT_DECISION_TASK);
    writeCommonTaskAttributes(xtw, decisionTask);

    writeExtensions(decisionTask, xtw);/*from w ww. j  a  v a2 s . c  om*/

    if (StringUtils.isNotEmpty(decisionTask.getDecisionRef())
            || StringUtils.isNotEmpty(decisionTask.getDecisionRefExpression())) {
        xtw.writeStartElement(ELEMENT_DECISION_REF_EXPRESSION);
        xtw.writeCData(StringUtils.isNotEmpty(decisionTask.getDecisionRef()) ? decisionTask.getDecisionRef()
                : decisionTask.getDecisionRefExpression());
        xtw.writeEndElement();
    }

    // end decision task element
    xtw.writeEndElement();
}

From source file:org.flowable.cmmn.converter.export.FieldExport.java

public static boolean writeFieldExtensions(List<FieldExtension> fieldExtensions,
        boolean didWriteExtensionElement, XMLStreamWriter xtw) throws XMLStreamException {
    if (fieldExtensions.size() > 0) {
        if (!didWriteExtensionElement) {
            xtw.writeStartElement(CmmnXmlConstants.ELEMENT_EXTENSION_ELEMENTS);
            didWriteExtensionElement = true;
        }/*from w w  w. j a  v a  2 s . c o  m*/

        for (FieldExtension fieldExtension : fieldExtensions) {
            xtw.writeStartElement(CmmnXmlConstants.FLOWABLE_EXTENSIONS_PREFIX, CmmnXmlConstants.ELEMENT_FIELD,
                    CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE);
            xtw.writeAttribute(CmmnXmlConstants.ATTRIBUTE_NAME, fieldExtension.getFieldName());

            if (StringUtils.isNotEmpty(fieldExtension.getStringValue())) {
                xtw.writeStartElement(CmmnXmlConstants.FLOWABLE_EXTENSIONS_PREFIX,
                        CmmnXmlConstants.ELEMENT_FIELD_STRING, CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE);
                xtw.writeCData(fieldExtension.getStringValue());
            } else {
                xtw.writeStartElement(CmmnXmlConstants.FLOWABLE_EXTENSIONS_PREFIX,
                        CmmnXmlConstants.ATTRIBUTE_FIELD_EXPRESSION,
                        CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE);
                xtw.writeCData(fieldExtension.getExpression());
            }
            xtw.writeEndElement();
            xtw.writeEndElement();
        }
    }

    return didWriteExtensionElement;
}

From source file:org.flowable.cmmn.converter.export.HumanTaskExport.java

public static void writeHumanTask(HumanTask humanTask, XMLStreamWriter xtw) throws Exception {
    // start human task element
    xtw.writeStartElement(ELEMENT_HUMAN_TASK);
    writeCommonTaskAttributes(xtw, humanTask);

    if (StringUtils.isNotEmpty(humanTask.getAssignee())) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_ASSIGNEE,
                humanTask.getAssignee());
    }/*from  w  ww  .  j av a 2s  .  co m*/

    if (StringUtils.isNotEmpty(humanTask.getOwner())) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_OWNER,
                humanTask.getOwner());
    }

    if (humanTask.getCandidateUsers() != null && humanTask.getCandidateUsers().size() > 0) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_CANDIDATE_USERS,
                convertListToCommaSeparatedString(humanTask.getCandidateUsers()));
    }

    if (humanTask.getCandidateGroups() != null && humanTask.getCandidateGroups().size() > 0) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE,
                ATTRIBUTE_CANDIDATE_GROUPS, convertListToCommaSeparatedString(humanTask.getCandidateGroups()));
    }

    if (StringUtils.isNotEmpty(humanTask.getFormKey())) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_FORM_KEY,
                humanTask.getFormKey());
    }

    // end human task element
    xtw.writeEndElement();
}

From source file:org.flowable.cmmn.converter.export.PlanItemControlExport.java

public static void writeItemControl(PlanItemControl planItemControl, XMLStreamWriter xtw) throws Exception {
    xtw.writeStartElement(ELEMENT_ITEM_CONTROL);
    writeItemControlContent(planItemControl, xtw);
    xtw.writeEndElement();
}

From source file:org.flowable.cmmn.converter.export.PlanItemControlExport.java

public static void writeDefaultControl(PlanItemControl planItemControl, XMLStreamWriter xtw) throws Exception {
    xtw.writeStartElement(ELEMENT_DEFAULT_CONTROL);
    writeItemControlContent(planItemControl, xtw);
    xtw.writeEndElement();
}

From source file:org.flowable.cmmn.converter.export.PlanItemControlExport.java

public static void writeRequiredRule(RequiredRule requiredRule, XMLStreamWriter xtw) throws XMLStreamException {
    if (requiredRule != null) {
        xtw.writeStartElement(ELEMENT_REQUIRED_RULE);
        if (StringUtils.isNotEmpty(requiredRule.getCondition())) {
            xtw.writeStartElement(ELEMENT_CONDITION);
            xtw.writeCData(requiredRule.getCondition());
            xtw.writeEndElement();
        }/*from  w w w .j a v a  2  s . c o m*/
        xtw.writeEndElement();
    }
}

From source file:org.flowable.cmmn.converter.export.PlanItemControlExport.java

public static void writeRepetitionRule(RepetitionRule repetitionRule, XMLStreamWriter xtw)
        throws XMLStreamException {
    if (repetitionRule != null) {
        xtw.writeStartElement(ELEMENT_REPETITION_RULE);
        if (StringUtils.isNotEmpty(repetitionRule.getRepetitionCounterVariableName())) {
            xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE,
                    ATTRIBUTE_REPETITION_COUNTER_VARIABLE_NAME,
                    repetitionRule.getRepetitionCounterVariableName());
        }/*from   w w  w .j  ava  2 s  . com*/
        if (StringUtils.isNotEmpty(repetitionRule.getCondition())) {
            xtw.writeStartElement(ELEMENT_CONDITION);
            xtw.writeCData(repetitionRule.getCondition());
            xtw.writeEndElement();
        }
        xtw.writeEndElement();
    }
}

From source file:org.flowable.cmmn.converter.export.PlanItemControlExport.java

public static void writeManualActivationRule(ManualActivationRule manualActivationRule, XMLStreamWriter xtw)
        throws XMLStreamException {
    if (manualActivationRule != null) {
        xtw.writeStartElement(ELEMENT_MANUAL_ACTIVATION_RULE);
        if (StringUtils.isNotEmpty(manualActivationRule.getCondition())) {
            xtw.writeStartElement(ELEMENT_CONDITION);
            xtw.writeCData(manualActivationRule.getCondition());
            xtw.writeEndElement();
        }/*from w  ww .  j a v  a  2 s .c  o  m*/
        xtw.writeEndElement();
    }
}

From source file:org.flowable.cmmn.converter.export.PlanItemControlExport.java

public static void writeCompletionNeutralRule(CompletionNeutralRule completionNeutralRule, XMLStreamWriter xtw)
        throws XMLStreamException {
    if (completionNeutralRule != null) {
        xtw.writeStartElement(ELEMENT_EXTENSION_ELEMENTS);
        xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_COMPLETION_NEUTRAL_RULE,
                FLOWABLE_EXTENSIONS_NAMESPACE);
        if (StringUtils.isNotBlank(completionNeutralRule.getCondition())) {

            xtw.writeStartElement(ELEMENT_CONDITION);
            xtw.writeCData(completionNeutralRule.getCondition());
            xtw.writeEndElement();
        }/*from  w  w  w  .  ja va2  s  . c om*/
        xtw.writeEndElement();
        xtw.writeEndElement();
    }
}