use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImpl method generateProcessForm.
@Override
public void generateProcessForm(Diagram diagram) {
try {
LOGGER.finest("Generating form for process ");
final Definitions definitions = toDefinitions(diagram);
final Path path = diagram.getMetadata().getPath();
final BusinessProcessFormModel formModel = bpmnFormModelGenerator.generateProcessFormModel(definitions, path);
createFormForModel(formModel, Paths.convert(path));
} catch (Exception ex) {
LOGGER.severe("Error generating process form");
throw new RuntimeException(ex);
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImpl method generateAllForms.
@Override
public void generateAllForms(Diagram diagram) {
try {
LOGGER.finest("Generating all forms");
final Path path = diagram.getMetadata().getPath();
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
final Definitions definitions = toDefinitions(diagram);
final BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions, path);
createFormForModel(processFormModel, nioPath);
List<TaskFormModel> taskFormModels = bpmnFormModelGenerator.generateTaskFormModels(definitions, path);
for (TaskFormModel taskFormModel : taskFormModels) {
createFormForModel(taskFormModel, nioPath);
}
} catch (Exception ex) {
LOGGER.severe("Error generating all diagram forms");
throw new RuntimeException(ex);
} finally {
ioService.endBatch();
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImplTest method init.
@Before
public void init() throws Exception {
SimpleFileSystemProvider simpleFileSystemProvider = new SimpleFileSystemProvider();
simpleFileSystemProvider.forceAsDefault();
Definitions processDefinitions = BPMN2Utils.getDefinitions(FormDefinitionGeneratorImplTest.class.getResourceAsStream(PROCESS_PATH));
// Prepare BPMNFormModelGenerator
when(kieModuleService.resolveModule(any())).thenReturn(module);
when(module.getRootPath()).thenReturn(path);
when(moduleClassLoaderHelper.getModuleClassLoader(module)).thenReturn(moduleClassLoader);
when(moduleClassLoader.loadClass(anyString())).thenAnswer(invocation -> Object.class);
BPMNFormModelGenerator bpmnFormModelGenerator = spy(new BPMNFormModelGeneratorImpl(kieModuleService, moduleClassLoaderHelper));
FormModelHandlerManager formModelHandlerManager = new TestFormModelHandlerManager(kieModuleService, moduleClassLoaderHelper, new TestFieldManager());
BPMNFormGeneratorService<Path> bpmnFormGeneratorService = new BPMNVFSFormDefinitionGeneratorService(new TestFieldManager(), formModelHandlerManager, formFinderService, formDefinitionSerializer, ioService, commentedOptionFactory, synchronizationUtil);
generator = spy(new TestFormDefinitionGeneratorImpl(formGenerationModelProviders, ioService, bpmnFormModelGenerator, formDefinitionSerializer, bpmnFormGeneratorService, processDefinitions));
when(diagram.getMetadata()).thenReturn(metadata);
when(metadata.getPath()).thenReturn(diagramPath);
when(diagram.getGraph()).thenReturn(graph);
when(diagramPath.toURI()).thenReturn("default:///src/main/resources" + PROCESS_PATH);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshaller method marshall.
@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
LOG.debug("Starting diagram marshalling...");
Bpmn2Resource resource = createBpmn2Resource();
// we start converting from the root, then pull out the result
DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
Definitions definitions = definitionsConverter.toDefinitions();
resource.getContents().add(definitions);
LOG.debug("Diagram marshalling completed successfully.");
String outputString = renderToString(resource);
LOG.trace(outputString);
return outputString;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.
the class BaseDiagramMarshaller method unmarshall.
@Override
public Graph unmarshall(final Metadata metadata, final InputStream inputStream) throws IOException {
LOG.debug("Starting diagram unmarshalling...");
// No rule checking for marshalling/unmarshalling, current jbpm designer marshallers should do it for us.
final Bpmn2UnMarshaller parser = new Bpmn2UnMarshaller(bpmnGraphBuilderFactory, definitionManager, factoryManager, rulesManager, oryxManager, graphCommandManager, commandFactory, indexBuilder, getDiagramDefinitionSetClass(), getDiagramDefinitionClass());
Graph result = null;
try {
// Unmarshall the diagram definition
final Definitions definitions = parseDefinitions(inputStream);
parser.setProfile(new DefaultProfileImpl());
result = parser.unmarshall(definitions, getPreProcessingData(metadata));
// Update diagram's settings.
updateRootUUID(metadata, result);
} catch (IOException e) {
LOG.error("Error unmarshalling file.", e);
}
LOG.debug("Diagram unmarshalling finished successfully.");
return result;
}
Aggregations