Search in sources :

Example 1 with Definition

use of io.vertigo.core.definition.Definition 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 2 with Definition

use of io.vertigo.core.definition.Definition in project vertigo by KleeGroup.

the class WebServiceDefinitionProvider method provideDefinitions.

/**
 * {@inheritDoc}
 */
@Override
public List<Definition> provideDefinitions(final DefinitionSpace definitionSpace) {
    Assertion.checkArgument(!definitionResourceConfigs.isEmpty(), "No definitionResource registered");
    // -----
    final List<Definition> webServiceDefinitions = new ArrayList<>();
    for (final DefinitionResourceConfig definitionResourceConfig : definitionResourceConfigs) {
        final String resourcePath = definitionResourceConfig.getPath();
        if (resourcePath.endsWith(".*")) {
            scanAndAddPackage(resourcePath.substring(0, resourcePath.length() - ".*".length()), webServiceDefinitions);
        } else {
            final Class<? extends WebServices> webServicesClass = ClassUtil.classForName(resourcePath, WebServices.class);
            webServiceDefinitions.addAll(scanWebServices(webServicesClass));
        }
    }
    Assertion.checkArgument(!webServiceDefinitions.isEmpty(), "No webService found by WebServiceDefinitionProvider");
    // ----
    return webServiceDefinitions;
}
Also used : DefinitionResourceConfig(io.vertigo.app.config.DefinitionResourceConfig) Definition(io.vertigo.core.definition.Definition) WebServiceDefinition(io.vertigo.vega.webservice.metamodel.WebServiceDefinition) ArrayList(java.util.ArrayList)

Aggregations

Definition (io.vertigo.core.definition.Definition)2 DefinitionResourceConfig (io.vertigo.app.config.DefinitionResourceConfig)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)1 AssociationSimpleDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition)1 MdaResult (io.vertigo.studio.mda.MdaResult)1 ListBuilder (io.vertigo.util.ListBuilder)1 MapBuilder (io.vertigo.util.MapBuilder)1 WebServiceDefinition (io.vertigo.vega.webservice.metamodel.WebServiceDefinition)1 ArrayList (java.util.ArrayList)1