Search in sources :

Example 1 with DtListURIForSimpleAssociation

use of io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation in project vertigo by KleeGroup.

the class DtObjectUtil method createDtListURIForSimpleAssociation.

/**
 * Récupération d'une URI de Collection à partir d'un dto
 * @param entity the entity
 * @param associationDefinitionName Nom de l'association
 * @param roleName Nom du role
 * @return URI de la collection référencée.
 */
public static DtListURIForSimpleAssociation createDtListURIForSimpleAssociation(final Entity entity, final String associationDefinitionName, final String roleName) {
    Assertion.checkNotNull(associationDefinitionName);
    Assertion.checkNotNull(roleName);
    Assertion.checkNotNull(entity);
    // -----
    final AssociationSimpleDefinition associationDefinition = Home.getApp().getDefinitionSpace().resolve(associationDefinitionName, AssociationSimpleDefinition.class);
    return new DtListURIForSimpleAssociation(associationDefinition, entity.getURI(), roleName);
}
Also used : AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) DtListURIForSimpleAssociation(io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation)

Example 2 with DtListURIForSimpleAssociation

use of io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation in project vertigo by KleeGroup.

the class StoreAccountStorePlugin method getAccountURIs.

/**
 * {@inheritDoc}
 */
@Override
public Set<URI<Account>> getAccountURIs(final URI<AccountGroup> groupURI) {
    final DtListURI userDtListURI;
    if (associationUserGroup instanceof AssociationSimpleDefinition) {
        userDtListURI = new DtListURIForSimpleAssociation((AssociationSimpleDefinition) associationUserGroup, groupURI, associationUserRoleName);
    } else {
        // autres cas éliminés par assertion dans le postStart
        Assertion.checkArgument(associationUserGroup instanceof AssociationNNDefinition, "Association ({0}) between User and Group must be an AssociationSimpleDefinition or an AssociationNNDefinition", associationUserGroup.getName());
        userDtListURI = new DtListURIForNNAssociation((AssociationNNDefinition) associationUserGroup, groupURI, associationUserRoleName);
    }
    // -----
    final DtList<? extends Entity> result = Home.getApp().getComponentSpace().resolve(StoreManager.class).getDataStore().findAll(userDtListURI);
    return result.stream().map(userEntity -> userToAccount(userEntity).getURI()).collect(Collectors.toSet());
}
Also used : AbstractAccountStorePlugin(io.vertigo.account.plugins.account.store.AbstractAccountStorePlugin) DtListURIForNNAssociation(io.vertigo.dynamo.domain.metamodel.association.DtListURIForNNAssociation) DtField(io.vertigo.dynamo.domain.metamodel.DtField) URI(io.vertigo.dynamo.domain.model.URI) Criteria(io.vertigo.dynamo.criteria.Criteria) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) StoreManager(io.vertigo.dynamo.store.StoreManager) Criterions(io.vertigo.dynamo.criteria.Criterions) DtListURIForSimpleAssociation(io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation) Assertion(io.vertigo.lang.Assertion) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition) Named(javax.inject.Named) AccountMapperHelper(io.vertigo.account.impl.account.AccountMapperHelper) AccountGroup(io.vertigo.account.account.AccountGroup) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Set(java.util.Set) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtList(io.vertigo.dynamo.domain.model.DtList) Collectors(java.util.stream.Collectors) VFile(io.vertigo.dynamo.file.model.VFile) AccountStorePlugin(io.vertigo.account.impl.account.AccountStorePlugin) Entity(io.vertigo.dynamo.domain.model.Entity) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) Account(io.vertigo.account.account.Account) AssociationDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationDefinition) Optional(java.util.Optional) Collections(java.util.Collections) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForNNAssociation(io.vertigo.dynamo.domain.metamodel.association.DtListURIForNNAssociation) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) DtListURIForSimpleAssociation(io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)

Aggregations

AssociationSimpleDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition)2 DtListURIForSimpleAssociation (io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation)2 Account (io.vertigo.account.account.Account)1 AccountGroup (io.vertigo.account.account.AccountGroup)1 AccountMapperHelper (io.vertigo.account.impl.account.AccountMapperHelper)1 AccountStorePlugin (io.vertigo.account.impl.account.AccountStorePlugin)1 AbstractAccountStorePlugin (io.vertigo.account.plugins.account.store.AbstractAccountStorePlugin)1 Home (io.vertigo.app.Home)1 Criteria (io.vertigo.dynamo.criteria.Criteria)1 Criterions (io.vertigo.dynamo.criteria.Criterions)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 DtField (io.vertigo.dynamo.domain.metamodel.DtField)1 AssociationDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationDefinition)1 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)1 DtListURIForNNAssociation (io.vertigo.dynamo.domain.metamodel.association.DtListURIForNNAssociation)1 DtList (io.vertigo.dynamo.domain.model.DtList)1 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)1 Entity (io.vertigo.dynamo.domain.model.Entity)1 URI (io.vertigo.dynamo.domain.model.URI)1 VFile (io.vertigo.dynamo.file.model.VFile)1