Suggested case list:
Using timer to refresh a grid
383guest172.69.33.12125nk0uiMay 7, 2020 7:23:47 AMlinkuser model to move item to another listbox
120guest162.158.193.148d0n3krApr 2, 2020 5:28:28 AMlinkDisabled list item row passed to VM-1981
296fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:44 PMlinkDisabled list item row passed to VM-1981
295fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:16 PMlinkDisabled list item row passed to VM-1981
294fatih123160.83.36.13225nk0uiFeb 13, 2018 3:30:44 PMlinkgrid sample with ListModel/RowRenderer
816guest80.82.2.1312vah9ajFeb 21, 2017 11:42:21 AMlinkgrid sample with ListModel/RowRenderer
809guest175.98.113.1622vah9ajJan 26, 2017 9:19:33 AMlinkgrid sample with ListModel/RowRenderer
196guest79.185.142.402vah9ajApr 26, 2014 10:53:57 PMlinkgrid sample with ListModel/RowRenderer
195guest79.185.142.402vah9ajApr 26, 2014 10:53:54 PMlinkgrid sample with ListModel/RowRenderer
194guest79.185.142.402vah9ajApr 26, 2014 10:53:51 PMlinkgrid sample with ListModel/RowRenderer
193guest79.185.142.402vah9ajApr 26, 2014 10:53:48 PMlinkgrid sample with ListModel/RowRenderer
192guest79.185.142.402vah9ajApr 26, 2014 10:53:44 PMlinkgrid sample with ListModel/RowRenderer
191guest79.185.142.402vah9ajApr 26, 2014 10:53:40 PMlinkHierarchy table without using ZK PE/EE
1aaknai151.28.135.2131s871daJul 29, 2013 11:02:46 PMlinkgrid sample with ListModel/RowRenderer
128aaknai151.28.135.2132vah9ajJul 29, 2013 7:20:00 PMlinkuser model to move item to another listbox
1TonyQ114.25.109.94d0n3krApr 21, 2012 10:43:27 AMlinkUsing timer to refresh a grid
1TonyQ220.133.44.3725nk0uiFeb 17, 2012 3:17:34 AMlinkFire a event from child iframe
1TonyQ220.133.44.372eupjotFeb 3, 2012 5:04:52 AMlinkTextbox input restriction sample
1TonyQ72.21.245.2431b3nlr0Dec 20, 2011 10:09:10 AMlinkTest web core taglib in ZUL
1TonyQ198.203.175.175ofqkemDec 17, 2011 3:36:08 AMlinkLatest 10 Fiddles :
constraint binding textbox
3guest172.68.151.16220peldaDec 5, 2025 5:08:19 PMlinkAnother new ZK fiddle
2guest172.68.151.16320peldaDec 5, 2025 5:07:51 PMlinkAnother new ZK fiddle
1guest172.68.151.16220peldaDec 5, 2025 5:07:32 PMlinkAnother new ZK fiddle
1peggypeng172.71.154.99364f4neDec 5, 2025 9:24:31 AMlinktooltip example
2guest104.22.23.13rc1ntoDec 4, 2025 2:23:45 PMlinkAnother new ZK fiddle
1guest172.69.134.2277t7602Dec 4, 2025 1:40:46 PMlinkAnother new ZK fiddle
1peggypeng104.22.17.1802df6e3oDec 4, 2025 8:41:29 AMlinkonClose
1peggypeng172.68.87.248j8kd8aDec 3, 2025 4:10:26 AMlinkAnother new ZK fiddle
1peggypeng172.69.134.2271rm7f4eNov 26, 2025 3:31:24 AMlinkZK-5912-Suggestion
2rebeccalai104.22.20.1442qrmiiuNov 26, 2025 2:07:15 AMlinkAnother new ZK fiddle
1guest162.158.22.1512bvensgOct 19, 2021 9:36:31 AMlinkresources
index.zulzul<?page id = "pdatapupld" title="Mandate Data Image Upload" contentType="text/html;charset=UTF-8"?>
<zk>
<window id = "wdataimgupld" apply="com.imageinfo.eclear.v2.webapp.ajax.controller.mandate_data_imgfile_upload" border="normal" sclass="expstyle1" xmlns:w="http://www.zkoss.org/2005/zk/client" width="100%" height="100%" contentStyle="overflow:auto">
<style>
.expstyle1 .z-window-modal-tl, .expstyle1 .z-window-modal-tr, .expstyle1 .z-window-modal-tm,
.expstyle1 .z-window-modal-cl, .expstyle1 .z-window-modal-cr, .expstyle1 .z-window-modal-cm,
.expstyle1 .z-window-modal-bl, .expstyle1 .z-window-modal-br, .expstyle1 .z-window-modal-bm,
.expstyle1 .z-window-modal-hl, .expstyle1 .z-window-modal-hr, .expstyle1 .z-window-modal-hm
{
background: #728C00;
}
.expstyle1 .z-window-modal-header
{
background: #728C00;
}
.expstyle1 .z-textbox
{
text-transform:uppercase;
}
</style>
<div id="divmain" visible = "true" align="center" width="100%" height="100%">
<div visible="true" id ="div1" align="center" width="100%" height="100%">
<grid id="grid1" width = "50%" align="center">
<columns>
<column width="40%"></column>
<column width="60%"></column>
</columns>
<rows>
<row id = "r3"><label value = "Flow Type"></label><combobox id = "flowtypecb" readonly = "true"></combobox></row>
<row id = "r5"><label value = "Mandate Type"></label><combobox id = "actiontypecb" readonly = "true"></combobox></row>
<row id = "r6"><label value = "Corporate Name"></label><combobox id = "corporatecb" ></combobox></row>
</rows>
</grid>
<hbox pack="end" height="30%" width="60%" >
<button id="next" label="Next" width="50px" mold="trendy"/>
</hbox>
</div>
<div visible="false" id ="uploaddiv" align="center" width="100%" height="100%">
<div align="center" width="70%" height="30%">
<grid id="grid2" width = "60%" align="center">
<columns>
<column width="50%"></column>
<column width="50%"></column>
</columns>
<rows>
<row><label value = "Corporate Name"></label><label id="corpnamelbl" ></label></row>
<row><label value = "Mandate Type"></label><label id="mandatetypelbl" ></label></row>
<row><label value = "Action"></label><hbox><button id="browse" label="Browse" visible="true" mold="trendy" upload="true,maxsize=-1,multiple=true,native"></button> <button id="parsePUPLD" label="Process" visible="true" mold="trendy" ></button> <button id="refreshbtn" label="Refresh" visible="true" mold="trendy" ></button></hbox></row>
</rows>
</grid>
<label id = "msg" ></label>
</div>
<div align="center" width="95%" height="100%">
<grid id="statusgrid" width = "100%" align="center">
<columns>
<column width="10%" label="S.No" ></column>
<column width="25%" label="File Name" ></column>
<column width="10%" label="Total Count" ></column>
<column width="10%" label="Accept Count" ></column>
<column width="10%" label="Reject Count" ></column>
<column width="20%" label="Status" ></column>
<column width="15%" label="Action" ></column>
</columns>
<rows id ="statusrows" >
</rows>
</grid>
<hbox id = "backhb" pack="end" width="80%" >
<button id="Back" label="Back" mold="trendy"/>
</hbox>
</div>
</div>
</div>
</window>
</zk>TestComposer.javajava
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.naming.InitialContext;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;
import org.apache.tika.Tika;
import org.zkoss.io.Files;
import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.KeyEvent;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Div;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Label;
import org.zkoss.zul.Row;
import org.zkoss.zul.Rows;
import org.zkoss.zul.Window;
import com.imageinfo.eclear.v2.utils.Globals;
import com.imageinfo.eclear.v2.utils.ImageViewer;
import com.imageinfo.eclear.v2.utils.JpgtoTiff;
import com.lowagie.text.Image;
@SuppressWarnings("rawtypes")
public class mandate_data_imgfile_upload extends GenericForwardComposer
{
private static final long serialVersionUID = 1L;
Window wdataimgupld;
Rows statusrows;
Row r6;
Row r5;
Row r3;
Label msg;
Label mandatetypelbl;
Label corpnamelbl;
Div uploaddiv;
Div divmain;
Div div1;
Combobox flowtypecb;
Combobox corporatecb;
Combobox actiontypecb;
Button refreshbtn;
Button parsePUPLD;
Button next;
Button browse;
Button Back;
HttpSession s;
String filename="",utilityname = "",actiontype,validutilitycode = "",filetype = "",filestype = "",sponsorifscode = "",curDate = "",client_code = "";
String file1[] =null;
String batchid ="";
int totalcount = 0;
int acceptedcount = 0;
int rejectedcount = 0;
String status;
LinkedHashMap<Integer, String> uploadedFile = new LinkedHashMap<Integer, String>();
LinkedHashMap<Integer, String> uploadedimage = new LinkedHashMap<Integer, String>();
LinkedHashMap<Integer, String> corporatetype = new LinkedHashMap<Integer, String>();
String _userno = "";
String _curdate = "";
String maxbatchsize = "25";
int maxfilerecordsize = 100;
String _lastdocno = "";
String _lastbatchid = "";
int totaltablecount = 0;
List<String> fields=new LinkedList<String>();
List<String> batchids=new LinkedList<String>();
ImageViewer iv = new ImageViewer();
Tika typeTika = new Tika();
String rejectionreason1="as";
double npcijpgSize = 0,npcitiffSize = 0;
LinkedHashMap<String, String> utilitymap = new LinkedHashMap<String, String>();
@SuppressWarnings("unchecked")
public void doAfterCompose(Component comp) throws Exception
{
super.doAfterCompose(comp);
s = (HttpSession)session.getNativeSession();
try{s.getAttribute("svalid").toString().toUpperCase();}catch (NullPointerException npe){Executions.sendRedirect("/invalid.zul");return;}
curDate = s.getAttribute("currentdate").toString();
actiontypecb.appendItem("CREATE");
actiontypecb.appendItem("AMEND");
actiontypecb.appendItem("CANCEL");
flowtypecb.appendItem("SPONSER");
flowtypecb.setSelectedIndex(0);
Connection conn = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
int i=0;
try
{
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
String sql = "select to_char(cur_date,'DDMMYYYY') as cur_date from tbl_eod_bod_stat";
pstmt1 = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
_curdate = rs1.getString("cur_date");
}
rs1.close();rs1=null;
pstmt1.close();pstmt1=null;
corporatecb.getChildren().clear();
utilitymap.clear();
corporatetype.clear();
sql = "select * from ( (select utility_code||'-'||utility_desc as account_name,utility_code,client_code,utility_desc from tbl_client_account_master where STATUS = 'E' and UTILITY_CODE in "+s.getAttribute("uilitycode")+" order by utility_code)a join (select distinct client_code from TBL_SPECDETAILS where data_type ='LINKED' and PRODUCT_NAME ='MMSOW') b on a.client_code = b.client_code)";
pstmt1 = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
//corporatecb.setDisabled(true);
//corporatecb.appendItem(rs1.getString("account_name"));
corporatecb.appendItem(rs1.getString("utility_desc"));
utilitymap.put(rs1.getString("utility_desc"), rs1.getString("utility_code")+"_"+rs1.getString("client_code"));
corporatetype.put(i, rs1.getString("account_name"));
i++;
}
rs1.close();rs1=null;
pstmt1.close();pstmt1=null;
}
catch (Exception e)
{
Globals.setLog(e);
}
finally{
try{if(rs1!=null){rs1.close();rs1 = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(pstmt1!=null){pstmt1.close();pstmt1 = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(conn!=null){conn.close();conn = null;}}catch (Exception fe){Globals.setLog(fe);}
}
//backhb.setVisible(false);
browse.addEventListener("onUpload",fileuploadevent);
// imgbrowse.addEventListener("onUpload",fileuploadevent);
next.addEventListener("onClick",nextevent);
next.addEventListener("onClick",nextevent);
parsePUPLD.addEventListener("onClick", parsePUPLDlistener);
parsePUPLD.addEventListener("onOK", parsePUPLDlistener);
Back.addEventListener("onClick",back);
Back.addEventListener("onOK",back);
refreshbtn.addEventListener("onOK",refreshevent);
refreshbtn.addEventListener("onClick",refreshevent);
_userno = Globals.paddingString((String)s.getAttribute("userno"), 5, "0", true);
r5.setVisible(true);
r6.setVisible(true);
r3.setVisible(true);
//showStatus();
}
public void clear()
{
msg.setValue("");
utilityname = "";
actiontype = "";
validutilitycode = "";
client_code = "";
filetype = "";
actiontypecb.setValue("");
corporatecb.setValue("");
uploadedFile.clear();
}
EventListener keylistener = new EventListener()
{
public void onEvent(Event event) throws Exception
{
if(event instanceof KeyEvent)
{
int k_code = ((KeyEvent)event).getKeyCode();
if(k_code == 85)//ALT+u/U
{
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","Do you want to upload files.Proceed?");
msgparams.put("defaultfocus","no");
Window win = (Window) Executions.createComponents("MessageBoxWithResponse.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
if(message_box_response.response.equalsIgnoreCase("yes"))
{
submitFile();
}
else
{
return;
}
}
else if(k_code == 66)//ALT+b/B
{
goBack();
}
}
}
};
EventListener refreshevent = new EventListener()
{
public void onEvent(Event arg0) throws Exception
{
if((arg0.getName().equalsIgnoreCase("onClick") || arg0.getName().equalsIgnoreCase("onOK")) && arg0.getTarget().getId().equalsIgnoreCase("refreshbtn"))
{
showStatus();
}
}
};
EventListener back = new EventListener()
{
public void onEvent(Event arg0) throws Exception
{
if((arg0.getName().equalsIgnoreCase("onClick") || arg0.getName().equalsIgnoreCase("onOK")))
{
goBack();
}
}
};
public void goBack()
{
uploaddiv.setVisible(false);
div1.setVisible(true);
filename = "";
actiontype = "";
actiontypecb.setValue("");
corporatecb.setValue("");
}
public void showStatus()
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
//clear();
msg.setValue("");
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
String sql = "SELECT FILE_NAME, APPLIED_RECORD, TOTAL_RECORD, NOT_APPLIED_RECORD, CASE WHEN FILE_STATUS IN ('0','9') THEN 'Processed' WHEN FILE_STATUS = '1' THEN 'Pending' END AS STATUS FROM TBL_IMPORT_FILE_DETAILS WHERE CUR_DATE = ? AND FILE_MODE = 'MANUAL' AND OTS_CODE = ? AND CLIENT_CODE = ? AND IMPORT_TYPE = 'MMSLINKED' ";
pstmt = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
pstmt.setString(1, (String) s.getAttribute("currentdate"));
pstmt.setString(2, utilitymap.get(corporatecb.getValue()).substring(0, utilitymap.get(corporatecb.getValue()).indexOf("_")));
pstmt.setString(3, utilitymap.get(corporatecb.getValue()).substring(utilitymap.get(corporatecb.getValue()).indexOf("_")+1));
rs = pstmt.executeQuery();
Row r;
Label lbl;
Button downloadbtn;
statusrows.getChildren().clear();
while(rs.next())
{
r = new Row();
r.setId("R|"+rs.getString("FILE_NAME"));
lbl = new Label();
lbl.setValue(""+rs.getRow());
lbl.setParent(r);
lbl = new Label();
lbl.setValue(rs.getString("FILE_NAME"));
lbl.setParent(r);
lbl = new Label();
lbl.setValue(rs.getString("TOTAL_RECORD"));
lbl.setParent(r);
lbl = new Label();
lbl.setValue(rs.getString("APPLIED_RECORD"));
lbl.setParent(r);
lbl = new Label();
lbl.setValue(rs.getString("NOT_APPLIED_RECORD"));
lbl.setParent(r);
lbl = new Label();
lbl.setValue(rs.getString("STATUS"));
lbl.setParent(r);
downloadbtn = new Button();
downloadbtn.setId(rs.getString("file_name"));
downloadbtn.setMold("trendy");
downloadbtn.setLabel("Download");
downloadbtn.addEventListener("onClick", downloadevent);
downloadbtn.setParent(r);
downloadbtn.setParent(r);
if("Processed".equalsIgnoreCase(rs.getString("STATUS")))
{
downloadbtn.setDisabled(false);
}
else
{
downloadbtn.setDisabled(true);
}
r.setParent(statusrows);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
}
catch (Exception e)
{
Globals.setLog(e);
}
finally{
try{if(rs!=null){rs.close();rs = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(pstmt!=null){pstmt.close();pstmt = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(conn!=null){conn.close();conn = null;}}catch (Exception fe){Globals.setLog(fe);}
}
}
EventListener downloadevent = new EventListener()
{
public void onEvent(Event event) throws Exception
{
fileDownload(event.getTarget().getId().toString());
}
};
EventListener nextevent = new EventListener()
{
public void onEvent(Event arg0) throws Exception
{
if((arg0.getName().equalsIgnoreCase("onClick")||arg0.getName().equalsIgnoreCase("onOk")) && arg0.getTarget().getId().equalsIgnoreCase("next"))
{
if(actiontypecb.getValue() == null || "".equals(actiontypecb.getValue()))
{
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","Please select Mandate type!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
else if(corporatecb.getValue() == null || "".equals(corporatecb.getValue()) || !Globals.validateComponentValues(corporatecb, corporatecb.getValue()) )
{
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","Please select Corporate Name!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
else
{
corpnamelbl.setValue(corporatecb.getValue());
mandatetypelbl.setValue(actiontypecb.getValue());
div1.setVisible(false);
uploaddiv.setVisible(true);
parsePUPLD.setDisabled(true);
batchid ="";
rejectionreason1="as";
actiontype = actiontypecb.getValue();
filetype = "ZIP";
if(!corporatecb.getValue().equalsIgnoreCase(""))
{
showStatus();
String utilcode = utilitymap.get(corporatecb.getValue());
validutilitycode = utilcode.substring(0, utilcode.indexOf("_"));
utilityname = corporatecb.getValue();
client_code = utilcode.substring(utilcode.indexOf("_")+1);
//validutilitycode = corporatecb.getValue().substring(0,corporatecb.getValue().indexOf("-"));
//utilityname = corporatecb.getValue().substring(corporatecb.getValue().indexOf("-")+1);
}
}
}
}
};
EventListener fileuploadevent = new EventListener()
{
public void onEvent(Event arg0) throws Exception
{
if(arg0.getName().equalsIgnoreCase("onUpload") && arg0.getTarget().getId().equalsIgnoreCase("browse"))
{
if(arg0 instanceof UploadEvent)
{
try
{
filename = "";
UploadEvent event=(UploadEvent) arg0;
Media m = event.getMedia();
boolean proceed = true;
filename = m.getName();
String msgstring = "";
if(!validateFileName(filetype,(m.isBinary()?m.getStreamData():null)))
{
proceed = false;
msgstring = "Not a valid file content type!";
}
if((((filename.length()-filename.replace(".", "").length())>1)))
{
proceed = false;
msgstring = "Not a valid file format having multiple extension!";
}
if(proceed)
{
if(!(m.getFormat().equalsIgnoreCase("zip")||m.getFormat().equalsIgnoreCase("xls")))
{
proceed = false;
msgstring = "Not a valid file format!";
}
}
if(proceed)
{
if(!(filename.endsWith("."+filetype)||filename.endsWith("."+filetype.toLowerCase())))
{
proceed = false;
msgstring = "Not a valid file type!";
}
}
if(proceed)
{
if(InsertFile(filename, m.getByteData()) == false)
{
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File already processed !");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
msg.setVisible(true);
msg.setValue("File already processed !");
return;
}
}
else
{
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring",msgstring);
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
msg.setVisible(true);
msg.setValue(msgstring);
return;
}
parsePUPLD.setDisabled(false);
msg.setValue("File Uploaded and Ready to Process");
}
catch (Exception e)
{
Globals.setLog(e);
}
}
}
}
};
public void fileDownload(String filename)
{
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try
{
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
ps = conn.prepareStatement("SELECT REJ_FILE_BLOB,REJ_FILE_NAME FROM TBL_IMPORT_FILE_DETAILS WHERE FILE_NAME = ? AND CUR_DATE = ?");
ps.setString(1, filename);
ps.setString(2, (String) s.getAttribute("currentdate"));
rs = ps.executeQuery();
if (rs.next())
{
Blob fileview = rs.getBlob("REJ_FILE_BLOB");
long flenbw = fileview.length();
byte[] fileblob = fileview.getBytes(1, (int) flenbw);
if (fileblob != null)
{
Filedownload.save(fileblob, "", rs.getString("REJ_FILE_NAME").substring(0,rs.getString("REJ_FILE_NAME").lastIndexOf(".")));
}
}
rs.close(); rs=null;
ps.close(); ps=null;
}
catch (Exception e)
{
Globals.setLog(e);
}
finally{
try{if(rs!=null){rs.close();rs = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(ps!=null){ps.close();ps = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(conn!=null){conn.close();conn = null;}}catch (Exception fe){Globals.setLog(fe);}
}
}
private boolean validateFileName(String filetype,InputStream stream)
{
boolean isValid = false;
String mimetype = "";
try
{
if(stream!=null)
{
try
{
mimetype = typeTika.detect(stream);
if(filetype.equalsIgnoreCase("ZIP")||filetype.equalsIgnoreCase("zip"))
{
if(mimetype.equalsIgnoreCase("application/zip"))
{
isValid = true;
}
else
{
isValid = false;
}
}
else
{
isValid = false;
}
}
catch(Exception e)
{
Globals.setLog(e);
isValid = false;
}
}
else
{
isValid = true;
}
}
catch(Exception e)
{
Globals.setLog(e);
isValid = false;
}
return isValid;
}
public boolean InsertFile(String insertfilename, byte [] fileBytes)
{
boolean ret = true;
Connection conn = null;
PreparedStatement pstmt2=null;
try
{
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
String q = "insert into tbl_import_file_details (FILE_NAME,TOTAL_RECORD,APPLIED_RECORD,NOT_APPLIED_RECORD,IMPORTER,IMPORTER_DATE,IMPORTER_IP_ADDRESS,FILE_STATUS,SERVER_IP,CUR_DATE,FILE_TYPE,OTS_CODE,OTS_NUMBER,OTS_INPATH,OTS_OUTPATH,IMPORT_TYPE,FILE_BLOB,FILE_MODE,CLIENT_CODE,UTILITY_NAME,ACTION_TYPE) values(?,?,?,?,?,systimestamp,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt2 = conn.prepareStatement(q, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pstmt2.setString(1, insertfilename);
pstmt2.setString(2, "0");
pstmt2.setString(3, "0");
pstmt2.setString(4, "0");
pstmt2.setString(5, (String)s.getAttribute("usern"));
pstmt2.setString(6, (String)s.getAttribute("ipaddress"));
pstmt2.setString(7, "2");
pstmt2.setString(8, (String)Executions.getCurrent().getLocalAddr());
pstmt2.setString(9, (String)s.getAttribute("currentdate"));
pstmt2.setString(10, filetype);
pstmt2.setString(11, validutilitycode);//utilitycode
pstmt2.setString(12, _userno);
pstmt2.setString(13, "");
pstmt2.setString(14, "");
pstmt2.setString(15, "MMSLINKED");
pstmt2.setBytes(16, fileBytes);
pstmt2.setString(17, "MANUAL");
pstmt2.setString(18, client_code);//client code
pstmt2.setString(19, utilityname);//utility name
pstmt2.setString(20, actiontypecb.getValue().toUpperCase());//action type
int insertedcount = pstmt2.executeUpdate();
//added on 20200319
if(insertedcount==0)
ret = false;
else
Globals.auditlogit_tran(filename, "BROWSE", "wdataimgupld", filename+" browsed for processing ", "MMS OUTWARD");
}
catch (Exception e){ Globals.setLog(e);ret = false;}
finally{try{if(pstmt2!=null){pstmt2.close();pstmt2 = null;}if(conn!=null){conn.close();conn=null;}}catch (Exception fe){Globals.setLog(fe);}}
return ret;
}
EventListener parsePUPLDlistener = new EventListener()
{
public void onEvent(Event arg0) throws Exception
{
if(arg0.getName().equalsIgnoreCase("onClick") || arg0.getName().equalsIgnoreCase("onOK") ||arg0.getTarget().getId().equalsIgnoreCase("parsePUPLD"))
{
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","Do you want to process file.Proceed?");
msgparams.put("defaultfocus","no");
Window win = (Window) Executions.createComponents("MessageBoxWithResponse.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
if(message_box_response.response.equalsIgnoreCase("yes"))
{
submitFile();
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File has been queued for processing !");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
parsePUPLD.setDisabled(true);
}
else
{
return;
}
}
}
};
public void submitFile()
{
/*
int recordcount=1;
totalcount = 0;
acceptedcount = 0;
rejectedcount = 0;
String ret = "";
parsePUPLD.setVisible(false);
msg.setVisible(true);
msg.setValue("Please wait. File is getting Uploaded ...");
div1.setVisible(true);
backhb.setVisible(true);
if(filetype.equalsIgnoreCase("ZIP") && (filename.endsWith("."+filetype)|filename.endsWith("."+filetype.toLowerCase())))
{
uploadedFile = unZipIt(uploadpath,filename,uploadpath);
setupdatebatch(true);
if(actiontype.equalsIgnoreCase("CANCEL"))
{
if(uploadedFile.size()>0 && uploadedFile.size()<=maxfilerecordsize)
{
totalcount = uploadedFile.size();
for(Map.Entry<Integer, String> datarow : uploadedFile.entrySet())
{
if(datarow.getValue().endsWith("TXT") || datarow.getValue().endsWith("txt"))
{
BufferedReader bufferedReader = null;
try
{
bufferedReader = new BufferedReader(new FileReader(uploadpath+datarow.getValue()));
int count = 0;
while(bufferedReader.readLine()!= null)
{
count++;
}
bufferedReader.close();bufferedReader = null;
if(count<=maxfilerecordsize)
{
totalcount = count;
bufferedReader = new BufferedReader(new FileReader(uploadpath+datarow.getValue()));
String line = "";
while((line = bufferedReader.readLine())!= null)
{
if(recordcount>Integer.parseInt(maxbatchsize))
{
recordcount=1;
setupdatebatch(true);
}
++recordcount;
try
{
//Globals.setLog("line:"+line);
// boolean uploaded = uploadDataxml(line,uploadpath+datarow.getValue());
//Globals.setLog("upload:"+uploaded);
if(uploaded)
{
acceptedcount++;
}
else
{
rejectedcount++;
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectedcount++;
}
}
}
else
{
ret = "File Record limit exceeded!";
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
Globals.setLog(e);
}
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectionreason1="ERROR : "+e.getMessage();
}
}
}
Globals.auditlogit_tran(filename,"Upload",wdataimgupld.getId(),"Mandate Data Image Uploaded With File : "+filename ,"MMS OUTWARD");
}
else if(uploadedFile.size()>maxfilerecordsize)
{
try
{
ret = "File Record limit exceeded!";
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
else if(uploadedFile.size()==0)
{
try
{
ret = "File is empty!";
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File is empty!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
}
else
{
if(uploadedFile.size()>0 && uploadedimage.size()>0 && uploadedFile.size()<=maxfilerecordsize)
{
totalcount = uploadedFile.size();
for(Map.Entry<Integer, String> datarow : uploadedFile.entrySet())
{
//Globals.setLog("name chk "+datarow.getValue());
if(datarow.getValue().endsWith("CSV") || datarow.getValue().endsWith("csv"))
{
BufferedReader bufferedReader = null;
try
{
bufferedReader = new BufferedReader(new FileReader(uploadpath+datarow.getValue()));
int count = 0;
while(bufferedReader.readLine()!= null)
{
count++;
}
bufferedReader.close();bufferedReader = null;
if(count<=maxfilerecordsize)
{
totalcount = count-1;
bufferedReader = new BufferedReader(new FileReader(uploadpath+datarow.getValue()));
String line = "";
while((line = bufferedReader.readLine())!= null)
{
try
{
if(recordcount>Integer.parseInt(maxbatchsize))
{
recordcount=1;
setupdatebatch(true);
}
++recordcount;
//Globals.setLog("line:"+line);
boolean uploaded = uploadData(line,uploadpath+datarow.getValue());
//Globals.setLog("upload:"+uploaded);
if(uploaded)
{
acceptedcount++;
}
else
{
rejectedcount++;
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectedcount++;
}
}
}
else
{
ret = "File Record limit exceeded!";
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectionreason1="ERROR : "+e.getMessage();
}
finally
{
if(bufferedReader!=null)
{
try
{
bufferedReader.close();
bufferedReader = null;
}
catch (IOException e)
{
Globals.setLog(e);
}
}
}
}
else if(datarow.getValue().endsWith("TXT") || datarow.getValue().endsWith("txt"))
{
BufferedReader bufferedReader = null;
try
{
bufferedReader = new BufferedReader(new FileReader(uploadpath+datarow.getValue()));
int count = 0;
while(bufferedReader.readLine()!= null)
{
count++;
}
bufferedReader.close();bufferedReader = null;
if(count<=maxfilerecordsize)
{
totalcount = count-1;
bufferedReader = new BufferedReader(new FileReader(uploadpath+datarow.getValue()));
String line = "";
while((line = bufferedReader.readLine())!= null)
{
try
{
if(recordcount>Integer.parseInt(maxbatchsize))
{
recordcount=1;
setupdatebatch(true);
}
++recordcount;
//Globals.setLog("line:"+line);
boolean uploaded = uploadDataxml(line,uploadpath+datarow.getValue());
//Globals.setLog("upload:"+uploaded);
if(uploaded)
{
acceptedcount++;
}
else
{
rejectedcount++;
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectedcount++;
}
}
}
else
{
ret = "File Record limit exceeded!";
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
Globals.setLog(e);
}
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectionreason1="ERROR : "+e.getMessage();
}
}
else if(datarow.getValue().endsWith("XLS") || datarow.getValue().endsWith("xls"))
{
InputStream ExcelFileToRead = null;
HSSFWorkbook wb = null;
BufferedReader bufferedReader = null;
try
{
ExcelFileToRead = new FileInputStream(uploadpath+datarow.getValue());
wb = new HSSFWorkbook(ExcelFileToRead);
HSSFSheet sheet = wb.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
if(rows<=maxfilerecordsize)
{
totalcount = rows-1;
for (int r = 1; r <=rows; r++)
{
try
{
if(recordcount>Integer.parseInt(maxbatchsize))
{
recordcount=1;
// setupdatebatch(true);
}
++recordcount;
HSSFRow row = sheet.getRow(r);
if (row == null)
{
continue;
}
boolean uploaded = uploadxls(row,uploadpath+datarow.getValue());
//Globals.setLog("upload:"+uploaded);
if(uploaded)
{
acceptedcount++;
}
else
{
rejectedcount++;
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectedcount++;
}
}
}
else
{
ret = "File Record limit exceeded!";
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectionreason1="ERROR : "+e.getMessage();
}
finally
{
if(bufferedReader!=null)
{
try
{
bufferedReader.close();
bufferedReader = null;
}
catch (IOException e)
{
Globals.setLog(e);
}
}
}
}
else if(datarow.getValue().endsWith("XLSX") || datarow.getValue().endsWith("xlsx"))
{
InputStream ExcelFileToRead = null;
XSSFWorkbook wb = null;
try
{
ExcelFileToRead = new FileInputStream(uploadpath+datarow.getValue());
wb = new XSSFWorkbook(ExcelFileToRead);
XSSFSheet sheet = wb.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
//Globals.setLog("size:"+rows);
if(rows<=maxfilerecordsize)
{
totalcount = rows-1;
//Globals.setLog("size:"+totalcount);
for (int r = 1; r <=rows; r++)
{
try
{
//Globals.setLog("coutn "+recordcount +" "+maxbatchsize);
if(recordcount>Integer.parseInt(maxbatchsize))
{
recordcount=1;
setupdatebatch(true);
}
++recordcount;
XSSFRow row = sheet.getRow(r);
if (row == null)
{
continue;
}
boolean uploaded = uploadxlsx(row,uploadpath+datarow.getValue());
//Globals.setLog("upload:"+uploaded);
if(uploaded)
{
acceptedcount++;
}
else
{
rejectedcount++;
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectedcount++;
}
}
}
else
{
ret = "File Record limit exceeded!";
try
{
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
}
catch(Exception e)
{
Globals.setLog(e);
rejectionreason1="ERROR : "+e.getMessage();
}
}
}
Globals.auditlogit_tran(filename,"Upload",wdataimgupld.getId(),"Mandate Data Image Uploaded With File : "+filename ,"MMS OUTWARD");
}
else if(uploadedFile.size()>maxfilerecordsize)
{
try
{
ret = "File Record limit exceeded!";
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File Record limit exceeded!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
else if(uploadedFile.size()==0)
{
try
{
ret = "File is empty!";
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","File is empty!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
else if((uploadedFile.size()>0 && uploadedimage.size()==0) || (uploadedFile.size()==0 && uploadedimage.size()>0))
{
try
{
ret = "Invalid File!";
HashMap<String, String> msgparams = new HashMap<String, String>();
msgparams.put("msgstring","Invalid File!");
Window win = (Window) Executions.createComponents("MessageBox.zul", null, msgparams);
win.doModal();
}
catch(Exception e)
{
}
}
}
}*/
Connection conn = null;
PreparedStatement pstmt2 = null;
try
{
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
String q = "update tbl_import_file_details set FILE_STATUS = '1' where FILE_NAME = ? AND CUR_DATE = ? AND FILE_TYPE = 'ZIP'";
pstmt2 = conn.prepareStatement(q, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pstmt2.setString(1, filename);
pstmt2.setString(2, (String)s.getAttribute("currentdate"));
pstmt2.executeUpdate();
//added on 20200319
Globals.auditlogit_tran(filename, "PARSE", "wdataimgupld", filename+" qued for processing ", "MMS OUTWARD");
}
catch (Exception e){Globals.setLog(e);}
finally{try{if(pstmt2!=null){pstmt2.close();pstmt2=null;}if(conn!=null){conn.close();conn = null;}}catch (Exception fe){Globals.setLog(fe);}}
showStatus();
}
public LinkedHashMap<Integer, String> unZipIt(String path,String zipFile,String outputFolder)
{
//Globals.setLog("not good 2 "+filestype);
String xmlFilename = "";
filestype="";
LinkedHashMap<Integer, String> ts = new LinkedHashMap<Integer,String>();
int i = 0;
int j=0;
byte[] buffer = new byte[16384];
Connection conn = null;
PreparedStatement ps1 = null;
PreparedStatement ps2 = null;
ResultSet rs=null;
try
{
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
ps1 = conn.prepareStatement("update tbl_import_file_details set file_status = ?,total_record = ? where file_name = ? and cur_date = ?",ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ps2 = conn.prepareStatement("select distinct file_type from TBL_SPECDETAILS where ACTIVE_STATUS = ? and PRODUCT_NAME=? and UTILITY_CODE= ? and LAYOUT_TYPE= ? and action_type=?",ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ps2.setString(1,"E");
ps2.setString(2,"MMSOW");
ps2.setString(3,validutilitycode);
ps2.setString(4,"Mandate");
ps2.setString(5,actiontype);
rs=ps2.executeQuery();
while(rs.next())
{
filestype+=rs.getString("file_type")+"|";
//Globals.setLog("type "+filestype);
}
rs.close();rs=null;
ps2.close();ps2=null;
String sp="N";
String s1;
String filename1 = null;
if(sp.equalsIgnoreCase("N"))
{
s1="mbulk";
if(actiontype.equalsIgnoreCase("CANCEL"))
{
s1="bulkcancel";
filename1=s1+"_"+_curdate;
}
else
{
s1="mbulk";
filename1=s1+"_"+actiontype+"_"+validutilitycode+"_"+_curdate;
}
}
else
{
if(actiontype.equalsIgnoreCase("CANCEL"))
{
s1="bulkcancel";
filename1=s1+"_"+_curdate;
}
else
{
s1="SC";
if(actiontype.equalsIgnoreCase("CREATE"))
{
filename1=s1+"_"+validutilitycode+"_"+_curdate;
}
else
{
filename1=s1+"_"+actiontype+"_"+validutilitycode+"_"+_curdate;
}
}
}
//Globals.setLog("chk "+filestype);
filestype=filestype.substring(0,filestype.length()-1);
file1=filestype.split("\\|");
ZipInputStream zis = new ZipInputStream(new FileInputStream(path+zipFile));
ZipEntry ze = zis.getNextEntry();
while(ze!=null)
{
String filenametemp = "";
String fileName = ze.getName();
try{filenametemp = fileName.substring(0,fileName.lastIndexOf("_"));}catch(Exception e){filenametemp = "";}
//Globals.setLog("temp "+filename1+"name "+filenametemp+"type "+filestype);
File newFile = new File(outputFolder + File.separator + fileName);
boolean flag=new File(newFile.getParent()).mkdirs();
Globals.setLog(""+flag);
FileOutputStream fos = null;
//Globals.setLog("name "+newFile.getName());
if(filename1.equalsIgnoreCase(filenametemp))
{
//Globals.setLog("name "+fileName);
for(int f = 0;f<file1.length;f++)
{
//Globals.setLog("type "+file1[f]);
//Globals.setLog("name "+newFile.getName());
if(newFile.getName().endsWith(file1[f]))
{
//Globals.setLog("yesssssss");
xmlFilename =newFile.getName();
ts.put(i,xmlFilename);
fos = new FileOutputStream(newFile);
i++;
}
}
}
if(newFile.getName().endsWith("tif")||newFile.getName().endsWith("tiff")||newFile.getName().endsWith("TIFF")||newFile.getName().endsWith("TIF"))
{
String file = newFile.getName().substring(0,newFile.getName().lastIndexOf("."))+".tif";
File newFile1 = new File(outputFolder + File.separator + file);
uploadedimage.put(j, file);
fos = new FileOutputStream(newFile1);
j++;
}
else if(newFile.getName().endsWith("jpg")||newFile.getName().endsWith("jpeg")||newFile.getName().endsWith("JPG")||newFile.getName().endsWith("JPEG"))
{
String file = newFile.getName().substring(0,newFile.getName().lastIndexOf("."))+".jpg";
File newFile1 = new File(outputFolder + File.separator + file);
uploadedimage.put(j, file);
fos = new FileOutputStream(newFile1);
j++;
}
int len;
while ((len = zis.read(buffer)) > 0)
{
if(fos!=null)
{
fos.write(buffer, 0, len);
}
}
if(fos!=null)
{
fos.close();
}
ze = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
ps1.setString(1,"1");
ps1.setString(2,String.valueOf(i));
ps1.setString(3,zipFile);
ps1.setString(4,(String)s.getAttribute("currentdate"));
ps1.executeUpdate();
}
catch(Exception ex)
{
ex.printStackTrace();
rejectionreason1="ERROR :"+ex.getMessage();
}
finally{try{if(ps1!=null){ps1.close();ps1 = null;}if(ps2!=null){ps2.close();ps2=null;}if(conn!=null){conn.close();conn = null;}}catch (Exception fe){Globals.setLog(fe);}}
return ts;
}
private void setupdatebatch(boolean updateBatchTotals)
{
int __lastdocno_fmuser = 0;
int __lastdocno_fmoutw = 0;
String sql = "";
Connection conn = null;
PreparedStatement pstmt5 = null;
ResultSet rs1 = null;
try
{
DataSource ds = (DataSource) new InitialContext(Globals.getICProps()).lookup(Globals.getDSlookup());
conn = ds.getConnection();
if(updateBatchTotals)
{
sql = "select usr_last_batch_id, usr_last_doc_no from tbl_user where upper(id) = ?";
pstmt5 = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
pstmt5.setString(1, ((String)s.getAttribute("usern")).toUpperCase());
rs1 = pstmt5.executeQuery();
if(rs1.next())
{
_lastbatchid = String.valueOf(rs1.getInt("usr_last_batch_id"));
//Globals.setLog("tablecnt "+totaltablecount+" max size "+maxbatchsize);
{
//Globals.setLog("batch 1");
_lastbatchid = String.valueOf(rs1.getInt("usr_last_batch_id")+1);
}
//Globals.setLog("batch id"+_lastbatchid);
__lastdocno_fmuser = rs1.getInt("usr_last_doc_no")+1;
}
//Globals.setLog("batch id"+__lastdocno_fmuser);
rs1.close();rs1=null;
pstmt5.close();pstmt5=null;
sql = "select max(substr(mandate_id,-9)) as usr_last_doc_no from tbl_out_dd_mandate where transaction_date = (select cur_date from tbl_eod_bod_stat) and creator = ?";
pstmt5 = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
pstmt5.setString(1, ((String)s.getAttribute("usern")).toUpperCase());
rs1 = pstmt5.executeQuery();
if(rs1.next())
{
__lastdocno_fmoutw = rs1.getInt("usr_last_doc_no")+1;
}
rs1.close();
pstmt5.close();
if(__lastdocno_fmoutw>__lastdocno_fmuser)
_lastdocno = String.valueOf(__lastdocno_fmoutw);
else
_lastdocno = String.valueOf(__lastdocno_fmuser);
//Globals.setLog("batch id"+__lastdocno_fmuser);
String sql1 = "";
if(updateBatchTotals)
{
sql1 = "insert into tbl_batch (CUR_DATE, BATCH_ID,ENTITY,STATUS,STATUS_TYPE,TOTAL_INSTRUMENT,TOTAL_AMOUNT,FLOW_TYPE,CREATOR_TIME,CREATOR,GROUP_ID) values (?,?,?,'0','0',?,?,?,(select systimestamp from dual),?,?) ";
pstmt5 = conn.prepareStatement(sql1,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pstmt5.setString(1,(String)s.getAttribute("currentdate"));
pstmt5.setString(2,_userno+"_"+_lastbatchid);
pstmt5.setString(3,(String)s.getAttribute("homebrentityid"));
pstmt5.setString(4,"0");
pstmt5.setString(5,"0");
pstmt5.setString(6,"");
pstmt5.setString(7,_userno);
pstmt5.setString(8,(String)s.getAttribute("groupid"));
pstmt5.executeUpdate();
pstmt5.close();
}
sql1 = "update tbl_user set usr_last_batch_id = ? where upper(id) = ? and ? > to_number(usr_last_batch_id)";
pstmt5 = conn.prepareStatement(sql1,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pstmt5.setString(1,_lastbatchid);
pstmt5.setString(2,((String)s.getAttribute("usern")).toUpperCase());
pstmt5.setString(3,Long.toString(Long.parseLong(_lastbatchid)));
pstmt5.executeUpdate();
pstmt5.close();
}
pstmt5.close();pstmt5=null;
}
catch (Exception e)
{
Globals.setLog(e);
}
finally{
try{if(rs1!=null){rs1.close();rs1 = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(pstmt5!=null){pstmt5.close();pstmt5 = null;}}catch (Exception fe){Globals.setLog(fe);}
try{if(conn!=null){conn.close();conn = null;}}catch (Exception fe){Globals.setLog(fe);}
}
}
public String paddingString( String s, int n, String c , boolean paddingLeft )
{
StringBuffer str = new StringBuffer(s);
int strLength = str.length();
if ( n > 0 && n > strLength )
{
for ( int i = 0; i <= n ; i ++ )
{
if ( paddingLeft )
{
if ( i < n - strLength ) str.insert( 0, c );
}
else
{
if ( i > strLength ) str.append( c );
}
}
}
return str.toString();
}
}