// 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); } } } }
// 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"); } } } }