Search in sources :

Example 1 with GeneralRectangleDimensionsSet

use of org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet in project kie-wb-common by kiegroup.

the class BusinessKnowledgeModelConverter method nodeFromDMN.

@Override
public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(BusinessKnowledgeModel.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    final org.kie.dmn.model.api.FunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic();
    final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, hasComponentWidthsConsumer);
    final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new StylingSet(), new GeneralRectangleDimensionsSet());
    node.getContent().setDefinition(bkm);
    if (informationItem != null) {
        informationItem.setParent(bkm);
    }
    if (functionDefinition != null) {
        functionDefinition.setParent(bkm);
    }
    if (Objects.nonNull(dmnFunctionDefinition)) {
        hasComponentWidthsConsumer.accept(dmnFunctionDefinition.getId(), functionDefinition);
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(javax.xml.namespace.QName) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)

Example 2 with GeneralRectangleDimensionsSet

use of org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet in project kie-wb-common by kiegroup.

the class DecisionConverter method nodeFromDMN.

@Override
public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
    final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new StylingSet(), new GeneralRectangleDimensionsSet());
    decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion()));
    decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers()));
    node.getContent().setDefinition(decision);
    if (informationItem != null) {
        informationItem.setParent(decision);
    }
    if (expression != null) {
        expression.setParent(decision);
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) AllowedAnswers(org.kie.workbench.common.dmn.api.property.dmn.AllowedAnswers) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Question(org.kie.workbench.common.dmn.api.property.dmn.Question) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)

Example 3 with GeneralRectangleDimensionsSet

use of org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet in project kie-wb-common by kiegroup.

the class BusinessKnowledgeModelTest method testDifferentStylingSet.

@Test
public void testDifferentStylingSet() {
    final BusinessKnowledgeModel modelOne = new BusinessKnowledgeModel(new Id("123"), new Description(), new Name(), new InformationItemPrimary(new Id("346"), new Name(), new QName()), new FunctionDefinition(new Id("789"), new Description(), new QName(), null), new StylingSet(), new GeneralRectangleDimensionsSet());
    final BusinessKnowledgeModel modelTwo = new BusinessKnowledgeModel(new Id("123"), new Description(), new Name(), new InformationItemPrimary(new Id("346"), new Name(), new QName()), new FunctionDefinition(new Id("789"), new Description(), new QName(), null), new StylingSet(), new GeneralRectangleDimensionsSet());
    assertEquals(modelOne, modelTwo);
    modelOne.getStylingSet().setFontSize(new FontSize(10.0));
    modelTwo.getStylingSet().setFontSize(new FontSize(11.0));
    assertNotEquals(modelOne, modelTwo);
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) FontSize(org.kie.workbench.common.dmn.api.property.styling.FontSize) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 4 with GeneralRectangleDimensionsSet

use of org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet in project kie-wb-common by kiegroup.

the class KnowledgeSourceTest method testDifferentStylingSet.

@Test
public void testDifferentStylingSet() {
    final KnowledgeSource modelOne = new KnowledgeSource(new Id("123"), new Description(), new Name(), new KnowledgeSourceType(), new LocationURI(), new StylingSet(), new GeneralRectangleDimensionsSet());
    final KnowledgeSource modelTwo = new KnowledgeSource(new Id("123"), new Description(), new Name(), new KnowledgeSourceType(), new LocationURI(), new StylingSet(), new GeneralRectangleDimensionsSet());
    assertEquals(modelOne, modelTwo);
    modelOne.getStylingSet().setFontSize(new FontSize(10.0));
    modelTwo.getStylingSet().setFontSize(new FontSize(11.0));
    assertNotEquals(modelOne, modelTwo);
}
Also used : LocationURI(org.kie.workbench.common.dmn.api.property.dmn.LocationURI) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) FontSize(org.kie.workbench.common.dmn.api.property.styling.FontSize) KnowledgeSourceType(org.kie.workbench.common.dmn.api.property.dmn.KnowledgeSourceType) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 5 with GeneralRectangleDimensionsSet

use of org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet in project kie-wb-common by kiegroup.

the class InputDataTest method testDifferentStylingSet.

@Test
public void testDifferentStylingSet() {
    final InputData modelOne = new InputData(new Id("123"), new Description(), new Name(), new InformationItemPrimary(new Id("346"), new Name(), new QName()), new StylingSet(), new GeneralRectangleDimensionsSet());
    final InputData modelTwo = new InputData(new Id("123"), new Description(), new Name(), new InformationItemPrimary(new Id("346"), new Name(), new QName()), new StylingSet(), new GeneralRectangleDimensionsSet());
    assertEquals(modelOne, modelTwo);
    modelOne.getStylingSet().setFontSize(new FontSize(10.0));
    modelTwo.getStylingSet().setFontSize(new FontSize(11.0));
    assertNotEquals(modelOne, modelTwo);
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) FontSize(org.kie.workbench.common.dmn.api.property.styling.FontSize) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)18 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)18 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)18 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)18 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)15 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)10 Node (org.kie.workbench.common.stunner.core.graph.Node)10 View (org.kie.workbench.common.stunner.core.graph.content.view.View)10 Test (org.junit.Test)8 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)6 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)6 FontSize (org.kie.workbench.common.dmn.api.property.styling.FontSize)5 AllowedAnswers (org.kie.workbench.common.dmn.api.property.dmn.AllowedAnswers)4 Question (org.kie.workbench.common.dmn.api.property.dmn.Question)4 KnowledgeSourceType (org.kie.workbench.common.dmn.api.property.dmn.KnowledgeSourceType)3 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)3 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)3 TextFormat (org.kie.workbench.common.dmn.api.property.dmn.TextFormat)3 IdUtils.getRawId (org.kie.workbench.common.dmn.client.marshaller.common.IdUtils.getRawId)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2