Commit e56debe3 by TongZuu

init CSCFrameWork4

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/dwr.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/CrystalClear.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/dynamicjava.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/j2ee.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/jdom.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/jtds-1.0.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/poi-2.5-final-20040302.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/LDAP/ldapjclnt10.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/Programmer/myHRAppServer/webapps/OEI/hrAppWeb.war/WEB-INF/lib/jasperreports-1.3.4modified.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/log4j.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/Programmer/myHRAppServer/webapps/OEI/hrAppWeb.war/WEB-INF/lib/CscFileUtils.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/ojdbc5.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/jar/commons/commons-lang-2.3.jar" sourcepath="D:/EnterprisePT/jar/commons/src/commons-lang-2.3-sources.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/Programmer/myHRAppServer/webapps/OEI/hrAppWeb.war/WEB-INF/lib/UTBean.jar"/>
<classpathentry kind="lib" path="D:/EnterprisePT/Programmer/myHRAppServer/webapps/OEI/hrAppWeb.war/WEB-INF/lib/CscMenu.jar"/>
<classpathentry kind="output" path=""/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CSCFrameWorkV4_DEV_beforeMerge</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Fri Jul 01 00:48:33 ICT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
Manifest-Version: 1.0
/*
* Created on 13 àÁ.Â. 2550
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.csc.entity;
import com.csc.library.session.RecordCmp0;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class CSC_Log extends RecordCmp0 {
public CSC_Log(){
super("csc_log","csc_log Table");
}
}
/*
* Created on 2 .. 2550
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.csc.entity;
import com.csc.library.session.RecordCmp0;
/**
* @author Administrator
*/
public class CSC_Processtrack extends RecordCmp0 {
private static final long serialVersionUID = 1L;
public CSC_Processtrack(){
super("csc_processtrack","csc_processtrack Table");
}
}
/*
* Created on 7 .. 2550
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.csc.entity;
import com.csc.library.database.MyInquiry;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.utilities.UProfile;
/**
* @author DrAgOnFiRe
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class CSC_QuqueInq extends MyInquiry {
public void setUProfile(UProfile uPro) {
try{
super.setUProfile(uPro);
InitialEnvironment inv = new InitialEnvironment("GLOBAL");
String[] db =inv.getValue("DBLIST-name").split(",");
this.databaseName = db[0];
}catch(Exception ex){
ex.printStackTrace();
}
}
}
package com.csc.entity;
import com.csc.library.entity.MyRemote;
public interface DataBMP extends MyRemote{
public void remove() throws Exception;
public void update(boolean afterSave)throws Exception;
}
package com.csc.entity;
import com.csc.library.utilities.UProfile;
public interface DataBMPHome {
public DataBMP create(DataBMPKey key)throws Exception ;
public DataBMP findByPrimaryKey(DataBMPKey key)throws Exception ;
public void setUProfile(UProfile upf)throws Exception ;
}
package com.csc.entity;
import com.csc.library.session.DbRecord;
public class DataBMPKey {
private DbRecord db;
public DataBMPKey() {
}
public void setKey(DbRecord db) {
this.db=db;
}
public DbRecord getDbRecord() {
return this.db;
}
}
package com.csc.library.authorize.ui;
import java.util.HashMap;
import com.csc.library.security.UIAuthenImp;
import com.csc.library.utilities.UProfile;
public class UIAuthen implements UIAuthenImp {
protected UProfile uprofile = null;
protected HashMap param = new HashMap();
public boolean authen() {
return false;
}
public HashMap getParam(HashMap param) {
return this.param;
}
public UProfile getUProfile(UProfile up) {
return uprofile;
}
public void setParam(HashMap param) {
this.param = param;
}
public void setUProfile(UProfile up) {
this.uprofile = up;
}
}
package com.csc.library.autonumber;
import java.rmi.RemoteException;
import java.util.HashMap;
/*
* Created on 9 ÁÔ.Â. 2548
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author NoVaViVa
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public interface AbstractAutoNumber {
public void setUprofile(Object uf) throws RemoteException;
public HashMap getUprofile() throws RemoteException;
public int getNextRecord() throws RemoteException;
public int getMaxRecord() throws RemoteException;
public String getNumber() throws RemoteException;
}
/*
* Created on 19 .. 2548
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.csc.library.autonumber;
import java.rmi.RemoteException;
import com.csc.library.autonumber.AbstractAutoNumber;
import com.csc.library.session.DbRecord;
import com.csc.library.utilities.UProfile;
/**
* @author NoVaViVa
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class InitialAutoNumber {
public InitialAutoNumber() {
}
public static synchronized String getAutoNumber(UProfile uf,String autonumCode) {
AbstractAutoNumber aauto = new MyAutoNumber(uf,autonumCode);
String res = null;
try {
res = aauto.getNumber();
} catch (RemoteException e) {
e.printStackTrace();
}
return res;
}
public static synchronized String getAutoNumber(UProfile uf,String autonumCode,String format) {
AbstractAutoNumber aauto = new MyAutoNumber(uf,autonumCode,format);
String res = null;
try {
res = aauto.getNumber();
} catch (RemoteException e) {
e.printStackTrace();
}
return res;
}
public static synchronized String getAutoNumber(UProfile uf,String autonumCode,String format,DbRecord parent,String initvalue) {
int init=0;
if(initvalue.trim().length()>0)
init=Integer.parseInt(initvalue);
AbstractAutoNumber aauto = new MyAutoNumber(uf,autonumCode,format,parent,init);
String res = null;
try {
synchronized (aauto){
res = aauto.getNumber();
}
} catch (RemoteException e) {
e.printStackTrace();
}
return res;
}
public static synchronized String getAutoNumber(UProfile uf,String autonumCode,String format,DbRecord parent,String initvalue,String res1,String res2) {
int init=0;
if(initvalue.trim().length()>0)
init=Integer.parseInt(initvalue);
AbstractAutoNumber aauto = new MyAutoNumber(uf,autonumCode,format,parent,init,res1,res2);
String res = null;
try {
synchronized (aauto){
res = aauto.getNumber();
}
} catch (RemoteException e) {
e.printStackTrace();
}
return res;
}
}
package com.csc.library.components;
public class Button extends MyTag {
private static final long serialVersionUID = 1L;
String src = "", tagInput = "";
public Button() {}
public Button(ComponentManager cm) {
super(cm);
this.setonClick(cm.getProperty("onclick"));
this.setSrc(cm.getProperty("src"));
}
public void setSrc(String img) {
this.src = " SRC=\"" + img + "\"";
}
public void ini() {
this.tagInput =
" <INPUT TYPE="
+ this.type.toUpperCase()
+ " Name='"
+ this.name
+ "'"
+ " VALUE='"
+ this.value
+ "'"
+ ((this.disable.equalsIgnoreCase("true")) ? " DISABLED" : "")
+ " onClick=\""
+ onClick
+ "\""
+ this.src
+ " onMouseOver=\""
+ this.onMouseOver
+ "\""
+ " onMouseOut=\""
+ this.onMouseOut
+ "\""
+ ">";
}
public String process() {
this.ini();
return this.tagInput;
}
public String getInput() {
this.ini();
return this.tagInput;
}
public void setSpace(int space) {}
}
package com.csc.library.components;
public class Calendar extends Text {
private static final long serialVersionUID = 1L;
public Calendar() {
this.type = "calendar";
}
public Calendar(ComponentManager cm) {
super(cm);
this.setSize("10");
this.setMax("10");
this.setDir(cm.getProperty("dir"));
if(cm.getProperty("onKeyUp")==null || cm.getProperty("onKeyUp").length()==0)
this.setonKeyup("formatDate(this);");
if(cm.getProperty("onBlur")==null || cm.getProperty("onBlur").length()==0)
this.setonBlur("chkInputDate(this);");
if(cm.getProperty("onKeyPress")==null || cm.getProperty("onKeyPress").length()==0)
this.setonKeyPress("chkInteger();");
this.ini();
}
public void ini() {
super.ini();
String linkcalendar="<a href=\"javascript:;\" onMouseOut=\"MM_swapImgRestore()\"" +
"onMouseOver=\"MM_swapImage('Image12','','../IMAGES/BUTTON/SWAP/CALENDAR_SWAP20.gif',1)\">\n" +
"<img src=\"../IMAGES/BUTTON/MAIN/CALENDAR20.gif\" alt=\"Calendar\" name=\"Image12\" width=\"20\" " +
"border=\"0\" align=\"absmiddle\" id=\"Image12\" onClick=\"viewCal('"
+this.name+"')\"></a>";
tagInput +=linkcalendar;
}
}
package com.csc.library.components;
public class CheckBox extends MyTag {
private static final long serialVersionUID = 1L;
String charsize = "";
String maxsize = "";
String tagInput = "";
String hspace = "";
String checked = "";
public CheckBox() {
this.type = "checkbox";
}
public CheckBox(ComponentManager cm) {
super(cm);
this.setChecked(cm.getProperty("checked"));
this.ini();
}
public void ini() {
String label2 = "", check = "";
if ((this.help != null) && (this.help.length() > 0)) {
label2 = "help";
label2 = this.tagHelp(this.help, this.name, label2);
}
if ((this.checked != null) && (this.checked.equals(this.value))) {
check = "CHECKED";
}
this.tagInput =
" <INPUT TYPE='"
+ this.type
+ "'"
+ " Name='"
+ this.name
+ "box"
+ "'"
+ " VALUE='"
+ this.checked
+ "' "
+ ((this.disable.equalsIgnoreCase("true")) ? " DISABLED" : "")
+ check
+ " onClick=\"javascript:unCheckBox('"
+ this.name
+ "','"
+ this.checked
+ "')\""
+ " onMouseOver=\""
+ this.onMouseOver
+ "\""
+ " onMouseOut=\""
+ this.onMouseOut
+ "\">"
+ label2;
}
public String process() {
this.ini();
if ((this.point != null) && (this.point.equalsIgnoreCase("l"))) {
return this.tagInput + this.hspace + this.label;
} else {
return this.label + this.hspace + this.tagInput;
}
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
hspace = hspace + "&nbsp;";
}
}
public String getInput() {
return this.tagInput;
}
public void setChecked(String check) {
this.checked = check;
}
}
package com.csc.library.components;
import com.csc.library.utilities.MyLog;
public class Component {
TagManager genTag;
ComponentManager cm;
public String getInput() {
return this.genTag.getInput();
}
public void setSpace(int space) {
this.genTag.setSpace(space);
}
public String getUI() {
return this.genTag.process();
}
public String getLabel() {
return this.genTag.getLabel();
}
public void process(ComponentManager cm) {
String comtype =cm.getComType();
if (("password").equalsIgnoreCase(comtype)) {
genTag = new Password(cm);
} else if (("label").equalsIgnoreCase(comtype)) {
Label label1 = new Label(cm);
label1.setLabel(cm.getProperty("value"));
genTag = (TagManager) label1;
} else if (("text").equalsIgnoreCase(comtype)) {
genTag = new Text(cm);
} else if (("radio").equalsIgnoreCase(comtype)) {
genTag = new Radio(cm);
} else if (("checkbox").equalsIgnoreCase(comtype)) {
genTag = new CheckBox(cm);
} else if (("menu").equalsIgnoreCase(comtype)) {
genTag = new Menu(cm);
} else if (("list").equalsIgnoreCase(comtype)) {
genTag = new ListBox(cm);
} else if (("textarea").equalsIgnoreCase(comtype)) {
genTag = new Textarea(cm);
} else if (("hidden").equalsIgnoreCase(comtype)) {
genTag = new Hidden(cm);
} else if (("tel").equalsIgnoreCase(comtype)) {
genTag = new Tel(cm);
} else if (("mobile").equalsIgnoreCase(comtype)) {
genTag = new Mobile(cm);
} else if (("calendar").equalsIgnoreCase(comtype)) {
genTag = new Calendar(cm);
} else if (("fileupload").equalsIgnoreCase(comtype)) {
genTag = new Fileupload(cm);
} else {
MyLog.warn(this, "Component type not found");
}
} // process
public TagManager getTag() {
return genTag;
}
} // component
package com.csc.library.components;
import java.io.Serializable;
import com.csc.library.database.ComponentField;
import com.csc.library.utilities.UProfile;
public interface ComponentManager extends Serializable {
public String getName();
public String getString();
public String getStringWidth(); //getWidth
public String getStringDecimal(); //getWidth
public String getProperty(String code);
public UProfile getUProfile();
public String getDataFormat();
public String getDescription();
public String getDescriptionThai();
public String getDescriptionEng();
public boolean getHELP_RETURN_FIELD();
public String getComType();
public String getAlt();
public String getAltEng();
public String getAltThai();
public String getHelp();
public char isKey();
public String getDefault();
public String getStringHTML();
public ComponentField getComponentField();
public char getLang();
public boolean isRead();
public boolean isEdit();
}
package com.csc.library.components;
import org.apache.commons.lang.StringUtils;
import com.csc.library.database.FieldManager;
import com.csc.library.download.FileDownloadUtils2;
import com.csc.library.utilities.MyLog;
/**
*
* Fileupload Ѻ upload
* <br />
* <h5>How ho use</h5>
* <pre>
* &lt;PICTURE lang=&quot;A&quot; encrypt=&quot;false&quot; log=&quot;false&quot; type=&quot;String&quot;&gt;
* &lt;WIDTH&gt;30&lt;/WIDTH&gt;
* &lt;DESC_ENG&gt;Picture&lt;/DESC_ENG&gt;
* &lt;DESC_THAI&gt;ٻҾ&lt;/DESC_THAI&gt;
* &lt;COMPONENT type=&quot;fileupload&quot;&gt;
* &lt;SIZE&gt;20&lt;/SIZE&gt;
* &lt;ALT_ENG&gt;Picture&lt;/ALT_ENG&gt;
* &lt;ALT_THAI&gt;ٻҾ&lt;/ALT_THAI&gt;
* &lt;READONLY&gt;true&lt;/READONLY&gt;
* &lt;DISPLAY_LINK&gt;0&lt;/DISPLAY_LINK&gt;
* &lt;/COMPONENT&gt;
* &lt;/PICTURE&gt;
*</pre>
*
* @version 2
*
* @author James
*
* @require <ul>
* <li><a href="http://commons.apache.org/lang/">Apache Commons Lang</a></li>
* <li>CscFileUtils</li>
* </ul>
*
*/
public class Fileupload extends MyTag {
private static final long serialVersionUID = -6417325453936606241L;
private String tagInput = "";
private String hspace = "";
protected String uploadButton = "";
protected String deleteButton = "";
protected String downloadLink = "";
protected String uploadField;
protected String displayLink = "1";
public Fileupload() {
this.type = "fileupload";
}
public Fileupload(ComponentManager cm) {
super(cm);
this.ini();
}
public void ini() {
setProperties();
genUploadButton();
genDeleteButton();
if( !"0".equalsIgnoreCase(displayLink) ) {
genDownloadLink();
}
// generate inputbox
StringBuilder html = new StringBuilder();
html.append("<input type=\"hidden\" ");
html.append("name=\"").append( name ).append("\" ");
html.append("componenttype=\"").append( "fileupload" ).append("\" ");
html.append("value=\"").append( value ).append("\" ");
html.append(" />");
html.append( this.uploadButton );
html.append( this.hspace );
html.append( deleteButton );
html.append( this.hspace ).append("&nbsp;&nbsp;");
html.append(downloadLink);
tagInput = html.toString();
}
public String process() {
ini();
return tagInput;
}
public String getInput() {
return tagInput;
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
this.hspace = this.hspace + "&nbsp;";
}
}
private void genUploadButton() {
StringBuilder html = new StringBuilder();
html.append("<a href=\"javascript:;\" onClick=\"uploadFile('").append( uploadField ).append("'");
html.append(", '").append( name ).append("'");
html.append(")\" >");
html.append("<img id=\"").append(name).append("_upload\" src=\"../IMAGES/BUTTON/MAIN/UPOAD20.gif\" ");
html.append("width=\"20\" height=\"20\" border=\"0\" alt=\"Insert Picture\"></a>");
uploadButton= html.toString();
}
private void genDeleteButton() {
StringBuilder html = new StringBuilder();
html.append("<a href=\"javascript:;\" onClick=\"deleteFile('").append( uploadField ).append("'");
html.append(", '").append( name ).append("'");
html.append(", '").append( value ).append("'");
html.append(")\" >");
html.append("<img id=\"").append(name).append("_delete\" src=\"../IMAGES/BUTTON/MAIN/DEL20.gif\" ");
html.append("width=\"20\" height=\"20\" border=\"0\" alt=\"Delete Picture\"></a>");
deleteButton = html.toString();
}
private void genDownloadLink() {
if(StringUtils.isNotBlank(value)) {
StringBuilder buffer = new StringBuilder();
buffer.append("<a id=\"").append(name).append("_link\" class=\"downloadLink\" href=\"");
FileDownloadUtils2 utils = new FileDownloadUtils2();
utils.setUploadField(uploadField);
utils.setFilename(value);
buffer.append(utils.getDownloadUrl());
buffer.append("\" >").append(value).append("</a>");
downloadLink = buffer.toString();
}
}
private void setProperties() {
try {
FieldManager fm = (FieldManager)com;
uploadField = fm.getParent().getTableName() +"." +fm.getName();
String _displayLink = com.getProperty("displaylink");
this.displayLink = StringUtils.trimToEmpty(_displayLink);
} catch (Exception e) {
MyLog.error(this, e);
}
}
}
package com.csc.library.components;
public class Hidden extends MyTag {
private static final long serialVersionUID = 1L;
private String tagInput = "";
public Hidden() {
this.type = "hidden";
this.ini();
}
public Hidden(ComponentManager cm) {
super(cm);
this.ini();
}
public void ini() {
tagInput = "<input type=\"" + "hidden" + "\" name=\"" + this.name + "\" value=\"" + this.value + "\">";
}
public String process() {
this.ini();
return this.tagInput;
}
public String getInput() {
return this.tagInput;
}
public void setSpace(int space) {}
}
\ No newline at end of file
package com.csc.library.components;
public class Label extends MyTag {
private static final long serialVersionUID = -974853324071143386L;
public Label() {}
public Label(ComponentManager cm) {
super(cm);
}
public String process() {
String label1 = this.label;
return label1;
}
public String getLabel() {
return this.process();
}
public String getInput() {
return this.process();
}
public void setLabel(String lable) {
if (this.key) {
this.label = "<label class=\"key\"><b>" + lable + "</b></label>";
} else if( this.require != null && !("").equalsIgnoreCase(this.require) ) {
this.label = "<label>" +lable + "<span class=\"require\">" +this.require +"</span></label>";
} else {
this.label = "<label>" +lable +"</label>";
}
}
public void setSpace(int space) {}
}
package com.csc.library.components;
import com.csc.library.utilities.ThaiUtilities;
/**
* <strong>Edit 2008/09/15 by James </strong><br />
* <p>
* - option ҧ listbox 㹡óշҧҨҡ systemcode <br/>
* default false
* <p><ul><u>ҹ</u>
* <li> <code>&lt;BLANKOPTION&gt; true&lt;/BLANKOPTION&gt;</code> protable
* ǹͧ component ͧŴ</li>
* <li> setBlank</li>
* </ul>
* </p>
* <blockquote><u>ŷ</u><br />&lt;select name='com_name' size='1'&gt;<br />&lt;option value=''&gt; &lt;/option&gt;<br />
* ...<br />...<br />&lt;/select&gt;</blockquote>
* </p>
*/
public class ListBox extends MyTag {
private static final long serialVersionUID = 1L;
static final String BLANK_OPTION = "<option value=\"\"> </option>";
String tagInput = "";
String hspace = "";
String checked = "";
String sizel = "";
String multiple = "";
boolean blank = false;
public ListBox() {
this.type = "list";
}
public ListBox(ComponentManager cm) {
super(cm);
this.setValidCode(cm.getProperty("validCode"));
this.setMultiple(cm.getProperty("multiple"));
this.setSizel(cm.getProperty("sizel"));
this.setTable(cm.getProperty("table"));
if(!cm.getString().trim().equals("")){
this.setChecked(cm.getString().trim());
} else {
this.setChecked(cm.getProperty("defaultvalue").trim());
}
String blankOpt = cm.getProperty("blankoption");
if(blankOpt !=null && "true".equalsIgnoreCase(blankOpt)) {
setBlank(true);
}
this.ini();
}
/**
* Edit by : james <br/>
* Edit date: 2008-09-12 <br/>
* tag options ҧ 1 ѹ <br/>
* <code>&lt;option value=&quot;&quot;&gt; &lt;/option&gt;<code>
*/
public void ini() {
ThaiUtilities ethai = new ThaiUtilities();
String label2;
String tmpV;
String tmpL="";
//String input2 = "";
tagInput = label2 = "";
StringBuilder tag = new StringBuilder();
StringBuilder options = new StringBuilder();
if (sysCode != null) {
if( blank && useValidCode) {
options.append(BLANK_OPTION);
}
for (int point = 0; point < sysCode.length; point++) {
tmpV = sysCode[point][0];
if((sysCode[point][1]==null)){
break;
}
tmpL = this.spilltLang(sysCode[point][1]);
// edit ͵ͧʴ
tmpL = ethai.ASCII2Unicode(tmpL);
if ((tmpV != null) && (tmpL != null) && (!tmpV.equals("")) && (!tmpL.equals("")) && (!tmpV.equals("null"))) {
options.append("<option ");
options.append(" value=\"").append(tmpV).append("\" ");
if ((this.checked != null) && (this.checked.equalsIgnoreCase(tmpV))) {
options.append("selected");
}
options.append(" >");
options.append(tmpL).append("</option>");
}
}
tag.append("<select name=\"").append(this.name).append("\" ");
tag.append("size=\"").append(this.sizel).append("\" ");
if("true".equalsIgnoreCase(this.disable)) {
tag.append(" disabled ");
}
if( this.onClick != null && !this.onClick.equals("") ){
tag.append("onClick=\"").append( this.onClick ).append("\" ");
}
if( this.onChange != null && !this.onChange.equals("") ){
tag.append("onChange=\"").append( this.onChange ).append("sysIsEdit();").append("\" ");
}
if( this.onBlur != null && !this.onBlur.equals("") ){
tag.append("onBlur=\"").append( this.onBlur ).append("\" ");
}
if( this.onKeyUp != null && !this.onKeyUp.equals("") ){
tag.append("onKeyUp=\"").append( this.onKeyUp ).append("\" ");
}
if( this.onMouseOver!= null && !this.onMouseOver.equals("") ){
tag.append("onMouseOver=\"").append( this.onMouseOver ).append("\" ");
}
if( this.onMouseOut != null && !this.onMouseOut.equals("") ){
tag.append("onMouseOut=\"").append( this.onMouseOut ).append("\" ");
}
if( com != null && com.getDescription() != null && com.getDescription().equals("")){
tag.append("alt=\"").append( com.getDescription()).append("\" ");
}
tag.append(multiple);
tag.append(" >");
tag.append(options.toString());
tag.append("</select>").append(label2);
this.tagInput = tag.toString();
}
}
public String process() {
this.ini();
if ((this.point != null) && (this.point.equalsIgnoreCase("l"))) {
return this.tagInput + this.hspace + this.label;
} else {
return this.label + this.hspace + this.tagInput;
}
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
hspace = hspace + "&nbsp;";
}
}
public void setSelect(String[][] code) {
sysCode = code;
}
public void setSelect(String value, String label) {
int i = 0;
if (this.sysCode.length != 0) {
i = this.sysCode.length;
}
sysCode[i][0] = value;
sysCode[i][1] = label;
}
public String getInput() {
return this.tagInput;
}
public void setChecked(String check) {
this.checked = check;
}
public void setSizel(String sizel) {
this.sizel = sizel;
}
public void setMultiple(String multiple) {
this.multiple = multiple;
}
public void setBlank(boolean blank){
this.blank = blank;
}
}
package com.csc.library.components;
public class Menu extends MyTag {
private static final long serialVersionUID = 1L;
String tagInput = "", hspace = "", checked = "";
public Menu() {
super();
this.type = "menu";
}
/**
* <p><b>BALL Edit</b>
* <p> this.setTable(cm.getProperty("table"));
* @param cm
* @param labelFont
* @param inputFont
*/
public Menu(ComponentManager cm) {
super(cm);
this.setValidCode(cm.getProperty("validCode"));
this.setTable(cm.getProperty("table"));
if(!cm.getProperty("value").trim().equals(""))
this.setChecked(cm.getProperty("value").trim());
else
this.setChecked(cm.getProperty("defaultvalue").trim());
this.ini();
}
public void setSelect(String[][] code) {
sysCode = code;
}
public void ini() {
String label2, tmpV, tmpL, input2 = "", check;
tagInput = label2 = "";
if ((this.help != null) && (this.help.length() > 0)) {
label2 = "help";
label2 = this.tagHelp(this.help, this.name, label2);
}
if (sysCode != null) {
for (int point = 0; point < sysCode.length; point++) {
tmpV = sysCode[point][0];
/***********Ball Edit 11-03-05***************/
if((sysCode[point][1]==null))break;
tmpL = this.spilltLang(sysCode[point][1]);
//System.out.println("lang "+this.uPro.get("lang")+" Menu tmpL ="+tmpL);
/**************************/
if ((tmpV == null) && (tmpL == null)) {
break;
}
check = "";
// this.logger.info(this.name+" checked="+checked+" tmpV="+tmpV);
if ((this.checked != null) && (this.checked.equalsIgnoreCase(tmpV))) {
check = "SELECTED";
}
input2 = input2 + " <OPTION " + check + " VALUE=\"" + tmpV + "\"> " + tmpL + " </OPTION>";
}
this.tagInput =
"<SELECT NAME=\""
+ this.name
+ "\" onChange=\""
+ onClick
+ "\" onMouseOver=\""
+ this.onMouseOver
+ "\" onMouseOut=\""
+ this.onMouseOut
+ "\" > "
+ input2
+ " </SELECT> "
+ label2;
}
}
public String process() {
this.ini();
if ((this.point != null) && (this.point.equalsIgnoreCase("l"))) {
return this.tagInput + this.hspace + this.label;
} else {
return this.label + this.hspace + this.tagInput;
}
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
hspace = hspace + "&nbsp;";
}
}
public void setSelect(String value, String label) {
int i = this.sysCode.length;
sysCode[i][0] = value;
sysCode[i][1] = label;
}
public String getInput() {
return this.tagInput;
}
public void setChecked(String check) {
this.checked = check;
}
}
package com.csc.library.components;
public class Mobile extends Text {
private static final long serialVersionUID = 1L;
public Mobile() {
this.type = "mobile";
}
public Mobile(ComponentManager cm) {
super(cm);
this.setSize(cm.getProperty("size"));
this.setMax(cm.getProperty("maxsize"));
this.setDir(cm.getProperty("dir"));
//
this.setonKeyPress("chkInputNumPhone();");
this.ini();
}
public void ini() {
// move for dwr
//this.setonBlur("chkMobilePhone(this,"+this.name+");");
String xValue = this.value;
// if(xValue.length()>2)xValue=xValue.substring(2);
tagInput =
"<INPUT TYPE='"
+ "TEXT"
+ "'"
+ " Name='"
+ this.name
+ "'"
+ " SIZE='"
+ this.charsize
+ "'"
+ " MAXLENGTH='"
+ this.maxsize
+ "'"
+ " VALUE='"
+ xValue
+ "'"
+ ((this.disable.equalsIgnoreCase("true")) ? " DISABLED" : "")
+" "
+ ((this.readonly.equalsIgnoreCase("true")) ? " READONLY " : "")
+ " onClick=\""
+ onClick
+ "\""
+ " onChange=\""
+ onChange+"sysIsEdit();"
+ "\""
+ " onMouseOver=\""
+ this.onMouseOver
+ "\""
+ " onMouseOut=\""
+ this.onMouseOut
+ "\""
+ " onKeyPress=\""
+ this.onKeyPress
+ "\""
+ " onKeyUp=\""
+ this.onKeyUp
+ "\""
+ " dir=\""+dir+"\""
+ " onBlur=\""+this.onBlur+"\""
+" onFocus=\""+this.onFocus+"\""
+" alt=\""+((com!=null)?com.getAlt():"")+"\""
+ " >";
}
}
package com.csc.library.components;
public class Password extends Text {
private static final long serialVersionUID = 1L;
public Password(ComponentManager cm) {
super(cm);
}
public Password() {
this.type = "password";
}
}
package com.csc.library.components;
import org.apache.commons.lang.StringUtils;
public class Radio extends MyTag {
private static final long serialVersionUID = 1L;
private String tagInput = "";
private String hspace = "";
private String checked = "";
private String br = "\n";
public Radio() {
this.type = "radio";
}
public Radio(ComponentManager cm) {
super(cm);
if(StringUtils.isNotBlank(cm.getString())) {
this.setChecked(cm.getString());
} else {
this.setChecked(cm.getProperty("defaultvalue"));
}
this.setValidCode(cm.getProperty("validCode"));
this.setBR(cm.getProperty("br"));
this.ini();
}
public void ini() {
// edit by james 24-06-2008
String tmpV, tmpL;
StringBuilder html = new StringBuilder();
if (sysCode != null) {
for (String code[]: sysCode) {
tmpV = code[0];
if((code[1] == null)) {
break;
}
tmpL = this.spilltLang(code[1]);
html.append("<label>");
html.append("<input type=\"").append(this.type).append("\" ");
html.append("name=\"").append(this.name).append("\" ");
html.append("value=\"").append( tmpV ).append("\" ");
if ((this.checked != null) && (this.checked.equalsIgnoreCase(tmpV))) {
html.append("checked=\"checked\" ");
}
if( this.disable != null && this.disable.equalsIgnoreCase("true") ){
html.append("disabled=\"disabled\" ");
}
if( this.onMouseOver!= null && !this.onMouseOver.equals("") ){
html.append("onMouseOver=\"").append( this.onMouseOver ).append("\" ");
}
if( this.onMouseOut != null && !this.onMouseOut.equals("") ){
html.append("onMouseOut=\"").append( this.onMouseOut ).append("\" ");
}
if( this.onClick != null && !this.onClick.equals("") ){
html.append("onClick=\"").append( this.onClick ).append("\" ");
}
if( this.onChange != null && !this.onChange.equals("") ){
html.append("onChange=\"").append( this.onChange ).append("sysIsEdit();").append("\" ");
}
if( this.onBlur != null && !this.onBlur.equals("") ){
html.append("onBlur=\"").append( this.onBlur ).append("\" ");
}
if( com != null && com.getAlt() != null && com.getAlt().equals("")){
html.append("alt=\"").append( com.getAlt()).append("\" ");
}
html.append(" />").append(this.hspace).append( tmpL ).append("</label>&nbsp;").append(br);
}
}
this.tagInput = html.toString();
}
public String process() {
this.ini();
return this.tagInput;
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
hspace = hspace + "&nbsp;";
}
}
public void setRadio(String value, String label) {
int i = this.sysCode.length;
sysCode[i][0] = value;
sysCode[i][1] = label;
}
public String getInput() {
return this.tagInput;
}
public void setChecked(String check) {
this.checked = StringUtils.trim(check);
}
public void setValue(String val) {
this.value = StringUtils.trim(val);
}
public void setBR(String br){
if(!("").equalsIgnoreCase(br) && !("false").equalsIgnoreCase(br)){
this.br = "<br />";
}
}
}
package com.csc.library.components;
public interface TagManager {
public String process();
public String getLabel();
public String getInput();
public void setSpace(int space);
public void setName(String Name);
public void ini();
}
package com.csc.library.components;
public class Tel extends Text {
private static final long serialVersionUID = 1L;
public Tel() {
this.type = "tel";
}
public Tel(ComponentManager cm) {
super(cm);
if (cm.getProperty("size").equals("")) {
this.setSize(cm.getStringWidth());
} else {
this.setSize(cm.getProperty("size"));
}
this.setMax(cm.getProperty("maxsize"));
this.setDir(cm.getProperty("dir"));
this.onKeyPress = "chkInputNumPhone(event);" + this.onKeyPress;
this.ini();
}
public void ini() {
String label2;
label2 = "<input type=\"hidden\""
+ " name=\"" + this.name + "\""
+ " value=\"" + this.value + "\"" + " alt=\""
+ ((com != null) ? com.getAlt() : "") + "\"" + " >";
ListBox lbox = new ListBox();
lbox.setUProfile(this.uPro);
lbox.setLabel("TelArea");
if (this.name.substring(0, 2).equals("__"))
lbox.setName(this.name.substring(2) + "area");
else
lbox.setName(this.name + "area");
this.onBlur = "chkHomePhone(" + this.name + "area" + "," + this.name
+ "_view," + this.name + ");";
lbox.setValidCode("TELAREA");
lbox.setonChange("chkHomePhone(this," + this.name + "_view,"
+ this.name + ");");
String xValue = this.value;
if (this.value.indexOf("02") == 0) {
lbox.setChecked("02");
xValue = xValue.substring(2);
} else {
if ((!this.value.equals("")) && (this.value.charAt(0) == '#')) {
if (xValue.length() > 1)
xValue = xValue.substring(1);
lbox.setChecked("#");
} else if (this.value.length() > 3) {
if (xValue.length() > 3)
xValue = xValue.substring(3);
lbox.setChecked(this.value.substring(0, 3));
}
}
lbox.ini();
tagInput = lbox.getInput()
+ " <input type=\"text\" "
+ " name=\""
+ this.name
+ "_view\""
+ " size=\""
+ this.charsize
+ "\"" // 9 ѡ => 02 9999999 099 999999
+ " maxlength=\""
+ this.maxsize
+ "\""
+ " value=\""
+ xValue
+ "\""
+ ((this.disable.equalsIgnoreCase("true")) ? " disabled" : "")
+ ((this.readonly.equalsIgnoreCase("true")) ? " readonly " : "")
+ " onClick=\"" + onClick + "\"" + " onChange=\"" + onChange
+ "sysIsEdit();" + "\"" + " onMouseOver=\"" + this.onMouseOver
+ "\"" + " onMouseOut=\"" + this.onMouseOut + "\""
+ " onKeyPress=\"" + this.onKeyPress + "\"" + " onKeyUp=\""
+ this.onKeyUp + "\"" + " dir=\"" + dir + "\"" + " onBlur=\""
+ this.onBlur + "\"" + " onFocus=\"" + this.onFocus + "\""
+ " alt=\"" + ((com != null) ? com.getAlt() : "") + "\""
+ " >" + label2;
}
}
package com.csc.library.components;
import java.util.StringTokenizer;
import com.csc.library.database.FieldAutoNumber;
import com.csc.library.database.FieldBigDecimal;
import com.csc.library.database.FieldDate;
import com.csc.library.database.FieldDouble;
import com.csc.library.database.FieldFloat;
import com.csc.library.database.FieldInteger;
import com.csc.library.database.FieldTime;
import com.csc.library.utilities.CscCalendar;
public class Text extends MyTag {
private static final long serialVersionUID = 1L;
String charsize = "";
String maxsize = "";
String tagInput = "";
String hspace = "";
String dir = "";
private boolean autonumber = false;
public Text() {
this.type = "text";
}
public Text(ComponentManager cm) {
super(cm);
if (cm.getProperty("size").equals("")) {
this.setSize(cm.getStringWidth());
} else {
this.setSize(cm.getProperty("size"));
}
this.setMax(cm.getProperty("maxsize"));
this.setDir(cm.getProperty("dir"));
if (cm.getProperty("dir") != null && !cm.getProperty("dir").equals("")) {
dir = "rtl";
}
if (cm instanceof FieldDate) {
if (this.value.equalsIgnoreCase("01-01-1900")){//||this.value.equalsIgnoreCase("31-12-2100")) {
if (cm.getProperty("default").equalsIgnoreCase("new")) {
this.value = new CscCalendar().getDDMMYYYY();
} else {
this.value = "";
}
}
if (this.onKeyUp.equals("") && this.onBlur.equals("") && this.onKeyPress.equals("")) {
this.setonKeyup("formatDate(this);");
this.setonBlur("chkInputDate(this);");
this.setonKeyPress("chkIntegerOfDate(this.value,event);");
this.setToolTip(cm.getAlt() + "(DDMMYYYY)");
}
this.setMax("10");
} else if ((cm instanceof FieldFloat) || (cm instanceof FieldDouble) || (cm instanceof FieldBigDecimal)) {
if (this.onKeyUp.equals("") && this.onBlur.equals("") && this.onKeyPress.equals("") && this.onFocus.equals("")) {
this.setonKeyup("checkComma(this,2);");
this.setonBlur("checkNumFloat(this,0,900000000);");
this.setonKeyPress("checkWordNumber(this.value,event);");
this.setonFocus("callDelComma(this);");
}
dir = "";
this.setCSS("numeric");
} else if (cm instanceof FieldTime) {
if (this.onKeyUp.equals("")) {
this.setonKeyup("isValidTime(this.value);");
}
} else if (cm instanceof FieldInteger) {
if (this.onBlur.equals("") && this.onKeyPress.equals("") && this.onFocus.equals("")) {
this.setonBlur("checkNumInt(this,0,900000000);");
this.setonKeyPress("chkInteger(event);");
this.setonFocus("callDelComma(this);");
}
dir = "";
this.setCSS("numeric");
} else if( cm instanceof FieldAutoNumber) {
autonumber = true;
} else {
if (cm.getProperty("isvalid").equals("") || cm.getProperty("isvalid").equals("true") || this.key) { //edit by pas óշ key ͧ ѡþ java script function chkSpecialStr
this.onBlur = "trimValue(this);" + this.onBlur;
if(this.key){
this.onKeyPress = "chkSpecialKey(event);" + this.onKeyPress;
}else{
this.onKeyPress = "chkSpecialStr(event);" + this.onKeyPress;
}
}
}
if (this.onFocus.equals("")) {
this.onFocus = "this.select();";
}
if ((cm.getLang() == 'E') || (cm.getLang() == 'e')) {
this.onKeyPress = "chkNotThaiChaOnly(event);" + this.onKeyPress;
}
this.ini();
if (this.maxsize.length() < 1)
this.maxsize = this.charsize;
if ((this.help != null) && (this.help.length() > 0)) {
if ((cm instanceof FieldFloat) || (cm instanceof FieldDouble) || (cm instanceof FieldBigDecimal) || (cm instanceof FieldInteger)) {
if (this.value.equals("")) {
this.setValue("0");
}
} else {
if (this.value.equals("")) {
this.setValue("NONE");
}
}
}
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
hspace = hspace + "&nbsp;";
}
}
public void ini() {
String label2;
label2 = "";
// this.logger.info("text help "+this.help+" "+this.help.length());
if ((this.help != null) && (this.help.length() > 0)) {
label2 = "help";
label2 = this.tagHelp(this.help, this.name, label2);
}
/*
tagInput =
"<INPUT TYPE='"
+ this.type
+ "'"
+ " Name='"
+ this.name
+ "'"
+ " SIZE='"
+ this.charsize
+ "'"
+ " MAXLENGTH='"
+ this.maxsize
+ "'"
+ " VALUE='"
+ this.value
+ "'"
+ ((this.disable.equalsIgnoreCase("true")) ? " DISABLED" : "")
+" "
+ ((this.readonly.equalsIgnoreCase("true")) ? " READONLY " : "")
+ " onClick=\""
+ onClick
+ "\""
+ " onChange=\""
+ onChange
+ "\""
+ " onMouseOver=\""
+ this.onMouseOver
+ "\""
+ " onMouseOut=\""
+ this.onMouseOut
+ "\""
+ " onKeyPress=\""
+ this.onKeyPress
+ "\""
+ " onKeyUp=\""
+ "sysIsEdit();" + this.onKeyUp
+ "\""
+ " dir=\""+dir+"\""
+ " onBlur=\""+this.onBlur+"\""
+" onFocus=\""+this.onFocus+"\""
+" class=\""+this.css+"\""
+" alt=\""+((com!=null)?com.getAlt():"")+"\""
+ " >"
+ label2;
*/
StringBuilder tag = new StringBuilder();
tag.append("<input type=\"").append(type).append("\" ");
tag.append("name=\"").append( name ).append("\" ");
tag.append("size=\"").append( charsize ).append("\" ");
tag.append("maxlength=\"").append( maxsize ).append("\" ");
tag.append("value=\"").append( value ).append("\" ");
if(autonumber) {
tag.append("autonumber ");
}
if("true".equalsIgnoreCase( disable )) {
tag.append("disabled ");
}
if("true".equalsIgnoreCase( readonly )) {
tag.append("readonly ");
}
if( !"".equalsIgnoreCase( css )) {
tag.append("class=\"").append( css ).append("\" ");
}
if( !"".equalsIgnoreCase( onClick )) {
tag.append("onclick=\"").append( onClick ).append("\" ");
}
if( !"".equalsIgnoreCase( onChange )) {
tag.append("onchange=\"").append( onChange ).append("\" ");
}
if( !"".equalsIgnoreCase( onKeyPress )) {
tag.append("onkeypress=\"").append( onKeyPress ).append("\" ");
}
if( !"".equalsIgnoreCase( onKeyUp )) {
tag.append("onkeyup=\"sysIsEdit();").append( onKeyUp ).append("\" ");
}else{
tag.append("onkeyup=\"sysIsEdit();").append("\" ");
}
if( !"".equalsIgnoreCase( onBlur )) {
tag.append("onblur=\"").append( onBlur ).append("\" ");
}
if( !"".equalsIgnoreCase( onFocus )) {
tag.append("onfocus=\"").append( onFocus ).append("\" ");
}
if( !"".equalsIgnoreCase( dir )) {
tag.append("dir=\"").append( dir ).append("\" ");
}
if( com != null ) {
tag.append("alt=\"").append( com.getAlt() ).append("\" ");
}
if( !"".equalsIgnoreCase( onMouseOver )) {
tag.append("onmousemver=\"").append( onMouseOver ).append("\" ");
}
if( !"".equalsIgnoreCase( onMouseOut )) {
tag.append("onmouseout=\"").append( onMouseOut ).append("\" ");
}
tag.append(" />");
tag.append( label2 );
tagInput = tag.toString();
}
public void setDir(String type) {
if ((type.equalsIgnoreCase("BigDecimal")) || (type.equalsIgnoreCase("Double")) || (type.equalsIgnoreCase("Integer")) || (type.equalsIgnoreCase("Float"))) {
dir = "rtl";
}
}
public void setSize(String size) {
this.charsize = size;
}
public void setMax(String max) {
this.maxsize = max;
}
public String process() {
this.ini();
if ((this.point != null) && (this.point.equalsIgnoreCase("l"))) {
return this.tagInput + this.hspace + this.label;
} else {
return this.label + this.hspace + this.tagInput;
}
}
public String getInput() {
return this.tagInput;
}
public void setonKeyPress(String script) {
if ((script.indexOf(";") < 0) && (script.indexOf("()") > 0)) {
script = script.substring(0, script.length() - 1) + "event)";
} else {
String temp = "";
String temp1 = "";
StringTokenizer token = new StringTokenizer(script, ";");
while (token.hasMoreTokens()) {
temp = token.nextToken();
if (temp.indexOf("()") > 0) {
temp1 += temp.substring(0, temp.length() - 1) + "event)";
} else {
if (temp.substring(temp.indexOf("(")).toLowerCase()
.indexOf("event") < 0) {
temp1 += temp.substring(0, temp.length() - 1)
+ ",event)";
} else {
temp1 += temp;
}
}
temp1 += ";";
}
script = temp1;
}
this.onKeyPress = script;
}
}
package com.csc.library.components;
public class Textarea extends MyTag {
private static final long serialVersionUID = 1L;
private String lines = "";
private String sizechar = "";
private String wrap = "";
private String tagInput = "";
private String hspace = "";
public Textarea() {
this.type = "textarea";
}
public Textarea(ComponentManager cm) {
super(cm);
if(cm.getProperty("size").equals("")) {
this.setSize(cm.getStringWidth());
} else {
this.setSize(cm.getProperty("size"));
}
this.setSizeChar(cm.getProperty("sizechar"));
this.setLines(cm.getProperty("lines"));
this.setWrap(cm.getProperty("wrap"));
if(this.onKeyUp.equals("")){
this.setonKeyup("chkLimitTextArea(this,"+cm.getStringWidth()+");");
}
if(cm.getProperty("isvalid").equals("")||cm.getProperty("isvalid").equals("true")){
this.onBlur = "trimValue(this);"+this.onBlur;
this.onKeyPress="chkSpecialStr(event);"+this.onKeyPress;
}
if((cm.getLang() == 'E')||(cm.getLang()== 'e' )){
this.onKeyPress = "chkNotThaiChaOnly(event);" +this.onKeyPress;
}
this.ini();
}
public void setLines(String lines) {
this.lines = lines;
}
public void setSizeChar(String sizechar) {
this.sizechar = sizechar;
}
public void setWrap(String wrap) {
this.wrap = wrap;
}
public void ini() {
String label2;
label2 = "";
tagInput =
"<TEXTAREA NAME='"
+ this.name
+ "'"
+ " COLS='"
+ this.sizechar
+ "'"
+ " ROWS='"
+ this.lines
+ "'"
+ " WRAP='"
+ this.wrap
+ "'"
+ " onClick=\""
+ onClick
+ "\""
+ " onChange=\""
+ onChange
+ "\""
+ " onMouseOver=\""
+ this.onMouseOver
+ "\""
+ " onMouseOut=\""
+ this.onMouseOut
+ "\""
+ " onKeyPress=\""
+ this.onKeyPress
+ "\""
+ " onKeyUp=\""
+ this.onKeyUp+"sysIsEdit();"
+ "\""
+ " onBlur=\""+this.onBlur+"\""
+" onFocus=\""+this.onFocus+"\""
+ ((this.disable.equalsIgnoreCase("true")) ? " DISABLED" : "")
+ ((this.readonly.equalsIgnoreCase("true")) ? " READONLY" : "")
+" alt=\""+((com!=null)?com.getAlt():"")+"\""
+" >" + this.value + "</TEXTAREA>" + label2;
}
public String process() {
this.ini();
if ((this.point != null) && (this.point.equalsIgnoreCase("l"))) {
return this.tagInput + this.hspace + this.label;
} else {
return this.label + this.hspace + this.tagInput;
}
}
public void setSpace(int space) {
for (int i = 0; i < space; i++) {
hspace = hspace + "&nbsp;";
}
}
public String getInput() {
return this.tagInput;
}
private void setSize(String size) {
this.sizechar = size;
}
}
\ No newline at end of file
package com.csc.library.config;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.session.InitialInquiry;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ThaiUtilities;
import com.csc.library.utilities.UProfile;
public class LoadConfig {
private UProfile upf=null;
Element str;
public LoadConfig(){
this.upf = new UProfile();
this.upf.setDefault();
try {
InitialEnvironment env = new InitialEnvironment("GLOBAL");
SAXBuilder builder = new SAXBuilder();
String pathName="";
pathName=env.getValue("config-dir") +"MCONFIG.xml";
File configxml=new File(pathName);
if(!configxml.exists()){
createConfigXML(pathName);
}else{
Document stru = builder.build(new File(pathName));
str = stru.getRootElement();
this.process();
}
} catch (Exception ex) {
MyLog.error(this, this.upf, ex);
}
}
private void process(){
String key = this.str.getAttributeValue("key");
try {
DbRecord db = new InitialRecord(this.upf).getDbRecord("Mconfig");
db.setColumn("*");
Element data;
List list = str.getChildren();
Iterator it = list.iterator();
while (it.hasNext()) {
data = (Element) it.next();
String fm="";
for (StringTokenizer token = new StringTokenizer(key, ","); token.hasMoreTokens();) {
fm = token.nextToken();
db.set(fm, data.getChildTextTrim(fm.toUpperCase()));
} // Set Key for Search
if(db.search()<1){ // If, Not Found, Save it
List sub_list =data.getChildren();
Iterator sub_it = sub_list.iterator();
Element fm_data;
while (sub_it.hasNext()) {
fm_data = (Element) sub_it.next();
db.set(fm_data.getName(), fm_data.getText());
}
db.save();
}
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void createConfigXML(String pathName){
try {
System.out.println("\tCREATE MCONFIG FILE..");
File configxml = new File(pathName);
OutputStream out = new BufferedOutputStream(new FileOutputStream(configxml));
PrintWriter writer = new PrintWriter(out);
writer.println("<?xml version=\"1.0\" encoding=\"TIS-620\"?>");
writer.println("<MCONFIG key=\"configid\">");
DbInquiry configinq=new InitialInquiry(this.upf).getDbInquiry();
configinq.initMyTable("mconfig","","");
configinq.setColumn("*");
configinq.refresh();
ThaiUtilities th=new ThaiUtilities();
while(configinq.next()){
writer.println("\t<DATA>");
writer.println("\t\t<CONFIGID><![CDATA["+th.ASCII2Unicode(configinq.getString("CONFIGID"))+"]]></CONFIGID>");
writer.println("\t\t<COMPANYID><![CDATA["+th.ASCII2Unicode(configinq.getString("COMPANYID"))+"]]></COMPANYID>");
writer.println("\t\t<TDESC><![CDATA["+th.ASCII2Unicode(configinq.getString("TDESC"))+"]]></TDESC>");
writer.println("\t\t<EDESC><![CDATA["+th.ASCII2Unicode(configinq.getString("TDESC"))+"]]></EDESC>");
writer.println("\t\t<CONFIG_TYPE><![CDATA["+th.ASCII2Unicode(configinq.getString("CONFIG_TYPE"))+"]]></CONFIG_TYPE>");
writer.println("\t\t<CONFIG_VALUE><![CDATA["+th.ASCII2Unicode(configinq.getString("CONFIG_VALUE"))+"]]></CONFIG_VALUE>");
writer.println("\t\t<COMPONENT><![CDATA["+th.ASCII2Unicode(configinq.getString("COMPONENT"))+"]]></COMPONENT>");
writer.println("\t\t<COMWIDTH><![CDATA["+th.ASCII2Unicode(configinq.getString("COMWIDTH"))+"]]></COMWIDTH>");
writer.println("\t\t<COMDECIMAL><![CDATA["+th.ASCII2Unicode(configinq.getString("COMDECIMAL"))+"]]></COMDECIMAL>");
writer.println("\t\t<GROUP_NAME><![CDATA["+th.ASCII2Unicode(configinq.getString("GROUP_NAME"))+"]]></GROUP_NAME>");
writer.println("\t\t<SCREEN_NAME><![CDATA["+th.ASCII2Unicode(configinq.getString("SCREEN_NAME"))+"]]></SCREEN_NAME>");
writer.println("\t\t<EFFECTIVEID><![CDATA["+th.ASCII2Unicode(configinq.getString("EFFECTIVEID"))+"]]></EFFECTIVEID>");
writer.println("\t</DATA>");
writer.println("");
}
writer.println("</MCONFIG>");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.csc.library.config;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.session.InitialInquiry;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ThaiUtilities;
import com.csc.library.utilities.UProfile;
public class LoadQueue {
private UProfile upf=null;
Element str;
public LoadQueue(){
this.upf = new UProfile();
this.upf.setDefault();
try {
InitialEnvironment env = new InitialEnvironment("GLOBAL");
SAXBuilder builder = new SAXBuilder();
String pathName="";
pathName=env.getValue("config-dir") +"CSC_QUEUE.xml";
File configxml=new File(pathName);
if(!configxml.exists()){
createConfigXML(pathName);
}else{
Document stru = builder.build(new File(pathName));
str = stru.getRootElement();
this.process();
}
} catch (Exception ex) {
MyLog.error(this, this.upf, ex);
}
}
private void process(){
try {
DbRecord db = new InitialRecord(this.upf).getDbRecord("com.csc.entity.CSC_Quque");
db.setColumn("*");
Element data;
List list = str.getChildren();
Iterator it = list.iterator();
while (it.hasNext()) {
data = (Element) it.next();
db.set("ququeid", data.getAttributeValue("ququeid"));
if(db.search()<1){
List sub_list =data.getChildren();
Iterator sub_it = sub_list.iterator();
Element fm_data;
while (sub_it.hasNext()) {
fm_data = (Element) sub_it.next();
db.set(fm_data.getName(), fm_data.getText());
}
db.save();
}
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void createConfigXML(String pathName){
try {
System.out.println("\tCREATE CSC_QUEUE FILE..");
File configxml = new File(pathName);
OutputStream out = new BufferedOutputStream(new FileOutputStream(configxml));
PrintWriter writer = new PrintWriter(out);
writer.println("<?xml version=\"1.0\" encoding=\"TIS-620\"?>");
writer.println("<QUEUE>");
DbInquiry configinq=new InitialInquiry(this.upf).getDbInquiry();
configinq.initMyTable("com.csc.entity.CSC_Quque","","");
configinq.setColumn("*");
configinq.setFilter("process_type='R'");
configinq.refresh();
ThaiUtilities th=new ThaiUtilities();
while(configinq.next()){
writer.println("\t<DATA ququeid=\""+th.ASCII2Unicode(configinq.getString("QUQUEID"))+"\">");
writer.println("\t\t<TNAME><![CDATA["+th.ASCII2Unicode(configinq.getString("TNAME"))+"]]></TNAME>");
writer.println("\t\t<ENAME><![CDATA["+th.ASCII2Unicode(configinq.getString("ENAME"))+"]]></ENAME>");
writer.println("\t\t<CLASS_NAME><![CDATA["+th.ASCII2Unicode(configinq.getString("CLASS_NAME"))+"]]></CLASS_NAME>");
writer.println("\t\t<PROCESS_STATUS><![CDATA["+th.ASCII2Unicode(configinq.getString("PROCESS_STATUS"))+"]]></PROCESS_STATUS>");
writer.println("\t\t<PROCESS_TYPE><![CDATA["+th.ASCII2Unicode(configinq.getString("PROCESS_TYPE"))+"]]></PROCESS_TYPE>");
writer.println("\t\t<PROCESS_GROUP><![CDATA["+th.ASCII2Unicode(configinq.getString("PROCESS_GROUP"))+"]]></PROCESS_GROUP>");
writer.println("\t\t<OWNER><![CDATA["+th.ASCII2Unicode(configinq.getString("OWNER"))+"]]></OWNER>");
writer.println("\t\t<REMOTE_IP><![CDATA["+th.ASCII2Unicode(configinq.getString("REMOTE_IP"))+"]]></REMOTE_IP>");
writer.println("\t\t<EMPLOYEEID><![CDATA["+th.ASCII2Unicode(configinq.getString("EMPLOYEEID"))+"]]></EMPLOYEEID>");
writer.println("\t\t<COMPANYID><![CDATA["+th.ASCII2Unicode(configinq.getString("COMPANYID"))+"]]></COMPANYID>");
writer.println("\t\t<USER_NAME><![CDATA["+th.ASCII2Unicode(configinq.getString("USER_NAME"))+"]]></USER_NAME>");
writer.println("\t\t<SCREEN_NAME><![CDATA["+th.ASCII2Unicode(configinq.getString("SCREEN_NAME"))+"]]></SCREEN_NAME>");
writer.println("\t\t<SERVER_NAME><![CDATA["+th.ASCII2Unicode(configinq.getString("SERVER_NAME"))+"]]></SERVER_NAME>");
writer.println("\t\t<NEXT_TIME><![CDATA["+th.ASCII2Unicode(configinq.getString("NEXT_TIME"))+"]]></NEXT_TIME>");
writer.println("\t\t<START_TIME><![CDATA["+th.ASCII2Unicode(configinq.getString("START_TIME"))+"]]></START_TIME>");
writer.println("\t\t<END_TIME><![CDATA["+th.ASCII2Unicode(configinq.getString("END_TIME"))+"]]></END_TIME>");
writer.println("\t\t<REMARK><![CDATA["+th.ASCII2Unicode(configinq.getString("REMARK"))+"]]></REMARK>");
writer.println("\t\t<PROCESS_PRIORITY><![CDATA["+th.ASCII2Unicode(configinq.getString("PROCESS_PRIORITY"))+"]]></PROCESS_PRIORITY>");
writer.println("\t\t<CONDITION><![CDATA["+th.ASCII2Unicode(configinq.getString("CONDITION"))+"]]></CONDITION>");
writer.println("\t\t<PARENTID><![CDATA["+th.ASCII2Unicode(configinq.getString("PARENTID"))+"]]></PARENTID>");
writer.println("\t\t<PTYPE><![CDATA["+th.ASCII2Unicode(configinq.getString("PTYPE"))+"]]></PTYPE>");
writer.println("\t</DATA>");
writer.println();
}
writer.println("</QUEUE>");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.csc.library.config;
import java.rmi.RemoteException;
import java.util.HashMap;
import com.csc.library.database.Relation;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.UProfile;
public class SetTransactionField {
public SetTransactionField() {
}
/**
*
* FieldList ="actorid,emp_group,emp_position,job,bu1,bu2,bu3,bu4,bu5,salatype,workarea,branch";
*
*/
private boolean checkColumn(DbRecord dbr,String columnList,String fieldName){
try {
if ( (dbr.getField(fieldName) != null && columnList != null && !columnList.equals("*")) && !columnList.equals("") &&columnList.toUpperCase().indexOf(fieldName.toUpperCase()) == -1) {
return true;
}
return false;
}
catch (Exception ex) {
ex.printStackTrace();
return false;
}
}
// private void setConfigSave(DbRecord db,String fieldName){
// try {
// UProfile u=db.getUProfile();
// String fieldList=db.getFieldList();
// if(this.checkColumn(db,fieldList,fieldName)){
// db.getField(fieldName).setWorking(true);
// fieldList+=","+fieldName;
//// db.setFieldList(fieldList);
// db.setColumn(fieldList);
// }
// String fieldValue="";
// if(db.getString(fieldName)!=null&&db.getString(fieldName).length()>0){
// fieldValue =db.getString(fieldName);
// }else if(db.getParam("__"+fieldName)!=null){
// fieldValue=(String) db.getParam("__"+fieldName);
// }else{
// fieldValue=(String) u.get(fieldName);
// }
// db.set(fieldName,fieldValue);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// }
private void setConfigSave(DbRecord db,String fieldName){
try {
UProfile u=db.getUProfile();
String fieldList=db.getFieldList();
if(this.checkColumn(db,fieldList,fieldName)){
db.getField(fieldName).setWorking(true);
fieldList+=","+fieldName;
db.setColumn(fieldList);
}
String fieldValue="";
if(db.getParam("__"+fieldName)!=null){
fieldValue=(String) db.getParam("__"+fieldName);
}else {
if(db.getField(fieldName)!=null){
Relation r = db.getRelation("memployee");
DbRecord dbemp =null;
if (r == null) {
dbemp = new InitialRecord(u).getDbRecord("memployee");
r = dbemp.getRelation(db.getTableName().toLowerCase());
}
String fname = "";
if (r != null)
for (int i = 0; i < r.parentField.size(); i++) {
if (r.parentField.elementAt(i).toString().equalsIgnoreCase("employeeid")) {
fname = r.childField.elementAt(i).toString();
break;
}
}
if (fname.length()>0&&!db.getString(fname).equals(u.get("employeeid"))) {
if(dbemp==null)
dbemp = new InitialRecord(u).getDbRecord("memployee");
dbemp.set("companyid",(String)u.get("companyid"));
dbemp.set("employeeid",db.getString(fname));
dbemp.search();
fieldValue = db.getString(fieldName);
} else {
fieldValue = (String) u.get(fieldName);
}
}
//System.out.println(db.getTableName()+" >Field : "+fieldName+" = "+db.getString(fieldName));
db.set(fieldName,fieldValue);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void setConfigSave(DbRecord db,String fieldName,String Value){
try {
UProfile u=db.getUProfile();
String fieldList=db.getFieldList();
if(this.checkColumn(db,fieldList,fieldName)){
db.getField(fieldName).setWorking(true);
fieldList+=","+fieldName;
// db.setFieldList(fieldList);
db.setColumn(fieldList);
// System.out.println(db.getTableName()+" >Field : "+fieldName+" = "+db.getString(fieldName));
}
db.set(fieldName,Value);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setColumnForSave(DbRecord db){
try {
UProfile u = db.getUProfile();
String tableName=db.getTableName();
HashMap pam= db.getParam();
String fconfig ="ON";
if(pam.containsKey("__fieldConfig"))
fconfig=(String)pam.get("__fieldConfig");
if((!tableName.equalsIgnoreCase("memployee"))&&(!(String.valueOf(tableName.charAt(0)).equalsIgnoreCase("h")))
&& !tableName.equalsIgnoreCase("mempl_movement")&&(fconfig.equalsIgnoreCase("ON"))){
setConfigSave(db,"actorid",u.get("actorid"));
setConfigSave(db,"emp_group");
setConfigSave(db,"emp_position");
setConfigSave(db,"job");
setConfigSave(db,"bu1");
setConfigSave(db,"bu2");
setConfigSave(db,"bu3");
setConfigSave(db,"bu4");
setConfigSave(db,"bu5");
setConfigSave(db,"salatype");
setConfigSave(db,"workarea");
setConfigSave(db,"branch");
setConfigSave(db,"bossid");
}
CscCalendar cs=new CscCalendar();
setConfigSave(db,"create_date", cs.getYYYYMMDD());
setConfigSave(db,"create_time",cs.getHHMMSS());
setConfigSave(db,"create_by",u.get("actorid"));
setConfigSave(db,"wf_status");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setColumnForUpdate(DbRecord db){
try {
setConfigSave(db,"actorid",(String)db.getUProfile().get("actorid"));
} catch (Exception e) {
e.printStackTrace();
}
}
/*
private String checkColumnConfig(DbRecord dbr,String columnList,String fieldName){
String clist="";
try {
if ( (dbr.getField(fieldName) != null && columnList != null && !columnList.equals("*")) && !columnList.equals("") &&columnList.toUpperCase().indexOf(fieldName.toUpperCase()) == -1) {
clist = ","+fieldName;
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return clist;
}
*/
/*
public String setColumnConfig(DbRecord db ,String columnList){
String columnlist =columnList;
try {
columnlist+=this.checkColumnConfig(db,columnList,"actorid");
columnlist+=this.checkColumnConfig(db,columnList,"emp_group");
columnlist+=this.checkColumnConfig(db,columnList,"emp_position");
columnlist+=this.checkColumnConfig(db,columnList,"job");
columnlist+=this.checkColumnConfig(db,columnList,"bu1");
columnlist+=this.checkColumnConfig(db,columnList,"bu2");
columnlist+=this.checkColumnConfig(db,columnList,"bu3");
columnlist+=this.checkColumnConfig(db,columnList,"bu4");
columnlist+=this.checkColumnConfig(db,columnList,"bu5");
columnlist+=this.checkColumnConfig(db,columnList,"salatype");
columnlist+=this.checkColumnConfig(db,columnList,"workarea");
columnlist+=this.checkColumnConfig(db,columnList,"branch");
}
catch (Exception ex) {
ex.printStackTrace();
}
return columnlist;
}
*/
/*
* public void setBeforeSave(DbRecord db){
try {
UProfile u = db.getUProfile();
String columnList=db.getFieldList();
db.set("actorid",u.get("actorid"));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void setPostInsert(DbRecord db){
try {
CscCalendar cs=new CscCalendar();
UProfile u = db.getUProfile();
String tableName=db.getTableName();
if((!tableName.equalsIgnoreCase("memployee"))&&(!(String.valueOf(tableName.charAt(0)).equalsIgnoreCase("h")))){
db.set("emp_group",u.get("emp_group"));
db.set("emp_position",u.get("emp_position"));
db.set("job",u.get("job"));
db.set("bu1",u.get("bu1"));
db.set("bu2",u.get("bu2"));
db.set("bu3",u.get("bu3"));
db.set("bu4",u.get("bu4"));
db.set("bu5",u.get("bu5"));
db.set("salatype",u.get("salatype"));
db.set("workarea",u.get("workarea"));
db.set("branch",u.get("branch"));
}
db.set("create_date",cs.getDDMMYYYY());
db.set("create_time",cs.getHHMMSS());
db.set("create_by",u.get("actorid"));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
*/
}
package com.csc.library.cscexport;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.jdom.Attribute;
import org.jdom.Element;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ReadXml;
/**
* <PRE>
* Cls 红 xml ͧ Export
* Cls CscExport ¡ҹдǡ
* </PRE>
*
* @author @SoCooL@
*/
public class ExportXml {
//root element
Element root;
// attribute in root element
private String xmlName;
private String fileOut;
private String processType;
private String fileType;
private String requiryFound;
private String separateRec;
// element INIT HEAD FOOT
private String initData;
private Vector head;
private Vector foot;
private Vector data;
private Vector configData;
private Vector configHead;
private Vector configFoot;
private HashMap attrData;
private HashMap attrHead;
private HashMap attrFoot;
/**
* <PRE>
* Constructor 㹡ҹҨҡ xml
* 絤ҵ Cls ҹ
* </PRE>
* @param xmlName xml ͧ Export
*/
public ExportXml(String xmlName) {
this.xmlName = xmlName;
data = new Vector();
head = new Vector();
foot = new Vector();
configData = new Vector();
configHead = new Vector();
configFoot = new Vector();
attrData = new HashMap();
attrHead = new HashMap();
attrFoot = new HashMap();
this.process();
}
/**
* ֧ config ͧ
* @param configNo
* - 1 config ͧ tag data
* - 2 config ͧ tag head
* - 3 config ͧ tag foot
* @return Vector Ѿ config Vector
* ¨纤 Key Value ͧ Property ͧ Tag ͧ
*/
public Vector getConfig(int configNo) {
if (configNo == 0) {
return this.configData;
} else if (configNo == 1) {
return this.configHead;
} else if (configNo == 2) {
return this.configFoot;
} else
return null;
}
/**
* ֧ property ͧ tag data ӴѺͧ
* @param no ӴѺͧ property ͧ
* @return HashMap [key,value] ͧ tag data
*/
public HashMap getConfigData(int no) {
return (HashMap) this.configData.get(no);
}
/**
* ֧ property ͧ tag head ӴѺͧ
* @param no ӴѺͧ property ͧ
* @return HashMap [key,value] ͧ tag head
*/
public HashMap getConfigHead(int no) {
return (HashMap) this.configHead.get(no);
}
/**
* ֧ property ͧ tag foot ӴѺͧ
* @param no ӴѺͧ property ͧ
* @return HashMap [key,value] ͧ tag foot
*/
public HashMap getConfigFoot(int no) {
return (HashMap) this.configFoot.get(no);
}
/**
* ֧Ըա㹡÷ӧҹ Export
* @return String Ըա㹡 export
*/
public String getProcessType() {
return processType;
}
/**
* ֧ ͧӡ¡ record
* @return String
*/
public String getSeparateRec() {
return separateRec;
}
/**
* 觤 Vector tag data Ѻ
* @return Vector
*/
public Vector getData() {
return data;
}
/**
* 觤 Vector tag foot Ѻ
* @return Vector
*/
public Vector getFoot() {
return foot;
}
/**
* 觤 Vector tag head Ѻ
* @return Vector
*/
public Vector getHead() {
return head;
}
/**
* 觤 export c:/test.txt
* @return String
*/
public String getFileOut() {
return fileOut;
}
/**
* 觤ҪԴͧ export txt , xml
* @return String
*/
public String getFileType() {
return fileType;
}
public String getRequiryFound(){
return this.requiryFound;
}
/**
* 觤 tag Init data Ѻ
* @return String
*/
public String getInitData() {
return initData;
}
/**
* 觤Ҫ xml Ѻ
* @return String
*/
public String getXmlName() {
return xmlName;
}
/**
* 絤 export c:/test.txt
* @param fileOut The fileOut to set
*/
public void setFileOut(String fileOut) {
this.fileOut = fileOut;
}
/**
* fetch Ũҡ node
* @param nodeData note ͧ fetch
* @param data Vector 红Ţͧ tag ͧ
* @param config Vector property ͧ tag
*/
private void fetchValue(String nodeData, Vector data, Vector config) {
HashMap h = new HashMap();
Element e = null;
List list = null, dataList = null;
Iterator it = null, dataIterate = null;
Attribute at = null;
int dataSize = 0;
if (root.getChild(nodeData)!=null) {
dataList = root.getChild(nodeData).getChildren();
dataIterate = dataList.listIterator();
while (dataIterate.hasNext()) {
e = (Element) dataIterate.next();
data.add(e.getText());
list = e.getAttributes();
it = list.listIterator();
while (it.hasNext()) {
at = (Attribute) it.next();
h.put(at.getName().trim(), at.getValue().trim());
}
config.add(dataSize, h.clone());
h.clear();
dataSize++;
}
}
}
protected boolean process() {
ReadXml r = new ReadXml(this.xmlName);
try {
// necessary
root = r.getRootElement();
// attribute in root element is name fileout filetype processtype separaterec
this.xmlName = r.getAttrValue(r.getRootElement(), "name").trim();
this.fileOut = r.getAttrValue(r.getRootElement(), "fileout").trim();
this.fileType = r.getAttrValue(r.getRootElement(), "filetype").trim();
this.processType = r.getAttrValue(r.getRootElement(), "processtype").trim();
this.initData = r.getString("INIT");
this.fetchValue("DATA", this.data, this.configData);
this.fetchValue("HEAD", this.head, this.configHead);
this.fetchValue("FOOT", this.foot, this.configFoot);
if (root.getChild("DATA")!=null) this.attrData = r.getHashMapAttr(root.getChild("DATA"));
if (root.getChild("HEAD")!=null) this.attrHead = r.getHashMapAttr(root.getChild("HEAD"));
if (root.getChild("FOOT")!=null) this.attrFoot = r.getHashMapAttr(root.getChild("FOOT"));
if (r.getAttrValue(r.getRootElement(),"requiryfound")!=null) this.requiryFound = r.getAttrValue(r.getRootElement(),"requiryfound").trim();
return true;
} catch (Exception e) {
MyLog.error(this, e);
return false;
}
}
/**
* Returns the atrbData.
* @return HashMap
*/
public String getAttrData(String key) {
return attrData.get(key).toString();
}
/**
* Returns the atrbFoot.
* @return HashMap
*/
public String getAttrFoot(String key) {
return attrFoot.get(key).toString();
}
/**
* Returns the atrbHead.
* @return HashMap
*/
public String getAttrHead(String key) {
return attrHead.get(key).toString();
}
public static void main(String[] args) {
ExportXml exp = new ExportXml("c:/export");
}
}
package com.csc.library.cscimport;
import java.util.Vector;
import org.jdom.Element;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ReadXml;
public class ImportXml {
// attribute ?????? root element
private boolean insert;
private boolean update;
private boolean lastUpdate;
private String xmlType = "";
private String xmlName = "";
private Vector childData = null;
private Vector data = null;
private Vector element = null;
private Vector blank = null;
private Vector source = null;
//private Vector fieldtype = null;
private String initStr = "";
private String impPattern = "";
private String condition = "";
private String processType = "";
private char delim = ' ';
private char wordDelim = ' ';
private int recSize = 0;
public ImportXml(String fname) {
this.xmlName = fname;
}
public String getCondition() {
return this.condition;
}
public String getImpPattern() {
return this.impPattern;
}
public String getInitStr() {
return this.initStr;
}
public Vector getDataField() {
return this.data;
}
public boolean getFlagIns() {
return this.insert;
}
public boolean getFlagUp() {
return this.update;
}
public boolean getFlagLastUp() {
return this.lastUpdate;
}
public String getXmlType() {
return this.xmlType;
}
public Vector getSource() {
return this.source;
}
public Vector getBlank() {
return this.blank;
}
public int getRecSize() {
return this.recSize;
}
public String getProcesType() {
return this.processType;
}
public String getName() {
return this.xmlName;
}
public char getDelim() {
return this.delim;
}
public char getWordDelim() {
return this.wordDelim;
}
public Vector getChildData() {
return this.childData;
}
public Vector getElement() {
return this.element;
}
public boolean chkSpace() {
if (this.xmlType == null || this.xmlType.equals("")) {
MyLog.error(this,"In xml File Check attribute filetype");
return false;
} else if (this.xmlName == null || this.xmlName.equals("")) {
MyLog.error(this,"In xml File Check attribute filename");
return false;
} else if (this.processType == null || this.processType.equals("")) {
MyLog.error(this,"In xml File Check attribute processtype");
return false;
} else if (this.initStr == null || this.initStr.equals("")) {
MyLog.error(this,"In xml File Check Node INIT");
return true;
} else if (this.impPattern == null || this.impPattern.equals("")) {
MyLog.error(this,"In xml File Check Node IMPORTPATTERN");
return true;
} else if (this.condition == null || this.condition.equals("")) {
MyLog.error(this,"In xml File Check Node CONDITION");
return true;
} else
return true;
}
private boolean getDataLineListFL(String procType, ReadXml r) {
source = new Vector();
blank = new Vector();
try {
Element e = null;
for (int i = 0; i < this.data.size(); i++) {
e = (Element) data.get(i);
source.add(e.getAttributeValue("source").toString().trim());
blank.add(e.getAttributeValue("blank").toString().trim());
}
} catch (Exception ex) {
MyLog.error(this,"In xml File Check attribute in Node COL");
return false;
}
return true;
}
private boolean getDataLineListFR(String procType, ReadXml r) {
source = new Vector();
try {
this.delim = r.getRootElement().getChild("DATA").getAttributeValue("tokendelimeter").charAt(0);
Element e = null;
String tmp = "";
for (int i = 0; i < this.data.size(); i++) {
e = (Element) data.get(i);
source.add(e.getAttributeValue("source").toString().trim());
}
} catch (Exception ex) {
MyLog.error(this,"In xml File Check attribute in Node COL");
return false;
}
return true;
}
private boolean getDataLineStripFix(String procType, ReadXml r) {
source = new Vector();
blank = new Vector();
try {
Element e = null;
this.recSize = new Integer(r.getRootElement().getChild("DATA").getAttributeValue("size")).intValue();
for (int i = 0; i < this.data.size(); i++) {
e = (Element) data.get(i);
source.add(e.getAttributeValue("source").toString().trim());
blank.add(e.getAttributeValue("blank").toString().trim());
}
} catch (Exception ex) {
MyLog.error(this,"In xml File Check attribute in Node COL");
return false;
}
return true;
}
private boolean getDataLineStripFree(String procType, ReadXml r) {
source = new Vector();
try {
this.delim = r.getRootElement().getChild("DATA").getAttributeValue("tokendelimeter").charAt(0);
this.wordDelim = r.getRootElement().getChild("DATA").getAttributeValue("worddelimmeter").charAt(0);
Element e = null;
for (int i = 0; i < this.data.size(); i++) {
e = (Element) data.get(i);
source.add(e.getAttributeValue("source").toString().trim());
}
} catch (Exception ex) {
ex.printStackTrace();
//System.out.println("ERROR:In xml File Check attribute in Node COL");
return false;
}
return true;
}
public boolean process() {
ReadXml r = new ReadXml(this.xmlName);
try {
this.insert = new Boolean(r.getAttrValue(r.getRootElement(), "insert").trim()).booleanValue();
this.update = (r.getAttrValue(r.getRootElement(), "update").trim().equals("true")) ? true : false;
this.lastUpdate = (r.getAttrValue(r.getRootElement(), "lastupdate").equals("true")) ? true : false;
this.xmlType = r.getAttrValue(r.getRootElement(), "filetype").trim();
this.xmlName = r.getAttrValue(r.getRootElement(), "name").trim();
this.processType = r.getAttrValue(r.getRootElement(), "processtype").trim();
this.data = r.listTovec(r.getRootElement().getChild("DATA").getChildren());
this.element = r.listTovec(r.getRootElement().getChildren());
this.initStr = r.getString("INIT");
this.impPattern = r.getString("IMPORTPATTERN");
this.condition = r.getString("CONDITION");
} catch (Exception e) {
MyLog.error(this,"Have null data Please Check your xml file");
}
if (this.chkSpace()) {
if (this.xmlType.equals("linelist")) {
if (this.processType.equals("fixspace")) {
return this.getDataLineListFL(this.getProcesType(), r);
} else if (this.processType.equals("freespace")) {
return this.getDataLineListFR(this.getProcesType(), r);
} else {
MyLog.error(this,"No such process type in xml filetype linelist");
return false;
}
} else if (this.xmlType.equals("linestrip")) {
if (this.getProcesType().equals("fixspace")) {
return this.getDataLineStripFix(this.getProcesType(), r);
} else if (this.getProcesType().equals("freespace")) {
return this.getDataLineStripFree(this.getProcesType(), r);
} else {
MyLog.error(this,"No such process type in xml filetype linestrip");
return false;
}
} else {
MyLog.error(this,"type:" + this.xmlType);
MyLog.error(this,"In XML File:No such file type in xml file");
return false;
}
} else
return false;
}
}
package com.csc.library.cscimport;
import java.util.Vector;
import com.csc.library.utilities.ReadFile;
public class ProcessBase {
protected Vector fieldData;
protected String dataFileName;
protected String processType;
protected ReadFile readFile;
public ProcessBase(String dataFile) {
readFile = new ReadFile(dataFile);
fieldData = new Vector();
this.setDataFileName(dataFile);
}
protected Vector getFieldData(String fname) {
return this.fieldData;
}
protected void setDataFileName(String fName) {
this.dataFileName = fName;
}
protected String getDataFileName() {
return this.dataFileName;
}
}
\ No newline at end of file
package com.csc.library.cscimport;
import java.util.Hashtable;
public class ProcessLineList extends ProcessBase implements RecordSet {
private int dataSize = 0;
private Hashtable config;
public ProcessLineList(String fName) {
super(fName);
config = new Hashtable();
}
public void set(String key, String value) {
this.config.put(key, value);
}
public void setObject(String key, Object value) {
this.config.put(key, value);
}
public void setInt(String key, int value) {
this.config.put(key, new Integer(value));
}
public Object get(String key) {
return this.config.get(key);
}
public int getInt(String key) {
Integer tmpInt = (Integer) config.get(key);
return tmpInt.intValue();
}
public String getString(String key) {
return config.get(key).toString();
}
public String next() {
return readFile.getStringRL(); //get String 1 line into String tmpStr
}
public boolean hasMoreElement() {
return this.readFile.hasMoreData();
}
}
\ No newline at end of file
package com.csc.library.cscimport;
import java.util.Hashtable;
public class ProcessLineStrip extends ProcessBase implements RecordSet {
private Hashtable config;
public ProcessLineStrip(String fName) {
super(fName);
config = new Hashtable();
}
public void set(String key, String value) {
this.config.put(key, value);
}
public void setObject(String key, Object value) {
this.config.put(key, value);
}
public void setInt(String key, int value) {
this.config.put(key, new Integer(value));
}
public Object get(String key) {
return this.config.get(key);
}
public int getInt(String key) {
Integer tmpInt = (Integer) config.get(key);
return tmpInt.intValue();
}
public String getString(String key) {
return config.get(key).toString();
}
public String next() {
if (this.getString("processtype").equalsIgnoreCase("fixspace")) {
return this.readFile.getCountString(this.getInt("recordsize"));
} else if (this.getString("processtype").equalsIgnoreCase("freespace")) {
return this.readFile.getStringToken(this.getString("worddelimeter").charAt(0));
} else
return null;
}
public boolean hasMoreElement() {
return this.readFile.hasMoreData();
}
}
\ No newline at end of file
package com.csc.library.cscimport;
public interface RecordSet{
public String next();
public boolean hasMoreElement();
public void set(String key,String value);
public void setObject(String key,Object value);
public void setInt(String key,int value);
public String getString(String key);
public int getInt(String key);
public Object get(String key);
}
\ No newline at end of file
package com.csc.library.database;
import com.csc.library.utilities.MyLog;
public class AutoNumber extends MyRecord {
public AutoNumber() {
super("autonum", "pwAuto Number table");
/*fieldManager field1= new fieldString("codeid",10,"????");
field1.setKey('1');
addField(field1);
fieldManager field2= new fieldString("format",10,"??????");
addField(field2);
fieldManager field3= new fieldNumeric("current_num",10,"???????????");
addField(field3);
setColumn("*");*/
}
public int getNextNumber(String code) {
int nextNumber = 9999999;
try {
//con.setAutoCommit(false);
//con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
this.setKey(code);
if (this.search() == 1) {
nextNumber = this.getInt("current_num");
this.set("current_num", nextNumber + 1);
this.save();
}
MyLog.debug(this, "num : " + nextNumber);
//con.commit();
} catch (Exception e) {
MyLog.error(this, e);
}
return nextNumber;
}
}
package com.csc.library.database;
import com.csc.library.summary.SumManager;
public class BasicSum implements SumManager {
protected float value = 0;
protected float oldValue = 0;
public float getAmount() {
return value;
}
public float getOldAmount() {
return oldValue;
}
public boolean sumCondition(MyInquiry q) {
return true;
}
public boolean clearCondition(MyInquiry q) {
return false;
}
public void sum(MyInquiry q) {}
public void clear() {
this.value = 0;
}
public void keepAmount() {
this.oldValue = value;
}
}
package com.csc.library.database;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Vector;
import com.csc.library.utilities.UProfile;
public interface ChildManager extends Serializable{
public void clearField() throws RemoteException;
public void clearChild() throws RemoteException;
public String getTableName() throws RemoteException;
public String getDescription() throws RemoteException;
public int setCondition(String condition[]) throws RemoteException;
public void refresh() throws RemoteException;
public void refreshChild() throws RemoteException;
public ChildManager getChild(String childName) throws RemoteException;
public Relation getRelation(String relation) throws RemoteException;
public char getUsedFor() throws RemoteException;
public int save() throws RemoteException;
public int delete()throws RemoteException;
public ConnectManager getConnectControl() throws RemoteException;
public void setRequiredFound(boolean requrire) throws RemoteException;
public boolean getRequiredFound() throws RemoteException;
public Hashtable getChildTable() throws RemoteException;
public boolean foundData() throws RemoteException;
public void setFilter(String condition) throws RemoteException;
public void isChild() throws RemoteException;
public int putChild(ChildManager oChild) throws RemoteException;
public Vector getAllKey() throws RemoteException;
public void setUProfile(UProfile uPro) throws RemoteException;
public UProfile getUProfile();
public String getActualName() throws RemoteException;
public void setParam(HashMap param) throws RemoteException;
public void referLangOff()throws RemoteException;
public void referLangOn()throws RemoteException;
public String getString(String field)throws RemoteException;
public HashMap getParam()throws RemoteException;
public int recCount()throws RemoteException;
public void setParent(ChildManager ch)throws RemoteException;
public boolean setColumn(String columnList) throws RemoteException;
public boolean setColumn(Vector columnList) throws RemoteException;
/**
* Start RequireFound Table
*/
public void setRequireFoundTable(String tablenames);
public void setRequireFoundTable(Vector childRequire);
public Vector getRequireFoundTable();
public String getStringHTML(String fieldName);
/**
* end RequireFound Table
*/
/**
* Start transaction
*/
// public void setSqlBatch(SqlBatch sqlseq);
//public SqlBatch getSqlBatch();
/**
* end transaction
*/
/**
* set aliasname for table
*/
public void setAliasName(String aliasname);
public String getAliasName();
}
\ No newline at end of file
/*
* Created on 22 .. 2550
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.csc.library.database;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
import org.jdom.Element;
/**
* @author Dragonfire
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ComponentField implements Serializable {
//HashMap key;
HashMap vHash = new HashMap();
String appName="";
HashMap fieldUse = new HashMap();
Map<String,String> labelMap = null;
/**
* @return Returns the appname.
*/
public String getAppName() {
return appName;
}
/**
* @param appname The appname to set.
*/
public void setAppName(String appname) {
this.appName = appname.toUpperCase();
this.fieldUse=this.getComField(this.appName);
}
public ComponentField(){
}
public ComponentField(Element em){
setComField(em);
}
public ComponentField(Element em,Element emdiff){
setComField(em,emdiff);
}
public void setLabelMap(Map<String, String> labelMap) {
this.labelMap = labelMap;
}
// /**
// * @return Returns the key.
// */
// public HashMap getKey() {
// return key;
// }
// /**
// * @param key The key to set.
// */
// public void setKey(HashMap key) {
// this.key = key;
// }
public HashMap setComField(Element em,String appname){
Iterator it,it2;
List list = em.getChildren();
it = list.iterator();
Element eChild;
HashMap cF=new HashMap();
// Vector newkey=(Vector)setAppNameAll(appname).clone();
// setAppNameAll(appname).clone();
cF.put("appname",appname.toUpperCase());
while(it.hasNext()){
eChild=(Element)it.next();
cF.put(eChild.getName(), eChild.getText().trim());
if (eChild.getName().equalsIgnoreCase("COMPONENT")) {
cF.put("COMTYPE", eChild.getAttributeValue("type").trim());
list = eChild.getChildren();
it2 = list.iterator();
Element subCom;
while (it2.hasNext()) {
subCom = (Element) it2.next();
if(!subCom.getName().equalsIgnoreCase("REQUIRE"))
cF.put(subCom.getName(), subCom.getText().trim());
}
}
}
return cF;
}
private Element getElemaneAppName(Element emdiff,String appname){
Vector v=new Vector(emdiff.getParent().getChildren("APPNAME"));
Element emdata=null;
for(int diff=0;diff<v.size();diff++){
emdata=(Element)v.get(diff);
if(emdata.getAttributeValue("name").equalsIgnoreCase(appname.toUpperCase())){
return emdata;
}
}
return null;
}
public HashMap setComField(Element em,String appname,Element emdiff){
HashMap cF=new HashMap();
if(emdiff==null){
cF=setComField(em,appname.toUpperCase());
}else{
Iterator it,it2;
List list = em.getChildren();
it = list.iterator();
Element eChild;
Element eDiff=this.getElemaneAppName(emdiff, appname.toUpperCase());
// Vector newkey=(Vector)setAppNameAll(appname).clone();
// setAppNameAll(appname).clone();
cF.put("appname",appname.toUpperCase());
while(it.hasNext()){
eChild=(Element)it.next();
if(eDiff!=null && eDiff.getChild(eChild.getName())!=null )
cF.put(eChild.getName(), eDiff.getChild(eChild.getName()).getText().trim());
else
cF.put(eChild.getName(), eChild.getText().trim());
if (eChild.getName().equalsIgnoreCase("COMPONENT")) {
if(eDiff!=null && eDiff.getChild(eChild.getName())!=null && eDiff.getChild(eChild.getName()).getAttributeValue("type")!=null)
cF.put("COMTYPE", eDiff.getChild(eChild.getName()).getAttributeValue("type").trim());
else
cF.put("COMTYPE", eChild.getAttributeValue("type").trim());
list = eChild.getChildren();
it2 = list.iterator();
Element subCom;
while (it2.hasNext()) {
subCom = (Element) it2.next();
if(!subCom.getName().equalsIgnoreCase("REQUIRE")){
if(eDiff!=null &&eDiff.getChild("COMPONENT")!=null && eDiff.getChild("COMPONENT").getChild(subCom.getName())!=null)
cF.put(subCom.getName(), eDiff.getChild("COMPONENT").getChild(subCom.getName()).getText().trim());
else
cF.put(subCom.getName(), subCom.getText().trim());
}
}
}
}
}
return cF;
}
public void setComField(Element em){
Iterator it, it2;
List list = em.getChildren("APPNAME");
it = list.iterator();
Element eChild;
vHash = new HashMap();
HashMap tmpHash = new HashMap();
//key=new Vector();
while(it.hasNext()){
eChild = (Element)it.next();
String appname[] = eChild.getAttributeValue("name").split(",");
tmpHash = setComField(eChild, eChild.getAttributeValue("name"));
// TODO set label
if(labelMap != null) {
tmpHash.putAll(labelMap);
}
for(int v=0; v<appname.length; v++){
vHash.put(appname[v].toUpperCase(),tmpHash);
}
}
}
public void setComField(Element em,Element emdiff){
Iterator it,it2;
List list = em.getChildren("APPNAME");
it = list.iterator();
Element eChild;
Element eDiff=(emdiff!=null && emdiff.getChild("APPNAME")!=null)?emdiff.getChild("APPNAME"):null;
vHash=new HashMap();
HashMap tmpHash=new HashMap();
// key=new Vector();
while(it.hasNext()){
eChild=(Element)it.next();
String appname[]=eChild.getAttributeValue("name").split(",");
tmpHash=setComField(eChild,eChild.getAttributeValue("name"),eDiff);
for(int v=0;v<appname.length;v++){
vHash.put(appname[v].toUpperCase(),tmpHash);
}
}
}
// remove by pas
// public HashMap getComField(String appname){
// HashMap hkey;
// Vector vkey;
// if(key!=null && key.contains(appname)){
// for(int h=0;h<vHash.size();h++){
// hkey=(HashMap)vHash.get(h);
// vkey=(Vector)hkey.get("appname");
// if(vkey.contains(appname))
// return hkey;
// }
// }
// return null;
// }
public HashMap getComField(String appname){
if(vHash.containsKey(appname.toUpperCase())){
return (HashMap)vHash.get(appname.toUpperCase());
}
return null;
}
public String getComFieldValue(String elementName){
if(fieldUse!=null && fieldUse.containsKey(elementName)){
return (String)fieldUse.get(elementName);
}
return null;
}
public String getComField(String appname,String code){
HashMap hVal=getComField(appname.toUpperCase());
String nCode=code.toUpperCase();
if(hVal!=null&&hVal.containsKey(nCode)){
return (String)hVal.get(nCode);
}
return null;
}
private Vector setAppNameAll(String appname){
StringTokenizer st=new StringTokenizer(appname,",");
String aName="";
Vector av=new Vector();
while(st.hasMoreTokens()){
aName=(String) st.nextToken();
av.add(aName.toUpperCase());
// if(!key.contains(aName.toUpperCase()))
// key.add(aName.toUpperCase());
}
return av;
}
}
package com.csc.library.database;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.jdom.Element;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ReadXml;
import com.csc.library.utilities.UProfile;
public class ConfigMetadata implements Serializable {
private transient ReadXml read1;
private Element rootElement;
private UProfile uf=null;
private String dependlevel = "true";
private Vector processdata = new Vector();
private Vector permanenttable= new Vector();
private String wfactive = "true";
// variable for Schedule
private String taskschedule = "false";
//Start check index
private String checkindex="false";
private String production="false";
private String debug="false";
private String info="false";
private String display="false";
private String warning="false";
private String limitlogin="false";
private String maxtemp="0";
private String ClearSize = "20";
public ConfigMetadata(UProfile uf) {
this.uf = uf;
}
public void process() {
if(StaticProperties.myConfig==null){
StaticProperties.myConfig=new MyHashMap();
this.initXml();
this.dependlevel = this.getValue("RULE_FOREINGEKEY","value","true");
this.wfactive = this.getValue("WORKFLOW_ACTIVE","value","true");
// Start Taskdef
this.taskschedule = this.getValue("TASKSCHEDULE","value","false");
// End Taskdef
this.setProcessData();
//this.setMessage();
//Start checkindex
this.checkindex=this.getValue("CHECKINDEX","value","false");
this.production=this.getValue("PRODUCTION","value","false");
this.debug=this.getValue("DEBUG","value","false");
this.info=this.getValue("INFO","value","false");
this.display=this.getValue("DISPLAY","value","false");
this.warning=this.getValue("WARN","value","false");
//end checkindex
//limit login
this.limitlogin=this.getValue("LIMITLOGIN","value","false");
this.maxtemp=this.getValue("TEMPTABLE","max","60");
this.ClearSize=this.getValue("TEMPTABLE","clear","20");
this.setPermentTable();
this.setValue();
}else{
this.getValue();
}
}
private void setFieldMap(HashMap map, String type, String field) {
Element em = rootElement.getChild(type).getChild(field);
Element tmp;
Iterator it = em.getChildren().iterator();
while (it.hasNext()) {
tmp = (Element) it.next();
map.put(tmp.getText(), tmp.getAttributeValue("type") + ","+ tmp.getAttributeValue("method"));
}
}
public boolean isGlobal() {
String dbName = this.uf.getDbName().trim();
return dbName.equalsIgnoreCase(new InitialEnvironment("GLOBAL")
.getValue("db-name"));
}
private String getConfigPath() {
return new InitialEnvironment("GLOBAL").getValue("config-dir");
}
public void initXml() {
if(this.rootElement==null){
ReadXml read = new ReadXml(this.getConfigPath() + "config");
this.rootElement =read.getRootElement();
}
}
public boolean isGlogalTable(String tableName) {
Element global = rootElement.getChild("GLOBAL");
java.util.Iterator it = global.getChildren().iterator();
while (it.hasNext()) {
Element ch = (Element) it.next();
String data = ch.getText();
if (tableName.equalsIgnoreCase(data))
return true;
}
return false;
}
public String getDependLevel() {
return this.dependlevel;
}
public Vector getProcessDataConfig() {
return this.processdata;
}
private void setProcessData() {
Element tmpChild = this.rootElement.getChild("PROCESSDATA");
if (tmpChild != null) {
Vector vec = new Vector(tmpChild.getChildren());
for (int i = 0; i < vec.size(); i++) {
this.processdata.add(((Element) vec.get(i)).getText().toLowerCase());
}
}
}
public String getWfActive() {
return this.wfactive;
}
private String getValue(String childname,String attrname,String defaultvalue) {
if (this.rootElement.getChild(childname) != null){
String a = this.rootElement.getChild(childname).getAttributeValue(attrname);
if (a !=null && !a.equals(""))
return a;
}
return defaultvalue;
}
public String getTaskSchedule() {
return this.taskschedule;
}
/**
* check Index of table
*/
public boolean checkIndexTable(){
if(this.checkindex!=null && this.checkindex.equalsIgnoreCase("true"))
return true;
return false;
}
public boolean getDebugStatus(){
if(this.debug!=null && this.debug.equalsIgnoreCase("true"))
return true;
return false;
}
public boolean getInfoStatus(){
if(this.info!=null && this.info.equalsIgnoreCase("true"))
return true;
return false;
}
public boolean getProductionStatus(){
if(this.production!=null && this.production.equalsIgnoreCase("true"))
return true;
return false;
}
public boolean getDisplayStatus(){
if(this.display!=null && this.display.equalsIgnoreCase("true"))
return true;
return false;
}
public boolean getWarningStatus(){
if(this.warning!=null && this.warning.equalsIgnoreCase("true"))
return true;
return false;
}
public boolean getLimitLogin(){
if(this.limitlogin!=null && this.limitlogin.equalsIgnoreCase("true"))
return true;
return false;
}
private void setPermentTable() {
Element tmpChild = this.rootElement.getChild("PERMANENT_TABLE");
if (tmpChild != null) {
Vector vec = new Vector(tmpChild.getChildren());
for (int i = 0; i < vec.size(); i++) {
this.permanenttable.add(convertTable(((Element) vec.get(i)).getText().toLowerCase()));
}
}
}
public Vector getPermanentTable(){
return this.permanenttable;
}
public int getMaxTemporary(){
return Integer.parseInt(this.maxtemp);
}
public int getClearSize(){
return Integer.parseInt(this.ClearSize);
}
private void setValue(){
StaticProperties.myConfig.put("dependlevel",dependlevel);
StaticProperties.myConfig.put("wfactive",wfactive);
StaticProperties.myConfig.put("taskschedule",taskschedule);
StaticProperties.myConfig.put("checkindex",checkindex);
StaticProperties.myConfig.put("production",production);
StaticProperties.myConfig.put("debug",debug);
StaticProperties.myConfig.put("info",info);
StaticProperties.myConfig.put("display",display);
StaticProperties.myConfig.put("warning",warning);
StaticProperties.myConfig.put("limitlogin",limitlogin);
StaticProperties.myConfig.put("maxtemp",maxtemp);
StaticProperties.myConfig.put("permanenttable",permanenttable);
StaticProperties.myConfig.put("processdata",processdata);
StaticProperties.myConfig.put("clearsize",ClearSize);
}
private void getValue(){
dependlevel =(String)StaticProperties.myConfig.get("dependlevel");
wfactive =(String)StaticProperties.myConfig.get("wfactive");
taskschedule=(String)StaticProperties.myConfig.get("taskschedule");
checkindex =(String)StaticProperties.myConfig.get("checkindex");
production =(String)StaticProperties.myConfig.get("production");
debug =(String)StaticProperties.myConfig.get("debug");
info =(String)StaticProperties.myConfig.get("info");
display =(String)StaticProperties.myConfig.get("display");
warning =(String)StaticProperties.myConfig.get("warning");
limitlogin =(String)StaticProperties.myConfig.get("limitlogin");
maxtemp =(String)StaticProperties.myConfig.get("maxtemp");
permanenttable=(Vector)StaticProperties.myConfig.get("permanenttable");
processdata=(Vector)StaticProperties.myConfig.get("processdata");
ClearSize=(String) StaticProperties.myConfig.get("clearsize");
}
private String convertTable(String tableName) {
String tName = tableName.toLowerCase();
return tName.substring(0, 1).toUpperCase() + tName.substring(1, tName.length());
}
}
package com.csc.library.database;
public class ConnectControl implements ConnectManager {
String Url, ClassP, User, Pass;
public void connectCSC() {
Url = ClassP = User = Pass = "";
}
public void setURL(String url) {
this.Url = url;
}
public void setClass(String classpath) {
this.ClassP = classpath;
}
public void setUser(String user) {
this.User = user;
}
public void setPassword(String password) {
this.Pass = password;
}
public String getURL() {
return this.Url;
}
public String getClassName() {
return this.ClassP;
}
public String getUser() {
return this.User;
}
public String getPassword() {
return this.Pass;
}
public void print() {//this.logger.info(
//this.logger.info("URL " + this.getURL());
//this.logger.info("Class " + this.getClassName());
//this.logger.info("User " + this.getUser());
//this.logger.info("Password " + this.getPassword());
}
}
package com.csc.library.database;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.UProfile;
public class ConnectDB {
private HashMap transactionOn = new HashMap();
private int hashCode = 0;
public ConnectDB() {
}
public Connection getConnection(String dataBaseName) {
try {
ConnectionPools cp = (ConnectionPools) StaticProperties.connectionMap.get(dataBaseName.toLowerCase());
Connection con = cp.getConnection();
if (con!=null &&hashCode!=con.hashCode()) {
hashCode = con.hashCode();
}
return con;
} catch (Exception ex) {
MyLog.error(this, ex);
return null;
}
}
public Connection getConnection(String dataBaseName, Object userKey) throws SQLException{
Connection con = null;
String processid = ((UProfile)userKey).getProcessid();
if(processid.length()>0) {
CscConnection conprocess=null;
if(ConnectionPools.connectionProcess.containsKey(processid)){
conprocess=(CscConnection)ConnectionPools.connectionProcess.get(processid);
if (conprocess.isClosed()) {
ConnectionPools cp = (ConnectionPools) StaticProperties.connectionMap.get(dataBaseName.toLowerCase());
conprocess = cp.createConnection();
conprocess.setProcessid(processid);
ConnectionPools.connectionProcess.put(((UProfile)userKey).getProcessid(), conprocess);
}
}else{
ConnectionPools cp = (ConnectionPools) StaticProperties.connectionMap.get(dataBaseName.toLowerCase());
conprocess = cp.createConnection();
conprocess.setProcessid(processid);
conprocess.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
conprocess.setAutoCommit(true);
// conprocess.setAutoCommit(false);
ConnectionPools.connectionProcess.put(((UProfile)userKey).getProcessid(), conprocess);
}
return conprocess;
}
if (userKey != null) {
String key = String.valueOf(((UProfile)userKey).getObjectID()).trim();
if (transactionOn.containsKey(key)) {
CscTransaction ts = (CscTransaction) transactionOn.get(key);
if (!ts.isRollback()) {
con = ts.getConnection(dataBaseName.toLowerCase(), userKey);
return con;
} else {
MyLog.debug(this, dataBaseName+" :Transaction have rollbacked!" + userKey);
SQLException x = new SQLException("Transaction have rollbacked!", "PIAK");
transactionOn.remove(key);
throw x;
}
} else {
con = this.getConnection(dataBaseName.toLowerCase());
}
}
if(con!=null){ //Ǥҧ approve ˹ inbox
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
con.setAutoCommit(true);
// con.setAutoCommit(false);
}
return con;
}
/**
*
* @throws SQLException
* ͧ Connection ˹ Transaction Tracking ӧҹ
*/
public void beginTransaction(Object userKey, Object beginTransactionKey) throws SQLException {
// synchronized(this.transactionOn){ // synchronized ͡ ͧҡԴ connection synchronization failed
CscTransaction ts=null;
String key = String.valueOf(((UProfile)userKey).getObjectID()).trim();
if (!this.transactionOn.containsKey(key)) {
ts=new CscTransaction();
ts.userKey=key;
if (userKey instanceof UProfile ) {
((UProfile) userKey).clearSystemStatus(" ");
}
MyLog.debug(this, "("+ts.userKey + ") System Begin Transaction!");
ts.beginTransactionKey = beginTransactionKey.hashCode();
this.transactionOn.put(ts.userKey, ts);
}
// }
}
/**
*
* @throws SQLException
* Commit data ׹ Connection
*/
public void endTransaction(Object userKey, Object endTransactionKey) throws SQLException {
// synchronized(this.transactionOn){// synchronized ͡ ͧҡԴ connection synchronization failed
CscTransaction ts;
String key = String.valueOf(((UProfile)userKey).getObjectID()).trim();
if (this.transactionOn.containsKey(key)) {
ts = (CscTransaction) this.transactionOn.get(key);
if (ts.beginTransactionKey==endTransactionKey.hashCode()) {
if (!ts.isRollback()) {
MyLog.debug(this, "("+key + ") System End Transaction!");
ts.commit();
}
this.transactionOn.remove(key);
// comment by pas ͧҡ 1 process 1 connection ͧ stamp actiontime
// } else {
// ts.setActionTime();
}
// }
}
}
/**
*
* @return Connection
* @throws SQLException
* Commit data ׹ Connection
*/
public void rollback(Object userKey, Object endTransactionKey) throws SQLException {
// synchronized(this.transactionOn){// synchronized ͡ ͧҡԴ connection synchronization failed
CscTransaction ts;
String key = String.valueOf(((UProfile)userKey).getObjectID()).trim();
if (this.transactionOn.containsKey(key)) {
ts = (CscTransaction) this.transactionOn.get(key);
ts.rollback();
MyLog.error(this, "("+key + ") System Rollback Transaction!");
this.transactionOn.remove(key);
}
// }
}
}
package com.csc.library.database;
import java.io.Serializable;
public interface ConnectManager extends Serializable {
public void setURL(String url);
public void setClass(String classpath);
public void setUser(String user);
public void setPassword(String password);
public String getURL();
public String getClassName();
public String getUser();
public String getPassword();
public void print();
}
package com.csc.library.database;
import java.util.Hashtable;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class ConnectXML extends DefaultHandler {
protected Hashtable blackBox;
ConnectManager con;
String name, data;
public void process() {
/* getProfiles pro = new getProfiles("connectxml","DATABASE");
String url;
url = "file:///"+pro.getValue()+"connect.xml";
try {
XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
if(blackBox==null)blackBox= new Hashtable();
connectXML SaxParser = new connectXML();
parser.setContentHandler(SaxParser);
parser.parse(url);
}
catch(IOException ioe) {
ioe.printStackTrace();
}
catch(SAXException saxe) {
saxe.printStackTrace();
}*/
}
public void characters(char[] ch, int start, int length) throws SAXException {
// if(length)
String temp = "";
for (int i = start; i < length; i++) {
temp = temp + ch[i];
}
temp = temp.trim();
data = temp;
// throw new java.lang.UnsupportedOperationException("Method characters() not yet implemented.");
}
public void endElement(String uri, String localName, String qName) throws SAXException {
if (localName.equalsIgnoreCase("JDBC")) {
// this.con.print();
this.setConnect(this.name, con);
} else if (localName.equalsIgnoreCase("CLASS")) {
this.con.setClass(data);
} else if (localName.equalsIgnoreCase("URL")) {
this.con.setURL(data);
} else if (localName.equalsIgnoreCase("USER")) {
this.con.setUser(data);
} else if (localName.equalsIgnoreCase("PASSWORD")) {
this.con.setPassword(data);
}
}
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (attributes.getValue("name") != null) {
con = new ConnectControl();
this.name = attributes.getValue("name");
}
}
public ConnectManager getConnect(String name) {
return (ConnectManager) this.blackBox.get(name);
}
public void setConnect(String key, ConnectManager connectMa) {
this.blackBox.put(key, connectMa);
}
}
package com.csc.library.database;
import java.rmi.RemoteException;
/**
* @author raisara
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public interface Connectable {
public boolean next() throws RemoteException;
public String getString(String field) throws RemoteException;
public boolean isEmpty() throws RemoteException;
}
package com.csc.library.database;
import java.sql.Connection;
import javax.naming.Context;
import javax.sql.DataSource;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.session.MyContext;
import com.csc.library.utilities.MyLog;
public class ConnectionPoolManager {
/**
* Method Pool create a new connection pool
*/
public ConnectionPoolManager() {
System.err.println("DBUtil instance created.");
}
/**
* Method getConnection.
* @return Connection New connection from the pool
*/
public Connection getConnection(String dbName) {
Connection conn = null;
String dsName = new InitialEnvironment(dbName).getValue("datasource-name");
try {
Context ic = new MyContext().getInitialContext();
DataSource ds = (DataSource) ic.lookup(dsName);
conn=ds.getConnection();
}
catch (Exception e) {
MyLog.error(this, e);
}
return conn;
}
}
package com.csc.library.database;
public class ConnectionReaper extends Thread {
private ConnectionPools pool;
private final long delay=300000;
ConnectionReaper(ConnectionPools pool) {
this.pool=pool;
}
public void run() {
while(true) {
try {
sleep(delay);
} catch( InterruptedException e) { }
pool.reapConnections();
}
}
}
package com.csc.library.database;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;
/**
*
* @author Dragonfire
*
*/
public class CscStatement implements Statement {
private Statement statment;
private CscConnection conn=null;
private ArrayList<ResultSet> resultset=new ArrayList<ResultSet>();
private boolean close=false;
private long createTime=0;
public CscStatement(Statement stm,long createtime) {
this.statment=stm;
this.createTime=createtime;
// this.isclose=false;
}
public void addBatch(String sql) throws SQLException {
this.statment.addBatch(sql);
}
public void cancel() throws SQLException {
this.statment.cancel();
}
public void clearBatch() throws SQLException {
this.statment.clearBatch();
}
public void clearWarnings() throws SQLException {
this.statment.clearWarnings();
}
public void close() throws SQLException {
if(this.statment!=null){
this.close=true;
this.closeResultSet();
this.statment.close();
if(conn!=null){
this.conn.getStm().remove(this);
}
this.statment=null;
}
}
public boolean execute(String sql) throws SQLException {
return this.statment.execute(sql);
}
public boolean execute(String sql, int autoGeneratedKeys)
throws SQLException {
return this.statment.execute(sql, autoGeneratedKeys);
}
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
return this.statment.execute(sql, columnIndexes);
}
public boolean execute(String sql, String[] columnNames)
throws SQLException {
return this.statment.execute(sql, columnNames);
}
public int[] executeBatch() throws SQLException {
return this.statment.executeBatch();
}
public ResultSet executeQuery(String sql) throws SQLException {
ResultSet rs= this.statment.executeQuery(sql);
this.resultset.add(rs);
return rs;
}
public int executeUpdate(String sql) throws SQLException {
return this.statment.executeUpdate(sql);
}
public int executeUpdate(String sql, int autoGeneratedKeys)
throws SQLException {
return this.statment.executeUpdate(sql, autoGeneratedKeys);
}
public int executeUpdate(String sql, int[] columnIndexes)
throws SQLException {
return this.statment.executeUpdate(sql, columnIndexes);
}
public int executeUpdate(String sql, String[] columnNames)
throws SQLException {
return this.statment.executeUpdate(sql, columnNames);
}
public Connection getConnection() throws SQLException {
return this.statment.getConnection();
}
public int getFetchDirection() throws SQLException {
return this.statment.getFetchDirection();
}
public int getFetchSize() throws SQLException {
return this.statment.getFetchSize();
}
public ResultSet getGeneratedKeys() throws SQLException {
ResultSet rs=this.statment.getGeneratedKeys();
this.resultset.add(rs);
return rs;
}
public int getMaxFieldSize() throws SQLException {
return this.statment.getMaxFieldSize();
}
public int getMaxRows() throws SQLException {
return this.statment.getMaxRows();
}
public boolean getMoreResults() throws SQLException {
return this.statment.getMoreResults();
}
public boolean getMoreResults(int current) throws SQLException {
return this.statment.getMoreResults(current);
}
public int getQueryTimeout() throws SQLException {
return this.statment.getQueryTimeout();
}
public ResultSet getResultSet() throws SQLException {
ResultSet rs=this.statment.getResultSet();
this.resultset.add(rs);
return rs;
}
public int getResultSetConcurrency() throws SQLException {
return this.statment.getResultSetConcurrency();
}
public int getResultSetHoldability() throws SQLException {
return this.statment.getResultSetHoldability();
}
public int getResultSetType() throws SQLException {
return this.statment.getResultSetType();
}
public int getUpdateCount() throws SQLException {
return this.statment.getUpdateCount();
}
public SQLWarning getWarnings() throws SQLException {
return this.statment.getWarnings();
}
public void setCursorName(String name) throws SQLException {
this.statment.setCursorName(name);
}
public void setEscapeProcessing(boolean enable) throws SQLException {
this.setEscapeProcessing(enable);
}
public void setFetchDirection(int direction) throws SQLException {
this.statment.setFetchDirection(direction);
}
public void setFetchSize(int rows) throws SQLException {
this.statment.setFetchSize(rows);
}
public void setMaxFieldSize(int max) throws SQLException {
this.statment.setMaxFieldSize(max);
}
public void setMaxRows(int max) throws SQLException {
this.statment.setMaxRows(max);
}
public void setQueryTimeout(int seconds) throws SQLException {
this.statment.setQueryTimeout(seconds);
}
public boolean isClose() {
return close;
}
public void setClose(boolean isclose) {
this.close = isclose;
}
private void closeResultSet(){
try{
if(this.resultset.size()>0){
for(int i=0;i<this.resultset.size();i++){
ResultSet rs=(ResultSet) this.resultset.get(i);
if(rs!=null){
rs.close();
resultset.remove(rs);
}
}
}
}catch(Exception ex){}
}
@Override
protected void finalize() throws Throwable {
this.close();
}
public boolean isBefore(long starttime){
if((starttime==0||this.createTime==starttime)&&this.conn.getStarttime()!=this.conn.getLasttime()){
//if((starttime==0||this.createTime<starttime)&&this.conn.getStarttime()!=this.conn.getLasttime()){
return true;
}
return false;
}
public CscConnection getCscConnection() {
return conn;
}
public void setCscConnection(CscConnection conn) {
this.conn = conn;
}
public <T> T unwrap(Class<T> iface) throws SQLException {
// TODO Auto-generated method stub
return null;
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
// TODO Auto-generated method stub
return false;
}
public boolean isClosed() throws SQLException {
return this.close;
}
public void setPoolable(boolean poolable) throws SQLException {
// TODO Auto-generated method stub
}
public boolean isPoolable() throws SQLException {
// TODO Auto-generated method stub
return false;
}
}
/*
* Created on 13 ¡.¾. 2550
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.csc.library.database;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import com.csc.library.utilities.UProfile;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class CscTransaction {
private boolean rollback = false;
private HashMap<String, CscConnection> connection = new HashMap<String, CscConnection>();
public int beginTransactionKey = 0;
public String userKey = "";
public void rollback() throws SQLException {
for (Iterator<String> it = connection.keySet().iterator(); it.hasNext();) {
CscConnection con = connection.get(it.next());
con.rollback();
con.setCscTransaction(null);
con.close();
}
connection.clear();
this.rollback = true;
}
public void commit() throws SQLException {
for (Iterator<String> it = connection.keySet().iterator(); it.hasNext();) {
CscConnection con = connection.get(it.next());
// con.commit();
con.setCscTransaction(null);
con.close();
}
connection.clear();
}
public void close() throws SQLException {
for (Iterator<String> it = connection.keySet().iterator(); it.hasNext();) {
CscConnection con = connection.get(it.next());
con.setCscTransaction(null);
con.close();
}
connection.clear();
}
// comment by pas à¹×èͧ¨Ò¡ 1 process 1 connection ·ÓãËéäÁèµéͧ stamp actiontime
// public void setActionTime() {
// for (Iterator<String> it = connection.keySet().iterator(); it.hasNext();) {
// CscConnection con = connection.get(it.next());
// con.setStarttime(System.currentTimeMillis());
// }
// }
public CscConnection getConnection(String dbName, Object userKey) throws SQLException {
CscConnection con = null;
if (!this.isRollback()){
String db = dbName.toLowerCase();
if (connection.containsKey(db)) {
con = connection.get(db);
if(con==null||(con!=null&&con.isClosed())){/** ¶éÒ connection ·Õè close ÃÐËÇèÒ§¡Ò÷ӧҹãËé·Ó¡Òà remove ·Ôé§ **/
if(con!=null){
con.closeAll();/**close connection ·Ôé§ä»¡Ã³Õ·ÕèÁѹäÁèÊÒÁÒöãªé§Ò¹connection ¹Ñé¹ä´é**/
con=null;
}
this.connection.remove(db);
con=getConnection(dbName,userKey);
}
} else {
/**
* ¡Ã³Õ·ÕèÁÕ¡ÒÃÊÃéÒ§ connection ãËÁèãËéä»get ¨Ò¡ connectDB áÅéǶéÒà»ç¹ Connection process ¨Ð·Ó¡Òà setProcessid à¢éÒä»ÍÕ¡¤ÃÑé§ËÒ¡àÃÕ¡
* StaticProperties.myConnection.getConnection(db,userKey) ¨Ðà¡Ô´ recursive ËÒ¡äÁèset process id ¢Í§ process ÁռšѺ¡Ò÷ӧҹ¢Í§ connectionPools
*/
con = (CscConnection) StaticProperties.myConnection.getConnection(db);
synchronized(con) {
UProfile up=(UProfile) userKey;
if(up.getProcessid().length()>0){
con.setProcessid(up.getProcessid());
}
this.connection.put(db, con);
con.setAutoCommit(false);
if(con.getTransactionIsolation()!=Connection.TRANSACTION_READ_UNCOMMITTED){
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
}
con.setUses(true);
con.setCscTransaction(this);
}
}
}
if(con!=null){
con.setLasttime(System.currentTimeMillis());
}
return con;
}
public boolean isRollback() {
return this.rollback;
}
public int getBeginTransactionKey() {
return beginTransactionKey;
}
public void setBeginTransactionKey(int beginTransactionKey) {
this.beginTransactionKey = beginTransactionKey;
}
public String getUserKey() {
return userKey;
}
public void setUserKey(String userKey) {
this.userKey = userKey;
}
}
package com.csc.library.database;
import java.util.Vector;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.InitialInquiry;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.UProfile;
/**
* @author Administrator
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class DeleteRecord {
private DbInquiry di;
private UProfile up=null;
private String tableName, filter,groupField;
public DeleteRecord(UProfile up,String tableName, String filter) {
this.up = up;
this.tableName = tableName;
this.filter = filter;
this.initInquiry();
}
public DeleteRecord(DbInquiry di) {
this.di = di;
}
private void initInquiry() {
try {
di = new InitialInquiry(up).getDbInquiry();
di.initMyTable(tableName, filter, "");
Vector v=di.getCurrentDbRecord().getAllKey();
String fieldList="";
for(int i=0;i<v.size();i++){
if(fieldList.length()==0)
fieldList+=(String)v.elementAt(i);
else fieldList+=","+(String)v.elementAt(i);
}
di.setColumn(fieldList);
} catch (Exception e) {
MyLog.error(this, e);
}
}
public void process() {
try {
di.refresh();
while (di.next()) {
di.getCurrentDbRecord().cloneRecord(true).delete();
}
} catch (Exception e) {
MyLog.error(this, e);
}
}
}
package com.csc.library.database;
public interface FConditionManager {
public boolean check(MyField fm);
}
package com.csc.library.database;
public interface FSecurityManager{
public boolean get(FieldManager mf);
public boolean set(FieldManager mf);
}
package com.csc.library.database;
import java.rmi.RemoteException;
import java.text.DecimalFormat;
import java.util.Calendar;
import com.csc.library.autonumber.InitialAutoNumber;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.UProfile;
public class FieldAutoNumber extends FieldString {
private String autoCode = "";
private int currNumber = 0;
public FieldAutoNumber(String name, String code) {
super(name);
this.autoCode = code;
this.setDefault("0");
this.setDefault();
this._DEFAULT_DEFAULTVALUE="0";
}
public FieldAutoNumber(String name, String description, String code) {
super(name, description);
this.autoCode = code;
this.setDefault("0");
this.setDefault();
this._DEFAULT_DEFAULTVALUE="0";
}
public FieldAutoNumber(String name, int width, int decimal, String description) {
super(name, width, decimal, description);
this.setDefault("0");
this.setDefault();
this._DEFAULT_DEFAULTVALUE="0";
// this.type = "Double";
}
public FieldAutoNumber(String name, Integer width, Integer decimal, String description) {
this(name, width.intValue(), decimal.intValue(), description);
this.setDefault("0");
this._DEFAULT_DEFAULTVALUE="0";
}
public FieldAutoNumber(String name, int width, String description, String code) {
super(name, width, description);
this.autoCode = code;
this.setDefault("0");
this.setDefault();
this._DEFAULT_DEFAULTVALUE="0";
}
public FieldAutoNumber(String name, int width, int decimal, String description, String code) {
super(name, width, decimal, description);
this.autoCode = code;
this.setDefault("0");
this.setDefault();
this._DEFAULT_DEFAULTVALUE="0";
this.setProperty("oldvalue", "0");
}
public String insAutoNumber() {
try {
String returnValue="1";
String table=this.getProperty("table");
String initv=this.getProperty("init");
if (table.indexOf("$")!=-1) {
table=swapFormat(table);
}
String format=this.getProperty("format");
String reset_char1=this.getProperty("reset_char1");
String reset_char2=this.getProperty("reset_char2");
if(this.getName().equalsIgnoreCase("RUNNO")){
table=this.getParent().getTableName().toUpperCase()+"_RUNNO";
}
if(reset_char1!=null && reset_char1.length()>0 && reset_char2!=null &&reset_char2.length()>0){
returnValue=InitialAutoNumber.getAutoNumber((UProfile)this.getUProfile().clone(),table,format,this.parent,initv,reset_char1,reset_char2);
}else{
returnValue=InitialAutoNumber.getAutoNumber((UProfile)this.getUProfile().clone(),table,format,this.parent,initv);
}
return returnValue;
} catch (Exception ex) {
ex.printStackTrace();
return "1";
}
}
public String getFieldCreate() {
return this.getName() + " DECIMAL(" + String.valueOf(this.getWidth()) + "," + String.valueOf(this.getDecimal()) + ")";
}
private String swapFormat(String sform){
String data="";
/***
* ٻẺ =YYYY$F{FIELDNAME,2}-000000
* $F{FIEDNAME,digit} field in table
* $D{DECIMAL VALUE} fix decimal value
* $U{keyname,digit} keyname in UProfile
*/
String rp=sform.substring(sform.indexOf("$"),sform.lastIndexOf("}")+1);
if(sform.indexOf("$")!=-1){
if(rp.indexOf(",")>-1){
String fieldName=rp.substring(3,rp.indexOf(","));
int maxlen=0;
try{
maxlen=Integer.parseInt(rp.substring(rp.indexOf(",")+1,rp.length()-1));
}catch(Exception ex){
maxlen=0;
}
try {
if(sform.indexOf("$U")==-1)
data=sform.replace(rp,parent.getString(fieldName).substring(0,maxlen));
else
data=sform.replace(rp,this.getUProfile().get(fieldName).substring(0,maxlen));
} catch (Exception e) {
data=sform.replace(rp,"");
}
}else{
String fieldName=rp.substring(3,rp.indexOf("}"));
try {
data=sform.replace(rp,parent.getString(fieldName));
} catch (Exception e) {
data=sform.replace(rp,"");
}
}
}else{
String fieldName=rp.substring(3,rp.indexOf("}"));
data=sform.replace(rp,fieldName);
}
return data;
}
/***
* @param x
* @Override ͧҡ óշ field autonumber ͧա checkvaild жǨзԴѭҼԴ format ö setvalue
* 仵Ǩͺrecordcmp0
*
*/
@Override
protected boolean setValue(String x) {
boolean check = false;
String tmpx = null;
if (x != null){
x=x.trim();
tmpx = new String(x);
} else tmpx = "";
if (this.isWorking()) {
if ((this.sf == null)||(this.sf.set(this))){
this.oValue=this.value;
this.value= tmpx;
if (!this.getValue().equals(this.getOriginalData())) {
this.modified = true;
} else {
this.modified = false;
}
this.refreshEffectField();
check = this.isedit;
this.setEdit(check);
} else {
this.setErrmess("You don't have permission to set up Value.");
this.setEdit(false);
}
}
return check;
}
}
package com.csc.library.database;
import java.math.BigDecimal;
/**
* @author Administrator
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class FieldBigDecimal extends FieldDouble {
public FieldBigDecimal(String name, int width, int decimal, String description) {
super(name, width, decimal, description);
this.setDefault("0");
this.setDefault();
this._DEFAULT_DEFAULTVALUE="0";
}
public FieldBigDecimal(String name, Integer width, Integer decimal, String description) {
this(name, width.intValue(), decimal.intValue(), description);
}
/*
public boolean set(String x) {
if (x.trim().length() == 0) {
return this.set(0);
} else if (x.indexOf(".") == -1) {
return this.set(new BigDecimal(x));
} else {
return this.set(new BigDecimal(x));
}
}
*/
public String getSaveString() {
if(this.isEncrypt())
return this.encryption();
else
return String.valueOf(this.getBigDecimal());
}
}
package com.csc.library.database;
public class FieldBlob extends MyField{
public FieldBlob(String name) {
super(name);
// this.type = "String";
}
public FieldBlob(String name, String description) {
super(name, description);
// this.type = "String";
}
public FieldBlob(String name, int width, String description) {
super(name, width, description);
// this.type = "String";
}
public FieldBlob(String name, int width, int decimal, String description) {
super(name, width, decimal, description);
// this.type = "String";
}
public FieldBlob(String name, Integer width, Integer decimal, String description) {
this(name, width.intValue(), decimal.intValue(), description);
}
/**
* Add Encryption
*/
public String getCompareString() {
return this.getName() + "='" + this.encryption() + "'";
}
public String getValueString() {
String buff = "";
if (this.getString() != null) {
buff = new String(this.getString());
// buff = new String(this.getString().getBytes(), 0);
}
return "'" + buff + "'";
}
public String getFieldCreate() {
return this.getName() + " VARCHAR(" + String.valueOf(this.getWidth()) + ")";
}
}
package com.csc.library.database;
public class FieldBoolean extends MyField {
public FieldBoolean(String name) {
super(name);
this.setDefault("true");
// this.type = "Boolean";
}
public FieldBoolean(String name, String description) {
super(name, description);
this.setDefault("true");
// this.type = "Boolean";
}
public FieldBoolean(String name, int width, String description) {
super(name, width, description);
this.setDefault("true");
// this.type = "Boolean";
}
public FieldBoolean(String name, int width, int decimal, String description) {
super(name, width, decimal, description);
this.setDefault("true");
// this.type = "Boolean";
}
public FieldBoolean(String name, Integer width, Integer decimal, String description) {
this(name, width.intValue(), decimal.intValue(), description);
}
public String getCompareString() {
return this.getName() + "=" + this.getValueString();
}
public String getValueString() {
return "'" + this.getString() + "'";
}
public String getFieldCreate() {
return this.getName() + " CHAR";
}
public String getSaveString() {
if(this.isEncrypt())
return this.encryption();
else
return String.valueOf(this.getBoolean());
}
}
package com.csc.library.database;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
public class FieldDate extends MyField {
private int d = 0;
private int m = 0;
private int y = 0;
String dateFormat = "DMY"; // DATE FORMAT FOR INPUT DATE DATA
public FieldDate(String name) {
super(name);
this.setDefault(defaultvalue);
this.setDefault();
// this.type = "Date";
}
public FieldDate(String name, String description) {
super(name, description);
this.setDefault(defaultvalue);
this.setDefault();
// this.type = "Date";
}
public FieldDate(String name, int width, String description) {
super(name, width, description);
this.setDefault(defaultvalue);
this.setDefault();
// this.type = "Date";
}
public FieldDate(String name, int width, int decimal, String description) {
super(name, width, decimal, description);
this.setDefault(defaultvalue);
this.setDefault();
// this.type = "Date";
}
public FieldDate(String name, Integer width, Integer decimal, String description) {
this(name, width.intValue(), decimal.intValue(), description);
}
public String getCompareString() {
return this.getName()+"='"+this.getcscCalendar().getYYYYMMDD()+"'";
//return new GenCompareString().generate(this.getName(), this);
}
/*public String getString() {
if (this.getValue().equalsIgnoreCase(" ")) {
return "1900-01-01";
} else if (this.getValue() == null) {
return "1900-01-01";
} else {
return this.getValue().substring(8, 10) + "/" + this.getValue().substring(5, 7) + "/" + this.getValue().substring(0, 4);
}
}*/
public String getValueString() {
return new GenCompareString().generate(this);
}
public String getDDMMYYYY() {
return this.getValue().substring(8, 10) + "/" + this.getValue().substring(5, 7) + "/" + this.getValue().substring(0, 4);
}
public boolean set(CscCalendar d) {
//System.out.println("*********** 01 "+d.getTimestamp());
String buff;
buff = this.dateFormat;
this.dateFormat = "YMD";
this.setValue(d.getTimestamp().toString().substring(0, 10));
this.dateFormat = buff;
return true;
}
public boolean set(Timestamp x) {
//System.out.println("*********** 02 "+x);
String buff;
buff = this.dateFormat;
this.dateFormat = "YMD";
this.setValue(x.toString().substring(0, 10));
this.dateFormat = buff;
return true;
}
public boolean set(java.sql.Date x) {
String buff;
buff = this.dateFormat;
this.dateFormat = "YMD";
this.setValue(x.toString().substring(0, 10));
this.dateFormat = buff;
return true;
}
/************* ball edit **************/
protected boolean setValue(String x1) {
String x;
if (this.isFormat &&
((this.property.get("format") != null &&
!this.property.get("format").equals(""))
|| (this.user.get("formatdate") != null &&
!this.user.get("formatdate").equals("")))) {
x = x1;
} else {
x = this.checkData(x1);
}
//System.out.println("Data In field date " + x);
if (x.trim().length() > 0) {
try {
super.setValue(x);
} catch (Exception e) {
boolean temp=this.isFormat;
this.isFormat=false;
super.setValue(x);
this.isFormat=temp;
MyLog.warn(this, this.getUProfile(), this.getName()+"------> "+e);
MyLog.warn(this, this.getUProfile(), e);
}
return true;
} else {
String buff;
buff = this.dateFormat;
this.dateFormat = "YMD";
x = this.checkData(x1);
this.dateFormat = buff;
if (x.trim().length() > 0) {
super.setValue(x);
return true;
} else {
if(this.defaultvalue.length()>0){//check conditionóշդ null ͪͧҧ default value
super.setValue(this.defaultvalue);//edit by pas 20130312 add defaultvalue
}else{
super.setValue("1900-01-01");//edit by pas 20130312 add default 1900-01-01
}
return false;
}
}
}
/***********************************/
public CscCalendar getcscCalendar() {
CscCalendar d;
d = new CscCalendar(this.getValue());
return d;
}
public void setOriginal(String x) {
try {
// super.setOriginal(x.substring(0, 10));
if (x==null) {
x = "1900-01-01";
}else if (x.trim().equals("")) {
x = "1900-01-01";
}
super.setOriginal(x);
} catch (RuntimeException e) {
MyLog.warn(this, this.getUProfile(), this.getName()+"------> "+e);
MyLog.warn(this, this.getUProfile(), e);
super.setOriginal(defaultvalue);
}
}
private String checkData(String s) {
String n = "";
String s1 = "";
int yearFormat = 2;
int maxnumber = 6;
int j = 0;
this.d = 0;
this.m = 0;
this.y = 0;
boolean error = false;
if (yearFormat == 4) {
maxnumber = 8;
}
for (int i = 0; i < s.length() && !error && j < 3; i++) {
if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
s1 += String.valueOf(s.charAt(i));
if (s1.length() == maxnumber) {
for (int p = 0; !error && j < 3; j++) {
if (dateFormat.charAt(j) == 'D') {
error = checkDMY(dateFormat.charAt(j), s.substring(p, p + 2));
p += 2;
} else {
if (dateFormat.charAt(j) == 'M') {
error = checkDMY(dateFormat.charAt(j), s.substring(p, p + 2));
p += 2;
} else {
error = checkDMY(dateFormat.charAt(j), s.substring(p, p + yearFormat));
p += yearFormat;
}
}
}
}
} else {
if (s1.trim().length() > 0) {
error = checkDMY(dateFormat.charAt(j), s1);
} else {
MyLog.warn(this, this.getUProfile(), this.getName()+" Date Format Error!");
error = true;
}
s1 = "";
j++;
}
};
if (j >= 2 && !error) {
if (j == 2) {
error = checkDMY(dateFormat.charAt(j), s1);
}
if (!error) {
CscCalendar date = new CscCalendar(y, m, d);
s1 = date.getTimestamp().toString().substring(0, 10);
// this.logger.info(s1);
return s1;
}
}
return "";
}
private boolean checkDMY(char type, String s1) {
int chk;
boolean error = false;
if (type == 'D') {
chk = Integer.valueOf(s1).intValue();
if (chk < 1 || chk > 31) {
error = true;
} else {
d = chk;
}
} else {
if (type == 'M') {
chk = Integer.valueOf(s1).intValue();
if (chk < 1 || chk > 12) {
error = true;
} else {
m = chk;
}
} else {
chk = Integer.valueOf(s1).intValue();
if (chk < 1900) {
if (chk > 100) {
error = true;
} else {
if (chk <= 20) {
chk += 2000;
} else {
chk += 1900;
}
}
}
y = chk;
}
}
return error;
}
public String getFieldCreate() {
return this.getName() + " DATE";
}
public String getSaveString() {
if(this.isEncrypt())
return this.encryption();
else
return String.valueOf(this.getDate());
}
public String getString() {
String value = super.getString();
//if (this.isFormat) {
return value;
//} else {
//GenCompareString genCom = new GenCompareString();
//value = genCom.dateString(new CscCalendar(value));
//return value;
//}
}
protected String getFormatValue(String format, String value) {
String rFormat=format.substring(0,format.indexOf(":"));
String local=format.substring(format.indexOf(":")+1,format.length());
SimpleDateFormat df = null;
if(local.equalsIgnoreCase("ENG"))
df=new SimpleDateFormat(rFormat, Locale.ENGLISH);
else
df=new SimpleDateFormat(rFormat, Locale.getDefault());
CscCalendar cs = new CscCalendar(value);
String data = df.format(new Date(cs.getTime()));
return data;
}
protected String getParseValue(String format, String value) {
try {
String rFormat=format.substring(0,format.indexOf(":"));
String local=format.substring(format.indexOf(":")+1,format.length());
SimpleDateFormat df = null;
if(local.equalsIgnoreCase("ENG"))
df=new SimpleDateFormat(rFormat, Locale.ENGLISH);
else
df=new SimpleDateFormat(rFormat, Locale.getDefault());
Date date = df.parse(value);
CscCalendar cs = new CscCalendar(date);
return cs.getYYYYMMDD();
} catch (ParseException e) {
MyLog.warn(this, this.getUProfile(), this.getName()+"------> "+e);
}
return value;
}
public String getDefault() {
if(this.defaultvalue==null){
this.defaultvalue=new CscCalendar().getYYYYMMDD();
}else{
this.defaultvalue=new CscCalendar(defaultvalue).getYYYYMMDD();
}
return this.defaultvalue;
}
}
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