Search in sources :

Example 1 with SetPropertyHeaderCommand

use of org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.SetPropertyHeaderCommand in project drools-wb by kiegroup.

the class ScenarioSimulationEventHandler method onEvent.

@Override
public void onEvent(SetPropertyHeaderEvent event) {
    if (context.getAbstractScesimGridModelByGridWidget(event.getGridWidget()).getSelectedColumn() == null) {
        return;
    }
    if (context.getAbstractScesimGridModelByGridWidget(event.getGridWidget()).isAlreadyAssignedProperty(event.getPropertyNameElements())) {
        String value;
        if (Objects.equals(FactMappingValueType.EXPRESSION, event.getFactMappingValueType())) {
            value = ConstantHolder.EXPRESSION;
        } else {
            value = String.join(".", event.getPropertyNameElements());
        }
        onEvent(new ScenarioNotificationEvent("Property \"" + value + "\" already assigned", NotificationEvent.NotificationType.ERROR));
        return;
    }
    context.getStatus().setFullPackage(event.getFullPackage());
    context.getStatus().setClassName(event.getFactType());
    context.getStatus().setPropertyNameElements(event.getPropertyNameElements());
    context.getStatus().setValueClassName(event.getValueClassName());
    context.getStatus().setImportPrefix(event.getImportPrefix());
    if (isSameFactProperty(event.getGridWidget(), event.getPropertyNameElements(), event.getFactMappingValueType()) && isSameSelectedColumnType(event.getGridWidget(), event.getValueClassName())) {
        return;
    } else {
        if (isSelectedColumnEmpty(event.getGridWidget())) {
            commonExecution(new SetPropertyHeaderCommand(event.getGridWidget(), event.getFactMappingValueType()), true);
        } else {
            if (isSameSelectedColumnType(event.getGridWidget(), event.getValueClassName()) && !ScenarioSimulationSharedUtils.isCollectionOrMap(event.getValueClassName())) {
                showPreserveDeletePopup(event);
            } else {
                showDeletePopup(event);
            }
        }
    }
}
Also used : SetPropertyHeaderCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.SetPropertyHeaderCommand) ScenarioNotificationEvent(org.drools.workbench.screens.scenariosimulation.client.events.ScenarioNotificationEvent)

Aggregations

SetPropertyHeaderCommand (org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.SetPropertyHeaderCommand)1 ScenarioNotificationEvent (org.drools.workbench.screens.scenariosimulation.client.events.ScenarioNotificationEvent)1