List of usage examples for org.apache.commons.lang3 StringUtils isNumeric
public static boolean isNumeric(final CharSequence cs)
Checks if the CharSequence contains only Unicode digits.
From source file:org.openlmis.core.view.viewmodel.StockMovementViewModel.java
private boolean isAnyQuantitiesNumeric() { return StringUtils.isNumeric(getReceived()) || StringUtils.isNumeric(getNegativeAdjustment()) || StringUtils.isNumeric(getPositiveAdjustment()) || StringUtils.isNumeric(getIssued()); }
From source file:org.openmrs.module.amrsreports.util.EmrUtils.java
/** * Parses a CSV list of concept ids, UUIDs or mappings * @param value the string/* w ww . ja va2 s . c o m*/ * @return the concepts */ public static List<Concept> parseConceptList(String value) { List<Concept> concepts = new ArrayList<Concept>(); for (String token : value.split(",")) { token = token.trim(); if (!StringUtils.isEmpty(token)) { if (StringUtils.isNumeric(token)) { concepts.add(Context.getConceptService().getConcept(Integer.valueOf(token))); } else { concepts.add(MohCacheUtils.getConcept(token)); } } } return concepts; }
From source file:org.openmrs.module.diseaseregistry.web.controller.workflow.WorkflowController.java
private void updateTests(HttpServletRequest request, DRWorkflow workflow) { DiseaseRegistryService drs = Context.getService(DiseaseRegistryService.class); List<DRConcept> tests = new ArrayList<DRConcept>( drs.getConceptByWorkflow(workflow, DiseaseRegistryService.NOT_INCLUDE_RETIRED)); String[] ids = request.getParameterValues("tests"); // add new and update existing tests for (int i = 0; i < ids.length; i++) { String key = ids[i];//from ww w . j a v a 2s . c o m if (StringUtils.isNumeric(key)) { String value = request.getParameter(key); DRConcept test = drs.getConcept(key); if (test == null) { // add new test test = new DRConcept(); test.setConcept(Context.getConceptService().getConcept(value)); test.setDrConceptId(key); test.setWeight(i); test.setWorkflow(workflow); test.setCreator(Context.getAuthenticatedUser()); test.setDateCreated(new Date()); drs.saveConcept(test); } else { // update concept test.setConcept(Context.getConceptService().getConcept(value)); test.setDrConceptId(key); test.setWeight(i); test.setWorkflow(workflow); test.setDateChanged(new Date()); drs.saveConcept(test); tests.remove(test); } } } // retired tests for (DRConcept test : tests) { test.setVoided(true); test.setVoidedBy(Context.getAuthenticatedUser()); test.setDateVoided(new Date()); drs.saveConcept(test); } }
From source file:org.openmrs.module.kenyaemr.util.EmrUtils.java
/** * Parses a CSV list of concept ids, UUIDs or mappings * @param csv the CSV string/*from w ww. ja v a 2s. c om*/ * @return the concepts */ public static List<Concept> parseConcepts(String csv) { List<String> identifiers = parseCsv(csv); List<Concept> concepts = new ArrayList<Concept>(); for (String identifier : identifiers) { if (StringUtils.isNumeric(identifier)) { concepts.add(Context.getConceptService().getConcept(Integer.valueOf(identifier))); } else { concepts.add(Dictionary.getConcept(identifier)); } } return concepts; }
From source file:org.openmrs.module.kenyaemr.util.KenyaEmrUtils.java
/** * Parses a CSV list of concept ids, UUIDs or mappings * @param value the string//from w ww.ja va 2 s . com * @return the concepts */ public static List<Concept> parseConceptList(String value) { List<Concept> concepts = new ArrayList<Concept>(); for (String token : value.split(",")) { token = token.trim(); if (!StringUtils.isEmpty(token)) { if (StringUtils.isNumeric(token)) { concepts.add(Context.getConceptService().getConcept(Integer.valueOf(token))); } else { concepts.add(Dictionary.getConcept(token)); } } } return concepts; }
From source file:org.opensilk.music.library.mediastore.provider.MediaStoreLibraryProvider.java
@Override protected void getTrack(String library, String identity, Subscriber<? super Track> subscriber, Bundle args) { if (StringUtils.isNumeric(identity)) { TracksLoader l = mTracksLoaderProvider.get(); l.setUri(appendId(Uris.EXTERNAL_MEDIASTORE_MEDIA, identity)); l.createObservable().doOnNext(new Action1<Track>() { @Override/*from w ww . j a va2 s . c o m*/ public void call(Track track) { Timber.v("Track name=%s artist=%s albumArtist=%s", track.name, track.artistName, track.albumArtistName); } }).subscribe(subscriber); } else { final File base = mStorageLookup.getStorageFile(library); final File f = new File(base, identity); if (!f.exists() || !f.isFile() || !f.canRead()) { Timber.e("Can't access path %s", f.getPath()); subscriber.onError(new IllegalArgumentException("Can't access path " + f.getPath())); } else { try { subscriber.onNext(FilesUtil.makeTrackFromFile(base, f)); subscriber.onCompleted(); } catch (Exception e) { subscriber.onError(e); } } } }
From source file:org.opensilk.video.util.Utils.java
public static int extractSeasonNumber(CharSequence title) { int num = -1; if (!StringUtils.isEmpty(title)) { Matcher m = TV_REGEX.matcher(title); if (m.matches()) { String episodes = m.group(2); if (!StringUtils.isEmpty(episodes)) { if (StringUtils.isNumeric(episodes)) { //101 style num = Character.getNumericValue(episodes.charAt(0)); } else { //s01e01 style int eidx = StringUtils.indexOfAny(episodes, "Ee"); num = Integer.valueOf(episodes.substring(1, eidx)); }//w w w. j a v a2s . co m } } } return num; }
From source file:org.opensilk.video.util.Utils.java
public static int extractEpisodeNumber(CharSequence title) { int num = -1; if (!StringUtils.isEmpty(title)) { Matcher m = TV_REGEX.matcher(title); if (m.matches()) { String episodes = m.group(2); if (!StringUtils.isEmpty(episodes)) { if (StringUtils.isNumeric(episodes)) { //101 style num = Integer.valueOf(episodes.substring(1)); } else { //s01e01 style int eidx = StringUtils.indexOfAny(episodes, "Ee"); num = Integer.valueOf(episodes.substring(eidx + 1)); }//from w w w . j a va 2s. c om } } } return num; }
From source file:org.opensingular.flow.core.SingularFlowConfigurationBean.java
@Nonnull protected final <X extends ProcessInstance, T extends ProcessDefinition<X>> Optional<X> getProcessInstanceOpt( @Nonnull Class<T> processClass, @Nonnull String id) { if (StringUtils.isNumeric(id)) { return getProcessInstanceOpt(processClass, Integer.valueOf(id)); }/*from ww w . ja v a 2 s . c o m*/ Optional<ProcessInstance> instance = getProcessInstanceOpt(id); if (instance.isPresent()) { getProcessDefinition(processClass).checkIfCompatible(instance.get()); } return (Optional<X>) instance; }
From source file:org.opensingular.form.persistence.service.AttachmentPersistenceService.java
@Override public AttachmentRef getAttachment(String fileId) { if (StringUtils.isNumeric(fileId)) { return new AttachmentRef(attachmentDao.findOrException(Long.valueOf(fileId))); }/*from www . j av a 2s . c o m*/ return null; }