Esempio n. 1
0
  /**
   * Edit
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward edit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    log.debug("<TargetedModificationAction> Entering edit");
    if (!isTokenValid(request)) {
      return mapping.findForward("failure");
    }

    // Grab the current modelID from the session
    String modelID = (String) request.getSession().getAttribute(Constants.MODELID);

    TargetedModificationForm targetedModificationForm = (TargetedModificationForm) form;

    // Grab the current SpontaneousMutation we are working with related to
    // this
    String aTargetedModificationID = targetedModificationForm.getModificationId();

    log.debug(
        "<TargetedModificationAction save> following Characteristics:"
            + "\n\t getName: "
            + targetedModificationForm.getName()
            + "\n\t getModificationType: "
            + targetedModificationForm.getModificationType()
            + "\n\t getOtherModificationType: "
            + targetedModificationForm.getOtherModificationType()
            + "\n\t getGeneIdentifier: "
            + targetedModificationForm.getGeneIdentifier()
            + "\n\t getEsCellLineName: "
            + targetedModificationForm.getEsCellLineName()
            + "\n\t getBlastocystName: "
            + targetedModificationForm.getBlastocystName()
            + "\n\t getConditionedBy: "
            + targetedModificationForm.getConditionedBy()
            + "\n\t getDescription: "
            + targetedModificationForm.getDescription()
            + "\n\t getComments: "
            + targetedModificationForm.getComments()
            + "\n\t getMgiId: "
            + targetedModificationForm.getMgiId()
            + "\n\t getZfinId: "
            + targetedModificationForm.getZfinId()
            + "\n\t getRgdId: "
            + targetedModificationForm.getRgdId()
            + "\n\t getUrl: "
            + targetedModificationForm.getUrl()
            + "\n\t getTitle: "
            + targetedModificationForm.getTitle()
            + "\n\t getDescriptionOfConstruct: "
            + targetedModificationForm.getDescriptionOfConstruct()
            + "\n\t getConstructSequence(): "
            + targetedModificationForm.getConstructSequence()
            + (String) request.getSession().getAttribute("camod.loggedon.username"));

    TargetedModificationManager targetedModificationManager =
        (TargetedModificationManager) getBean("targetedModificationManager");
    String theAction = (String) request.getParameter(Constants.Parameters.ACTION);

    String theForward = "AnimalModelTreePopulateAction";
    try {
      // retrieve animal model by it's id
      AnimalModelManager theAnimalModelManager = (AnimalModelManager) getBean("animalModelManager");
      AnimalModel theAnimalModel = theAnimalModelManager.get(modelID);

      if ("Delete".equals(theAction)) {

        targetedModificationManager.remove(aTargetedModificationID, theAnimalModel);

        ActionMessages msg = new ActionMessages();
        msg.add(
            ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("targetedmodification.delete.successful"));
        saveErrors(request, msg);

      } else {
        TargetedModification theTargetedModification =
            targetedModificationManager.get(aTargetedModificationID);
        targetedModificationManager.update(
            theAnimalModel, targetedModificationForm, theTargetedModification, request);

        log.debug("TargetedModification edited");

        ActionMessages msg = new ActionMessages();
        msg.add(
            ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("targetedmodification.edit.successful"));
        saveErrors(request, msg);
      }
    } catch (IllegalArgumentException e) {
      log.error("Exception ocurred editing a TargetedModification", e);

      theForward = "input";

      // Encountered an error saving the model.
      ActionMessages msg = new ActionMessages();
      msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.image.unsupportedfiletype"));
      saveErrors(request, msg);

    } catch (Exception e) {
      log.error("Exception occurred creating a TargetedModification", e);

      // Encountered an error saving the model.
      ActionMessages msg = new ActionMessages();
      msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.admin.message"));
      saveErrors(request, msg);
    }

    log.debug("< TargetedModificationAction> Exiting edit");
    resetToken(request);

    return mapping.findForward(theForward);
  }
Esempio n. 2
0
  /**
   * Save
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward save(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    log.debug("<TargetedModificationAction> Entering save");
    if (!isTokenValid(request)) {
      return mapping.findForward("failure");
    }

    // Create a form to edit
    TargetedModificationForm targetedModificationForm = (TargetedModificationForm) form;

    // Grab the current modelID from the session
    String theModelId = (String) request.getSession().getAttribute(Constants.MODELID);

    log.debug(
        "<TargetedModificationAction save> following Characteristics:"
            + "\n\t getName: "
            + targetedModificationForm.getName()
            + "\n\t getModificationType: "
            + targetedModificationForm.getModificationType()
            + "\n\t getOtherModificationType: "
            + targetedModificationForm.getOtherModificationType()
            + "\n\t getGeneIdentifier: "
            + targetedModificationForm.getGeneIdentifier()
            + "\n\t getEsCellLineName: "
            + targetedModificationForm.getEsCellLineName()
            + "\n\t getBlastocystName: "
            + targetedModificationForm.getBlastocystName()
            + "\n\t getConditionedBy: "
            + targetedModificationForm.getConditionedBy()
            + "\n\t getDescription: "
            + targetedModificationForm.getDescription()
            + "\n\t getComments: "
            + targetedModificationForm.getComments()
            + "\n\t getMgiId: "
            + targetedModificationForm.getMgiId()
            + "\n\t getZfinId: "
            + targetedModificationForm.getZfinId()
            + "\n\t getRgdId: "
            + targetedModificationForm.getRgdId()
            + "\n\t getUrl: "
            + targetedModificationForm.getUrl()
            + "\n\t getTitle: "
            + targetedModificationForm.getTitle()
            + "\n\t getDescriptionOfConstruct: "
            + targetedModificationForm.getDescriptionOfConstruct()
            + "\n\t getConstructSequence(): "
            + targetedModificationForm.getConstructSequence()
            + (String) request.getSession().getAttribute("camod.loggedon.username"));

    String theForward = "AnimalModelTreePopulateAction";

    try {
      // retrieve model and update w/ new values
      AnimalModelManager theAnimalModelManager = (AnimalModelManager) getBean("animalModelManager");
      AnimalModel theAnimalModel = theAnimalModelManager.get(theModelId);

      theAnimalModelManager.addGeneticDescription(
          theAnimalModel, targetedModificationForm, request);

      log.debug("New TargetedModification created");

      // Add a message to be displayed in submitOverview.jsp saying you've
      // created a new model successfully
      ActionMessages msg = new ActionMessages();
      msg.add(
          ActionMessages.GLOBAL_MESSAGE,
          new ActionMessage("targetedmodification.creation.successful"));
      saveErrors(request, msg);

    } catch (IllegalArgumentException e) {
      log.error("Exception ocurred saving a TargetedModification", e);

      theForward = "input";

      // Encountered an error saving the model.
      ActionMessages msg = new ActionMessages();
      msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.image.unsupportedfiletype"));
      saveErrors(request, msg);

    } catch (Exception e) {
      log.error("Exception ocurred creating TargetedModification", e);

      // Encountered an error saving the model.
      ActionMessages msg = new ActionMessages();
      msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.admin.message"));
      saveErrors(request, msg);
    }

    log.debug("<TargetedModificationAction> Exiting save");
    resetToken(request);

    return mapping.findForward(theForward);
  }