Search in sources :

Example 56 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class AssemblyContextActionFactory method setSourceAssemblyContext.

private static AssemblyContextAction setSourceAssemblyContext(final AssemblyContextAction action, final String assemblyContextID) {
    final org.palladiosimulator.pcm.system.System systemModel = ActionFactory.getRuntimeModels().getSystemModel();
    final AssemblyContext assemblyContext = ActionFactory.getAssemblyContext(assemblyContextID, systemModel);
    action.setSourceAssemblyContext(assemblyContext);
    return action;
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 57 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class AllocationModification method initResContainer2AllocationContext.

private void initResContainer2AllocationContext() {
    this.resContainer2AllocationContext = new HashMap<>();
    this.assemblyCon2AllocationContext = new HashMap<>();
    for (final AllocationContext ac : this.allocationModel.getAllocationContexts_Allocation()) {
        final ResourceContainer resCon = ac.getResourceContainer_AllocationContext();
        if (!this.resContainer2AllocationContext.containsKey(resCon.getId())) {
            this.resContainer2AllocationContext.put(resCon.getId(), new LinkedList<AllocationContext>());
        }
        this.resContainer2AllocationContext.get(resCon.getId()).add(ac);
        final AssemblyContext assemblyCon = ac.getAssemblyContext_AllocationContext();
        if (!this.assemblyCon2AllocationContext.containsKey(assemblyCon.getId())) {
            this.assemblyCon2AllocationContext.put(assemblyCon.getId(), ac);
        } else {
            throw new RuntimeException("An assembly context was found twice during assembly context analysis!");
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 58 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext 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 59 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class SystemGeneration method addAssemblyContexts.

/**
 * @param assemblyContextCount
 * @param prefix
 * @return
 */
public List<AssemblyContext> addAssemblyContexts(final int assemblyContextCount, final String prefix) {
    final List<AssemblyContext> newACs = new ArrayList<>();
    for (int i = 0; i < assemblyContextCount; i++) {
        final String namePrefix = Integer.toString(i) + "_" + prefix;
        final AssemblyContext newAC = this.generateNewAC(namePrefix);
        newACs.add(newAC);
        SystemGeneration.LOGGER.info("CREATING: \tAssemblyContext: \t {}", newAC.getId());
    }
    this.finalizeModelGeneration();
    return newACs;
}
Also used : ArrayList(java.util.ArrayList) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 60 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext 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

AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)64 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)16 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)11 ArrayList (java.util.ArrayList)9 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)9 AssemblyConnector (org.palladiosimulator.pcm.core.composition.AssemblyConnector)8 System (org.palladiosimulator.pcm.system.System)8 Test (org.junit.Test)7 Connector (org.palladiosimulator.pcm.core.composition.Connector)7 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)6 HashSet (java.util.HashSet)5 EObject (org.eclipse.emf.ecore.EObject)5 Allocation (org.palladiosimulator.pcm.allocation.Allocation)5 DataPrivacyLvl (org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)5 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)5 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)5 HashMap (java.util.HashMap)4 AssemblyEntry (org.iobserve.model.correspondence.AssemblyEntry)4 RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)4 URL (java.net.URL)3