use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class SystemDataFactory method createAssemblyConnector.
/**
* Create an {@link AssemblyConnector} which links two {@link AssemblyContext}.
*
* @param name
* name of the connector
* @param providingContext
* providing {@link AssemblyContext}
* @param requiringContext
* requiring {@link AssemblyContext}
* @return returns a new {@link AssemblyConnector}
*/
public static AssemblyConnector createAssemblyConnector(final String name, final AssemblyContext providingContext, final AssemblyContext requiringContext) {
final AssemblyConnector connector = CompositionFactory.eINSTANCE.createAssemblyConnector();
final ProvidedRole providedRole = providingContext.getEncapsulatedComponent__AssemblyContext().getProvidedRoles_InterfaceProvidingEntity().get(0);
final RequiredRole requiredRole = requiringContext.getEncapsulatedComponent__AssemblyContext().getRequiredRoles_InterfaceRequiringEntity().get(0);
connector.setEntityName(name);
connector.setProvidedRole_AssemblyConnector((OperationProvidedRole) providedRole);
connector.setRequiredRole_AssemblyConnector((OperationRequiredRole) requiredRole);
connector.setProvidingAssemblyContext_AssemblyConnector(providingContext);
connector.setRequiringAssemblyContext_AssemblyConnector(requiringContext);
return connector;
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class RepositoryLookupModelProvider method initializeLookupMaps.
/**
* Initializing the maps for data access.
*/
private void initializeLookupMaps() {
this.opInfToProvInfMap = new HashMap<>();
this.opProvidedRoleMap = new HashMap<>();
this.operationInterfaceMap = new HashMap<>();
this.operationSignatureMap = new HashMap<>();
// loading OperationProvidedRoles and OperationInterfaces in dedicated maps
for (final RepositoryComponent nextRepoCmp : this.repositoryModel.getComponents__Repository()) {
if (nextRepoCmp instanceof BasicComponent) {
final BasicComponent basicCmp = (BasicComponent) nextRepoCmp;
for (final ProvidedRole providedRole : basicCmp.getProvidedRoles_InterfaceProvidingEntity()) {
if (providedRole instanceof OperationProvidedRole) {
final OperationProvidedRole opProvRole = (OperationProvidedRole) providedRole;
final OperationInterface opInterface = opProvRole.getProvidedInterface__OperationProvidedRole();
this.opInfToProvInfMap.put(opInterface.getId(), opProvRole.getId());
this.opProvidedRoleMap.put(opProvRole.getId(), opProvRole);
}
}
}
}
// loading OperationInterfaces and OperationSignatures in dedicated maps
for (final Interface nextInterface : this.repositoryModel.getInterfaces__Repository()) {
if (nextInterface instanceof OperationInterface) {
final OperationInterface opInf = (OperationInterface) nextInterface;
this.operationInterfaceMap.put(opInf.getId(), opInf);
for (final OperationSignature opSig : opInf.getSignatures__OperationInterface()) {
this.operationSignatureMap.put(opSig.getId(), opSig);
}
}
}
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class RepositoryLookupModelProvider method initializeLookupMaps.
/**
* Initializing the maps for data access.
*/
private void initializeLookupMaps() {
this.opInfToProvInfMap = new HashMap<>();
this.opProvidedRoleMap = new HashMap<>();
this.operationInterfaceMap = new HashMap<>();
this.operationSignatureMap = new HashMap<>();
// loading OperationProvidedRoles and OperationInterfaces in dedicated maps
for (final RepositoryComponent nextRepoCmp : this.repositoryModel.getComponents__Repository()) {
if (nextRepoCmp instanceof BasicComponent) {
final BasicComponent basicCmp = (BasicComponent) nextRepoCmp;
for (final ProvidedRole providedRole : basicCmp.getProvidedRoles_InterfaceProvidingEntity()) {
if (providedRole instanceof OperationProvidedRole) {
final OperationProvidedRole opProvRole = (OperationProvidedRole) providedRole;
final OperationInterface opInterface = opProvRole.getProvidedInterface__OperationProvidedRole();
this.opInfToProvInfMap.put(opInterface.getId(), opProvRole.getId());
this.opProvidedRoleMap.put(opProvRole.getId(), opProvRole);
}
}
}
}
// loading OperationInterfaces and OperationSignatures in dedicated maps
for (final Interface nextInterface : this.repositoryModel.getInterfaces__Repository()) {
if (nextInterface instanceof OperationInterface) {
final OperationInterface opInf = (OperationInterface) nextInterface;
this.operationInterfaceMap.put(opInf.getId(), opInf);
for (final OperationSignature opSig : opInf.getSignatures__OperationInterface()) {
this.operationSignatureMap.put(opSig.getId(), opSig);
}
}
}
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole 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;
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class SystemGeneration method removeAssemblyContext.
private void removeAssemblyContext(final AssemblyContext assemblyContext) {
boolean removed = this.system.getAssemblyContexts__ComposedStructure().remove(assemblyContext);
if (removed) {
for (final ProvidedRole provRole : assemblyContext.getEncapsulatedComponent__AssemblyContext().getProvidedRoles_InterfaceProvidingEntity()) {
if (!(provRole instanceof OperationProvidedRole)) {
continue;
}
final OperationProvidedRole provInterface = (OperationProvidedRole) provRole;
final String interfaceID = provInterface.getProvidedInterface__OperationProvidedRole().getId();
final boolean success = this.openProvidedInterfaces.get(interfaceID).remove(assemblyContext);
removed = removed && success;
}
for (final RequiredRole requRole : assemblyContext.getEncapsulatedComponent__AssemblyContext().getRequiredRoles_InterfaceRequiringEntity()) {
// Connect all providing interfaces!
if (!(requRole instanceof OperationRequiredRole)) {
continue;
}
final OperationRequiredRole reqInterface = (OperationRequiredRole) requRole;
final String interfaceID = reqInterface.getRequiredInterface__OperationRequiredRole().getId();
final boolean success = this.openRequiredInterfaces.get(interfaceID).remove(assemblyContext);
removed = removed && success;
}
}
if (!removed) {
SystemGeneration.LOGGER.error("Something went wrong during the removal of AssemblyContext: {}", assemblyContext.getId());
}
}
Aggregations