Beispiel #1
0
  /**
   * Returns all NEW projects submitted to this YRC member's group(s)
   *
   * @param researcherID The researcher ID of the YRC member
   * @return A list of new projects (within the last 30 days) for this member's groups, null if this
   *     is not a YRC member
   */
  public static List<Project> getNewProjectsForYRCMember(Researcher r) throws SQLException {
    int researcherID = r.getID();
    Groups gm = Groups.getInstance();

    // return null if they're not in a YRC group
    if (!gm.isInAGroup(researcherID)) return null;

    ProjectsSearcher ps = new ProjectsSearcher();
    // ps.setResearcher(r);

    // Set the start date of the search to 1 month ago
    Calendar cal = GregorianCalendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    ps.setStartDate(cal.getTime());

    // Set the groups to search
    List groups = gm.getGroups();
    Iterator iter = groups.iterator();
    while (iter.hasNext()) {
      String group = (String) (iter.next());
      if (gm.isMember(researcherID, group)) {
        ps.addGroup(group);
      }
    }

    List<Project> projects = ps.search();
    return projects;
  }
Beispiel #2
0
  public static List<Integer> getAllGroupIds(User user) throws SQLException {

    Groups groups = Groups.getInstance();

    List<Integer> groupIds = new ArrayList<Integer>();

    // Get a list of groups that this user is a member of.
    List<String> groupMemberships = groups.getUserGroups(user.getResearcher().getID());
    if (groupMemberships != null && groupMemberships.size() > 0)
      groupIds.add(groups.getGroupID(groupMemberships.get(0)));

    return groupIds;
  }
Beispiel #3
0
  /**
   * Returns the ID of ONE of the groups the user is a member of. If the user is an administrator,
   * the ID of the "administrators" group is returned. If the user is not a member of any group, 0
   * is returned
   *
   * @param user
   * @return
   * @throws SQLException
   */
  public static int getOneGroupId(User user) throws SQLException {

    Groups groups = Groups.getInstance();

    // If the user is an administrator return the ID of the administrators group
    if (groups.isMember(user.getResearcher().getID(), "administrators"))
      return groups.getGroupID("administrators");

    // Otherwise get a list of groups that this user is a member of.  Returns the
    // ID of the first group.
    List<String> groupMemberships = groups.getUserGroups(user.getResearcher().getID());
    if (groupMemberships != null && groupMemberships.size() > 0)
      return groups.getGroupID(groupMemberships.get(0));

    // If the user is not a member of any group return 0
    return 0;
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // User making this request
    User user = UserUtils.getUser(request);
    if (user == null) {
      ActionErrors errors = new ActionErrors();
      errors.add("username", new ActionMessage("error.login.notloggedin"));
      saveErrors(request, errors);
      return mapping.findForward("authenticate");
    }

    // Restrict access to researchers who are members of a group
    Groups groupMan = Groups.getInstance();
    if (!groupMan.isInAGroup(user.getResearcher().getID())) {
      ActionErrors errors = new ActionErrors();
      errors.add("access", new ActionMessage("error.access.invalidgroup"));
      saveErrors(request, errors);
      return mapping.findForward("standardHome");
    }

    UploadMSDataForm newForm = new UploadMSDataForm();
    if (groupMan.isMember(user.getResearcher().getID(), "administrators")) {
      newForm.setPipeline(Pipeline.TPP);
      newForm.setDataServer("local");
    } else if (groupMan.isMember(user.getResearcher().getID(), "MacCoss")) {
      newForm.setPipeline(Pipeline.MACOSS);
      newForm.setDataServer("local");
    } else {
      newForm.setPipeline(Pipeline.TPP);
      newForm.setDataServer("local");
    }

    try {
      int projectID = Integer.parseInt(request.getParameter("projectID"));
      newForm.setProjectID(projectID);
    } catch (Exception e) {
      newForm.setProjectID(0);
    }

    request.setAttribute("uploadMSDataForm", newForm);

    // get a list of projects on which this researcher is listed
    List<ProjectLite> projects =
        ProjectLiteDAO.instance().getResearcherWritableProjects(user.getResearcher().getID());
    Collections.sort(
        projects,
        new Comparator<ProjectLite>() {
          @Override
          public int compare(ProjectLite o1, ProjectLite o2) {
            return Integer.valueOf(o2.getId()).compareTo(o1.getId());
          }
        });

    request.getSession().setAttribute("researcherProjects", projects);

    // get a list of instruments available
    List<MsInstrument> instruments = DAOFactory.instance().getInstrumentDAO().loadAllInstruments();
    request.getSession().setAttribute("instrumentList", instruments);

    // Kick it to the view page
    return mapping.findForward("Success");
  }
Beispiel #5
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // User making this request
    User user = UserUtils.getUser(request);
    if (user == null) {
      ActionErrors errors = new ActionErrors();
      errors.add("username", new ActionMessage("error.login.notloggedin"));
      saveErrors(request, errors);
      return mapping.findForward("authenticate");
    }

    // Restrict access to yrc members
    Groups groupMan = Groups.getInstance();
    if (!groupMan.isInAGroup(user.getResearcher().getID())) {
      ActionErrors errors = new ActionErrors();
      errors.add("access", new ActionMessage("error.access.invalidgroup"));
      saveErrors(request, errors);
      return mapping.findForward("Failure");
    }

    try {
      Job job = MSJobFactory.getInstance().getJob(Integer.parseInt(request.getParameter("id")));

      if (job == null) {
        ActionErrors errors = new ActionErrors();
        errors.add(
            "general",
            new ActionMessage(
                "error.general.errorMessage",
                "No job found with ID " + request.getParameter("id")));
        saveErrors(request, errors);
        return mapping.findForward("Failure");
      }

      request.setAttribute("job", job);
      if (job instanceof MSJob) {
        int speciesId = ((MSJob) job).getTargetSpecies();
        Species species = Species.getInstance(speciesId);
        request.setAttribute("species", species);
        request.setAttribute("experimentUploadJob", true);
      } else if (job instanceof MsAnalysisUploadJob) {
        request.setAttribute("analysisUploadJob", true);
      } else if (job instanceof PercolatorJob) {
        request.setAttribute("percolatorJob", true);
      }

    } catch (Exception e) {

      log.error("Error loading job with ID: " + request.getParameter("id"), e);
      ActionErrors errors = new ActionErrors();
      errors.add(
          "general",
          new ActionMessage(
              "error.general.errorMessage",
              "Error reading job with ID: "
                  + request.getParameter("id")
                  + ". Error was: "
                  + e.getMessage()));
      saveErrors(request, errors);
      return mapping.findForward("Failure");
    }

    return mapping.findForward("Success");
  }