Commit 0b462335 authored by ssalve's avatar ssalve

Sarita : Done changes on 06FEB2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@179748 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 23c0c30c
......@@ -41,6 +41,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
public String globalXtraParams = "";
E12GenericUtility genericUtility = new E12GenericUtility();
DecimalFormat deciFormater = new DecimalFormat("0.00");
//Pattern pattern = Pattern.compile("[0-9].{2}");
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
......@@ -94,8 +95,12 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
String childNodeName = "",siteCode="",prdCode="";
//Added by sarita on 4JAN2018
Timestamp prdCodeCurrent=null , currDate = null;
double totalPer=0 ,crntPer=0;
double totalPer=0.0 ,crntPer=0.0;
String allocation = "",CurrentLineNo="",updateFlag="";
//Added by sarita on 06FEB2018
int allocNumber = 0;
int detlCnt1 = 0;
boolean result = true;
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
......@@ -323,33 +328,42 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
System.out.println("childNodeName::: for Case3"+childNodeName +"updateFlag :::"+updateFlag);
allocation = checkNull(genericUtility.getColumnValueFromNode("allocation",parentNode));
//allocation = checkNull(genericUtility.getColumnValue("allocation",dom2));
CurrentLineNo= checkNull(genericUtility.getColumnValueFromNode("line_no",parentNode));
System.out.println("Allocation Percentage Value is :::::["+allocation+"]" + "\t"+ "CurrentLineNo is :::"+CurrentLineNo);
int detlCnt1 = getNumOfNonDelDetail(dom2,3);
System.out.println("DETAIL COUNT" +detlCnt1);
//if(!("D".equalsIgnoreCase(updateFlag)) && allocation.trim().length()==0 || allocation == null)
//Added by sarita on 12JAN2018
if(detlCnt1 == 0)
//Added by sarita on 06FEB2018
detlCnt1 = getNumOfNonDelDetail(dom2,3);
System.out.println("DETAIL COUNT IS [[" +detlCnt1+"]]");
if(detlCnt1 == 0)
{
System.out.println("Delete count is 0");
errCode = "VTBLNKDTL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(!"D".equalsIgnoreCase(updateFlag))//Added by sarita on 11JAN2018
if(allocation != null && allocation.trim().length() > 0)
{
if(allocation == null || allocation.trim().length()==0)
{
System.out.println("inside alloc_perc LENGTH..");
errCode = "VMEMPQLF03";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
System.out.println("inside alloc_perc ");
try
{
crntPer = Double.parseDouble(allocation);
System.out.println("::crntPer::"+crntPer);
}
catch(Exception e)
{
System.out.println("Error::"+e);
errCode = "NOTANUMBR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
result = false;
}
}
if(result && (allocation != null && allocation.trim().length() > 0))
{
System.out.println("Allocation value is ["+allocation+"] Proper Number");
if("A".equalsIgnoreCase(updateFlag))//changes by sarita on 06FEB2018
{
System.out.println("inside alloc_perc ");
crntPer = Double.parseDouble(allocation);
System.out.println("crntPer :::::["+crntPer+"]");
//Added by sarita on 06NOV2017
......@@ -380,10 +394,20 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
else if(result && (allocation == null || allocation.trim().length()==0))//Added by sarita on 06FEB2018
{
System.out.println("Allocation Value is Null!!!!");
if(("A".equalsIgnoreCase(updateFlag)))
{
System.out.println("Allocation Value is null && result is true");
errCode = "VMEMPQLF03";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}//end of for loop
}
......@@ -434,6 +458,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
e.printStackTrace();
//Added by sarita on 15JAN2018
errStringXml.append("</Errors> </Root> \r\n");
throw new ITMException(e);//Added by sarita on 06FEB2018
}
finally
{
......@@ -521,8 +546,11 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
System.out.println("errStringXml .........."+errStringXml);
errString1 = "";
}
errStringXml.append("</Errors></Root>\r\n");
errStringXml.append("</Errors></Root>\r\n");
throw new ITMException(e);//Added by sarita on 06FEB2018
}
System.out.println("final retsting from ic["+errString+"]");
return errString;
}
......@@ -555,6 +583,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
}
catch(Exception e){
e.printStackTrace();
throw new ITMException(e);//Added by sarita on 06FEB2018
}
return returnStr;
}
......@@ -584,7 +613,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
Timestamp toDateTimestamp = null;
int domID=0,domIDDet =0;
String drcrFlagVal = "", allocdescr = "";
double allocation_perc=0,unitAllocation = 0;;
double allocation_perc=0,unitAllocation = 0;
boolean isresult = true;
int cnt=0;
double allocPercent=0;
try
......@@ -995,29 +1025,49 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
System.out.println("detailString value is DOM=="+genericUtility.serializeDom(dom));
domIDDet = Integer.parseInt(curDetail.getAttributes().getNamedItem("domID").getNodeValue());
System.out.println("domIDDet ["+domIDDet+"]");
totUnit = Double.parseDouble(genericUtility.getColumnValue("tot_units", dom));
allocation = genericUtility.getColumnValue("allocation", dom);
allocation = checkNull(genericUtility.getColumnValue("allocation", dom));
System.out.println("totUnit ["+totUnit+"]" + "\t"+ "allocation ["+allocation+"]");
//Added by sarita on 24JAN2018
if(allocation != null && allocation.trim().length() > 0)
{
allocation_perc = Double.parseDouble(genericUtility.getColumnValue("allocation", dom));
try
{
allocation_perc = Double.parseDouble(allocation);//Added by sarita on 06FEB2018
System.out.println("::allocation_perc in ITEMCHANGE FIELD::"+allocation_perc);
}
catch(Exception e)
{
System.out.println("Error::"+e);
isresult = false;
}
}
System.out.println("Value of totUnit :::: ["+totUnit+"]" + "allocation_perc :::: ["+allocation_perc+"]");
unitAllocation = setUnitAllocationValue(totUnit,allocation_perc);
accountCode = checkNull(genericUtility.getColumnValue("acct_code", dom));
System.out.println("allocation_perc ::::["+allocation_perc+"]" + "unitAllocation ::::["+unitAllocation+"]" + "accountCode ::::["+accountCode+"]" + "totUnit ::::: ["+totUnit+"]");
valueXmlString.append("<Detail3 domID='" + domIDDet + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\"/>\r\n");
valueXmlString.append("<selectbox>true</selectbox>\r\n");
valueXmlString.append("<unit_alloc><![CDATA[" ).append(unitAllocation).append( "]]></unit_alloc>\r\n" );
valueXmlString.append("</Detail3>\r\n");
}
if(isresult && (allocation != null && allocation.trim().length() > 0))
{
allocation_perc = Double.parseDouble(genericUtility.getColumnValue("allocation", dom));
System.out.println("Value of totUnit :::: ["+totUnit+"]" + "allocation_perc :::: ["+allocation_perc+"]");
unitAllocation = setUnitAllocationValue(totUnit,allocation_perc);
accountCode = checkNull(genericUtility.getColumnValue("acct_code", dom));
System.out.println("allocation_perc ::::["+allocation_perc+"]" + "unitAllocation ::::["+unitAllocation+"]" + "accountCode ::::["+accountCode+"]" + "totUnit ::::: ["+totUnit+"]");
valueXmlString.append("<Detail3 domID='" + domIDDet + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected='Y' updateFlag='Y' status=\"N\"/>\r\n");
valueXmlString.append("<selectbox>true</selectbox>\r\n");
valueXmlString.append("<allocation><![CDATA[" ).append(allocation_perc).append( "]]></allocation>\r\n" );
valueXmlString.append("<unit_alloc><![CDATA[" ).append(unitAllocation).append( "]]></unit_alloc>\r\n" );
valueXmlString.append("</Detail3>\r\n");
}
else if(isresult && (allocation == null || allocation.trim().length() == 0))
{
System.out.println("allocation if allocation value is null["+allocation+"]");
valueXmlString.append("<Detail3 domID='" + domIDDet + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected='Y' updateFlag='Y' status=\"N\"/>\r\n");
valueXmlString.append("<selectbox>true</selectbox>\r\n");
valueXmlString.append("<allocation><![CDATA[" ).append(allocation).append( "]]></allocation>\r\n" );
valueXmlString.append("<unit_alloc><![CDATA[" ).append(0.0).append( "]]></unit_alloc>\r\n" );
valueXmlString.append("</Detail3>\r\n");
}
}
break;
}
}
......@@ -1761,7 +1811,8 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
public double getNumOftotalallocPercentage(Document dom2,String CurrentLineNo) throws ITMException
{
String perAmt="",lineNo="",updateFlag = "";
double num=0;
double num=0.0,linenum=0.0;
boolean checkPerAmt = true;
System.out.println("Inside getXmlDocument method!!!!!!!!!!!!!!");
try
{
......@@ -1782,11 +1833,23 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
perAmt= pNode.getElementsByTagName("allocation").item(0).getFirstChild().getNodeValue();
lineNo = pNode.getElementsByTagName("line_no").item(0).getFirstChild().getNodeValue();
System.out.println("[If update flag is not D ]perAmt ::"+perAmt + "\t" + "lineNo ::"+lineNo +"update Flag ::"+updateFlag);
if(!lineNo.equalsIgnoreCase(CurrentLineNo.trim()))
if(!lineNo.equalsIgnoreCase(CurrentLineNo.trim()))//Added by sarita on 06FEB2018
{
try
{
linenum = Double.parseDouble(perAmt);
}
catch(Exception e)
{
System.out.println(e);
checkPerAmt = false;
}
if(checkPerAmt)
{
num += Double.parseDouble(perAmt);
System.out.println("num is ==="+num);
}
}
}
}
}
......@@ -1848,12 +1911,16 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
}//end of method getResourceBasVal
//Added by sarita on 06NOV2017
//public String getAttributeVal(Node dom2, String attribName )throws ITMException
public String getAttributeVal(Node dom, String attribName )throws ITMException
{
System.out.println("Inside getAttributeVal method is !!!!!!!!!!!!!!");
String AttribValue = null;
try
{
NodeList detailList = dom.getChildNodes();
//NodeList detailList = dom2.getChildNodes();
NodeList detailList = dom.getChildNodes();
System.out.println("Details NodeList is ====["+detailList+"]" + "Length is ======"+detailList.getLength());
int detListLength = detailList.getLength();
for(int ctr = 0; ctr < detListLength; ctr++)
{
......@@ -1861,6 +1928,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
if(curDetail.getNodeName().equals("attribute"))
{
AttribValue = curDetail.getAttributes().getNamedItem(attribName).getNodeValue();
System.out.println("Attribute Value is =====["+AttribValue+"]");
break;
}
else
......@@ -1877,7 +1945,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
return AttribValue;
}
//Added by sarita on 6NOV2017
public int getNumOfNonDelDetail(Document dom2,int detailNo)
public int getNumOfNonDelDetail(Document dom2,int detailNo) throws ITMException
{
Node childNode = null;
NodeList updateList;
......@@ -1897,23 +1965,27 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
childNodeName = pNode.getNodeName();
//System.out.println("pNode::["+pNode+"]"+"cNodeList::["+cNodeList+"]");
updateFlag = getAttributeVal(pNode,"updateFlag");
System.out.println("updateFlag [" + updateFlag + "]");
if(!updateFlag.equalsIgnoreCase("D"))
System.out.println("Before updateFlag counter is ===["+cntr+"]"+"\t"+"updateFlag [" + updateFlag + "]");
//if(!updateFlag.equalsIgnoreCase("D"))
if("A".equalsIgnoreCase(updateFlag))//changes by sarita on 06FEB2018
{
cntr++;
}
System.out.println("Counter is ==="+cntr);
System.out.println("After updateFlag counter is ===["+cntr+"]"+"\t"+"updateFlag [" + updateFlag + "]");
//System.out.println("Counter is ==="+cntr);
}
}
catch(Exception e)
{
System.out.println("Exception : : getNumOfNonDelDetail :"+e);
e.printStackTrace();
throw new ITMException(e);
}
return cntr;
}
//Added by sarita on 15JAN2018
public String getUpdateFlag(Document dom2,int detailNo)
public String getUpdateFlag(Document dom2,int detailNo) throws ITMException
{
String updateFlag="";
Node childNode = null;
......@@ -1938,10 +2010,29 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
{
System.out.println("Exception : : getNumOfNonDelDetail :"+e);
e.printStackTrace();
throw new ITMException(e);
}
return updateFlag;
}
//Added by sarita on 06FEB2018
public boolean getDataAlloc(String allocation)
{
boolean resultActNum = false;
double allocNumber = 0.0;
try
{
allocNumber = Double.parseDouble(allocation);
}
catch(NumberFormatException e)
{
System.out.println(e);
resultActNum = true;
}
System.out.println("resultActNum:::"+resultActNum);
return resultActNum;
}
}//end of class CostCtrAllocIC
......
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