Search in sources :

Example 1 with ResourceEnvironment

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);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) AT(org.palladiosimulator.architecturaltemplates.AT) ArchitecturalTemplateSelectionDialog(org.palladiosimulator.architecturaltemplates.ui.dialogs.ArchitecturalTemplateSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) System(org.palladiosimulator.pcm.system.System)

Example 2 with ResourceEnvironment

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);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 3 with ResourceEnvironment

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));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 4 with ResourceEnvironment

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)));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) EObject(org.eclipse.emf.ecore.EObject) CommunicationLinkResourceType(org.palladiosimulator.pcm.resourcetype.CommunicationLinkResourceType) Test(org.junit.Test)

Example 5 with ResourceEnvironment

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));
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Test(org.junit.Test)

Aggregations

ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)39 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)19 Test (org.junit.Test)12 Allocation (org.palladiosimulator.pcm.allocation.Allocation)9 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)8 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)7 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)7 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)6 EObject (org.eclipse.emf.ecore.EObject)5 PCMModelHandler (org.iobserve.model.PCMModelHandler)5 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)5 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)5 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)5 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)5 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)5 System (org.palladiosimulator.pcm.system.System)5 URI (org.eclipse.emf.common.util.URI)4 CostModelHandler (org.iobserve.model.provider.file.CostModelHandler)4 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)4 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)4