use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools by kiegroup.
the class ActionWorkItemCol52 method diff.
@Override
public List<BaseColumnFieldDiff> diff(BaseColumn otherColumn) {
if (otherColumn == null) {
return null;
}
List<BaseColumnFieldDiff> result = super.diff(otherColumn);
ActionWorkItemCol52 other = (ActionWorkItemCol52) otherColumn;
// Field: Work Item definition.
final PortableWorkDefinition thisDefinition = this.getWorkItemDefinition();
final PortableWorkDefinition otherDefinition = other.getWorkItemDefinition();
// for differences between the two WorkItemDefinitions
if (thisDefinition == null && otherDefinition == null) {
return result;
} else if (thisDefinition != null && otherDefinition == null) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_NAME, thisDefinition.getName(), null));
for (PortableParameterDefinition parameter : thisDefinition.getParameters()) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, parameter.getName(), null));
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, parameter.asString(), null));
}
} else if (thisDefinition == null && otherDefinition != null) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_NAME, null, otherDefinition.getName()));
for (PortableParameterDefinition parameter : otherDefinition.getParameters()) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, null, parameter.getName()));
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, null, parameter.asString()));
}
} else {
if (!thisDefinition.getName().equals(otherDefinition.getName())) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_NAME, thisDefinition.getName(), otherDefinition.getName()));
}
final List<String> thisDefinitionParameterNames = Arrays.asList(thisDefinition.getParameterNames());
final List<String> otherDefinitionParameterNames = Arrays.asList(otherDefinition.getParameterNames());
// Some Parameters have been deleted
final List<String> parameterNamesDeleted = new ArrayList<String>(thisDefinitionParameterNames);
parameterNamesDeleted.removeAll(otherDefinitionParameterNames);
for (String parameterName : parameterNamesDeleted) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, thisDefinition.getParameter(parameterName).getName(), null));
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, thisDefinition.getParameter(parameterName).asString(), null));
}
// Some Parameters have been added
final List<String> parameterNamesAdded = new ArrayList<String>(otherDefinitionParameterNames);
parameterNamesAdded.removeAll(thisDefinitionParameterNames);
for (String parameterName : parameterNamesAdded) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, null, otherDefinition.getParameter(parameterName).getName()));
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, null, otherDefinition.getParameter(parameterName).asString()));
}
// Some Parameters have been updated
final List<String> parameterNamesUpdated = new ArrayList<String>(thisDefinitionParameterNames);
parameterNamesUpdated.retainAll(otherDefinitionParameterNames);
for (String parameterName : parameterNamesUpdated) {
boolean parameterNamesDiffer = false;
if (!isEqualOrNull(thisDefinition.getParameter(parameterName).getName(), otherDefinition.getParameter(parameterName).getName())) {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, thisDefinition.getParameter(parameterName).getName(), otherDefinition.getParameter(parameterName).getName()));
parameterNamesDiffer = true;
}
if (!isEqualOrNull(thisDefinition.getParameter(parameterName).asString(), otherDefinition.getParameter(parameterName).asString())) {
if (!parameterNamesDiffer) {
result.add(new WorkItemColumnParameterValueDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, thisDefinition.getParameter(parameterName).getName(), thisDefinition.getParameter(parameterName).asString(), otherDefinition.getParameter(parameterName).asString()));
} else {
result.add(new BaseColumnFieldDiffImpl(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, thisDefinition.getParameter(parameterName).asString(), otherDefinition.getParameter(parameterName).asString()));
}
}
}
}
return result;
}
use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project kie-wb-common by kiegroup.
the class WorkItemParametersWidget method setParameters.
public void setParameters(Collection<PortableParameterDefinition> parameters) {
this.clear();
this.parameters = sort(parameters);
for (PortableParameterDefinition ppd : this.parameters) {
WorkItemParameterWidget pw = WorkItemParameterWidgetFactory.getWidget(ppd, bindingProvider, isReadOnly);
add(pw);
}
}
use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools-wb by kiegroup.
the class WorkItemsEditorServiceImpl method convertWorkItemParameters.
private Set<PortableParameterDefinition> convertWorkItemParameters(final Set<ParameterDefinition> parameters) {
final Set<PortableParameterDefinition> pps = new HashSet<PortableParameterDefinition>();
for (ParameterDefinition pd : parameters) {
final DataType pdt = pd.getType();
PortableParameterDefinition ppd = null;
if (pdt instanceof BooleanDataType) {
ppd = new PortableBooleanParameterDefinition();
} else if (pdt instanceof FloatDataType) {
ppd = new PortableFloatParameterDefinition();
} else if (pdt instanceof IntegerDataType) {
ppd = new PortableIntegerParameterDefinition();
} else if (pdt instanceof ObjectDataType) {
ppd = new PortableObjectParameterDefinition();
final PortableObjectParameterDefinition oppd = (PortableObjectParameterDefinition) ppd;
final ObjectDataType odt = (ObjectDataType) pdt;
oppd.setClassName(odt.getClassName());
} else if (pd.getType() instanceof StringDataType) {
ppd = new PortableStringParameterDefinition();
}
if (ppd != null) {
ppd.setName(pd.getName());
pps.add(ppd);
}
}
return pps;
}
use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPluginTest method testSetWorkItem.
@Test
public void testSetWorkItem() throws Exception {
final String workItemKey = "workItem";
final PortableWorkDefinition workDefinition = mock(PortableWorkDefinition.class);
final PortableParameterDefinition parameterDefinition = mock(PortableParameterDefinition.class);
final ActionWorkItemSetFieldPlugin.WorkItemParameter parameter = mock(ActionWorkItemSetFieldPlugin.WorkItemParameter.class);
final HashMap<String, ActionWorkItemSetFieldPlugin.WorkItemParameter> workItems = new HashMap<String, ActionWorkItemSetFieldPlugin.WorkItemParameter>() {
{
put(workItemKey, parameter);
}
};
final List<ActionInsertFactCol52> actions = new ArrayList<ActionInsertFactCol52>() {
{
add(mock(ActionInsertFactCol52.class));
}
};
doReturn(model).when(presenter).getModel();
doReturn(actions).when(model).getActionCols();
doReturn("workName").when(workDefinition).getName();
doReturn("parameterName").when(parameterDefinition).getName();
doReturn("parameterClassName").when(parameterDefinition).getClassName();
doReturn(workItems).when(plugin).getWorkItems();
doReturn(workDefinition).when(parameter).getWorkDefinition();
doReturn(parameterDefinition).when(parameter).getWorkParameterDefinition();
plugin.setWorkItem(workItemKey);
assertEquals(workItemKey, plugin.getWorkItem());
verify(editingWrapper).setWorkItemName("workName");
verify(editingWrapper).setWorkItemResultParameterName("parameterName");
verify(editingWrapper).setParameterClassName("parameterClassName");
verify(plugin).fireChangeEvent(workItemPage);
}
use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPluginTest method firstFakeWorkItem.
private ActionWorkItemCol52 firstFakeWorkItem() {
final ActionWorkItemCol52 workItemCol52 = new ActionWorkItemCol52();
final PortableWorkDefinition portableWorkDefinition = new PortableWorkDefinition();
final PortableParameterDefinition portableStringParameterDefinition = new PortableStringParameterDefinition();
portableStringParameterDefinition.setName("StringResult");
portableWorkDefinition.setResults(Collections.singleton(portableStringParameterDefinition));
portableWorkDefinition.setName("StringWorkItemName");
portableWorkDefinition.setDisplayName("StringWorkItemDisplayName");
workItemCol52.setWorkItemDefinition(portableWorkDefinition);
return workItemCol52;
}
Aggregations