コード例 #1
0
  // Used for adding competences to the competence profile of an user
  @Log
  private void addCompetences(Person person, ApplicationDTO appDTO) {
    Competence tempcomp = null;
    Competence_profile competenceProfile;

    if (appDTO.getCompetences() != null) {

      for (CompetenceProfileDTO comp : appDTO.getCompetences()) {
        try {
          tempcomp =
              em.createNamedQuery(
                      "Competence.findByName", Competence.class) // Check if competence exists
                  .setParameter("name", comp.getName())
                  .getSingleResult();
        } catch (NoResultException e) {

        }
        competenceProfile = new Competence_profile(tempcomp, person);
        if (!person
            .getCompetenceProfileCollection()
            .contains(competenceProfile)) { // Check if competence profile already exists

          competenceProfile.setYearsOfExperience(comp.getYearsOfExperience());
          em.persist(competenceProfile);
        }
      }
    }
  }
 // NOTE: The following Getters are used to return saved values in the global.jelly. Intellij
 // marks them unused, but they actually are used.
 // These getters are also named in the following format: doFill<JellyField>Items.
 @SuppressWarnings("unused")
 public ListBoxModel doFillApplicationIdItems() {
   ListBoxModel listBox = new ListBoxModel();
   for (ApplicationDTO app : applications) {
     final String value = String.valueOf(app.getApplicationId());
     listBox.add(new ListBoxModel.Option(app.getApplicationName(), value, false));
   }
   return listBox;
 }
コード例 #3
0
 // Creates an availability for a person
 @Log
 private void addAvailability(Person person, ApplicationDTO appDTO) throws NullArgumentException {
   if (appDTO.getDates() != null) {
     for (AvailabilityDTO avDTO : appDTO.getDates()) {
       if (avDTO.getFrom() != null && avDTO.getTo() != null) {
         if (avDTO.getFrom().before(avDTO.getTo())) {
           Availability availability = new Availability(person);
           availability.setFromDate(avDTO.getFrom());
           availability.setToDate(avDTO.getTo());
           em.persist(availability);
         } else {
           throw new IllegalArgumentException("From date not before to date");
         }
       } else {
         throw new NullArgumentException("Null argument AvailableFrom/AvailableTo");
       }
     }
   }
 }