Search in sources :

Example 6 with AbstractScesimModel

use of org.drools.scenariosimulation.api.model.AbstractScesimModel in project drools-wb by kiegroup.

the class AbstractSelectedColumnCommand method manageCollectionProperty.

/**
 * @param context
 * @param selectedColumn
 * @param factName The name of the class to be used to retrieve the corresponding <code>FactModelTree</code>, i.e. without the <b>package</b>
 * @param columnIndex
 * @param fullPropertyPathElements This is the <code>List</code> of all the elements pointing to the final property (ex. Book.author.books)
 */
protected void manageCollectionProperty(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn, String factName, int columnIndex, List<String> fullPropertyPathElements) {
    final SortedMap<String, FactModelTree> dataObjectFieldsMap = context.getDataObjectFieldsMap();
    final FactModelTree factModelTree = dataObjectFieldsMap.get(factName);
    final Optional<AbstractScesimModel> selectedScenarioGridModel = context.getAbstractScesimGridModelByGridWidget(gridWidget).getAbstractScesimModel();
    if (!selectedScenarioGridModel.isPresent()) {
        throw new IllegalArgumentException("SelectedGrid not found");
    }
    final FactMapping factMapping = selectedScenarioGridModel.get().getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
    selectedColumn.setFactory(context.getCollectionEditorSingletonDOMElementFactory(gridWidget));
    if (factModelTree.isSimple()) {
        factMapping.setGenericTypes(factModelTree.getGenericTypeInfo(VALUE));
    } else {
        final FactModelTree nestedFactModelTree = navigateComplexObject(factModelTree, fullPropertyPathElements, dataObjectFieldsMap);
        factMapping.setGenericTypes(nestedFactModelTree.getGenericTypeInfo(fullPropertyPathElements.get(fullPropertyPathElements.size() - 1)));
    }
}
Also used : FactMapping(org.drools.scenariosimulation.api.model.FactMapping) AbstractScesimModel(org.drools.scenariosimulation.api.model.AbstractScesimModel) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)

Aggregations

AbstractScesimModel (org.drools.scenariosimulation.api.model.AbstractScesimModel)6 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)4 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 FactMappingValue (org.drools.scenariosimulation.api.model.FactMappingValue)2 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)2 Simulation (org.drools.scenariosimulation.api.model.Simulation)2 VALUE (org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE)2 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)2 AbstractScesimGridModel (org.drools.workbench.screens.scenariosimulation.client.models.AbstractScesimGridModel)2 Test (org.junit.Test)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ContextMenuEvent (com.google.gwt.event.dom.client.ContextMenuEvent)1 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 MouseWheelEvent (com.google.gwt.event.dom.client.MouseWheelEvent)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1