Search in sources :

Example 1 with Interface

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

the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.

@Override
@Test
public void createThenUpdateThenReadUpdated() {
    final ModelProvider<Repository> modelProvider = new ModelProvider<>(RepositoryModelProviderTest.graph);
    final TestModelBuilder testModelBuilder = new TestModelBuilder();
    final Repository writtenModel = testModelBuilder.getRepository();
    final Interface payInterface = testModelBuilder.getPayInterface();
    final RepositoryComponent paymentComponent = testModelBuilder.getPaymentComponent();
    final Repository readModel;
    modelProvider.createComponent(writtenModel);
    // Update the model by renaming and replacing the payment method
    writtenModel.setEntityName("MyVideoOnDemandService");
    final OperationProvidedRole providedPayOperation = RepositoryFactory.eINSTANCE.createOperationProvidedRole();
    providedPayOperation.setEntityName("payPalPayment");
    providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
    paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
    paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
    modelProvider.updateComponent(Repository.class, writtenModel);
    readModel = modelProvider.readOnlyRootComponent(Repository.class);
    Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
Also used : Repository(org.palladiosimulator.pcm.repository.Repository) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface) Test(org.junit.Test)

Example 2 with Interface

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

the class RepositoryModelHandler method loadData.

/**
 * Loading and initializing the maps for data access.
 *
 * @param model
 *            repository model
 * @deprecated this functionality now resides in {@link RepositoryLookupModelProvier}
 */
@Deprecated
public void loadData(final Repository model) {
    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 : model.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 : model.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 3 with Interface

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

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

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

Aggregations

Interface (org.palladiosimulator.pcm.repository.Interface)9 OperationInterface (org.palladiosimulator.pcm.repository.OperationInterface)8 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)6 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)6 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)5 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)5 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)5 Repository (org.palladiosimulator.pcm.repository.Repository)3 ParameterDataProtection (org.iobserve.model.privacy.ParameterDataProtection)2 ReturnTypeDataProtection (org.iobserve.model.privacy.ReturnTypeDataProtection)2 Test (org.junit.Test)2 Parameter (org.palladiosimulator.pcm.repository.Parameter)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 EObject (org.eclipse.emf.ecore.EObject)1 EReference (org.eclipse.emf.ecore.EReference)1 DBException (org.iobserve.model.persistence.DBException)1