List of usage examples for org.apache.commons.lang3 StringUtils defaultString
public static String defaultString(final String str)
Returns either the passed in String, or if the String is null , an empty String ("").
StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
From source file:de.micromata.genome.gwiki.controls.GWikiPageListActionBean.java
public String renderField(String fieldName, GWikiElementInfo elementInfo) { if (StringUtils.equals(fieldName, "PAGEID") == true) { return WebUtils.escapeHtml(elementInfo.getId()); }//from ww w .j av a 2s .co m if (StringUtils.equals(fieldName, GWikiPropKeys.TITLE) == true) { return WebUtils.escapeHtml(elementInfo.getTitle()); } String val = elementInfo.getProps().getStringValue(fieldName); if (GWikiPropKeys.CREATEDAT.equals(fieldName) == true || GWikiPropKeys.MODIFIEDAT.equals(fieldName) == true) { val = WebUtils.escapeHtml(wikiContext.getUserDateString(GWikiProps.parseTimeStamp(val))); } return WebUtils.escapeHtml(StringUtils.defaultString(val)); }
From source file:com.netsteadfast.greenstep.bsc.command.TimeSeriesAnalysisExcelCommand.java
private void putTables(XSSFWorkbook wb, XSSFSheet sh, Context context) throws Exception { TsaVO tsa = (TsaVO) context.get("tsa"); @SuppressWarnings("unchecked") List<BbTsaMaCoefficients> coefficients = (List<BbTsaMaCoefficients>) context.get("coefficients"); @SuppressWarnings("unchecked") List<TimeSeriesAnalysisResult> tsaResults = (List<TimeSeriesAnalysisResult>) context.get("tsaResults"); XSSFFont cellHeadFont = wb.createFont(); cellHeadFont.setBold(true);//from w w w . jav a 2s . c om XSSFCellStyle cellHeadStyle = wb.createCellStyle(); cellHeadStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#f5f5f5"))); cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellHeadStyle.setBorderBottom(BorderStyle.THIN); cellHeadStyle.setBorderTop(BorderStyle.THIN); cellHeadStyle.setBorderRight(BorderStyle.THIN); cellHeadStyle.setBorderLeft(BorderStyle.THIN); cellHeadStyle.setFont(cellHeadFont); XSSFCellStyle cellHeadStyleBlank = wb.createCellStyle(); cellHeadStyleBlank.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff"))); cellHeadStyleBlank.setFont(cellHeadFont); XSSFCellStyle cellHeadStyle2 = wb.createCellStyle(); cellHeadStyle2.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff"))); cellHeadStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellHeadStyle2.setBorderBottom(BorderStyle.THIN); cellHeadStyle2.setBorderTop(BorderStyle.THIN); cellHeadStyle2.setBorderRight(BorderStyle.THIN); cellHeadStyle2.setBorderLeft(BorderStyle.THIN); sh.setColumnWidth(0, 12000); int row = 0; // ============================================================== Row nowRow = sh.createRow(row); Cell cellTitle = nowRow.createCell(0); cellTitle.setCellStyle(cellHeadStyleBlank); cellTitle.setCellValue("Forecast analysis - " + context.get("visionName")); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell0a = nowRow.createCell(0); cell0a.setCellStyle(cellHeadStyleBlank); cell0a.setCellValue("Frequency: " + context.get("frequencyName") + " , Date range: " + context.get("date1") + " - " + context.get("date2") + " , " + "Measure data type for: " + context.get("dataFor") + " , " + context.get("organizationName") + context.get("employeeName")); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell0b = nowRow.createCell(0); cell0b.setCellStyle(cellHeadStyleBlank); cell0b.setCellValue(""); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell1 = nowRow.createCell(0); cell1.setCellStyle(cellHeadStyleBlank); cell1.setCellValue("Param infornation"); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell2_a = nowRow.createCell(0); cell2_a.setCellStyle(cellHeadStyle); cell2_a.setCellValue("Item"); Cell cell2_b = nowRow.createCell(1); cell2_b.setCellStyle(cellHeadStyle); cell2_b.setCellValue("Value"); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell3_a = nowRow.createCell(0); cell3_a.setCellStyle(cellHeadStyle2); cell3_a.setCellValue("Param name"); Cell cell3_b = nowRow.createCell(1); cell3_b.setCellStyle(cellHeadStyle2); cell3_b.setCellValue(tsa.getName()); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell4_a = nowRow.createCell(0); cell4_a.setCellStyle(cellHeadStyle2); cell4_a.setCellValue("Integration order"); Cell cell4_b = nowRow.createCell(1); cell4_b.setCellStyle(cellHeadStyle2); cell4_b.setCellValue(tsa.getIntegrationOrder()); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell5_a = nowRow.createCell(0); cell5_a.setCellStyle(cellHeadStyle2); cell5_a.setCellValue("Forecast next"); Cell cell5_b = nowRow.createCell(1); cell5_b.setCellStyle(cellHeadStyle2); cell5_b.setCellValue(tsa.getForecastNext()); row++; // ============================================================== nowRow = sh.createRow(row); Cell cell6_a = nowRow.createCell(0); cell6_a.setCellStyle(cellHeadStyle2); cell6_a.setCellValue("Description"); Cell cell6_b = nowRow.createCell(1); cell6_b.setCellStyle(cellHeadStyle2); cell6_b.setCellValue(StringUtils.defaultString(tsa.getDescription()).trim()); row++; // ============================================================== for (int i = 0; coefficients != null && i < coefficients.size(); i++) { BbTsaMaCoefficients coefficient = coefficients.get(i); nowRow = sh.createRow(row); Cell cell7x_a = nowRow.createCell(0); cell7x_a.setCellStyle(cellHeadStyle2); cell7x_a.setCellValue("Coefficient (" + (i + 1) + ")"); Cell cell7x_b = nowRow.createCell(1); cell7x_b.setCellStyle(cellHeadStyle2); cell7x_b.setCellValue(String.valueOf(coefficient.getSeqValue())); row++; } // ============================================================== nowRow = sh.createRow(row); Cell cellTitle3a = nowRow.createCell(0); cellTitle3a.setCellStyle(cellHeadStyleBlank); cellTitle3a.setCellValue(""); row++; // nowRow = sh.createRow(row); Cell cellTitle2a = nowRow.createCell(0); cellTitle2a.setCellStyle(cellHeadStyle); cellTitle2a.setCellValue("KPIs"); int j = 1; TimeSeriesAnalysisResult firstResult = tsaResults.get(0); for (int i = 0; i < firstResult.getKpi().getDateRangeScores().size(); i++) { DateRangeScoreVO dateRangeScore = firstResult.getKpi().getDateRangeScores().get(i); Cell cellTitle2a_dateRange = nowRow.createCell(j); j++; cellTitle2a_dateRange.setCellStyle(cellHeadStyle); cellTitle2a_dateRange.setCellValue(dateRangeScore.getDate()); } for (int i = 0; i < firstResult.getForecastNext().size(); i++) { Cell cellTitle2a_dateRange = nowRow.createCell(j); j++; cellTitle2a_dateRange.setCellStyle(cellHeadStyle); cellTitle2a_dateRange.setCellValue("next(" + (i + 1) + ")"); } row++; // Date Range score Forecast next score for (int i = 0; i < tsaResults.size(); i++) { nowRow = sh.createRow(row); j = 0; TimeSeriesAnalysisResult resultModel = tsaResults.get(i); Cell cell_kpi = nowRow.createCell(j); cell_kpi.setCellStyle(cellHeadStyle); cell_kpi.setCellValue(resultModel.getKpi().getName()); j++; for (int n = 0; n < resultModel.getKpi().getDateRangeScores().size(); n++) { DateRangeScoreVO dateRangeScore = resultModel.getKpi().getDateRangeScores().get(n); Cell cell_dateRangeScore = nowRow.createCell(j); cell_dateRangeScore.setCellStyle(cellHeadStyle2); cell_dateRangeScore.setCellValue(dateRangeScore.getScore()); j++; } for (int n = 0; n < resultModel.getForecastNext().size(); n++) { double forecastScore = resultModel.getForecastNext().get(n); Cell cell_forecastScore = nowRow.createCell(j); cell_forecastScore.setCellStyle(cellHeadStyle2); cell_forecastScore.setCellValue(forecastScore); j++; } row++; } }
From source file:io.github.swagger2markup.internal.document.PathsDocument.java
/** * Returns the basePath which should be prepended to the relative path * * @return either the relative or the full path *//*from w w w. j a v a 2 s. co m*/ private String getBasePath() { if (config.isBasePathPrefixEnabled()) { return StringUtils.defaultString(context.getSwagger().getBasePath()); } return ""; }
From source file:net.andydvorak.intellij.lessc.ui.configurable.LessProfileConfigurableForm.java
@Nullable private String promptForFilePath(final @Nullable String initial) { @NotNull/*ww w . j av a 2s . c o m*/ final String initialNN = StringUtils.defaultString(initial); final FileChooserDescriptor d = getFileChooserDescriptor(); final VirtualFile initialFile = StringUtil.isNotEmpty(initialNN) ? LocalFileSystem.getInstance().findFileByPath(initialNN) : null; final VirtualFile file = project != null ? FileChooser.chooseFile(project, d, initialFile) : FileChooser.chooseFile(profileMappingTable, d, initialFile); String path = null; if (file != null) { path = file.getPresentableUrl(); if (SystemInfo.isWindows && path.length() == 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') { path += "\\"; // make path absolute } } return path; }
From source file:com.sonicle.webtop.core.util.NotificationHelper.java
/** * Builds notification template.// w w w.ja va 2 s .co m * This uses a custom body that supports a custom html body. */ public static String buildCustomBodyTpl(Locale locale, String source, String recipientEmail, String bodyHeader, String customBodyHtml, String becauseString) throws IOException, TemplateException { MapItem notMap = new MapItem(); notMap.putAll(createCustomBodyTplStrings(locale, source, recipientEmail, bodyHeader, customBodyHtml, becauseString)); MapItem map = new MapItem(); map.put("recipientEmail", StringUtils.defaultString(recipientEmail)); return builTpl(notMap, map); }
From source file:com.netsteadfast.greenstep.util.SystemFormUtils.java
public static String getViewPage(Map<String, String> resultMap) { return StringUtils.defaultString(resultMap.get("viewPage")); }
From source file:com.netsteadfast.greenstep.base.interceptor.UserLoginInterceptor.java
/** * 1. admin/* w w w. j a va2s . c o m*/ * 2. admin tester * gsbsc-web http-session admin , ?core-webtestersession , ??CURRENT cookie ? gsbsc-web * ??? http-session * * @param actionContext * @throws Exception */ private void invalidCurrentSessionForDifferentAccount(ActionContext actionContext) throws Exception { if (this.accountObj == null) { return; } Map<String, String> dataMap = UserCurrentCookie .getCurrentData((HttpServletRequest) actionContext.get(StrutsStatics.HTTP_REQUEST)); String account = StringUtils.defaultString(dataMap.get("account")); if (StringUtils.isBlank(account)) { return; } if (this.accountObj.getAccount().equals(account)) { return; } this.accountObj = null; UserAccountHttpSessionSupport.remove(actionContext.getSession()); Subject subject = SecurityUtils.getSubject(); if (subject.isAuthenticated() && !account.equals(subject.getPrincipal())) { subject.logout(); } }
From source file:controllers.modules.AspectLexBuilder.java
public static Html renderDocumentsView(UUID corpus, UUID lexicon) { LexiconBuilderDocumentStore builder = fetchBuilder(corpus, lexicon); DocumentCorpus corpusObj = fetchResource(corpus, DocumentCorpus.class); AspectLexicon lexiconObj = fetchResource(lexicon, AspectLexicon.class); DocumentCorpusModel corpusVM = (DocumentCorpusModel) createViewModel(corpusObj); corpusVM.populateSize(em(), corpusObj); AspectLexiconModel lexiconVM = (AspectLexiconModel) createViewModel(lexiconObj); lexiconVM.populateSize(em(), lexiconObj); return documentSlider.render(corpusVM, lexiconVM, corpusObj.getLinguisticProcessor().getBasicPosTags(), Lists.newArrayList(Splitter.on("|") .split(StringUtils.defaultString(builder.getProperty("emphasizedTags", String.class))))); }
From source file:edu.toronto.cs.phenotips.tools.PropertyDisplayer.java
private FormElement generateField(String id, String title, boolean expandable, boolean yesSelected, boolean noSelected) { String hint = getLabelFromOntology(id); if (id.equals(hint) && title != null) { hint = title;//from w w w. j ava 2 s . c o m } String metadata = ""; Map<String, String> metadataValues = this.metadata.get(id); if (metadataValues != null) { metadata = metadataValues .get(noSelected ? this.data.getNegativePropertyName() : this.data.getPositivePropertyName()); } return new FormField(id, StringUtils.defaultIfEmpty(title, hint), hint, StringUtils.defaultString(metadata), expandable, yesSelected, noSelected); }
From source file:com.netsteadfast.greenstep.bsc.action.DegreeFeedbackProjectSaveOrUpdateAction.java
private void confirmProcessFlowTask() throws ControllerException, AuthorityException, ServiceException, Exception { String projectOid = StringUtils.defaultString(this.getFields().get("projectOid")); String taskId = StringUtils.defaultString(this.getFields().get("taskId")); String reason = StringUtils.defaultString(this.getFields().get("reason")); String confirm = StringUtils.defaultString(this.getFields().get("confirm")); this.degreeFeedbackLogicService.confirmTask(projectOid, taskId, reason, confirm); this.success = IS_YES; this.message = SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS); }