@Override
  @SuppressWarnings("rawtypes")
  public BusinessObject getBusinessObject(Map fieldValues) {
    SalaryGroupBo salaryGroup = null;

    if (StringUtils.isNotBlank((String) fieldValues.get("hrSalGroupId"))) {
      salaryGroup =
          SalaryGroupBo.from(
              HrServiceLocator.getSalaryGroupService()
                  .getSalaryGroup((String) fieldValues.get("hrSalGroupId")));
    } else if (StringUtils.isNotBlank((String) fieldValues.get("hrSalGroup"))
        && StringUtils.isNotBlank((String) fieldValues.get("effectiveDate"))) {
      String hrSalGroup = (String) fieldValues.get("hrSalGroup");
      String effDate = (String) fieldValues.get("effectiveDate");
      LocalDate effectiveDate =
          StringUtils.isBlank(effDate) ? LocalDate.now() : TKUtils.formatDateString(effDate);

      salaryGroup =
          SalaryGroupBo.from(
              HrServiceLocator.getSalaryGroupService().getSalaryGroup(hrSalGroup, effectiveDate));
    } else {
      salaryGroup = (SalaryGroupBo) super.getBusinessObject(fieldValues);
    }

    return salaryGroup;
  }
 @Override
 protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
   LocalDate asOfDate = LocalDate.now();
   List<LeavePlan> leavePlans =
       HrServiceLocator.getLeavePlanService()
           .getLeavePlansNeedsCarryOverScheduled(getLeavePlanPollingWindow(), asOfDate);
   try {
     if (CollectionUtils.isNotEmpty(leavePlans)) {
       // schedule batch job for all LeavePlans who fall in leave polling window.
       for (LeavePlan leavePlan : leavePlans) {
         getBatchJobService().scheduleLeaveCarryOverJobs(leavePlan);
       }
     }
   } catch (SchedulerException se) {
     LOG.warn("Exception thrown during job scheduling of Carry over for Leave", se);
     //        	throw new JobExecutionException("Exception thrown during job scheduling of Carry
     // over for Leave", se);
   }
 }
Esempio n. 3
0
  @Override
  public List<KeyValue> getKeyValues(ViewModel model) {

    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
    HrBusinessObject anHrKeyObject =
        (HrBusinessObject) docForm.getDocument().getNewMaintainableObject().getDataObject();
    LocalDate aDate = LocalDate.fromDateFields(anHrKeyObject.getRelativeEffectiveDate());

    if (aDate != null) {
      List<? extends HrGroupKey> groupKeyList =
          HrServiceLocator.getHrGroupKeyService().getAllActiveHrGroupKeys(aDate);
      if (CollectionUtils.isNotEmpty(groupKeyList)) {
        for (HrGroupKey groupKey : groupKeyList) {
          keyValues.add(
              new ConcreteKeyValue(
                  (String) groupKey.getGroupKeyCode(), (String) groupKey.getGroupKeyCode()));
        }
      }
    }

    return keyValues;
  }
Esempio n. 4
0
  public boolean principalHasRole(
      String principalId,
      String namespaceCode,
      String roleName,
      Map<String, String> qualification,
      DateTime asOfDate) {
    boolean principalHasRole = false;

    String roleId = getRoleService().getRoleIdByNamespaceCodeAndName(namespaceCode, roleName);

    if (roleId == null) {
      return false;
    }
    if (asOfDate.compareTo(LocalDate.now().toDateTimeAtStartOfDay()) == 0) {
      principalHasRole =
          getRoleService()
              .principalHasRole(principalId, Collections.singletonList(roleId), qualification);
    } else {
      List<RoleMember> roleMembers =
          getRoleMembers(namespaceCode, roleName, qualification, asOfDate, true);

      for (RoleMember roleMember : roleMembers) {
        if (MemberType.PRINCIPAL.equals(roleMember.getType())) {
          if (StringUtils.equals(roleMember.getMemberId(), principalId)) {
            principalHasRole = true;
            break;
          }
        } else if (MemberType.GROUP.equals(roleMember.getType())) {
          if (HrServiceLocator.getKPMEGroupService()
              .isMemberOfGroupWithId(principalId, roleMember.getMemberId(), asOfDate)) {
            // if (getGroupService().isMemberOfGroup(principalId, roleMember.getMemberId())) {
            principalHasRole = true;
            break;
          }
        } else if (MemberType.ROLE.equals(roleMember.getType())) {
          Role derivedRole =
              getRoleService()
                  .getRoleByNamespaceCodeAndName(
                      KPMENamespace.KPME_HR.getNamespaceCode(),
                      KPMERole.DERIVED_ROLE_POSITION.getRoleName());
          // check if the member represents the (nested) derived role 'position'
          if (derivedRole != null && roleMember.getMemberId().equals(derivedRole.getId())) {
            // add custom attributes
            Map<String, String> qual = new HashMap<String, String>();
            qual.putAll(roleMember.getAttributes());
            qual.put("asOfDate", asOfDate.toString());
            // return true if the principal id is a member of the (nested) derived role 'position'
            RoleTypeService roleTypeService = getRoleTypeService(derivedRole);
            if (roleTypeService.hasDerivedRole(
                principalId,
                new ArrayList<String>(),
                derivedRole.getNamespaceCode(),
                derivedRole.getName(),
                qual)) {
              principalHasRole = true;
              break;
            }
          }
        }
      }
    }

    return principalHasRole;
  }