Search in sources :

Example 1 with SecurityAccessGroup

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

the class UserRepresentationsBuilder method buildSecurityAccessGroups.

private void buildSecurityAccessGroups() {
    model.getSecurityAccessGroups().clear();
    List<Aggregate> allAggregatesWithSecurityAccessGroups = resolvingHelper.resolveAllAggregates().stream().filter(agg -> agg.getSecurityAccessGroup() != null && !"".equals(agg.getSecurityAccessGroup())).collect(Collectors.toList());
    Map<String, List<Aggregate>> aggregatesPerSecurityAccessGroup = allAggregatesWithSecurityAccessGroups.stream().collect(Collectors.groupingBy(Aggregate::getSecurityAccessGroup));
    for (Entry<String, List<Aggregate>> entry : aggregatesPerSecurityAccessGroup.entrySet()) {
        SecurityAccessGroup securityAccessGroup = factory.createSecurityAccessGroup();
        securityAccessGroup.setName(entry.getKey());
        for (Aggregate aggregate : entry.getValue()) securityAccessGroup.getNanoentities().addAll(nanoentityResolver.getAllNanoentities(aggregate));
        model.getSecurityAccessGroups().add(securityAccessGroup);
    }
}
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) List(java.util.List) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) SecurityAccessGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup)

Example 2 with SecurityAccessGroup

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

the class UserRepresentationsBuilderTest method canGenerateSecurityAccessGroupsFromCML.

@Test
public void canGenerateSecurityAccessGroupsFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-11.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(2, scModel.getSecurityAccessGroups().size());
    SecurityAccessGroup admin = scModel.getSecurityAccessGroups().stream().filter(s -> s.getName().equals("Admin")).findFirst().get();
    SecurityAccessGroup pub = scModel.getSecurityAccessGroups().stream().filter(s -> s.getName().equals("Public")).findFirst().get();
    assertNotNull(admin);
    assertNotNull(pub);
    assertEquals(2, admin.getNanoentities().size());
    assertEquals(1, pub.getNanoentities().size());
    assertTrue(admin.getNanoentities().contains("Customer.firstName"));
    assertTrue(admin.getNanoentities().contains("Contract.contractId"));
    assertTrue(pub.getNanoentities().contains("TestEntity.attribute1"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) SecurityAccessGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 3 with SecurityAccessGroup

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

the class UserRepresentationsExampleFactory method createSampleSecurityAccessGroups.

private List<SecurityAccessGroup> createSampleSecurityAccessGroups() {
    List<SecurityAccessGroup> securityAccessGroups = Lists.newArrayList();
    if (allModelAttributes.size() > 0) {
        SecurityAccessGroup exampleSecurityAccessGroup = factory.createSecurityAccessGroup();
        exampleSecurityAccessGroup.setName("SecurityAccessGroupTemplate");
        exampleSecurityAccessGroup.setDoc("/* Security Accress 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. */");
        exampleSecurityAccessGroup.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        exampleSecurityAccessGroup.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        securityAccessGroups.add(exampleSecurityAccessGroup);
    }
    return securityAccessGroups;
}
Also used : SecurityAccessGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup)

Aggregations

SecurityAccessGroup (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup)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 SeparatedSecurityZone (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone)1