Commit 2bf680ec authored by ssalve's avatar ssalve

Sarita: Done changes as geeting error to call nvo componenet through service on 19 JUN 18

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@186678 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cba2ac0d
......@@ -34,10 +34,14 @@ import java.util.Map;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.XMLType;
//import javax.xml.rpc.encoding.XMLType;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import oracle.sql.TIMESTAMP;
......@@ -95,6 +99,12 @@ AssetSalesConfLocal,AssetSalesConfRemote
StringBuffer xmlBuff = new StringBuffer();
String xmlString="";
java.sql.Timestamp currentDate = null,today = null;//added by sarita on 06 JUN 2018
//Added by sarita on 19 JUN 18 to store values of asset_register [START]
Timestamp remDate = null;;
String status = "", tranIdRem = "", tranSerRem = "",purpose = "C",deprMethod = "S",confirm="Y",commitFlag = "Y",assetSrc = "S",xmlTabString="" , finalXmlString = "",currentDateTime = "";
double remValues = 0;
HashMap<String , String> retErrTypeValue = new HashMap<String,String>();
//Added by sarita on 19 JUN 18 to store values of asset_register [END]
try
{
ConnDriver connDriver = null;
......@@ -264,6 +274,33 @@ conn = getConnection();
rs = null;
System.out.println("saleCd.compareTo(prdCdUpto) >= 0 >>> sale cd"+saleCd+">>>>>"+prdCdUpto);
//Added by sarita on 19 JUN 18 to store asset_register values before update [START]
sql = "select rem_date , status , tran_id__rem, tran_ser__rem, rem_value from asset_register where asset_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,assetCode);
rs = pstmt.executeQuery();
if(rs.next())
{
remDate= rs.getTimestamp("rem_date");
status = rs.getString("status");
tranIdRem = rs.getString("tran_id__rem");
tranSerRem = rs.getString("tran_ser__rem");
remValues = rs.getDouble("rem_value");
}
System.out.println("Origional Values of asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
//Added by sarita on 19 JUN 18 to store asset_register values before update [END]
if(saleCd.compareTo(prdCdUpto) >= 0)
{
......@@ -299,24 +336,115 @@ conn = getConnection();
{
calc_depreciation = true;
}
if(calc_depreciation == false)
//Commented by sarita on 19 JUN 18 to comment errormessage and else statement[START]
/*if(calc_depreciation == false)
{
errString = itmdbAccess.getErrorString("", "VTASSTSALE", "", "", conn);
return errString;
}
else
else*/
//Commented by sarita on 19 JUN 18 to comment errormessage and else statement[END]
if(calc_depreciation == true)
{
//Added & Commented by sarita on 19 JUN 18 to commit transaction if calc_depreciation = true & create tabxml & xml file[nvo_business_object_fin_asset_sales] and pass to confirmJournalVoucher method [START]
conn.commit();
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
currentDateTime = sdf2.format(today); System.out.println("Current Date Time in Application Format : ["+currentDateTime+"]");
StringBuffer recTabStrBuff = new StringBuffer();//data from d_depr_proc_month.srd
recTabStrBuff.append(siteCode).append("\t"); //site_code
recTabStrBuff.append(itmSer).append("\t"); //item_ser__fr
recTabStrBuff.append(itmSer).append("\t"); //item_ser__to
recTabStrBuff.append(grpCode).append("\t"); //grp_code__fr
recTabStrBuff.append(grpCode).append("\t"); //grp_code__to
recTabStrBuff.append(itmCode).append("\t"); //item_code__fr
recTabStrBuff.append(itmCode).append("\t"); //item_code__to
recTabStrBuff.append(assetCode).append("\t"); //asset_code__fr
recTabStrBuff.append(assetCode).append("\t"); //asset_code__to
recTabStrBuff.append(prdCdUpto).append("\t"); //prd_code__upto
recTabStrBuff.append(purpose).append("\t"); //purpose
recTabStrBuff.append(deprMethod).append("\t"); //depr_method
recTabStrBuff.append(confirm).append("\t"); //confirm
recTabStrBuff.append(commitFlag).append("\t"); //commit_flag
recTabStrBuff.append(assetSrc).append("\t"); //asset_source
recTabStrBuff.append(currentDateTime).append("\t"); //post_date with Application Date Format
xmlTabString = recTabStrBuff.toString();System.out.println(">>>xmlTabString:"+xmlTabString);
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append("").append("</editFlag></header>");
valueXmlString.append("<Detail1>");
valueXmlString.append("<site_code>").append(siteCode).append("</site_code>\r\n");
valueXmlString.append("<item_ser__fr>").append(itmSer).append("</item_ser__fr>\r\n");
valueXmlString.append("<item_ser__to>").append(itmSer).append("</item_ser__to>\r\n");
valueXmlString.append("<grp_code__fr>").append(grpCode).append("</grp_code__fr>\r\n");
valueXmlString.append("<grp_code__to>").append(grpCode).append("</grp_code__to>\r\n");
valueXmlString.append("<item_code__fr>").append(itmCode).append("</item_code__fr>\r\n");
valueXmlString.append("<item_code__to>").append(itmCode).append("</item_code__to>\r\n");
valueXmlString.append("<asset_code__fr>").append(assetCode).append("</asset_code__fr>\r\n");
valueXmlString.append("<asset_code__to>").append(assetCode).append("</asset_code__to>\r\n");
valueXmlString.append("<prd_code__upto>").append(prdCdUpto).append("</prd_code__upto>\r\n");
valueXmlString.append("<purpose>").append(purpose).append("</purpose>\r\n");
valueXmlString.append("<depr_method>").append(deprMethod).append("</depr_method>\r\n");
valueXmlString.append("<confirm>").append(confirm).append("</confirm>\r\n");
valueXmlString.append("<commit_flag>").append(commitFlag).append("</commit_flag>\r\n");
valueXmlString.append("<asset_source>").append(assetSrc).append("</asset_source>\r\n");
valueXmlString.append("<post_date>").append(currentDateTime).append("</post_date>\r\n");
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
finalXmlString = valueXmlString.toString();System.out.println(">>>finalXmlString:"+finalXmlString);
retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, xmlTabString,finalXmlString, conn);
System.out.println("ReturnString of confirmJournalVoucher is :\n" +retString );
if((retString != null && retString.trim().length() > 0) && (retString.indexOf("Errors") > -1))
{
retErrTypeValue = getErrorTypeVal(retString); System.out.println("Values in HashMap[retErrTypeValue] are : ["+retErrTypeValue+"]");
for (String errType : retErrTypeValue.keySet())
{
if("E".equalsIgnoreCase(errType) || "W".equalsIgnoreCase(errType))
{
errCode = retErrTypeValue.get(errType); System.out.println("errCode is ["+errCode+"]");
//Added by sarita to update original values if error occurred on retString on 19 JUN 18 [START]
sql = "update asset_register set rem_date = ?,status=?,tran_id__rem=?,tran_ser__rem=?,rem_value=? where asset_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setTimestamp(1, remDate);
pstmt.setString(2, status);
pstmt.setString(3, tranIdRem);
pstmt.setString(4, tranSerRem);
pstmt.setDouble(5, remValues);
pstmt.setString(6, assetCode);
int chkData = pstmt.executeUpdate();
retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, "", conn);
if(chkData > 0)
{
System.out.println("["+chkData+"] Updated Origional Values to asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
//Added by sarita to update original values if error occurred on retString on 19 JUN 18 [END]
errString = itmdbAccess.getErrorString("", errCode, "", "", conn); System.out.println("errString :>>kkk"+errString);
return errString;
}
}
}
/*retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, "", conn);
if(retString.indexOf("Errors") > -1)
{
errCode = retString;
errString = itmDBAccess.getErrorString("",errCode,"","",conn);
System.out.println("errString :>>kkk"+errString);
return errString;
}
}*/
//Added & Commented by sarita on 19 JUN 18 to commit transaction if calc_depreciation = true & create tabxml & xml file[nvo_business_object_fin_asset_sales] and pass to confirmJournalVoucher method [END]
}
//commented below code for avoiding tax calculation by varsha v on 24-05-18
/*System.out.println("calling taxCalc");
......@@ -1446,8 +1574,11 @@ conn = getConnection();
return retString;
}
public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) throws ITMException
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [START]
//public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) throws ITMException
public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String xmlTabString, String finalXmlString, Connection conn) throws ITMException
{
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [END]
String methodName = "";
String compName = "";
String retString = "";
......@@ -1457,17 +1588,23 @@ conn = getConnection();
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String compType = "",argName = "",argName1 = ""; //Added by sarita on 14 JUN 18
HashMap<String , String> getArgName = new HashMap<String , String>();
int i = 0;
//System.out.println("confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) called >>>");
try
{
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
methodName = "gbf_post";
actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
//Commented by sarita on 19 JUN 18 as methodName will come from table. [START]
//methodName = "gbf_post";
//actionURI = "http://NvoServiceurl.org/" + methodName;
//Commented by sarita on 19 JUN 18 as methodName will come from table. [END]
//Commented and Added by sarita to add comp_type in query on 19 JUN 18 [START]
//sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
......@@ -1475,8 +1612,10 @@ conn = getConnection();
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
}
System.out.println("serviceCode = "+serviceCode+" compName "+compName);
//System.out.println("serviceCode = "+serviceCode+" compName "+compName);
System.out.println("serviceCode = "+serviceCode+" compName "+compName + "compType "+compType);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (pstmt != null)
{
......@@ -1489,15 +1628,21 @@ conn = getConnection();
rs=null;
}
// Changed by Manish on 01/04/16 for max cursor issue [end]
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
//Commented and Added by sarita to add comp_type in query on 19 JUN 18 [END]
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [START]
//sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
sql = "SELECT SERVICE_URI,METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceURI = rs.getString("SERVICE_URI");
methodName = rs.getString("METHOD_NAME");
}
System.out.println("serviceURI = "+serviceURI+" compName = "+compName);
//System.out.println("serviceURI = "+serviceURI+" compName = "+compName);
System.out.println("serviceURI = "+serviceURI+" compName = "+compName+" methodName ="+methodName);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (pstmt != null)
{
......@@ -1510,15 +1655,68 @@ conn = getConnection();
rs=null;
}
// Changed by Manish on 01/04/16 for max cursor issue [end]
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [END]
//Commented and Added by sarita on 19 JUN 18 to dynamic call [START]
actionURI = "http://NvoServiceurl.org/" + methodName;
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[4];
Object[] aobj = new Object[5];
if("WSR".equalsIgnoreCase(compType))
{
sql = "SELECT ARG_NAME FROM SYSTEM_SERVICE_ARGS WHERE SERVICE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
while ( rs.next() )
{
argName = rs.getString("ARG_NAME"); argName1 = argName.toLowerCase().trim();
if("COMPONENT_TYPE".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compType);
}
else if("COMPONENT_NAME".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compName);
}
else if(argName.startsWith("TAB_"))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xmlTabString);
}
else if("DUMMY".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String("");
}
else if("XTRA_PARAMS".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xtraParams);;
}
System.out.println(" Values in aobj[i] : ["+aobj[i]+"] \t For Argument is ["+argName1+"] \t value of i is ["+i+"] ");
i++;
}//end of while loop
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
}//end of if for comp_type [WSR]
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
/*call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
......@@ -1526,8 +1724,10 @@ conn = getConnection();
aobj[0] = new String(compName);
aobj[1] = new String(tranIdFr);
aobj[2] = new String(xtraParams);
aobj[3] = new String(forcedFlag);
aobj[3] = new String(forcedFlag);*/
//System.out.println("@@@@@@@@@@loginEmpCode:" +genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode")+":");
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
......@@ -1579,5 +1779,45 @@ conn = getConnection();
}
return retString;
}
//Added by sarita on 19 JUN 18 to get store errorType and errCode in HashMap and Return [Start]
private HashMap<String,String> getErrorTypeVal(String retString)
{
HashMap<String,String> sh = new HashMap<String,String>();
Document dom = null;
NodeList parentNodeList = null,childNodeList = null;
Node childNode = null;
String errotType = "", errorCode = "";
try
{
dom = genericUtility.parseString(retString);
parentNodeList = dom.getElementsByTagName("Errors");
System.out.println("parentNodeList is ["+parentNodeList+"] \t length ["+parentNodeList.getLength()+"]");
for(int ctr = 0; ctr < parentNodeList.getLength(); ctr++)
{
childNodeList = parentNodeList.item(ctr).getChildNodes();
int childNodeListlen = childNodeList.getLength();
for(int ctrD = 0; ctrD < childNodeListlen ; ctrD++)
{
childNode = childNodeList.item(ctrD);
if("error".equalsIgnoreCase(childNode.getNodeName()))
{
errotType = childNode.getAttributes().getNamedItem("type").getNodeValue();
errorCode = childNode.getAttributes().getNamedItem("id").getNodeValue();
System.out.println("Post Save Status for Detail2["+errotType+"\t errorCode ["+errorCode+"]");
sh.put(errotType, errorCode);
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Error Inside Method [getErrorTypeVal] is "+e);
}
return sh;
}
//Added by sarita on 19 JUN 18 to get store errorType and errCode in HashMap and Return [End]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment