List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty
public static boolean isNotEmpty(final CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
From source file:de.pavloff.spark4knime.jsnippet.JavaSnippetUtil.java
/** Convert file location to File. Also accepts file in URL format * (e.g. local drop files as URL)./* w w w.j a va 2 s . c o m*/ * @param location The location string. * @return The file to the location * @throws InvalidSettingsException if argument is null, empty or the file * does not exist. */ public static final File toFile(final String location) throws InvalidSettingsException { CheckUtils.checkSetting(StringUtils.isNotEmpty(location), "Invalid (empty) jar file location"); File result; URL url = null; try { url = new URL(location); } catch (MalformedURLException mue) { } if (url != null) { result = FileUtil.getFileFromURL(url); } else { result = new File(location); } CheckUtils.checkSetting(result != null && result.exists(), "Can't read file \"%s\"; invalid class path", location); return result; }
From source file:com.thruzero.common.core.fs.walker.visitor.FileRenamingVisitor.java
protected void doRenameFileOrDirectory(final File fileOrDir) throws IOException { String newName = substitutionStrategy.replaceAll(fileOrDir.getName()); if (StringUtils.isNotEmpty(newName) && !fileOrDir.getName().equals(newName)) { if (logger.isDebugEnabled()) { logger.debug(" - renaming file = " + fileOrDir.getName() + " to " + newName); }/*from w w w . j av a 2 s. c o m*/ fileOrDir.renameTo(new File(fileOrDir.getParent(), newName)); getStatus().incNumProcessed(); } }
From source file:com.glaf.jbpm.action.InvokerAction.java
public void execute(ExecutionContext ctx) { logger.debug("-------------------------------------------------------"); logger.debug("--------------------InvokerAction----------------------"); logger.debug("-------------------------------------------------------"); if (StringUtils.isNotEmpty(className) && StringUtils.isNotEmpty(method)) { MethodInvoker methodInvoker = new MethodInvoker(); Object target = ClassUtils.instantiateObject(className); Map<String, Object> params = new java.util.HashMap<String, Object>(); ContextInstance contextInstance = ctx.getContextInstance(); Map<String, Object> variables = contextInstance.getVariables(); if (variables != null && variables.size() > 0) { Set<Entry<String, Object>> entrySet = variables.entrySet(); for (Entry<String, Object> entry : entrySet) { String name = entry.getKey(); Object value = entry.getValue(); if (name != null && value != null && params.get(name) == null) { params.put(name, value); }/* w ww .j av a2 s .c o m*/ } } if (elements != null) { if (LogUtils.isDebug()) { logger.debug("elements:" + elements.asXML()); } Object object = CustomFieldInstantiator.getValue(Map.class, elements); if (object instanceof Map) { Map<String, Object> paramMap = (Map<String, Object>) object; Set<Entry<String, Object>> entrySet = paramMap.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { params.put(key, value); } } } } Map<String, Object> varMap = contextInstance.getVariables(); if (varMap != null && varMap.size() > 0) { Set<Entry<String, Object>> entrySet = varMap.entrySet(); for (Entry<String, Object> entry : entrySet) { String variableName = entry.getKey(); if (params.get(variableName) == null) { Object value = contextInstance.getVariable(variableName); params.put(variableName, value); } } } Object rowId = contextInstance.getVariable(Constant.PROCESS_ROWID); params.put("rowId", rowId); ProcessInstance processInstance = ctx.getProcessInstance(); ProcessDefinition processDefinition = processInstance.getProcessDefinition(); Long processInstanceId = processInstance.getId(); params.put("processInstanceId", processInstanceId); params.put("processName", processDefinition.getName()); params.put("processDefinitionId", processDefinition.getId()); params.put("processDefinition", processDefinition); params.put("processInstance", processInstance); Object[] arguments = { params, ctx.getJbpmContext().getConnection() }; methodInvoker.setArguments(arguments); methodInvoker.setTargetObject(target); methodInvoker.setTargetMethod(method); try { methodInvoker.prepare(); methodInvoker.invoke(); } catch (Exception ex) { if (LogUtils.isDebug()) { ex.printStackTrace(); logger.debug(ex); } throw new JbpmException(ex); } } }
From source file:com.lichengbao.specification.MobileAssessmentSpecDef.java
@SuppressWarnings("rawtypes") @Override// w w w. j a v a2 s . co m List<Specification> getSpecifications(SpecDef def) { List<Specification> specs = new ArrayList<>(); MobileAssessmentSpecDef specDef = (MobileAssessmentSpecDef) def; if (StringUtils.isNotEmpty(specDef.getOwner())) specs.add(isOwner(specDef.getOwner())); return specs; }
From source file:com.th.jbp.backend.service.TrailerTailService.java
@Override @Transactional(readOnly = true)/* w ww . j ava 2 s. co m*/ public Page<TrailerTailM> lists(String licensePlate, PageRequest pageRequest) { LOGGER.debug("licensePlate = " + licensePlate + " , pageRequest = " + pageRequest); Page<TrailerTailM> results = null; if (StringUtils.isNotEmpty(licensePlate)) { results = repository.findByLicensePlate("%" + licensePlate + "%", pageRequest); } else { results = repository.findAll(pageRequest); } return results; }
From source file:com.lichengbao.specification.MonthlyAssessmentSpecDef.java
@SuppressWarnings("rawtypes") @Override/*from www. ja v a 2 s . c o m*/ List<Specification> getSpecifications(SpecDef def) { List<Specification> specs = new ArrayList<>(); MonthlyAssessmentSpecDef specDef = (MonthlyAssessmentSpecDef) def; if (StringUtils.isNotEmpty(specDef.getOwner())) specs.add(isOwner(specDef.getOwner())); return specs; }
From source file:com.glaf.chart.bean.ChartDataManager.java
protected void fetchData(Chart chart, TableModel rowMode, String querySQL, Map<String, Object> paramMap, String actorId) {/*ww w . ja va 2 s . c o m*/ if (StringUtils.isNotEmpty(querySQL)) { paramMap.put("curr_yyyymm", Integer.parseInt(SystemConfig.getCurrentYYYYMM())); paramMap.put("curr_yyyymmdd", Integer.parseInt(SystemConfig.getCurrentYYYYMMDD())); querySQL = QueryUtils.replaceSQLVars(querySQL); // querySQL = QueryUtils.replaceSQLParas(querySQL, paramMap); logger.debug("paramMap=" + paramMap); logger.debug("querySQL=" + querySQL); rowMode.setSql(querySQL); DatabaseConnectionConfig config = new DatabaseConnectionConfig(); Long databaseId = chart.getDatabaseId(); LoginContext loginContext = IdentityFactory.getLoginContext(actorId); Database currentDB = config.getDatabase(loginContext, databaseId); String systemName = Environment.getCurrentSystemName(); try { if (currentDB != null) { Environment.setCurrentSystemName(currentDB.getName()); } List<Map<String, Object>> rows = getTablePageService().getListData(querySQL, paramMap); if (rows != null && !rows.isEmpty()) { logger.debug(rows); int index = 0; Map<String, Object> dataMap = new java.util.HashMap<String, Object>(); for (Map<String, Object> rowMap : rows) { dataMap.clear(); Set<Entry<String, Object>> entrySet = rowMap.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); Object value = entry.getValue(); dataMap.put(key, value); dataMap.put(key.toLowerCase(), value); } if ("pie".equals(chart.getChartType())) { index++; ColumnModel cell = new ColumnModel(); cell.setColumnName("col_" + index); cell.setSeries(MapUtils.getString(dataMap, "series")); cell.setDoubleValue(MapUtils.getDouble(dataMap, "doublevalue")); chart.addCellData(cell); } else { index++; ColumnModel cell = new ColumnModel(); cell.setColumnName("col_" + index); cell.setCategory(MapUtils.getString(dataMap, "category")); cell.setSeries(MapUtils.getString(dataMap, "series")); cell.setDoubleValue(MapUtils.getDouble(dataMap, "doublevalue")); chart.addCellData(cell); } } logger.debug("rows size:" + chart.getColumns().size()); } } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } finally { Environment.setCurrentSystemName(systemName); } } }
From source file:com.inkubator.hrm.web.payroll.PayComponentDataExceptionFormController.java
@PostConstruct @Override//from w w w . j a v a 2s. c o m public void initialization() { super.initialization(); try { String payComponentExceptionId = FacesUtil.getRequestParameter("payComponentExceptionId"); paySalaryComponentId = FacesUtil.getRequestParameter("paySalaryComponentId"); model = new PayComponentDataExceptionModel(); isUpdate = Boolean.FALSE; if (StringUtils.isNotEmpty(paySalaryComponentId)) { PaySalaryComponent paySalaryComponent = paySalaryComponentService .getEntiyByPK(Long.parseLong(paySalaryComponentId.substring(1))); model.setComponentName(paySalaryComponent.getCode() + " - " + paySalaryComponent.getName()); if (payComponentExceptionId != null) { PayComponentDataException payComponentDataException = payComponentDataExceptionService .getByPaySalaryComponentId(Long.parseLong(payComponentExceptionId)); model = getModelFromEntity(payComponentDataException); isUpdate = Boolean.TRUE; } } } catch (Exception e) { LOGGER.error("Error", e); } }
From source file:de.micromata.genome.gwiki.fssvn.DavFileSystem.java
protected void connect() { if (sardine != null) { return;/*from w w w.j a v a 2s . c o m*/ } try { if (StringUtils.isNotEmpty(user) == true) { sardine = SardineFactory.begin(user, pass, SslUtils.createEasySSLSocketFactory()); } else { sardine = SardineFactory.begin(SslUtils.createEasySSLSocketFactory()); } } catch (SardineException ex) { throw new FsException("Cannot initialize webdav: " + ex.getMessage(), ex); } }
From source file:com.devicehive.service.helpers.HazelcastHelper.java
private Predicate prepareFilters(Long id, String guid, Collection<String> devices, Collection<String> notifications, Collection<String> commands, Date timestampSt, Date timestampEnd, String status) {// w ww. j a va 2 s. co m final List<Predicate> predicates = new ArrayList<>(); if (id != null) { predicates.add(Predicates.equal(ID.getField(), id)); } if (StringUtils.isNotEmpty(guid)) { predicates.add(Predicates.equal(GUID.getField(), guid)); } if (devices != null && !devices.isEmpty()) { predicates.add(Predicates.in(DEVICE_GUID.getField(), devices.toArray(new String[devices.size()]))); } if (notifications != null && !notifications.isEmpty()) { predicates.add(Predicates.in(NOTIFICATION.getField(), notifications.toArray(new String[notifications.size()]))); } else if (commands != null && !commands.isEmpty()) { predicates.add(Predicates.in(COMMAND.getField(), commands.toArray(new String[commands.size()]))); } if (timestampSt != null) { predicates.add(Predicates.greaterThan(TIMESTAMP.getField(), timestampSt)); } if (timestampEnd != null) { predicates.add(Predicates.lessThan(TIMESTAMP.getField(), timestampEnd)); } if (StringUtils.isNotEmpty(status)) { predicates.add(Predicates.equal(STATUS.getField(), status)); } final Predicate[] predicatesArray = new Predicate[predicates.size()]; for (int i = 0; i < predicates.size(); i++) { predicatesArray[i] = predicates.get(i); } return Predicates.and(predicatesArray); }