Search in sources :

Example 6 with RequiredRole

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;
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) System(org.palladiosimulator.pcm.system.System) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) LinkedList(java.util.LinkedList) SystemFactoryImpl(org.palladiosimulator.pcm.system.impl.SystemFactoryImpl) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) Logger(org.slf4j.Logger) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Set(java.util.Set) Connector(org.palladiosimulator.pcm.core.composition.Connector) EList(org.eclipse.emf.common.util.EList) CompositionPrivacyFactory(org.palladiosimulator.pcm.compositionprivacy.CompositionPrivacyFactory) List(java.util.List) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) DataPrivacyLvl(org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) Repository(org.palladiosimulator.pcm.repository.Repository) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Example 7 with RequiredRole

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());
    }
}
Also used : OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Example 8 with RequiredRole

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;
}
Also used : OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Aggregations

RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)8 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)6 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)5 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)5 ArrayList (java.util.ArrayList)4 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)4 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)3 EObject (org.eclipse.emf.ecore.EObject)2 EReference (org.eclipse.emf.ecore.EReference)2 PalladioSelectEObjectDialog (org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog)2 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)2 ServiceEffectSpecification (org.palladiosimulator.pcm.seff.ServiceEffectSpecification)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 EList (org.eclipse.emf.common.util.EList)1