use of org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement in project drools by kiegroup.
the class DMNElementConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
DMNElement e = (DMNElement) parent;
if (e.getDescription() != null) {
writeChildrenNodeAsValue(writer, context, e.getDescription(), DESCRIPTION);
}
if (e.getExtensionElements() != null) {
writeChildrenNode(writer, context, e.getExtensionElements(), EXTENSION_ELEMENTS);
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement in project drools by kiegroup.
the class DMNElementConverter method assignAttributes.
@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
super.assignAttributes(reader, parent);
String id = reader.getAttribute(ID);
String label = reader.getAttribute(LABEL);
DMNElement dmne = (DMNElement) parent;
dmne.setId(id);
dmne.setLabel(label);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement in project drools by kiegroup.
the class XStreamMarshaller method newXStream.
private XStream newXStream() {
XStream xStream = createTrustingXStream(staxDriver, Definitions.class.getClassLoader());
xStream.alias("artifact", Artifact.class);
xStream.alias("definitions", Definitions.class);
xStream.alias("inputData", InputData.class);
xStream.alias("decision", Decision.class);
xStream.alias("variable", InformationItem.class);
xStream.alias("informationRequirement", InformationRequirement.class);
xStream.alias("requiredInput", DMNElementReference.class);
xStream.alias("literalExpression", LiteralExpression.class);
// TODO will need to remove dups and find missing element not captured?
xStream.alias("DMNElement", DMNElement.class);
xStream.alias("allowedValues", UnaryTests.class);
xStream.alias("artifact", Artifact.class);
xStream.alias("association", Association.class);
xStream.alias("authorityRequirement", AuthorityRequirement.class);
xStream.alias("authorityRequirement", AuthorityRequirement.class);
xStream.alias("authorityRequirement", AuthorityRequirement.class);
xStream.alias("binding", Binding.class);
xStream.alias("businessContextElement", BusinessContextElement.class);
xStream.alias("businessKnowledgeModel", BusinessKnowledgeModel.class);
xStream.alias("column", InformationItem.class);
xStream.alias("context", Context.class);
xStream.alias("contextEntry", ContextEntry.class);
xStream.alias("decision", Decision.class);
xStream.alias("decisionMade", DMNElementReference.class);
xStream.alias("decisionMaker", DMNElementReference.class);
xStream.alias("decisionOwned", DMNElementReference.class);
xStream.alias("decisionOwner", DMNElementReference.class);
xStream.alias("decisionService", DecisionService.class);
xStream.alias("decisionTable", DecisionTable.class);
xStream.alias("defaultOutputEntry", LiteralExpression.class);
xStream.alias("definitions", Definitions.class);
xStream.alias("drgElement", DMNElementReference.class);
// xStream.alias("drgElement", DRGElement.class ); ambiguity, also referring to top-level xsd element just under xsd root.
xStream.alias("elementCollection", ElementCollection.class);
xStream.alias("elementCollection", ElementCollection.class);
xStream.alias("encapsulatedDecision", DMNElementReference.class);
xStream.alias("encapsulatedLogic", FunctionDefinition.class);
xStream.alias("expression", Expression.class);
xStream.alias("formalParameter", InformationItem.class);
xStream.alias("functionDefinition", FunctionDefinition.class);
xStream.alias("impactedPerformanceIndicator", DMNElementReference.class);
xStream.alias("impactingDecision", DMNElementReference.class);
xStream.alias("import", Import.class);
xStream.alias("import", Import.class);
// TODO where?
xStream.alias("importedElement", String.class);
xStream.alias("importedValues", ImportedValues.class);
xStream.alias("informationItem", InformationItem.class);
xStream.alias("informationRequirement", InformationRequirement.class);
xStream.alias("input", InputClause.class);
xStream.alias("inputData", DMNElementReference.class);
xStream.alias("inputData", InputData.class);
xStream.alias("inputDecision", DMNElementReference.class);
xStream.alias("inputEntry", UnaryTests.class);
xStream.alias("inputExpression", LiteralExpression.class);
xStream.alias("inputValues", UnaryTests.class);
xStream.alias("invocation", Invocation.class);
xStream.alias("itemComponent", ItemDefinition.class);
xStream.alias("itemDefinition", ItemDefinition.class);
xStream.alias("itemDefinition", ItemDefinition.class);
xStream.alias("knowledgeRequirement", KnowledgeRequirement.class);
xStream.alias("knowledgeRequirement", KnowledgeRequirement.class);
xStream.alias("knowledgeSource", KnowledgeSource.class);
xStream.alias("literalExpression", LiteralExpression.class);
xStream.alias("namedElement", NamedElement.class);
xStream.alias("organizationUnit", OrganizationUnit.class);
xStream.alias("output", OutputClause.class);
xStream.alias("outputDecision", DMNElementReference.class);
xStream.alias("outputEntry", LiteralExpression.class);
xStream.alias("outputValues", UnaryTests.class);
xStream.alias("owner", DMNElementReference.class);
xStream.alias("parameter", InformationItem.class);
xStream.alias("performanceIndicator", PerformanceIndicator.class);
xStream.alias("relation", Relation.class);
xStream.alias("requiredAuthority", DMNElementReference.class);
xStream.alias("requiredDecision", DMNElementReference.class);
xStream.alias("requiredDecision", DMNElementReference.class);
xStream.alias("requiredInput", DMNElementReference.class);
xStream.alias("requiredInput", DMNElementReference.class);
xStream.alias("requiredKnowledge", DMNElementReference.class);
xStream.alias("rule", DecisionRule.class);
xStream.alias("sourceRef", DMNElementReference.class);
xStream.alias("supportedObjective", DMNElementReference.class);
xStream.alias("targetRef", DMNElementReference.class);
xStream.alias("textAnnotation", TextAnnotation.class);
// TODO where?
xStream.alias("type", String.class);
xStream.alias("typeRef", QName.class);
xStream.alias("usingProcess", DMNElementReference.class);
xStream.alias("usingTask", DMNElementReference.class);
xStream.alias("variable", InformationItem.class);
xStream.alias("variable", InformationItem.class);
xStream.alias("variable", InformationItem.class);
xStream.alias("variable", InformationItem.class);
// xStream.alias("allowedAnswers", xsd:string.class );
// xStream.alias("description", xsd:string.class );
// xStream.alias("question", xsd:string.class );
// xStream.alias("text", xsd:string.class );
// xStream.alias("text", xsd:string.class );
// xStream.alias("text", xsd:string.class );
xStream.alias("row", org.kie.dmn.model.v1_1.List.class);
xStream.alias("list", org.kie.dmn.model.v1_1.List.class);
xStream.alias("extensionElements", DMNElement.ExtensionElements.class);
// Manually imported TEXT = String
xStream.alias(LiteralExpressionConverter.TEXT, String.class);
xStream.alias(TextAnnotationConverter.TEXT, String.class);
xStream.alias(UnaryTestsConverter.TEXT, String.class);
xStream.alias(DecisionConverter.QUESTION, String.class);
xStream.alias(DecisionConverter.ALLOWED_ANSWERS, String.class);
xStream.alias(DMNElementConverter.DESCRIPTION, String.class);
xStream.registerConverter(new AssociationConverter(xStream));
xStream.registerConverter(new AuthorityRequirementConverter(xStream));
xStream.registerConverter(new BindingConverter(xStream));
xStream.registerConverter(new BusinessKnowledgeModelConverter(xStream));
xStream.registerConverter(new ContextConverter(xStream));
xStream.registerConverter(new ContextEntryConverter(xStream));
xStream.registerConverter(new DecisionConverter(xStream));
xStream.registerConverter(new DecisionRuleConverter(xStream));
xStream.registerConverter(new DecisionServiceConverter(xStream));
xStream.registerConverter(new DecisionTableConverter(xStream));
xStream.registerConverter(new DefinitionsConverter(xStream));
xStream.registerConverter(new DMNElementReferenceConverter(xStream));
xStream.registerConverter(new FunctionDefinitionConverter(xStream));
xStream.registerConverter(new ImportConverter(xStream));
xStream.registerConverter(new ImportedValuesConverter(xStream));
xStream.registerConverter(new InformationItemConverter(xStream));
xStream.registerConverter(new InformationRequirementConverter(xStream));
xStream.registerConverter(new InputClauseConverter(xStream));
xStream.registerConverter(new InputDataConverter(xStream));
xStream.registerConverter(new InvocationConverter(xStream));
xStream.registerConverter(new ItemDefinitionConverter(xStream));
xStream.registerConverter(new KnowledgeRequirementConverter(xStream));
xStream.registerConverter(new KnowledgeSourceConverter(xStream));
xStream.registerConverter(new LiteralExpressionConverter(xStream));
xStream.registerConverter(new OrganizationUnitConverter(xStream));
xStream.registerConverter(new OutputClauseConverter(xStream));
xStream.registerConverter(new PerformanceIndicatorConverter(xStream));
xStream.registerConverter(new RelationConverter(xStream));
xStream.registerConverter(new TextAnnotationConverter(xStream));
xStream.registerConverter(new UnaryTestsConverter(xStream));
xStream.registerConverter(new QNameConverter());
xStream.registerConverter(new DMNListConverter(xStream));
xStream.registerConverter(new ElementCollectionConverter(xStream));
xStream.registerConverter(new ExtensionElementsConverter(xStream, extensionRegisters));
xStream.ignoreUnknownElements();
for (DMNExtensionRegister extensionRegister : extensionRegisters) {
extensionRegister.registerExtensionConverters(xStream);
}
return xStream;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement in project kie-wb-common by kiegroup.
the class DMNMarshaller method stunnerToDDExt.
private static DMNShape stunnerToDDExt(View<? extends DMNElement> v) {
DMNShape result = new DMNShape();
result.setId("dmnshape-" + v.getDefinition().getId().getValue());
result.setDmnElementRef(v.getDefinition().getId().getValue());
Bounds bounds = new Bounds();
result.setBounds(bounds);
bounds.setX(v.getBounds().getUpperLeft().getX());
bounds.setY(v.getBounds().getUpperLeft().getY());
if (v.getDefinition() instanceof Decision) {
Decision d = (Decision) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyBackgroundStyles(d.getBackgroundSet(), result);
result.setFontStyle(FontSetPropertyConverter.dmnFromWB(d.getFontSet()));
} else if (v.getDefinition() instanceof InputData) {
InputData d = (InputData) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyBackgroundStyles(d.getBackgroundSet(), result);
result.setFontStyle(FontSetPropertyConverter.dmnFromWB(d.getFontSet()));
} else if (v.getDefinition() instanceof BusinessKnowledgeModel) {
BusinessKnowledgeModel d = (BusinessKnowledgeModel) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyBackgroundStyles(d.getBackgroundSet(), result);
result.setFontStyle(FontSetPropertyConverter.dmnFromWB(d.getFontSet()));
} else if (v.getDefinition() instanceof KnowledgeSource) {
KnowledgeSource d = (KnowledgeSource) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyBackgroundStyles(d.getBackgroundSet(), result);
result.setFontStyle(FontSetPropertyConverter.dmnFromWB(d.getFontSet()));
} else if (v.getDefinition() instanceof TextAnnotation) {
TextAnnotation d = (TextAnnotation) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyBackgroundStyles(d.getBackgroundSet(), result);
result.setFontStyle(FontSetPropertyConverter.dmnFromWB(d.getFontSet()));
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement in project kie-wb-common by kiegroup.
the class DMNMarshaller method marshall.
@Override
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
Graph<?, Node<View, ?>> g = diagram.getGraph();
Map<String, org.kie.dmn.model.v1_1.DRGElement> nodes = new HashMap<>();
Map<String, org.kie.dmn.model.v1_1.TextAnnotation> textAnnotations = new HashMap<>();
@SuppressWarnings("unchecked") Node<View<DMNDiagram>, ?> dmnDiagramRoot = (Node<View<DMNDiagram>, ?>) findDMNDiagramRoot(g);
Definitions definitionsStunnerPojo = dmnDiagramRoot.getContent().getDefinition().getDefinitions();
org.kie.dmn.model.v1_1.Definitions definitions = DefinitionsConverter.dmnFromWB(definitionsStunnerPojo);
if (definitions.getExtensionElements() == null) {
definitions.setExtensionElements(new org.kie.dmn.model.v1_1.Definitions.ExtensionElements());
}
org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNDiagram dmnDDDMNDiagram = new org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNDiagram();
definitions.getExtensionElements().getAny().add(dmnDDDMNDiagram);
for (Node<?, ?> node : g.nodes()) {
if (node.getContent() instanceof View<?>) {
View<?> view = (View<?>) node.getContent();
if (view.getDefinition() instanceof DRGElement) {
DRGElement n = (org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement) view.getDefinition();
nodes.put(n.getId().getValue(), stunnerToDMN(node));
dmnDDDMNDiagram.getAny().add(stunnerToDDExt((View<? extends DMNElement>) view));
} else if (view.getDefinition() instanceof TextAnnotation) {
TextAnnotation textAnnotation = (TextAnnotation) view.getDefinition();
textAnnotations.put(textAnnotation.getId().getValue(), textAnnotationConverter.dmnFromNode((Node<View<TextAnnotation>, ?>) node));
dmnDDDMNDiagram.getAny().add(stunnerToDDExt((View<? extends DMNElement>) view));
List<org.kie.dmn.model.v1_1.Association> associations = AssociationConverter.dmnFromWB((Node<View<TextAnnotation>, ?>) node);
definitions.getArtifact().addAll(associations);
}
}
}
nodes.values().forEach(definitions.getDrgElement()::add);
textAnnotations.values().forEach(definitions.getArtifact()::add);
String marshalled = marshaller.marshal(definitions);
return marshalled;
}
Aggregations