@Override
 protected void process(final ActivityInformation<MissionProcess> activityInformation) {
   final User user = Authenticate.getUser();
   final Person person = user.getPerson();
   final MissionProcess missionProcess = activityInformation.getProcess();
   missionProcess.unAllocateFunds(person);
 }
  public void execute(Summary summary, Professorship professorshipLogged)
      throws NotAuthorizedException {

    try {
      User userViewLogged = Authenticate.getUser();

      boolean executionCourseResponsibleLogged = professorshipLogged.isResponsibleFor();

      if (userViewLogged == null
          || userViewLogged.getPerson().getPersonRolesSet() == null
          || professorshipLogged == null) {
        throw new NotAuthorizedException("error.summary.not.authorized");
      }
      if (executionCourseResponsibleLogged
          && (summary.getProfessorship() != null
              && (!summary.getProfessorship().equals(professorshipLogged)))) {
        throw new NotAuthorizedException("error.summary.not.authorized");

      } else if (!executionCourseResponsibleLogged
          && (summary.getProfessorship() == null
              || (!summary.getProfessorship().equals(professorshipLogged)))) {
        throw new NotAuthorizedException("error.summary.not.authorized");
      }

    } catch (RuntimeException ex) {
      throw new NotAuthorizedException("error.summary.not.authorized");
    }
  }
  private void renderCMSPage(
      final HttpServletRequest req, HttpServletResponse res, Site sites, String pageSlug)
      throws ServletException, IOException, PebbleException {
    if (pageSlug.startsWith("/")) {
      pageSlug = pageSlug.substring(1);
    }
    String[] parts = pageSlug.split("/");

    String pageName = parts[0];

    Page page;
    if (Strings.isNullOrEmpty(pageName) && sites.getInitialPage() != null) {
      page = sites.getInitialPage();
    } else {
      page =
          sites
              .getPagesSet()
              .stream()
              .filter(p -> pageName.equals(p.getSlug()))
              .findAny()
              .orElse(null);
    }

    if (page == null || page.getTemplate() == null) {
      errorPage(req, res, sites, 404);
    } else if (!page.isPublished() || !page.getCanViewGroup().isMember(Authenticate.getUser())) {
      errorPage(req, res, sites, 404);
    } else {
      try {
        renderPage(req, pageSlug, res, sites, page, parts);
      } catch (ResourceNotFoundException e) {
        errorPage(req, res, sites, 404);
      }
    }
  }
Exemple #4
0
  public ActionForward showTeacherCredits(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws NumberFormatException, FenixServiceException, ParseException {

    DynaActionForm teacherCreditsForm = (DynaActionForm) form;
    ExecutionSemester executionSemester =
        FenixFramework.getDomainObject((String) teacherCreditsForm.get("executionPeriodId"));

    Teacher requestedTeacher =
        FenixFramework.getDomainObject((String) teacherCreditsForm.get("teacherId"));

    User userView = Authenticate.getUser();
    Teacher loggedTeacher = userView.getPerson().getTeacher();

    if (requestedTeacher == null || loggedTeacher != requestedTeacher) {
      ActionMessages actionMessages = new ActionMessages();
      actionMessages.add("", new ActionMessage("message.invalid.teacher"));
      saveMessages(request, actionMessages);
      return mapping.findForward("teacher-not-found");
    }

    showLinks(request, executionSemester, RoleType.DEPARTMENT_MEMBER);
    getAllTeacherCredits(request, executionSemester, requestedTeacher);
    return mapping.findForward("show-teacher-credits");
  }
  public ActionForward transferEnrollments(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String selectedStudentCurricularPlanIdString =
        (String) dynaActionForm.get("selectedStudentCurricularPlanId");
    final String selectedCurriculumGroupID =
        (String) dynaActionForm.get("selectedCurriculumGroupID");
    final String[] enrollmentStringIDsToTransfer =
        (String[]) dynaActionForm.get("enrollmentIDsToTransfer");

    if (isPresent(selectedStudentCurricularPlanIdString)
        && enrollmentStringIDsToTransfer != null
        && enrollmentStringIDsToTransfer.length > 0) {

      final User userView = Authenticate.getUser();

      TransferEnrollments.run(
          selectedStudentCurricularPlanIdString,
          enrollmentStringIDsToTransfer,
          selectedCurriculumGroupID);
    }

    return show(mapping, form, request, response);
  }
  private Spreadsheet buildReport(
      final Degree degree, final SortedSet<SecondCycleIndividualCandidacyProcess> name) {
    final Spreadsheet spreadsheet = new Spreadsheet(degree.getSigla(), getHeader());

    for (final SecondCycleIndividualCandidacyProcess process : name) {
      if (!process.canExecuteActivity(Authenticate.getUser())) {
        continue;
      }
      final Row row = spreadsheet.addRow();
      row.setCell(process.getPersonalDetails().getName());
      row.setCell(process.getPrecedentDegreeInformation().getConclusionGrade());
      row.setCell(process.getCandidacyProfessionalExperience());
      row.setCell(process.getPrecedentDegreeInformation().getDegreeAndInstitutionName());
      row.setCell(process.getCandidacyAffinity());
      row.setCell(process.getCandidacyDegreeNature());
      row.setCell(process.getCandidacyGrade());
      row.setCell(
          process.getCandidacyInterviewGrade() != null
              ? process.getCandidacyInterviewGrade()
              : " ");
      row.setCell(process.getCandidacySeriesGrade());
      if (process.isCandidacyAccepted() || process.isCandidacyRejected()) {
        row.setCell(
            BundleUtil.getString(
                Bundle.ENUMERATION, process.getCandidacyState().getQualifiedName()));
      } else {
        row.setCell(" ");
      }
    }

    return spreadsheet;
  }
  private SupportRequestBean userInfoContextAppend(
      HttpServletRequest request, final StringBuilder exceptionInfo) {

    exceptionInfo.append("[UserLoggedIn] ");

    SupportRequestBean requestBean;
    String user;
    User userView = Authenticate.getUser();
    if (userView != null) {
      user = userView.getUsername();
      requestBean = SupportRequestBean.generateExceptionBean(userView.getPerson());
      MenuFunctionality selectedFunctionality =
          BennuPortalDispatcher.getSelectedFunctionality(request);
      if (selectedFunctionality != null) {
        requestBean.setSelectedFunctionality(selectedFunctionality);
      }
      setUserName(user);
      Set<RoleType> roles = new HashSet<RoleType>();
      for (Role role : userView.getPerson().getPersonRolesSet()) {
        roles.add(role.getRoleType());
      }
      setUserRoles(roles);
    } else {
      user = "******";
      requestBean = SupportRequestBean.generateExceptionBean(null);
    }
    exceptionInfo.append(user + "\n");
    return requestBean;
  }
  protected void putStudentCurricularInformationInRequest(
      final HttpServletRequest request, final Integer studentNumber, final DegreeType degreeType)
      throws FenixServiceException {
    final User userView = Authenticate.getUser();

    final List infoStudentCurricularPlans =
        ReadStudentCurricularInformation.run(studentNumber, degreeType);
    request.setAttribute("infoStudentCurricularPlans", infoStudentCurricularPlans);
  }
 @Atomic
 public void createNewPeriod() {
   final User userView = Authenticate.getUser();
   if (userView != null && RoleType.MANAGER.isMember(userView.getPerson().getUser())) {
     if (title != null && title.hasContent() && start != null && end != null) {
       new GenericApplicationPeriod(title, description, start, end);
     }
   }
 }
Exemple #10
0
 public static boolean getGrantAccess() {
   final User user = Authenticate.getUser();
   if (user != null) {
     final int year = Year.now().getValue();
     final CgdCard card = findCardFor(user, year, false);
     return card != null && card.getAllowSendDetails();
   }
   return false;
 }
 public ActionForward backToShowInformation(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response) {
   final Person person = Authenticate.getUser().getPerson();
   request.setAttribute("personBean", new PersonBean(person));
   EmergencyContactBean emergencyContactBean = new EmergencyContactBean(person);
   request.setAttribute("emergencyContactBean", emergencyContactBean);
   return mapping.findForward("visualizePersonalInformation");
 }
  /**
   * Method setExecutionContext.
   *
   * @param request
   */
  private InfoExecutionPeriod setExecutionContext(HttpServletRequest request) throws Exception {

    InfoExecutionPeriod infoExecutionPeriod =
        (InfoExecutionPeriod) request.getAttribute(PresentationConstants.INFO_EXECUTION_PERIOD_KEY);
    if (infoExecutionPeriod == null) {
      User userView = Authenticate.getUser();
      infoExecutionPeriod = ReadCurrentExecutionPeriod.run();

      request.setAttribute(PresentationConstants.INFO_EXECUTION_PERIOD_KEY, infoExecutionPeriod);
    }
    return infoExecutionPeriod;
  }
Exemple #13
0
  public static Set<Sender> getAvailableSenders() {
    final User userView = Authenticate.getUser();

    final Set<Sender> senders = new TreeSet<Sender>(Sender.COMPARATOR_BY_FROM_NAME);
    for (final Sender sender : Bennu.getInstance().getUtilEmailSendersSet()) {
      if (sender.getMembers().isMember(userView)
          || (userView != null && userView.getPerson().hasRole(RoleType.MANAGER))) {
        senders.add(sender);
      }
    }

    return senders;
  }
  private Map<String, Object> makeRequestWrapper(HttpServletRequest req) {
    HashMap<String, Object> result = new HashMap<String, Object>();

    result.put("user", new UserWrap(Authenticate.getUser()));

    result.put("method", req.getMethod());
    result.put("protocol", req.getProtocol());

    result.put("url", getFullURL(req));
    result.put("contentType", req.getContentType());
    result.put("contextPath", req.getContextPath());

    return result;
  }
  public void execute(String executionDegreeID, List<SituationName> situationNames)
      throws NotAuthorizedException {

    User id = Authenticate.getUser();
    if ((id != null
            && id.getPerson().getPersonRolesSet() != null
            && !containsRoleType(id.getPerson().getPersonRolesSet()))
        || (id != null
            && id.getPerson().getPersonRolesSet() != null
            && !hasPrivilege(id, executionDegreeID))
        || (id == null)
        || (id.getPerson().getPersonRolesSet() == null)) {
      throw new NotAuthorizedException();
    }
  }
Exemple #16
0
 @Atomic
 public static CgdCard setGrantAccess(final boolean allowAccess) {
   final User user = Authenticate.getUser();
   if (user != null) {
     final int year = Year.now().getValue();
     final CgdCard card = findCardFor(user, year, allowAccess);
     if (card != null) {
       card.setAllowSendDetails(allowAccess);
       if (allowAccess) {
         return card;
       }
     }
   }
   return null;
 }
Exemple #17
0
    public static boolean eval(Person contactPerson) {
      if (hasRole(RoleType.OPERATOR)
          || hasRole(RoleType.MANAGER)
          || isSelfPerson(contactPerson)
          || hasRole(RoleType.PERSONNEL_SECTION)) {
        return true;
      }

      if (contactPerson.getStudent() != null
          && !contactPerson.hasRole(RoleType.GRANT_OWNER)
          && !contactPerson.hasRole(RoleType.EMPLOYEE)) {
        return AcademicAuthorizationGroup.get(AcademicOperationType.EDIT_STUDENT_PERSONAL_DATA)
            .isMember(Authenticate.getUser());
      }

      return false;
    }
  public ActionForward deleteEnrollment(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final String enrollmentIdString = request.getParameter("enrollmentId");
    final String studentNumberString = request.getParameter("studentNumber");
    final String degreeTypeString = request.getParameter("degreeType");
    final Integer studentNumber = Integer.valueOf(studentNumberString);
    final DegreeType degreeType = DegreeType.valueOf(degreeTypeString);

    final User userView = Authenticate.getUser();

    DeleteEnrollment.run(studentNumber, degreeType, enrollmentIdString);

    return show(mapping, form, request, response);
  }
 public SortedSet<OutboundMobilityCandidacyContestGroup> getCandidacyContestGroupSet(
     final OutboundMobilityCandidacyPeriod period) {
   final User user = Authenticate.getUser();
   if (AcademicAuthorizationGroup.get(AcademicOperationType.MANAGE_MOBILITY_OUTBOUND)
       .isMember(user)) {
     return period.getOutboundMobilityCandidacyContestGroupSet();
   }
   final SortedSet<OutboundMobilityCandidacyContestGroup> result =
       new TreeSet<OutboundMobilityCandidacyContestGroup>();
   if (user != null && user.getPerson() != null) {
     for (final OutboundMobilityCandidacyContestGroup group :
         user.getPerson().getOutboundMobilityCandidacyContestGroupSet()) {
       if (hasContestForPeriod(period, group)) {
         result.add(group);
       }
     }
   }
   return result;
 }
Exemple #20
0
  public static boolean hasAvailableSender() {
    final User userView = Authenticate.getUser();
    if (userView != null) {
      if (userView.getPerson().hasRole(RoleType.MANAGER)) {
        return true;
      }

      final Person person = userView.getPerson();
      if (person != null && !person.getMessagesSet().isEmpty()) {
        return true;
      }

      for (final Sender sender : Bennu.getInstance().getUtilEmailSendersSet()) {
        if (sender.allows(userView)) {
          return true;
        }
      }
    }
    return false;
  }
  public ActionForward createStudentCurricularPlan(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String studentNumberString = (String) dynaActionForm.get("number");
    final String degreeTypeString = (String) dynaActionForm.get("degreeType");
    final String studentCurricularPlanStateString =
        (String) dynaActionForm.get("studentCurricularPlanState");
    final String degreeCurricularPlanIdString =
        (String) dynaActionForm.get("degreeCurricularPlanId");
    final String startDateString = (String) dynaActionForm.get("startDate");

    if (isPresent(studentNumberString)
        && isPresent(degreeTypeString)
        && isPresent(studentCurricularPlanStateString)
        && isPresent(degreeCurricularPlanIdString)
        && isPresent(startDateString)) {

      final Integer studentNumber = new Integer(studentNumberString);
      final DegreeType degreeType = DegreeType.valueOf(degreeTypeString);
      final StudentCurricularPlanState studentCurricularPlanState =
          StudentCurricularPlanState.valueOf(studentCurricularPlanStateString);
      final Date startDate = simpleDateFormat.parse(startDateString);

      final User userView = Authenticate.getUser();

      CreateStudentCurricularPlan.run(
          studentNumber,
          degreeType,
          studentCurricularPlanState,
          degreeCurricularPlanIdString,
          startDate);
    }

    return show(mapping, form, request, response);
  }
        @Override
        public boolean evaluate(Context context) {
          User user = Authenticate.getUser();
          if (RoleType.SCIENTIFIC_COUNCIL.isMember(user)) {
            return true;
          }

          final DegreeCurricularPlan parentDegreeCurricularPlan =
              context.getParentCourseGroup().getParentDegreeCurricularPlan();
          if (!parentDegreeCurricularPlan.isBolonhaDegree()) {
            return true;
          }

          if (AcademicAuthorizationGroup.get(AcademicOperationType.MANAGE_DEGREE_CURRICULAR_PLANS)
                  .isMember(user)
              || RoleType.MANAGER.isMember(user)
              || RoleType.OPERATOR.isMember(user)) {
            return true;
          }

          return parentDegreeCurricularPlan.getCurricularPlanMembersGroup().isMember(user);
        }
  public void handleRequest(
      Site site, HttpServletRequest req, HttpServletResponse res, String pageSlug)
      throws IOException, ServletException {

    if (site.getCanViewGroup().isMember(Authenticate.getUser())) {
      if (site.getPublished()) {
        try {
          String baseUrl = "/" + site.getBaseUrl();
          if (pageSlug.startsWith(baseUrl)) {
            pageSlug = pageSlug.substring(baseUrl.length());
          }
          if (pageSlug.endsWith("/") && !req.getRequestURI().equals(req.getContextPath() + "/")) {
            handleLeadingSlash(req, res, site);
          } else if (pageSlug.startsWith("/static/")) {
            handleStaticResource(req, res, site, pageSlug);
          } else if (pageSlug.startsWith("/rss")) {
            handleRSS(req, res, site, pageSlug);
          } else {
            renderCMSPage(req, res, site, pageSlug);
          }
        } catch (Exception e) {
          logger.error("Exception while rendering CMS page " + req.getRequestURI(), e);
          if (res.isCommitted()) {
            return;
          }
          res.reset();
          res.resetBuffer();
          errorPage(req, res, site, 500);
        }
      } else {
        res.sendError(404);
      }
    } else {
      res.sendError(404);
      return;
    }
  }
 private boolean isVisible(PartyContact contact) {
   boolean publicSpace =
       true; // because this is a homepage. When this logic is exported to a more proper place
             // remember to pass this as an argument.
   if (!Authenticate.isLogged() && publicSpace && contact.getVisibleToPublic().booleanValue()) {
     return true;
   }
   if (Authenticate.isLogged()) {
     User user = Authenticate.getUser();
     Person reader = user.getPerson();
     if (reader.hasRole(RoleType.CONTACT_ADMIN).booleanValue()
         || reader.hasRole(RoleType.MANAGER).booleanValue()
         || reader.hasRole(RoleType.DIRECTIVE_COUNCIL).booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.EMPLOYEE).booleanValue()
         && contact.getVisibleToEmployees().booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.TEACHER).booleanValue()
         && contact.getVisibleToTeachers().booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.STUDENT).booleanValue()
         && contact.getVisibleToStudents().booleanValue()) {
       return true;
     }
     if (reader.hasRole(RoleType.ALUMNI).booleanValue()
         && contact.getVisibleToAlumni().booleanValue()) {
       return true;
     }
     if (contact.getVisibleToPublic()) {
       return true;
     }
   }
   return false;
 }
  public ActionForward showYearInformation(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    User userView = Authenticate.getUser();

    YearViewBean searchFormBean = (YearViewBean) getRenderedObject("searchFormBean");
    RenderUtils.invalidateViewState();

    if (searchFormBean == null || searchFormBean.getExecutionYear() == null) {
      String degreeCurricularPlanID = null;
      DegreeCurricularPlan degreeCurricularPlan = null;
      if (request.getParameter("degreeCurricularPlanID") != null) {
        degreeCurricularPlanID = request.getParameter("degreeCurricularPlanID");
        request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanID);
        degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID);
      }

      searchFormBean = new YearViewBean(degreeCurricularPlan);
      request.setAttribute("searchFormBean", searchFormBean);
      return mapping.findForward("xYearEntry");
    }

    /*
     * YearViewBean yearViewBean = new
     * YearViewBean(searchFormBean.getDegreeCurricularPlan());
     * yearViewBean.setExecutionYear(searchFormBean.getExecutionYear());
     * yearViewBean.setEnrolments();
     */

    request.setAttribute("dcpEId", searchFormBean.getDegreeCurricularPlan().getExternalId());
    request.setAttribute("eyEId", searchFormBean.getExecutionYear().getExternalId());

    /*
     * Inar totalInar = generateINAR(yearViewBean);
     * request.setAttribute("totalInar", totalInar);
     *
     * int years =
     * yearViewBean.getDegreeCurricularPlan().getDegree().getDegreeType
     * ().getYears(); request.setAttribute("#years", years);
     *
     * Map<CurricularYear, Inar> mapInarByYear =
     * generateInarByCurricularYear(yearViewBean); for (int i = 1; i <=
     * years; i++) { Inar value =
     * mapInarByYear.get(CurricularYear.readByYear(i)); String label =
     * "InarFor" + i + "Year"; request.setAttribute(label, value); }
     *
     * Map<CurricularYear, String> mapAveragebyYear =
     * generateAverageByCurricularYear(yearViewBean); List averageByYear =
     * new LinkedList(mapAveragebyYear.entrySet());
     * request.setAttribute("averageByYear", averageByYear);
     *
     * // @Deprecated // if(<3 == true) {you.marry(me) ? super.happy() :
     * null;} if (yearViewBean.hasBranchesByType(BranchType.MAJOR)) {
     * Map<BranchCourseGroup, Inar> mapInarByBranches =
     * generateInarByBranch(yearViewBean, BranchType.MAJOR);
     * yearViewBean.setHasMajorBranches(true);
     * yearViewBean.setMajorBranches(
     * yearViewBean.getDegreeCurricularPlan().getBranchesByType
     * (BranchType.MAJOR));
     * yearViewBean.setInarByMajorBranches(mapInarByBranches);
     *
     * Map<BranchCourseGroup, String> mapAverageByBranches =
     * generateAverageByBranch(yearViewBean, BranchType.MAJOR);
     * yearViewBean.setAverageByMajorBranches(mapAverageByBranches); }
     *
     * if (yearViewBean.hasBranchesByType(BranchType.MINOR)) {
     * Map<BranchCourseGroup, Inar> mapInarByBranches =
     * generateInarByBranch(yearViewBean, BranchType.MINOR);
     * yearViewBean.setHasMinorBranches(true);
     * yearViewBean.setMinorBranches(
     * yearViewBean.getDegreeCurricularPlan().getBranchesByType
     * (BranchType.MINOR));
     * yearViewBean.setInarByMinorBranches(mapInarByBranches);
     *
     * Map<BranchCourseGroup, String> mapAverageByBranches =
     * generateAverageByBranch(yearViewBean, BranchType.MINOR);
     * yearViewBean.setAverageByMinorBranches(mapAverageByBranches); }
     *
     * String resumedQUC = generateQUCResults(yearViewBean);
     * yearViewBean.setResumedQUC(resumedQUC);
     *
     * request.setAttribute("yearViewBean", yearViewBean);
     */

    request.setAttribute("searchFormBean", searchFormBean);
    return mapping.findForward("xYearDisplay");
  }
  public ActionForward insert(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {

    User userView = Authenticate.getUser();

    final Degree degree = FenixFramework.getDomainObject(request.getParameter("degreeId"));

    DynaActionForm dynaForm = (DynaValidatorForm) form;

    String name = (String) dynaForm.get("name");
    String stateString = (String) dynaForm.get("state");
    String initialDateString = (String) dynaForm.get("initialDate");
    String endDateString = (String) dynaForm.get("endDate");
    Integer degreeDuration = new Integer((String) dynaForm.get("degreeDuration"));
    Integer minimalYearForOptionalCourses =
        new Integer((String) dynaForm.get("minimalYearForOptionalCourses"));
    String neededCreditsString = (String) dynaForm.get("neededCredits");
    String markTypeString = (String) dynaForm.get("markType");
    String numerusClaususString = (String) dynaForm.get("numerusClausus");
    String anotationString = (String) dynaForm.get("anotation");

    String gradeTypeString = (String) dynaForm.get("gradeType");
    GradeScale gradeScale = null;
    if (gradeTypeString != null && gradeTypeString.length() > 0) {
      gradeScale = GradeScale.valueOf(gradeTypeString);
    }

    InfoDegreeCurricularPlanEditor infoDegreeCurricularPlan = new InfoDegreeCurricularPlanEditor();
    DegreeCurricularPlanState state = DegreeCurricularPlanState.valueOf(stateString);

    Calendar initialDate = Calendar.getInstance();
    if (initialDateString.compareTo("") != 0) {
      String[] initialDateTokens = initialDateString.split("/");
      initialDate.set(Calendar.DAY_OF_MONTH, (new Integer(initialDateTokens[0])).intValue());
      initialDate.set(Calendar.MONTH, (new Integer(initialDateTokens[1])).intValue() - 1);
      initialDate.set(Calendar.YEAR, (new Integer(initialDateTokens[2])).intValue());
      infoDegreeCurricularPlan.setInitialDate(initialDate.getTime());
    }

    Calendar endDate = Calendar.getInstance();
    if (endDateString.compareTo("") != 0) {
      String[] endDateTokens = endDateString.split("/");
      endDate.set(Calendar.DAY_OF_MONTH, (new Integer(endDateTokens[0])).intValue());
      endDate.set(Calendar.MONTH, (new Integer(endDateTokens[1])).intValue() - 1);
      endDate.set(Calendar.YEAR, (new Integer(endDateTokens[2])).intValue());
      infoDegreeCurricularPlan.setEndDate(endDate.getTime());
    }

    if (endDate.before(initialDate)) {
      throw new InvalidArgumentsActionException("message.manager.date.restriction");
    }

    if (neededCreditsString.compareTo("") != 0) {
      Double neededCredits = new Double(neededCreditsString);
      infoDegreeCurricularPlan.setNeededCredits(neededCredits);
    }

    MarkType markType = new MarkType(new Integer(markTypeString));
    infoDegreeCurricularPlan.setMarkType(markType);

    if (numerusClaususString.compareTo("") != 0) {
      Integer numerusClausus = new Integer(numerusClaususString);
      infoDegreeCurricularPlan.setNumerusClausus(numerusClausus);
    }

    infoDegreeCurricularPlan.setName(name);
    infoDegreeCurricularPlan.setState(state);
    infoDegreeCurricularPlan.setDegreeDuration(degreeDuration);
    infoDegreeCurricularPlan.setMinimalYearForOptionalCourses(minimalYearForOptionalCourses);
    infoDegreeCurricularPlan.setAnotation(anotationString);
    infoDegreeCurricularPlan.setGradeScale(gradeScale);
    InfoDegree infoDegree = new InfoDegree(degree);
    infoDegreeCurricularPlan.setInfoDegree(infoDegree);

    try {
      InsertDegreeCurricularPlan.run(infoDegreeCurricularPlan);

    } catch (ExistingServiceException ex) {
      throw new ExistingActionException(ex.getMessage(), ex);
    } catch (NonExistingServiceException exception) {
      throw new NonExistingActionException(
          "message.nonExistingDegree", mapping.findForward("readDegree"));
    } catch (FenixServiceException e) {
      throw new FenixActionException(e);
    }

    return mapping.findForward("readDegree");
  }
  @Atomic
  private Map<ExecutionDegree, Integer> setFirstYearShiftsCapacity(
      Boolean toBlock, ExecutionYear executionYear) {

    final ExecutionSemester executionSemester = executionYear.getFirstExecutionPeriod();

    final Map<Shift, Set<ExecutionDegree>> shiftsDegrees =
        new HashMap<Shift, Set<ExecutionDegree>>();
    final Set<Shift> shifts = new HashSet<Shift>();
    final Map<ExecutionDegree, Integer> modified = new HashMap<ExecutionDegree, Integer>();

    for (final Degree degree :
        Degree.readAllByDegreeType(
            DegreeType.BOLONHA_DEGREE, DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE)) {
      for (final DegreeCurricularPlan degreeCurricularPlan :
          degree.getActiveDegreeCurricularPlans()) {
        final ExecutionDegree executionDegree =
            degreeCurricularPlan.getExecutionDegreeByAcademicInterval(
                executionSemester.getExecutionYear().getAcademicInterval());

        if (executionDegree != null) {
          for (final SchoolClass schoolClass : executionDegree.getSchoolClassesSet()) {
            if (schoolClass.getAnoCurricular().equals(FIRST_CURRICULAR_YEAR)
                && schoolClass.getExecutionPeriod() == executionSemester) {
              for (final Shift shift : schoolClass.getAssociatedShiftsSet()) {
                Set<ExecutionDegree> executionDegrees = shiftsDegrees.get(shift);
                if (executionDegrees == null) {
                  executionDegrees = new HashSet<ExecutionDegree>();
                }
                executionDegrees.add(executionDegree);
                shiftsDegrees.put(shift, executionDegrees);
                shifts.add(shift);
              }
            }
          }
        }
      }
    }

    for (final Shift shift : shifts) {
      int capacity = shift.getLotacao().intValue();

      if (toBlock && capacity > 0) {
        shift.setLotacao(capacity * -1);
      } else if (!toBlock && capacity < 0) {
        shift.setLotacao(capacity * -1);
      } else {
        continue;
      }

      for (ExecutionDegree executionDegree : shiftsDegrees.get(shift)) {
        if (modified.containsKey(executionDegree)) {
          modified.put(executionDegree, modified.get(executionDegree) + 1);
        } else {
          modified.put(executionDegree, 1);
        }
      }
    }

    if (modified.size() > 0) {
      new FirstYearShiftsCapacityToggleLog(
          executionYear.getFirstExecutionPeriod(), Authenticate.getUser().getPerson().getUser());
    }

    return modified;
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.apache.struts.actions.DispatchAction#dispatchMethod(org.apache.struts
   * .action.ActionMapping, org.apache.struts.action.ActionForm,
   * javax.servlet.http.HttpServletRequest,
   * javax.servlet.http.HttpServletResponse, java.lang.String)
   */
  public ActionForward prepare(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String inputPage = request.getParameter(PresentationConstants.INPUT_PAGE);
    String nextPage = request.getParameter(PresentationConstants.NEXT_PAGE);
    if (inputPage != null) {
      request.setAttribute(PresentationConstants.INPUT_PAGE, inputPage);
    }
    if (nextPage != null) {
      request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage);
    }

    User userView = Authenticate.getUser();

    InfoExecutionPeriod infoExecutionPeriod = setExecutionContext(request);

    // TODO: this semester and curricular year list needs to be
    // refactored in order to incorporate masters
    /* Criar o bean de semestres */
    List semestres = new ArrayList();
    semestres.add(new LabelValueBean("escolher", ""));
    semestres.add(new LabelValueBean("1 º", "1"));
    semestres.add(new LabelValueBean("2 º", "2"));
    request.setAttribute("semestres", semestres);

    /* Criar o bean de anos curricutares */
    List anosCurriculares = new ArrayList();
    anosCurriculares.add(new LabelValueBean("escolher", ""));
    anosCurriculares.add(new LabelValueBean("1 º", "1"));
    anosCurriculares.add(new LabelValueBean("2 º", "2"));
    anosCurriculares.add(new LabelValueBean("3 º", "3"));
    anosCurriculares.add(new LabelValueBean("4 º", "4"));
    anosCurriculares.add(new LabelValueBean("5 º", "5"));
    request.setAttribute(PresentationConstants.CURRICULAR_YEAR_LIST_KEY, anosCurriculares);

    /* Cria o form bean com as licenciaturas em execucao. */

    List executionDegreeList =
        ReadExecutionDegreesByExecutionYear.run(infoExecutionPeriod.getInfoExecutionYear());

    List licenciaturas = new ArrayList();

    licenciaturas.add(new LabelValueBean("escolher", ""));

    Collections.sort(executionDegreeList, new ComparatorByNameForInfoExecutionDegree());

    Iterator iterator = executionDegreeList.iterator();

    int index = 0;
    while (iterator.hasNext()) {
      InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) iterator.next();
      String name = infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getNome();

      name =
          infoExecutionDegree
                  .getInfoDegreeCurricularPlan()
                  .getInfoDegree()
                  .getDegreeType()
                  .toString()
              + " em "
              + name;

      name +=
          duplicateInfoDegree(executionDegreeList, infoExecutionDegree)
              ? "-" + infoExecutionDegree.getInfoDegreeCurricularPlan().getName()
              : "";

      licenciaturas.add(new LabelValueBean(name, String.valueOf(index++)));
    }

    request.setAttribute(PresentationConstants.INFO_EXECUTION_DEGREE_LIST_KEY, executionDegreeList);

    request.setAttribute(PresentationConstants.DEGREES, licenciaturas);

    if (inputPage != null) {
      return mapping.findForward(inputPage);
    }

    // TODO : throw a proper exception
    throw new Exception("SomeOne is messing around with the links");
  }
Exemple #29
0
 private static boolean isSelfPerson(Party person) {
   final User userView = Authenticate.getUser();
   return userView.getPerson() != null && userView.getPerson().equals(person);
 }
 @Override
 protected void process(final ActivityInformation activityInformation) {
   final MissionProcess missionProcess = (MissionProcess) activityInformation.getProcess();
   missionProcess.authorize(Authenticate.getUser());
   // missionProcess.addToProcessParticipantInformationQueues();
 }