use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.
the class ProcessCompensationRefProvider method getSelectorData.
@Override
@SuppressWarnings("unchecked")
public SelectorData getSelectorData(FormRenderingContext context) {
final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
final String rootUUID = diagram.getMetadata().getCanvasRootUUID();
final Node<?, ? extends Edge> selectedNode = getSelectedNode(diagram, sessionManager.getCurrentSession());
final Map<Object, String> values = new TreeMap<>(SafeComparator.TO_STRING_COMPARATOR);
if (selectedNode != null) {
Node<?, ? extends Edge> currentNode = selectedNode;
final List<Node> compensableNodes = new ArrayList<>();
Node<?, ? extends Edge> parentNode;
int levels = 0;
do {
parentNode = GraphUtils.getParent(currentNode).asNode();
compensableNodes.addAll(getCompensableNodes(parentNode));
if (rootUUID.equals(parentNode.getUUID())) {
levels = 2;
} else if (isSubProcess(parentNode)) {
currentNode = parentNode;
levels++;
} else if (isLane(parentNode)) {
currentNode = parentNode;
}
} while (levels < 2);
compensableNodes.stream().map(node -> buildPair(node.getUUID(), (BPMNDefinition) (((View) node.getContent()).getDefinition()))).forEach(pair -> values.put(pair.getK1(), pair.getK2()));
ActivityRef currentActivityRef = null;
if (isEndCompensationEvent(selectedNode)) {
currentActivityRef = ((EndCompensationEvent) ((View) selectedNode.getContent()).getDefinition()).getExecutionSet().getActivityRef();
} else if (isIntermediateCompensationEventThrowing(selectedNode)) {
currentActivityRef = ((IntermediateCompensationEventThrowing) ((View) selectedNode.getContent()).getDefinition()).getExecutionSet().getActivityRef();
}
if (currentActivityRef != null && !isEmpty(currentActivityRef.getValue()) && !values.containsKey(currentActivityRef.getValue())) {
Node configured = diagram.getGraph().getNode(currentActivityRef.getValue());
if (configured != null) {
Pair<Object, String> pair = buildPair(configured.getUUID(), (BPMNDefinition) ((View) configured.getContent()).getDefinition());
values.put(pair.getK1(), pair.getK2());
}
}
}
return new SelectorData(values, null);
}
use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.
the class BeanPropertiesProvider method getSelectorData.
@Override
public SelectorData getSelectorData(FormRenderingContext context) {
HashMap<String, String> values = new HashMap<>();
if (context instanceof FormEditorRenderingContext && context.getParentContext() != null) {
if (context.getParentContext().getModel() instanceof MultipleSubFormFieldDefinition) {
FormEditorRenderingContext editorContext = (FormEditorRenderingContext) context;
if (context.getParentContext() != null) {
MultipleSubFormFieldDefinition subForm = (MultipleSubFormFieldDefinition) context.getParentContext().getModel();
Path path = editorContext.getFormPath();
String typeName = subForm.getStandaloneClassName();
final TableColumnMeta currentMeta = (TableColumnMeta) context.getModel();
Set<String> unavailableProperties = subForm.getColumnMetas().stream().map(TableColumnMeta::getProperty).collect(Collectors.toSet());
if (currentMeta != null && !StringUtils.isEmpty(currentMeta.getProperty())) {
unavailableProperties.remove(currentMeta.getProperty());
}
modelFinderService.getModel(typeName, path).getProperties().stream().filter(property -> !unavailableProperties.contains(property.getName())).forEachOrdered(property -> values.put(property.getName(), property.getName()));
}
}
}
return new SelectorData(values, null);
}
use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.
the class RuleFlowGroupFormProviderTest method testGroupWithSameProject.
@Test
public void testGroupWithSameProject() {
RuleFlowGroup group1 = new RuleFlowGroup("g1");
group1.setPathUri("default://main@MySpace/Project1/src/main/resources/com/myspace/project1/RulesFile.rdrl");
RuleFlowGroup group2 = new RuleFlowGroup("g1");
group2.setPathUri("default://main@MySpace/Project1/src/main/resources/com/myspace/RulesFile2.rdrl".replace('/', '\\'));
RuleFlowGroup group3 = new RuleFlowGroup("g1");
group3.setPathUri("default://main@MySpace/Project2/src/main/resources/com/myspace/project1/RulesFile.rdrl");
List<RuleFlowGroup> groups = Arrays.asList(group1, group2, group3);
when(dataProvider.getRuleFlowGroupNames()).thenReturn(groups);
FormRenderingContext context = mock(FormRenderingContext.class);
SelectorData<String> data = tested.getSelectorData(context);
Map<String, String> values = data.getValues();
assertNotNull(values);
assertEquals(1, values.size());
assertEquals("g1 [Project1, Project2]", values.get(group1.getName()));
verify(requestRuleFlowGroupDataEvent, times(1)).fire(any(RequestRuleFlowGroupDataEvent.class));
}
use of org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext in project kie-wb-common by kiegroup.
the class RuleFlowGroupFormProviderTest method testGetSelectorData.
@Test
@SuppressWarnings("unchecked")
public void testGetSelectorData() {
RuleFlowGroup group1 = new RuleFlowGroup("g1");
group1.setPathUri("default://main@MySpace/Project1/src/main/resources/com/myspace/project1/RulesFile.rdrl");
RuleFlowGroup group2 = new RuleFlowGroup("g2");
group2.setPathUri("default://main@MySpace/Project1/src/main/resources/com/myspace/RulesFile2.rdrl".replace('/', '\\'));
RuleFlowGroup group3 = new RuleFlowGroup("g1");
group3.setPathUri("default://main@MySpace/Project2/src/main/resources/com/myspace/project1/RulesFile.rdrl");
List<RuleFlowGroup> groups = Arrays.asList(group1, group2, group3);
when(dataProvider.getRuleFlowGroupNames()).thenReturn(groups);
FormRenderingContext context = mock(FormRenderingContext.class);
SelectorData data = tested.getSelectorData(context);
Map<String, String> values = data.getValues();
assertNotNull(values);
assertEquals(2, values.size());
assertEquals("g2 [Project1]", values.get(group2.getName()));
assertEquals("g1 [Project1, Project2]", values.get(group1.getName()));
verify(requestRuleFlowGroupDataEvent, times(1)).fire(any(RequestRuleFlowGroupDataEvent.class));
}
Aggregations