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