List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
public void getCreditDate() { Date Currentdate = null;//from w w w. j av a 2 s .c o m Calendar now = Calendar.getInstance(); int days = Integer.parseInt(m_App.getProperties().getValidity()); now.add(Calendar.DATE, days); DateFormat formatter; formatter = new SimpleDateFormat("dd-MM-yyyy"); String str_date = (now.get(Calendar.DATE)) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + (now.get(Calendar.YEAR)); try { Currentdate = (Date) formatter.parse(str_date); } catch (java.text.ParseException ex) { logger.info("Order No. " + m_oTicket.getOrderId() + " exception in getCreditDate" + ex.getMessage()); Logger.getLogger(RetailTicketInfo.class.getName()).log(Level.SEVERE, null, ex); } m_oTicket.setNewDate(Currentdate); }
From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java
@Override public Integer getcountfindbytransactionRegisterList(ArrayList<?> theFilterDetails, int moaccountid) throws BankingException { Session aSession = null;//from www . j av a 2 s . c o m String param1 = null, param2 = null, value = null, param3 = "0"; Integer aCount = 0; if (theFilterDetails != null) { for (int i = 0; i < theFilterDetails.size(); i++) { if (i == 0) { param1 = theFilterDetails.get(i).toString(); } else if (i == 1) { param2 = theFilterDetails.get(i).toString(); } else if (i == 2) { value = theFilterDetails.get(i).toString(); } else if (i == 3) { param3 = theFilterDetails.get(i).toString(); } } } List<Motransaction> aQueryList = new ArrayList<Motransaction>(); String aCustomerQry = "SELECT *,CASE WHEN moTransaction.rxMasterID IS NULL THEN description ELSE (SELECT NAME FROM rxMaster WHERE " + " rxMasterID=moTransaction.rxMasterID) END 'namedescription' FROM moTransaction WHERE moAccountID =" + moaccountid; Motransaction aMotransaction = null; if (param1 != null && param1.equalsIgnoreCase("Amount")) { if (param2 != null && param2.equalsIgnoreCase("Exact")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) =" + value; else if (param2 != null && param2.equalsIgnoreCase("Greater")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) >" + value; else if (param2 != null && param2.equalsIgnoreCase("Greater or equal")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) >=" + value; else if (param2 != null && param2.equalsIgnoreCase("Less")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) <" + value; else if (param2 != null && param2.equalsIgnoreCase("Less or equal")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) <=" + value; } else if (param1 != null && param1.equalsIgnoreCase("Cleared Status")) { if (param2 != null && param2.equalsIgnoreCase("Reconcile")) aCustomerQry += " and reconciled=1"; else if (param2 != null && param2.equalsIgnoreCase("Unreconciled")) aCustomerQry += " and reconciled=0 and status=0"; } else if (param1 != null && param1.equalsIgnoreCase("Date")) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat parseDateFormat = new SimpleDateFormat("MM/dd/yyyy"); Date fromDate = null, toDate = null; try { if (param2 != null) fromDate = parseDateFormat.parse(param2); } catch (ParseException e) { e.printStackTrace(); } if (param2 != null && value.equals("0")) aCustomerQry += " and transactionDate >='" + simpleDateFormat.format(fromDate) + "'"; else if (param2 == null && value != null) aCustomerQry += " and transactionDate <='" + simpleDateFormat.format(toDate) + "'"; else if (param2 != null && value != null && !value.equals("0")) { if (value != null && !value.equals("0")) try { toDate = parseDateFormat.parse(value); } catch (ParseException e) { e.printStackTrace(); } aCustomerQry += " and transactionDate between '" + simpleDateFormat.format(fromDate) + "' and '" + simpleDateFormat.format(toDate) + "'"; } } else if (param1 != null && param1.equalsIgnoreCase("Reference")) { if (param2 != null && param2.equalsIgnoreCase("Contains")) aCustomerQry += " and reference like '%" + value + "%'"; else if (param2 != null && param2.equalsIgnoreCase("Exact")) aCustomerQry += " and reference ='" + value + "'"; } else if (param1 != null && param1.equalsIgnoreCase("G/L Account #")) { aCustomerQry += " and coAccountID =" + param2 + ""; } else if (param1 != null && param1.equalsIgnoreCase("Type")) { if (param2 != null && param2.equalsIgnoreCase("Deposit")) aCustomerQry += " and amount > 0 "; else aCustomerQry += " and amount < 0 "; } //aCustomerQry +=" ORDER BY moTransactionID DESC"; String sort = (String) theFilterDetails.get(theFilterDetails.size() - 1); String descriptionFilter = ""; if (param1 != null && param1.equalsIgnoreCase("Description")) { if (sort.equals("0")) aCustomerQry += " ORDER BY transactionDate ASC"; else aCustomerQry += " ORDER BY transactionDate DESC"; if (param2 != null && param2.equalsIgnoreCase("Contains")) descriptionFilter += " description like '%" + value + "%' or namedescription like '%" + value + "%'"; else if (param2 != null && param2.equalsIgnoreCase("Ends with")) descriptionFilter += " description like '%" + value + "' or namedescription like '%" + value + "'"; else if (param2 != null && param2.equalsIgnoreCase("Exact")) descriptionFilter += " description ='" + value + "' or namedescription = '" + value + "'"; else if (param2 != null && param2.equalsIgnoreCase("Starts with")) descriptionFilter += " description like '" + value + "%' or namedescription like '" + value + "%'"; aCustomerQry = "Select * from (" + aCustomerQry + ")as subquery where " + descriptionFilter; } else { if (sort.equals("0")) aCustomerQry += " ORDER BY transactionDate ASC "; else aCustomerQry += " ORDER BY transactionDate DESC "; } try { aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aCustomerQry); aCount = aQuery.list().size(); } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; } finally { aSession.flush(); aSession.close(); aCustomerQry = null; } return aCount; }
From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java
public void getCreditDate() { Date Currentdate = null;/*from w w w.j av a 2 s. c o m*/ Calendar now = Calendar.getInstance(); int days = Integer.parseInt(m_App.getProperties().getValidity()); now.add(Calendar.DATE, days); DateFormat formatter; formatter = new SimpleDateFormat("dd-MM-yyyy"); String str_date = (now.get(Calendar.DATE)) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + (now.get(Calendar.YEAR)); try { Currentdate = (Date) formatter.parse(str_date); // Currentdate =; } catch (java.text.ParseException ex) { logger.info("Order No. " + m_oTicket.getOrderId() + " exception in getCreditDate" + ex.getMessage()); Logger.getLogger(RetailTicketInfo.class.getName()).log(Level.SEVERE, null, ex); } // Currentdate =; m_oTicket.setNewDate(Currentdate); // Currentdate =; }
From source file:gov.llnl.lustre.lwatch.PlotFrame2.java
/** * Redraw the plot frame based on either pan/zoom event or * heartbeat refresh timer trip./*from w w w . ja v a2 s .c o m*/ */ void refreshPlotFrame() { // Stop any refreshTimer controlled tasks. stopRefresh(); //Debug.out("startIndex & stopIndex = " + startIndex + " & " + stopIndex); fromRefresh = true; ovIDX = 0; // Calculate the number of curves to be plotted nRowsSelected = controls.getCategoryPanel().getNumSelected(); if (isAnAggPlot) nRowsSelected = 1; nColsSelected = controls.getVariablePanel().getNumSelected(); nCurvesSelected = controls.getCurvePanel().getNumCurvesSelected(); if (nRowsSelected == 0 || nColsSelected == 0 || nCurvesSelected == 0) { if (localDebug) Debug.out("Insufficient selection for generating a history plot."); LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "Insufficient selection for generating a history plot.", 1); // type 1 = info with "continue resetIntervals(pD); return; } granularity = granularityChooser.getGranularity(); if (isAnAggPlot && (granularity == Database.RAW || granularity == HEARTBEAT)) { LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "Invalid granularity setting for aggregate plot. " + "Raw & Raw Live not allowed at this time.", 1); // type 1 = info with "continue resetIntervals(pD); return; } if (granularity == HEARTBEAT) updateLive = true; else updateLive = false; String[] selectedRows; if (!isAnAggPlot) selectedRows = controls.getCategoryPanel().getSelected(); else { selectedRows = new String[1]; selectedRows[0] = "Aggregate"; } String[] selectedVars = controls.getVariablePanel().getSelected(); //String [] selectedCurves = controls.getCurvePanel().getSelected(); loadAggregate = controls.getCurvePanel().isAggregateSet(); loadMinimum = controls.getCurvePanel().isMinimumSet(); loadMaximum = controls.getCurvePanel().isMaximumSet(); loadAverage = controls.getCurvePanel().isAverageSet(); //rawData = null; int vTot = nRowsSelected * nColsSelected * nCurvesSelected; ovRangeMax = new float[vTot]; ovRangeMin = new float[vTot]; dataPointCount = new int[vTot]; if (localDebug) Debug.out("nrows, ncols, nCurves, vTot = " + nRowsSelected + " " + nColsSelected + " " + nCurvesSelected + " " + vTot); cats2Plot = new String[nRowsSelected]; vars2Plot = new String[nColsSelected]; crvs2Plot = controls.getCurvePanel().getSelected(); //new String[nCurvesSelected]; //aggVal = new double[vTot]; //maxVal = new double[vTot]; //minVal = new double[vTot]; //avgVal = new double[vTot]; // Grab values from the control panel so that start & end timestamps, // granularity, and aggregate data types can be determined. // Starting Timestamp calculation int yearBeg = yrChooser.getYearSelected(); int monthBeg = monthChooser.getMonthSelected() + 1; int dayBeg = dayChooser.getDaySelected(); int hourBeg = hourChooser.getHourSelected(); int minuteBeg = minuteChooser.getMinuteSelected(); //if (localDebug) //Debug.out(pad(monthBeg,2) + "/" + pad(dayBeg,2) + "/" + //yearBeg + " " + pad(hourBeg,2) + ":" + pad(minuteBeg,2)); // Ending Timestamp calculation int yearEnd; int monthEnd; int dayEnd; int hourEnd; int minuteEnd; if (!useDuration) { // End date/time defined by "End" definition if (localDebug) Debug.out("End time defined by END Spec."); yearEnd = yrEndChooser.getYearSelected(); monthEnd = monthEndChooser.getMonthSelected() + 1; dayEnd = dayEndChooser.getDaySelected(); hourEnd = hourEndChooser.getHourSelected(); minuteEnd = minuteEndChooser.getMinuteSelected(); if (yearBeg == yearEnd && monthBeg == monthEnd && dayBeg == dayEnd && hourBeg == hourEnd && minuteBeg == minuteEnd) { //Debug.out("Same begin & end times yield zero-length time interval."); LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "zero-length time interval specified.", 1); // type 1 = info with "continue resetIntervals(pD); return; } } else { // End date/time defined by "Duration" definition if (localDebug) Debug.out("End time defined by DURATION Spec."); yearEnd = yearBeg + yrDurChooser.getValueSelected(); monthEnd = monthBeg + monthDurChooser.getValueSelected(); dayEnd = dayBeg + dayDurChooser.getValueSelected(); hourEnd = hourBeg + hourDurChooser.getValueSelected(); minuteEnd = minuteBeg + minuteDurChooser.getValueSelected(); if (minuteEnd > 59) { hourEnd++; minuteEnd -= 59; } if (hourEnd > 23) { dayEnd++; hourEnd -= 23; } if (dayEnd > daysInMonth(monthBeg)) { monthEnd++; dayEnd -= daysInMonth(monthBeg); } if (monthEnd > 12) { yearEnd++; monthEnd -= 12; } } if (localDebug) Debug.out(pad(monthEnd, 2) + "/" + pad(dayEnd, 2) + "/" + yearEnd + " " + pad(hourEnd, 2) + ":" + pad(minuteEnd, 2)); long nowMillis = System.currentTimeMillis(); String intervalBegString = Integer.toString(yearBeg) + "-" + pad(monthBeg, 2) + "-" + pad(dayBeg, 2) + " " + pad(hourBeg, 2) + ":" + pad(minuteBeg, 2) + ":00"; String intervalEndString = Integer.toString(yearEnd) + "-" + pad(monthEnd, 2) + "-" + pad(dayEnd, 2) + " " + pad(hourEnd, 2) + ":" + pad(minuteEnd, 2) + ":00"; if (limitedDebug) { Debug.out( "intervalBegString = " + intervalBegString + "\n" + "intervalEndString = " + intervalEndString); try { // Remove try block when debugging completed. long dtStart = simpleDateFormat.parse(intervalBegString).getTime(); long dtEnd = simpleDateFormat.parse(intervalEndString).getTime(); String cStart = (new Date(dtStart)).toString(); String cEnd = (new Date(dtEnd)).toString(); Debug.out("recalc of startDateTime = " + cStart + "\nendDateTime = " + cEnd); } catch (java.text.ParseException e) { Debug.out("Exception detected while calculating Timestamp objects.\n" + e.getMessage()); resetIntervals(pD); return; } } // End of -- if (localDebug) if (granularity == HEARTBEAT) { tsStart = new Timestamp(nowMillis - (liveDisplayInterval)); tsEnd = new Timestamp(nowMillis); } long begTimeLong = -1; long endTimeLong = -1; try { if (granularity == HEARTBEAT) { begTimeLong = tsStart.getTime(); endTimeLong = tsEnd.getTime(); } else { // simpleDateFormat.parse(dateTimeString).getTime() returns // the number of milliseconds since January 1, 1970, 00:00:00 GMT begTimeLong = simpleDateFormat.parse(intervalBegString).getTime(); endTimeLong = simpleDateFormat.parse(intervalEndString).getTime(); if (endTimeLong > nowMillis) endTimeLong = nowMillis; } tsStartPlot = new Timestamp(begTimeLong); tsEndPlot = new Timestamp(endTimeLong); if (begTimeLong >= endTimeLong) { LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "Invalid time interval <= zero or " + "future time specified.", 1); // type 1 = info with "continue resetIntervals(pD); return; } double tNtrvl = (double) (endTimeLong - begTimeLong); long nT = (long) (tNtrvl / tRate[granularity - 1]); //Debug.out((long)tNtrvl + " / " + (long)tRate[granularity-1] + " = " + nT); //Debug.out("Chart container pane width = " + chartContainerPane.getWidth()); if ((nT > ((double) chartContainerPane.getWidth() * 1.5)) && ((chartContainerPane.getWidth() > 100))) { LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "Plot contains more data than # of pixels in plot window. " + "Usefulness will be questionable.", // The message to put in the window 0); // type 0 = info with "cancel" & "continue" if (cancel) { //Debug.out("Request canceled. Reset values..."); resetIntervals(pD); return; } } /**** Runtime.getRuntime().gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long totalMemory = Runtime.getRuntime().totalMemory(); long maxMemory = Runtime.getRuntime().maxMemory(); long usedMemory = totalMemory-freeMemory; double percentOfMax = (double) usedMemory / (double) maxMemory; if (true) //(limitedDebug) Debug.out("\n\nPrior to GC :\n" + "\nfreeMemory = " + freeMemory + " maxMemory = " + maxMemory + "\ntotalMemory = " + totalMemory + " usedMemory = " + usedMemory + "\n% of Max used = " + percentOfMax); ****/ if (limitedDebug) Debug.out("tsStart, tsEnd = " + tsStart + ", " + tsEnd + "\ntsStartPlot, tsEndPlot = " + tsStartPlot + ", " + tsEndPlot); if ((granularity == Database.RAW) || (granularity == HEARTBEAT)) { int estimatedTime = (int) ((nRowsSelected * nColsSelected * nCurvesSelected) * (((endTimeLong - begTimeLong) / ONEDAY) + 1) * 5.0); double percentOfMem = (double) (nRowsSelected * nColsSelected * nCurvesSelected) * (((double) (endTimeLong - begTimeLong) / ONEDAY) + 1.0) * 3.5; percentOfMem *= (double) ((double) (1024 * 1024 * 200) / (double) (Runtime.getRuntime().maxMemory())); if ((estimatedTime > 15) || (percentOfMem > 80.0)) { //Debug.out("Requested Raw data retrieval of 5 or more days." + //" This may take a while."); String msg = "Requested data "; if (estimatedTime > 15) msg += "may take up to " + estimatedTime + " secs to retrieve"; if (percentOfMem > 80.0) { if (estimatedTime > 15) msg += " & "; msg += "requires 80% or more of memory"; } msg += "."; LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true msg, // The message to put in the window 0); // type 0 = info with "cancel" & "continue" if (cancel) { //Debug.out("Request canceled. Reset values..."); resetIntervals(pD); return; } } if (granularity == Database.RAW) { tsStart = new Timestamp(tsStartPlot.getTime() - HALFDAY); tsEnd = new Timestamp(tsEndPlot.getTime() + HALFDAY); } } else if (granularity == Database.HOUR) { tsStart = new Timestamp(tsStartPlot.getTime() - SIXMONTHS); tsEnd = new Timestamp(tsEndPlot.getTime() + SIXMONTHS); } else { // Granularity > 1 hour. Grab everything. tsStart = new Timestamp((long) SIXMONTHS * 10); tsEnd = new Timestamp(new java.util.Date().getTime()); } if (tsEnd.getTime() > nowMillis) tsEnd = new Timestamp(nowMillis); if (tsStart.getTime() >= tsEnd.getTime()) { if (granularity == HEARTBEAT) { tsStart = new Timestamp(nowMillis - (liveDisplayInterval)); tsEnd = new Timestamp(nowMillis); } else if (granularity == Database.RAW) tsStart = new Timestamp(nowMillis - HALFDAY); else if (granularity == Database.HOUR) tsStart = new Timestamp(nowMillis - SIXMONTHS); else tsStart = new Timestamp(ONEYEAR * 37); } if (limitedDebug) Debug.out("granularity = " + granularity + "\ntsStart, tsEnd = " + tsStart + ", " + tsEnd); } catch (java.text.ParseException e) { Debug.out("Exception detected while building Timestamp objects.\n" + e.getMessage()); resetIntervals(pD); return; } rawData = null; initialLoad = true; int zeroReturnCount = 0; for (int irow = 0; irow < nRowsSelected; irow++) { cats2Plot[irow] = selectedRows[irow]; for (int ivar = 0; ivar < nColsSelected; ivar++) { vars2Plot[ivar] = selectedVars[ivar]; int index = irow * nColsSelected + ivar; if (localDebug) Debug.out("Read data for row, col, curve = " + irow + ", " + ivar); //getRawData(selectedRows[irow], selectedVars[ivar], index, vTot); thpFrame.setCursor(hourglassCursor); loadHistoricalData(this.type, this.subIdent, selectedRows[irow], selectedVars[ivar], crvs2Plot, index, vTot); thpFrame.setCursor(normalCursor); for (int kk = 0; kk < crvs2Plot.length; kk++) { int kkdx = irow * nColsSelected * nCurvesSelected + ivar * nCurvesSelected + kk; if (dataPointCount[kkdx] <= 0) zeroReturnCount++; } /**** if (dataPointCount[0] <= 0) { if (!isAnAggPlot || (vTot == 1)) { if (localDebug) Debug.out("Zero-length array result from data load request."); LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "DB request yielded no data.", 1); // type 1 = info with "continue //redrawChartPanel(); //wideView.repaint(); continue; } } ****/ //%%%tsStart = new Timestamp(rawTimes[0][0]); //%%%tsEnd = new Timestamp(rawTimes[0][dataPointCount[0]-1]); // Set up the overview plot interval if (granularity == HEARTBEAT) { ovEndPlot = new Timestamp(tsEndPlot.getTime()); ovStartPlot = new Timestamp(tsStartPlot.getTime()); } else if (granularity == Database.RAW) { ovEndPlot = new Timestamp(Math.min(tsEnd.getTime(), tsEndPlot.getTime() + HOUR)); ovStartPlot = new Timestamp(Math.max(tsStart.getTime(), tsStartPlot.getTime() - HOUR)); } else if (granularity == Database.HOUR) { ovEndPlot = new Timestamp( Math.min(tsEnd.getTime(), tsEndPlot.getTime() + ((long) (2) * ONEDAY))); ovStartPlot = new Timestamp( Math.max(tsStart.getTime(), tsStartPlot.getTime() - ((long) (2) * ONEDAY))); } else if (granularity == Database.DAY) { ovEndPlot = new Timestamp( Math.min(tsEnd.getTime(), tsEndPlot.getTime() + ((long) (30) * ONEDAY))); ovStartPlot = new Timestamp( Math.max(tsStart.getTime(), tsStartPlot.getTime() - ((long) (30) * ONEDAY))); //Debug.out("ovStartPlot = " + ovStartPlot + " -- ovEndPlot = " + ovEndPlot); } else if (granularity == Database.WEEK) { ovEndPlot = new Timestamp(Math.min(tsEnd.getTime(), tsEndPlot.getTime() + (long) (ONEYEAR))); ovStartPlot = new Timestamp( Math.max(tsStart.getTime(), tsStartPlot.getTime() - (long) (ONEYEAR))); } else if (granularity == Database.MONTH) { ovEndPlot = new Timestamp(Math.min(tsEnd.getTime(), tsEndPlot.getTime() + (long) (ONEYEAR))); ovStartPlot = new Timestamp( Math.max(tsStart.getTime(), tsStartPlot.getTime() - (long) (ONEYEAR))); } else if (granularity == Database.YEAR) { ovEndPlot = new Timestamp(Math.min(tsEnd.getTime(), tsEndPlot.getTime() + (long) (ONEYEAR))); ovStartPlot = new Timestamp( Math.max(tsStart.getTime(), tsStartPlot.getTime() - (long) (ONEYEAR))); } if (localDebug) Debug.out("After loadHistoricalData, plot interval = " + tsStartPlot + " " + tsEndPlot); /********* if (arrayLimit <= 1000) { // was 1000 ovStartIndex = 0; ovStopIndex = arrayLimit - 1; } else { //ovStartIndex = Math.max(0, (startIndex+stopIndex)/2 - 500); // was 500 //ovStopIndex = Math.min(arrayLimit - 1, (startIndex+stopIndex)/2 + 500); int midIdx = (startIndex + stopIndex) / 2; startIndex = Math.max(0, midIdx - 400); stopIndex = Math.min(arrayLimit - 1, midIdx + 400); ovStartIndex = Math.max(0, midIdx - 500); ovStopIndex = Math.min(arrayLimit - 1, midIdx + 500); } **********/ } } initialLoad = false; if (zeroReturnCount == vTot) { if (localDebug) Debug.out("Zero-length array result from data load request."); LwatchAlert lwAlert = new LwatchAlert(this); lwAlert.displayDialog(true, // modal = true "DB request yielded no data.", 1); // type 1 = info with "continue } /***** long tDivisor = getTimeDivisor(granularity); long timeNtrvls = (tsEnd.getTime() - tsStart.getTime()) / tDivisor; long plotTimeNtrvls = (tsEndPlot.getTime() - tsStartPlot.getTime()) / tDivisor; if ( (plotTimeNtrvls - timeNtrvls) <= 1000 ) { ovStartPlot = new Timestamp(tsStart.getTime()); ovEndPlot = new Timestamp(tsEnd.getTime()); } else { ovStartPlot = new Timestamp(tsStartPlot.getTime() - 500*tDivisor); ovEndPlot = new Timestamp(tsEndPlot.getTime() + 500*tDivisor); } *****/ // Reset overview plot range to row, column, curve zero. yLo = ovRangeMin[ovIDX]; yHi = ovRangeMax[ovIDX] + (ovRangeMax[ovIDX] - ovRangeMin[ovIDX]) / 10.; //Debug.out("startIndex & stopIndex = " + startIndex + " & " + stopIndex); // Update the statsReportPane with data for curve 0 if ((cats2Plot.length > 0) && (vars2Plot.length > 0) && (crvs2Plot.length > 0)) { String buttText = cats2Plot[0] + " : " + vars2Plot[0] + " : " + crvs2Plot[0] + getDataText(cats2Plot[0] + " : " + vars2Plot[0] + " : " + crvs2Plot[0]); Color buttColor = getDataColor(cats2Plot[0] + " : " + vars2Plot[0] + " : " + crvs2Plot[0]); ammaLabel.setText(buttText); //Debug.out("ammaLabel text = " + buttText); statsReportPane.setBackground(buttColor); } else { ammaLabel.setText("Incomplete Data Selection"); statsReportPane.setBackground(Color.lightGray); } if (localDebug) Debug.out("Draw new set of curves."); thpFrame.setCursor(hourglassCursor); updateControlValues(); lastRefreshPlotParams = new PlotDescriptor(); redrawChartPanel(); wideView.repaint(); /**** plotPanel.remove(wideView); wideView = new OverView(); plotPanel.add(wideView); ppc = new GridBagConstraints(); ppc.gridx = 0; ppc.gridy = 1; // Insets are Top, Left, Bottom, Right ppc.insets = new Insets(0, 76, 10, 18); //(8, 4, 0, 5); ppc.anchor = GridBagConstraints.NORTH; ppc.fill = GridBagConstraints.BOTH; ppc.weightx = 1.0; ppc.weighty = 0.25; //0.15; //1.0; ppgbl.setConstraints(wideView, ppc); plotPanel.invalidate(); plotPanel.validate(); ****/ thpFrame.setCursor(normalCursor); if (localDebug) Debug.out("Build new set of stat displays. # of vars = " + vTot); refreshVariableStats(); if (granularity == HEARTBEAT) { setRefresh(refreshRate, 3600000); } else { stopRefresh(); } /**** long freeMemory = Runtime.getRuntime().freeMemory(); long totalMemory = Runtime.getRuntime().totalMemory(); long maxMemory = Runtime.getRuntime().maxMemory(); long usedMemory = totalMemory-freeMemory; double percentOfMax = (double) usedMemory / (double) maxMemory; Debug.out("\n\nAfter to DB load & new plots with " + "\n# of variables = " + vTot + " & granularity = " + granularity + "\ninterval = " + tsStart + " --- " + tsEnd + "\nfreeMemory = " + freeMemory + " maxMemory = " + maxMemory + "\ntotalMemory = " + totalMemory + " usedMemory = " + usedMemory + "\n% of Max used = " + percentOfMax); ***/ //Debug.out("startIndex & stopIndex = " + startIndex + " & " + stopIndex); }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private void m_jSettleBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jSettleBillActionPerformed logger.info("m_jSettleBillActionPerformed"); logger.info(/*from w w w. ja v a 2s . c o m*/ "Start Settle Bill Button :" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date())); //Below code is used for closing the day automatically if the application is not closed yesterday SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date sysDate = new Date(); m_RootApp = (JRootApp) m_App; String closeTime = m_App.getProperties().getProperty("machine.closetime"); String currentDate = format.format(sysDate).toString() + " " + closeTime; String closeDayDate = sdf.format(m_RootApp.getActiveDayDateStart()); Date closeDate = null; Date activeDayDate = null; try { closeDate = sdf.parse(currentDate); activeDayDate = sdf.parse(closeDayDate); } catch (ParseException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } //Comparing the actual close day date and current active close day date. if its greater than 0, then close the day automatically if (closeDate.compareTo(activeDayDate) > 0) { m_RootApp.closeDay(); m_oTicket.setActiveCash(m_App.getActiveCashIndex()); m_oTicket.setActiveDay(m_App.getActiveDayIndex()); m_oTicket.setDate(new Date()); String accDate = new SimpleDateFormat("yyyy-MM-dd").format(m_App.getActiveDayDateStart()); Date dateValue = java.sql.Date.valueOf(accDate); m_oTicket.setAccountDate(dateValue); } if (m_oTicket.getLinesCount() == 0) { return; } boolean updated = checkTicketUpdation(); if (!updated) { dbUpdatedDate = null; //Checking whether non kot items is there in the bill if (kotaction == 1) { try { kotDisplay(); } catch (BasicException ex) { logger.info("Order NO." + m_oTicket.getOrderId() + "exception on clicking settle bill kot action" + ex.getMessage()); Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } } //Checking whether the bill is printed if (!m_oTicket.isPrinted()) { showMessage(this, "Settle bill is allowed after Bill is Printed"); logger.info("Settle bill is allowed after Bill is Printed"); return; //Checking whether bill is modified after the print } else if (m_oTicket.isPrinted() && m_oTicket.isListModified()) { showMessage(this, "Bill is Modified after previous print. So please print it again"); logger.info("Bill is Modified after previous print. So please print it again"); return; } JPaymentEditor.showMessage(JRetailPanelTicket.this, dlReceipts, m_oTicket, this, "Sales"); } }
From source file:org.fcrepo.server.access.FedoraAccessServlet.java
/** * <p>/*from www.j a va 2 s .co m*/ * Process Fedora Access Request. Parse and validate the servlet input * parameters and then execute the specified request. * </p> * * @param request * The servlet request. * @param response * servlet The servlet response. * @throws ServletException * If an error occurs that effects the servlet's basic operation. * @throws IOException * If an error occurrs with an input or output operation. */ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String PID = null; String sDefPID = null; String methodName = null; String dsID = null; Date asOfDateTime = null; Date versDateTime = null; Property[] userParms = null; boolean isGetObjectProfileRequest = false; boolean isGetDisseminationRequest = false; boolean isGetDatastreamDisseminationRequest = false; boolean xml = false; requestURI = request.getQueryString() != null ? request.getRequestURL().toString() + "?" + request.getQueryString() : request.getRequestURL().toString(); logger.info("Got request: {}", requestURI); // Parse servlet URL. // For the Fedora API-A-LITE "get" syntax, valid entries include: // // For dissemination requests: // http://host:port/fedora/get/pid/sDefPid/methodName // http://host:port/fedora/get/pid/sDefPid/methodName/timestamp // http://host:port/fedora/get/pid/sDefPid/methodName?parm=value[&parm=value] // http://host:port/fedora/get/pid/sDefPid/methodName/timestamp?parm=value[&parm=value] // // For object profile requests: // http://host:port/fedora/get/pid // http://host:port/fedora/get/pid/timestamp // // For datastream dissemination requests: // http://host:port/fedora/get/pid/dsID // http://host:port/fedora/get/pid/dsID/timestamp // // use substring to avoid an additional char array copy String[] URIArray = requestURI.substring(0, request.getRequestURL().length()).split("/"); if (URIArray.length == 6 || URIArray.length == 7) { // Request is either an ObjectProfile request or a datastream // request if (URIArray.length == 7) { // They either specified a date/time or a datastream id. if (URIArray[6].indexOf(":") == -1) { // If it doesn't contain a colon, they were after a // datastream, // so this is a DatastreamDissemination request dsID = URLDecoder.decode(URIArray[6], "UTF-8"); isGetDatastreamDisseminationRequest = true; } else { // If it DOES contain a colon, they were after a // date/time-stamped object profile try { versDateTime = DateUtility.parseDateStrict(URIArray[6]); } catch (ParseException e) { String message = "ObjectProfile Request Syntax Error: DateTime value " + "of \"" + URIArray[6] + "\" is not a valid DateTime format. " + " <br></br> The expected format for DateTime is \"" + "YYYY-MM-DDTHH:MM:SS.SSSZ\". " + " <br></br> The expected syntax for " + "ObjectProfile requests is: \"" + URIArray[0] + "//" + URIArray[2] + "/" + URIArray[3] + "/" + URIArray[4] + "/PID[/dateTime] \" ." + " <br></br> Submitted request was: \"" + requestURI + "\" . "; logger.warn(message); throw new ServletException("from FedoraAccessServlet" + message); /* * commented out for exception.jsp test * response.setStatus * (HttpServletResponse.SC_INTERNAL_SERVER_ERROR); * response * .sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR * , message); return; commented out for exception.jsp * test */ } asOfDateTime = versDateTime; isGetObjectProfileRequest = true; } } else { // URIArray.length==6 so this is a GetObjectProfile request isGetObjectProfileRequest = true; } } else if (URIArray.length > 7) { // Request is either dissemination request or timestamped get // datastream request methodName = URLDecoder.decode(URIArray[7], "UTF-8"); if (URIArray.length == 8) { if (URIArray[6].indexOf(":") == -1) { // If it doesn't contain a colon, they were after a // timestamped // datastream, so this is a GetDatastreamDissemination // request. dsID = URLDecoder.decode(URIArray[6], "UTF-8"); try { versDateTime = DateUtility.parseDateStrict(URIArray[7]); } catch (ParseException e) { String message = "GetDatastreamDissemination Request Syntax Error: DateTime value " + "of \"" + URIArray[7] + "\" is not a valid DateTime format. " + " <br></br> The expected format for DateTime is \"" + "YYYY-MM-DDTHH:MM:SS.SSSZ\". " + " <br></br> The expected syntax for GetDatastreamDissemination requests is: \"" + URIArray[0] + "//" + URIArray[2] + "/" + URIArray[3] + "/" + URIArray[4] + "/PID/dsID[/dateTime] \" " + " <br></br> Submitted request was: \"" + requestURI + "\" . "; logger.warn(message); throw new ServletException("from FedoraAccessServlet" + message); } asOfDateTime = versDateTime; isGetDatastreamDisseminationRequest = true; } else { isGetDisseminationRequest = true; } } else if (URIArray.length == 9) { try { versDateTime = DateUtility.parseDateStrict(URIArray[8]); } catch (ParseException e) { String message = "Dissemination Request Syntax Error: DateTime value " + "of \"" + URIArray[8] + "\" is not a valid DateTime format. " + " <br></br> The expected format for DateTime is \"" + "YYYY-MM-DDTHH:MM:SS.SSS\". " + " <br></br> The expected syntax for Dissemination requests is: \"" + URIArray[0] + "//" + URIArray[2] + "/" + URIArray[3] + "/" + URIArray[4] + "/PID/sDefPID/methodName[/dateTime][?ParmArray] \" " + " <br></br> Submitted request was: \"" + requestURI + "\" . "; logger.warn(message); throw new ServletException("from FedoraAccessServlet" + message); /* * commented out for exception.jsp test * response.setStatus(HttpServletResponse * .SC_INTERNAL_SERVER_ERROR); * response.sendError(HttpServletResponse * .SC_INTERNAL_SERVER_ERROR, message); return; commented * out for exception.jsp test */ } asOfDateTime = versDateTime; isGetDisseminationRequest = true; } if (URIArray.length > 9) { String message = "Dissemination Request Syntax Error: The expected " + "syntax for Dissemination requests is: \"" + URIArray[0] + "//" + URIArray[2] + "/" + URIArray[3] + "/" + URIArray[4] + "/PID/sDefPID/methodName[/dateTime][?ParmArray] \" " + " <br></br> Submitted request was: \"" + requestURI + "\" . "; logger.warn(message); throw new ServletException("from FedoraAccessServlet" + message); /* * commented out for exception.jsp test * response.setStatus(HttpServletResponse * .SC_INTERNAL_SERVER_ERROR); * response.sendError(HttpServletResponse * .SC_INTERNAL_SERVER_ERROR, message); return; commented out * for exception.jsp test */ } } else { // Bad syntax; redirect to syntax documentation page. response.sendRedirect("/userdocs/client/browser/apialite/index.html"); return; } // Separate out servlet parameters from method parameters Hashtable<String, String> h_userParms = new Hashtable<String, String>(); for (Enumeration<?> e = request.getParameterNames(); e.hasMoreElements();) { String name = URLDecoder.decode((String) e.nextElement(), "UTF-8"); if (isGetObjectProfileRequest && name.equalsIgnoreCase("xml")) { xml = Boolean.parseBoolean(request.getParameter(name)); } else { String value = URLDecoder.decode(request.getParameter(name), "UTF-8"); h_userParms.put(name, value); } } // API-A interface requires user-supplied parameters to be of type // Property[] so create Property[] from hashtable of user parameters. int userParmCounter = 0; userParms = new Property[h_userParms.size()]; for (Enumeration<String> e = h_userParms.keys(); e.hasMoreElements();) { Property userParm = new Property(); userParm.name = e.nextElement(); userParm.value = h_userParms.get(userParm.name); userParms[userParmCounter] = userParm; userParmCounter++; } PID = URIArray[5]; String actionLabel = "Access"; try { if (isGetObjectProfileRequest) { logger.debug("Servicing getObjectProfile request (PID={}, asOfDate={})", PID, versDateTime); Context context = ReadOnlyContext.getContext(HTTP_REQUEST.REST.uri, request); getObjectProfile(context, PID, asOfDateTime, xml, request, response); logger.debug("Finished servicing getObjectProfile request"); } else if (isGetDisseminationRequest) { sDefPID = URIArray[6]; logger.debug("Servicing getDissemination request (PID={}, sDefPID={}, methodName={}, asOfDate={})", PID, sDefPID, methodName, versDateTime); Context context = ReadOnlyContext.getContext(HTTP_REQUEST.REST.uri, request); getDissemination(context, PID, sDefPID, methodName, userParms, asOfDateTime, response, request); logger.debug("Finished servicing getDissemination request"); } else if (isGetDatastreamDisseminationRequest) { logger.debug("Servicing getDatastreamDissemination request " + "(PID={}, dsID={}, asOfDate={})", PID, dsID, versDateTime); Context context = ReadOnlyContext.getContext(HTTP_REQUEST.REST.uri, request); getDatastreamDissemination(context, PID, dsID, asOfDateTime, response, request); logger.debug("Finished servicing getDatastreamDissemination " + "request"); } } catch (MethodNotFoundException e) { logger.error("Method not found for request: " + requestURI + " (actionLabel=" + actionLabel + ")", e); throw new NotFound404Exception("", e, request, actionLabel, e.getMessage(), EMPTY_STRING_ARRAY); } catch (DatastreamNotFoundException e) { logger.error("Datastream not found for request: " + requestURI + " (actionLabel=" + actionLabel + ")", e); throw new NotFound404Exception("", e, request, actionLabel, e.getMessage(), EMPTY_STRING_ARRAY); } catch (ObjectNotFoundException e) { logger.error("Object not found for request: " + requestURI + " (actionLabel=" + actionLabel + ")", e); throw new NotFound404Exception("", e, request, actionLabel, e.getMessage(), EMPTY_STRING_ARRAY); } catch (DisseminationException e) { logger.error("Dissemination failed: " + requestURI + " (actionLabel=" + actionLabel + ")", e); throw new NotFound404Exception("", e, request, actionLabel, e.getMessage(), EMPTY_STRING_ARRAY); } catch (ObjectNotInLowlevelStorageException e) { logger.error("Object or datastream not found for request: " + requestURI + " (actionLabel=" + actionLabel + ")", e); throw new NotFound404Exception("", e, request, actionLabel, e.getMessage(), EMPTY_STRING_ARRAY); } catch (AuthzException ae) { logger.error("Authorization failed for request: " + requestURI + " (actionLabel=" + actionLabel + ")", ae); throw RootException.getServletException(ae, request, actionLabel, EMPTY_STRING_ARRAY); } catch (Throwable th) { logger.error("Unexpected error servicing API-A request", th); throw new InternalError500Exception("", th, request, actionLabel, "", EMPTY_STRING_ARRAY); } }
From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java
@Override public List<Motransaction> findbytransactionRegisterList(int theFrom, int theTo, ArrayList<?> theFilterDetails, int moaccountid) throws BankingException { Session aSession = null;// ww w . ja v a 2 s .c om String param1 = null, param2 = null, value = null, param3 = "0"; if (theFilterDetails != null) { for (int i = 0; i < theFilterDetails.size(); i++) { if (i == 0) { param1 = theFilterDetails.get(i).toString(); } else if (i == 1) { param2 = theFilterDetails.get(i).toString(); } else if (i == 2) { value = theFilterDetails.get(i).toString(); } else if (i == 3) { param3 = theFilterDetails.get(i).toString(); } } } List<Motransaction> aQueryList = new ArrayList<Motransaction>(); String aCustomerQry = "SELECT *,CASE WHEN moTransaction.rxMasterID IS NULL THEN description ELSE (SELECT NAME FROM rxMaster WHERE " + " rxMasterID=moTransaction.rxMasterID) END 'namedescription' FROM moTransaction WHERE moAccountID =" + moaccountid; Motransaction aMotransaction = null; if (param1 != null && param1.equalsIgnoreCase("Amount")) { if (param2 != null && param2.equalsIgnoreCase("Exact")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) =" + value; else if (param2 != null && param2.equalsIgnoreCase("Greater")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) >" + value; else if (param2 != null && param2.equalsIgnoreCase("Greater or equal")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) >=" + value; else if (param2 != null && param2.equalsIgnoreCase("Less")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) <" + value; else if (param2 != null && param2.equalsIgnoreCase("Less or equal")) aCustomerQry += " and IF(amount < 0, amount*-1, amount) <=" + value; } else if (param1 != null && param1.equalsIgnoreCase("Cleared Status")) { if (param2 != null && param2.equalsIgnoreCase("Reconcile")) aCustomerQry += " and reconciled=1 "; else if (param2 != null && param2.equalsIgnoreCase("Unreconciled")) aCustomerQry += " and reconciled=0 and status=0"; /*if (param3.equals("0")) aCustomerQry += " limit " + theFrom + " ," + theTo; if (param3.equals("1")) aCustomerQry += " limit " + theFrom + " ," + theTo;*/ System.out.println("==============================================>" + aCustomerQry); } else if (param1 != null && param1.equalsIgnoreCase("Date")) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat parseDateFormat = new SimpleDateFormat("MM/dd/yyyy"); Date fromDate = null, toDate = null; try { if (param2 != null) fromDate = parseDateFormat.parse(param2); } catch (ParseException e) { e.printStackTrace(); } if (param2 != null && value.equals("0")) aCustomerQry += " and transactionDate >='" + simpleDateFormat.format(fromDate) + "'"; else if (param2 == null && value != null) aCustomerQry += " and transactionDate <='" + simpleDateFormat.format(toDate) + "'"; else if (param2 != null && value != null && !value.equals("0")) { if (value != null && !value.equals("0")) try { toDate = parseDateFormat.parse(value); } catch (ParseException e) { e.printStackTrace(); } aCustomerQry += " and transactionDate between '" + simpleDateFormat.format(fromDate) + "' and '" + simpleDateFormat.format(toDate) + "'"; } } else if (param1 != null && param1.equalsIgnoreCase("Reference")) { if (param2 != null && param2.equalsIgnoreCase("Contains")) aCustomerQry += " and reference like '%" + value + "%'"; else if (param2 != null && param2.equalsIgnoreCase("Exact")) aCustomerQry += " and reference ='" + value + "'"; } else if (param1 != null && param1.equalsIgnoreCase("G/L Account #")) { aCustomerQry += " and coAccountID =" + param2 + ""; } else if (param1 != null && param1.equalsIgnoreCase("Type")) { if (param2 != null && param2.equalsIgnoreCase("Deposit")) aCustomerQry += " and amount > 0 "; else aCustomerQry += " and amount < 0 "; } //aCustomerQry +=" ORDER BY moTransactionID DESC"; String sort = (String) theFilterDetails.get(theFilterDetails.size() - 1); String descriptionFilter = ""; if (param1 != null && param1.equalsIgnoreCase("Description")) { if (sort.equals("0")) aCustomerQry += " ORDER BY transactionDate ASC"; else aCustomerQry += " ORDER BY transactionDate DESC"; if (param2 != null && param2.equalsIgnoreCase("Contains")) descriptionFilter += " description like '%" + value + "%' or namedescription like '%" + value + "%'"; else if (param2 != null && param2.equalsIgnoreCase("Ends with")) descriptionFilter += " description like '%" + value + "' or namedescription like '%" + value + "'"; else if (param2 != null && param2.equalsIgnoreCase("Exact")) descriptionFilter += " description ='" + value + "' or namedescription = '" + value + "'"; else if (param2 != null && param2.equalsIgnoreCase("Starts with")) descriptionFilter += " description like '" + value + "%' or namedescription like '" + value + "%'"; aCustomerQry = "Select * from (" + aCustomerQry + ")as subquery where " + descriptionFilter; if (sort.equals("0")) aCustomerQry += " limit " + theFrom + " ," + theTo; else aCustomerQry += " limit " + theFrom + " ," + theTo; } else { if (sort.equals("0")) aCustomerQry += " ORDER BY transactionDate ASC limit " + theFrom + " ," + theTo; else aCustomerQry += " ORDER BY transactionDate DESC limit " + theFrom + " ," + theTo; } System.out.println("aCustomerQry===" + aCustomerQry); try { aSession = itsSessionFactory.openSession(); Query aQuery = aSession.createSQLQuery(aCustomerQry); Iterator<?> aIterator = aQuery.list().iterator(); while (aIterator.hasNext()) { aMotransaction = new Motransaction(); Object[] aObj = (Object[]) aIterator.next(); aMotransaction.setMoTransactionId((Integer) aObj[0]); aMotransaction.setRxMasterId((Integer) aObj[1]); aMotransaction.setRxAddressId((Integer) aObj[2]); aMotransaction.setCoAccountId((Integer) aObj[3]); aMotransaction.setMoAccountId((Integer) aObj[4]); if (aObj[5] != null && aObj[5] != "") aMotransaction.setTransDate((String) DateFormatUtils.format((Date) aObj[5], "MM/dd/yyyy")); aMotransaction.setMoTransactionTypeId((Short) aObj[6]); aMotransaction.setMoTypeId((Short) aObj[6]); aMotransaction.setCheckType((Short) aObj[7]); aMotransaction.setReference((String) aObj[8]); aMotransaction.setDescription((String) aObj[9]); aMotransaction.setVoid_((Byte) aObj[10]); aMotransaction.setReconciled((Byte) aObj[11]); aMotransaction.setTempRec((Byte) aObj[12]); aMotransaction.setPrinted((Byte) aObj[13]); aMotransaction.setAmount((BigDecimal) aObj[14]); aMotransaction.setWithDrawel((BigDecimal) aObj[14]); aMotransaction.setDirectDeposit((Byte) aObj[15]); aMotransaction.setBalance((BigDecimal) aObj[16]); aMotransaction.setStatus((Boolean) aObj[17]); aMotransaction.setMemo((String) aObj[18]); aMotransaction.setDisplaydiscription((String) aObj[21]); Date myDate = new Date(); String futureornot = "Current Transaction"; if ((Date) aObj[5] != null) { if (myDate.compareTo((Date) aObj[5]) < 0 || myDate.compareTo((Date) aObj[5]) == 0) { futureornot = "Future Transaction"; } else { futureornot = "Current Transaction"; } } aMotransaction.setFutureorcurrent(futureornot); aQueryList.add(aMotransaction); } } catch (Exception e) { itsLogger.error(e.getMessage(), e); BankingException aBankingException = new BankingException(e.getMessage(), e); throw aBankingException; } finally { aSession.flush(); aSession.close(); aCustomerQry = null; } return aQueryList; }
From source file:com.clustercontrol.plugin.impl.SchedulerPlugin.java
private void initDbmsScheduler() throws HinemosUnknown { log.debug("initDbmsScheduler() start."); Throwable exception = null;/* www. j a v a2s.com*/ //???(???Hinemos??) String propCron = null; String propBaseTime = null; propCron = PropertyConstants.hub_transfer_delay_interval.string(); log.debug("propCron:" + propCron); try { CronExpression.validateExpression(propCron); } catch (ParseException e) { log.warn(PropertyConstants.hub_transfer_delay_interval.message_invalid(propCron)); //?????DB??? propCron = null; } propBaseTime = PropertyConstants.hub_transfer_batch_basetime.string(); log.debug("propBaseTime:" + propBaseTime); List<DbmsSchedulerEntity> entityList = null; entityList = QueryUtil.getAllDbmsScheduler(); for (DbmsSchedulerEntity entity : entityList) { if (log.isDebugEnabled()) log.debug("entity:" + entity.getId().getJobId()); try { boolean isMisfire = entity.getMisfireInstr() == Trigger.MISFIRE_INSTRUCTION_DO_NOTHING ? true : false; //? Serializable[] jdArgs = new Serializable[entity.getJobArgNum()]; @SuppressWarnings("unchecked") Class<? extends Serializable>[] jdArgsType = new Class[entity.getJobArgNum()]; for (int i = 0; i < entity.getJobArgNum(); i++) { String strArg = null; switch (i) { case 0: strArg = entity.getJobArg00(); break; case 1: strArg = entity.getJobArg01(); break; case 2: strArg = entity.getJobArg02(); break; case 3: strArg = entity.getJobArg03(); break; case 4: strArg = entity.getJobArg04(); break; case 5: strArg = entity.getJobArg05(); break; case 6: strArg = entity.getJobArg06(); break; case 7: strArg = entity.getJobArg07(); break; case 8: strArg = entity.getJobArg08(); break; case 9: strArg = entity.getJobArg09(); break; case 10: strArg = entity.getJobArg10(); break; case 11: strArg = entity.getJobArg11(); break; case 12: strArg = entity.getJobArg12(); break; case 13: strArg = entity.getJobArg13(); break; case 14: strArg = entity.getJobArg14(); break; default: log.debug("arg count ng."); } if (log.isDebugEnabled()) log.debug("strArg[" + i + "]:" + strArg); if (strArg != null) { String[] splitArg = strArg.split(":", 2); if (splitArg[0].equals("String")) { jdArgsType[i] = String.class; jdArgs[i] = splitArg[1]; } else if (splitArg[0].equals("Boolean")) { jdArgsType[i] = Boolean.class; jdArgs[i] = Boolean.parseBoolean(splitArg[1]); } else if (splitArg[0].equals("Integer")) { jdArgsType[i] = Integer.class; jdArgs[i] = Integer.parseInt(splitArg[1]); } else if (splitArg[0].equals("Long")) { jdArgsType[i] = Long.class; jdArgs[i] = Long.parseLong(splitArg[1]); } else if (splitArg[0].equals("Short")) { jdArgsType[i] = Short.class; jdArgs[i] = Short.parseShort(splitArg[1]); } else if (splitArg[0].equals("Float")) { jdArgsType[i] = Float.class; jdArgs[i] = Float.parseFloat(splitArg[1]); } else if (splitArg[0].equals("Double")) { jdArgsType[i] = Double.class; jdArgs[i] = Double.parseDouble(splitArg[1]); } else if (splitArg[0].equals("nullString")) { jdArgsType[i] = String.class; jdArgs[i] = null; } else { log.debug("not support class"); } if (log.isDebugEnabled()) log.debug("jdArgs[" + i + "]:" + jdArgs[i]); } } // ?? JobDetail job = JobBuilder.newJob(ReflectionInvokerJob.class) .withIdentity(entity.getId().getJobId(), entity.getId().getJobGroup()).storeDurably(true) // ?????? .usingJobData(ReflectionInvokerJob.KEY_CLASS_NAME, entity.getJobClassName()) // ??????? .usingJobData(ReflectionInvokerJob.KEY_METHOD_NAME, entity.getJobMethodName()) // ????? .usingJobData(ReflectionInvokerJob.KEY_RESET_ON_RESTART, isMisfire) // ??trigger()??????? .build(); job.getJobDataMap().put(ReflectionInvokerJob.KEY_ARGS_TYPE, jdArgsType); job.getJobDataMap().put(ReflectionInvokerJob.KEY_ARGS, jdArgs); // ??trigger? Trigger trigger = null; if (entity.getTriggerType().equals(SchedulerPlugin.TriggerType.CRON.name())) { CronTriggerBuilder triggerBuilder = CronTriggerBuilder.newTrigger() .withIdentity(entity.getId().getJobId(), entity.getId().getJobGroup()); if (isMisfire) { triggerBuilder.withMisfireHandlingInstructionDoNothing(); } else { triggerBuilder.withMisfireHandlingInstructionIgnoreMisfires(); } trigger = triggerBuilder.cronSchedule(entity.getCronExpression()).startAt(entity.getStartTime()) .endAt(entity.getEndTime()).build(); ((AbstractTrigger) trigger).setNextFireTime(entity.getNextFireTime()); ((AbstractTrigger) trigger).setPreviousFireTime(entity.getPrevFireTime()); } else if (entity.getTriggerType().equals(SchedulerPlugin.TriggerType.SIMPLE.name())) { SimpleTriggerBuilder triggerBuilder = SimpleTriggerBuilder.newTrigger() .withIdentity(entity.getId().getJobId(), entity.getId().getJobGroup()); if (isMisfire) { triggerBuilder.withMisfireHandlingInstructionDoNothing(); } else { triggerBuilder.withMisfireHandlingInstructionIgnoreMisfires(); } trigger = triggerBuilder.setPeriod(entity.getRepeatInterval()).startAt(entity.getStartTime()) .endAt(entity.getEndTime()).build(); ((AbstractTrigger) trigger).setNextFireTime(entity.getNextFireTime()); ((AbstractTrigger) trigger).setPreviousFireTime(entity.getPrevFireTime()); } //???(???Hinemos???) if (entity.getId().getJobGroup().equals(com.clustercontrol.hub.bean.QuartzConstant.GROUP_NAME)) { //???DB? TransferInfo ti = null; try { ti = com.clustercontrol.hub.util.QueryUtil.getTransferInfo(entity.getId().getJobId(), ObjectPrivilegeMode.MODIFY); } catch (LogTransferNotFound e) { log.warn("Not Found TransferInfo:" + entity.getId().getJobId()); } catch (InvalidRole e) { log.warn("Failed to get TransferInfo for InvalidRole:" + entity.getId().getJobId()); } //????trigger? if (ti != null) { if (propCron != null && ti.getTransType() == TransferType.delay) { CronTriggerBuilder triggerBuilder = CronTriggerBuilder.newTrigger() .withIdentity(entity.getId().getJobId(), entity.getId().getJobGroup()); if (isMisfire) { triggerBuilder.withMisfireHandlingInstructionDoNothing(); } else { triggerBuilder.withMisfireHandlingInstructionIgnoreMisfires(); } trigger = triggerBuilder.cronSchedule(propCron) .startAt(HinemosTime.currentTimeMillis() + 15 * 1000).build(); } else if (propBaseTime != null && ti.getTransType() == TransferType.batch) { int intervalSec = ti.getInterval() * 60 * 60; long baseTime = com.clustercontrol.hub.factory.ModifySchedule.getBaseTime(propBaseTime, intervalSec); log.debug("baseTime:" + baseTime); SimpleTriggerBuilder triggerBuilder = SimpleTriggerBuilder.newTrigger() .withIdentity(entity.getId().getJobId(), entity.getId().getJobGroup()); if (isMisfire) { triggerBuilder.withMisfireHandlingInstructionDoNothing(); } else { triggerBuilder.withMisfireHandlingInstructionIgnoreMisfires(); } trigger = triggerBuilder.setPeriod(intervalSec * 1000).startAt(baseTime).build(); } } //?DB try { ModifyDbmsScheduler dbms = new ModifyDbmsScheduler(); dbms.modifyDbmsScheduler(job, trigger); trigger.computeFirstFireTime(HinemosTime.currentTimeMillis()); dbms.modifyDbmsSchedulerInternal(job, trigger, TriggerState.SCHEDULED.name()); } catch (Exception e) { log.warn("hub setting init err. entity : jobId = " + entity.getId().getJobId() + ", " + entity.getId().getJobGroup() + ", " + e.getClass().getSimpleName() + ", " + e.getMessage()); exception = e; } } if (log.isDebugEnabled()) { log.debug("getNextFireTime=" + trigger.getNextFireTime() + ", getPreviousFireTime=" + trigger.getPreviousFireTime()); } // ? synchronized (_schedulerLock) { if (log.isDebugEnabled()) log.debug("scheduleJob() name=" + entity.getId().getJobId() + ", group=" + entity.getId().getJobGroup()); // DB???????RAM??/???? _scheduler.get(SchedulerPlugin.SchedulerType.DBMS).initDbmsScheduleJob(job, trigger, entity.getTriggerState()); } } catch (RuntimeException e) { log.warn("initDbmsScheduler() entity : jobId = " + entity.getId().getJobId() + ", " + entity.getId().getJobGroup() + ", " + e.getClass().getSimpleName() + ", " + e.getMessage()); // ??????throw???? exception = e; } } if (exception != null) { throw new HinemosUnknown("failed dbms scheduler:", exception); } log.debug("initDbmsScheduler() end."); }
From source file:de.tuttas.servlets.DokuServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww .j a v a 2 s. co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String auth = request.getParameter("auth_token"); String service = request.getParameter("service_key"); Log.d("auth_token=" + auth); if (request.getParameter("cmd") == null || request.getParameter("idklasse") == null || request.getParameter("from") == null) { Log.d("Info zeigen"); response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Doku Servlet Usage</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Doku Servlet @ " + request.getContextPath() + "</h1>"); out.println( "<a href='?cmd=Verlauf&idklasse=3608&from=2015-09-08&debug=" + Config.getInstance().debug + "' target='_pdf'>Usage: ?cmd=verlauf&idklasse=3608&from=2015-09-08</a>"); out.println("</body>"); out.println("</html>"); } } else { if (Config.getInstance().debug || service != null && auth != null && Authenticator.getInstance().isAuthTokenValid(auth)) { Log.d("ID Klasse = " + request.getParameter("idklasse")); Klasse kl = em.find(Klasse.class, Integer.parseInt(request.getParameter("idklasse"))); String cmd = request.getParameter("cmd"); String type = request.getParameter("type"); String sidSchuljahr = request.getParameter("idSchuljahr"); int idSchuljahr = -1; if (sidSchuljahr != null) { try { idSchuljahr = Integer.parseInt(sidSchuljahr); } catch (NumberFormatException nux) { } } String filter1 = request.getParameter("dokufilter1"); String filter2 = request.getParameter("dokufilter2"); int anwFilter1 = 0; int anwFilter2 = 0; if (request.getParameter("anwfilter1") != null) { anwFilter1 = Integer.parseInt(request.getParameter("anwfilter1")); } if (request.getParameter("anwfilter2") != null) { anwFilter2 = Integer.parseInt(request.getParameter("anwfilter2")); } Authenticator a = Authenticator.getInstance(); String me = a.getUser(auth); Log.d("Verlauf Filter1=" + filter1 + " Verlauf Filter2=" + filter2 + " me=" + me); Log.d("Anwesenheitsfilter 1 = " + anwFilter1 + " Filter2=" + anwFilter2); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date parsedFrom = null; try { parsedFrom = (Date) dateFormat.parse(request.getParameter("from")); } catch (ParseException ex) { Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex); } Date parsedTo = null; if (request.getParameter("to") == null) { parsedTo = new java.sql.Date(System.currentTimeMillis()); } else { try { parsedTo = (Date) dateFormat.parse(request.getParameter("to")); } catch (ParseException ex) { Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex); } } Log.d("setze To auf " + new java.sql.Date(parsedTo.getTime())); Log.d("type=" + type + " cmd=" + cmd + " Klasse=" + kl.getKNAME()); if (type.compareTo("csv") == 0) { MyTableDataModel myModel = null; if (cmd.compareTo("Betriebe") == 0) { response.setContentType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String fileName = cmd + "_" + kl.getKNAME() + "_" + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx"; fileName = URLEncoder.encode(fileName, "UTF-8"); String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName; response.addHeader("Content-Disposition", contentDisposition); myModel = getModelBetriebsliste(kl); XSSFWorkbook wb = ExcelUtil.readExcel( Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx", new String[] { "Betriebe" }, myModel.getRows(), myModel.getCols()); wb = myModel.toExcel(wb, 0); wb.write(response.getOutputStream()); } else if (cmd.compareTo("Notenliste") == 0) { response.setContentType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String fileName = cmd + "_" + kl.getKNAME() + "_" + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx"; fileName = URLEncoder.encode(fileName, "UTF-8"); String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName; response.addHeader("Content-Disposition", contentDisposition); myModel = getModelNotenliste(kl, idSchuljahr); XSSFWorkbook wb = ExcelUtil.readExcel( Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx", new String[] { "Notenliste" }, myModel.getRows(), myModel.getCols()); wb = myModel.toExcel(wb, 0); wb.write(response.getOutputStream()); } else if (cmd.compareTo("Fehlzeiten") == 0) { response.setContentType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String fileName = cmd + "_" + kl.getKNAME() + "_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx"; fileName = URLEncoder.encode(fileName, "UTF-8"); String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName; response.addHeader("Content-Disposition", contentDisposition); myModel = getModelFehlzeiten(kl, parsedFrom, parsedTo); XSSFWorkbook wb = ExcelUtil.readExcel( Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx", new String[] { "Fehlzeiten" }, myModel.getRows(), myModel.getCols()); wb = myModel.toExcel(wb, 0); wb.write(response.getOutputStream()); } else if (cmd.compareTo("Anwesenheit") == 0) { response.setContentType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String fileName = cmd + "_" + kl.getKNAME() + "_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx"; fileName = URLEncoder.encode(fileName, "UTF-8"); String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName; response.addHeader("Content-Disposition", contentDisposition); myModel = getModelAnwesenheit(kl, parsedFrom, parsedTo, anwFilter1, anwFilter2); XSSFWorkbook wb = ExcelUtil.readExcel( Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx", new String[] { "Anwesenheit" }, myModel.getRows(), myModel.getCols()); wb = myModel.toExcel(wb, 0); wb.write(response.getOutputStream()); } else if (cmd.compareTo("Verlauf") == 0) { response.setContentType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String fileName = cmd + "_" + kl.getKNAME() + "_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx"; fileName = URLEncoder.encode(fileName, "UTF-8"); String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName; response.addHeader("Content-Disposition", contentDisposition); myModel = getModelVerlauf(kl, parsedFrom, parsedTo, filter1, filter2, me); XSSFWorkbook wb = ExcelUtil.readExcel( Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx", new String[] { "Unterrichtsverlauf" }, myModel.getRows(), myModel.getCols()); wb = myModel.toExcel(wb, 0); wb.write(response.getOutputStream()); } else if (cmd.compareTo("UmfrageAuswertung") == 0) { Umfrage u = em.find(Umfrage.class, anwFilter1); Umfrage u2 = em.find(Umfrage.class, anwFilter2); response.setContentType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String fileName = "Auswertung_" + u.getNAME() + "_vom_" + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx"; fileName = URLEncoder.encode(fileName, "UTF-8"); String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName; response.addHeader("Content-Disposition", contentDisposition); List<UmfrageResult> res1 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter1, filter1); List<UmfrageResult> res2 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter2, filter2); res2 = UmfrageUtil.getComparableResultList(res1, res2); myModel = getModelUmfrageAuswertung(res1); XSSFWorkbook wb = ExcelUtil.readExcel( Config.getInstance().TEMPLATE_FILE_PATH + u.getNAME() + ".xlsx", new String[] { "Hauptgruppe", "Vergleichsgruppe", "Info" }, myModel.getRows(), myModel.getCols()); wb = myModel.toExcel(wb, 0); myModel = getModelUmfrageAuswertung(res2); wb = myModel.toExcel(wb, 1); XSSFSheet s = wb.getSheetAt(2); XSSFRow r = s.getRow(0); r.getCell(0).setCellValue(u.getNAME()); r.getCell(1).setCellValue(filter1); r = s.getRow(1); r.getCell(0).setCellValue(u2.getNAME()); r.getCell(1).setCellValue(filter2); wb.write(response.getOutputStream()); } else { PrintWriter out = response.getWriter(); response.setContentType("application/json; charset=UTF-8"); String r = "{\"error\":true,\"msg\":\"Kann fr " + cmd + " kein Datenmodell erzeugen!\"}"; out.print(r); } } else { response.setContentType("application/pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); try { String kopf = ""; kopf += ("<table border='1' align='center' width='100%'>"); kopf += ("<tr>"); kopf += ("<td rowspan=\"3\" width='150px'></td>"); kopf += ("<td align='center'><h2>Multi Media Berufsbildende Schulen Hannover</h2></td>"); if (cmd.compareTo("Verlauf") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Unterrichtsverlauf</b></td>"); } else if (cmd.compareTo("Anwesenheit") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Anwesenheit</b></td>"); } else if (cmd.compareTo("Fehlzeiten") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Fehlzeiten</b></td>"); } else if (cmd.compareTo("Stundenplan") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Stundenplan</b></td>"); } else if (cmd.compareTo("Vertretungsplan") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Vertretungsplan</b></td>"); } else if (cmd.compareTo("Notenliste") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Notenliste</b></td>"); } else if (cmd.compareTo("Betriebe") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Betriebsliste</b></td>"); } else if (cmd.compareTo("UmfrageAuswertung") == 0) { kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Auswertung Umfrage</b></td>"); } kopf += ("</tr>"); kopf += ("<tr>"); if (cmd.compareTo("UmfrageAuswertung") == 0) { Umfrage u1 = em.find(Umfrage.class, anwFilter1); Umfrage u2 = em.find(Umfrage.class, anwFilter2); kopf += ("<td align='center' rowspan=\"2\" style=\"padding:5px;font-size: 11\">Hauptgruppe: (" + u1.getNAME() + "/" + filter1 + ")<br></br> Vergleichsgruppe: (" + u2.getNAME() + "/" + filter2 + ")</td>"); } else { kopf += ("<td align='center' rowspan=\"2\"><h3>Klasse/ Kurs: " + kl.getKNAME() + "</h3></td>"); } kopf += ("<td style=\"font-size: 11;\">Verantwortlicher: " + kl.getID_LEHRER() + "</td>"); kopf += ("<td style=\"font-size: 11;\">geprft</td>"); kopf += ("</tr>"); kopf += ("<tr>"); DateFormat df = new SimpleDateFormat("dd.MM.yyyy"); Calendar c = df.getCalendar(); c.setTimeInMillis(System.currentTimeMillis()); String dat = c.get(Calendar.DAY_OF_MONTH) + "." + (c.get(Calendar.MONTH) + 1) + "." + c.get(Calendar.YEAR); kopf += ("<td style=\"font-size: 11;\">Ausdruck am: " + dat + "</td>"); kopf += ("<td style=\"font-size: 11;\">Datum</td>"); kopf += ("</tr>"); kopf += ("</table>"); kopf += ("<p> </p>"); Document document; if (cmd.compareTo("Verlauf") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Verlauf_" + kl.getKNAME() + "_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); document = createVerlauf(kl, kopf, parsedFrom, parsedTo, out, filter1, filter2, me); } else if (cmd.compareTo("Portfolio") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Portfolio_" + kl.getKNAME() + ".pdf"); document = createPortfolio(kl, out); } else if (cmd.compareTo("Anwesenheit") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Anwesenheit_" + kl.getKNAME() + "_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); document = createAnwesenheit(kl, kopf, parsedFrom, parsedTo, out, anwFilter1, anwFilter2); } else if (cmd.compareTo("Fehlzeiten") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Fehlzeiten_" + kl.getKNAME() + "_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); MyTableDataModel myModel = getModelFehlzeiten(kl, parsedFrom, parsedTo); document = createFehlzeiten(kl, kopf, parsedFrom, parsedTo, out); } else if (cmd.compareTo("Vertretungsliste") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Vertretungsliste_" + new java.sql.Date(parsedFrom.getTime()).toString() + "-" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); document = createVertretungsliste(parsedFrom, parsedTo, out); } else if (cmd.compareTo("Notenliste") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Notenliste_" + kl.getKNAME() + "_" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); MyTableDataModel myModel = getModelNotenliste(kl, idSchuljahr); Schuljahr schuljahr = em.find(Schuljahr.class, idSchuljahr); document = createNotenliste(myModel, kopf, out, schuljahr.getNAME()); } else if (cmd.compareTo("Betriebe") == 0) { response.addHeader("Content-Disposition", "attachment; filename=Betriebsliste_" + kl.getKNAME() + "_" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); MyTableDataModel myModel = getModelBetriebsliste(kl); document = createBetriebsListe(myModel, kopf, out); } else if (cmd.compareTo("UmfrageAuswertung") == 0) { response.addHeader("Content-Disposition", "attachment; filename=UmfrageAuswertung_" + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf"); List<UmfrageResult> res1 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter1, filter1); List<UmfrageResult> res2 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter2, filter2); res2 = UmfrageUtil.getComparableResultList(res1, res2); if (res1 != null && res2 != null) { Log.d("erzeuge pdf Dokument"); document = createUmfrageauswertung(res1, res2, anwFilter1, anwFilter2, filter1, filter2, kopf, out); } } } catch (DocumentException exc) { Log.d("Document Exception " + exc.getMessage()); exc.printStackTrace(); throw new IOException(exc.getMessage()); } catch (ParseException ex) { Log.d("Parse Exception " + ex.getMessage()); Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex); } finally { out.close(); } } } else { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Doku Servlet Usage</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>You are not authorized</h1>"); out.println("</body>"); out.println("</html>"); } } } }