Search in sources :

Example 1 with VALUE

use of org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE in project drools-wb by kiegroup.

the class AbstractDataManagementStrategy method getPropertiesToHide.

/**
 * This method returns a <code>List</code> with the properties of a given <b>Type</b> (Fact, class, other dmn defined) instance,
 * to be hidden from the right panel for the selected column.
 * <p>
 * If click happen on an already assigned property, <b>all</b> all the properties of given type should be shown;
 * if, instead, click is on an unassigned property, the already assigned properties must be hidden.
 * (e.g. inside GIVEN there is an "Author" group; if clicking on "books" property header, this method returns  an <b>empty</b> <code>List</code>;
 * if click is on an unassigned property column, this method returns a <code>List</code>.
 * with all the <b>already assigned</b> Author's properties)
 * @param selectedColumn
 * @param abstractScesimGridModel
 * @return
 */
protected <T extends AbstractScesimModel<E>, E extends AbstractScesimData> List<List<String>> getPropertiesToHide(ScenarioGridColumn selectedColumn, AbstractScesimGridModel<T, E> abstractScesimGridModel) {
    List<List<String>> toReturn = new ArrayList<>();
    if (!selectedColumn.isPropertyAssigned()) {
        abstractScesimGridModel.getAbstractScesimModel().ifPresent(simulation -> {
            final ScesimModelDescriptor simulationDescriptor = simulation.getScesimModelDescriptor();
            List<ScenarioGridColumn> instanceColumns = abstractScesimGridModel.getInstanceScenarioGridColumns(selectedColumn);
            toReturn.addAll(instanceColumns.stream().filter(ScenarioGridColumn::isPropertyAssigned).map(instanceColumn -> abstractScesimGridModel.getColumns().indexOf(instanceColumn)).map(columnIndex -> {
                List<String> propertyNameElements = simulationDescriptor.getFactMappingByIndex(columnIndex).getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList());
                if (propertyNameElements.isEmpty()) {
                    propertyNameElements.add(VALUE);
                }
                return Collections.unmodifiableList(propertyNameElements);
            }).collect(Collectors.toList()));
        });
    }
    return toReturn;
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) 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) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)

Aggregations

ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Collectors (java.util.stream.Collectors)1 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)1 AbstractScesimModel (org.drools.scenariosimulation.api.model.AbstractScesimModel)1 ExpressionElement (org.drools.scenariosimulation.api.model.ExpressionElement)1 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)1 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)1 ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)1 VALUE (org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE)1 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)1 GridWidget (org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget)1