use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class DeploymentModelUpdater method createAndAddAssemblyContext.
/**
* Create {@link AssemblyContext} with the given name and insert it in the system model.
*
* @param systemModelProvider
* system model provider
* @param name
* name of the assembly context
* @return created assembly context
*/
private AssemblyContext createAndAddAssemblyContext(final IModelProvider<org.palladiosimulator.pcm.system.System> systemModelProvider, final String name) {
final org.palladiosimulator.pcm.system.System systemModel = systemModelProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class);
final AssemblyContext assemblyContext = SystemModelFactory.createAssemblyContextsIfAbsent(systemModel, name);
systemModelProvider.updateComponent(org.palladiosimulator.pcm.system.System.class, systemModel);
return assemblyContext;
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class EntryEventMapperStage method computePcmEntryCallEvent.
private void computePcmEntryCallEvent(final ComponentEntry componentEntry, final OperationEntry operationEntry, final AllocationEntry allocationEntry, final EntryCallEvent event) throws DBException {
/**
* retrieve PCM model elements from mapping.
*/
final AllocationContext allocationContext = this.allocationResource.findObjectByTypeAndId(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, ModelGraphFactory.getIdentification(allocationEntry.getAllocation()));
final OperationSignature operationSignature = this.repositoryResource.findAndLockObjectById(OperationSignature.class, RepositoryPackage.Literals.OPERATION_SIGNATURE, ModelGraphFactory.getIdentification(operationEntry.getOperation()));
final RepositoryComponent component = this.repositoryResource.findObjectByTypeAndId(RepositoryComponent.class, RepositoryPackage.Literals.REPOSITORY_COMPONENT, ModelGraphFactory.getIdentification(componentEntry.getComponent()));
/**
* assembly is inferred from allocation.
*/
final AssemblyContext assemblyContext = this.assemblyResource.findObjectByTypeAndId(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(allocationContext.getAssemblyContext_AllocationContext()));
/**
* assemble event.
*/
final PCMEntryCallEvent mappedEvent = new PCMEntryCallEvent(event.getEntryTime(), event.getExitTime(), component, operationSignature, assemblyContext, allocationContext);
this.outputPort.send(mappedEvent);
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext 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.core.composition.AssemblyContext 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.core.composition.AssemblyContext in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddAllocationContextAssemblyContext method execute.
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
AllocationContext allocationContext = (AllocationContext) parameters.get("instance");
AssemblyContext assemblyContext = (AssemblyContext) getAssemblyContext(allocationContext);
allocationContext.setAssemblyContext_AllocationContext(assemblyContext);
}
Aggregations