public UUID exportDiagram(Diagram diagram, String kit, String taskId) throws Exception { JavaModelConverter converter = new JavaModelConverter(); DiagramXml diagramXml = converter.convertToXml(diagram); TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); String directoryPath = String.format("%s/trikKit%s/tasks/%s", PathConstants.STEPIC_PATH, kit, taskId); String targetPath = String.format( "%s/solutions/%s/%s", directoryPath, String.valueOf(diagramXml.getUuid()), taskId); File targetDirectory = new File(targetPath); targetDirectory.mkdirs(); new File(String.format("%s/%s", targetPath, PathConstants.PATH_TO_GRAPHICAL_PART)).mkdirs(); new File(String.format("%s/%s", targetPath, PathConstants.PATH_TO_LOGICAL_PART)).mkdirs(); new File(String.format("%s/%s", targetPath, PathConstants.PATH_TO_ROOT_ID)).mkdirs(); copyDefaultFiles(taskId, directoryPath, targetPath); exportDiagramXml(diagramXml, targetPath); exportRootId(diagramXml.getRootIdXml(), targetPath); return diagramXml.getUuid(); }
private void exportDiagramXml(DiagramXml diagramXml, String targetPath) throws Exception { for (DiagramElementXml elementXml : diagramXml.getDiagramElements()) { exportDiagramElement(elementXml, targetPath); } }