use of io.github.edmm.core.transformation.TransformationContext in project winery by eclipse.
the class TransformationManager method transform.
public File transform(EntityGraph entityGraph, String target, String wineryRepository) throws Exception {
PluginService pluginService = PluginManager.getInstance().getPluginService();
TransformationService transformationService = new TransformationService(pluginService);
// getting the model from the graph
DeploymentModel deploymentModel = new DeploymentModel(UUID.randomUUID().toString(), entityGraph);
// the paths of the artifacts or operation files start from the root directory
File sourceDirectory = Paths.get(wineryRepository).toFile();
File targetDirectory = Files.createTempDirectory(target + "-").toFile();
TransformationContext transformationContext = transformationService.createContext(deploymentModel, target, sourceDirectory, targetDirectory);
transformationService.start(transformationContext);
// throws an exception if the transformation wasn't successful
transformationContext.throwExceptionIfErrorState();
Path zipPath = Paths.get(System.getProperty("java.io.tmpdir")).resolve(target + ".zip");
ZipUtility.pack(targetDirectory.toPath(), zipPath);
return zipPath.toFile();
}
Aggregations