コード例 #1
0
  /**
   * This does not explicitly delete the names because its assumed the recalculation will clean it
   * up.
   */
  public boolean deleteSystemOfRecordPerson(
      final SorPerson sorPerson, final boolean mistake, final String terminationTypes) {
    Assert.notNull(sorPerson, "sorPerson cannot be null.");
    final String terminationTypeToUse =
        terminationTypes != null ? terminationTypes : Type.TerminationTypes.UNSPECIFIED.name();

    final Person person = this.personRepository.findByInternalId(sorPerson.getPersonId());
    Assert.notNull(person, "person cannot be null.");

    if (mistake) {
      Set<Role> rolesToDelete = new HashSet<Role>();

      for (final SorRole sorRole : sorPerson.getRoles()) {
        for (final Role role : person.getRoles()) {
          if (sorRole.getId().equals(role.getSorRoleId())) {
            rolesToDelete.add(role);
          }
        }
      }

      for (final Role role : rolesToDelete) {
        // let sorRoleElector delete the role and add another role if required
        sorRoleElector.removeCalculatedRole(
            person, role, this.personRepository.getSoRRecordsForPerson(person));
      }

      final Number number = this.personRepository.getCountOfSoRRecordsForPerson(person);

      if (number.intValue() == 1) {
        this.personRepository.deletePerson(person);
      }

      this.personRepository.deleteSorPerson(sorPerson);
      return true;
    }

    // we do this explicitly here because once they're gone we can't re-calculate?  We might move to
    // this to the recalculateCalculatedPerson method.
    final Type terminationReason =
        this.referenceRepository.findType(Type.DataTypes.TERMINATION, terminationTypeToUse);

    for (final SorRole sorRole : sorPerson.getRoles()) {
      for (final Role role : person.getRoles()) {
        if (!role.isTerminated() && sorRole.getId().equals(role.getSorRoleId())) {
          role.expireNow(terminationReason, true);
        }
      }
    }

    this.personRepository.deleteSorPerson(sorPerson);
    this.personRepository.savePerson(person);

    Person p = recalculatePersonBiodemInfo(person, sorPerson, RecalculationType.DELETE, mistake);
    this.personRepository.savePerson(p);
    return true;
  }
コード例 #2
0
ファイル: Form.java プロジェクト: povder/playframework
    /** Return the indexes available for this field (for repeated fields ad List) */
    @SuppressWarnings("rawtypes")
    public List<Integer> indexes() {
      if (form.value().isPresent()) {
        BeanWrapper beanWrapper = new BeanWrapperImpl(form.value().get());
        beanWrapper.setAutoGrowNestedPaths(true);
        String objectKey = name;
        if (form.name() != null && name.startsWith(form.name() + ".")) {
          objectKey = name.substring(form.name().length() + 1);
        }

        List<Integer> result = new ArrayList<>();
        if (beanWrapper.isReadableProperty(objectKey)) {
          Object value = beanWrapper.getPropertyValue(objectKey);
          if (value instanceof Collection) {
            for (int i = 0; i < ((Collection) value).size(); i++) {
              result.add(i);
            }
          }
        }

        return result;

      } else {
        Set<Integer> result = new HashSet<>();
        Pattern pattern = Pattern.compile("^" + Pattern.quote(name) + "\\[(\\d+)\\].*$");

        for (String key : form.data().keySet()) {
          java.util.regex.Matcher matcher = pattern.matcher(key);
          if (matcher.matches()) {
            result.add(Integer.parseInt(matcher.group(1)));
          }
        }

        List<Integer> sortedResult = new ArrayList<>(result);
        Collections.sort(sortedResult);
        return sortedResult;
      }
    }
コード例 #3
0
ファイル: Form.java プロジェクト: povder/playframework
 static {
   internalAnnotationAttributes.add("message");
   internalAnnotationAttributes.add("groups");
   internalAnnotationAttributes.add("payload");
 }