Search in sources :

Example 36 with AssemblyContext

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

the class AllocationServices method getUndeployedSubAssemblyContexts.

public Collection<AssemblyContext> getUndeployedSubAssemblyContexts(AssemblyContext assemblyContext, Allocation allocation, boolean recursively) {
    if (!(assemblyContext.getEncapsulatedComponent__AssemblyContext() instanceof SubSystem))
        throw new IllegalArgumentException("The encapsulated component of " + assemblyContext + " must be a SubSystem");
    SubSystem subSystem = (SubSystem) assemblyContext.getEncapsulatedComponent__AssemblyContext();
    Collection<AssemblyContext> result = new ArrayList<AssemblyContext>();
    for (AssemblyContext a : subSystem.getAssemblyContexts__ComposedStructure()) {
        if (!isAllocated(a, allocation)) {
            result.add(a);
            if (recursively && a.getEncapsulatedComponent__AssemblyContext() instanceof SubSystem) {
                result.addAll(getUndeployedSubAssemblyContexts(a, allocation, true));
            }
        }
    }
    return result;
}
Also used : SubSystem(org.palladiosimulator.pcm.subsystem.SubSystem) ArrayList(java.util.ArrayList) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 37 with AssemblyContext

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

the class AddAssemblyContext method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_ASSEMBLY_CONTEXT);
    if (parameter == null || !(parameter instanceof AssemblyContext)) {
        return;
    }
    final AssemblyContext assemblyContext = (AssemblyContext) parameter;
    final RepositoryComponent repositoryComponent = getRepositoryComponent(assemblyContext);
    if (repositoryComponent != null) {
        assemblyContext.setEncapsulatedComponent__AssemblyContext(repositoryComponent);
        assemblyContext.setEntityName("Assembly_" + repositoryComponent.getEntityName());
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 38 with AssemblyContext

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

the class DeleteAsemblyContext method execute.

@Override
public void execute(Collection<? extends EObject> selection, Map<String, Object> parameters) {
    AssemblyContext element = (AssemblyContext) parameters.get("element");
    Iterator<Connector> iter = element.getParentStructure__AssemblyContext().getConnectors__ComposedStructure().iterator();
    Connector connector;
    while (iter.hasNext()) {
        connector = iter.next();
        // necessary
        if (connector instanceof AssemblyInfrastructureConnector) {
            AssemblyInfrastructureConnector tmpConnector = (AssemblyInfrastructureConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getProvidingAssemblyContext__AssemblyInfrastructureConnector().equals(element) || tmpConnector.getRequiringAssemblyContext__AssemblyInfrastructureConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof AssemblyConnector) {
            AssemblyConnector tmpConnector = (AssemblyConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getProvidingAssemblyContext_AssemblyConnector().equals(element) || tmpConnector.getRequiringAssemblyContext_AssemblyConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof AssemblyEventConnector) {
            AssemblyEventConnector tmpConnector = (AssemblyEventConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getSinkAssemblyContext__AssemblyEventConnector().equals(element) || tmpConnector.getSourceAssemblyContext__AssemblyEventConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof EventChannelSourceConnector) {
            EventChannelSourceConnector tmpConnector = (EventChannelSourceConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext__EventChannelSourceConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof EventChannelSinkConnector) {
            EventChannelSinkConnector tmpConnector = (EventChannelSinkConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext__EventChannelSinkConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof SinkDelegationConnector) {
            SinkDelegationConnector tmpConnector = (SinkDelegationConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext__SinkDelegationConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof SourceDelegationConnector) {
            SourceDelegationConnector tmpConnector = (SourceDelegationConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext__SourceDelegationConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof ProvidedDelegationConnector) {
            ProvidedDelegationConnector tmpConnector = (ProvidedDelegationConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext_ProvidedDelegationConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof ProvidedInfrastructureDelegationConnector) {
            ProvidedInfrastructureDelegationConnector tmpConnector = (ProvidedInfrastructureDelegationConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext__ProvidedInfrastructureDelegationConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof RequiredInfrastructureDelegationConnector) {
            RequiredInfrastructureDelegationConnector tmpConnector = (RequiredInfrastructureDelegationConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext__RequiredInfrastructureDelegationConnector().equals(element)) {
                iter.remove();
            }
        } else if (connector instanceof RequiredDelegationConnector) {
            RequiredDelegationConnector tmpConnector = (RequiredDelegationConnector) connector;
            // Remove if element is part of connector
            if (tmpConnector.getAssemblyContext_RequiredDelegationConnector().equals(element)) {
                iter.remove();
            }
        }
    }
// TODO DelegationConnector
}
Also used : ProvidedDelegationConnector(org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector) RequiredDelegationConnector(org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector) SinkDelegationConnector(org.palladiosimulator.pcm.core.composition.SinkDelegationConnector) RequiredInfrastructureDelegationConnector(org.palladiosimulator.pcm.core.composition.RequiredInfrastructureDelegationConnector) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Connector(org.palladiosimulator.pcm.core.composition.Connector) AssemblyEventConnector(org.palladiosimulator.pcm.core.composition.AssemblyEventConnector) SourceDelegationConnector(org.palladiosimulator.pcm.core.composition.SourceDelegationConnector) EventChannelSourceConnector(org.palladiosimulator.pcm.core.composition.EventChannelSourceConnector) EventChannelSinkConnector(org.palladiosimulator.pcm.core.composition.EventChannelSinkConnector) ProvidedInfrastructureDelegationConnector(org.palladiosimulator.pcm.core.composition.ProvidedInfrastructureDelegationConnector) AssemblyInfrastructureConnector(org.palladiosimulator.pcm.core.composition.AssemblyInfrastructureConnector) ProvidedDelegationConnector(org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector) ProvidedInfrastructureDelegationConnector(org.palladiosimulator.pcm.core.composition.ProvidedInfrastructureDelegationConnector) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) EventChannelSinkConnector(org.palladiosimulator.pcm.core.composition.EventChannelSinkConnector) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) SourceDelegationConnector(org.palladiosimulator.pcm.core.composition.SourceDelegationConnector) RequiredDelegationConnector(org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector) AssemblyEventConnector(org.palladiosimulator.pcm.core.composition.AssemblyEventConnector) EventChannelSourceConnector(org.palladiosimulator.pcm.core.composition.EventChannelSourceConnector) SinkDelegationConnector(org.palladiosimulator.pcm.core.composition.SinkDelegationConnector) AssemblyInfrastructureConnector(org.palladiosimulator.pcm.core.composition.AssemblyInfrastructureConnector) RequiredInfrastructureDelegationConnector(org.palladiosimulator.pcm.core.composition.RequiredInfrastructureDelegationConnector)

Example 39 with AssemblyContext

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

the class DeploymentModelUpdaterTest method testExecutePCMDeployedEvent.

/**
 * Test method for
 * {@link org.iobserve.analysis.deployment.DeploymentModelUpdater#execute(org.iobserve.analysis.deployment.data.PCMDeployedEvent)}.
 *
 * @throws DBException
 */
@Test
public void testExecutePCMDeployedEvent() throws DBException {
    java.lang.System.err.println("AAAAAAAAAAAAAAAAAAAAAAa");
    this.initializationDatabase();
    java.lang.System.err.println("q alloc");
    final Allocation initDbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    java.lang.System.err.println("deployer filter");
    final DeploymentModelUpdater deploymentModelUpdater = new DeploymentModelUpdater(this.correspondenceResource, this.allocationResource);
    /**
     * input deployment event
     */
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final PCMDeployedEvent deploymentEvent = ModelLevelDataFactory.createPCMDeployedEvent(ISOCountryCode.EVIL_EMPIRE, assemblyContext);
    deploymentEvent.setResourceContainer(ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3));
    final List<PCMDeployedEvent> inputEvents = new ArrayList<>();
    inputEvents.add(deploymentEvent);
    StageTester.test(deploymentModelUpdater).and().send(inputEvents).to(deploymentModelUpdater.getInputPort()).start();
    Assert.assertThat(deploymentModelUpdater.getDeployedNotifyOutputPort(), StageTester.produces(deploymentEvent));
    // TODO check is DB contains a deployment
    final Allocation dbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    for (final AllocationContext context : dbAllocation.getAllocationContexts_Allocation()) {
        Assert.assertNotEquals("No assembly context for " + context.getEntityName(), context.getAssemblyContext_AllocationContext(), null);
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) DeploymentModelUpdater(org.iobserve.analysis.deployment.DeploymentModelUpdater) Allocation(org.palladiosimulator.pcm.allocation.Allocation) PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) ArrayList(java.util.ArrayList) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) Test(org.junit.Test)

Example 40 with AssemblyContext

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

the class UndeploymentVisualizationStageTest method setUp.

/**
 * Initialize test data and stub necessary method calls.
 *
 * @throws MalformedURLException
 *             if the creation of the URL fails.
 * @throws DBException
 */
@Before
public void setUp() throws MalformedURLException, DBException {
    final URL changelogURL = new URL("http://" + UndeploymentVisualizationStageTest.OUTPUT_HOSTNAME + ":" + UndeploymentVisualizationStageTest.OUTPUT_PORT + "/v1/systems/" + UndeploymentVisualizationStageTest.SYSTEM_ID + "/changelogs");
    this.undeploymentVisualizationStage = new UndeploymentVisualizationStage(changelogURL, UndeploymentVisualizationStageTest.SYSTEM_ID, this.mockedResourceContainerModelProvider, this.mockedSystemModelGraphProvider);
    // TODO reimplement for current filters
    /**
     * test correspondent
     */
    // UndeploymentVisualizationStageTest.testCorrespondent =
    // CorrespondentFactory.newInstance("test.org.pcm.entity",
    // "testPcmEntityId", "testPcmOperationName", "testPcmOperationId");
    // UndeploymentVisualizationStageTest.optTestCorrespondent = Optional
    /**
     * test events
     */
    final String urlContext = UndeploymentVisualizationStageTest.CONTEXT.replaceAll("\\.", "/");
    final String url = "http://" + UndeploymentVisualizationStageTest.SERVICE + '/' + urlContext;
    final PCMUndeployedEvent undeployedEvent = new PCMUndeployedEvent(UndeploymentVisualizationStageTest.SERVICE, null, /* AssemblyContextDataFactory.ASSEMBLY_CONTEXT */
    this.testResourceContainer, 0);
    /**
     * input events
     */
    this.inputEvents.add(undeployedEvent);
    /**
     * test resource container
     */
    this.testResourceContainer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
    this.testResourceContainer.setId(UndeploymentVisualizationStageTest.TEST_NODE_ID);
    this.testResourceContainers.add(this.testResourceContainer);
    /**
     * test assembly context
     */
    final AssemblyContext testAssemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext();
    testAssemblyContext.setId("test_serviceId");
    testAssemblyContext.setEntityName("test_serviceName");
    this.testAssemblyContexts.add(testAssemblyContext);
    // stubbing
    Mockito.when(this.mockedResourceContainerModelProvider.findObjectsByTypeAndProperty(ResourceContainer.class, ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER, "entityName", UndeploymentVisualizationStageTest.SERVICE)).thenReturn(this.testResourceContainers);
// TODO fix this
// Mockito.when(this.mockedCorrespondenceModel.getCorrespondent(UndeploymentVisualizationStageTest.CONTEXT))
// .thenReturn(UndeploymentVisualizationStageTest.optTestCorrespondent);
// final String asmContextName =
// UndeploymentVisualizationStageTest.testCorrespondent.getPcmEntityName() + "_"
// + UndeploymentVisualizationStageTest.SERVICE;
// Mockito.when(this.mockedSystemModelGraphProvider.findObjectsByTypeAndName(AssemblyContext.class,
// CompositionPackage.Literals.ASSEMBLY_CONTEXT, "entityName", asmContextName))
// .thenReturn(this.testAssemblyContexts);
}
Also used : UndeploymentVisualizationStage(org.iobserve.analysis.service.updater.UndeploymentVisualizationStage) PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) URL(java.net.URL) Before(org.junit.Before)

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