Search in sources :

Example 21 with Context

use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.

the class MoveRowsCommandTest method setup.

@Before
public void setup() {
    this.context = new Context();
    this.uiModel = new DMNGridData();
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
    addContextEntry(II1);
    addContextEntry(II2);
    addUiModelColumn(uiRowNumberColumn);
    addUiModelColumn(uiNameColumn);
    addUiModelColumn(uiExpressionEditorColumn);
    addUiModelRow(0);
    addUiModelRow(1);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 22 with Context

use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.

the class HasExpressionTest method testWrapNonNull.

@Test
public void testWrapNonNull() {
    final LiteralExpression le = new LiteralExpression();
    final HasExpression hasExpression = HasExpression.wrap(parent, le);
    assertNotNull(hasExpression.getExpression());
    assertEquals(le, hasExpression.getExpression());
    assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
    final Context context = new Context();
    hasExpression.setExpression(context);
    assertNotNull(hasExpression.getExpression());
    assertEquals(context, hasExpression.getExpression());
    assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Test(org.junit.Test)

Example 23 with Context

use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.

the class ContextGrid method doAfterSelectionChange.

@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
    if (hasAnyHeaderCellSelected() || hasMultipleRowsSelected()) {
        super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
        return;
    }
    if (uiRowIndex < model.getRowCount() - 1) {
        if (getExpression().get().isPresent()) {
            final Context context = getExpression().get().get();
            fireDomainObjectSelectionEvent(context.getContextEntry().get(uiRowIndex).getVariable());
            return;
        }
    }
    super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context)

Example 24 with Context

use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method checkDecisionWithContextWithoutDefaultResult.

private void checkDecisionWithContextWithoutDefaultResult(Graph<?, Node<?, ?>> g) {
    Node<?, ?> decisionNode = g.getNode("_30810b88-8416-4c02-8ed1-8c19b7606243");
    assertNodeContentDefinitionIs(decisionNode, Decision.class);
    Context context = (Context) ((Decision) ((View<?>) decisionNode.getContent()).getDefinition()).getExpression();
    InformationItem defaultResultVariable = context.getContextEntry().get(1).getVariable();
    assertNull("Default result variable", defaultResultVariable);
    Expression defaultResultExpression = context.getContextEntry().get(1).getExpression();
    assertNull("Default result expression", defaultResultExpression);
}
Also used : NamespaceContext(javax.xml.namespace.NamespaceContext) DMNContext(org.kie.dmn.api.core.DMNContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 25 with Context

use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testContextEntryDataType.

@Test
@SuppressWarnings("unchecked")
public void testContextEntryDataType() throws Exception {
    final DMNMarshallerStandalone marshaller = getDMNMarshaller();
    final Context context = new Context();
    context.setTypeRef(BuiltInType.DATE_TIME.asQName());
    final ContextEntry contextEntry = new ContextEntry();
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.setTypeRef(BuiltInType.BOOLEAN.asQName());
    literalExpression.getText().setValue("feel");
    contextEntry.setExpression(literalExpression);
    context.getContextEntry().add(contextEntry);
    final Diagram<Graph, Metadata> mockedDiagram = newDiagramDecisionWithExpression(context);
    final String marshalledSource = marshaller.marshall(mockedDiagram);
    final Graph<?, Node<View, ?>> unmarshalledGraph = marshaller.unmarshall(createMetadata(), new StringInputStream(marshalledSource));
    assertThat(unmarshalledGraph.nodes()).hasSize(2);
    checkDecisionExpression(unmarshalledGraph, context);
}
Also used : NamespaceContext(javax.xml.namespace.NamespaceContext) DMNContext(org.kie.dmn.api.core.DMNContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) StringInputStream(org.apache.tools.ant.filters.StringInputStream) Graph(org.kie.workbench.common.stunner.core.graph.Graph) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) BusinessKnowledgeModelNode(org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode) Node(org.kie.workbench.common.stunner.core.graph.Node) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) Test(org.junit.Test)

Aggregations

Context (org.kie.workbench.common.dmn.api.definition.model.Context)49 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)21 Test (org.junit.Test)20 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)15 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)13 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)12 TContext (org.kie.dmn.model.v1_2.TContext)9 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 NamespaceContext (javax.xml.namespace.NamespaceContext)6 Before (org.junit.Before)6 DMNContext (org.kie.dmn.api.core.DMNContext)6 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)5 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)5 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)5 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)5 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 ArrayList (java.util.ArrayList)4