use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemDataFactory method createAssemblyContext.
private static AssemblyContext createAssemblyContext(final Repository repository, final String contextName, final String componentName) {
final AssemblyContext assemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext();
final RepositoryComponent component = RepositoryModelDataFactory.findComponentByName(repository, componentName);
assemblyContext.setEncapsulatedComponent__AssemblyContext(component);
assemblyContext.setEntityName(contextName);
return assemblyContext;
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemModelProviderTest method createThenReadReferencing.
@Override
@Test
public void createThenReadReferencing() throws DBException {
final Neo4JModelResource<System> resource = ModelProviderTestUtils.prepareResource("createThenReadReferencing", this.prefix, this.ePackage);
resource.storeModelPartition(this.testModel);
final List<EObject> expectedReferencingComponents = new LinkedList<>();
final List<EObject> readReferencingComponents;
final Connector businessQueryConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_QUERY_CONNECTOR);
final Connector businessPayConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_PAY_CONNECTOR);
expectedReferencingComponents.add(businessQueryConnector);
expectedReferencingComponents.add(businessPayConnector);
final AssemblyContext context = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.BUSINESS_ORDER_ASSEMBLY_CONTEXT);
readReferencingComponents = resource.collectReferencingObjectsByTypeAndProperty(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(context));
// Only the businessQueryInputConnector and the businessPayConnector are referencing the
// businessOrderContext
Assert.assertTrue(readReferencingComponents.size() == 2);
Assert.assertTrue(this.equalityHelper.comparePartitions(expectedReferencingComponents, readReferencingComponents, readReferencingComponents.get(0).eClass()));
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
final Neo4JModelResource<System> resource = ModelProviderTestUtils.prepareResource("createThenUpdateThenReadUpdated", this.prefix, this.ePackage);
resource.storeModelPartition(this.testModel);
// Update the model by renaming and removing the business context
this.testModel.setEntityName("MyVideoOnDemandService");
final AssemblyContext businessQueryAssemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.BUSINESS_ORDER_ASSEMBLY_CONTEXT);
final Connector businessQueryConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_QUERY_CONNECTOR);
final Connector businessPayConnector = SystemDataFactory.findConnector(this.system, SystemDataFactory.BUSINESS_PAY_CONNECTOR);
this.testModel.getAssemblyContexts__ComposedStructure().remove(businessQueryAssemblyContext);
this.testModel.getConnectors__ComposedStructure().remove(businessQueryConnector);
this.testModel.getConnectors__ComposedStructure().remove(businessPayConnector);
// Replace the business context by a context for groups of people placing an order
final AssemblyContext sharedOrderContext = CompositionFactory.eINSTANCE.createAssemblyContext();
sharedOrderContext.setEntityName("sharedOrderContext_org.myvideoondemandservice.orderComponent");
sharedOrderContext.setEncapsulatedComponent__AssemblyContext(RepositoryModelDataFactory.findComponentByName(this.repository, RepositoryModelDataFactory.ORDER_COMPONENT));
final AssemblyContext queryInputAssemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
final OperationProvidedRole providedInputRole = RepositoryModelDataFactory.findProvidedRole(sharedOrderContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.QUERY_PROVIDED_ROLE);
final OperationRequiredRole requiredInputRole = RepositoryModelDataFactory.findRequiredRole(queryInputAssemblyContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.QUERY_REQUIRED_ROLE);
final AssemblyConnector sharedQueryInputConnector = CompositionFactory.eINSTANCE.createAssemblyConnector();
sharedQueryInputConnector.setEntityName("sharedQueryInput");
sharedQueryInputConnector.setProvidedRole_AssemblyConnector(providedInputRole);
sharedQueryInputConnector.setRequiredRole_AssemblyConnector(requiredInputRole);
sharedQueryInputConnector.setProvidingAssemblyContext_AssemblyConnector(sharedOrderContext);
sharedQueryInputConnector.setRequiringAssemblyContext_AssemblyConnector(queryInputAssemblyContext);
final AssemblyContext paymentAssemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.PAYMENT_ASSEMBLY_CONTEXT);
final OperationProvidedRole providedPayRole = RepositoryModelDataFactory.findProvidedRole(paymentAssemblyContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.PAYMENT_PROVIDED_ROLE);
final OperationRequiredRole requiredPayRole = RepositoryModelDataFactory.findRequiredRole(sharedOrderContext.getEncapsulatedComponent__AssemblyContext(), RepositoryModelDataFactory.PAYMENT_REQUIRED_ROLE);
final AssemblyConnector sharedPayConnector = CompositionFactory.eINSTANCE.createAssemblyConnector();
sharedPayConnector.setEntityName("sharedPayment");
sharedPayConnector.setProvidedRole_AssemblyConnector(providedPayRole);
sharedPayConnector.setRequiredRole_AssemblyConnector(requiredPayRole);
sharedPayConnector.setProvidingAssemblyContext_AssemblyConnector(paymentAssemblyContext);
sharedPayConnector.setRequiringAssemblyContext_AssemblyConnector(sharedOrderContext);
this.testModel.getAssemblyContexts__ComposedStructure().add(sharedOrderContext);
this.testModel.getConnectors__ComposedStructure().add(sharedQueryInputConnector);
this.testModel.getConnectors__ComposedStructure().add(sharedPayConnector);
resource.updatePartition(this.testModel);
final System readModel = resource.getModelRootNode(System.class, this.eClass);
Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class ModelProcessing method rebuildEnvironment.
private void rebuildEnvironment() throws ModelHandlingErrorException {
for (final AllocationGroup allocationGroup : this.originalAllocationGroups.getAllocationGroups()) {
final AllocationContext representingContext = allocationGroup.getRepresentingContext();
// Set assembly context from allocation group to the context from the processed model
final AssemblyContext representedAsmCtx = this.systemModel.getAssemblyContexts__ComposedStructure().stream().filter(ctx -> representingContext.getAssemblyContext_AllocationContext().getId().equals(ctx.getId())).findFirst().orElse(null);
if (representedAsmCtx == null) {
throw new RuntimeException("There was something wrong with the system model. Please check your models.");
}
representingContext.setAssemblyContext_AllocationContext(representedAsmCtx);
this.createResourcesAndReplicationDegrees(this.decisionModel, allocationGroup);
this.allocationModel.getAllocationContexts_Allocation().add(representingContext);
}
for (final AllocationGroup allocationGroup : this.originalAllocationGroups.getAllocationGroups()) {
final String allocationDegreeName = String.format("%s_AllocationDegree", allocationGroup.getName());
DesignDecisionModelFactory.createAllocationDegree(this.decisionModel, allocationDegreeName, allocationGroup.getRepresentingContext(), this.resourceEnvironmentModel.getResourceContainer_ResourceEnvironment());
}
ModelHelper.addAllAllocationsToReplicationDegrees(this.allocationModel, this.decisionModel);
this.saveModels();
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class AllocationGroupsContainer method getAllocationGroup.
/**
* Returns the allocation group to which the given allocation context belongs.
*
* @param allocContext
* the allocation context for which to get the allocation group
* @return the corresponding allocation group or null if there is none
*/
public AllocationGroup getAllocationGroup(final AllocationContext allocContext) {
final AssemblyContext asmContext = allocContext.getAssemblyContext_AllocationContext();
final String componentName = asmContext.getEncapsulatedComponent__AssemblyContext().getEntityName();
final String containerIdentifier = ModelHelper.getResourceContainerIdentifier(allocContext.getResourceContainer_AllocationContext());
return this.getAllocationGroup(componentName, containerIdentifier);
}
Aggregations