use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class DataProtectionWarner method addDeployedComponents.
/**
* Adding deployment info.
*
* @param privacyGraph
* the graph containing privacy information
* @throws DBException
* @throws InvocationException
*/
private void addDeployedComponents(final PrivacyGraph privacyGraph) throws InvocationException, DBException {
DeploymentLock.lock();
for (final AllocationContext allocationContext : this.allocationRootElement.getAllocationContexts_Allocation()) {
final AssemblyContext proxyAssemblyContext = allocationContext.getAssemblyContext_AllocationContext();
final AssemblyContext assemblyContext = this.systemModelResource.resolve(proxyAssemblyContext);
final RepositoryComponent proxyComponent = assemblyContext.getEncapsulatedComponent__AssemblyContext();
final BasicComponent basicComponent = (BasicComponent) this.repositoryResource.resolve(proxyComponent);
/**
* Creating component vertices. *
*/
// TODO name should be allocation name or assembly name + instance count
final Vertex vertex = new Vertex(basicComponent.getEntityName(), this.computeStereotype(basicComponent));
vertex.setAllocationContext(allocationContext);
privacyGraph.addVertex(vertex);
this.vertices.put(basicComponent.getId(), vertex);
final ResourceContainer resourceContainer = this.resourceEnvironmentResource.resolve(allocationContext.getResourceContainer_AllocationContext());
final GeoLocation geo = this.geolocations.get(resourceContainer.getId());
if (geo == null) {
this.logger.info("Geolocation infomation not available {}", resourceContainer.getId());
} else {
final Vertex vGeo = new Vertex(geo.getIsocode().getName(), EStereoType.GEOLOCATION);
if (!this.vertices.containsKey(geo.getIsocode().getName())) {
// New Geolocation
privacyGraph.addVertex(vGeo);
privacyGraph.addEdge(vGeo, vertex);
this.vertices.put(geo.getIsocode().getName(), vGeo);
} else {
// Existing Geolocation
privacyGraph.addEdge(this.vertices.get(geo.getIsocode().getName()), vertex);
}
}
}
DeploymentLock.unlock();
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent 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;
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddAssemblyContext method getRepositoryComponent.
private RepositoryComponent getRepositoryComponent(final AssemblyContext assemblyContext) {
final PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), FILTER_LIST, ADDITIONAL_REFERENCES, assemblyContext.eResource().getResourceSet());
dialog.setProvidedService(RepositoryComponent.class);
dialog.open();
if (dialog.getResult() == null) {
return null;
}
if (!(dialog.getResult() instanceof RepositoryComponent)) {
return null;
}
return (RepositoryComponent) dialog.getResult();
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent 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.RepositoryComponent 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);
}
}
}
}
Aggregations