Search in sources :

Example 1 with DMNStyle

use of org.kie.dmn.model.v1_2.dmndi.DMNStyle in project drools by kiegroup.

the class XStreamMarshaller method newXStream.

private XStream newXStream() {
    XStream xStream = XStreamUtils.createNonTrustingXStream(staxDriver, Definitions.class.getClassLoader(), DMNXStream::from);
    xStream.addPermission(new TypeHierarchyPermission(QName.class));
    xStream.addPermission(new TypeHierarchyPermission(KieDMNModelInstrumentedBase.class));
    xStream.alias("artifact", TArtifact.class);
    xStream.alias("definitions", TDefinitions.class);
    xStream.alias("inputData", TInputData.class);
    xStream.alias("decision", TDecision.class);
    xStream.alias("variable", TInformationItem.class);
    xStream.alias("informationRequirement", TInformationRequirement.class);
    xStream.alias("requiredInput", TDMNElementReference.class);
    xStream.alias("literalExpression", TLiteralExpression.class);
    xStream.alias("DMNElement", TDMNElement.class);
    xStream.alias("allowedValues", TUnaryTests.class);
    xStream.alias("artifact", TArtifact.class);
    xStream.alias("association", TAssociation.class);
    xStream.alias("authorityRequirement", TAuthorityRequirement.class);
    xStream.alias("binding", TBinding.class);
    xStream.alias("businessContextElement", TBusinessContextElement.class);
    xStream.alias("businessKnowledgeModel", TBusinessKnowledgeModel.class);
    xStream.alias("column", TInformationItem.class);
    xStream.alias("context", TContext.class);
    xStream.alias("contextEntry", TContextEntry.class);
    xStream.alias("decision", TDecision.class);
    xStream.alias("decisionMade", TDMNElementReference.class);
    xStream.alias("decisionMaker", TDMNElementReference.class);
    xStream.alias("decisionOwned", TDMNElementReference.class);
    xStream.alias("decisionOwner", TDMNElementReference.class);
    xStream.alias("decisionService", TDecisionService.class);
    xStream.alias("decisionTable", TDecisionTable.class);
    xStream.alias("defaultOutputEntry", TLiteralExpression.class);
    xStream.alias("definitions", TDefinitions.class);
    xStream.alias("drgElement", TDMNElementReference.class);
    xStream.alias("elementCollection", TElementCollection.class);
    xStream.alias("encapsulatedDecision", TDMNElementReference.class);
    xStream.alias("encapsulatedLogic", TFunctionDefinition.class);
    xStream.alias("expression", TExpression.class);
    xStream.alias("formalParameter", TInformationItem.class);
    xStream.alias("functionDefinition", TFunctionDefinition.class);
    xStream.alias("impactedPerformanceIndicator", TDMNElementReference.class);
    xStream.alias("impactingDecision", TDMNElementReference.class);
    xStream.alias("import", TImport.class);
    xStream.alias("import", TImport.class);
    // TODO where?
    xStream.alias("importedElement", String.class);
    xStream.alias("importedValues", TImportedValues.class);
    xStream.alias("informationItem", TInformationItem.class);
    xStream.alias("informationRequirement", TInformationRequirement.class);
    xStream.alias("input", TInputClause.class);
    xStream.alias("inputData", TInputData.class);
    xStream.alias("inputDecision", TDMNElementReference.class);
    xStream.alias("inputEntry", TUnaryTests.class);
    xStream.alias("inputExpression", TLiteralExpression.class);
    xStream.alias("inputValues", TUnaryTests.class);
    xStream.alias("invocation", TInvocation.class);
    xStream.alias("itemComponent", TItemDefinition.class);
    xStream.alias("itemDefinition", TItemDefinition.class);
    xStream.alias("knowledgeRequirement", TKnowledgeRequirement.class);
    xStream.alias("knowledgeSource", TKnowledgeSource.class);
    xStream.alias("literalExpression", TLiteralExpression.class);
    xStream.alias("namedElement", TNamedElement.class);
    xStream.alias("organizationUnit", TOrganizationUnit.class);
    xStream.alias("output", TOutputClause.class);
    xStream.alias("outputDecision", TDMNElementReference.class);
    xStream.alias("outputEntry", TLiteralExpression.class);
    xStream.alias("outputValues", TUnaryTests.class);
    xStream.alias("owner", TDMNElementReference.class);
    xStream.alias("parameter", TInformationItem.class);
    xStream.alias("performanceIndicator", TPerformanceIndicator.class);
    xStream.alias("relation", TRelation.class);
    xStream.alias("requiredAuthority", TDMNElementReference.class);
    xStream.alias("requiredDecision", TDMNElementReference.class);
    xStream.alias("requiredInput", TDMNElementReference.class);
    xStream.alias("requiredKnowledge", TDMNElementReference.class);
    xStream.alias("rule", TDecisionRule.class);
    xStream.alias("sourceRef", TDMNElementReference.class);
    xStream.alias("supportedObjective", TDMNElementReference.class);
    xStream.alias("targetRef", TDMNElementReference.class);
    xStream.alias("textAnnotation", TTextAnnotation.class);
    // TODO where?
    xStream.alias("type", String.class);
    xStream.alias("typeRef", QName.class);
    xStream.alias("usingProcess", TDMNElementReference.class);
    xStream.alias("usingTask", TDMNElementReference.class);
    xStream.alias("variable", TInformationItem.class);
    xStream.alias("row", org.kie.dmn.model.v1_2.TList.class);
    xStream.alias("list", org.kie.dmn.model.v1_2.TList.class);
    xStream.alias("extensionElements", TDMNElement.TExtensionElements.class);
    // Manually imported TEXT = String
    xStream.alias(LiteralExpressionConverter.TEXT, String.class);
    // unnecessary 'text' key repetition:        xStream.alias( TextAnnotationConverter.TEXT, String.class );
    // unnecessary 'text' key repetition:        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);
    // unnecessary 'text' key repetition:      xStream.alias("text", xsd:string.class );
    // unnecessary 'text' key repetition:      xStream.alias("text", xsd:string.class );
    // unnecessary 'text' key repetition:      xStream.alias("text", xsd:string.class );
    // xStream.alias("question", xsd:string.class );
    // xStream.alias("allowedAnswers", xsd:string.class );
    // xStream.alias("description", xsd:string.class );
    // DMN v1.2:
    // Note, to comply with NS for XStream need also to adjust entries inside DMNModelInstrumentedBaseConverter
    xStream.alias("annotation", TRuleAnnotationClause.class);
    xStream.alias("annotationEntry", TRuleAnnotation.class);
    xStream.registerConverter(new RuleAnnotationClauseConverter(xStream));
    xStream.registerConverter(new RuleAnnotationConverter(xStream));
    xStream.alias("DMNDI", DMNDI.class);
    xStream.registerConverter(new DMNDIConverter(xStream));
    xStream.alias("DMNDiagram", DMNDiagram.class);
    xStream.registerConverter(new DMNDiagramConverter(xStream));
    xStream.alias("DMNStyle", DMNStyle.class);
    xStream.registerConverter(new DMNStyleConverter(xStream));
    xStream.alias("Size", Dimension.class);
    xStream.registerConverter(new DimensionConverter(xStream));
    xStream.alias("DMNShape", DMNShape.class);
    xStream.registerConverter(new DMNShapeConverter(xStream));
    xStream.alias("FillColor", Color.class);
    xStream.alias("StrokeColor", Color.class);
    xStream.alias("FontColor", Color.class);
    xStream.registerConverter(new ColorConverter(xStream));
    xStream.alias("Bounds", Bounds.class);
    xStream.registerConverter(new BoundsConverter(xStream));
    xStream.alias("DMNLabel", DMNLabel.class);
    xStream.registerConverter(new DMNLabelConverter(xStream));
    xStream.alias("DMNEdge", DMNEdge.class);
    xStream.registerConverter(new DMNEdgeConverter(xStream));
    xStream.alias("DMNDecisionServiceDividerLine", DMNDecisionServiceDividerLine.class);
    xStream.registerConverter(new DMNDecisionServiceDividerLineConverter(xStream));
    xStream.alias("waypoint", Point.class);
    xStream.registerConverter(new PointConverter(xStream));
    xStream.alias("extension", DiagramElement.Extension.class);
    xStream.alias(DMNLabelConverter.TEXT, 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.registerConverter(new DiagramElementExtensionConverter(xStream, extensionRegisters));
    xStream.ignoreUnknownElements();
    for (DMNExtensionRegister extensionRegister : extensionRegisters) {
        extensionRegister.registerExtensionConverters(xStream);
    }
    return xStream;
}
Also used : KieDMNModelInstrumentedBase(org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase) XStream(com.thoughtworks.xstream.XStream) DMNXStream(org.kie.dmn.backend.marshalling.v1x.DMNXStream) DMNExtensionRegister(org.kie.dmn.api.marshalling.DMNExtensionRegister) DiagramElement(org.kie.dmn.model.v1_2.dmndi.DiagramElement) DMNXStream(org.kie.dmn.backend.marshalling.v1x.DMNXStream) TypeHierarchyPermission(com.thoughtworks.xstream.security.TypeHierarchyPermission) QName(javax.xml.namespace.QName) TDefinitions(org.kie.dmn.model.v1_2.TDefinitions) Definitions(org.kie.dmn.model.api.Definitions) TDMNElement(org.kie.dmn.model.v1_2.TDMNElement)

Example 2 with DMNStyle

use of org.kie.dmn.model.v1_2.dmndi.DMNStyle in project kie-wb-common by kiegroup.

the class DMNMarshallerStandalone method internalAugment.

@SuppressWarnings("unchecked")
private void internalAugment(final Stream<DMNShape> drgShapeStream, final Id id, final Bound ulBound, final RectangleDimensionsSet dimensionsSet, final Bound lrBound, final StylingSet stylingSet, final DoubleConsumer decisionServiceDividerLineYSetter) {
    final Optional<DMNShape> drgShapeOpt = drgShapeStream.filter(shape -> shape.getDmnElementRef().getLocalPart().endsWith(id.getValue())).findFirst();
    if (!drgShapeOpt.isPresent()) {
        return;
    }
    final DMNShape drgShape = drgShapeOpt.get();
    if (ulBound != null) {
        ulBound.setX(xOfShape(drgShape));
        ulBound.setY(yOfShape(drgShape));
    }
    dimensionsSet.setWidth(new Width(widthOfShape(drgShape)));
    dimensionsSet.setHeight(new Height(heightOfShape(drgShape)));
    if (lrBound != null) {
        lrBound.setX(xOfShape(drgShape) + widthOfShape(drgShape));
        lrBound.setY(yOfShape(drgShape) + heightOfShape(drgShape));
    }
    final DMNStyle dmnStyleOfDrgShape = drgShape.getStyle() instanceof DMNStyle ? (DMNStyle) drgShape.getStyle() : null;
    if (dmnStyleOfDrgShape != null) {
        if (null != dmnStyleOfDrgShape.getFillColor()) {
            stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
        }
        if (null != dmnStyleOfDrgShape.getStrokeColor()) {
            stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
        }
    }
    final StylingSet fontSet = new StylingSet();
    if (dmnStyleOfDrgShape != null) {
        mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
    }
    if (drgShape.getDMNLabel() != null && drgShape.getDMNLabel().getSharedStyle() instanceof DMNStyle) {
        mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN((DMNStyle) drgShape.getDMNLabel().getSharedStyle()));
    }
    if (drgShape.getDMNLabel() != null && drgShape.getDMNLabel().getStyle() instanceof DMNStyle) {
        mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN((DMNStyle) drgShape.getDMNLabel().getStyle()));
    }
    mergeFontSet(stylingSet, fontSet);
    if (drgShape.getDMNDecisionServiceDividerLine() != null) {
        decisionServiceDividerLineYSetter.accept(drgShape.getDMNDecisionServiceDividerLine().getWaypoint().get(0).getY());
    }
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) Edge(org.kie.workbench.common.stunner.core.graph.Edge) PointUtils.yOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfBound) PointUtils.xOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfBound) DoubleConsumer(java.util.function.DoubleConsumer) Bounds(org.kie.dmn.model.api.dmndi.Bounds) Map(java.util.Map) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) Set(java.util.Set) BusinessKnowledgeModelConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.BusinessKnowledgeModelConverter) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) PointUtils.heightOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.heightOfShape) Stream(java.util.stream.Stream) PointUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils) QName(javax.xml.namespace.QName) PointUtils.widthOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.widthOfShape) DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) PointUtils.yOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfShape) DMNDefinitionSet(org.kie.workbench.common.dmn.api.DMNDefinitionSet) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) Point(org.kie.dmn.model.api.dmndi.Point) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Color(org.kie.dmn.model.api.dmndi.Color) ItemDefinitionPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.ItemDefinitionPropertyConverter) DiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMetadataMarshaller) ArrayList(java.util.ArrayList) FontSetPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.FontSetPropertyConverter) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) PointUtils.upperLeftBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.upperLeftBound) BiConsumer(java.util.function.BiConsumer) StreamSupport(java.util.stream.StreamSupport) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) IOException(java.io.IOException) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) InputStreamReader(java.io.InputStreamReader) InputDataConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.InputDataConverter) Association(org.kie.workbench.common.dmn.api.definition.model.Association) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) KnowledgeSourceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.KnowledgeSourceConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) DecisionConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionConverter) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) DMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine) DMNEdge(org.kie.dmn.model.api.dmndi.DMNEdge) UUID(org.kie.workbench.common.stunner.core.util.UUID) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) TextAnnotationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.TextAnnotationConverter) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Collectors.toMap(java.util.stream.Collectors.toMap) PointUtils.lowerRightBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.lowerRightBound) InformationRequirement(org.kie.workbench.common.dmn.api.definition.model.InformationRequirement) DiagramElement(org.kie.dmn.model.v1_2.dmndi.DiagramElement) Collections.emptyList(java.util.Collections.emptyList) DiagramMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMarshaller) Import(org.kie.dmn.model.api.Import) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Collectors(java.util.stream.Collectors) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) List(java.util.List) DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) DMNDI(org.kie.dmn.model.v1_2.dmndi.DMNDI) Entry(java.util.Map.Entry) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Node(org.kie.workbench.common.stunner.core.graph.Node) PointUtils.xOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfShape) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) DefinitionsConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DefinitionsConverter) HashMap(java.util.HashMap) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ColorUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ColorUtils) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ComponentsWidthsExtension(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentsWidthsExtension) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) KnowledgeRequirement(org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) DMNViewDefinition(org.kie.workbench.common.dmn.api.definition.DMNViewDefinition) SimpleEntry(java.util.AbstractMap.SimpleEntry) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) AssociationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.AssociationConverter) DMNMarshallerImportsHelperStandalone(org.kie.workbench.common.dmn.backend.common.DMNMarshallerImportsHelperStandalone) DecisionServiceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionServiceConverter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) AuthorityRequirement(org.kie.workbench.common.dmn.api.definition.model.AuthorityRequirement) Consumer(java.util.function.Consumer) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) InputStream(java.io.InputStream) BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour)

Example 3 with DMNStyle

use of org.kie.dmn.model.v1_2.dmndi.DMNStyle in project drools by kiegroup.

the class DMNDI method replaceSharedStyleIfStubbed.

private void replaceSharedStyleIfStubbed(DiagramElement element, Map<String, DMNStyle> styleById) {
    if (element.getSharedStyle() instanceof IDREFStubStyle) {
        DMNStyle locatedStyle = styleById.get(element.getSharedStyle().getId());
        element.setSharedStyle(locatedStyle);
    }
}
Also used : IDREFStubStyle(org.kie.dmn.model.v1_2.dmndi.Style.IDREFStubStyle) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle)

Example 4 with DMNStyle

use of org.kie.dmn.model.v1_2.dmndi.DMNStyle in project drools by kiegroup.

the class DMNModelInstrumentedBaseConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    KieDMNModelInstrumentedBase mib = (KieDMNModelInstrumentedBase) parent;
    CustomStaxWriter staxWriter = ((CustomStaxWriter) writer.underlyingWriter());
    for (Entry<String, String> kv : mib.getNsContext().entrySet()) {
        try {
            if (KieDMNModelInstrumentedBase.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) {
            LOG.warn("The XML driver writer failed to manage writing namespace, namespaces prefixes could be wrong in the resulting file.", e);
        }
    }
    for (Entry<QName, String> kv : mib.getAdditionalAttributes().entrySet()) {
        staxWriter.addAttribute(kv.getKey().getPrefix() + ":" + kv.getKey().getLocalPart(), kv.getValue());
    }
    if (parent instanceof TDefinitions) {
        TDefinitions tDefinitions = (TDefinitions) parent;
        String dmndiPrefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_DMNDI).orElse("dmndi");
        String diPrefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_DI).orElse("di");
        String dcPrefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_DC).orElse("dc");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNDI", dmndiPrefix), "DMNDI");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNDiagram", dmndiPrefix), "DMNDiagram");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNStyle", dmndiPrefix), "style");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNStyle", dmndiPrefix), "DMNStyle");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNShape", dmndiPrefix), "DMNShape");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNEdge", dmndiPrefix), "DMNEdge");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNDecisionServiceDividerLine", dmndiPrefix), "DMNDecisionServiceDividerLine");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "DMNLabel", dmndiPrefix), "DMNLabel");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, DMNLabelConverter.TEXT, dmndiPrefix), DMNLabelConverter.TEXT);
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "Size", dmndiPrefix), "Size");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "FillColor", dmndiPrefix), "FillColor");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "StrokeColor", dmndiPrefix), "StrokeColor");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DMNDI, "FontColor", dmndiPrefix), "FontColor");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DI, "waypoint", diPrefix), "waypoint");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DI, "extension", diPrefix), "extension");
        staxWriter.getQNameMap().registerMapping(new QName(KieDMNModelInstrumentedBase.URI_DC, "Bounds", dcPrefix), "Bounds");
    }
}
Also used : CustomStaxWriter(org.kie.dmn.backend.marshalling.CustomStaxWriter) QName(javax.xml.namespace.QName) KieDMNModelInstrumentedBase(org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase) TDefinitions(org.kie.dmn.model.v1_2.TDefinitions)

Aggregations

QName (javax.xml.namespace.QName)3 DMNStyle (org.kie.dmn.model.api.dmndi.DMNStyle)2 KieDMNModelInstrumentedBase (org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase)2 DiagramElement (org.kie.dmn.model.v1_2.dmndi.DiagramElement)2 XStream (com.thoughtworks.xstream.XStream)1 TypeHierarchyPermission (com.thoughtworks.xstream.security.TypeHierarchyPermission)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1