Search in sources :

Example 16 with AssociationSimpleDefinition

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

the class EAXmiTestParserAA method testAssoctationA1vBnv.

/**
 * Test d'une relation A1v - Bnv.
 */
@Test
public void testAssoctationA1vBnv() {
    final AssociationSimpleDefinition association = getAssociationSimpleDefinition("A_CHI_CHI_2");
    /* "0..1" */
    Assert.assertFalse(association.getAssociationNodeA().isMultiple());
    Assert.assertFalse(association.getAssociationNodeA().isNotNull());
    /* "0..*" */
    Assert.assertTrue(association.getAssociationNodeB().isMultiple());
    Assert.assertFalse(association.getAssociationNodeB().isNotNull());
    Assert.assertEquals("R2A", association.getAssociationNodeA().getRole());
    Assert.assertEquals("R2B", association.getAssociationNodeB().getRole());
    Assert.assertTrue(association.getAssociationNodeA().isNavigable());
    Assert.assertTrue(association.getAssociationNodeB().isNavigable());
}
Also used : AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) Test(org.junit.Test)

Example 17 with AssociationSimpleDefinition

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

the class EAXmiTestParserAA method testAssoctationA1Bnv.

/**
 * Test d'une relation A1 - Bnv.
 */
@Test
public void testAssoctationA1Bnv() {
    final AssociationSimpleDefinition association = getAssociationSimpleDefinition("A_CHI_CHI_1");
    Assert.assertNotNull(association);
    /* "0..1" */
    Assert.assertFalse(association.getAssociationNodeA().isMultiple());
    Assert.assertFalse(association.getAssociationNodeA().isNotNull());
    /* "0..*" */
    Assert.assertTrue(association.getAssociationNodeB().isMultiple());
    Assert.assertFalse(association.getAssociationNodeB().isNotNull());
    Assert.assertEquals("R1A", association.getAssociationNodeA().getRole());
    Assert.assertEquals("R1B", association.getAssociationNodeB().getRole());
    Assert.assertFalse(association.getAssociationNodeA().isNavigable());
    Assert.assertTrue(association.getAssociationNodeB().isNavigable());
}
Also used : AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) Test(org.junit.Test)

Example 18 with AssociationSimpleDefinition

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

the class EAXmiTestParserAA method testAssoctationAnvB1.

/**
 * Test d'une relation Anv - B1.
 */
@Test
public void testAssoctationAnvB1() {
    final AssociationSimpleDefinition association = getAssociationSimpleDefinition("A_CHI_CHI_5");
    /* "0..*" */
    Assert.assertTrue(association.getAssociationNodeA().isMultiple());
    Assert.assertFalse(association.getAssociationNodeA().isNotNull());
    /* "0..*" */
    Assert.assertFalse(association.getAssociationNodeB().isMultiple());
    Assert.assertFalse(association.getAssociationNodeB().isNotNull());
    Assert.assertEquals("R5A", association.getAssociationNodeA().getRole());
    Assert.assertEquals("R5B", association.getAssociationNodeB().getRole());
    Assert.assertTrue(association.getAssociationNodeA().isNavigable());
    Assert.assertFalse(association.getAssociationNodeB().isNavigable());
}
Also used : AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) Test(org.junit.Test)

Example 19 with AssociationSimpleDefinition

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

the class StoreAccountStorePlugin method getGroupURIs.

/**
 * {@inheritDoc}
 */
@Override
public Set<URI<AccountGroup>> getGroupURIs(final URI<Account> accountURI) {
    if (associationUserGroup instanceof AssociationSimpleDefinition) {
        // case 1 group per user
        final URI<Entity> userURI = new URI(getUserDtDefinition(), accountURI.getId());
        final Entity userEntity = storeManager.getDataStore().readOne(userURI);
        final Object fkValue = ((AssociationSimpleDefinition) associationUserGroup).getFKField().getDataAccessor().getValue(userEntity);
        final URI<AccountGroup> groupURI = new URI(userGroupDtDefinition, fkValue);
        return Collections.singleton(groupURI);
    }
    // case N group per user
    // other case checked in postStart by assertions
    Assertion.checkArgument(associationUserGroup instanceof AssociationNNDefinition, "Association ({0}) between User and Group must be an AssociationSimpleDefinition or an AssociationNNDefinition", associationUserGroup.getName());
    final DtListURI groupDtListURI = new DtListURIForNNAssociation((AssociationNNDefinition) associationUserGroup, accountURI, associationGroupRoleName);
    // -----
    final DtList<? extends Entity> result = Home.getApp().getComponentSpace().resolve(StoreManager.class).getDataStore().findAll(groupDtListURI);
    return result.stream().map(groupEntity -> groupToAccount(groupEntity).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) Entity(io.vertigo.dynamo.domain.model.Entity) AccountGroup(io.vertigo.account.account.AccountGroup) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForNNAssociation(io.vertigo.dynamo.domain.metamodel.association.DtListURIForNNAssociation) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)

Example 20 with AssociationSimpleDefinition

use of io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition 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)32 Test (org.junit.Test)24 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)7 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)5 AccountMapperHelper (io.vertigo.account.impl.account.AccountMapperHelper)3 DtField (io.vertigo.dynamo.domain.metamodel.DtField)3 AssociationDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationDefinition)3 DtListURIForSimpleAssociation (io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation)3 URI (io.vertigo.dynamo.domain.model.URI)3 Account (io.vertigo.account.account.Account)2 AccountGroup (io.vertigo.account.account.AccountGroup)2 AccountStorePlugin (io.vertigo.account.impl.account.AccountStorePlugin)2 AbstractAccountStorePlugin (io.vertigo.account.plugins.account.store.AbstractAccountStorePlugin)2 Home (io.vertigo.app.Home)2 Criteria (io.vertigo.dynamo.criteria.Criteria)2 Criterions (io.vertigo.dynamo.criteria.Criterions)2 DtListURIForNNAssociation (io.vertigo.dynamo.domain.metamodel.association.DtListURIForNNAssociation)2 DtList (io.vertigo.dynamo.domain.model.DtList)2 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)2 Entity (io.vertigo.dynamo.domain.model.Entity)2