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;
}
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());
}
}
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
}
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);
}
}
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);
}
Aggregations