use of org.palladiosimulator.pcm.resourcetype.ResourceRepository in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddLinkingResourceAction method execute.
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final Object parameter = parameters.get(NEW_COMMUNICATION_LINK_RESOURCE_SPECIFICATION);
if (parameter == null || !(parameter instanceof CommunicationLinkResourceSpecification)) {
return;
}
final CommunicationLinkResourceSpecification communicationLinkResourceSpecification = (CommunicationLinkResourceSpecification) parameter;
// latency
final PCMRandomVariable latency = getRandomVariableFromStoExDialog(LATENCY_DISPLAY_TITLE);
if (latency == null) {
return;
}
communicationLinkResourceSpecification.setLatency_CommunicationLinkResourceSpecification(latency);
// throughput
final PCMRandomVariable throughput = getRandomVariableFromStoExDialog(THROUGHPUT_DISPLAY_TITLE);
if (throughput == null) {
return;
}
communicationLinkResourceSpecification.setThroughput_CommunicationLinkResourceSpecification(throughput);
// Communication Link
Session session = SessionManager.INSTANCE.getSession(communicationLinkResourceSpecification);
URI uri = URI.createURI("pathmap://PCM_MODELS/Palladio.resourcetype");
Resource palladioResources = SiriusCustomUtil.getResourceByURI(uri, session);
if (palladioResources != null) {
ResourceRepository rep = (ResourceRepository) palladioResources.getContents().iterator().next();
for (EObject o : rep.eContents()) {
if ((o instanceof CommunicationLinkResourceType) && ((CommunicationLinkResourceType) o).getEntityName().equals("LAN")) {
communicationLinkResourceSpecification.setCommunicationLinkResourceType_CommunicationLinkResourceSpecification((CommunicationLinkResourceType) o);
break;
}
}
}
}
Aggregations