/**
   * Handles the user's request to update their experiment.
   *
   * @param command SequencerRun command object
   * @param request a {@link javax.servlet.http.HttpServletRequest} object.
   * @param response a {@link javax.servlet.http.HttpServletResponse} object.
   * @return a {@link org.springframework.web.servlet.ModelAndView} object.
   * @throws java.lang.Exception if any.
   */
  public ModelAndView handleUpdate(
      HttpServletRequest request, HttpServletResponse response, SequencerRun command)
      throws Exception {

    Registration registration = Security.getRegistration(request);
    if (registration == null) return new ModelAndView("redirect:/login.htm");

    ModelAndView modelAndView = null;
    BindingResult errors = this.validateSequencerRun(request, command);
    if (errors.hasErrors()) {
      Map model = errors.getModel();
      modelAndView = new ModelAndView("SequencerRunUpdate", model);
    } else {
      SequencerRun newSequencerRun = command;
      SequencerRun oldSequencerRun = getCurrentSequencerRun(request);
      if (newSequencerRun != null && oldSequencerRun != null) {
        new ServletRequestDataBinder(oldSequencerRun).bind(request);
        getSequencerRunService().update(oldSequencerRun);
        modelAndView = new ModelAndView("redirect:/sequencerRunList.htm");
      } else {
        modelAndView = new ModelAndView("redirect:/Error.htm");
      }
    }

    request.getSession(false).removeAttribute("sequencerRun");

    return modelAndView;
  }
Пример #2
0
  /** {@inheritDoc} */
  @Override
  protected ModelAndView handleRequestInternal(
      HttpServletRequest request, HttpServletResponse response) throws Exception {
    // TODO Auto-generated method stub
    Registration registration = Security.getRegistration(request);
    if (registration == null) return new ModelAndView("redirect:/login.htm");

    ModelAndView modelAndView = new ModelAndView("Search");
    modelAndView.addObject("types", getTypes());
    String checked = getChecked(request);
    if ("true".equals(checked)) {
      modelAndView.addObject("checked", "checked=\"yes\"");
    } else {
      modelAndView.addObject("checked", "");
    }
    return modelAndView;
  }
  /**
   * {@inheritDoc}
   *
   * @return
   * @throws java.lang.Exception
   */
  @Override
  protected ModelAndView handleRequestInternal(
      HttpServletRequest request, HttpServletResponse response) throws Exception {

    Registration registration = Security.getRegistration(request);
    if (registration == null) return new ModelAndView("redirect:/login.htm");

    WorkflowRun workflowRun = getRequestedWorkflowRun(request);

    if (workflowRun != null) {
      Integer ownerId = workflowRun.getOwner().getRegistrationId();
      Integer registrationId = registration.getRegistrationId();

      if (registrationId.equals(ownerId)) {
        if (workflowRun.getStatus() != WorkflowRunStatus.completed) {
          workflowRun.setStatus(WorkflowRunStatus.cancelled);
          getWorkflowRunService().update(workflowRun);
        }
      }
    }

    return null;
  }
  /**
   * Handles the user's request to submit a new experiment.
   *
   * @param request HttpServletRequest
   * @param response HttpServletResponse
   * @param command SequencerRun command object
   * @return ModelAndView
   * @throws java.lang.Exception if any.
   */
  public ModelAndView handleSubmit(
      HttpServletRequest request, HttpServletResponse response, SequencerRun command)
      throws Exception {

    Registration registration = Security.getRegistration(request);
    if (registration == null) return new ModelAndView("redirect:/login.htm");

    ModelAndView modelAndView = null;
    BindingResult errors = this.validateSequencerRun(request, command);
    if (errors.hasErrors()) {
      Map model = errors.getModel();
      modelAndView = new ModelAndView("SequencerRun1", model);
    } else {
      Debug.put("HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
      getSequencerRunService().insert(command);
      // command.setOwnerId(registration.getRegistrationId());
      modelAndView = new ModelAndView("redirect:/sequencerRunList.htm");
    }

    request.getSession(false).removeAttribute("sequencerRun");

    return modelAndView;
  }
  /**
   * Handles the user's request to submit a new study.
   *
   * @param request HttpServletRequest
   * @param response HttpServletResponse
   * @param command Study command object
   * @return ModelAndView
   * @throws java.lang.Exception if any.
   */
  public ModelAndView handleSubmit(
      HttpServletRequest request, HttpServletResponse response, UploadFile command)
      throws Exception {

    Registration registration = Security.getRegistration(request);
    if (registration == null) return new ModelAndView("redirect:/login.htm");

    ServletContext context = this.getServletContext();
    command.setFolderStore(context.getInitParameter("path.to.upload.directory"));
    command.setStrStartURL(context.getInitParameter("true.protocols"));

    ModelAndView modelAndView = null;
    BindingResult errors = this.validate(request, command);
    if (errors.hasErrors()) {
      Map model = errors.getModel();
      Integer id = getRequestedId(request);
      String typeNode = getRequestedTypeNode(request);
      String nameNode = getNameNode(id, typeNode);
      List<FileType> listFileType = getFileTypeService().list();

      model.put("id", id);
      model.put("tn", typeNode);
      model.put("nameNode", nameNode);
      model.put("listFileType", listFileType);

      modelAndView = new ModelAndView("UploadFile", model);
    } else {
      String folderStore = context.getInitParameter("path.to.upload.directory");

      // MultipartFile file = command.getFile();

      // MultipartFile file = command.getFileFromURL();

      Log.info("URL = " + command.getFileURL());
      Log.info("USE URL ? = " + command.getUseURL());

      FileType fileType = getFileTypeService().findByID(command.getFileTypeId());

      Integer id = getRequestedId(request);
      String typeNode = getRequestedTypeNode(request);

      Log.info("ID = " + id);
      Log.info("typeNode = " + typeNode);

      if ("st".equals(typeNode)) {
        Study study = getStudyService().findByID(id);
        getFileUploadService().uploadFile(study, command, fileType, registration);
      }

      if ("exp".equals(typeNode)) {
        Experiment experiment = getExperimentService().findByID(id);
        getFileUploadService().uploadFile(experiment, command, fileType, registration);
      }
      if ("sam".equals(typeNode)) {
        Sample sample = getSampleService().findByID(id);
        getFileUploadService().uploadFile(sample, command, fileType, registration);
      }
      if ("seq".equals(typeNode)) {
        Lane lane = getLaneService().findByID(id);
        getFileUploadService().uploadFile(lane, command, fileType, registration);
      }
      if ("ius".equals(typeNode)) {
        IUS ius = getIUSService().findByID(id);
        getFileUploadService().uploadFile(ius, command, fileType, registration);
      }
      if ("ae".equals(typeNode)) {
        Processing processing = getProcessingService().findByID(id);
        getFileUploadService().uploadFile(processing, command, fileType, registration);
      }
      if ("sr".equals(typeNode)) {
        SequencerRun sequencerRun = getSequencerRunService().findByID(id);
        getFileUploadService().uploadFile(sequencerRun, command, fileType, registration);
      }
      modelAndView = new ModelAndView(getViewName(request));
    }

    return modelAndView;
  }