use of io.vertigo.util.ListBuilder 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);
});
}
use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.
the class BerkeleyKVStoreManagerTest method testFindAll.
@Test
public void testFindAll() {
final List<Flower> flowers = new ListBuilder<Flower>().add(buildFlower("daisy", 60)).add(buildFlower("tulip", 100)).add(buildFlower("rose", 110)).add(buildFlower("lily", 120)).add(buildFlower("orchid", 200)).build();
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final List<Flower> foundFlowers = kvStoreManager.findAll("flowers", 0, null, Flower.class);
Assert.assertTrue(foundFlowers.isEmpty());
int i = 0;
for (final Flower flower : flowers) {
final String id = "" + i++;
kvStoreManager.put("flowers", id, flower);
}
final List<Flower> foundFlowers2 = kvStoreManager.findAll("flowers", 0, 1000, Flower.class);
Assert.assertEquals(flowers.size(), foundFlowers2.size());
transaction.commit();
}
}
use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.
the class LocaleManagerImpl method createLocales.
private static List<Locale> createLocales(final String locales) {
final ListBuilder<Locale> listBuilder = new ListBuilder<>();
// Liste des variables utilisées dans la boucle
String language;
String country;
String variant;
for (final String locale : locales.split(",")) {
final String[] loc = locale.trim().split("_");
Assertion.checkArgument(loc.length > 0, "Locale specifiée vide");
language = loc[0];
country = loc.length > 1 ? loc[1] : "";
variant = loc.length > 2 ? loc[2] : "";
listBuilder.add(new Locale(language, country, variant));
}
return listBuilder.unmodifiable().build();
}
use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.
the class Studio method definitionTypes.
private List<DefinitionTypeModel> definitionTypes() {
final ListBuilder<DefinitionTypeModel> listBuilder = new ListBuilder<>();
for (final Class<? extends Definition> definitionClass : app.getDefinitionSpace().getAllTypes()) {
final DefinitionTypeModel definitionTypeModel = new DefinitionTypeModel(definitionClass, app.getDefinitionSpace().getAll(definitionClass));
listBuilder.add(definitionTypeModel);
}
return listBuilder.unmodifiable().build();
}
Aggregations