Example #1
0
  /**
   * Updates/Creates worker
   *
   * @param map HashMap is analaog to SkillType class
   * @return Optional Business message
   * @throws Exception
   */
  public String saveItem(HashMap map) throws Exception {
    String rtn = ITEM_SAVED_OK_MSG;
    PolicySF psf = ServiceLocator.getPolicySFLocal();
    SkillType skillType = new SkillType();
    CopyUtils.copyProperties(skillType, map);
    long id = skillType.getId();

    if (id > 0) {
      psf.update(skillType);
    } else {

      id = psf.create(skillType);
      skillType.setId(id);
      if (id <= 0) {
        logger.error("SkillType not created.");
      } else {
        logger.info("SkillType created sucessfully id: " + id);
      }
    }

    if (id > 0) {
      LookupMgr.reloadCDLV(SkillTypeRef.class);
    }
    return rtn;
  }
Example #2
0
 public String deleteItem(Long skillTypeId) throws Exception {
   String rtn = ITEM_DELETED_MSG;
   PolicySF psf = ServiceLocator.getPolicySFLocal();
   List<Skill> skills = (List<Skill>) psf.getWorkerSkillGivenSkillType(skillTypeId);
   SkillType skillType = psf.get(SkillType.class, skillTypeId);
   // archive if any skill-worker present else delete
   if (!skills.isEmpty()) {
     psf.removeWorkerSkillGivenSkillType(skillTypeId);
     skillType.setArchivedDate(new java.util.Date());
     psf.update(skillType);
   } else {
     psf.remove(skillType);
   }
   LookupMgr.reloadCDLV(SkillTypeRef.class);
   return rtn;
 }