Search in sources :

Example 46 with AssemblyContext

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

the class SystemDataFactory method createAssemblyContext.

private static AssemblyContext createAssemblyContext(final Repository repository, final String contextName, final String componentName) {
    final AssemblyContext assemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext();
    final RepositoryComponent component = RepositoryModelDataFactory.findComponentByName(repository, componentName);
    assemblyContext.setEncapsulatedComponent__AssemblyContext(component);
    assemblyContext.setEntityName(contextName);
    return assemblyContext;
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 47 with AssemblyContext

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

the class SystemModelProviderTest method createThenReadReferencing.

@Override
@Test
public void createThenReadReferencing() throws DBException {
    final Neo4JModelResource<System> resource = ModelProviderTestUtils.prepareResource("createThenReadReferencing", this.prefix, this.ePackage);
    resource.storeModelPartition(this.testModel);
    final List<EObject> expectedReferencingComponents = new LinkedList<>();
    final List<EObject> readReferencingComponents;
    final Connector businessQueryConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_QUERY_CONNECTOR);
    final Connector businessPayConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_PAY_CONNECTOR);
    expectedReferencingComponents.add(businessQueryConnector);
    expectedReferencingComponents.add(businessPayConnector);
    final AssemblyContext context = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.BUSINESS_ORDER_ASSEMBLY_CONTEXT);
    readReferencingComponents = resource.collectReferencingObjectsByTypeAndProperty(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(context));
    // Only the businessQueryInputConnector and the businessPayConnector are referencing the
    // businessOrderContext
    Assert.assertTrue(readReferencingComponents.size() == 2);
    Assert.assertTrue(this.equalityHelper.comparePartitions(expectedReferencingComponents, readReferencingComponents, readReferencingComponents.get(0).eClass()));
}
Also used : AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Connector(org.palladiosimulator.pcm.core.composition.Connector) EObject(org.eclipse.emf.ecore.EObject) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) System(org.palladiosimulator.pcm.system.System) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 48 with AssemblyContext

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

the class SystemModelProviderTest method createThenUpdateThenReadUpdated.

@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
    final Neo4JModelResource<System> resource = ModelProviderTestUtils.prepareResource("createThenUpdateThenReadUpdated", this.prefix, this.ePackage);
    resource.storeModelPartition(this.testModel);
    // Update the model by renaming and removing the business context
    this.testModel.setEntityName("MyVideoOnDemandService");
    final AssemblyContext businessQueryAssemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.BUSINESS_ORDER_ASSEMBLY_CONTEXT);
    final Connector businessQueryConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_QUERY_CONNECTOR);
    final Connector businessPayConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_PAY_CONNECTOR);
    this.testModel.getAssemblyContexts__ComposedStructure().remove(businessQueryAssemblyContext);
    this.testModel.getConnectors__ComposedStructure().remove(businessQueryConnector);
    this.testModel.getConnectors__ComposedStructure().remove(businessPayConnector);
    // Replace the business context by a context for groups of people placing an order
    final AssemblyContext sharedOrderContext = CompositionFactory.eINSTANCE.createAssemblyContext();
    sharedOrderContext.setEntityName("sharedOrderContext_org.myvideoondemandservice.orderComponent");
    sharedOrderContext.setEncapsulatedComponent__AssemblyContext(RepositoryModelDataFactory.findComponentByName(this.repository, RepositoryModelDataFactory.ORDER_COMPONENT));
    final AssemblyContext queryInputAssemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final OperationProvidedRole providedInputRole = RepositoryModelDataFactory.findProvidedRole(sharedOrderContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.QUERY_PROVIDED_ROLE);
    final OperationRequiredRole requiredInputRole = RepositoryModelDataFactory.findRequiredRole(queryInputAssemblyContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.QUERY_REQUIRED_ROLE);
    final AssemblyConnector sharedQueryInputConnector = CompositionFactory.eINSTANCE.createAssemblyConnector();
    sharedQueryInputConnector.setEntityName("sharedQueryInput");
    sharedQueryInputConnector.setProvidedRole_AssemblyConnector(providedInputRole);
    sharedQueryInputConnector.setRequiredRole_AssemblyConnector(requiredInputRole);
    sharedQueryInputConnector.setProvidingAssemblyContext_AssemblyConnector(sharedOrderContext);
    sharedQueryInputConnector.setRequiringAssemblyContext_AssemblyConnector(queryInputAssemblyContext);
    final AssemblyContext paymentAssemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.PAYMENT_ASSEMBLY_CONTEXT);
    final OperationProvidedRole providedPayRole = RepositoryModelDataFactory.findProvidedRole(paymentAssemblyContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.PAYMENT_PROVIDED_ROLE);
    final OperationRequiredRole requiredPayRole = RepositoryModelDataFactory.findRequiredRole(sharedOrderContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.PAYMENT_REQUIRED_ROLE);
    final AssemblyConnector sharedPayConnector = CompositionFactory.eINSTANCE.createAssemblyConnector();
    sharedPayConnector.setEntityName("sharedPayment");
    sharedPayConnector.setProvidedRole_AssemblyConnector(providedPayRole);
    sharedPayConnector.setRequiredRole_AssemblyConnector(requiredPayRole);
    sharedPayConnector.setProvidingAssemblyContext_AssemblyConnector(paymentAssemblyContext);
    sharedPayConnector.setRequiringAssemblyContext_AssemblyConnector(sharedOrderContext);
    this.testModel.getAssemblyContexts__ComposedStructure().add(sharedOrderContext);
    this.testModel.getConnectors__ComposedStructure().add(sharedQueryInputConnector);
    this.testModel.getConnectors__ComposedStructure().add(sharedPayConnector);
    resource.updatePartition(this.testModel);
    final System readModel = resource.getModelRootNode(System.class, this.eClass);
    Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
}
Also used : AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Connector(org.palladiosimulator.pcm.core.composition.Connector) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) System(org.palladiosimulator.pcm.system.System) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) Test(org.junit.Test)

Example 49 with AssemblyContext

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

the class ModelProcessing method rebuildEnvironment.

private void rebuildEnvironment() throws ModelHandlingErrorException {
    for (final AllocationGroup allocationGroup : this.originalAllocationGroups.getAllocationGroups()) {
        final AllocationContext representingContext = allocationGroup.getRepresentingContext();
        // Set assembly context from allocation group to the context from the processed model
        final AssemblyContext representedAsmCtx = this.systemModel.getAssemblyContexts__ComposedStructure().stream().filter(ctx -> representingContext.getAssemblyContext_AllocationContext().getId().equals(ctx.getId())).findFirst().orElse(null);
        if (representedAsmCtx == null) {
            throw new RuntimeException("There was something wrong with the system model. Please check your models.");
        }
        representingContext.setAssemblyContext_AllocationContext(representedAsmCtx);
        this.createResourcesAndReplicationDegrees(this.decisionModel, allocationGroup);
        this.allocationModel.getAllocationContexts_Allocation().add(representingContext);
    }
    for (final AllocationGroup allocationGroup : this.originalAllocationGroups.getAllocationGroups()) {
        final String allocationDegreeName = String.format("%s_AllocationDegree", allocationGroup.getName());
        DesignDecisionModelFactory.createAllocationDegree(this.decisionModel, allocationDegreeName, allocationGroup.getRepresentingContext(), this.resourceEnvironmentModel.getResourceContainer_ResourceEnvironment());
    }
    ModelHelper.addAllAllocationsToReplicationDegrees(this.allocationModel, this.decisionModel);
    this.saveModels();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AllocationGroup(org.iobserve.planning.data.AllocationGroup) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 50 with AssemblyContext

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

the class AllocationGroupsContainer method getAllocationGroup.

/**
 * Returns the allocation group to which the given allocation context belongs.
 *
 * @param allocContext
 *            the allocation context for which to get the allocation group
 * @return the corresponding allocation group or null if there is none
 */
public AllocationGroup getAllocationGroup(final AllocationContext allocContext) {
    final AssemblyContext asmContext = allocContext.getAssemblyContext_AllocationContext();
    final String componentName = asmContext.getEncapsulatedComponent__AssemblyContext().getEntityName();
    final String containerIdentifier = ModelHelper.getResourceContainerIdentifier(allocContext.getResourceContainer_AllocationContext());
    return this.getAllocationGroup(componentName, containerIdentifier);
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

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