use of io.vertigo.studio.mda.MdaResult in project vertigo by KleeGroup.
the class Studio method start.
/**
* Start method of the server
*/
public void start() {
Spark.exception(Exception.class, (e, request, response) -> {
response.status(500);
LOGGER.error("studio : error on render ", e);
response.body(e.getMessage());
});
Spark.get("/studio", (request, response) -> {
final MdaResult mdaResult = null;
return display(response, mdaResult);
});
Spark.get("/grammar", (request, response) -> {
final MdaResult mdaResult = null;
return grammar(response, mdaResult);
});
Spark.get("/studio/definitions/:definitionName", (request, response) -> {
final String defintionName = request.params(":definitionName");
final Map<String, Object> model = new MapBuilder<String, Object>().put("definition", getDefinition(defintionName)).build();
return render(response, "template/definition.ftl", model);
});
Spark.get("/generate", (request, response) -> {
final MdaResult mdaResult = generate();
return display(response, mdaResult);
});
Spark.get("/clean", (request, response) -> {
final MdaResult mdaResult = clean();
return display(response, mdaResult);
});
Spark.get("/graph", (request, response) -> {
final ListBuilder<Vertex> verticlesBuilder = new ListBuilder<>();
final ListBuilder<Definition> edgesBuilders = new ListBuilder<>();
edgesBuilders.addAll(app.getDefinitionSpace().getAll(DtDefinition.class));
for (final AssociationNNDefinition associationDefinition1 : app.getDefinitionSpace().getAll(AssociationNNDefinition.class)) {
verticlesBuilder.add(new Vertex(associationDefinition1.getAssociationNodeA().getDtDefinition(), associationDefinition1.getAssociationNodeB().getDtDefinition()));
}
for (final AssociationSimpleDefinition associationDefinition2 : app.getDefinitionSpace().getAll(AssociationSimpleDefinition.class)) {
verticlesBuilder.add(new Vertex(associationDefinition2.getAssociationNodeA().getDtDefinition(), associationDefinition2.getAssociationNodeB().getDtDefinition()));
}
// for (final Domain domain : app.getDefinitionSpace().getAll(Domain.class)) {
// // verticlesBuilder.add(new Vertex(domain.getFormatter(), domain));
// for (final DefinitionReference<ConstraintDefinition> constraintDefinitionRef : domain.getConstraintDefinitionRefs()) {
// verticlesBuilder.add(new Vertex(constraintDefinitionRef.get(), domain));
// }
// }
// edgesBuilders.addAll(app.getDefinitionSpace().getAll(ConstraintDefinition.class));
// edgesBuilders.addAll(app.getDefinitionSpace().getAll(Domain.class));
final Map<String, Object> model = new MapBuilder<String, Object>().put("edges", edgesBuilders.build()).put("verticles", verticlesBuilder.build()).build();
return render(response, "template/graph.ftl", model);
});
}
Aggregations