List of usage examples for org.apache.commons.lang ArrayUtils isEmpty
public static boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null
.
From source file:gnete.card.web.merch.MerchAction.java
/** * ?????/*from w ww. ja v a 2 s. c o m*/ * @return * @throws Exception */ public String fenzhiCheckList() throws Exception { // ??ID String ids[] = workflowService.getMyJob(WorkflowConstants.WORKFLOW_CARD_ADD_MERCH, getSessionUser()); if (ArrayUtils.isEmpty(ids)) { this.page = new Paginater(this.getPageSize(), this.getPageNumber()); return "fenzhiCheckList"; } Map<String, Object> params = new HashMap<String, Object>(); params.put("ids", ids); this.page = this.merchInfoRegDAO.find(params, this.getPageNumber(), this.getPageSize()); return "fenzhiCheckList"; }
From source file:hudson.plugins.clearcase.ClearToolExec.java
@Override public void update(String viewPath, String[] loadRules) throws IOException, InterruptedException { FilePath filePath = getLauncher().getWorkspace().child(viewPath); ArgumentListBuilder cmd = new ArgumentListBuilder(); cmd.add("update"); cmd.add("-force"); cmd.add("-overwrite"); cmd.add("-log", "NUL"); if (!ArrayUtils.isEmpty(loadRules)) { cmd.add("-add_loadrules"); for (String loadRule : loadRules) { cmd.add(fixLoadRule(loadRule)); }// w w w. j a v a 2 s . c o m } List<IOException> exceptions = new ArrayList<IOException>(); String output = runAndProcessOutput(cmd, new ByteArrayInputStream("yes\nyes\n".getBytes()), filePath, true, exceptions); if (!exceptions.isEmpty()) { handleHijackedDirectoryCCBug(viewPath, filePath, exceptions, output); } }
From source file:com.photon.phresco.util.Utility.java
public static ProjectInfo getProjectInfo(String appDirPath, String module) throws PhrescoException { BufferedReader reader = null; Gson gson = new Gson(); ProjectInfo projectInfo = null;/* w ww. java 2 s .co m*/ File[] split_phresco = null; File[] split_src = null; File[] dotPhrescoFolders = null; File dotAppDir = null; File srcAppDir = null; try { File appDir = new File(appDirPath); String name = appDir.getName(); String[] split = appDirPath.split("###"); if (split.length > 1) { for (int i = 0; i < split.length;) { appDir = new File(split[0]); name = split[1]; break; } } if (StringUtils.isNotEmpty(module)) { File appDirT = new File(appDir + File.separator + module); dotPhrescoFolders = appDirT.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } else { dotPhrescoFolders = appDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } if (ArrayUtils.isEmpty(dotPhrescoFolders)) { if (StringUtils.isNotEmpty(module)) { dotAppDir = new File(appDir + File.separator + name + SUFFIX_PHRESCO + File.separator + module); } else { dotAppDir = new File(appDir + File.separator + name + SUFFIX_PHRESCO); } split_phresco = dotAppDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); if (ArrayUtils.isEmpty(split_phresco)) { if (StringUtils.isNotEmpty(module)) { srcAppDir = new File(appDir + File.separator + name + File.separator + module); } else { srcAppDir = new File(appDir + File.separator + name); } split_src = srcAppDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } } if (!ArrayUtils.isEmpty(dotPhrescoFolders)) { File[] dotProjectFiles = dotPhrescoFolders[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(dotProjectFiles)) { reader = new BufferedReader(new FileReader(dotProjectFiles[0])); projectInfo = gson.fromJson(reader, ProjectInfo.class); } } if (!ArrayUtils.isEmpty(split_phresco)) { File[] splitDotProjectFiles = split_phresco[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(splitDotProjectFiles)) { reader = new BufferedReader(new FileReader(splitDotProjectFiles[0])); projectInfo = gson.fromJson(reader, ProjectInfo.class); } } if (!ArrayUtils.isEmpty(split_src)) { File[] splitSrcDotProjectFiles = split_src[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(splitSrcDotProjectFiles)) { reader = new BufferedReader(new FileReader(splitSrcDotProjectFiles[0])); projectInfo = gson.fromJson(reader, ProjectInfo.class); } } return projectInfo; } catch (JsonSyntaxException e) { throw new PhrescoException(e); } catch (JsonIOException e) { throw new PhrescoException(e); } catch (FileNotFoundException e) { throw new PhrescoException(e); } finally { closeReader(reader); } }
From source file:com.photon.phresco.util.Utility.java
public static String getProjectInfoPath(String appDirPath, String module) throws PhrescoException { try {//from ww w . j a v a 2s . co m File appDir = new File(appDirPath); File[] split_phresco = null; File[] split_src = null; File[] dotPhrescoFolders = null; File dotAppDir = null; File srcAppDir = null; String projInfoPath = ""; if (StringUtils.isNotEmpty(module)) { File appDirT = new File(appDir + File.separator + module); dotPhrescoFolders = appDirT.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } else { dotPhrescoFolders = appDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } if (ArrayUtils.isEmpty(dotPhrescoFolders)) { if (StringUtils.isNotEmpty(module)) { dotAppDir = new File( appDir + File.separator + appDir.getName() + SUFFIX_PHRESCO + File.separator + module); } else { dotAppDir = new File(appDir + File.separator + appDir.getName() + SUFFIX_PHRESCO); } split_phresco = dotAppDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); if (ArrayUtils.isEmpty(split_phresco)) { if (StringUtils.isNotEmpty(module)) { srcAppDir = new File(appDir + File.separator + appDir.getName() + File.separator + module); } else { srcAppDir = new File(appDir + File.separator + appDir.getName()); } split_src = srcAppDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } } if (!ArrayUtils.isEmpty(dotPhrescoFolders)) { File[] dotProjectFiles = dotPhrescoFolders[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(dotProjectFiles)) { projInfoPath = dotProjectFiles[0].getPath(); } } if (!ArrayUtils.isEmpty(split_phresco)) { File[] splitDotProjectFiles = split_phresco[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(splitDotProjectFiles)) { projInfoPath = splitDotProjectFiles[0].getPath(); } } if (!ArrayUtils.isEmpty(split_src)) { File[] splitSrcDotProjectFiles = split_src[0] .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE)); if (!ArrayUtils.isEmpty(splitSrcDotProjectFiles)) { projInfoPath = splitSrcDotProjectFiles[0].getPath(); } } return projInfoPath; } catch (JsonSyntaxException e) { throw new PhrescoException(e); } catch (JsonIOException e) { throw new PhrescoException(e); } }
From source file:net.grinder.SingleConsole.java
private void checkExecutionErrors(ProcessReports[] processReports) { if (samplingCount == 0 && ArrayUtils.isNotEmpty(this.processReports) && ArrayUtils.isEmpty(processReports)) { getListeners().apply(new Informer<ConsoleShutdownListener>() { public void inform(ConsoleShutdownListener listener) { listener.readyToStop(StopReason.SCRIPT_ERROR); }//w ww.ja v a 2 s . c o m }); } }
From source file:gnete.card.service.impl.MerchServiceImpl.java
/** * ??/*from w w w . j a va 2s .co m*/ * @param arr ?? * @param count ??? * @param fieldNum ? * @param merchNameSet ?? * @throws BizException */ private void checkMerchName(String[] arr, int count, int fieldNum, Set<String> merchNameSet) throws BizException { // ???. if (arr.length != fieldNum) { String msg = "[" + count + "]?,?[" + fieldNum + "]"; logger.error(msg); throw new BizException(msg); } if (ArrayUtils.isEmpty(arr)) { throw new BizException("?"); } //???, String merchName = arr[0]; if (StringUtils.isBlank(merchName)) { throw new BizException("[" + count + " ]????"); } //????? if (merchNameSet.contains(merchName)) { throw new BizException("[" + merchName + "]??"); } merchNameSet.add(merchName); }
From source file:com.etcc.csc.dao.OraclePaymentDAO.java
public String getMonthlyStatementPaymentReceipt(BigDecimal docId, String docType, String dbSessionId, String ipAddress, String loginId, BigDecimal paymentId, String reportFormat) throws EtccErrorMessageException, Exception { String reportUrl = null;/*from w w w .j a v a 2s. co m*/ try { setConnection(Util.getDbConnection()); String[] O_REPORT_URL = new String[] { "" }; OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() }; int result = new OLCSC_INV(conn).GET_MONTHLY_STATEMENT_RCPT_RPT(reportFormat, docId, docType, paymentId, dbSessionId, ipAddress, loginId, O_REPORT_URL, O_ERROR_MSG_ARR).intValue(); if (result == 1) { if (!ArrayUtils.isEmpty(O_REPORT_URL)) { reportUrl = O_REPORT_URL[0].trim(); } } else { if (O_ERROR_MSG_ARR[0] != null && O_ERROR_MSG_ARR[0].getArray() != null && O_ERROR_MSG_ARR[0].getArray().length > 0) { OLC_ERROR_MSG_REC[] errorMsgRecs = O_ERROR_MSG_ARR[0].getArray(); EtccErrorMessageException em = new EtccErrorMessageException("postViolations error message"); for (int i = 0; i < errorMsgRecs.length; i++) { em.addRecoverable(errorMsgRecs[i].getERROR_MSG()); } throw em; } else { throw new EtccException("postViolations fatal error"); } } } finally { closeConnection(); } return reportUrl; }
From source file:com.photon.phresco.util.Utility.java
public static String getDotPhrescoFolderPath(String appDirPath, String module) throws PhrescoException { try {//from w w w .j a v a2 s .c o m File appDir = new File(appDirPath); File[] split_phresco = null; File[] split_src = null; File[] dotPhrescoFolders = null; File dotAppDir = null; File srcAppDir = null; String dotPhrescoPath = ""; if (StringUtils.isNotEmpty(module)) { File appDirT = new File(appDir + File.separator + module); dotPhrescoFolders = appDirT.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } else { dotPhrescoFolders = appDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } if (ArrayUtils.isEmpty(dotPhrescoFolders)) { if (StringUtils.isNotEmpty(module)) { dotAppDir = new File( appDir + File.separator + appDir.getName() + SUFFIX_PHRESCO + File.separator + module); } else { dotAppDir = new File(appDir + File.separator + appDir.getName() + SUFFIX_PHRESCO); } split_phresco = dotAppDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); if (ArrayUtils.isEmpty(split_phresco)) { if (StringUtils.isNotEmpty(module)) { srcAppDir = new File(appDir + File.separator + appDir.getName() + File.separator + module); } else { srcAppDir = new File(appDir + File.separator + appDir.getName()); } split_src = srcAppDir.listFiles(new PhrescoFileNameFilter(DOT_PHRESCO_FOLDER)); } } if (!ArrayUtils.isEmpty(dotPhrescoFolders)) { dotPhrescoPath = dotPhrescoFolders[0].getPath(); } if (!ArrayUtils.isEmpty(split_phresco)) { dotPhrescoPath = split_phresco[0].getPath(); } if (!ArrayUtils.isEmpty(split_src)) { dotPhrescoPath = split_src[0].getPath(); } return dotPhrescoPath; } catch (JsonSyntaxException e) { throw new PhrescoException(e); } catch (JsonIOException e) { throw new PhrescoException(e); } }
From source file:fr.paris.lutece.plugins.document.web.DocumentJspBean.java
/** * Processes document action for multiselection * @param request The Http request//from www . j a v a 2 s .com * @return The URL to redirect to */ public String doActionSelectionDocument(HttpServletRequest request) { String strAction = request.getParameter(PARAMETER_SELECTION); String[] strIdDocuments = (String[]) request.getParameterMap().get(PARAMETER_DOCUMENT_SELECTION); _multiSelectionValues = strIdDocuments; int nbDocumentsAffected = 0; if (!ArrayUtils.isEmpty(strIdDocuments)) { if (strAction.equals(CONSTANT_REMOVE)) { UrlItem url = new UrlItem(JSP_DO_REMOVE_SELECTION); return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_DELETE_SELECTION, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); } else if (strAction.equals(CONSTANT_ARCHIVE)) { UrlItem url = new UrlItem(JSP_DO_ARCHIVE_SELECTION); for (String strIdDocument : _multiSelectionValues) { int nIdDocument = IntegerUtils.convert(strIdDocument); Document document = DocumentHome.findByPrimaryKey(nIdDocument); // Test if the document is published or assigned boolean bPublishedDocument = PublishingService.getInstance().isAssigned(nIdDocument); if ((document != null) && (document.getStateId() == DocumentState.STATE_VALIDATE) && (bPublishedDocument)) { return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_ARCHIVE_SELECTION, PATH_JSP + url.getUrl(), AdminMessage.TYPE_QUESTION); } } for (String strIdDocument : _multiSelectionValues) { int nIdDocument = IntegerUtils.convert(strIdDocument); Document document = DocumentHome.findByPrimaryKey(nIdDocument); try { if ((document != null) && (document.getStateId() == DocumentState.STATE_VALIDATE) && isAuthorized(DocumentAction.ACTION_ARCHIVE, document)) { DocumentService.getInstance().archiveDocument(document, getUser(), DocumentState.STATE_ARCHIVED); } } catch (DocumentException e) { return getErrorMessageUrl(request, e.getI18nMessage()); } } } else { for (String strIdDocument : strIdDocuments) { int nIdDocument = IntegerUtils.convert(strIdDocument); int nActionId = -1; Document document = DocumentHome.findByPrimaryKey(nIdDocument); if (document != null) { int stateId = document.getStateId(); if ((strAction.equals(CONSTANT_VALIDATE)) && ((stateId == DocumentState.STATE_WAITING_FOR_APPROVAL) || (stateId == DocumentState.STATE_WAITING_FOR_CHANGE_APPROVAL))) { try { //set the action if (stateId == DocumentState.STATE_WAITING_FOR_APPROVAL) { nActionId = DocumentAction.ACTION_VALIDATE; } else if (stateId == DocumentState.STATE_WAITING_FOR_CHANGE_APPROVAL) { nActionId = DocumentAction.ACTION_VALIDATE_CHANGE; } if (isAuthorized(nActionId, document)) { DocumentService.getInstance().validateDocument(document, getUser(), DocumentState.STATE_VALIDATE); nbDocumentsAffected++; } } catch (DocumentException e) { return getErrorMessageUrl(request, e.getI18nMessage()); } } else if ((strAction.equals(CONSTANT_REFUSE)) && ((stateId == DocumentState.STATE_WAITING_FOR_APPROVAL) || (stateId == DocumentState.STATE_WAITING_FOR_CHANGE_APPROVAL))) { try { if (stateId == DocumentState.STATE_WAITING_FOR_APPROVAL) { nActionId = DocumentAction.ACTION_REFUSE; if (isAuthorized(nActionId, document)) { DocumentService.getInstance().changeDocumentState(document, getUser(), DocumentState.STATE_REJECTED); } } else if (stateId == DocumentState.STATE_WAITING_FOR_CHANGE_APPROVAL) { nActionId = DocumentAction.ACTION_REFUSE_CHANGE; if (isAuthorized(nActionId, document)) { DocumentService.getInstance().changeDocumentState(document, getUser(), DocumentState.STATE_IN_CHANGE); } } nbDocumentsAffected++; } catch (DocumentException e) { return getErrorMessageUrl(request, e.getI18nMessage()); } } else if ((strAction.equals(CONSTANT_UNARCHIVE)) && (stateId == DocumentState.STATE_ARCHIVED)) { nActionId = DocumentAction.ACTION_UNARCHIVE; try { if (isAuthorized(nActionId, document)) { DocumentService.getInstance().changeDocumentState(document, getUser(), DocumentState.STATE_VALIDATE); nbDocumentsAffected++; } } catch (DocumentException e) { return getErrorMessageUrl(request, e.getI18nMessage()); } } else if (strAction.equals(CONSTANT_SUBMIT)) { try { if ((stateId == DocumentState.STATE_WRITING) || (stateId == DocumentState.STATE_REJECTED)) { nActionId = DocumentAction.ACTION_SUBMIT; DocumentService.getInstance().changeDocumentState(document, getUser(), DocumentState.STATE_WAITING_FOR_APPROVAL); nbDocumentsAffected++; } else if ((stateId == DocumentState.STATE_IN_CHANGE)) { nActionId = DocumentAction.ACTION_SUBMIT_CHANGE; if (isAuthorized(nActionId, document)) { DocumentService.getInstance().changeDocumentState(document, getUser(), DocumentState.STATE_WAITING_FOR_CHANGE_APPROVAL); } nbDocumentsAffected++; } } catch (DocumentException e) { return getErrorMessageUrl(request, e.getI18nMessage()); } } } } } } return getHomeUrl(request); }
From source file:edu.jhuapl.openessence.controller.ReportController.java
private Map<String, Object> createTimeseries(String userPrincipalName, DataSeriesSource dss, List<Filter> filters, GroupingImpl group, String timeResolution, Integer prepull, String graphTimeSeriesUrl, final Collection<Record> records, final List<Dimension> accumulations, final List<Dimension> timeseriesDenominators, String detectorClass, boolean includeDetails, boolean displayIntervalEndDate, GraphDataInterface graphData, TimeZone clientTimezone) { Map<String, Object> result = new HashMap<String, Object>(); Map<String, ResolutionHandler> resolutionHandlers = null; result.put("success", false); try {//from w w w . j a v a 2s .com GroupingDimension grpdim = dss.getGroupingDimension(group.getId()); resolutionHandlers = grpdim.getResolutionsMap(); String dateFieldName = group.getId(); Date startDate = null; Date endDate = null; if (grpdim != null && (grpdim.getSqlType() == FieldType.DATE || grpdim.getSqlType() == FieldType.DATE_TIME)) { for (Filter f : filters) { if (f instanceof OneArgOpFilter) { OneArgOpFilter of = (OneArgOpFilter) f; if (of.getFilterId().equalsIgnoreCase(grpdim.getId()) && (of.getSqlSnippet("").contains(">="))) { startDate = (Date) of.getArguments().get(0); } else if (of.getFilterId().equalsIgnoreCase(grpdim.getId()) && (of.getSqlSnippet("").contains("<="))) { endDate = (Date) of.getArguments().get(0); } } } } //union accumulations to get all results List<Dimension> dimensions = new ArrayList<Dimension>( ControllerUtils.unionDimensions(accumulations, timeseriesDenominators)); int timeOffsetMillies = 0; String timezoneEnabledString = messageSource.getMessage(TIMEZONE_ENABLED, "false"); if (timezoneEnabledString.equalsIgnoreCase("true")) { timeOffsetMillies = (clientTimezone.getRawOffset() - clientTimezone.getDSTSavings()) - (TimeZone.getDefault().getRawOffset() - TimeZone.getDefault().getDSTSavings()); } Calendar startDayCal = Calendar.getInstance(clientTimezone); startDayCal.setTime(startDate); startDayCal.add(Calendar.MILLISECOND, timeOffsetMillies); //get data grouped by group dimension List<AccumPoint> points = extractAccumulationPoints(userPrincipalName, dss, records, startDayCal.getTime(), endDate, dimensions, group, resolutionHandlers); if (points.size() > 0) { DateFormat dateFormat = getDateFormat(timeResolution); //dateFormat.setTimeZone(timezone); DateFormat tmpDateFormat = (DateFormat) dateFormat.clone(); tmpDateFormat.setTimeZone(clientTimezone); // number format for level NumberFormat numFormat3 = NumberFormat.getNumberInstance(); numFormat3.setMinimumFractionDigits(0); numFormat3.setMaximumFractionDigits(3); // number format for expected count NumberFormat numFormat1 = NumberFormat.getNumberInstance(); numFormat1.setMinimumFractionDigits(0); numFormat1.setMaximumFractionDigits(1); Calendar cal = new GregorianCalendar(); cal.setTime(startDayCal.getTime()); //offset start date to match prepull offset if (timeResolution.equals("weekly")) { cal.add(Calendar.DATE, (7 * prepull)); } else if (timeResolution.equals("daily")) { cal.add(Calendar.DATE, prepull); } Date queryStartDate = cal.getTime(); //-- Handles Denominator Types -- // double[] divisors = new double[points.size()]; double multiplier = 1.0; boolean percentBased = false; String yAxisLabel = messageSource.getDataSourceMessage("graph.count", dss); boolean isDetectionDetector = !NoDetectorDetector.class.getName().equalsIgnoreCase(detectorClass); //if there is a denominator we need to further manipulate the data if (timeseriesDenominators != null && !timeseriesDenominators.isEmpty()) { // divisor is the sum of timeseriesDenominators divisors = totalSeriesValues(points, timeseriesDenominators); multiplier = 100.0; percentBased = true; yAxisLabel = messageSource.getDataSourceMessage("graph.percent", dss); } else { //the query is for total counts Arrays.fill(divisors, 1.0); } double[][] allCounts = new double[accumulations.size()][]; int[][] allColors = new int[accumulations.size()][]; String[][] allAltTexts = new String[accumulations.size()][]; String[] dates = new String[] { "" }; double[][] allExpecteds = new double[accumulations.size()][]; double[][] allLevels = new double[accumulations.size()][]; String[][] allLineSetURLs = new String[accumulations.size()][]; String[][] allSwitchInfo = new String[accumulations.size()][]; String[] lineSetLabels = new String[accumulations.size()]; boolean[] displayAlerts = new boolean[accumulations.size()]; //get all results Collection<Dimension> dims = new ArrayList<Dimension>(dss.getResultDimensions()); Collection<String> dimIds = ControllerUtils.getDimensionIdsFromCollection(dims); Collection<String> accIds = ControllerUtils.getDimensionIdsFromCollection(dss.getAccumulations()); //remove extra accumulations in the result set using string ids dimIds.removeAll(accIds); //for each accumulation we run detection and gather results int aIndex = 0; for (Dimension accumulation : accumulations) { String accumId = accumulation.getId(); // use display name if it has one, otherwise translate its ID String accumIdTranslated = accumulation.getDisplayName(); if (accumIdTranslated == null) { accumIdTranslated = messageSource.getDataSourceMessage(accumulation.getId(), dss); } TemporalDetectorInterface TDI = (TemporalDetectorInterface) DetectorHelper .createObject(detectorClass); TemporalDetectorSimpleDataObject TDDO = new TemporalDetectorSimpleDataObject(); int[] colors; double[] counts; String[] altTexts; double[] expecteds; double[] levels; String[] switchInfo; String[] urls; //pull the counts from the accum array points double[] seriesDoubleArray = generateSeriesValues(points, accumId); //run divisor before detection for (int i = 0; i < seriesDoubleArray.length; i++) { double div = divisors[i]; if (div == 0) { seriesDoubleArray[i] = 0.0; } else { seriesDoubleArray[i] = (seriesDoubleArray[i] / div) * multiplier; } } //run detection TDDO.setCounts(seriesDoubleArray); TDDO.setStartDate(startDate); TDDO.setTimeResolution(timeResolution); try { TDI.runDetector(TDDO); } catch (Exception e) { String errorMessage = "Failure to create Timeseries"; if (e.getMessage() != null) { errorMessage = errorMessage + ":<BR>" + e.getMessage(); } result.put("message", errorMessage); result.put("success", false); return result; } TDDO.cropStartup(prepull); counts = TDDO.getCounts(); int tddoLength = counts.length; if (!DAILY.equalsIgnoreCase(timeResolution)) { //toggle between start date and end date //TDDO.setDates(getOurDates(startDate, endDate, tddoLength, timeResolution)); TDDO.setDates(getOurDates(queryStartDate, endDate, tddoLength, timeResolution, displayIntervalEndDate)); } double[] tcolors = TDDO.getColors(); Date[] tdates = TDDO.getDates(); altTexts = TDDO.getAltTexts(); expecteds = TDDO.getExpecteds(); levels = TDDO.getLevels(); switchInfo = TDDO.getSwitchInfo(); colors = new int[tddoLength]; dates = new String[tddoLength]; urls = new String[tddoLength]; //add the accumId for the current series dimIds.add(accumId); StringBuilder jsCall = new StringBuilder(); jsCall.append("javascript:OE.report.datasource.showDetails({"); jsCall.append("dsId:'").append(dss.getClass().getName()).append("'"); //specify results jsCall.append(",results:[") .append(StringUtils.collectionToDelimitedString(dimIds, ",", "'", "'")).append(']'); //specify accumId jsCall.append(",accumId:'").append(accumId).append("'"); addJavaScriptFilters(jsCall, filters, dateFieldName); //this builds urls and hover texts int startDay = getWeekStartDay(resolutionHandlers); Calendar c = Calendar.getInstance(clientTimezone); // Calendar curr = Calendar.getInstance(); for (int i = 0; i < tddoLength; i++) { colors[i] = (int) tcolors[i]; // For a time series data point, set time to be current server time // This will allow us to convert this data point date object to be request timezone date c.setTime(tdates[i]); c.add(Calendar.MILLISECOND, timeOffsetMillies); if (timeResolution.equals(WEEKLY)) { dates[i] = dateFormatWeekPart.format(tdates[i]) + "-W" + PgSqlDateHelper.getWeekOfYear(startDay, c) + "-" + PgSqlDateHelper.getYear(startDay, c); } else { dates[i] = tmpDateFormat.format(c.getTime()); } altTexts[i] = "(" + accumIdTranslated + ") " + // Accum "Date: " + dates[i] + // Date ", Level: " + numFormat3.format(levels[i]) + // Level ", Count: " + ((int) counts[i]) + // Count ", Expected: " + numFormat1.format(expecteds[i]); // Expected if (switchInfo != null) { altTexts[i] += ", Switch: " + switchInfo[i] + ", "; } // build the click through url StringBuilder tmp = new StringBuilder(jsCall.toString()); // add the date field with start and end dates from the data point if (!DAILY.equalsIgnoreCase(timeResolution)) { Calendar timeSet = Calendar.getInstance(clientTimezone); timeSet.setTime(tdates[i]); if (WEEKLY.equalsIgnoreCase(timeResolution)) { timeSet.set(Calendar.DAY_OF_WEEK, startDay + 1); tmp.append(",").append(dateFieldName).append("_start:'") .append(timeSet.getTimeInMillis()).append("'"); timeSet.add(Calendar.DAY_OF_YEAR, 6); tmp.append(",").append(dateFieldName).append("_end:'") .append(timeSet.getTimeInMillis()).append("'"); } else if (MONTHLY.equalsIgnoreCase(timeResolution)) { // Compute last day of month timeSet.set(Calendar.DAY_OF_MONTH, 1); timeSet.add(Calendar.MONTH, 1); timeSet.add(Calendar.DAY_OF_YEAR, -1); tmp.append(",").append(dateFieldName).append("_end:'") .append(timeSet.getTimeInMillis()).append("'"); // set first day of month timeSet.set(Calendar.DAY_OF_MONTH, 1); tmp.append(",").append(dateFieldName).append("_start:'") .append(timeSet.getTimeInMillis()).append("'"); } else if (YEARLY.equalsIgnoreCase(timeResolution)) { // Compute last day of month timeSet.set(Calendar.DATE, 31); timeSet.add(Calendar.MONTH, Calendar.DECEMBER); tmp.append(",").append(dateFieldName).append("_end:'") .append(timeSet.getTimeInMillis()).append("'"); timeSet.set(Calendar.DATE, 1); timeSet.add(Calendar.MONTH, Calendar.JANUARY); tmp.append(",").append(dateFieldName).append("_start:'") .append(timeSet.getTimeInMillis()).append("'"); } } else { // compute end date for individual data points based on the selected resolution // detailsPointEndDate = computeEndDate(tdates[i],timeResolution); // add the date field with start and end dates from the data point tmp.append(",").append(dateFieldName).append("_start:'").append(tdates[i].getTime()) .append("'"); tmp.append(",").append(dateFieldName).append("_end:'").append(tdates[i].getTime()) .append("'"); } tmp.append("});"); urls[i] = tmp.toString(); } allCounts[aIndex] = counts; allColors[aIndex] = colors; allAltTexts[aIndex] = altTexts; allExpecteds[aIndex] = expecteds; allLevels[aIndex] = levels; allLineSetURLs[aIndex] = urls; allSwitchInfo[aIndex] = switchInfo; lineSetLabels[aIndex] = accumIdTranslated; displayAlerts[aIndex] = isDetectionDetector; aIndex++; //remove the accumId for the next series dimIds.remove(accumId); } GraphDataSerializeToDiskHandler hndl = new GraphDataSerializeToDiskHandler(graphDir); GraphController gc = getGraphController(null, hndl, userPrincipalName); //TODO figure out why I (hodancj1) added this to be accumulation size ~Feb 2012 // gc.setMaxLegendItems(accumulations.size()); graphData.setShowSingleAlertLegends(isDetectionDetector); graphData.setCounts(allCounts); graphData.setColors(allColors); graphData.setAltTexts(allAltTexts); graphData.setXLabels(dates); graphData.setExpecteds(allExpecteds); graphData.setLevels(allLevels); graphData.setLineSetURLs(allLineSetURLs); graphData.setLineSetLabels(lineSetLabels); graphData.setDisplayAlerts(displayAlerts); // graphData.setDisplaySeverityAlerts(displayAlerts); graphData.setPercentBased(percentBased); graphData.setXAxisLabel(messageSource.getDataSourceMessage(group.getResolution(), dss)); graphData.setYAxisLabel(yAxisLabel); int maxLabels = graphData.getGraphWidth() / 30; graphData.setMaxLabeledCategoryTicks(Math.min(maxLabels, allCounts[0].length)); StringBuffer sb = new StringBuffer(); GraphObject graph = gc.writeTimeSeriesGraph(sb, graphData, true, true, false, graphTimeSeriesUrl); result.put("html", sb.toString()); //added to build method calls from javascript Map<String, Object> graphConfig = new HashMap<String, Object>(); graphConfig.put("address", graphTimeSeriesUrl); graphConfig.put("graphDataId", graph.getGraphDataId()); graphConfig.put("imageMapName", graph.getImageMapName()); graphConfig.put("graphTitle", graphData.getGraphTitle()); graphConfig.put("xAxisLabel", graphData.getXAxisLabel()); graphConfig.put("yAxisLabel", graphData.getYAxisLabel()); graphConfig.put("xLabels", graphData.getXLabels()); graphConfig.put("graphWidth", graphData.getGraphWidth()); graphConfig.put("graphHeight", graphData.getGraphHeight()); graphConfig.put("yAxisMin", graph.getYAxisMin()); graphConfig.put("yAxisMax", graph.getYAxisMax()); // fix invalid JSON coming from GraphController String dataSeriesJson = graph.getDataSeriesJSON().replaceFirst("\\{", "") // remove trailing "}" .substring(0, graph.getDataSeriesJSON().length() - 2); // read malformed JSON ObjectMapper mapper = new ObjectMapper(); JsonFactory jsonFactory = mapper.getJsonFactory() .configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true) .configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); JsonParser jsonParser = jsonFactory.createJsonParser(dataSeriesJson); // array of String -> Object maps TypeReference<Map<String, Object>[]> dataSeriesType = new TypeReference<Map<String, Object>[]>() { }; // write JSON as Map so that it can be serialized properly back to JSON Map<String, Object>[] seriesMap = mapper.readValue(jsonParser, dataSeriesType); graphConfig.put("dataSeriesJSON", seriesMap); if (includeDetails) { int totalPoints = 0; List<HashMap<String, Object>> details = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> detail; for (int i = 0; i < allCounts.length; i++) { for (int j = 0; j < allCounts[i].length; j++) { totalPoints++; detail = new HashMap<String, Object>(); detail.put("Date", dates[j]); detail.put("Series", lineSetLabels[i]); detail.put("Level", allLevels[i][j]); detail.put("Count", allCounts[i][j]); if (!ArrayUtils.isEmpty(allExpecteds[i])) { detail.put("Expected", allExpecteds[i][j]); } if (!ArrayUtils.isEmpty(allSwitchInfo[i])) { detail.put("Switch", allSwitchInfo[i][j]); } detail.put("Color", allColors[i][j]); details.add(detail); } } result.put("detailsTotalRows", totalPoints); result.put("details", details); } result.put("graphConfiguration", graphConfig); result.put("success", true); } else { StringBuilder sb = new StringBuilder(); sb.append("<h2>" + messageSource.getDataSourceMessage("graph.nodataline1", dss) + "</h2>"); sb.append("<p>" + messageSource.getDataSourceMessage("graph.nodataline2", dss) + "</p>"); result.put("html", sb.toString()); result.put("success", true); } } catch (Exception e) { log.error("Failure to create Timeseries", e); } return result; }