use of org.palladiosimulator.pcm.resourceenvironment.impl.LinkingResourceImpl in project iobserve-analysis by research-iobserve.
the class InitializeDeploymentVisualization method getTechnology.
/**
* Help function for getting the technology used for communication. Therefore get the
* {@link ResourceContainer}s on which the two communicating {@link AssemblyContext}s are
* deployed. This information is stored in the {@link Allocation} model. Then find the
* {@link LinkingResource} in the {@link ResourceEnvironment} model, that connect these
* {@link ResourceContainer}s.
*
* @param connector
* assembly connector
* @param linkingResources
* list of linking resources
* @return technology used for communication, entity name of linking resource
*/
private String getTechnology(final AssemblyConnector connector, final List<LinkingResource> linkingResources) {
final String assemblyContextSourceId = connector.getProvidingAssemblyContext_AssemblyConnector().getId();
final String assemblyContextTargetId = connector.getRequiringAssemblyContext_AssemblyConnector().getId();
/**
* ID of resource container on which source (regarding communication) assembly context is
* deployed
*/
final String resourceSourceId = this.findResourceIdByAssemblyContextId(assemblyContextSourceId);
/**
* ID of resource container on which target (regarding communication) assembly context is
* deployed
*/
final String resourceTargetId = this.findResourceIdByAssemblyContextId(assemblyContextTargetId);
/**
* technology of communication
*/
String technology = null;
if (resourceSourceId != null && resourceTargetId != null) {
for (int l = 0; l < linkingResources.size(); l++) {
final LinkingResource linkingResource = linkingResources.get(l);
if (linkingResource instanceof LinkingResourceImpl) {
final List<ResourceContainer> connectedResourceConts = linkingResource.getConnectedResourceContainers_LinkingResource();
final List<String> connectedResourceContsIds = new ArrayList<>();
for (int k = 0; k < connectedResourceConts.size(); k++) {
connectedResourceContsIds.add(connectedResourceConts.get(k).getId());
}
if (connectedResourceContsIds.contains(resourceSourceId) && connectedResourceContsIds.contains(resourceTargetId)) {
technology = linkingResource.getEntityName();
}
}
}
}
return technology;
}
Aggregations