コード例 #1
0
  /**
   * Gets the application list response.
   *
   * @param applicationList the application list
   * @return the application list response
   * @throws Exception the exception
   */
  public static ApplicationListResponse getApplicationListResponse(
      List<edu.sga.apex.entity.Application> applicationList) throws Exception {
    ApplicationListResponse appListResponse = factory.createApplicationListResponse();

    /* check valid dao entity */
    if (applicationList != null) {
      for (edu.sga.apex.entity.Application application : applicationList) {
        /* construct application jaxb for each dao */
        Application applicationJAXB = factory.createApplication();
        applicationJAXB.setAppID(application.getAppId());
        applicationJAXB.setAppName(application.getAppName());
        applicationJAXB.setScriptPath(application.getScript_path());

        /* check valid application input */
        if (application.getInputList() != null && !application.getInputList().isEmpty()) {
          for (AppInput appInputDAO : application.getInputList()) {
            /* construct app input jaxb */
            ApplicationInput appInputJAXB = factory.createApplicationInput();
            appInputJAXB.setInput(appInputDAO.getInput());
            appInputJAXB.setDescription(appInputDAO.getDescription());

            /* add appInput jaxb to application jaxb */
            applicationJAXB.getAppInputs().add(appInputJAXB);
          }
        }

        /* add application jaxb to list response */
        appListResponse.getApplicationList().add(applicationJAXB);
      }
    } else {
      throw new Exception("Empty Application List DAO received. Cannot construct JAXB.");
    }

    return appListResponse;
  }
コード例 #2
0
  /**
   * Gets the experiment jaxb.
   *
   * @param experiment the experiment
   * @return the experiment jaxb
   * @throws Exception the exception
   */
  public static edu.sga.apex.rest.jaxb.Experiment getExperimentJAXB(Experiment experiment)
      throws Exception {
    /* check valid experiment dao */
    if (experiment != null) {
      edu.sga.apex.rest.jaxb.Experiment experimentJAXB = factory.createExperiment();

      /* set basic jaxb parameters */
      experimentJAXB.setJobID(experiment.getJobId());
      experimentJAXB.setJobName(experiment.getJobName());
      experimentJAXB.setStatus(experiment.getStatus());
      experimentJAXB.setWallTime(experiment.getWallTime());
      experimentJAXB.setNumNodes(experiment.getNumOfNodes());
      experimentJAXB.setNumProcPerNode(experiment.getProcPerNode());

      /* set date parameters */
      if (experiment.getCreatedAt() != null && experiment.getUpdatedAt() != null) {
        experimentJAXB.setCreatedAt(APIUtil.getXMLGregorianCalendar(experiment.getCreatedAt()));
        experimentJAXB.setUpdatedAt(APIUtil.getXMLGregorianCalendar(experiment.getUpdatedAt()));
      }

      /* check if user entity exists */
      if (experiment.getUserName() != null) {
        experimentJAXB.setUserName(experiment.getUserName().getUsername());
      }

      /* construct the application jaxb from dao */
      if (experiment.getApplication() != null) {
        Application applicationJAXB = factory.createApplication();
        applicationJAXB.setAppID(experiment.getApplication().getAppId());
        applicationJAXB.setAppName(experiment.getApplication().getAppName());
        applicationJAXB.setScriptPath(experiment.getApplication().getScript_path());

        /* set the application jaxb */
        experimentJAXB.setApplication(applicationJAXB);
      }

      /* construct the machine jaxb from dao */
      if (experiment.getMachine() != null) {
        Machine machineJAXB = factory.createMachine();
        machineJAXB.setHostName(experiment.getMachine().getHostname());
        machineJAXB.setMachineID(experiment.getMachine().getMachineId());
        machineJAXB.setMachineName(experiment.getMachine().getMachineName());
        machineJAXB.setPortNumber(experiment.getMachine().getPortNum());
        machineJAXB.setWorkingDir(experiment.getMachine().getWorking_dir());

        /* set the machine jaxb */
        experimentJAXB.setMachine(machineJAXB);
      }

      return experimentJAXB;
    } else {
      throw new Exception("Empty Experiment DAO received. Cannot construct JAXB.");
    }
  }