List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:com.hangum.tadpole.engine.sql.util.sqlscripts.scripts.OracleDDLScript.java
@Override public String getProcedureScript(ProcedureFunctionDAO procedureDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); if (logger.isDebugEnabled()) logger.debug("\n Procedure DDL Generation..."); StringBuilder result = new StringBuilder(""); String objType = (String) client.queryForObject("getSourceObjectType", procedureDAO.getName()); List<String> srcScriptList = null; if (StringUtils.contains(objType, "PROCEDURE")) { // result.append("/* DROP PROCEDURE " + procedureDAO.getName() + "; */ \n\n"); result.append("CREATE OR REPLACE "); srcScriptList = client.queryForList("getProcedureScript", procedureDAO.getName()); for (int i = 0; i < srcScriptList.size(); i++) { result.append(srcScriptList.get(i)); }/*from w w w.j a v a 2s .co m*/ } else if (StringUtils.contains(objType, "PACKAGE")) { result.append("/* STATEMENT PACKAGE BODY " + procedureDAO.getName() + "; */ \n\n"); result.append("/* STATEMENT PACKAGE " + procedureDAO.getName() + "; */ \n\n"); result.append("CREATE OR REPLACE "); srcScriptList = client.queryForList("getPackageScript.head", procedureDAO.getName()); for (int i = 0; i < srcScriptList.size(); i++) { result.append(srcScriptList.get(i)); } result.append("/ \n\n "); result.append("CREATE OR REPLACE "); srcScriptList = client.queryForList("getPackageScript.body", procedureDAO.getName()); for (int i = 0; i < srcScriptList.size(); i++) { result.append(srcScriptList.get(i)); } result.append("/ \n\n "); } return result.toString(); }
From source file:com.rosy.bill.dao.hibernate.HibernateDao.java
private String prepareCountSql(String orgSql) { String fromSql = orgSql;/* www . j a va 2s. c o m*/ //select??order by???count,?. fromSql = "from " + StringUtils.substringAfter(fromSql, "from"); fromSql = StringUtils.substringBefore(fromSql, "order by"); if (StringUtils.contains(fromSql, "group by")) { return " select count(*) from ( select count(*) " + fromSql + ")"; } String countSql = "select count(*) " + fromSql; return countSql; }
From source file:jp.co.opentone.bsol.linkbinder.service.correspon.impl.CorresponFullTextSearchServiceImpl.java
private Long idToLong(String id) { String str;/*from ww w . java 2s . co m*/ if (StringUtils.contains(id, '@')) { str = StringUtils.split(id, '@')[1]; } else { str = id; } return NumberUtils.toLong(str); }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MSSQLLoginComposite.java
@Override public boolean connection() { if (!isValidate()) return false; String dbUrl = ""; String strHost = textHost.getText(); if (StringUtils.contains(strHost, "\\")) { String strIp = StringUtils.substringBefore(strHost, "\\"); String strInstance = StringUtils.substringAfter(strHost, "\\"); dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), strIp, textPort.getText(), textDatabase.getText()) + ";instance=" + strInstance; } else if (StringUtils.contains(strHost, "/")) { String strIp = StringUtils.substringBefore(strHost, "/"); String strInstance = StringUtils.substringAfter(strHost, "/"); dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), strIp, textPort.getText(), textDatabase.getText()) + ";instance=" + strInstance; } else {// w w w. ja v a 2 s. co m dbUrl = String.format(DBDefine.MSSQL_DEFAULT.getDB_URL_INFO(), textHost.getText(), textPort.getText(), textDatabase.getText()); } if (logger.isDebugEnabled()) logger.debug("[db url]" + dbUrl); userDB = new UserDBDAO(); userDB.setTypes(DBDefine.MSSQL_DEFAULT.getDBToString()); userDB.setUrl(dbUrl); userDB.setDb(textDatabase.getText()); userDB.setGroup_name(comboGroup.getText().trim()); userDB.setDisplay_name(textDisplayName.getText()); userDB.setOperation_type(DBOperationType.getNameToType(comboOperationType.getText()).toString()); userDB.setHost(textHost.getText()); userDB.setPasswd(textPassword.getText()); userDB.setPort(textPort.getText()); userDB.setUsers(textUser.getText()); // ?? ?? if (oldUserDB != null) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.SQLiteLoginComposite_13)) //$NON-NLS-1$ return false; if (!checkDatabase(userDB)) return false; try { TadpoleSystem_UserDBQuery.updateUserDB(userDB, oldUserDB, SessionManager.getSeq()); } catch (Exception e) { logger.error(Messages.SQLiteLoginComposite_8, e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.SQLiteLoginComposite_5, //$NON-NLS-1$ errStatus); return false; } // ?? . } else { int intVersion = 0; try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); // ? . DBInfoDAO dbInfo = (DBInfoDAO) sqlClient.queryForObject("findDBInfo"); //$NON-NLS-1$ intVersion = Integer.parseInt(StringUtils.substringBefore(dbInfo.getProductversion(), ".")); } catch (Exception e) { logger.error("MSSQL Connection", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MSSQLLoginComposite_8, //$NON-NLS-1$ errStatus); return false; } try { if (intVersion <= 8) { userDB.setTypes(DBDefine.MSSQL_8_LE_DEFAULT.getDBToString()); } TadpoleSystem_UserDBQuery.newUserDB(userDB, SessionManager.getSeq()); } catch (Exception e) { logger.error("MSSQL", e); //$NON-NLS-1$ Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(getShell(), "Error", Messages.MSSQLLoginComposite_10, //$NON-NLS-1$ errStatus); } } return true; }
From source file:com.zb.app.web.controller.manage.ManageCmsController.java
@RequestMapping(value = "/delLink.htm", produces = "application/json") @ResponseBody//from w w w .j a v a 2 s. co m public JsonResult delLink(Long id) { if (id == null || id == 0) { return JsonResultUtils.error("id?!"); } TravelAdvertisementDO advertisement = cmsService.getAdvertisementById(id); if (advertisement == null) { return JsonResultUtils.error("id?!"); } if (StringUtils.isNotEmpty(advertisement.getPic()) && StringUtils.contains(advertisement.getPic(), "/static/")) { fileService.delFileByPath(advertisement.getPic()); } boolean isDel = cmsService.realDelAdvertisement(id); return isDel ? JsonResultUtils.success("?!") : JsonResultUtils.error("!"); }
From source file:edu.ku.brc.specify.toycode.mexconabio.FileMakerToMySQL.java
public void endElement(final String namespaceURI, final String localName, final String qName) { //System.out.println(localName+" "+qName+" ["+buffer.toString()+"]"); if (localName.equals("DATA")) { //if (buffer.length() > 0) System.out.println(buffer.toString()); if (debug) { //if (rowCnt > 106000) {/* w w w . jav a 2 s . c o m*/ //System.out.println("col["+colNum+"]"); //if (colNum == 0) System.out.println("BarCd["+buffer.toString()+"]"); } } if (!doColSizes) { values.add(buffer.toString()); } else { String val = buffer.toString(); FieldDef fd = fields.get(colNum); fd.setMaxSize(buffer.length()); if (fd.isNumber() && !fd.isDouble() && StringUtils.contains(buffer.toString(), '.')) { fd.setDouble(true); } } colNum++; } else if (localName.equals("ROW")) { if (!doColSizes) { writeRow(); } else if (debug) { //System.out.println("R: "+rowCnt); //if (rowCnt > chkRow) System.out.println("R: "+rowCnt); } if (rowCnt % 1000 == 0) System.out.println(rowCnt); rowCnt++; colNum = 0; } else if (localName.equals("METADATA")) { if (!doColSizes) { createTable(tableName, keyField, true); if (true) { System.exit(0); } } } else if (localName.equals("RESULTSET")) { if (doColSizes) { for (FieldDef fd : fields) { if (fd.getMaxSize() > 0) System.out.println(fd.getName() + " - " + fd.getMaxSize()); } } } buffer.setLength(0); }
From source file:com.cloudera.hive.udf.functions.ParseKeyValueTuple.java
/** * Processes the input string into a KeyValue Map utilizing the fieldDelimiter and keyValSeparator.</br> * Only considers valid pairs(has keyValSeparator) with non-empty/null keys that are in keyNames. * <p>//from ww w .j ava 2 s .com * Note: The key is the string before the first occurrence of keyValSeparator and the value is everything after.</br> * Note: If a key occurs twice the last value seen will be represented. * * @param inputString the string to be processed * @param fieldDelimiter separator between KeyValue pairs * @param keyValSeparator separator between key and value * @param keyNames used to filter values inserted * @return the key value map for keyNames */ private Map<String, String> getKeyValMap(final String inputString, final String fieldDelimiter, final String keyValSeparator, final List<String> keyNames) { final Set<String> uniqueKeyNames = new HashSet<String>(keyNames); // Optimize in the case of duplicate key names final Map<String, String> keyValMap = new HashMap<String, String>(uniqueKeyNames.size()); //Initialized with the expected size final Iterable<String> splitIterable = Splitter.on(fieldDelimiter).omitEmptyStrings().split(inputString); //Iterator to prevent excessive allocation int count = 0; // Counter to break out when we have seen all of the uniqueKeyNames for (final String keyValPair : splitIterable) { final String key = StringUtils.substringBefore(keyValPair, keyValSeparator); final String value = StringUtils.substringAfter(keyValPair, keyValSeparator); // Only consider valid pairs with non-empty/null keys that are in uniqueKeyNames if (StringUtils.contains(keyValPair, keyValSeparator) && !StringUtils.isEmpty(key) && uniqueKeyNames.contains(key)) { final String prev = keyValMap.put(key, value); if (prev == null) { count++; } else if (!mapWarned) { // Otherwise a key was replaced LOG.warn( "At least 1 inputString had a duplicate key for a keyName. The second value will be represented. Additional warnings for a duplicate key will be suppressed."); mapWarned = true; } if (count >= uniqueKeyNames.size()) { break; // We have seen all of the keyNames needed } } } return keyValMap; }
From source file:com.qualogy.qafe.gwt.server.event.assembler.AbstractEventRenderer.java
private boolean containsAttribute(String string) { return (StringUtils.contains(string, '[') && StringUtils.contains(string, ']')); }
From source file:edu.ku.brc.specify.ui.CollectingEventDataObjFmt.java
@Override public void init(final String nameArg, final Properties properties) { this.name = nameArg; if (properties != null) { formatStr = properties.getProperty("format"); }//from w ww . j a va 2 s . c om if (StringUtils.isEmpty(formatStr)) { formatStr = DEF_FMT_STR; } for (String token : tokens) { if (StringUtils.contains(formatStr, token)) { fieldsHash.put(token, true); } } }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.composite.AbstractLoginComposite.java
/** * db ?? ? ./*www . j a v a 2 s . co m*/ * * @param userDB * @param isTest * @return */ private boolean checkDatabase(final UserDBDAO userDB, boolean isTest) { try { if (userDB.getDBDefine() == DBDefine.MONGODB_DEFAULT) { MongoConnectionManager.getInstance(userDB); } else if (userDB.getDBDefine() == DBDefine.TAJO_DEFAULT) { new TajoConnectionManager().connectionCheck(userDB); } else if (userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) { String strFileLoc = StringUtils.difference( StringUtils.remove(userDB.getDBDefine().getDB_URL_INFO(), "%s"), userDB.getUrl()); File fileDB = new File(strFileLoc); if (fileDB.exists()) { List<String> strArr = FileUtils.readLines(fileDB); if (!StringUtils.contains(strArr.get(0), "SQLite format")) { throw new SQLException("Doesn't SQLite files."); } } } else { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); sqlClient.queryForList("connectionCheck", userDB.getDb()); //$NON-NLS-1$ } return true; } catch (Exception e) { String errMsg = e.getMessage(); // driver ? . try { Throwable cause = e.getCause().getCause(); if (cause instanceof ClassNotFoundException) { errMsg = String.format(Messages.get().TadpoleTableComposite_driverMsg, userDB.getDbms_type(), e.getMessage()); } } catch (Exception ee) { // igonre exception } logger.error("DB Connecting... [url]" + userDB.getUrl(), e); //$NON-NLS-1$ // If UserDBDao is not invalid, remove UserDBDao at internal cache TadpoleSQLManager.removeInstance(userDB); // mssql ??? ? ?? ?. . // https://github.com/hangum/TadpoleForDBTools/issues/512 if (!isTest) {// && loginInfo.getDBDefine() != DBDefine.MSSQL_DEFAULT) { TDBYesNoErroDialog dialog = new TDBYesNoErroDialog(getShell(), userDB.getDb() + " Test", String.format(Messages.get().AbstractLoginComposite_3, errMsg)); if (dialog.open() == IDialogConstants.OK_ID) return true; } else { TDBInfoDialog dialog = new TDBInfoDialog(getShell(), userDB.getDb() + " Test", errMsg); dialog.open(); } return false; } }