Search in sources :

Example 6 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class AbstractDMNDataManagementStrategyTest method setup.

@Before
public void setup() {
    super.setup();
    factModelTupleLocal = new FactModelTuple(visibleFactsLocal, hiddenFactsLocal);
    factModelTreeHolderlocal = new AbstractDataManagementStrategy.ResultHolder();
    factModelTreeHolderlocal.setFactModelTuple(factModelTupleLocal);
    when(dmnTypeServiceMock.retrieveFactModelTuple(any(), anyString())).thenReturn(factModelTupleLocal);
    modelLocal.getSettings().setDmnFilePath(DMN_FILE_PATH);
    abstractDMNDataManagementStrategySpy = spy(new AbstractDMNDataManagementStrategy(mock(EventBus.class)) {

        @Override
        protected void retrieveFactModelTuple(TestToolsView.Presenter testToolsPresenter, ScenarioSimulationContext context, GridWidget gridWidget) {
        }

        {
            this.currentPath = mock(Path.class);
            this.model = modelLocal;
            this.factModelTreeHolder = factModelTreeHolderlocal;
            this.dmnFilePath = DMN_FILE_PATH;
        }
    });
}
Also used : ScenarioSimulationContext(org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext) Path(org.uberfire.backend.vfs.Path) GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) EventBus(com.google.gwt.event.shared.EventBus) Before(org.junit.Before)

Example 7 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class AbstractDataManagementStrategy method storeData.

/**
 * Store data in required target objects
 */
public void storeData(final FactModelTuple factModelTuple, final TestToolsView.Presenter testToolsPresenter, final ScenarioSimulationContext context, final GridWidget gridWidget) {
    // Instantiate a map of already assigned properties
    final Map<String, List<List<String>>> propertiesToHide = getPropertiesToHide(context.getAbstractScesimGridModelByGridWidget(gridWidget));
    final SortedMap<String, FactModelTree> visibleFacts = factModelTuple.getVisibleFacts();
    final Map<Boolean, List<Map.Entry<String, FactModelTree>>> partitionBy = visibleFacts.entrySet().stream().collect(Collectors.partitioningBy(stringFactModelTreeEntry -> stringFactModelTreeEntry.getValue().isSimple()));
    final SortedMap<String, FactModelTree> complexDataObjects = new TreeMap<>(partitionBy.get(false).stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
    final SortedMap<String, FactModelTree> simpleDataObjects = new TreeMap<>(partitionBy.get(true).stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
    // Update context
    SortedMap<String, FactModelTree> dataObjectFieldsMap = new TreeMap<>();
    dataObjectFieldsMap.putAll(visibleFacts);
    dataObjectFieldsMap.putAll(factModelTuple.getHiddenFacts());
    context.setDataObjectFieldsMap(dataObjectFieldsMap);
    // Update model
    // Avoid Collections.emptySortedMap() due to "The method emptySortedMap() is undefined for the type Collections" error
    SortedMap<String, FactModelTree> instanceFieldsMap = new TreeMap<>();
    SortedMap<String, FactModelTree> simpleJavaTypeInstanceFieldsMap = new TreeMap<>();
    if (GridWidget.SIMULATION.equals(gridWidget)) {
        instanceFieldsMap = getInstanceMap(complexDataObjects);
        simpleJavaTypeInstanceFieldsMap = getInstanceMap(simpleDataObjects);
        Set<String> dataObjectsInstancesName = new HashSet<>(visibleFacts.keySet());
        dataObjectsInstancesName.addAll(instanceFieldsMap.keySet());
        context.setDataObjectsInstancesName(dataObjectsInstancesName);
        Set<String> simpleJavaTypeInstancesName = new HashSet<>(simpleDataObjects.keySet());
        simpleJavaTypeInstancesName.addAll(simpleJavaTypeInstanceFieldsMap.keySet());
        context.getAbstractScesimGridModelByGridWidget(gridWidget).setSimpleJavaTypeInstancesName(simpleJavaTypeInstancesName);
    }
    // Update right panel
    TestToolsPresenterData testToolsPresenterData = new TestToolsPresenterData(complexDataObjects, simpleDataObjects, instanceFieldsMap, simpleJavaTypeInstanceFieldsMap, factModelTuple.getHiddenFacts(), propertiesToHide, gridWidget);
    testToolsPresenter.populateTestTools(testToolsPresenterData);
}
Also used : ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ExpressionElement(org.drools.scenariosimulation.api.model.ExpressionElement) ScenarioSimulationContext(org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext) AbstractScesimModel(org.drools.scenariosimulation.api.model.AbstractScesimModel) VALUE(org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE) Map(java.util.Map) AbstractScesimGridModel(org.drools.workbench.screens.scenariosimulation.client.models.AbstractScesimGridModel) ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) TestToolsPresenterData(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenterData) Set(java.util.Set) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) Collectors(java.util.stream.Collectors) TestToolsView(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsView) Objects(java.util.Objects) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) List(java.util.List) TreeMap(java.util.TreeMap) Collections(java.util.Collections) SortedMap(java.util.SortedMap) AbstractScesimData(org.drools.scenariosimulation.api.model.AbstractScesimData) TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) ArrayList(java.util.ArrayList) List(java.util.List) TestToolsPresenterData(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenterData) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashSet(java.util.HashSet)

Example 8 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class ScenarioSimulationEditorPresenter method setTestTools.

public void setTestTools(TestToolsView.Presenter presenter) {
    context.setTestToolsPresenter(presenter);
    presenter.setEventBus(eventBus);
    GridWidget gridWidget = scenarioBackgroundGridWidget.isSelected() ? GridWidget.BACKGROUND : GridWidget.SIMULATION;
    dataManagementStrategy.populateTestTools(presenter, context, gridWidget);
}
Also used : GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) ScenarioGridWidget(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridWidget)

Aggregations

GridWidget (org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget)8 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 SortedMap (java.util.SortedMap)3 TreeMap (java.util.TreeMap)3 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)3 FactModelTuple (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple)3 Test (org.junit.Test)3 EventBus (com.google.gwt.event.shared.EventBus)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 FactModelTree (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)2 Before (org.junit.Before)2 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1