use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.
the class GraphFactory method createModelGraph.
/*
* Build Graph Helpers
*/
private ModelGraph createModelGraph() {
final Map<String, DeploymentNode> servers = new HashMap<>();
final Map<String, ComponentNode> components = new HashMap<>();
// Build Servers Nodes
for (final ResourceContainerPrivacy resContainer : this.resourceContainers.values()) {
final DeploymentNode server = new DeploymentNode(resContainer.getId(), resContainer.getEntityName(), resContainer.getGeolocation());
servers.put(resContainer.getId(), server);
}
// Build Component Nodes
for (final AssemblyContext ac : this.assemblyContexts.values()) {
final DeploymentNode hostServer = servers.get(this.ac2rcMap.get(ac.getId()));
final DataPrivacyLvl acPrivacyLvl = this.assemblyContextPrivacyLvl.get(ac.getId());
final ComponentNode component = new ComponentNode(ac.getId(), ac.getEntityName(), acPrivacyLvl, hostServer, ac.getEncapsulatedComponent__AssemblyContext().getId(), this.assemblyID2allocID.get(ac.getId()));
hostServer.addComponent(component);
components.put(ac.getId(), component);
}
// Set Edges
for (final AssemblyConnectorPrivacy acp : this.assemblyConnectors.values()) {
final String provACID = acp.getProvidingAssemblyContext_AssemblyConnector().getId();
final String reqACID = acp.getRequiringAssemblyContext_AssemblyConnector().getId();
final ComponentNode provNode = components.get(provACID);
final ComponentNode reqNode = components.get(reqACID);
final ComponentEdge edge = new ComponentEdge(acp.getId(), acp.getEntityName(), provNode, reqNode, acp.getPrivacyLevel());
provNode.addCommunicationEdge(edge);
reqNode.addCommunicationEdge(edge);
}
return new ModelGraph(servers.values(), components.values(), this.modelProvider);
}
use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.
the class GraphFactory method extractAssemblyConnectors.
private void extractAssemblyConnectors(final org.palladiosimulator.pcm.system.System sysModel) {
final EList<Connector> newConnectors = sysModel.getConnectors__ComposedStructure();
for (final Connector connector : newConnectors) {
if (connector instanceof AssemblyConnectorPrivacy) {
final AssemblyConnectorPrivacy acp = (AssemblyConnectorPrivacy) connector;
this.assemblyConnectors.put(connector.getId(), acp);
}
}
}
use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.
the class GraphFactory method adaptPrivacyLvl.
private void adaptPrivacyLvl() {
final Collection<AssemblyConnectorPrivacy> acps = this.assemblyConnectors.values();
final Set<String> acs = new HashSet<>();
for (final AssemblyConnectorPrivacy acp : acps) {
final DataPrivacyLvl assemblyConnectorPrivacyLvl = acp.getPrivacyLevel();
final String providedACID = acp.getProvidingAssemblyContext_AssemblyConnector().getId();
final String requiredACID = acp.getRequiringAssemblyContext_AssemblyConnector().getId();
this.updatePrivacyLvl(acp, assemblyConnectorPrivacyLvl, providedACID);
this.updatePrivacyLvl(acp, assemblyConnectorPrivacyLvl, requiredACID);
acs.add(requiredACID);
acs.add(providedACID);
}
if (GraphFactory.LOGGER.isInfoEnabled()) {
GraphFactory.LOGGER.info("Individual Assembly Contexts found in Assembly Connectors: " + acs.size());
}
}
use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.
the class SystemGeneration method createAssemblyConnector.
/*
* This method creates an assembly connector between the given AssemblyContextes for the given
* interface.
*/
private AssemblyConnector createAssemblyConnector(final AssemblyContext requiringAC, final AssemblyContext providingAC, final String interfaceID) {
final AssemblyConnectorPrivacy connector = SystemGeneration.COMPOSITION_PRIVACY_FACTORY.createAssemblyConnectorPrivacy();
connector.setEntityName(requiringAC.getEntityName() + " -> " + providingAC.getEntityName());
final java.util.Optional<ProvidedRole> providedRole = providingAC.getEncapsulatedComponent__AssemblyContext().getProvidedRoles_InterfaceProvidingEntity().stream().filter(s -> this.matchingInterface(s, interfaceID)).findFirst();
final java.util.Optional<RequiredRole> requiredRole = requiringAC.getEncapsulatedComponent__AssemblyContext().getRequiredRoles_InterfaceRequiringEntity().stream().filter(s -> this.matchingInterface(s, interfaceID)).findFirst();
connector.setProvidingAssemblyContext_AssemblyConnector(providingAC);
connector.setRequiringAssemblyContext_AssemblyConnector(requiringAC);
connector.setProvidedRole_AssemblyConnector((OperationProvidedRole) providedRole.get());
connector.setRequiredRole_AssemblyConnector((OperationRequiredRole) requiredRole.get());
final float randFloat = ThreadLocalRandom.current().nextFloat();
if (randFloat < 0.15) {
connector.setPrivacyLevel(DataPrivacyLvl.PERSONAL);
} else if (randFloat < 0.50) {
connector.setPrivacyLevel(DataPrivacyLvl.DEPERSONALIZED);
} else {
connector.setPrivacyLevel(DataPrivacyLvl.ANONYMIZED);
}
this.system.getConnectors__ComposedStructure().add(connector);
this.unconnectedAssemblyContextes.remove(requiringAC);
this.unconnectedAssemblyContextes.remove(providingAC);
return connector;
}
Aggregations