Search in sources :

Example 1 with DeploymentModel

use of io.github.edmm.model.DeploymentModel 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();
}
Also used : Path(java.nio.file.Path) DeploymentModel(io.github.edmm.model.DeploymentModel) PluginService(io.github.edmm.core.plugin.PluginService) TransformationService(io.github.edmm.core.transformation.TransformationService) File(java.io.File) TransformationContext(io.github.edmm.core.transformation.TransformationContext)

Example 2 with DeploymentModel

use of io.github.edmm.model.DeploymentModel in project winery by eclipse.

the class EdmmResource method checkModelSupport.

@GET
@Path("check-model-support")
@Produces(MediaType.APPLICATION_JSON)
public Response checkModelSupport() {
    EntityGraph graph = RestUtils.getEdmmEntityGraph(this.element, true);
    GraphNormalizer.normalize(graph);
    PluginService pluginService = PluginManager.getInstance().getPluginService();
    // getting the model from the graph
    DeploymentModel model = new DeploymentModel(UUID.randomUUID().toString(), graph);
    List<PluginSupportResult> result = pluginService.checkModelSupport(model);
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(result).build();
}
Also used : EntityGraph(io.github.edmm.core.parser.EntityGraph) DeploymentModel(io.github.edmm.model.DeploymentModel) PluginSupportResult(io.github.edmm.model.PluginSupportResult) PluginService(io.github.edmm.core.plugin.PluginService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

PluginService (io.github.edmm.core.plugin.PluginService)2 DeploymentModel (io.github.edmm.model.DeploymentModel)2 EntityGraph (io.github.edmm.core.parser.EntityGraph)1 TransformationContext (io.github.edmm.core.transformation.TransformationContext)1 TransformationService (io.github.edmm.core.transformation.TransformationService)1 PluginSupportResult (io.github.edmm.model.PluginSupportResult)1 File (java.io.File)1 Path (java.nio.file.Path)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1