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);
}
}
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"));
}
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;
}
Aggregations