Package sk.iway.iwcm
Class DB
java.lang.Object
sk.iway.iwcm.DB
- Direct Known Subclasses:
DocDB,DocTreeDB,GroupsDB,HistoryDB,StatDB,TemplatesDB,UserGroupsDB
nadtrieda DB tried, ma zakladne uzitocne funkcie
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringProduces a string representation of a complete result setstatic voidstatic StringfilterEscaped(String escapedString) Deprecated.- use filterHtmlstatic StringfilterHtml(String data) Nahradi nebezpecne HTML znaky za entitystatic StringfixAiCiCol(String column) Add lower/unaccent(column) for case insensitive search in Oracle/PostgreSQLstatic StringfixAiCiValue(String value) Fix value for case insensitive search in Oracle/PostgreSQLstatic BooleangetBoolean(ResultSet rs, String colName) Vrati Boolean hodnotu z databazy, pricom korektne vrati aj NULLstatic StringgetBooleanSql(boolean b) Returns 1/0 or true/false dependind on DB typestatic Datestatic Stringvrati naformatovany datum z databazystatic StringgetDbDateTime(ResultSet db_result, String fieldName) Gets the dbDateTime attribute of the DB classstatic StringgetDbDateTime(ResultSet db_result, String fieldName, String serverName) Gets the dbDateTime attribute of the DB classstatic StringgetDbString(ResultSet db_result, String fieldName) vrati prekodovany a trimnuty string z result setu (povodne sa pouzivalo kvoli Oracle)static StringgetDbString(ResultSet db_result, String fieldName, boolean filter) vrati prekodovany a trimnuty string z result setu (povodne sa pouzivalo kvoli Oracle), ak je filter true vykona aj ResponseUtils.filterstatic Stringvrati naformatovany cas z databazystatic TimestampgetDbTimestamp(long time) static longgetDbTimestamp(ResultSet rs, String fieldName) Vrati long hodnotu Timestampu (ak nie je null), inak vrati 0static List<org.apache.commons.beanutils.DynaBean>getDynaList(String sql) Vrati List DynaBeanov pre zadane SQLstatic List<org.apache.commons.beanutils.DynaBean>getDynaList(String sql, List<?> params) static List<org.apache.commons.beanutils.DynaBean>getDynaList(String sql, List<?> params, String dbName) static StringgetFullName(ResultSet rs) static StringgetFullName(ResultSet rs, String titleName) Gets the fullName attribute of the DB objectstatic IntegergetInteger(ResultSet rs, String colName) Vrati Integer hodnotu z databazy, pricom korektne vrati aj NULLstatic intgetIntValue(Object o, int defaultValue) static longgetLongValue(Object o, long defaultValue) static StringgetOnlyNumbersIn(String ids) Vrati a skontroluje IN zoznam pre SQL tak, aby obsahoval len cisla, cize z "1,xxx,2,3" spravi "1,2,3"static StringgetOnlyNumbersIn(String ids, boolean checkGroups) Vrati a skontroluje IN zoznam pre SQL tak, aby obsahoval len cisla, cize z "1,xxx,2,3" spravi "1,2,3" ak sa jedna o id-ckaGroupDetailstak v pripade ze je zapnuty cloud sa kontroluje aj ich dostupnost pre aktualnu domenustatic intgetSqlParamsDatatable(List<Object> params, PreparedStatement ps, int psCounter) Fill PreparedStatement with parametersstatic StringgetSqlQueryDatatable(String fieldName, String searchText, boolean addAnd, List<Object> params) static longgetTimestamp(String dateTime) static longgetTimestamp(String date, String time) return sql timestamp from given date and timestatic longgetTimestamp(String date, String time, String serverName) static longgetTimestampNotAfterYear(long timestamp, int year) Upravi hodnotu timestampu tak, aby nebola za zadanym rokom (kedze DB to tak nevedia mat)static longgetTimestampNotBeforeAfterYear(long timestamp, int yearFrom, int yearTo) Upravi hodnotu timestampu tak, aby nebola pred a za zadanym rokom (kedze DB to tak nevedia mat)static longgetTimestampNotBeforeYear(long timestamp, int year) Upravi hodnotu timestampu tak, aby nebola pred zadanym rokom (kedze DB to tak nevedia mat)static StringinternationalToEnglish(String source) prekoduje diakritiku a azbuku do cisteho asciistatic booleanisHtmlAllowed(String fieldName) Overi, ci je mozne v danom DB stlpci pouzit HTML kod, ak nie, tak sa pri citani rovno escapnu specialne znaky ako < alebo > aby nebolo mozne vykonat XSS utok https://thoughts-on-java.org/jpa-21-how-to-implement-type-converter/static StringprepareString(String s, int maxLen) Oreze s tak, aby nebol dlhsi ako maxLenstatic BigDecimalqueryForBigDecimal(String sql, Object... parameters) static doublequeryForDouble(String sql, Object... parameters) static intqueryForInt(String sql, Object... parameters) static ListqueryForList(String sql, Object... parameters) static longqueryForLong(String sql, Object... parameters) static StringqueryForString(String sql, Object... parameters) static StringremoveSlashes(String sqlParam) odstrani apostrofy zo stringu, treba volat vzdy, ked sa nejaky parameter dava priamo do SQL prikazustatic StringDeprecated.replaced byTools.replace(String, String, String)static voidstatic voidsetClob(PreparedStatement ps, int pos, String data) nastavi pole text, alebo clob v preparedStatemente
-
Constructor Details
-
DB
public DB()
-
-
Method Details
-
isHtmlAllowed
Overi, ci je mozne v danom DB stlpci pouzit HTML kod, ak nie, tak sa pri citani rovno escapnu specialne znaky ako < alebo > aby nebolo mozne vykonat XSS utok https://thoughts-on-java.org/jpa-21-how-to-implement-type-converter/- Parameters:
fieldName-- Returns:
-
resetHtmlAllowedFields
public static void resetHtmlAllowedFields() -
getDbString
public static String getDbString(ResultSet db_result, String fieldName, boolean filter) throws SQLException vrati prekodovany a trimnuty string z result setu (povodne sa pouzivalo kvoli Oracle), ak je filter true vykona aj ResponseUtils.filter- Parameters:
db_result-fieldName-filter-- Returns:
- Throws:
SQLException
-
getDbString
vrati prekodovany a trimnuty string z result setu (povodne sa pouzivalo kvoli Oracle)- Parameters:
db_result- result setfieldName- meno fieldu v databaze- Returns:
- prekodovany a trimnuty string
- Throws:
Exception- Description of the ExceptionSQLException
-
filterHtml
Nahradi nebezpecne HTML znaky za entity- Parameters:
data-- Returns:
-
getDbTimestamp
Vrati long hodnotu Timestampu (ak nie je null), inak vrati 0- Parameters:
rs-fieldName-- Returns:
- Throws:
Exception
-
getDbTimestamp
-
getDbDate
vrati naformatovany datum z databazy- Parameters:
db_result- result setfieldName- meno fieldu v databaze- Returns:
- naformatovany datum z databazy
- Throws:
Exception- Description of the ExceptionSQLException
-
getDate
- Throws:
SQLException
-
getDbTime
vrati naformatovany cas z databazy- Parameters:
db_result- result setfieldName- meno fieldu v databaze- Returns:
- naformatovany cas z databazy
- Throws:
Exception- Description of the Exception
-
getDbDateTime
Gets the dbDateTime attribute of the DB class- Parameters:
db_result- Description of the ParameterfieldName- Description of the Parameter- Returns:
- The dbDateTime value
- Throws:
Exception- Description of the ExceptionSQLException
-
getDbDateTime
public static String getDbDateTime(ResultSet db_result, String fieldName, String serverName) throws SQLException Gets the dbDateTime attribute of the DB class- Parameters:
db_result- Description of the ParameterfieldName- Description of the ParameterserverName- Description of the Parameter- Returns:
- The dbDateTime value
- Throws:
Exception- Description of the ExceptionSQLException
-
getTimestamp
-
getTimestamp
-
getTimestamp
return sql timestamp from given date and time- Parameters:
date- datumtime- cas- Returns:
- The timestamp value
-
internationalToEnglish
prekoduje diakritiku a azbuku do cisteho ascii- Parameters:
source- Description of the Parameter- Returns:
- Description of the Return Value
-
replace
Deprecated.replaced byTools.replace(String, String, String)Replace stringu na string- Parameters:
src- zdrojovy stringoldStr- co sa ma nahraditnewStr- za co sa ma nahradit- Returns:
- string src v ktorom je nahradene oldStr za newStr
-
setClob
nastavi pole text, alebo clob v preparedStatemente- Parameters:
ps- The new clob valuepos- The new clob valuedata- The new clob value- Throws:
Exception- Description of the Exception
-
removeSlashes
odstrani apostrofy zo stringu, treba volat vzdy, ked sa nejaky parameter dava priamo do SQL prikazu- Parameters:
sqlParam-- Returns:
-
dumpResultSet
Produces a string representation of a complete result set- Parameters:
rs- The ResultSet to be displayed- Returns:
- The string representation
- Throws:
SQLException- to indicate a problem with the ResultSet
-
getFullName
- Throws:
Exception
-
getFullName
Gets the fullName attribute of the DB object- Parameters:
rs- Description of the Parameter- Returns:
- The fullName value
- Throws:
Exception
-
prepareString
Oreze s tak, aby nebol dlhsi ako maxLen- Parameters:
s-maxLen-- Returns:
-
getDynaList
Vrati List DynaBeanov pre zadane SQL- Parameters:
sql- - SQL prikaz- Returns:
-
getDynaList
-
getDynaList
-
getIntValue
-
getLongValue
-
execute
-
queryForInt
-
queryForLong
-
queryForString
-
queryForDouble
-
queryForBigDecimal
-
queryForList
-
getOnlyNumbersIn
Vrati a skontroluje IN zoznam pre SQL tak, aby obsahoval len cisla, cize z "1,xxx,2,3" spravi "1,2,3"- Parameters:
ids-- Returns:
-
getOnlyNumbersIn
Vrati a skontroluje IN zoznam pre SQL tak, aby obsahoval len cisla, cize z "1,xxx,2,3" spravi "1,2,3" ak sa jedna o id-ckaGroupDetailstak v pripade ze je zapnuty cloud sa kontroluje aj ich dostupnost pre aktualnu domenu- Parameters:
ids-checkGroups- indikuje ci sa jedna o id-cka GroupDetails- Returns:
-
getTimestampNotBeforeYear
public static long getTimestampNotBeforeYear(long timestamp, int year) Upravi hodnotu timestampu tak, aby nebola pred zadanym rokom (kedze DB to tak nevedia mat)- Parameters:
timestamp-year-- Returns:
-
getTimestampNotAfterYear
public static long getTimestampNotAfterYear(long timestamp, int year) Upravi hodnotu timestampu tak, aby nebola za zadanym rokom (kedze DB to tak nevedia mat)- Parameters:
timestamp-year-- Returns:
-
getTimestampNotBeforeAfterYear
public static long getTimestampNotBeforeAfterYear(long timestamp, int yearFrom, int yearTo) Upravi hodnotu timestampu tak, aby nebola pred a za zadanym rokom (kedze DB to tak nevedia mat)- Parameters:
timestamp-yearFrom-yearTo-- Returns:
-
filterEscaped
Deprecated.- use filterHtmlosetri HTML znacky v retazci - DEPRECATED, pouzi filterHtml- Parameters:
escapedString-- Returns:
- *
-
getInteger
Vrati Integer hodnotu z databazy, pricom korektne vrati aj NULL- Parameters:
rs-colName-- Returns:
- Throws:
SQLException
-
getBoolean
Vrati Boolean hodnotu z databazy, pricom korektne vrati aj NULL- Parameters:
rs-colName-- Returns:
- Throws:
SQLException
-
getBooleanSql
Returns 1/0 or true/false dependind on DB type- Parameters:
b-- Returns:
-
fixAiCiCol
Add lower/unaccent(column) for case insensitive search in Oracle/PostgreSQL- Parameters:
column-- Returns:
-
fixAiCiValue
Fix value for case insensitive search in Oracle/PostgreSQL- Parameters:
value-- Returns:
-
getSqlQueryDatatable
-
getSqlParamsDatatable
public static int getSqlParamsDatatable(List<Object> params, PreparedStatement ps, int psCounter) throws SQLException Fill PreparedStatement with parameters- Parameters:
params- - list of Parametersps- - prepared statementpsCounter- - counter of parameters, starts with 1 for first parameter- Returns:
- - new counter of parameters
- Throws:
SQLException
-