use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddATAction method execute.
/**
* Creates an {@link ArchitecturalTemplateSelectEObjectDialog} that queries the user for an
* {@link AT} and applies the corresponding {@link Stereotype} to the selected {@link System}.
*/
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final ArchitecturalTemplateSelectionDialog profileSelectionDialog = new ArchitecturalTemplateSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
profileSelectionDialog.setElements(ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().toArray(new AT[ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().size()]));
profileSelectionDialog.setMessage(DIALOG_MESSAGE);
if (profileSelectionDialog.open() != Dialog.OK) {
return;
}
final AT at = profileSelectionDialog.getResultArchitecturalTemplate();
final EObject eObject = selections.iterator().next();
if (eObject instanceof System) {
final System system = (System) eObject;
ArchitecturalTemplateAPI.applyArchitecturalTemplate(system, at);
} else if (eObject instanceof ResourceEnvironment) {
final ResourceEnvironment resourceenvironment = (ResourceEnvironment) eObject;
ArchitecturalTemplateAPI.applyArchitecturalTemplate(resourceenvironment, at);
} else {
throw new RuntimeException("Unsupported eObject: " + eObject);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenReadByType.
@Override
@Test
public void createThenReadByType() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ModelProvider<ResourceContainer> modelProvider2 = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
final List<ResourceContainer> writtenContainers = writtenModel.getResourceContainer_ResourceEnvironment();
final List<String> readIds;
// Create complete model but only read ResourceContainers because ResourceEnvironment itself
// has no id
modelProvider.createComponent(writtenModel);
readIds = modelProvider2.readComponentByType(ResourceContainer.class);
Assert.assertTrue(readIds.size() == writtenContainers.size());
for (int i = 0; i < readIds.size(); i++) {
boolean foundEqualElem = false;
for (int j = 0; j < readIds.size(); j++) {
if (writtenContainers.get(i).getId().equals(readIds.get(j))) {
foundEqualElem = true;
}
}
Assert.assertTrue(foundEqualElem);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenDeleteComponentAndDatatypes.
@Override
@Test
public void createThenDeleteComponentAndDatatypes() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
modelProvider.createComponent(writtenModel);
Assert.assertFalse(IModelProviderTest.isGraphEmpty(modelProvider));
for (final LinkingResource lr : writtenModel.getLinkingResources__ResourceEnvironment()) {
new ModelProvider<LinkingResource>(ResourceEnvironmentModelProviderTest.graph).deleteComponentAndDatatypes(LinkingResource.class, lr.getId(), true);
}
for (final ResourceContainer rc : writtenModel.getResourceContainer_ResourceEnvironment()) {
new ModelProvider<ResourceContainer>(ResourceEnvironmentModelProviderTest.graph).deleteComponentAndDatatypes(ResourceContainer.class, rc.getId(), true);
}
Assert.assertTrue(IModelProviderTest.isGraphEmpty(modelProvider));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenReadReferencing.
@Override
@Test
public void createThenReadReferencing() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final TestModelBuilder testModelBuilder = new TestModelBuilder();
final ResourceEnvironment writtenModel = testModelBuilder.getResourceEnvironment();
final List<EObject> readReferencingComponents;
modelProvider.createComponent(writtenModel);
readReferencingComponents = modelProvider.readOnlyReferencingComponentsById(CommunicationLinkResourceType.class, testModelBuilder.getLan1Type().getId());
// Only the lan1 CommunicationLinkResourceSpecification is referencing the lan1
// CommunicationLinkResourceType
Assert.assertTrue(readReferencingComponents.size() == 1);
Assert.assertTrue(this.equalityHelper.equals(testModelBuilder.getLan1Specification(), readReferencingComponents.get(0)));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenReadByName.
@Override
@Test
public void createThenReadByName() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
final List<ResourceEnvironment> readModels;
modelProvider.createComponent(writtenModel);
readModels = modelProvider.readOnlyComponentByName(ResourceEnvironment.class, writtenModel.getEntityName());
Assert.assertTrue(readModels.size() == 1);
for (final ResourceEnvironment readModel : readModels) {
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
}
Aggregations