use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImpl method constructContent.
@Override
protected TestScenarioModelContent constructContent(Path path, Overview overview) {
final Scenario scenario = load(path);
final String packageName = moduleService.resolvePackage(path).getPackageName();
final PackageDataModelOracle dataModelOracle = getDataModel(path);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
final Set<String> usedFullyQualifiedClassNames = getUsedFullyQualifiedClassNames(scenario, dataModelOracle);
DataModelOracleUtilities.populateDataModel(dataModelOracle, dataModel, usedFullyQualifiedClassNames);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new TestScenarioModelContent(scenario, overview, packageName, dataModel);
}
use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.
the class WorkItemsEditorServiceImpl method constructContent.
@Override
protected WorkItemsModelContent constructContent(Path path, Overview overview) {
final String definition = load(path);
final List<String> workItemImages = loadWorkItemImages(path);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new WorkItemsModelContent(definition, overview, workItemImages);
}
use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method constructContent.
@Override
protected GuidedDecisionTableEditorContent constructContent(Path path, Overview overview) {
final GuidedDecisionTable52 model = load(path);
final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
// Get FQCN's used by model
final GuidedDecisionTableModelVisitor visitor = new GuidedDecisionTableModelVisitor(model);
final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
// Get FQCN's used by Globals
consumedFQCNs.addAll(oracle.getPackageGlobals().values());
// Get FQCN's of collections defined in project settings
// they can be used in From Collect expressions
consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(entry -> entry.getValue()).map(entry -> entry.getKey()).collect(Collectors.toSet()));
DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
final Set<PortableWorkDefinition> workItemDefinitions = workItemsService.loadWorkItemDefinitions(path);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dataModel);
}
use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImplTest method checkConstructContent.
@Test
public void checkConstructContent() {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
when(oracle.getModuleCollectionTypes()).thenReturn(new HashMap<String, Boolean>() {
{
put("java.util.List", true);
put("java.util.Set", true);
put("java.util.Collection", true);
put("java.util.UnknownCollection", false);
}
});
final Set<PortableWorkDefinition> workItemDefinitions = new HashSet<>();
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable.gdst");
when(dataModelService.getDataModel(eq(path))).thenReturn(oracle);
when(workItemsService.loadWorkItemDefinitions(eq(path))).thenReturn(workItemDefinitions);
final GuidedDecisionTableEditorContent content = service.constructContent(path, overview);
verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
assertNotNull(content.getModel());
assertNotNull(content.getDataModel());
assertNotNull(content.getWorkItemDefinitions());
assertEquals(overview, content.getOverview());
assertEquals(3, content.getDataModel().getCollectionTypes().size());
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Collection"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.List"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Set"));
}
use of org.uberfire.workbench.events.ResourceOpenedEvent in project drools-wb by kiegroup.
the class GlobalsEditorServiceImpl method constructContent.
@Override
protected GlobalsEditorContent constructContent(Path path, Overview overview) {
// De-serialize model
final GlobalsModel model = load(path);
final ModuleDataModelOracle oracle = dataModelService.getModuleDataModel(path);
final String[] fullyQualifiedClassNames = new String[oracle.getModuleModelFields().size()];
oracle.getModuleModelFields().keySet().toArray(fullyQualifiedClassNames);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GlobalsEditorContent(model, overview, Arrays.asList(fullyQualifiedClassNames));
}
Aggregations