Search in sources :

Example 1 with SeparatedSecurityZone

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

the class UserRepresentationsBuilder method buildSeparatedSecurityZones.

private void buildSeparatedSecurityZones() {
    model.getSeparatedSecurityZones().clear();
    List<Aggregate> allAggregatesWithSecurityZone = resolvingHelper.resolveAllAggregates().stream().filter(agg -> agg.getSecurityZone() != null && !"".equals(agg.getSecurityZone())).collect(Collectors.toList());
    Map<String, List<Aggregate>> aggregatesPerSecurityZone = allAggregatesWithSecurityZone.stream().collect(Collectors.groupingBy(Aggregate::getSecurityZone));
    for (Entry<String, List<Aggregate>> entry : aggregatesPerSecurityZone.entrySet()) {
        SeparatedSecurityZone separatedSecurityZone = factory.createSeparatedSecurityZone();
        separatedSecurityZone.setName(entry.getKey());
        for (Aggregate aggregate : entry.getValue()) separatedSecurityZone.getNanoentities().addAll(nanoentityResolver.getAllNanoentities(aggregate));
        model.getSeparatedSecurityZones().add(separatedSecurityZone);
    }
}
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) SeparatedSecurityZone(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone)

Example 2 with SeparatedSecurityZone

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

the class UserRepresentationsBuilderTest method canGenerateSeparatedSecurityZonesFromCML.

@Test
public void canGenerateSeparatedSecurityZonesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-10.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(2, scModel.getSeparatedSecurityZones().size());
    SeparatedSecurityZone zoneA = scModel.getSeparatedSecurityZones().stream().filter(s -> s.getName().equals("ZoneA")).findFirst().get();
    SeparatedSecurityZone zoneB = scModel.getSeparatedSecurityZones().stream().filter(s -> s.getName().equals("ZoneB")).findFirst().get();
    assertNotNull(zoneA);
    assertNotNull(zoneB);
    assertEquals(2, zoneA.getNanoentities().size());
    assertEquals(1, zoneB.getNanoentities().size());
    assertTrue(zoneA.getNanoentities().contains("Customer.firstName"));
    assertTrue(zoneA.getNanoentities().contains("Contract.contractId"));
    assertTrue(zoneB.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) SeparatedSecurityZone(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 3 with SeparatedSecurityZone

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

the class UserRepresentationsExampleFactory method createSampleSeparatedSecurityZones.

private List<SeparatedSecurityZone> createSampleSeparatedSecurityZones() {
    List<SeparatedSecurityZone> separatedSecurityZones = Lists.newArrayList();
    if (allModelAttributes.size() > 0) {
        SeparatedSecurityZone exampleSeparatedSecurityZone = factory.createSeparatedSecurityZone();
        exampleSeparatedSecurityZone.setName("SeparatedSecurityZoneTemplate");
        exampleSeparatedSecurityZone.setDoc("/* Separated Security Zones 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. */");
        exampleSeparatedSecurityZone.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        exampleSeparatedSecurityZone.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        separatedSecurityZones.add(exampleSeparatedSecurityZone);
    }
    return separatedSecurityZones;
}
Also used : SeparatedSecurityZone(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone)

Aggregations

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