Search in sources :

Example 1 with AssociationDefinition

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

the class StoreAccountStorePlugin method postStart.

@Override
protected void postStart() {
    userGroupDtDefinition = Home.getApp().getDefinitionSpace().resolve(groupIdentityEntity, DtDefinition.class);
    mapperHelper = new AccountMapperHelper(userGroupDtDefinition, GroupProperty.class, groupToGroupAccountMappingStr).withMandatoryDestField(GroupProperty.id).withMandatoryDestField(GroupProperty.displayName).parseAttributeMapping();
    for (final AssociationDefinition association : Home.getApp().getDefinitionSpace().getAll(AssociationDefinition.class)) {
        if ((userGroupDtDefinition.equals(association.getAssociationNodeA().getDtDefinition()) && getUserDtDefinition().equals(association.getAssociationNodeB().getDtDefinition()))) {
            associationUserGroup = association;
            associationUserRoleName = association.getAssociationNodeB().getRole();
            associationGroupRoleName = association.getAssociationNodeA().getRole();
            break;
        } else if (userGroupDtDefinition.equals(association.getAssociationNodeB().getDtDefinition()) && getUserDtDefinition().equals(association.getAssociationNodeA().getDtDefinition())) {
            associationUserGroup = association;
            associationUserRoleName = association.getAssociationNodeA().getRole();
            associationGroupRoleName = association.getAssociationNodeB().getRole();
            break;
        }
    }
    Assertion.checkNotNull(associationUserGroup, "Association between User ({0}) and Group ({1}) not found", getUserDtDefinition().getClassSimpleName(), userGroupDtDefinition.getClassSimpleName());
    Assertion.checkState(associationUserGroup instanceof AssociationSimpleDefinition || associationUserGroup instanceof AssociationNNDefinition, "Association ({0}) between User and Group must be an AssociationSimpleDefinition or an AssociationNNDefinition", associationUserGroup.getName());
}
Also used : AssociationDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) AccountMapperHelper(io.vertigo.account.impl.account.AccountMapperHelper) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)

Aggregations

AccountMapperHelper (io.vertigo.account.impl.account.AccountMapperHelper)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 AssociationDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationDefinition)1 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)1 AssociationSimpleDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition)1