public class UtilScript
extends com.accela.aa.emse.dom.service.BaseAAScript
implements java.io.Serializable, com.accela.aa.emse.dom.service.UtilScriptService
Accela Automation
File: UtilScript.java
Accela, Inc.
Copyright (C): 2001-2014
Description: EMSE script util class.
Notes:
$Id: UtilScript.java 270462 2014-04-28 10:05:58Z ..\rain.wang $
Revision History:
Feb 24, 2004, Joey Lv Initial Version.
Oct 30, 2004, Sunny Wu Added method toObjectArray(Object obj).
12/22/04 Edwin Lin solve HTTP Authentication problem.
07/19/2005 Edwin Lin Add the newArrayList()
03/21/2006 Yan Xiao Added two new methodd named writeToFile/ftpUpload for the requirement 06ACT-00580 - AA-CFW & RC Interface.
| Constructor and Description |
|---|
UtilScript()
UtilScript Constructor.
|
UtilScript(java.lang.String serviceProviderCode,
java.lang.String auditID,
com.accela.aa.emse.dom.service.CachedService cachedService)
UtilScript Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
add(double firstValue,
double secondValue)
Returns a double whose value is (firstValue +
secondValue).
|
ScriptResult |
batchUpdate(java.lang.String dataSourceName,
java.lang.String sqlString,
java.util.List<java.lang.Object[]> parameters)
Batch Insert, delete or update custom DB directly in EMSE script
To use this API, you need to follow below steps:
1.
|
int |
compare(double firstValue,
double secondValue)
Compares the firstValue with the secondeValue.
|
java.util.Date |
dateDiff(java.util.Date date,
java.lang.String intervalType,
int interval)
Date diff.
|
ScriptResult |
deepClone(java.lang.Object srcObject)
Do deep object clone.
|
void |
deleteFile(java.lang.String fileName)
Delete a special file.
|
double |
divide(double dividend,
double divisor)
Returns a double whose value is (dividend /
divisor).
|
double |
divide(double dividend,
double divisor,
int scale)
Returns a double whose value is (dividend /
divisor).
|
java.lang.Double |
doubleFormat(java.lang.Double amount)
Format double to keep two decimal digits .
|
java.lang.String |
formatDate(java.util.Date date,
java.lang.String format)
Format date.
|
java.lang.String |
formatFee(double fee)
Format double to keep two decimal digits.
|
static ScriptResult |
ftpUpload(java.lang.String site,
java.lang.String port,
java.lang.String username,
java.lang.String password,
java.lang.String folder,
java.io.File file)
Method to upload one file to a ftp site.
|
java.util.Calendar |
getCalendar()
Gets the calendar.
|
java.lang.String |
getCustomContentByType(java.lang.String contentType,
java.util.Hashtable parameters)
replace parameter for Email.
|
java.lang.String |
getCustomContentByType4InspScheAfter(java.lang.String contentType,
com.accela.aa.inspection.inspection.InspectionModel inspection,
com.accela.aa.aamain.cap.CapIDModel capIdModel,
java.util.Hashtable<java.lang.String,java.lang.String> parameters)
Replace parameter for the event InspectionScheduleAfter.
|
java.lang.String |
getCustomDescAsSubjectByType(java.lang.String contentType,
java.util.Hashtable parameters)
Get custom desc As subject by contentType.
|
ScriptResult |
getDeadlineDay(java.util.Date currectDate,
java.util.Date registrationDate,
java.lang.String deadline)
get deadline's day.
|
com.accela.util.AVLogger |
getLogger()
Utility to return Utility logger in order to allow scripts to
log information into server.log on the application server
|
java.lang.String |
getValueFromXML(java.lang.String tag,
java.lang.String registerResultXML)
match value by teg from string.
|
ScriptResult |
httpPost(java.lang.String url,
java.lang.String parameters)
httpPost method.
|
ScriptResult |
httpPost(java.lang.String url,
java.lang.String userName,
java.lang.String passWord)
httpPost for HTTP Authentication.
|
ScriptResult |
httpPost(java.lang.String url,
java.lang.String parameters,
java.lang.String userName,
java.lang.String passWord)
httpPost for HTTP Authentication.
|
ScriptResult |
httpPostToSoapWebService(java.lang.String url,
java.lang.String parameters,
java.lang.String userName,
java.lang.String passWord,
java.lang.String sSoapAction)
httpPostToSoapWebService for HTTP Authentication.
|
boolean |
instanceOfString(java.lang.Object obj)
Check to see if the object is data model.
|
static void |
main(java.lang.String[] ares)
Main method.
|
double |
multiply(double firstValue,
double secondValue)
Returns a double whose value is (firstValue *
secondValue).
|
java.util.ArrayList |
newArrayList()
Utility to construct a new java.util.ArrayList
|
java.util.HashMap |
newHashMap()
Utility to construct a new java.util.HashMap
|
java.util.Hashtable |
newHashtable()
create an instance for Hashtable.
|
com.accela.aa.util.QueryFormat |
newQueryFormat()
Utility to construct a new QueryFormat.
|
java.lang.StringBuffer |
newStringBuffer()
Utility to construct a new java.lang.StringBuffer
|
java.util.Date |
now()
Now.
|
java.lang.String |
numberFormat(java.lang.Double number)
format number.
|
java.util.Date |
parseDate(java.lang.String dateString)
Takes a string formatted as a date.
|
java.lang.Double |
parseDouble(java.lang.String value)
Parses the double.
|
java.lang.Integer |
parseInt(java.lang.String value)
Parses the int.
|
java.lang.Long |
parseLong(java.lang.String value)
Parses the long.
|
double |
round(double d,
int scale)
Returns a double whose value is round to scale.
|
ScriptResult |
select(java.lang.String dataSourceName,
java.lang.String sqlString,
java.lang.Object[] parameters)
Select in custom DB directly in EMSE script
To use this API, you need to follow below steps:
1.
|
double |
subtract(double minuend,
double subtrahend)
Returns a double whose value is (minuend -
subtrahend).
|
ScriptResult |
toObjectArray(java.lang.Object obj)
Convert to ObjectArray.
|
ScriptResult |
update(java.lang.String dataSourceName,
java.lang.String sqlString,
java.lang.Object[] parameters)
Insert, delete or update custom DB directly in EMSE script
To use this API, you need to follow below steps:
1.
|
java.io.File |
writeToFile(java.lang.Object obj,
java.lang.String fileName)
Method to write to file.
|
public UtilScript(java.lang.String serviceProviderCode,
java.lang.String auditID,
com.accela.aa.emse.dom.service.CachedService cachedService)
throws com.accela.aa.exception.AAException
serviceProviderCode - agency codeauditID - the caller idcom.accela.aa.exception.AAException - The AA exceptionpublic UtilScript()
throws com.accela.aa.exception.AAException
com.accela.aa.exception.AAException - The AA exceptionpublic ScriptResult httpPost(java.lang.String url, java.lang.String parameters)
com.accela.aa.emse.dom.service.UtilScriptServicehttpPost in interface com.accela.aa.emse.dom.service.UtilScriptServiceurl - url addressparameters - parameterspublic ScriptResult httpPost(java.lang.String url, java.lang.String userName, java.lang.String passWord)
com.accela.aa.emse.dom.service.UtilScriptServicehttpPost in interface com.accela.aa.emse.dom.service.UtilScriptServiceurl - url addressuserName - the user namepassWord - the passwordpublic ScriptResult httpPost(java.lang.String url, java.lang.String parameters, java.lang.String userName, java.lang.String passWord)
com.accela.aa.emse.dom.service.UtilScriptServicehttpPost in interface com.accela.aa.emse.dom.service.UtilScriptServiceurl - url addressparameters - parametersuserName - the user namepassWord - the passwordpublic ScriptResult httpPostToSoapWebService(java.lang.String url, java.lang.String parameters, java.lang.String userName, java.lang.String passWord, java.lang.String sSoapAction)
com.accela.aa.emse.dom.service.UtilScriptServicehttpPostToSoapWebService in interface com.accela.aa.emse.dom.service.UtilScriptServiceurl - the urlparameters - the parametersuserName - the user namepassWord - the pass wordsSoapAction - the s soap actionpublic ScriptResult toObjectArray(java.lang.Object obj)
com.accela.aa.emse.dom.service.UtilScriptServicetoObjectArray in interface com.accela.aa.emse.dom.service.UtilScriptServiceobj - Objectpublic java.util.HashMap newHashMap()
com.accela.aa.emse.dom.service.UtilScriptServicenewHashMap in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.util.Hashtable newHashtable()
com.accela.aa.emse.dom.service.UtilScriptServicenewHashtable in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.lang.String getCustomContentByType(java.lang.String contentType,
java.util.Hashtable parameters)
com.accela.aa.emse.dom.service.UtilScriptServicegetCustomContentByType in interface com.accela.aa.emse.dom.service.UtilScriptServicecontentType - the content typeparameters - the parameterspublic java.lang.String getCustomDescAsSubjectByType(java.lang.String contentType,
java.util.Hashtable parameters)
contentType - parameters - public java.lang.String getCustomContentByType4InspScheAfter(java.lang.String contentType,
com.accela.aa.inspection.inspection.InspectionModel inspection,
com.accela.aa.aamain.cap.CapIDModel capIdModel,
java.util.Hashtable<java.lang.String,java.lang.String> parameters)
contentType - Content Type.inspection - Inspection Model.capIdModel - CapIDModel.parameters - variables.public java.util.ArrayList newArrayList()
newArrayList in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.lang.StringBuffer newStringBuffer()
com.accela.aa.emse.dom.service.UtilScriptServicenewStringBuffer in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic com.accela.aa.util.QueryFormat newQueryFormat()
com.accela.aa.emse.dom.service.UtilScriptServicenewQueryFormat in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.util.Calendar getCalendar()
com.accela.aa.emse.dom.service.UtilScriptServicegetCalendar in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.lang.String formatDate(java.util.Date date,
java.lang.String format)
com.accela.aa.emse.dom.service.UtilScriptServiceformatDate in interface com.accela.aa.emse.dom.service.UtilScriptServicedate - the dateformat - the formatpublic java.util.Date now()
com.accela.aa.emse.dom.service.UtilScriptServicenow in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.util.Date parseDate(java.lang.String dateString)
throws com.accela.aa.exception.AAException
com.accela.aa.emse.dom.service.UtilScriptServiceparseDate in interface com.accela.aa.emse.dom.service.UtilScriptServicedateString - the date stringcom.accela.aa.exception.AAException - the AA exceptionpublic java.util.Date dateDiff(java.util.Date date,
java.lang.String intervalType,
int interval)
com.accela.aa.emse.dom.service.UtilScriptServicedateDiff in interface com.accela.aa.emse.dom.service.UtilScriptServicedate - the dateintervalType - the interval typeinterval - the intervalpublic com.accela.util.AVLogger getLogger()
com.accela.aa.emse.dom.service.UtilScriptServicegetLogger in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic java.io.File writeToFile(java.lang.Object obj,
java.lang.String fileName)
com.accela.aa.emse.dom.service.UtilScriptServicewriteToFile in interface com.accela.aa.emse.dom.service.UtilScriptServiceobj - the objfileName - the file namepublic void deleteFile(java.lang.String fileName)
com.accela.aa.emse.dom.service.UtilScriptServicedeleteFile in interface com.accela.aa.emse.dom.service.UtilScriptServicefileName - the file namepublic static ScriptResult ftpUpload(java.lang.String site, java.lang.String port, java.lang.String username, java.lang.String password, java.lang.String folder, java.io.File file)
site - the siteport - the portusername - the usernamepassword - the passwordfolder - the folderfile - the filepublic boolean instanceOfString(java.lang.Object obj)
com.accela.aa.emse.dom.service.UtilScriptServiceinstanceOfString in interface com.accela.aa.emse.dom.service.UtilScriptServiceobj - the objpublic java.lang.String getValueFromXML(java.lang.String tag,
java.lang.String registerResultXML)
com.accela.aa.emse.dom.service.UtilScriptServicegetValueFromXML in interface com.accela.aa.emse.dom.service.UtilScriptServicetag - the tagregisterResultXML - the register result xmlpublic java.lang.String numberFormat(java.lang.Double number)
com.accela.aa.emse.dom.service.UtilScriptServicenumberFormat in interface com.accela.aa.emse.dom.service.UtilScriptServicenumber - the numberpublic java.lang.Integer parseInt(java.lang.String value)
com.accela.aa.emse.dom.service.UtilScriptServiceparseInt in interface com.accela.aa.emse.dom.service.UtilScriptServicevalue - the valuepublic java.lang.Long parseLong(java.lang.String value)
com.accela.aa.emse.dom.service.UtilScriptServiceparseLong in interface com.accela.aa.emse.dom.service.UtilScriptServicevalue - the valuepublic java.lang.Double parseDouble(java.lang.String value)
com.accela.aa.emse.dom.service.UtilScriptServiceparseDouble in interface com.accela.aa.emse.dom.service.UtilScriptServicevalue - the valuepublic ScriptResult getDeadlineDay(java.util.Date currectDate, java.util.Date registrationDate, java.lang.String deadline)
com.accela.aa.emse.dom.service.UtilScriptServicegetDeadlineDay in interface com.accela.aa.emse.dom.service.UtilScriptServicecurrectDate - the currect dateregistrationDate - the registration datedeadline - the deadlinepublic double subtract(double minuend,
double subtrahend)
com.accela.aa.emse.dom.service.UtilScriptServicesubtract in interface com.accela.aa.emse.dom.service.UtilScriptServiceminuend - minuend valuesubtrahend - subtrahend valuepublic double add(double firstValue,
double secondValue)
com.accela.aa.emse.dom.service.UtilScriptServiceadd in interface com.accela.aa.emse.dom.service.UtilScriptServicefirstValue - value to addsecondValue - value to addpublic double multiply(double firstValue,
double secondValue)
com.accela.aa.emse.dom.service.UtilScriptServicemultiply in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic double divide(double dividend,
double divisor,
int scale)
com.accela.aa.emse.dom.service.UtilScriptServicedivide in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic double divide(double dividend,
double divisor)
com.accela.aa.emse.dom.service.UtilScriptServicedivide in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic double round(double d,
int scale)
com.accela.aa.emse.dom.service.UtilScriptServiceround in interface com.accela.aa.emse.dom.service.UtilScriptServicepublic int compare(double firstValue,
double secondValue)
com.accela.aa.emse.dom.service.UtilScriptServicecompare in interface com.accela.aa.emse.dom.service.UtilScriptServicefirstValue - the first valuesecondValue - the second valuepublic java.lang.String formatFee(double fee)
com.accela.aa.emse.dom.service.UtilScriptServiceformatFee in interface com.accela.aa.emse.dom.service.UtilScriptServicefee - double to format.public java.lang.Double doubleFormat(java.lang.Double amount)
com.accela.aa.emse.dom.service.UtilScriptServicedoubleFormat in interface com.accela.aa.emse.dom.service.UtilScriptServiceamount - double to formatpublic ScriptResult deepClone(java.lang.Object srcObject)
deepClone in interface com.accela.aa.emse.dom.service.UtilScriptServicesrcObject - object will be cloned.public ScriptResult update(java.lang.String dataSourceName, java.lang.String sqlString, java.lang.Object[] parameters)
update in interface com.accela.aa.emse.dom.service.UtilScriptServicedataSourceName - Data Source NamesqlString - sql which hoped to executeparameters - parameters needed in sqlpublic ScriptResult batchUpdate(java.lang.String dataSourceName, java.lang.String sqlString, java.util.List<java.lang.Object[]> parameters)
batchUpdate in interface com.accela.aa.emse.dom.service.UtilScriptServicedataSourceName - Data Source NamesqlString - sql which hoped to executeparameters - List of parameters needed in sqlpublic ScriptResult select(java.lang.String dataSourceName, java.lang.String sqlString, java.lang.Object[] parameters)
select in interface com.accela.aa.emse.dom.service.UtilScriptServicedataSourceName - Data Source NamesqlString - sql which hoped to executeparameters - parameters needed in sqlpublic static void main(java.lang.String[] ares)
ares - the aresjava.lang.Exception