Search in sources :

Example 1 with EntityEmployment

use of org.kuali.kfs.kim.impl.identity.employment.EntityEmployment in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method setCollegeAndDepartmentBasedOnPrimaryDepartment.

/**
 * Sets the College and Department based on the initiator primary department.
 *
 * @param documentForm
 */
private void setCollegeAndDepartmentBasedOnPrimaryDepartment(IWantDocumentForm documentForm) {
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    String primaryDeptOrg = null;
    IWantDocument iWantDocument = null;
    if (documentForm != null && documentForm.getDocument() != null) {
        iWantDocument = (IWantDocument) documentForm.getDocument();
    }
    if (iWantDocument != null && StringUtils.isEmpty(iWantDocument.getCollegeLevelOrganization())) {
        Person currentUser = GlobalVariables.getUserSession().getPerson();
        Entity entityInfo = KimApiServiceLocator.getIdentityService().getEntityByPrincipalId(currentUser.getPrincipalId());
        if (ObjectUtils.isNotNull(entityInfo)) {
            if (ObjectUtils.isNotNull(entityInfo.getEmploymentInformation()) && entityInfo.getEmploymentInformation().size() > 0) {
                EntityEmployment employmentInformation = entityInfo.getEmploymentInformation().get(0);
                String primaryDepartment = employmentInformation.getPrimaryDepartmentCode();
                primaryDeptOrg = primaryDepartment.substring(primaryDepartment.lastIndexOf('-') + 1, primaryDepartment.length());
                String cLevelOrg = iWantDocumentService.getCLevelOrganizationForDLevelOrg(primaryDepartment);
                ((IWantDocument) documentForm.getDocument()).setCollegeLevelOrganization(cLevelOrg);
            }
        }
    }
    if (iWantDocument != null && StringUtils.isNotEmpty(iWantDocument.getCollegeLevelOrganization())) {
        String cLevelOrg = iWantDocument.getCollegeLevelOrganization();
        documentForm.getDeptOrgKeyLabels().clear();
        documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue("", "Please Select"));
        List<LevelOrganization> dLevelOrgs = iWantDocumentService.getDLevelOrganizations(cLevelOrg);
        for (LevelOrganization levelOrganization : dLevelOrgs) {
            documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue(levelOrganization.getCode(), levelOrganization.getCodeAndDescription()));
        }
        if (primaryDeptOrg != null) {
            iWantDocument.setDepartmentLevelOrganization(primaryDeptOrg);
        }
    }
}
Also used : ConcreteKeyValue(org.kuali.kfs.core.api.util.ConcreteKeyValue) Entity(org.kuali.kfs.kim.impl.identity.entity.Entity) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) EntityEmployment(org.kuali.kfs.kim.impl.identity.employment.EntityEmployment) Person(org.kuali.kfs.kim.api.identity.Person) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 2 with EntityEmployment

use of org.kuali.kfs.kim.impl.identity.employment.EntityEmployment in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method setUpIWantDocDefaultValues.

/**
 * @see edu.cornell.kfs.module.purap.document.service.IWantDocumentService#setUpIWantDocDefaultValues(IWantDocument, Person)
 */
@Override
public void setUpIWantDocDefaultValues(IWantDocument iWantDocument, Person initiatorUser) {
    String principalId = iWantDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    Principal initiator = KimApiServiceLocator.getIdentityService().getPrincipal(principalId);
    String initiatorPrincipalID = initiator.getPrincipalId();
    String initiatorNetID = initiator.getPrincipalName();
    iWantDocument.setInitiatorNetID(initiatorNetID);
    String initiatorName = initiatorUser.getName();
    String initiatorPhoneNumber = initiatorUser.getPhoneNumber();
    String initiatorEmailAddress = initiatorUser.getEmailAddress();
    String address = getPersonCampusAddress(initiatorNetID);
    iWantDocument.setInitiatorName(initiatorName);
    iWantDocument.setInitiatorPhoneNumber(initiatorPhoneNumber);
    iWantDocument.setInitiatorEmailAddress(initiatorEmailAddress);
    iWantDocument.setInitiatorAddress(address);
    // check default user options
    Map<String, String> primaryKeysCollegeOption = new HashMap<String, String>();
    primaryKeysCollegeOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysCollegeOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_COLLEGE);
    IWantDocUserOptions userOptionsCollege = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysCollegeOption);
    Map<String, String> primaryKeysDepartmentOption = new HashMap<String, String>();
    primaryKeysDepartmentOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDepartmentOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DEPARTMENT);
    IWantDocUserOptions userOptionsDepartment = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDepartmentOption);
    // check default deliver to address info
    Map<String, String> primaryKeysdeliverToNetIDOption = new HashMap<String, String>();
    primaryKeysdeliverToNetIDOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysdeliverToNetIDOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NET_ID);
    IWantDocUserOptions userOptionsDeliverToNetID = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysdeliverToNetIDOption);
    Map<String, String> primaryKeysDeliverToNameOption = new HashMap<String, String>();
    primaryKeysDeliverToNameOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToNameOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NAME);
    IWantDocUserOptions userOptionsDeliverToName = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToNameOption);
    Map<String, String> primaryKeysDeliverToEmailOption = new HashMap<String, String>();
    primaryKeysDeliverToEmailOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToEmailOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_EMAIL_ADDRESS);
    IWantDocUserOptions userOptionsDeliverToEmail = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToEmailOption);
    Map<String, String> primaryKeysDeliverToPhnNbrOption = new HashMap<String, String>();
    primaryKeysDeliverToPhnNbrOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToPhnNbrOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_PHONE_NUMBER);
    IWantDocUserOptions userOptionsDeliverToPhnNbr = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToPhnNbrOption);
    Map<String, String> primaryKeysDeliverToAddressOption = new HashMap<String, String>();
    primaryKeysDeliverToAddressOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToAddressOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_ADDRESS);
    IWantDocUserOptions userOptionsDeliverToAddress = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToAddressOption);
    if (ObjectUtils.isNotNull(userOptionsCollege)) {
        iWantDocument.setCollegeLevelOrganization(userOptionsCollege.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDepartment)) {
        iWantDocument.setDepartmentLevelOrganization(userOptionsDepartment.getOptionValue());
    }
    // if no default user options check primary department
    if (ObjectUtils.isNull(userOptionsCollege) && ObjectUtils.isNull(userOptionsDepartment)) {
        String primaryDeptOrg = null;
        if (ObjectUtils.isNotNull(iWantDocument)) {
            Entity entityInfo = KimApiServiceLocator.getIdentityService().getEntityByPrincipalId(initiatorUser.getPrincipalId());
            if (ObjectUtils.isNotNull(entityInfo)) {
                if (ObjectUtils.isNotNull(entityInfo.getEmploymentInformation()) && entityInfo.getEmploymentInformation().size() > 0) {
                    EntityEmployment employmentInformation = entityInfo.getEmploymentInformation().get(0);
                    String primaryDepartment = employmentInformation.getPrimaryDepartmentCode();
                    primaryDeptOrg = primaryDepartment.substring(primaryDepartment.lastIndexOf('-') + 1, primaryDepartment.length());
                    String cLevelOrg = getCLevelOrganizationForDLevelOrg(primaryDepartment);
                    iWantDocument.setCollegeLevelOrganization(cLevelOrg);
                }
            }
        }
        if (ObjectUtils.isNotNull(iWantDocument) && StringUtils.isNotEmpty(iWantDocument.getCollegeLevelOrganization())) {
            if (ObjectUtils.isNotNull(primaryDeptOrg)) {
                iWantDocument.setDepartmentLevelOrganization(primaryDeptOrg);
            }
        }
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToNetID)) {
        iWantDocument.setDeliverToNetID(userOptionsDeliverToNetID.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToName)) {
        iWantDocument.setDeliverToName(userOptionsDeliverToName.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToEmail)) {
        iWantDocument.setDeliverToEmailAddress(userOptionsDeliverToEmail.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToPhnNbr)) {
        iWantDocument.setDeliverToPhoneNumber(userOptionsDeliverToPhnNbr.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToAddress)) {
        iWantDocument.setDeliverToAddress(userOptionsDeliverToAddress.getOptionValue());
    }
    setIWantDocumentDescription(iWantDocument);
}
Also used : Entity(org.kuali.kfs.kim.impl.identity.entity.Entity) HashMap(java.util.HashMap) EntityEmployment(org.kuali.kfs.kim.impl.identity.employment.EntityEmployment) IWantDocUserOptions(edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal)

Example 3 with EntityEmployment

use of org.kuali.kfs.kim.impl.identity.employment.EntityEmployment in project cu-kfs by CU-CommunityApps.

the class IdentityServiceImpl method getPrincipalsByEmployeeId.

@Override
public List<Principal> getPrincipalsByEmployeeId(String employeeId) throws IllegalArgumentException {
    incomingParamCheck(employeeId, "employeeId");
    List<Principal> principals = new ArrayList<>();
    Map<String, Object> criteria = new HashMap<>(2);
    criteria.put(KIMPropertyConstants.Person.EMPLOYEE_ID, employeeId);
    Collection<EntityEmployment> entityEmployments = businessObjectService.findMatching(EntityEmployment.class, criteria);
    if (entityEmployments != null && !entityEmployments.isEmpty()) {
        List<String> entityIds = new ArrayList<>();
        for (EntityEmployment entityEmployment : entityEmployments) {
            String entityId = entityEmployment.getEntityId();
            if (StringUtils.isNotBlank(entityId) && !entityIds.contains(entityId)) {
                entityIds.add(entityId);
            }
        }
        for (String entityId : entityIds) {
            List<Principal> principalsForEntity = getPrincipalsByEntityId(entityId);
            if (principalsForEntity != null && !principalsForEntity.isEmpty()) {
                principals.addAll(principalsForEntity);
            }
        }
        if (!principals.isEmpty()) {
            return principals;
        }
    }
    return null;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EntityEmployment(org.kuali.kfs.kim.impl.identity.employment.EntityEmployment) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal)

Example 4 with EntityEmployment

use of org.kuali.kfs.kim.impl.identity.employment.EntityEmployment in project cu-kfs by CU-CommunityApps.

the class IdentityServiceImpl method getEntity.

@Cacheable(cacheNames = Entity.CACHE_NAME, key = "'{getEntity}-id=' + #p0")
@Override
public Entity getEntity(String entityId) throws IllegalArgumentException {
    incomingParamCheck(entityId, "entityId");
    Entity entity = businessObjectService.findByPrimaryKey(Entity.class, Collections.singletonMap("id", entityId));
    if (entity == null) {
        return null;
    }
    // from the db. This will load those references so Employment Information is populated when editing a Person.
    for (EntityEmployment entityEmployment : entity.getEmploymentInformation()) {
        if (ObjectUtils.isNull(entityEmployment.getEntityAffiliation())) {
            entityEmployment.refreshReferenceObject("entityAffiliation");
        }
    }
    return entity;
}
Also used : Entity(org.kuali.kfs.kim.impl.identity.entity.Entity) EntityEmployment(org.kuali.kfs.kim.impl.identity.employment.EntityEmployment) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 5 with EntityEmployment

use of org.kuali.kfs.kim.impl.identity.employment.EntityEmployment in project cu-kfs by CU-CommunityApps.

the class PersonImpl method populateEmploymentInfo.

protected void populateEmploymentInfo(Entity entity) {
    if (entity != null) {
        EntityEmployment employmentInformation = entity.getPrimaryEmployment();
        if (employmentInformation != null) {
            employeeStatusCode = unNullify(employmentInformation.getEmployeeStatus() != null ? employmentInformation.getEmployeeStatus().getCode() : null);
            employeeTypeCode = unNullify(employmentInformation.getEmployeeType() != null ? employmentInformation.getEmployeeType().getCode() : null);
            primaryDepartmentCode = unNullify(employmentInformation.getPrimaryDepartmentCode());
            employeeId = unNullify(employmentInformation.getEmployeeId());
            if (employmentInformation.getBaseSalaryAmount() != null) {
                baseSalaryAmount = employmentInformation.getBaseSalaryAmount();
            } else {
                baseSalaryAmount = KualiDecimal.ZERO;
            }
            primary = employmentInformation.isPrimary();
        } else {
            employeeStatusCode = "";
            employeeTypeCode = "";
            primaryDepartmentCode = "";
            employeeId = "";
            baseSalaryAmount = KualiDecimal.ZERO;
        }
    }
}
Also used : EntityEmployment(org.kuali.kfs.kim.impl.identity.employment.EntityEmployment)

Aggregations

EntityEmployment (org.kuali.kfs.kim.impl.identity.employment.EntityEmployment)5 Entity (org.kuali.kfs.kim.impl.identity.entity.Entity)3 HashMap (java.util.HashMap)2 Principal (org.kuali.kfs.kim.impl.identity.principal.Principal)2 IWantDocUserOptions (edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions)1 LevelOrganization (edu.cornell.kfs.module.purap.businessobject.LevelOrganization)1 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)1 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)1 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)1 ArrayList (java.util.ArrayList)1 ConcreteKeyValue (org.kuali.kfs.core.api.util.ConcreteKeyValue)1 Person (org.kuali.kfs.kim.api.identity.Person)1 Cacheable (org.springframework.cache.annotation.Cacheable)1