Search in sources :

Example 1 with SharedOwnerGroup

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateSharedOwnerGroupsFromCML.

@Test
public void canGenerateSharedOwnerGroupsFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-3.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(1, scModel.getSharedOwnerGroups().size());
    SharedOwnerGroup ownerGroup = scModel.getSharedOwnerGroups().get(0);
    assertEquals("TeamA", ownerGroup.getName());
    assertEquals(1, ownerGroup.getNanoentities().size());
    assertEquals("TestEntity.attribute1", ownerGroup.getNanoentities().get(0));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) SharedOwnerGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 2 with SharedOwnerGroup

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilder method buildSharedOwnerGroups.

private void buildSharedOwnerGroups() {
    model.getSharedOwnerGroups().clear();
    List<Aggregate> allAggregatesWithOwner = resolvingHelper.resolveAllAggregates().stream().filter(agg -> agg.getOwner() != null).collect(Collectors.toList());
    if (allAggregatesWithOwner.isEmpty())
        return;
    Map<String, Set<String>> nanoentitiesPerOwner = Maps.newHashMap();
    for (Aggregate aggregate : allAggregatesWithOwner) {
        if (!nanoentitiesPerOwner.containsKey(aggregate.getOwner().getName()))
            nanoentitiesPerOwner.put(aggregate.getOwner().getName(), Sets.newHashSet());
        nanoentitiesPerOwner.get(aggregate.getOwner().getName()).addAll(nanoentityResolver.getAllNanoentities(aggregate));
    }
    for (Entry<String, Set<String>> entry : nanoentitiesPerOwner.entrySet()) {
        SharedOwnerGroup ownerGroup = factory.createSharedOwnerGroup();
        ownerGroup.setName(entry.getKey());
        ownerGroup.getNanoentities().addAll(entry.getValue());
        model.getSharedOwnerGroups().add(ownerGroup);
    }
    if (!model.getSharedOwnerGroups().isEmpty())
        model.getSharedOwnerGroups().get(0).setDoc("/* These shared owner groups are generated from the CML model. Note that they are overwritten each time you use the service cut generator! */");
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) PredefinedService(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService) SeparatedSecurityZone(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) Set(java.util.Set) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) BoundedContextType(org.contextmapper.dsl.contextMappingDSL.BoundedContextType) CMLModelObjectsResolvingHelper(org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper) List(java.util.List) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) NanoentityResolver(org.contextmapper.dsl.generator.servicecutter.input.nanoentities.NanoentityResolver) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) Map(java.util.Map) SecurityAccessGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup) Entry(java.util.Map.Entry) ServiceCutterConfigurationDSLFactory(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterConfigurationDSLFactory) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) SharedOwnerGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup) SharedOwnerGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup) Set(java.util.Set) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate)

Example 3 with SharedOwnerGroup

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsExampleFactory method createSampleSharedOwnerGroups.

private List<SharedOwnerGroup> createSampleSharedOwnerGroups() {
    List<SharedOwnerGroup> sharedOwnerGroups = Lists.newArrayList();
    if (allModelAttributes.size() > 0) {
        SharedOwnerGroup exampleSharedOwnerGroup = factory.createSharedOwnerGroup();
        exampleSharedOwnerGroup.setName("SharedOwnerGroupTemplate");
        exampleSharedOwnerGroup.setDoc("/* Shared Owner Groups cannot be derived from ContextMap. \n " + "* This is a template/example how you can define them. If you do not want to specify any, remove this block. */");
        exampleSharedOwnerGroup.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        exampleSharedOwnerGroup.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        sharedOwnerGroups.add(exampleSharedOwnerGroup);
    }
    return sharedOwnerGroups;
}
Also used : SharedOwnerGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup)

Aggregations

SharedOwnerGroup (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup)3 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)2 ServiceCutterUserRepresentationsModel (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel)2 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 CMLModelObjectsResolvingHelper (org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper)1 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)1 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)1 BoundedContextType (org.contextmapper.dsl.contextMappingDSL.BoundedContextType)1 UserRequirement (org.contextmapper.dsl.contextMappingDSL.UserRequirement)1 NanoentityResolver (org.contextmapper.dsl.generator.servicecutter.input.nanoentities.NanoentityResolver)1 UserRepresentationsBuilder (org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder)1 PredefinedService (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService)1 SecurityAccessGroup (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup)1