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)));
}
}
Aggregations