@Atomic
  public static void run(Department department, String[] add, String[] remove) {
    check(RolePredicates.DEPARTMENT_ADMINISTRATIVE_OFFICE_PREDICATE);
    List<Person> toAdd = materializePersons(add);
    List<Person> toRemove = materializePersons(remove);
    List<Person> finalList = new ArrayList<Person>();

    Role bolonhaRole = Role.getRoleByRoleType(RoleType.BOLONHA_MANAGER);

    Group group = department.getCompetenceCourseMembersGroup();
    if (group == null) {
      group = new FixedSetGroup();
    }

    for (Person person : group.getElements()) {

      if (!toRemove.contains(person)) {
        finalList.add(person);
        addBolonhaRole(person, bolonhaRole);
      } else if (person.hasRole(RoleType.BOLONHA_MANAGER)
          && !belongsToOtherGroupsWithSameRole(department, person)) {
        person.removeRoleByType(RoleType.BOLONHA_MANAGER);
      }
    }

    for (Person person : toAdd) {
      if (!finalList.contains(person)) {
        finalList.add(person);
        addBolonhaRole(person, bolonhaRole);
      }
    }

    department.setCompetenceCourseMembersGroup(new FixedSetGroup(finalList));
  }
  public ActionForward showExecutionDegrees(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    DynaValidatorForm personExecutionCourseForm = (DynaValidatorForm) form;

    String personId = (String) personExecutionCourseForm.get("teacherId");
    Person person = Person.readPersonByUsername(personId);
    setChoosedExecutionPeriod(
        request, ReadNotClosedExecutionPeriods.run(), personExecutionCourseForm);
    InfoExecutionPeriod infoExecutionPeriod =
        (InfoExecutionPeriod) request.getAttribute("infoExecutionPeriod");
    final ExecutionSemester executionPeriod = infoExecutionPeriod.getExecutionPeriod();
    if (executionPeriod.getSemester().intValue() == 2
        && executionPeriod.getExecutionYear().getYear().equals("2010/2011")) {
    } else {
      if (person.getTeacher() == null
          || (person.getTeacher().getTeacherAuthorization(executionPeriod) == null
              && !person.hasRole(RoleType.TEACHER))) {
        request.setAttribute("notAuth", true);
        return showExecutionYearExecutionPeriods(
            mapping, personExecutionCourseForm, request, response);
      }
    }

    prepareSecondStep(personExecutionCourseForm, request);
    personExecutionCourseForm.set("page", new Integer(2));
    return mapping.findForward("second-step");
  }
예제 #3
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;
    }
 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;
 }
예제 #5
0
 private static boolean hasRole(final RoleType roleType) {
   final Person person = AccessControl.getPerson();
   return person != null && person.hasRole(roleType);
 }
 private static void addBolonhaRole(Person person, Role bolonhaRole) {
   if (!person.hasRole(RoleType.BOLONHA_MANAGER)) {
     person.addPersonRoles(bolonhaRole);
   }
 }
  protected String run(
      final String description, final ExecutionYear executionYear, final String contents)
      throws Exception {

    final CardGenerationBatch cardGenerationBatch = findOrCreate(executionYear, description);
    final CardGenerationBatch cardGenerationBatchWithProblems =
        new CardGenerationBatch("Com Problemas", executionYear, true);
    final CardGenerationBatch cardGenerationBatchWithDuplicates =
        new CardGenerationBatch("Duplicados", executionYear, true);

    for (final String fline : contents.split("\n")) {
      if (!fline.isEmpty()) {
        final String identificationId =
            StringUtils.trim(fline.substring(0, 20).trim()).replace(" ", "");
        final String line = normalize(fline.substring(20)) + "\r\n";

        final Person person = findPerson(identificationId, line);
        final CardGenerationEntry cardGenerationEntry;
        if (person == null) {
          cardGenerationEntry = createEntry(cardGenerationBatch, identificationId, line);
          cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithProblems);
          new CardGenerationProblem(
              cardGenerationBatchWithProblems, "no.person.found", identificationId, null);
        } else {
          //		    if (!hasMatchingLine(person, line)) {
          cardGenerationEntry = createEntry(cardGenerationBatch, identificationId, line, person);

          if (cardGenerationEntry != null) {
            final Category category = cardGenerationEntry.getCategory();
            if (category == Category.CODE_73
                || category == Category.CODE_82
                || category == Category.CODE_96) {
              final Category categoryForLine = CardGenerationEntry.readCategory(line);
              final String studentLine = createNewLine(person, cardGenerationBatch);
              if (studentLine == null) {
                if (category != Category.CODE_96) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithProblems);
                  new CardGenerationProblem(
                      cardGenerationBatchWithProblems,
                      "multiple.user.information.type.not.crossed",
                      identificationId,
                      person);
                } else if (hasMatchingLine(person, line, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
              } else {
                final Category categoryForStudentLine =
                    CardGenerationEntry.readCategory(studentLine);
                final String newLine =
                    merge(line, categoryForLine, studentLine, categoryForStudentLine);
                if (hasMatchingLine(person, newLine, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
                cardGenerationEntry.setLine(newLine);
              }
            } else if (cardGenerationEntry.getCardGenerationBatch() == cardGenerationBatch
                && person != null
                && person.hasRole(RoleType.STUDENT)) {
              final Category categoryForLine = CardGenerationEntry.readCategory(line);
              final String studentLine = createNewLine(person, cardGenerationBatch);
              if (studentLine == null) {
                if (hasMatchingLine(person, line, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
                //			    		cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchUnmatched);
                //			    		new CardGenerationProblem(cardGenerationBatchUnmatched,
                // "person.has.student.role.but.cannot.generate.line", identificationId, person);
              } else {
                final Category categoryForStudentLine =
                    CardGenerationEntry.readCategory(studentLine);
                final String newLine =
                    merge(line, categoryForLine, studentLine, categoryForStudentLine);
                if (hasMatchingLine(person, newLine, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
                cardGenerationEntry.setLine(newLine);
              }
            } else {
              if (hasMatchingLine(person, line, cardGenerationEntry)) {
                cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                new CardGenerationProblem(
                    cardGenerationBatchWithDuplicates,
                    "duplicate.line.from.previous.batch",
                    identificationId,
                    person);
              }
            }
          }
          //		    }
        }
      }
    }

    result.append("Matched " + matched + "\n");
    result.append("Multiple id matches " + multipleIdMatches + "\n");
    result.append("Multiple name matches " + multipleNameMatches + "\n");
    result.append("Unmatched " + unmatched + "\n");
    result.append("Matched lines " + matchedLines + "\n");
    result.append("New lines " + newLines + "\n");

    System.out.flush();
    System.err.flush();

    return result.toString();
  }