com.ing.connector.newbus.WPendingOverridesImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.ing.connector.newbus.WPendingOverridesImpl.java

Source

//******************************************************************************
// THE SOFTWARE COMPRISING THIS SYSTEM IS THE PROPERTY OF ELECTRONIC DATA
// SYSTEMS CORP. OR ITS LICENSORS.
//
// ALL COPYRIGHT, PATENT, TRADE SECRET, AND OTHER INTELLECTUAL PROPERTY RIGHTS
// IN THE SOFTWARE COMPRISING THIS SYSTEM ARE, AND SHALL REMAIN, THE VALUABLE
// PROPERTY OF ELECTRONIC DATA SYSTEMS CORP. OR ITS LICENSORS.
//
// USE, DISCLOSURE, OR REPRODUCTION OF THIS SOFTWARE IS STRICTLY PROHIBITED,
// EXCEPT UNDER WRITTEN LICENSE FROM ELECTRONIC DATA SYSTEMS CORP. OR ITS
// LICENSORS.
//
// (C) COPYRIGHT 1998 ELECTRONIC DATA SYSTEMS CORP.  ALL RIGHTS RESERVED
//******************************************************************************

//******************************************************************************
// $Log:
//
//   Rev CSST400   Feb 2003   BRB
// Get override agent id
//   Rev 4.0   May 2001   JFG
// Pass in Company Id in WObjectKeys.
//
//   Rev 3.0   Oct 2000   DIL
// Check the table type ini entry to determine which stored procedure to exeucte.
//
//   Rev 2.0   Dec 1999   JFG
// Bypass stored procedure call if the agent number did not come from NNB.
//
//    Rev 1.1   Apr 1999   JSK
// Modified to support WObjectKeys.
//
//    Rev 1.0   Apr 1998   J Killeen
// Initial revision.
//******************************************************************************

package com.ing.connector.newbus;

import java.sql.*;
import java.util.*;

import org.apache.commons.lang.StringUtils;

import com.ing.connector.Registrar;
import com.ing.connector.model.WAgentOverrideExt;
import com.ing.connector.model.WCollection;
import com.ing.connector.newbus.WDateIsoFormat;
import com.ing.connector.server.LookUp;
import com.ing.connector.util.WObjectKeys;
import com.ing.connector.util.WResult;
import com.ing.connector.util.WStringUtil;

public class WPendingOverridesImpl extends WImpl {
    public WPendingOverridesImpl(IDriverNewBus driver) {
        super(driver);
    }

    /**
     * This method will query the database and create an Odd string that
     * represents the collection of agent overrides.
     */
    public WResult getObject(WObjectKeys keys) {
        String policyId = keys.getStringKey(1);
        String agentSystemSource = keys.getStringKey(2); //JFG2.0
        String companyId = keys.getStringKey(3); //JFG4.0
        String agentParm = keys.getStringKey(4); //CSST400
        String driverSystemSource = getDriver().getSystemSource(); //JFG2.0
        String driverTableType = getDriver().getTableType(); //DIL3.0
        String databaseName = "scldbali"; //DIL3.0
        String procedureName = null; //DIL3.0
        String userType = keys.getStringKey(5);
        String agentName;

        com.ing.connector.Registrar.logInfoMessage("wpendingoverridesimpl - userType" + userType);

        WResult result = new WResult();

        WCollection collection = new WCollection("com.ing.connector.model.WAgentOverrideExt");

        result.setModelObject(collection);

        if (!agentSystemSource.equals(driverSystemSource)) //JFG2.0
        {
            result.setStatus(WResult.OBJECT_NOT_FOUND);
            return result;
        }

        if (userType != null && userType.equalsIgnoreCase("internalUser"))
            databaseName = LookUp.getInstance().getStringProperty("Connector.History.Database");
        ;

        // March 2004 deleted int connNo = line

        Connection con = getConnection();
        // March 2004 removed param

        if (driverTableType.equals(TABLETYPECOPY)) //DIL3.0
        { //DIL3.0

            procedureName = "bali_WAgentOverrides_get_p"; //DIL3.0
        } //DIL3.0
        else //DIL3.0
        { //DIL3.0
            //databaseName = "scldpt";                        //RL-004454 RSD 

            procedureName = "bali_WAgentOverridesImpl"; //DIL3.0
        } //DIL3.0
        com.ing.connector.Registrar.logInfoMessage("wpendingoverridesimpl - databaseName" + databaseName);
        com.ing.connector.Registrar.logInfoMessage("wpendingoverridesimpl - procedureName" + procedureName);
        try {
            Statement stmt = con.createStatement();
            //DIL3.0            stmt.execute("use " + "scldpt");
            stmt.execute("use " + databaseName);
            Registrar.logInfoMessage("exec " + procedureName + " " + policyId + "," + agentParm);
            //DIL3.0            CallableStatement cstmt = con.prepareCall("{call bali_WAgentOverridesImpl(?)}");
            CallableStatement cstmt = con.prepareCall("{call " + procedureName + "(?,?)}"); //CSST400
            cstmt.setString(1, policyId);
            cstmt.setString(2, agentParm); //CSST400

            ResultSet rs = cstmt.executeQuery();

            WDateIsoFormat isoFormat = new WDateIsoFormat();

            while (rs.next()) {

                WAgentOverrideExt single = new WAgentOverrideExt(getDriverName(), getImplTypeName());

                single.setAgentId(rs.getString("agent_number"));
                agentName = new String(rs.getString("agent_name"));
                //RL-009402 - SXL - START
                String formattedAgentName = WStringUtil.formatAgentName(agentName);

                single.setFormattedAgentName(formattedAgentName);

                if (StringUtils.countMatches(agentName, ",") == 2) {
                    String lastName = agentName.substring(0, agentName.indexOf(",")).trim();
                    String firstName = (agentName.substring(agentName.indexOf(",") + 1, agentName.lastIndexOf(",")))
                            .trim();
                    String middleName = (agentName.substring(agentName.lastIndexOf(",") + 1)).trim();
                    single.setLastName(lastName);
                    single.setFirstName(firstName);
                    single.setMiddleName(middleName);
                } else {
                    //RL-009402 - SXL - END  
                    int i = agentName.indexOf(',');
                    if (i != -1) {
                        single.setLastName(agentName.substring(0, i).trim());
                        single.setFirstName(agentName.substring(i + 1).trim());
                    } else {
                        single.setLastName(agentName);
                    }
                }

                single.setOverridePercent(rs.getDouble("commission_split"));
                single.setContractType(rs.getString("agent_contract_typ"));
                single.setOverrideId(rs.getString("ovr_agent_number")); //CSST400
                single.setOverrideAgentName(rs.getString("ovr_agent_name")); //   KLN/02/13/07//RL-001655    
                single.setLevel(rs.getString("Hierarchy_Type")); //RL-005642 LXJ added
                collection.addElement(single);
            }

            rs.close();
            cstmt.close();
            stmt.close();

            result.setModelObject(collection);

            if (collection.size() == 0) {
                result.setStatus(WResult.OBJECT_NOT_FOUND);
            }

        } catch (SQLException sqle) {
            result.setException(sqle);
            com.ing.connector.Registrar.logError(getClass().getName() + ": " + sqle.getMessage());
        } catch (Exception exc) {
            result.setException(exc);
            com.ing.connector.Registrar.logError(getClass().getName() + ": " + exc.getMessage());
        }

        releaseConnection(con);
        //March 2004 changed param from connNo to con

        return result;

    }

}