Search in sources :

Example 11 with RepositoryComponent

use of org.palladiosimulator.pcm.repository.RepositoryComponent 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);
            }
        }
    }
}
Also used : OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface)

Example 12 with RepositoryComponent

use of org.palladiosimulator.pcm.repository.RepositoryComponent 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)

Example 13 with RepositoryComponent

use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.

the class SystemModification method modifySystemChangeComp.

public int modifySystemChangeComp(final int changes) {
    int madeChanges = 0;
    // Copy the assembly context list
    final EList<AssemblyContext> assemblyContextsList = this.systemModel.getAssemblyContexts__ComposedStructure();
    final List<AssemblyContext> assemblyContexts = assemblyContextsList.stream().collect(Collectors.toList());
    // Randomize the list!
    Collections.shuffle(assemblyContexts);
    // Iterate over random list
    for (final AssemblyContext assemblyContext : assemblyContexts) {
        final String interfaceSignature = this.caluclateInterfaceSignature(assemblyContext.getEncapsulatedComponent__AssemblyContext());
        if (this.duplicateRepositoryComponents.containsKey(interfaceSignature)) {
            // Duplicate to containing comp is available!
            final List<RepositoryComponent> equalComponents = this.duplicateRepositoryComponents.get(interfaceSignature);
            // Find non-self replacement
            RepositoryComponent newRepoComp = null;
            for (int j = 0; newRepoComp != null && j < equalComponents.size() * 10; j++) {
                final int randomIndex = ThreadLocalRandom.current().nextInt(equalComponents.size());
                final RepositoryComponent candidate = equalComponents.get(randomIndex);
                if (!assemblyContext.getEncapsulatedComponent__AssemblyContext().getId().equals(candidate.getId())) {
                    newRepoComp = candidate;
                }
            }
            if (newRepoComp != null) {
                // Exchange containing comp
                assemblyContext.setEncapsulatedComponent__AssemblyContext(newRepoComp);
                madeChanges++;
                if (madeChanges == changes) {
                    break;
                }
            }
        }
    }
    return madeChanges;
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 14 with RepositoryComponent

use of org.palladiosimulator.pcm.repository.RepositoryComponent in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddAssemblyContext method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_ASSEMBLY_CONTEXT);
    if (parameter == null || !(parameter instanceof AssemblyContext)) {
        return;
    }
    final AssemblyContext assemblyContext = (AssemblyContext) parameter;
    final RepositoryComponent repositoryComponent = getRepositoryComponent(assemblyContext);
    if (repositoryComponent != null) {
        assemblyContext.setEncapsulatedComponent__AssemblyContext(repositoryComponent);
        assemblyContext.setEntityName("Assembly_" + repositoryComponent.getEntityName());
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 15 with RepositoryComponent

use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.

the class ComponentEntryImpl method setComponent.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setComponent(RepositoryComponent newComponent) {
    RepositoryComponent oldComponent = component;
    component = newComponent;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, CorrespondencePackage.COMPONENT_ENTRY__COMPONENT, oldComponent, component));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Aggregations

RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)19 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)10 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)9 OperationInterface (org.palladiosimulator.pcm.repository.OperationInterface)7 Interface (org.palladiosimulator.pcm.repository.Interface)6 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)6 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)5 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)4 Repository (org.palladiosimulator.pcm.repository.Repository)4 Test (org.junit.Test)3 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)3 HashMap (java.util.HashMap)2 EObject (org.eclipse.emf.ecore.EObject)2 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)2 RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1