Search in sources :

Example 1 with ListBuilder

use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.

the class AnnotationWriter method writeSimpleAssociationAnnotation.

/**
 * Ectiture des annotations sur un DT_FIELD gérant une association.
 *
 * @param associationSimple Definition de l'association
 * @return Liste des lignes de code java à ajouter.
 */
List<String> writeSimpleAssociationAnnotation(final AssociationSimpleDefinition associationSimple) {
    final AssociationNode primaryNode = associationSimple.getPrimaryAssociationNode();
    final AssociationNode foreignNode = associationSimple.getForeignAssociationNode();
    final String primaryMultiplicity = AssociationUtil.getMultiplicity(primaryNode.isNotNull(), primaryNode.isMultiple());
    final String foreignMultiplipicity = AssociationUtil.getMultiplicity(foreignNode.isNotNull(), foreignNode.isMultiple());
    return new ListBuilder<String>().add("@" + Association.class.getCanonicalName() + "(").add(INDENT + "name = \"" + associationSimple.getName() + "\",").add(INDENT + "fkFieldName = \"" + associationSimple.getFKField().getName() + "\",").add(INDENT + "primaryDtDefinitionName = \"" + primaryNode.getDtDefinition().getName() + "\",").add(INDENT + "primaryIsNavigable = " + primaryNode.isNavigable() + ',').add(INDENT + "primaryRole = \"" + primaryNode.getRole() + "\",").add(INDENT + "primaryLabel = \"" + primaryNode.getLabel() + "\",").add(INDENT + "primaryMultiplicity = \"" + primaryMultiplicity + "\",").add(INDENT + "foreignDtDefinitionName = \"" + foreignNode.getDtDefinition().getName() + "\",").add(INDENT + "foreignIsNavigable = " + foreignNode.isNavigable() + ',').add(INDENT + "foreignRole = \"" + foreignNode.getRole() + "\",").add(INDENT + "foreignLabel = \"" + foreignNode.getLabel() + "\",").add(INDENT + "foreignMultiplicity = \"" + foreignMultiplipicity + "\")").build();
}
Also used : ListBuilder(io.vertigo.util.ListBuilder) AssociationNode(io.vertigo.dynamo.domain.metamodel.association.AssociationNode)

Example 2 with ListBuilder

use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.

the class AnnotationWriter method writeNNAssociationAnnotation.

/**
 * Ectiture des annotations sur un DT_FIELD gérant une association.
 *
 * @param associationNN Definition de l'association
 * @return Liste des lignes de code java à ajouter.
 */
List<String> writeNNAssociationAnnotation(final AssociationNNDefinition associationNN) {
    final AssociationNode nodeA = associationNN.getAssociationNodeA();
    final AssociationNode nodeB = associationNN.getAssociationNodeB();
    return new ListBuilder<String>().add("@" + AssociationNN.class.getCanonicalName() + "(").add(INDENT + "name = \"" + associationNN.getName() + "\",").add(INDENT + "tableName = \"" + associationNN.getTableName() + "\",").add(INDENT + "dtDefinitionA = \"" + nodeA.getDtDefinition().getName() + "\",").add(INDENT + "dtDefinitionB = \"" + nodeB.getDtDefinition().getName() + "\",").add(INDENT + "navigabilityA = " + nodeA.isNavigable() + ',').add(INDENT + "navigabilityB = " + nodeB.isNavigable() + ',').add(INDENT + "roleA = \"" + nodeA.getRole() + "\",").add(INDENT + "roleB = \"" + nodeB.getRole() + "\",").add(INDENT + "labelA = \"" + nodeA.getLabel() + "\",").add(INDENT + "labelB = \"" + nodeB.getLabel() + "\")").build();
}
Also used : ListBuilder(io.vertigo.util.ListBuilder) AssociationNode(io.vertigo.dynamo.domain.metamodel.association.AssociationNode)

Example 3 with ListBuilder

use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.

the class AccountDefinitionProvider method provideDefinitions.

/**
 * {@inheritDoc}
 */
@Override
public List<Definition> provideDefinitions(final DefinitionSpace definitionSpace) {
    final Domain domainAccountId = Domain.builder("DO_X_ACCOUNT_ID", DataType.String).build();
    final Domain domainAccountName = Domain.builder("DO_X_ACCOUNT_NAME", DataType.String).build();
    final Domain domainAccountEmail = Domain.builder("DO_X_ACCOUNT_EMAIL", DataType.String).build();
    final DtDefinition accountDtDefinition = DtDefinition.builder("DT_ACCOUNT").addIdField(ID, "id", domainAccountId).addDataField(DISPLAY_NAME, "displayName", domainAccountName, false, true).addDataField(EMAIL, "email", domainAccountEmail, false, true).withSortField(DISPLAY_NAME).withDisplayField(DISPLAY_NAME).build();
    final DtDefinition accountGroupDtDefinition = DtDefinition.builder("DT_ACCOUNT_GROUP").addIdField(ID, "id", domainAccountId).addDataField(DISPLAY_NAME, "displayName", domainAccountName, false, true).withSortField(DISPLAY_NAME).withDisplayField(DISPLAY_NAME).build();
    return new ListBuilder<Definition>().add(domainAccountId).add(domainAccountName).add(domainAccountEmail).add(accountDtDefinition).add(accountGroupDtDefinition).build();
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) ListBuilder(io.vertigo.util.ListBuilder) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 4 with ListBuilder

use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.

the class WebServiceManagerImpl method scanComponents.

/**
 * Scan WebServices as WebServiceDefinitions on all the components.
 * @param componentSpace ComponentSpace
 * @return Scanned webServiceDefinitions
 */
List<WebServiceDefinition> scanComponents(final ComponentSpace componentSpace) {
    final AopPlugin aopPlugin = Home.getApp().getConfig().getBootConfig().getAopPlugin();
    final ListBuilder<WebServiceDefinition> allWebServiceDefinitionListBuilder = new ListBuilder<>();
    // 1- We introspect all RestfulService class
    for (final String componentId : componentSpace.keySet()) {
        final Object component = componentSpace.resolve(componentId, Object.class);
        if (component instanceof WebServices) {
            final WebServices webServices = aopPlugin.unwrap(WebServices.class.cast(component));
            final List<WebServiceDefinition> webServiceDefinitions = webServiceScannerPlugin.scanWebService(webServices.getClass());
            allWebServiceDefinitionListBuilder.addAll(webServiceDefinitions);
        }
    }
    // 2- We sort by path, parameterized path should be after strict path
    return allWebServiceDefinitionListBuilder.sort(Comparator.comparing(WebServiceDefinition::getName)).unmodifiable().build();
}
Also used : WebServiceDefinition(io.vertigo.vega.webservice.metamodel.WebServiceDefinition) WebServices(io.vertigo.vega.webservice.WebServices) ListBuilder(io.vertigo.util.ListBuilder) AopPlugin(io.vertigo.core.component.AopPlugin)

Example 5 with ListBuilder

use of io.vertigo.util.ListBuilder in project vertigo by KleeGroup.

the class VegaFeatures method buildFeatures.

/**
 * {@inheritDoc}
 */
@Override
protected void buildFeatures() {
    final PluginConfigBuilder corsAllowerPluginConfigBuilder = PluginConfig.builder(CorsAllowerWebServiceHandlerPlugin.class);
    if (myOriginCORSFilter != null) {
        corsAllowerPluginConfigBuilder.addParam(Param.of("originCORSFilter", myOriginCORSFilter));
    }
    getModuleConfigBuilder().addComponent(WebServiceManager.class, WebServiceManagerImpl.class).addPlugin(AnnotationsWebServiceScannerPlugin.class).addComponent(SwaggerWebServices.class).addComponent(CatalogWebServices.class).addPlugin(ExceptionWebServiceHandlerPlugin.class).addPlugin(corsAllowerPluginConfigBuilder.build()).addPlugin(AnalyticsWebServiceHandlerPlugin.class).addPlugin(JsonConverterWebServiceHandlerPlugin.class);
    if (mySearchApiVersion != null) {
        getModuleConfigBuilder().addComponent(JsonEngine.class, GoogleJsonEngine.class, Param.of("searchApiVersion", mySearchApiVersion));
    } else {
        getModuleConfigBuilder().addComponent(JsonEngine.class, GoogleJsonEngine.class);
    }
    if (securityEnabled) {
        getModuleConfigBuilder().addPlugin(SessionInvalidateWebServiceHandlerPlugin.class).addPlugin(SessionWebServiceHandlerPlugin.class).addPlugin(SecurityWebServiceHandlerPlugin.class);
    }
    if (tokensEnabled) {
        getModuleConfigBuilder().addPlugin(ServerSideStateWebServiceHandlerPlugin.class).addPlugin(AccessTokenWebServiceHandlerPlugin.class).addPlugin(PaginatorAndSortWebServiceHandlerPlugin.class).addComponent(TokenManager.class, TokenManagerImpl.class, Param.of("collection", myTokens));
    }
    if (miscEnabled) {
        getModuleConfigBuilder().addPlugin(RateLimitingWebServiceHandlerPlugin.class);
    }
    if (myPort != null) {
        final ListBuilder<Param> params = new ListBuilder().add(Param.of("port", Integer.toString(myPort)));
        if (myApiPrefix != null) {
            params.add(Param.of("apiPrefix", myApiPrefix));
        }
        getModuleConfigBuilder().addPlugin(new PluginConfig(SparkJavaEmbeddedWebServerPlugin.class, params.build()));
    }
    getModuleConfigBuilder().addPlugin(ValidatorWebServiceHandlerPlugin.class).addPlugin(RestfulServiceWebServiceHandlerPlugin.class);
}
Also used : WebServiceManagerImpl(io.vertigo.vega.impl.webservice.WebServiceManagerImpl) SessionWebServiceHandlerPlugin(io.vertigo.vega.plugins.webservice.handler.SessionWebServiceHandlerPlugin) ExceptionWebServiceHandlerPlugin(io.vertigo.vega.plugins.webservice.handler.ExceptionWebServiceHandlerPlugin) SwaggerWebServices(io.vertigo.vega.impl.webservice.catalog.SwaggerWebServices) PaginatorAndSortWebServiceHandlerPlugin(io.vertigo.vega.plugins.webservice.handler.PaginatorAndSortWebServiceHandlerPlugin) ServerSideStateWebServiceHandlerPlugin(io.vertigo.vega.plugins.webservice.handler.ServerSideStateWebServiceHandlerPlugin) PluginConfigBuilder(io.vertigo.app.config.PluginConfigBuilder) PluginConfig(io.vertigo.app.config.PluginConfig) SparkJavaEmbeddedWebServerPlugin(io.vertigo.vega.plugins.webservice.webserver.sparkjava.SparkJavaEmbeddedWebServerPlugin) WebServiceManager(io.vertigo.vega.webservice.WebServiceManager) Param(io.vertigo.core.param.Param) ListBuilder(io.vertigo.util.ListBuilder) ValidatorWebServiceHandlerPlugin(io.vertigo.vega.plugins.webservice.handler.ValidatorWebServiceHandlerPlugin) AnalyticsWebServiceHandlerPlugin(io.vertigo.vega.plugins.webservice.handler.AnalyticsWebServiceHandlerPlugin)

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