Search in sources :

Example 6 with ListBuilder

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);
    });
}
Also used : AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Definition(io.vertigo.core.definition.Definition) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition) MapBuilder(io.vertigo.util.MapBuilder) ListBuilder(io.vertigo.util.ListBuilder) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) MdaResult(io.vertigo.studio.mda.MdaResult)

Example 7 with ListBuilder

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();
    }
}
Also used : Flower(io.vertigo.dynamo.kvstore.data.Flower) ListBuilder(io.vertigo.util.ListBuilder) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) AbstractKVStoreManagerTest(io.vertigo.dynamo.kvstore.AbstractKVStoreManagerTest) Test(org.junit.Test)

Example 8 with ListBuilder

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();
}
Also used : Locale(java.util.Locale) ListBuilder(io.vertigo.util.ListBuilder)

Example 9 with ListBuilder

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();
}
Also used : DefinitionTypeModel(io.vertigo.studio.ui.model.DefinitionTypeModel) ListBuilder(io.vertigo.util.ListBuilder)

Aggregations

ListBuilder (io.vertigo.util.ListBuilder)9 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)2 AssociationNode (io.vertigo.dynamo.domain.metamodel.association.AssociationNode)2 PluginConfig (io.vertigo.app.config.PluginConfig)1 PluginConfigBuilder (io.vertigo.app.config.PluginConfigBuilder)1 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)1 AopPlugin (io.vertigo.core.component.AopPlugin)1 Definition (io.vertigo.core.definition.Definition)1 Param (io.vertigo.core.param.Param)1 Domain (io.vertigo.dynamo.domain.metamodel.Domain)1 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)1 AssociationSimpleDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition)1 AbstractKVStoreManagerTest (io.vertigo.dynamo.kvstore.AbstractKVStoreManagerTest)1 Flower (io.vertigo.dynamo.kvstore.data.Flower)1 MdaResult (io.vertigo.studio.mda.MdaResult)1 DefinitionTypeModel (io.vertigo.studio.ui.model.DefinitionTypeModel)1 MapBuilder (io.vertigo.util.MapBuilder)1 WebServiceManagerImpl (io.vertigo.vega.impl.webservice.WebServiceManagerImpl)1 SwaggerWebServices (io.vertigo.vega.impl.webservice.catalog.SwaggerWebServices)1 AnalyticsWebServiceHandlerPlugin (io.vertigo.vega.plugins.webservice.handler.AnalyticsWebServiceHandlerPlugin)1