Search in sources :

Example 1 with LevelOrganization

use of edu.cornell.kfs.module.purap.businessobject.LevelOrganization in project cu-kfs by CU-CommunityApps.

the class LevelOrganizationDaoJdbc method getDLevelOrganizations.

/**
 * This overridden method ...
 *
 * @see edu.cornell.kfs.module.purap.dataaccess.LevelOrganizationDao#getDLevelOrganizations(java.lang.String)
 */
public List<LevelOrganization> getDLevelOrganizations(String cLevelOrg) {
    if (StringUtils.isNotEmpty(cLevelOrg) && cLevelOrg.contains("-")) {
        String chart = cLevelOrg.substring(0, cLevelOrg.lastIndexOf("-"));
        String cOrg = cLevelOrg.substring(cLevelOrg.lastIndexOf("-") + 1, cLevelOrg.length());
        try {
            // Build the SQL
            StringBuilder sqlBuilder = new StringBuilder(3500);
            sqlBuilder.append(" select D_Level_Code, D_Level_Name from ( select ");
            sqlBuilder.append("       org_cd,");
            sqlBuilder.append("                  ( select org_cd ");
            sqlBuilder.append("                    from ca_org_t where org_typ_cd='C' and ROWNUM=1 ");
            sqlBuilder.append("              start with org_cd=t2.org_cd and fin_coa_cd= ? ");
            sqlBuilder.append("                   connect by prior rpts_to_org_cd = org_cd and rpts_to_org_cd not in ('UNIV') and fin_coa_cd=?) C_Level_Code, ");
            sqlBuilder.append("               ( select org_nm ");
            sqlBuilder.append("               from ca_org_t where org_typ_cd='C' and ROWNUM=1 ");
            sqlBuilder.append("                start with org_cd=t2.org_cd and fin_coa_cd=? ");
            sqlBuilder.append("                 connect by prior rpts_to_org_cd = org_cd and rpts_to_org_cd not in ('UNIV') and fin_coa_cd=?) C_Level_Name, ");
            sqlBuilder.append("                ( select org_cd from ca_org_t where org_typ_cd='D' and ROWNUM=1 ");
            sqlBuilder.append("              start with org_cd=t2.org_cd and fin_coa_cd=?");
            sqlBuilder.append("             connect by prior rpts_to_org_cd = org_cd and rpts_to_org_cd not in ('UNIV') and fin_coa_cd=?) D_Level_Code,");
            sqlBuilder.append("                       ( select org_nm from ca_org_t where org_typ_cd='D' and ROWNUM=1 ");
            sqlBuilder.append("                start with org_cd=t2.org_cd and fin_coa_cd=?");
            sqlBuilder.append("                connect by prior rpts_to_org_cd = org_cd and rpts_to_org_cd not in ('UNIV') and fin_coa_cd=?) D_Level_Name ");
            sqlBuilder.append("             from  ca_org_t t2 where t2.org_typ_cd = 'D' and ORG_ACTIVE_CD = 'Y' ");
            sqlBuilder.append("             ) t where t.C_Level_Code = ? order by D_Level_Name");
            String sqlString = sqlBuilder.toString();
            // Get the SIP data from the data base, map it to the object and build a result set of objects to be returned to the user.
            RowMapper<LevelOrganization> mapper = new RowMapper<LevelOrganization>() {

                public LevelOrganization mapRow(ResultSet rs, int rowNum) throws SQLException {
                    LevelOrganization cLevelOrganization = new LevelOrganization();
                    cLevelOrganization.setCode(rs.getString("D_Level_Code"));
                    cLevelOrganization.setName(rs.getString("D_Level_Name"));
                    return cLevelOrganization;
                }
            };
            return this.getJdbcTemplate().query(sqlString, mapper, chart, chart, chart, chart, chart, chart, chart, chart, cOrg);
        } catch (Exception ex) {
            LOG.info("LevelOrganizationDaoJdbc Exception: " + ex.getMessage());
            return null;
        }
    } else
        return null;
}
Also used : LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) ResultSet(java.sql.ResultSet) SQLException(java.sql.SQLException) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 2 with LevelOrganization

use of edu.cornell.kfs.module.purap.businessobject.LevelOrganization 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.rice.core.api.util.ConcreteKeyValue) Entity(org.kuali.rice.kim.api.identity.entity.Entity) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) EntityEmployment(org.kuali.rice.kim.api.identity.employment.EntityEmployment) Person(org.kuali.rice.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 3 with LevelOrganization

use of edu.cornell.kfs.module.purap.businessobject.LevelOrganization in project cu-kfs by CU-CommunityApps.

the class CollegeLevelOrganizationValuesFinder method getKeyValues.

public List<KeyValue> getKeyValues() {
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    List<LevelOrganization> cLevelOrganizations = iWantDocumentService.getCLevelOrganizations();
    keyValues.add(new ConcreteKeyValue("", ""));
    if (cLevelOrganizations != null) {
        for (LevelOrganization cLevelOrganization : cLevelOrganizations) {
            keyValues.add(new ConcreteKeyValue(cLevelOrganization.getCode(), cLevelOrganization.getCodeAndDescription()));
        }
    }
    return keyValues;
}
Also used : ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) KeyValue(org.kuali.rice.core.api.util.KeyValue) ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) ArrayList(java.util.ArrayList) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 4 with LevelOrganization

use of edu.cornell.kfs.module.purap.businessobject.LevelOrganization in project cu-kfs by CU-CommunityApps.

the class LevelOrganizationDaoJdbc method getCLevelOrganizations.

/**
 * This overridden method ...
 *
 * @see edu.cornell.kfs.module.purap.dataaccess.LevelOrganizationDao#getCLevelOrganizations()
 */
public List<LevelOrganization> getCLevelOrganizations() {
    try {
        // Build the SQL
        StringBuilder sqlBuilder = new StringBuilder(3500);
        sqlBuilder.append("select fin_coa_cd, org_cd, org_nm from ca_org_t where fin_coa_cd in('IT') and ORG_ACTIVE_CD = 'Y' and org_cd <> 'XXXX' and org_typ_cd = 'C' order by fin_coa_cd desc, org_nm");
        String sqlString = sqlBuilder.toString();
        RowMapper<LevelOrganization> mapper = new RowMapper<LevelOrganization>() {

            public LevelOrganization mapRow(ResultSet rs, int rowNum) throws SQLException {
                LevelOrganization cLevelOrganization = new LevelOrganization();
                cLevelOrganization.setCode(rs.getString("fin_coa_cd") + "-" + rs.getString("org_cd"));
                cLevelOrganization.setName(rs.getString("org_nm"));
                return cLevelOrganization;
            }
        };
        return this.getJdbcTemplate().query(sqlString, mapper);
    } catch (Exception ex) {
        LOG.info("LevelOrganizationDaoJdbc Exception: " + ex.getMessage());
        return null;
    }
}
Also used : LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) ResultSet(java.sql.ResultSet) SQLException(java.sql.SQLException) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 5 with LevelOrganization

use of edu.cornell.kfs.module.purap.businessobject.LevelOrganization in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method getDLevelOrganizationsString.

/**
 * @see edu.cornell.kfs.module.purap.document.service.IWantDocumentService#getDLevelOrganizationsString(java.lang.String)
 */
public String getDLevelOrganizationsString(String cLevelOrg) {
    List<LevelOrganization> dLevelOrgs = getDLevelOrganizations(cLevelOrg);
    StringBuilder dLevelOrgsString = new StringBuilder();
    for (LevelOrganization organization : dLevelOrgs) {
        dLevelOrgsString.append(organization.getCode()).append(' ').append(organization.getCodeAndDescription()).append('#');
    }
    return dLevelOrgsString.toString();
}
Also used : LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization)

Aggregations

LevelOrganization (edu.cornell.kfs.module.purap.businessobject.LevelOrganization)6 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)3 ConcreteKeyValue (org.kuali.rice.core.api.util.ConcreteKeyValue)3 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 RowMapper (org.springframework.jdbc.core.RowMapper)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ActionForward (org.apache.struts.action.ActionForward)1 KeyValue (org.kuali.rice.core.api.util.KeyValue)1 Person (org.kuali.rice.kim.api.identity.Person)1 EntityEmployment (org.kuali.rice.kim.api.identity.employment.EntityEmployment)1 Entity (org.kuali.rice.kim.api.identity.entity.Entity)1