Search in sources :

Example 6 with DMNModelInstrumentedBase

use of org.kie.dmn.model.v1_1.DMNModelInstrumentedBase in project drools by kiegroup.

the class DMNModelInstrumentedBaseConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    DMNModelInstrumentedBase mib = (DMNModelInstrumentedBase) parent;
    CustomStaxWriter staxWriter = ((CustomStaxWriter) writer.underlyingWriter());
    for (Entry<String, String> kv : mib.getNsContext().entrySet()) {
        try {
            if (DMNModelInstrumentedBase.URI_DMN.equals(kv.getValue())) {
            // skip as that is the default namespace xmlns<:prefix>=DMN is handled by the stax driver.
            } else {
                staxWriter.writeNamespace(kv.getKey(), kv.getValue());
            }
        } catch (Exception e) {
            // TODO what to do?
            e.printStackTrace();
        }
    }
    for (Entry<QName, String> kv : mib.getAdditionalAttributes().entrySet()) {
        staxWriter.addAttribute(kv.getKey().getPrefix() + ":" + kv.getKey().getLocalPart(), kv.getValue());
    }
}
Also used : CustomStaxWriter(org.kie.dmn.backend.marshalling.CustomStaxWriter) QName(javax.xml.namespace.QName) DMNModelInstrumentedBase(org.kie.dmn.model.v1_1.DMNModelInstrumentedBase)

Example 7 with DMNModelInstrumentedBase

use of org.kie.dmn.model.v1_1.DMNModelInstrumentedBase in project drools by kiegroup.

the class DecisionServiceConverter method parseElements.

@Override
protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) {
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        Object object = null;
        String nodeName = reader.getNodeName();
        if (nodeName.equals(INPUT_DATA)) {
            // Patch because the tag name inputData is used in both decision services and as a DRG Element
            DMNElementReference ref = new DMNElementReference();
            ref.setHref(reader.getAttribute("href"));
            object = ref;
        } else {
            // Default behaviour
            object = readItem(reader, context, null);
        }
        if (object instanceof DMNModelInstrumentedBase) {
            ((DMNModelInstrumentedBase) object).setParent((DMNModelInstrumentedBase) parent);
            ((DMNModelInstrumentedBase) parent).addChildren((DMNModelInstrumentedBase) object);
        }
        reader.moveUp();
        assignChildElement(parent, nodeName, object);
    }
}
Also used : DMNElementReference(org.kie.dmn.model.v1_1.DMNElementReference) DMNModelInstrumentedBase(org.kie.dmn.model.v1_1.DMNModelInstrumentedBase)

Aggregations

DMNModelInstrumentedBase (org.kie.dmn.model.v1_1.DMNModelInstrumentedBase)6 QName (javax.xml.namespace.QName)3 CustomStaxReader (org.kie.dmn.backend.marshalling.CustomStaxReader)2 CustomStaxWriter (org.kie.dmn.backend.marshalling.CustomStaxWriter)2 XStream (com.thoughtworks.xstream.XStream)1 AbstractPullReader (com.thoughtworks.xstream.io.xml.AbstractPullReader)1 QNameMap (com.thoughtworks.xstream.io.xml.QNameMap)1 StaxDriver (com.thoughtworks.xstream.io.xml.StaxDriver)1 StaxWriter (com.thoughtworks.xstream.io.xml.StaxWriter)1 CannotResolveClassException (com.thoughtworks.xstream.mapper.CannotResolveClassException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1