Search in sources :

Example 1 with LinkingResourceImpl

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;
}
Also used : LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ArrayList(java.util.ArrayList) LinkingResourceImpl(org.palladiosimulator.pcm.resourceenvironment.impl.LinkingResourceImpl) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Aggregations

ArrayList (java.util.ArrayList)1 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1 LinkingResourceImpl (org.palladiosimulator.pcm.resourceenvironment.impl.LinkingResourceImpl)1