Search in sources :

Example 31 with AssemblyContext

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

the class CreateCorrespondenceMain method main.

/**
 * @param args
 *            arguments
 */
public static void main(final String[] args) {
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_FrontendService", "jpetstore-frontend-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_AccountService", "jpetstore-account-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_CatalogService", "jpetstore-catalog-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_OdrderService", "jpetstore-order-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_AccountDatabase", "jpetstore-account-database");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_CatalogDatabase", "jpetstore-catalog-database");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_OrderDatabase", "jpetstore-order-database");
    final String pcmDirectory = "/home/reiner/Projects/iObserve/experiments/distributed-jpetstore-experiment/pcm/JPetStore";
    try {
        final ModelImporter modelHandler = new ModelImporter(new File(pcmDirectory));
        // final Repository repository = modelHandler.getRepositoryModel();
        // final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
        final System system = modelHandler.getSystemModel();
        // final Allocation allocation = modelHandler.getAllocationModel();
        final CorrespondenceModel correspondenceModel = CorrespondenceFactory.eINSTANCE.createCorrespondenceModel();
        final Part part = CorrespondenceFactory.eINSTANCE.createPart();
        correspondenceModel.getParts().add(part);
        part.setModelType(system);
        for (final AssemblyContext assembly : system.getAssemblyContexts__ComposedStructure()) {
            final AssemblyEntry entry = CorrespondenceFactory.eINSTANCE.createAssemblyEntry();
            final String value = CreateCorrespondenceMain.NAME_MAPS.get(assembly.getEntityName());
            entry.setImplementationId(value);
            entry.setAssembly(assembly);
            part.getEntries().add(entry);
        }
        final URI outputURI = URI.createFileURI("/home/reiner/correspondence.correspondence");
        CreateCorrespondenceMain.save(correspondenceModel, outputURI);
    } catch (final IOException e) {
        CreateCorrespondenceMain.LOGGER.error("Canot load all models {}", e.getLocalizedMessage());
    }
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) Part(org.iobserve.model.correspondence.Part) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) IOException(java.io.IOException) File(java.io.File) URI(org.eclipse.emf.common.util.URI) System(org.palladiosimulator.pcm.system.System)

Example 32 with AssemblyContext

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

the class AllocationModelProviderTest method createThenReadReferencing.

@Override
@Test
public void createThenReadReferencing() throws DBException {
    final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_READ_REFERENCING, this.prefix, this.ePackage);
    resource.storeModelPartition(this.testModel);
    final AssemblyContext context = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.PAYMENT_ASSEMBLY_CONTEXT);
    final List<EObject> readReferencingComponents = resource.collectReferencingObjectsByTypeAndProperty(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(context));
    // Only the payment server allocation context is referencing the payment assembly context
    Assert.assertTrue(readReferencingComponents.size() == 1);
    Assert.assertTrue(this.equalityHelper.comparePartition(AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.PAYMENT_ALLOCATION_CONTEXT), readReferencingComponents.get(0), this.testModel.eClass()));
    resource.getGraphDatabaseService().shutdown();
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) EObject(org.eclipse.emf.ecore.EObject) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) Test(org.junit.Test)

Example 33 with AssemblyContext

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

the class PCMNeo4JTest method testUpdate.

/**
 * Test whether updates work as suggested.
 *
 * @throws NodeLookupException
 *             on node lookup errors
 * @throws DBException
 *             on db errors
 */
@Test
public void testUpdate() throws NodeLookupException, DBException {
    /**
     * store model in database.
     */
    this.repositoryResource.storeModelPartition(this.repository);
    this.resourceEnvironmentResource.storeModelPartition(this.resourceEnvironment);
    this.systemResource.storeModelPartition(this.system);
    this.allocationResource.storeModelPartition(this.allocation);
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3);
    final Allocation allocationModel = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
    newAllocationContext.setEntityName(AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_3);
    newAllocationContext.setAssemblyContext_AllocationContext(assemblyContext);
    newAllocationContext.setResourceContainer_AllocationContext(container);
    allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
    this.allocationResource.updatePartition(allocationModel);
    for (final AllocationContext context : this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT)) {
    // NOCS
    // TODO
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 34 with AssemblyContext

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

the class AllocationDataFactory method createAllocationContext.

private static AllocationContext createAllocationContext(final System system, final ResourceEnvironment resourceEnvironment, final String allocation, final String assemblyContextName, final String containerName) {
    final AllocationContext context = AllocationFactory.eINSTANCE.createAllocationContext();
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(system, assemblyContextName);
    final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(resourceEnvironment, containerName);
    context.setEntityName(allocation);
    context.setAssemblyContext_AllocationContext(assemblyContext);
    context.setResourceContainer_AllocationContext(container);
    return context;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 35 with AssemblyContext

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

the class AllocationServices method getUndeployedAssemblyContexts.

public Collection<AssemblyContext> getUndeployedAssemblyContexts(Allocation allocation) {
    Collection<AssemblyContext> assemblyContexts = allocation.getSystem_Allocation().getAssemblyContexts__ComposedStructure();
    Collection<AssemblyContext> result = new ArrayList<AssemblyContext>();
    for (AssemblyContext assemblyContext : assemblyContexts) {
        if (assemblyContext.getEncapsulatedComponent__AssemblyContext() instanceof SubSystem) {
            if (hasDeployedComponents((SubSystem) assemblyContext.getEncapsulatedComponent__AssemblyContext(), allocation)) {
                result.add(assemblyContext);
                result.addAll(getUndeployedSubAssemblyContexts(assemblyContext, allocation, true));
            }
        }
    }
    return result;
}
Also used : SubSystem(org.palladiosimulator.pcm.subsystem.SubSystem) ArrayList(java.util.ArrayList) 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