Search in sources :

Example 1 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() {
    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 RepositoryComponent

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

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

the class SystemGeneration method initInterfaceMaps.

private void initInterfaceMaps() {
    this.openRequiredInterfaces = new HashMap<>();
    this.openProvidedInterfaces = new HashMap<>();
    this.connectedProvidedInterfaces = new HashMap<>();
    this.unconnectedAssemblyContextes = new HashSet<>();
    for (final RepositoryComponent component : this.components) {
        for (final ProvidedRole provRole : component.getProvidedRoles_InterfaceProvidingEntity()) {
            if (!(provRole instanceof OperationProvidedRole)) {
                continue;
            }
            final OperationProvidedRole provInterface = (OperationProvidedRole) provRole;
            final String interfaceID = provInterface.getProvidedInterface__OperationProvidedRole().getId();
            if (!this.openProvidedInterfaces.containsKey(interfaceID)) {
                this.openProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.openRequiredInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.connectedProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
            }
        }
        for (final RequiredRole requRole : component.getRequiredRoles_InterfaceRequiringEntity()) {
            if (!(requRole instanceof OperationRequiredRole)) {
                continue;
            }
            final OperationRequiredRole reqInterface = (OperationRequiredRole) requRole;
            final String interfaceID = reqInterface.getRequiredInterface__OperationRequiredRole().getId();
            if (!this.openProvidedInterfaces.containsKey(interfaceID)) {
                this.openProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.openRequiredInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.connectedProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
            }
        }
    }
}
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) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Example 4 with RepositoryComponent

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

the class SystemModification method initDuplicateRepo.

/*
     * Calculates all duplicated Repositories.
     */
private void initDuplicateRepo(final RepositoryComponent[] comps) {
    SystemModification.LOGGER.info("Calculating euql Repository Components ...");
    final Map<String, RepositoryComponent> existingInterfaceSig = new HashMap<>();
    for (final RepositoryComponent comp : comps) {
        // Calc Sig
        final String interfaceSignature = this.caluclateInterfaceSignature(comp);
        if (existingInterfaceSig.containsKey(interfaceSignature)) {
            // Sig already exists
            if (this.duplicateRepositoryComponents.containsKey(interfaceSignature)) {
                // Already 2+ equal sig exist
                this.duplicateRepositoryComponents.get(interfaceSignature).add(comp);
            } else {
                // First duplicate with this sig found
                final List<RepositoryComponent> duplicates = new ArrayList<>();
                duplicates.add(existingInterfaceSig.get(interfaceSignature));
                duplicates.add(comp);
                this.duplicateRepositoryComponents.put(interfaceSignature, duplicates);
            }
        } else {
            // No equal sig found
            existingInterfaceSig.put(interfaceSignature, comp);
        }
    }
    SystemModification.LOGGER.info("Duplicate Interfacestructures found:\t {}", this.duplicateRepositoryComponents.keySet().size());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

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

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