List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.biz.report.service.impl.ReportServiceImpl.java
@Override public List<Report3DataSet> readBarChart(String types, String months, String year) { if (!StringUtils.isEmpty(types) && types.contains("[")) { types = types.substring(1, types.length() - 1); }//from w w w . ja v a 2 s . c om if (!StringUtils.isEmpty(months) && months.contains("[")) { months = months.substring(1, months.length() - 1); } List list = reportDao.readPieChartData(types, year, months); List<Report2> reportList = new MappingEngine().getPieChartReport(list); List<Report3DataSet> dataSets = new ArrayList<Report3DataSet>(); for (Report2 r : reportList) { dataSets.add(new Report3DataSet(r.getTypeName(), r.getAmount())); } return dataSets; }
From source file:com.ocs.dynamo.importer.impl.BaseXlsImporter.java
/** * Retrieves the numeric value of a cell * /*from w w w . ja v a 2 s .c om*/ * @param cell * @return */ protected Double getNumericValue(Cell cell) { if (cell != null && (Cell.CELL_TYPE_NUMERIC == cell.getCellType() || Cell.CELL_TYPE_BLANK == cell.getCellType())) { try { return cell.getNumericCellValue(); } catch (NullPointerException nex) { // cannot return null from getNumericCellValue - so if the cell // is empty we // have to handle it in this ugly way return null; } catch (Exception ex) { throw new OCSImportException("Found an invalid numeric value: " + cell.getStringCellValue(), ex); } } else if (cell != null && Cell.CELL_TYPE_STRING == cell.getCellType()) { // in case the value is not numeric, simply output a warning. If the // field is required, this will trigger // an error at a later stage if (!StringUtils.isEmpty(cell.getStringCellValue().trim())) { throw new OCSImportException("Found an invalid numeric value: " + cell.getStringCellValue()); } } return null; }
From source file:uk.ac.ebi.ep.parser.parsers.DiseaseParser.java
private void LoadToDB(String[] fields) throws InterruptedException { double[] scores = new double[1]; if (fields.length >= 4) { String[] scoresCell = fields[4].split(" ?/ ?"); String accession = fields[0]; String[] omimCell = fields[1].split("\\s"); String[] meshIdsCell = fields[2].split(" ?/ ?"); String[] meshHeadsCell = fields[3].split(" / "); if (fields[4].contains("/")) { scores = new double[scoresCell.length]; for (int i = 0; i < scoresCell.length; i++) { final String scoreString = scoresCell[i].trim(); if (scoreString.equals("exact")) { scores[i] = Double.MAX_VALUE; } else { scores[i] = Double.valueOf(scoreString); }/*from www .j a va 2 s . c o m*/ } } else { if (scoresCell[0].equals("exact")) { scores[0] = Double.MAX_VALUE; } else { scores[0] = Double.valueOf(scoresCell[0]); } } String definition = ""; String url = "#"; for (int i = 0; i < scores.length; i++) { //check to see if accession is an enzyme Optional<UniprotEntry> enzyme = uniprotEntryService.findByAccession(accession); if (enzyme.isPresent()) { if (!meshHeadsCell[i].contains(" ")) { definition = bioPortalService.getDiseaseDescription(meshHeadsCell[i]); } else { definition = bioPortalService.getDiseaseDescription(meshIdsCell[i].trim()); } Optional<EnzymePortalSummary> summary = enzymeSummaryRepository.findDiseaseEvidence(accession); EnzymePortalDisease disease = new EnzymePortalDisease(); String diseaseName = resolveSpecialCharacters(meshHeadsCell[i].toLowerCase(Locale.ENGLISH)); disease.setDiseaseName(diseaseName.replaceAll(",", "").trim()); disease.setMeshId(meshIdsCell[i].trim()); disease.setOmimNumber(omimCell[0]); disease.setScore(Double.toString(scores[i])); disease.setDefinition(definition); disease.setUniprotAccession(enzyme.get()); if (summary.isPresent()) { disease.setEvidence(summary.get().getCommentText()); } if (!StringUtils.isEmpty(omimCell[0]) && !omimCell[0].equals("-")) { url = "http://purl.bioontology.org/ontology/OMIM/" + omimCell[0]; } else { url = "http://purl.bioontology.org/ontology/MESH/" + meshIdsCell[i]; } disease.setUrl(url); diseaseList.add(disease); // LOGGER.debug(accession + " mim : " + omimCell[0] + " mesh :" + meshIdsCell[i] // + " name: " + meshHeadsCell[i] + " score : " + scores[i]); // // System.out.println(accession + " mim : " + omimCell[0] + " mesh :" + meshIdsCell[i] // + " name: " + meshHeadsCell[i] + " score : " + scores[i] +"evidence "+ disease.getEvidence()); } } } else { LOGGER.fatal("ArrayIndexOutOfBoundsException. The size of fields is " + fields.length); // throw new ArrayIndexOutOfBoundsException(); } }
From source file:org.sakuli.actions.screenbased.TypingUtil.java
/** * Decrypt and enters the given text one character/key after another using keyDown/keyUp. * The entered text will be masked at the logging. For the deatails of the decryption see {@link #decryptSecret(String)}. * <p>/* ww w .j ava 2 s . co m*/ * About the usable Key constants see documentation of {@link org.sikuli.script.Key}. * The function could also type UTF-8 unicode characters, if the OS supports it. * The text is entered at the current position of the focus. * </p> * * @param text containing characters and/or {@link org.sikuli.script.Key} constants * @param optModifiers (optional) an String with only {@link org.sikuli.script.Key} constants. * @return this {@link A} or NULL on errors. */ public A typeAndDecrypt(String text, String optModifiers) { if (StringUtils.isEmpty(optModifiers)) { return typeImpl(decryptSecret(text), false); } return typeModifiedImpl(decryptSecret(text), optModifiers, false); }
From source file:net.phoenix.thrift.xml.ArgsBeanDefinitionParser.java
/** * InetSocketAddress server socket?/* w ww . java2 s. com*/ * * @param element * @param parserContext * @return */ protected AbstractBeanDefinition buildInetSocketAddress(Element element) { int port = Integer.parseInt(element.getAttribute("port")); String hostname = element.getAttribute("hostname"); BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(InetSocketAddress.class); if (!StringUtils.isEmpty(hostname)) builder.addConstructorArgValue(hostname); builder.addConstructorArgValue(port); return builder.getBeanDefinition(); }
From source file:com.capitalone.dashboard.collector.TeamDataClient.java
/** * Explicitly updates queries for the source system, and initiates the * update to MongoDB from those calls./*w ww. j a va 2s . c o m*/ */ public void updateTeamInformation() throws HygieiaException { // super.objClass = ScopeOwnerCollectorItem.class; String returnDate = getFeatureSettings().getDeltaCollectorItemStartDate(); if (!StringUtils.isEmpty(getMaxChangeDate())) { returnDate = getMaxChangeDate(); } returnDate = DateUtil.getChangeDateMinutePrior(returnDate, getFeatureSettings().getScheduledPriorMin()); String queryName = getFeatureSettings().getTeamQuery(); String query = getQuery(returnDate, queryName); updateObjectInformation(query); }
From source file:de.codecentric.boot.admin.config.AdminClientProperties.java
private String append(String uri, String path) { String baseUri = uri.replaceFirst("/+$", ""); if (StringUtils.isEmpty(path)) { return baseUri; }//from w w w. ja v a 2s . co m String normPath = path.replaceFirst("^/+", "").replaceFirst("/+$", ""); return baseUri + "/" + normPath; }
From source file:com.biz.report.service.impl.RepReportServiceImpl.java
public List<Report5DataSet> readDataForLineChart(String reps, String months, String year) { if (!StringUtils.isEmpty(reps) && reps.contains("[")) { reps = reps.substring(1, reps.length() - 1); }/*from www .j a va2s . c o m*/ String[] typeAr; if (!StringUtils.isEmpty(reps) && reps.contains(",")) { typeAr = reps.split("[,]"); } else { typeAr = new String[] { reps }; } if (!StringUtils.isEmpty(months) && months.contains("[")) { months = months.substring(1, months.length() - 1); } String[] monthAr; if (!StringUtils.isEmpty(months) && months.contains(",")) { monthAr = months.split("[,]"); } else { monthAr = new String[] { months }; } int typeCount = typeAr.length; List list = repReportDao.read(reps, months, year); List<Report1> reportList = new MappingEngine().getList(list); logger.info(reportList.size()); List<Report5DataSet> dataSets = new ArrayList<Report5DataSet>(); for (int i = 0; i < typeCount; i++) { List<DataPoint> dataPoints = constructDataPoints(reportList, typeAr[i].trim(), monthAr, i); dataSets.add(new Report5DataSet(dataPoints, typeAr[i])); } return dataSets; }
From source file:org.elasticsoftware.elasterix.server.messages.AbstractSipMessage.java
/** * Tokenizes value belonging to given header, e.g. * Authorization: Digest username="124",realm="elasticsoftware",nonce="24855234", * uri="sip:sip.outerteams.com:5060",response="749c35e9fe30d6ba46cc801bdfe535a0",algorithm=MD5 * <br>//from w ww. j av a2s .co m * <br> * will be tokenized into: * <ol> * <li>digest -> digest</li> * <li>username -> 124</li> * <li>realm -> elasticsoftware</li> * <li>nonce -> 24855234</li> * <li>uri -> sip:sip.outerteams.com:5060</li> * <li>response -> 749c35e9fe30d6ba46cc801bdfe535a0</li> * <li>algorithm -> MD5</li> * </ol> * <br> * <b>This method does **not** handle spaces and comma correctly in attribute values</b> * * @param value * @return */ public Map<String, String> tokenize(SipHeader header) { Map<String, String> map = new HashMap<String, String>(); // sanity check String value = getHeader(header); if (StringUtils.isEmpty(value)) { return map; } // Authorization: Digest username="124",realm="elasticsoftware",nonce="24855234", // uri="sip:sip.outerteams.com:5060",response="749c35e9fe30d6ba46cc801bdfe535a0",algorithm=MD5 StringTokenizer st = new StringTokenizer(value, " ,", false); while (st.hasMoreTokens()) { String token = st.nextToken(); int idx = token.indexOf("="); if (idx != -1) { map.put(token.substring(0, idx).toLowerCase(), token.substring(idx + 1).replace('\"', ' ').trim()); } else { map.put(token.toLowerCase(), token); } } return map; }
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.lucene.tools.LuceneTaxonomyMapper.java
public static Document getLuceneDocumentFromIAView(InformationAssetView iaViewSample) { Document doc = new Document(); doc.add(new StringField(InformationAssetViewFields.DOCREFERENCE.toString(), iaViewSample.getDOCREFERENCE(), Field.Store.YES));/*w w w .ja va2 s . c om*/ doc.add(new TextField(InformationAssetViewFields.DESCRIPTION.toString(), iaViewSample.getDESCRIPTION(), Field.Store.YES)); if (!StringUtils.isEmpty(iaViewSample.getCATDOCREF())) { doc.add(new StringField(InformationAssetViewFields.CATDOCREF.toString(), iaViewSample.getCATDOCREF(), Field.Store.YES)); } if (!StringUtils.isEmpty(iaViewSample.getTITLE())) { doc.add(new TextField(InformationAssetViewFields.TITLE.toString(), iaViewSample.getTITLE(), Field.Store.YES)); } if (!StringUtils.isEmpty(iaViewSample.getCONTEXTDESCRIPTION())) { doc.add(new TextField(InformationAssetViewFields.CONTEXTDESCRIPTION.toString(), iaViewSample.getCONTEXTDESCRIPTION(), Field.Store.YES)); } if (iaViewSample.getCORPBODYS() != null) { doc.add(new TextField(InformationAssetViewFields.CORPBODYS.toString(), Arrays.toString(iaViewSample.getCORPBODYS()), Field.Store.YES)); } if (iaViewSample.getPERSON_FULLNAME() != null) { doc.add(new TextField(InformationAssetViewFields.PERSON_FULLNAME.toString(), Arrays.toString(iaViewSample.getPERSON_FULLNAME()), Field.Store.YES)); } if (iaViewSample.getPLACE_NAME() != null) { doc.add(new TextField(InformationAssetViewFields.PLACE_NAME.toString(), Arrays.toString(iaViewSample.getPLACE_NAME()), Field.Store.YES)); } if (iaViewSample.getSUBJECTS() != null) { doc.add(new TextField(InformationAssetViewFields.SUBJECTS.toString(), Arrays.toString(iaViewSample.getSUBJECTS()), Field.Store.YES)); } if (iaViewSample.getSOURCE() != null) { doc.add(new IntField(InformationAssetViewFields.SOURCE.toString(), Integer.parseInt(iaViewSample.getSOURCE()), Field.Store.YES)); } return doc; }