use of org.palladiosimulator.pcm.repository.Interface in project iobserve-analysis by research-iobserve.
the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() {
final ModelProvider<Repository> modelProvider = new ModelProvider<>(RepositoryModelProviderTest.graph);
final TestModelBuilder testModelBuilder = new TestModelBuilder();
final Repository writtenModel = testModelBuilder.getRepository();
final Interface payInterface = testModelBuilder.getPayInterface();
final RepositoryComponent paymentComponent = testModelBuilder.getPaymentComponent();
final Repository readModel;
modelProvider.createComponent(writtenModel);
// Update the model by renaming and replacing the payment method
writtenModel.setEntityName("MyVideoOnDemandService");
final OperationProvidedRole providedPayOperation = RepositoryFactory.eINSTANCE.createOperationProvidedRole();
providedPayOperation.setEntityName("payPalPayment");
providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
modelProvider.updateComponent(Repository.class, writtenModel);
readModel = modelProvider.readOnlyRootComponent(Repository.class);
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
use of org.palladiosimulator.pcm.repository.Interface in project iobserve-analysis by research-iobserve.
the class RepositoryModelHandler method loadData.
/**
* Loading and initializing the maps for data access.
*
* @param model
* repository model
* @deprecated this functionality now resides in {@link RepositoryLookupModelProvier}
*/
@Deprecated
public void loadData(final Repository model) {
this.opInfToProvInfMap = new HashMap<>();
this.opProvidedRoleMap = new HashMap<>();
this.operationInterfaceMap = new HashMap<>();
this.operationSignatureMap = new HashMap<>();
// loading OperationProvidedRoles and OperationInterfaces in dedicated maps
for (final RepositoryComponent nextRepoCmp : model.getComponents__Repository()) {
if (nextRepoCmp instanceof BasicComponent) {
final BasicComponent basicCmp = (BasicComponent) nextRepoCmp;
for (final ProvidedRole providedRole : basicCmp.getProvidedRoles_InterfaceProvidingEntity()) {
if (providedRole instanceof OperationProvidedRole) {
final OperationProvidedRole opProvRole = (OperationProvidedRole) providedRole;
final OperationInterface opInterface = opProvRole.getProvidedInterface__OperationProvidedRole();
this.opInfToProvInfMap.put(opInterface.getId(), opProvRole.getId());
this.opProvidedRoleMap.put(opProvRole.getId(), opProvRole);
}
}
}
}
// loading OperationInterfaces and OperationSignatures in dedicated maps
for (final Interface nextInterface : model.getInterfaces__Repository()) {
if (nextInterface instanceof OperationInterface) {
final OperationInterface opInf = (OperationInterface) nextInterface;
this.operationInterfaceMap.put(opInf.getId(), opInf);
for (final OperationSignature opSig : opInf.getSignatures__OperationInterface()) {
this.operationSignatureMap.put(opSig.getId(), opSig);
}
}
}
}
use of org.palladiosimulator.pcm.repository.Interface in project iobserve-analysis by research-iobserve.
the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
final Neo4JModelResource<Repository> resource = ModelProviderTestUtils.prepareResource("createThenUpdateThenReadUpdated", this.prefix, this.ePackage);
final Interface payInterface = RepositoryModelDataFactory.findInterfaceByName(this.repository, RepositoryModelDataFactory.PAYMENT_INTERFACE);
final RepositoryComponent paymentComponent = RepositoryModelDataFactory.findComponentByName(this.repository, RepositoryModelDataFactory.PAYMENT_COMPONENT);
resource.storeModelPartition(this.testModel);
// Update the model by renaming and replacing the payment method
this.testModel.setEntityName("MyVideoOnDemandService");
final OperationProvidedRole providedPayOperation = ((RepositoryFactory) this.ePackage.getEFactoryInstance()).createOperationProvidedRole();
providedPayOperation.setEntityName("payPalPayment");
providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
resource.updatePartition(this.testModel);
final Repository readModel = resource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
resource.getGraphDatabaseService().shutdown();
}
use of org.palladiosimulator.pcm.repository.Interface in project iobserve-analysis by research-iobserve.
the class RepositoryLookupModelProvider method initializeLookupMaps.
/**
* Initializing the maps for data access.
*/
private void initializeLookupMaps() {
this.opInfToProvInfMap = new HashMap<>();
this.opProvidedRoleMap = new HashMap<>();
this.operationInterfaceMap = new HashMap<>();
this.operationSignatureMap = new HashMap<>();
// loading OperationProvidedRoles and OperationInterfaces in dedicated maps
for (final RepositoryComponent nextRepoCmp : this.repositoryModel.getComponents__Repository()) {
if (nextRepoCmp instanceof BasicComponent) {
final BasicComponent basicCmp = (BasicComponent) nextRepoCmp;
for (final ProvidedRole providedRole : basicCmp.getProvidedRoles_InterfaceProvidingEntity()) {
if (providedRole instanceof OperationProvidedRole) {
final OperationProvidedRole opProvRole = (OperationProvidedRole) providedRole;
final OperationInterface opInterface = opProvRole.getProvidedInterface__OperationProvidedRole();
this.opInfToProvInfMap.put(opInterface.getId(), opProvRole.getId());
this.opProvidedRoleMap.put(opProvRole.getId(), opProvRole);
}
}
}
}
// loading OperationInterfaces and OperationSignatures in dedicated maps
for (final Interface nextInterface : this.repositoryModel.getInterfaces__Repository()) {
if (nextInterface instanceof OperationInterface) {
final OperationInterface opInf = (OperationInterface) nextInterface;
this.operationInterfaceMap.put(opInf.getId(), opInf);
for (final OperationSignature opSig : opInf.getSignatures__OperationInterface()) {
this.operationSignatureMap.put(opSig.getId(), opSig);
}
}
}
}
use of org.palladiosimulator.pcm.repository.Interface in project iobserve-analysis by research-iobserve.
the class NonAdaptiveModelProbeController method computeAvailableProbes.
/**
* Compute available probes.
*
* @return returns a map of {@link AllocationContext}s and their relevant
* {@link OperationSignature}s
* @throws DBException
*/
private Map<AllocationContext, Set<OperationSignature>> computeAvailableProbes() throws DBException {
final Repository repositoryModel = this.repositoryResource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
final List<AllocationContext> allocations = this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT);
final Map<AllocationContext, Set<OperationSignature>> availableProbes = new HashMap<>();
this.logger.debug("Found " + allocations.size() + " allocation context entries");
for (final AllocationContext allocation : allocations) {
final Set<OperationSignature> allocationMethods = new LinkedHashSet<>();
try {
final AssemblyContext assemblyContext = this.systemModelResource.resolve(allocation.getAssemblyContext_AllocationContext());
final RepositoryComponent component = this.repositoryResource.resolve(assemblyContext.getEncapsulatedComponent__AssemblyContext());
final List<ProvidedRole> providingRoles = component.getProvidedRoles_InterfaceProvidingEntity();
for (final ProvidedRole providedRole : providingRoles) {
this.logger.debug("Providing roles: " + providingRoles);
final String roleName = providedRole.getEntityName();
for (final Interface iface : repositoryModel.getInterfaces__Repository()) {
if (iface instanceof OperationInterface) {
if (roleName.contains(iface.getEntityName())) {
this.logger.debug("Matching operation interfaces: " + ((OperationInterface) iface).getSignatures__OperationInterface());
// found interface
allocationMethods.addAll(((OperationInterface) iface).getSignatures__OperationInterface());
}
}
}
}
} catch (InvocationException | DBException e) {
this.logger.error("Could not resolve elements of the PCM during the computation of the available probes", e);
}
availableProbes.put(allocation, allocationMethods);
}
return availableProbes;
}
Aggregations