Search in sources :

Example 16 with AssemblyContext

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

the class DeploymentModelUpdater method createAndAddAssemblyContext.

/**
 * Create {@link AssemblyContext} with the given name and insert it in the system model.
 *
 * @param systemModelProvider
 *            system model provider
 * @param name
 *            name of the assembly context
 * @return created assembly context
 */
private AssemblyContext createAndAddAssemblyContext(final IModelProvider<org.palladiosimulator.pcm.system.System> systemModelProvider, final String name) {
    final org.palladiosimulator.pcm.system.System systemModel = systemModelProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class);
    final AssemblyContext assemblyContext = SystemModelFactory.createAssemblyContextsIfAbsent(systemModel, name);
    systemModelProvider.updateComponent(org.palladiosimulator.pcm.system.System.class, systemModel);
    return assemblyContext;
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 17 with AssemblyContext

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

the class EntryEventMapperStage method computePcmEntryCallEvent.

private void computePcmEntryCallEvent(final ComponentEntry componentEntry, final OperationEntry operationEntry, final AllocationEntry allocationEntry, final EntryCallEvent event) throws DBException {
    /**
     * retrieve PCM model elements from mapping.
     */
    final AllocationContext allocationContext = this.allocationResource.findObjectByTypeAndId(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, ModelGraphFactory.getIdentification(allocationEntry.getAllocation()));
    final OperationSignature operationSignature = this.repositoryResource.findAndLockObjectById(OperationSignature.class, RepositoryPackage.Literals.OPERATION_SIGNATURE, ModelGraphFactory.getIdentification(operationEntry.getOperation()));
    final RepositoryComponent component = this.repositoryResource.findObjectByTypeAndId(RepositoryComponent.class, RepositoryPackage.Literals.REPOSITORY_COMPONENT, ModelGraphFactory.getIdentification(componentEntry.getComponent()));
    /**
     * assembly is inferred from allocation.
     */
    final AssemblyContext assemblyContext = this.assemblyResource.findObjectByTypeAndId(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(allocationContext.getAssemblyContext_AllocationContext()));
    /**
     * assemble event.
     */
    final PCMEntryCallEvent mappedEvent = new PCMEntryCallEvent(event.getEntryTime(), event.getExitTime(), component, operationSignature, assemblyContext, allocationContext);
    this.outputPort.send(mappedEvent);
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) PCMEntryCallEvent(org.iobserve.service.privacy.violation.data.PCMEntryCallEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 18 with AssemblyContext

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

the class DataProtectionWarner method addDeployedComponents.

/**
 * Adding deployment info.
 *
 * @param privacyGraph
 *            the graph containing privacy information
 * @throws DBException
 * @throws InvocationException
 */
private void addDeployedComponents(final PrivacyGraph privacyGraph) throws InvocationException, DBException {
    DeploymentLock.lock();
    for (final AllocationContext allocationContext : this.allocationRootElement.getAllocationContexts_Allocation()) {
        final AssemblyContext proxyAssemblyContext = allocationContext.getAssemblyContext_AllocationContext();
        final AssemblyContext assemblyContext = this.systemModelResource.resolve(proxyAssemblyContext);
        final RepositoryComponent proxyComponent = assemblyContext.getEncapsulatedComponent__AssemblyContext();
        final BasicComponent basicComponent = (BasicComponent) this.repositoryResource.resolve(proxyComponent);
        /**
         * Creating component vertices. *
         */
        // TODO name should be allocation name or assembly name + instance count
        final Vertex vertex = new Vertex(basicComponent.getEntityName(), this.computeStereotype(basicComponent));
        vertex.setAllocationContext(allocationContext);
        privacyGraph.addVertex(vertex);
        this.vertices.put(basicComponent.getId(), vertex);
        final ResourceContainer resourceContainer = this.resourceEnvironmentResource.resolve(allocationContext.getResourceContainer_AllocationContext());
        final GeoLocation geo = this.geolocations.get(resourceContainer.getId());
        if (geo == null) {
            this.logger.info("Geolocation infomation not available {}", resourceContainer.getId());
        } else {
            final Vertex vGeo = new Vertex(geo.getIsocode().getName(), EStereoType.GEOLOCATION);
            if (!this.vertices.containsKey(geo.getIsocode().getName())) {
                // New Geolocation
                privacyGraph.addVertex(vGeo);
                privacyGraph.addEdge(vGeo, vertex);
                this.vertices.put(geo.getIsocode().getName(), vGeo);
            } else {
                // Existing Geolocation
                privacyGraph.addEdge(this.vertices.get(geo.getIsocode().getName()), vertex);
            }
        }
    }
    DeploymentLock.unlock();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) GeoLocation(org.iobserve.model.privacy.GeoLocation) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 19 with AssemblyContext

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

the class NonAdaptiveModelProbeController method computeAvailableProbes.

/**
 * Compute available probes.
 *
 * @return returns a map of {@link AllocationContext}s and their relevant
 *         {@link OperationSignature}s
 * @throws DBException
 */
private Map<AllocationContext, Set<OperationSignature>> computeAvailableProbes() throws DBException {
    final Repository repositoryModel = this.repositoryResource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
    final List<AllocationContext> allocations = this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT);
    final Map<AllocationContext, Set<OperationSignature>> availableProbes = new HashMap<>();
    this.logger.debug("Found " + allocations.size() + " allocation context entries");
    for (final AllocationContext allocation : allocations) {
        final Set<OperationSignature> allocationMethods = new LinkedHashSet<>();
        try {
            final AssemblyContext assemblyContext = this.systemModelResource.resolve(allocation.getAssemblyContext_AllocationContext());
            final RepositoryComponent component = this.repositoryResource.resolve(assemblyContext.getEncapsulatedComponent__AssemblyContext());
            final List<ProvidedRole> providingRoles = component.getProvidedRoles_InterfaceProvidingEntity();
            for (final ProvidedRole providedRole : providingRoles) {
                this.logger.debug("Providing roles: " + providingRoles);
                final String roleName = providedRole.getEntityName();
                for (final Interface iface : repositoryModel.getInterfaces__Repository()) {
                    if (iface instanceof OperationInterface) {
                        if (roleName.contains(iface.getEntityName())) {
                            this.logger.debug("Matching operation interfaces: " + ((OperationInterface) iface).getSignatures__OperationInterface());
                            // found interface
                            allocationMethods.addAll(((OperationInterface) iface).getSignatures__OperationInterface());
                        }
                    }
                }
            }
        } catch (InvocationException | DBException e) {
            this.logger.error("Could not resolve elements of the PCM during the computation of the available probes", e);
        }
        availableProbes.put(allocation, allocationMethods);
    }
    return availableProbes;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DBException(org.iobserve.model.persistence.DBException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Repository(org.palladiosimulator.pcm.repository.Repository) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) InvocationException(org.iobserve.model.persistence.neo4j.InvocationException) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface)

Example 20 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddAllocationContextAssemblyContext method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    AllocationContext allocationContext = (AllocationContext) parameters.get("instance");
    AssemblyContext assemblyContext = (AssemblyContext) getAssemblyContext(allocationContext);
    allocationContext.setAssemblyContext_AllocationContext(assemblyContext);
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Aggregations

AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)68 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 EObject (org.eclipse.emf.ecore.EObject)6 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)6 HashSet (java.util.HashSet)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