use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class SetHeaderCellValueCommand method recursivelyFindIsPropertyType.
protected boolean recursivelyFindIsPropertyType(ScenarioSimulationContext context, FactModelTree factModelTree, List<String> propertyNameElements) {
boolean toReturn = propertyNameElements.size() == 1 && (factModelTree.getSimpleProperties().containsKey(propertyNameElements.get(0)) || factModelTree.getExpandableProperties().containsKey(propertyNameElements.get(0)));
if (!toReturn && propertyNameElements.size() > 1) {
String propertyParent = propertyNameElements.get(0);
if (factModelTree.getExpandableProperties().containsKey(propertyParent)) {
List<String> nestedPropertyNameElements = propertyNameElements.subList(1, propertyNameElements.size());
String className = factModelTree.getExpandableProperties().get(propertyParent);
final FactModelTree nestedFactModelTree = context.getDataObjectFieldsMap().get(className);
toReturn = recursivelyFindIsPropertyType(context, nestedFactModelTree, nestedPropertyNameElements);
}
}
return toReturn;
}
use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class AbstractDMODataManagementStrategy method getFactModelTree.
/**
* Create a <code>FactModelTree</code> for a given <b>factName</b> populating it with the given
* <code>ModelField[]</code>
* @param factName
* @param superTypeMap
* @param modelFields
* @return
* @implNote For the moment being, due to current implementation of <b>DMO</b>, it it not possible to retrieve <b>all</b>
* the generic types of a class with more then one, but only the last one. So, for <code>Map</code>, the <b>key</b>
* will always be a <code>java.lang.String</code>
*/
public FactModelTree getFactModelTree(String factName, Map<String, String> superTypeMap, ModelField[] modelFields) {
Map<String, FactModelTree.PropertyTypeName> simpleProperties = new HashMap<>();
Map<String, List<String>> genericTypesMap = new HashMap<>();
String fullFactClassName = getFQCNByFactName(factName);
String factPackageName = packageName;
String factClassName = fullFactClassName;
if (fullFactClassName != null && fullFactClassName.contains(".")) {
factPackageName = fullFactClassName.substring(0, fullFactClassName.lastIndexOf('.'));
factClassName = fullFactClassName.substring(fullFactClassName.lastIndexOf('.') + 1);
}
if (ScenarioSimulationSharedUtils.isEnumCanonicalName(superTypeMap.get(factName))) {
simpleProperties.put(ConstantsHolder.VALUE, new FactModelTree.PropertyTypeName(fullFactClassName));
return getSimpleClassFactModelTree(factName, fullFactClassName);
}
for (ModelField modelField : modelFields) {
if (!modelField.getName().equals("this")) {
String className = defineClassNameField(modelField.getClassName(), superTypeMap);
simpleProperties.put(modelField.getName(), new FactModelTree.PropertyTypeName(className));
if (ScenarioSimulationSharedUtils.isCollectionOrMap(className)) {
populateGenericTypeMap(genericTypesMap, factName, modelField.getName(), ScenarioSimulationSharedUtils.isList(className));
}
}
}
return FactModelTree.ofDMO(factName, factPackageName, simpleProperties, genericTypesMap, factClassName);
}
Aggregations