Example #1
0
  /**
   * It will create a new scenario based on the given one, if the given one is not already saved.
   * The returned scenario will have some (or all if possible) assignments on resource settings
   * resolved. The method calls internally {@link #resolveAssignments(RequestedFederationScenario)}
   *
   * @param The requested scenario
   * @return a new scenario based on the requested, with resolved dependencies (if possible at first
   *     pass)
   */
  public RequestedFederationScenario prepareScenarioRequest(RequestedFederationScenario scenario) {

    RequestedFederationScenario newScenario;
    if (scenario.getRuntimeInfo() == null) {
      newScenario = FederationscenariosFactory.eINSTANCE.createRequestedFederationScenario();
      newScenario = (RequestedFederationScenario) EcoreUtil.copy(scenario);
      RuntimeElement rtinfo = ExperimentRuntimeFactory.eINSTANCE.createRuntimeElement();
      rtinfo.setDescription(
          "Scenario is based on request by:" + scenario.eResource().getURI().path());
      newScenario.setRuntimeInfo(rtinfo);
      for (ResourceRequest resReq :
          newScenario.getInfrastructureRequest().getReqOfferedResources()) {
        RuntimeElement rtInfo = ExperimentRuntimeFactory.eINSTANCE.createRuntimeElement();
        resReq.setRuntimeInfo(rtInfo);
        rtInfo.setStatus(RuntimeElementStatus.NOT_EXISTS);
      }

    } else {
      newScenario = scenario;
    }

    resolveAssignments(newScenario);
    return newScenario;
  }