use of org.palladiosimulator.pcm.repository.RequiredRole 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.RequiredRole 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());
}
}
use of org.palladiosimulator.pcm.repository.RequiredRole in project iobserve-analysis by research-iobserve.
the class SystemGeneration method generateNewAC.
/*
*
*/
private AssemblyContext generateNewAC(final String namePrefix) {
final int randomInt = ThreadLocalRandom.current().nextInt(this.components.length);
final RepositoryComponent randComponent = this.components[randomInt];
final AssemblyContext newAC = SystemGeneration.COMPOSITION_PRIVACY_FACTORY.createAssemblyContextPrivacy();
newAC.setEntityName(namePrefix + "_AC_" + randComponent.getEntityName());
newAC.setEncapsulatedComponent__AssemblyContext(randComponent);
newAC.setParentStructure__AssemblyContext(this.system);
this.system.getAssemblyContexts__ComposedStructure().add(newAC);
this.unconnectedAssemblyContextes.add(newAC);
final EList<ProvidedRole> provRoles = randComponent.getProvidedRoles_InterfaceProvidingEntity();
this.connectProvidedInterfaces(newAC, provRoles);
final EList<RequiredRole> requRoles = randComponent.getRequiredRoles_InterfaceRequiringEntity();
this.connectRequiredInterfaces(newAC, requRoles);
return newAC;
}
Aggregations