Search in sources :

Example 6 with RepositoryComponent

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

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

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

the class AddAssemblyContext method getRepositoryComponent.

private RepositoryComponent getRepositoryComponent(final AssemblyContext assemblyContext) {
    final PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), FILTER_LIST, ADDITIONAL_REFERENCES, assemblyContext.eResource().getResourceSet());
    dialog.setProvidedService(RepositoryComponent.class);
    dialog.open();
    if (dialog.getResult() == null) {
        return null;
    }
    if (!(dialog.getResult() instanceof RepositoryComponent)) {
        return null;
    }
    return (RepositoryComponent) dialog.getResult();
}
Also used : PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 9 with RepositoryComponent

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

the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.

@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
    final Neo4JModelResource<Repository> resource = ModelProviderTestUtils.prepareResource("createThenUpdateThenReadUpdated", this.prefix, this.ePackage);
    final Interface payInterface = RepositoryModelDataFactory.findInterfaceByName(this.repository, RepositoryModelDataFactory.PAYMENT_INTERFACE);
    final RepositoryComponent paymentComponent = RepositoryModelDataFactory.findComponentByName(this.repository, RepositoryModelDataFactory.PAYMENT_COMPONENT);
    resource.storeModelPartition(this.testModel);
    // Update the model by renaming and replacing the payment method
    this.testModel.setEntityName("MyVideoOnDemandService");
    final OperationProvidedRole providedPayOperation = ((RepositoryFactory) this.ePackage.getEFactoryInstance()).createOperationProvidedRole();
    providedPayOperation.setEntityName("payPalPayment");
    providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
    paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
    paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
    resource.updatePartition(this.testModel);
    final Repository readModel = resource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
    Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
    resource.getGraphDatabaseService().shutdown();
}
Also used : Repository(org.palladiosimulator.pcm.repository.Repository) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) RepositoryFactory(org.palladiosimulator.pcm.repository.RepositoryFactory) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface) Test(org.junit.Test)

Example 10 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)

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