List of usage examples for org.apache.commons.lang3 StringUtils isNoneEmpty
public static boolean isNoneEmpty(final CharSequence... css)
Checks if none of the CharSequences are empty ("") or null.
StringUtils.isNoneEmpty(null) = false StringUtils.isNoneEmpty(null, "foo") = false StringUtils.isNoneEmpty("", "bar") = false StringUtils.isNoneEmpty("bob", "") = false StringUtils.isNoneEmpty(" bob ", null) = false StringUtils.isNoneEmpty(" ", "bar") = true StringUtils.isNoneEmpty("foo", "bar") = true
From source file:org.opendaylight.tsdr.persistence.elasticsearch.ElasticsearchStore.java
/** * Create an one part of condition queryString of the ELK query. *///from w w w . java 2 s . com void appendCondition(StringBuffer queryBuffer, String fieldName, String fieldValue) { if (StringUtils.isNoneEmpty(fieldValue)) { // If it is not the first condition then we must add clausule And if (queryBuffer.length() > 0) { queryBuffer.append(" AND "); } queryBuffer.append(String.format(QUERY_CONDITION, fieldName, fieldValue)); } }
From source file:org.openlmis.core.view.viewmodel.StockMovementViewModel.java
public boolean validateEmpty() { return reason != null && StringUtils.isNoneEmpty(movementDate) && !allQuantitiesEmpty(); }
From source file:org.pad.pgsql.loadmovies.LoadFiles.java
/** * Load movies from csv file and save them in DB. * * @throws Exception/*from ww w . jav a2s . c o m*/ */ private static void loadMoviesAndLinks() throws Exception { MovieDao movieDao = new MovieDao(DS); Map<Integer, Integer[]> moviesLinks = new HashMap<>(); //Loads all links informations in memory to enrich afterwards movies CSVParser parser = new CSVParser(new FileReader("C:\\PRIVE\\SRC\\ml-20m\\links.csv"), CSVFormat.EXCEL.withHeader()); for (CSVRecord link : parser) { Integer movieId = Integer.parseInt(link.get("movieId")); if (keepId(movieId)) { System.out.println("Parsing line " + link.toString()); Integer[] otherIds = new Integer[2]; otherIds[0] = Integer.parseInt(link.get("imdbId")); if (StringUtils.isNoneEmpty(link.get("tmdbId"))) { otherIds[1] = Integer.parseInt(link.get("tmdbId")); } moviesLinks.put(movieId, otherIds); } } //Read movie file final Reader reader = new FileReader("C:\\PRIVE\\SRC\\ml-20m\\movies.csv"); parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader()); for (CSVRecord record : parser) { //build a movie object from record Integer movieId = Integer.parseInt(record.get("movieId")); if (keepId(movieId)) { String title = record.get("title"); String genres = record.get("genres"); //Splitting title to extract the date String movieDate = StringUtils.substringBeforeLast(StringUtils.substringAfterLast(title, "("), ")"); String movieName = null; if (StringUtils.isNumeric(movieDate)) { movieName = StringUtils.substringBeforeLast(title, "("); } else { movieName = title; movieDate = null; } System.out.println(movieName + " - " + movieDate); Movie movieToAdd = new Movie(movieId, movieName, movieDate); //Enrich movie with links Integer[] additionalIds = moviesLinks.get(movieId); if (additionalIds != null) { movieToAdd.setImdbId(additionalIds[0]); movieToAdd.setTmdbId(additionalIds[1]); } //Save in database movieDao.save(movieToAdd); } } }
From source file:org.power.commons.lang.util.internal.IndentableStringBuilder.java
/** * ???end()????// w ww.jav a2 s . c o m */ public IndentableStringBuilder end() { flush(); // ?? if (lazyStartHangingIndent) { if (!endsWithNewLine()) { lazyAppendNewLine = true; } lazyStartHangingIndent = false; return this; } // ??end quote if (indentLevel > quoteLevel) { indentLevel--; } else { assertTrue(indentLevel == quoteLevel, "indentLevel != quoteLevel"); if (indentLevel > 0) { indentLevel--; quoteLevel--; String endQuote = indents.getEndQuote(indentLevel); if (StringUtils.isNoneEmpty(endQuote)) { // ?end quote?? if (!endsWithNewLine()) { appendInternalNewLine(); } // end quote appendIndent(indentLevel); appendInternal(endQuote); } lazyAppendNewLine = true; } } indents.popIndent(); return this; }
From source file:org.talend.librariesmanager.nexus.nexus3.handler.AbsNexus3SearchHandler.java
protected String getQueryParameter(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch, String continuationToken) { StringBuffer sb = new StringBuffer(); boolean hasParameter = false; if (StringUtils.isNoneEmpty(repositoryId)) { sb.append("repository=").append(repositoryId); //$NON-NLS-1$ hasParameter = true;/*w w w .j a v a2s. c o m*/ } if (StringUtils.isNoneEmpty(groupIdToSearch)) { if (hasParameter) { sb.append("&"); //$NON-NLS-1$ } sb.append("group=").append(groupIdToSearch); //$NON-NLS-1$ hasParameter = true; } if (StringUtils.isNoneEmpty(artifactId)) { if (hasParameter) { sb.append("&"); //$NON-NLS-1$ } sb.append("name=").append(artifactId); //$NON-NLS-1$ hasParameter = true; } if (StringUtils.isNoneEmpty(versionToSearch)) { if (hasParameter) { sb.append("&"); //$NON-NLS-1$ } sb.append("version=").append(versionToSearch); //$NON-NLS-1$ hasParameter = true; } if (StringUtils.isNoneEmpty(continuationToken)) { if (hasParameter) { sb.append("&"); //$NON-NLS-1$ } sb.append("continuationToken=").append(continuationToken); //$NON-NLS-1$ hasParameter = true; } return sb.toString(); }
From source file:se.trixon.jota.server.JobExecutor.java
@Override public void run() { mLastRun = System.currentTimeMillis(); mHistoryBuilder = new StringBuilder(); String dryRunIndicator = ""; if (mDryRun) { dryRunIndicator = String.format(" (%s)", Dict.DRY_RUN.toString()); }/*from w w w. ja va 2 s . c o m*/ mHistoryBuilder .append(String.format("%s %s%s\n", Jota.nowToDateTime(), Dict.STARTED.toString(), dryRunIndicator)); String s = String.format("%s %s: '%s'='%s'", Jota.nowToDateTime(), Dict.START.toString(), Dict.JOB.toString(), mJob.getName()); mOutBuffer.append(s).append("\n"); send(ProcessEvent.OUT, s); JobExecuteSection jobExecute = mJob.getExecuteSection(); try { String command; // run before first task command = jobExecute.getBeforeCommand(); if (jobExecute.isBefore() && StringUtils.isNoneEmpty(command)) { run(command, jobExecute.isBeforeHaltOnError(), mJobExecBundle.getString("JobPanel.beforePanel.header")); } runTasks(); if (mNumOfFailedTasks == 0) { // run after last task - if all ok command = jobExecute.getAfterSuccessCommand(); if (jobExecute.isAfterSuccess() && StringUtils.isNoneEmpty(command)) { run(command, false, mJobExecBundle.getString("JobPanel.afterSuccessPanel.header")); } } else { s = String.format(Dict.TASKS_FAILED.toString(), mNumOfFailedTasks); mOutBuffer.append(s).append("\n"); send(ProcessEvent.OUT, s); // run after last task - if any failed command = jobExecute.getAfterFailureCommand(); if (jobExecute.isAfterFailure() && StringUtils.isNoneEmpty(command)) { run(command, false, mJobExecBundle.getString("JobPanel.afterFailurePanel.header")); } } // run after last task command = jobExecute.getAfterCommand(); if (jobExecute.isAfter() && StringUtils.isNoneEmpty(command)) { run(command, false, mJobExecBundle.getString("JobPanel.afterPanel.header")); } Thread.sleep(500); mHistoryBuilder.append(String.format("%s %s\n", Jota.nowToDateTime(), Dict.DONE.toString())); s = String.format("%s %s: %s", Jota.nowToDateTime(), Dict.DONE.toString(), Dict.JOB.toString()); mOutBuffer.append(s).append("\n"); updateJobStatus(0); writelogs(); send(ProcessEvent.FINISHED, s); Xlog.timedOut(String.format(Dict.JOB_FINISHED.toString(), mJob.getName())); } catch (InterruptedException ex) { mCurrentProcess.destroy(); mHistoryBuilder.append(String.format("%s %s\n", Jota.nowToDateTime(), Dict.CANCEL.toString())); updateJobStatus(99); writelogs(); mServer.getClientCallbacks().stream().forEach((clientCallback) -> { try { clientCallback.onProcessEvent(ProcessEvent.CANCELED, mJob, null, null); } catch (RemoteException ex1) { // nvm Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex1); } }); } catch (IOException ex) { writelogs(); Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionFailedException ex) { //Logger.getLogger(JobExecutor.class.getName()).log(Level.SEVERE, null, ex); //send(ProcessEvent.OUT, "before failed and will not continue"); mHistoryBuilder.append(String.format("%s %s\n", Jota.nowToDateTime(), Dict.FAILED.toString())); updateJobStatus(1); writelogs(); send(ProcessEvent.FAILED, String.format("\n\n%s", Dict.JOB_FAILED.toString())); } mServer.getJobExecutors().remove(mJob.getId()); }
From source file:se.trixon.jota.server.JobExecutor.java
private boolean runTask(Task task) throws InterruptedException { StringBuilder taskHistoryBuilder = new StringBuilder(); String dryRunIndicator = ""; if (mDryRun || task.isDryRun()) { dryRunIndicator = String.format(" (%s)", Dict.DRY_RUN.toString()); }//from w w w . ja v a2 s . com taskHistoryBuilder .append(String.format("%s %s%s\n", Jota.nowToDateTime(), Dict.STARTED.toString(), dryRunIndicator)); String s = String.format("%s %s: %s='%s'", Jota.nowToDateTime(), Dict.START.toString(), Dict.TASK.toString(), task.getName()); send(ProcessEvent.OUT, s); mTaskFailed = false; boolean doNextStep = true; TaskExecuteSection taskExecute = task.getExecuteSection(); String command; // run before command = taskExecute.getBeforeCommand(); if (taskExecute.isBefore() && StringUtils.isNoneEmpty(command)) { doNextStep = runTaskStep(command, taskExecute.isBeforeHaltOnError(), mTaskExecBundle.getString("TaskExecutePanel.beforePanel.header")); } // run rsync if (doNextStep) { int exitValue = runRsync(task); boolean rsyncSuccess = exitValue == 0; s = String.format("%s %s: rsync (%s)", Jota.nowToDateTime(), Dict.DONE.toString(), getRsyncErrorCode(exitValue)); mOutBuffer.append(s).append("\n"); send(ProcessEvent.OUT, s); if (rsyncSuccess) { // run after success command = taskExecute.getAfterSuccessCommand(); if (taskExecute.isAfterSuccess() && StringUtils.isNoneEmpty(command)) { doNextStep = runTaskStep(command, taskExecute.isAfterSuccessHaltOnError(), mTaskExecBundle.getString("TaskExecutePanel.afterSuccessPanel.header")); } } else { // run after failure command = taskExecute.getAfterFailureCommand(); if (taskExecute.isAfterFailure() && StringUtils.isNoneEmpty(command)) { doNextStep = runTaskStep(command, taskExecute.isAfterFailureHaltOnError(), mTaskExecBundle.getString("TaskExecutePanel.afterFailurePanel.header")); } } } if (doNextStep) { // run after command = taskExecute.getAfterCommand(); if (taskExecute.isAfter() && StringUtils.isNoneEmpty(command)) { runTaskStep(command, taskExecute.isAfterHaltOnError(), mTaskExecBundle.getString("TaskExecutePanel.afterPanel.header")); } } if (mTaskFailed) { mNumOfFailedTasks++; } taskHistoryBuilder.append(String.format("%s %s\n", Jota.nowToDateTime(), Dict.DONE.toString())); mJotaManager.getTaskManager().getTaskById(task.getId()) .addHistory(taskHistoryBuilder.append("\n").toString()); s = String.format("%s %s: %s", Jota.nowToDateTime(), Dict.DONE.toString(), Dict.TASK.toString()); send(ProcessEvent.OUT, s); boolean doNextTask = !(mTaskFailed && taskExecute.isJobHaltOnError()); return doNextTask; }
From source file:zz.filecollector.ExtensionRegister.java
public IOFileFilter getFileFilter() { return new IOFileFilter() { @Override/*www . jav a2 s . c o m*/ public boolean accept(File file) { if (file != null) { return this.accept(file.getParentFile(), file.getName()); } return false; } @Override public boolean accept(File dir, String name) { if (StringUtils.isNoneEmpty(name)) { String ext = FilenameUtils.getExtension(name); if (StringUtils.isNoneEmpty(ext)) { return isPhoto(ext) || isVideo(ext); } } return false; } }; }