use of org.palladiosimulator.pcm.repository.OperationProvidedRole 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.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class DataProtectionWarner method addConnectors.
/**
* Adding connections between components to the privacy graph.
*
* @param graph
* graph
* @throws DBException
* on db errors during resolving objects
* @throws InvocationException
* on other errors during resolving objects
*/
private void addConnectors(final PrivacyGraph graph) throws InvocationException, DBException {
for (final Connector connector : this.systemRootElement.getConnectors__ComposedStructure()) {
if (connector instanceof AssemblyConnector) {
final AssemblyConnector assemblyConnector = (AssemblyConnector) connector;
// Providing Component
final AssemblyContext provididingAssemblyContext = assemblyConnector.getProvidingAssemblyContext_AssemblyConnector();
final RepositoryComponent providingComponent = this.repositoryResource.resolve(provididingAssemblyContext.getEncapsulatedComponent__AssemblyContext());
// Requiring Component
final AssemblyContext requiringAssemblyContext = assemblyConnector.getRequiringAssemblyContext_AssemblyConnector();
final RepositoryComponent requiringComponent = this.repositoryResource.resolve(requiringAssemblyContext.getEncapsulatedComponent__AssemblyContext());
if (providingComponent != null && requiringComponent != null) {
final OperationProvidedRole providedRole = this.repositoryResource.resolve(assemblyConnector.getProvidedRole_AssemblyConnector());
final String interfaceName = this.shortName(providedRole.getEntityName());
// Check Interface Name in Repository and add Edge
final OperationInterface operationInterface = this.interfaces.get(interfaceName);
this.computePrivacyLevelsAndAddEdge(graph, operationInterface, providingComponent, requiringComponent);
} else {
this.logger.info("Either Providing: " + providingComponent + " was Null or Requiring: " + requiringComponent + " was Null.");
}
}
}
}
Aggregations