Example usage for javax.xml.stream XMLStreamWriter writeCData

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

Introduction

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

Prototype

public void writeCData(String data) throws XMLStreamException;

Source Link

Document

Writes a CData section

Usage

From source file:org.flowable.bpmn.converter.ScriptTaskXMLConverter.java

@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        throws Exception {
    ScriptTask scriptTask = (ScriptTask) element;
    if (StringUtils.isNotEmpty(scriptTask.getScript())) {
        xtw.writeStartElement(ATTRIBUTE_TASK_SCRIPT_TEXT);
        xtw.writeCData(scriptTask.getScript());
        xtw.writeEndElement();/*from ww  w.j a va 2 s. co m*/
    }
}

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 w  w.  j  a  v  a  2  s  .c  o  m

    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;
        }/*w  w w. j  av  a2 s .  co 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.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 ww. j a v a 2 s.c  om*/
        }
        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  ww.jav a 2  s.c  o  m
        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  .  jav  a2s.com*/
        }
        xtw.writeEndElement();
        xtw.writeEndElement();
    }
}

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

public static void writePlanItem(PlanItem planItem, XMLStreamWriter xtw) throws Exception {
    // start plan item element
    xtw.writeStartElement(ELEMENT_PLAN_ITEM);
    xtw.writeAttribute(ATTRIBUTE_ID, planItem.getId());

    if (StringUtils.isNotEmpty(planItem.getName())) {
        xtw.writeAttribute(ATTRIBUTE_NAME, planItem.getName());
    }/*from   w  w  w .j  a va  2  s  .c  o  m*/

    if (StringUtils.isNotEmpty(planItem.getDefinitionRef())) {
        xtw.writeAttribute(ATTRIBUTE_DEFINITION_REF, planItem.getDefinitionRef());
    }

    if (StringUtils.isNotEmpty(planItem.getDocumentation())) {
        xtw.writeStartElement(ELEMENT_DOCUMENTATION);
        xtw.writeCharacters(planItem.getDocumentation());
        xtw.writeEndElement();
    }
    if (planItem.getItemControl() != null) {
        xtw.writeStartElement(ELEMENT_ITEM_CONTROL);
        RepetitionRule repetitionRule = planItem.getItemControl().getRepetitionRule();
        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());
            }
            if (StringUtils.isNotEmpty(repetitionRule.getCondition())) {
                xtw.writeStartElement(ELEMENT_CONDITION);
                xtw.writeCData(repetitionRule.getCondition());
                xtw.writeEndElement();
            }
            xtw.writeEndElement();
        }
        xtw.writeEndElement();
    }

    CriteriaExport.writeCriteriaElements(planItem, xtw);

    // end plan item element
    xtw.writeEndElement();
}

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

public static void writeProcessTask(ProcessTask processTask, XMLStreamWriter xtw) throws Exception {
    // start process task element
    xtw.writeStartElement(ELEMENT_PROCESS_TASK);
    writeCommonTaskAttributes(xtw, processTask);

    if (StringUtils.isNotEmpty(processTask.getProcessRef())
            || StringUtils.isNotEmpty(processTask.getProcessRefExpression())) {
        xtw.writeStartElement(ELEMENT_PROCESS_REF_EXPRESSION);
        xtw.writeCData(StringUtils.isNotEmpty(processTask.getProcessRef()) ? processTask.getProcessRef()
                : processTask.getProcessRefExpression());
        xtw.writeEndElement();//from   ww  w. j a  va2  s  . c  o m
    }

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

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

public static void writeSentry(Sentry sentry, XMLStreamWriter xtw) throws Exception {
    // start sentry element
    xtw.writeStartElement(ELEMENT_SENTRY);
    xtw.writeAttribute(ATTRIBUTE_ID, sentry.getId());

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

    for (SentryOnPart sentryOnPart : sentry.getOnParts()) {
        // start sentry on part element
        xtw.writeStartElement(ELEMENT_PLAN_ITEM_ON_PART);

        xtw.writeAttribute(ATTRIBUTE_ID, sentryOnPart.getId());
        xtw.writeAttribute(ATTRIBUTE_SOURCE_REF, sentryOnPart.getSourceRef());

        // start standard event element
        xtw.writeStartElement(ELEMENT_STANDARD_EVENT);
        xtw.writeCharacters(sentryOnPart.getStandardEvent());
        xtw.writeEndElement();

        // end sentry on part element
        xtw.writeEndElement();
    }

    // If part
    if (sentry.getSentryIfPart() != null) {
        xtw.writeStartElement(ELEMENT_IF_PART);
        xtw.writeStartElement(ELEMENT_CONDITION);
        xtw.writeCData(sentry.getSentryIfPart().getCondition());
        xtw.writeEndElement();
        xtw.writeEndElement();
    }

    // end plan item element
    xtw.writeEndElement();
}