Package org.nxplanner.export

Examples of org.nxplanner.export.ExportException


            ByteArrayOutputStream data = new ByteArrayOutputStream();
            file.write(data);
            return data.toByteArray();
        } catch (Exception e) {
            throw new ExportException("exception during export", e);
        }
    }
View Full Code Here


        try {
            output = new ByteArrayOutputStream();
            exportToPdf(object, output);
            return output.toByteArray();
        } catch (DocumentException e) {
            throw new ExportException(e);
        } finally {
            if (output != null) {
                output.reset();
            }
        }
View Full Code Here

            Object object = getRepository(objectClass).load(Integer.parseInt(request.getParameter("oid")));
            byte[] data = exporter.export(session, object);
            exporter.initializeHeaders(response);
            response.getOutputStream().write(data);
        } catch (Exception ex) {
            throw new ExportException(ex);
        } finally {
            session.connection().rollback();
        }

        // Optional forward
View Full Code Here

         Iteration iteration = (Iteration)object;

         try {
            ds = new IterationDataSource(iteration, session);
         } catch (HibernateException he) {
            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRIteration.jasper");
         parameters.put("IterationName", iteration.getName());
         parameters.put("IterationStartDate", iteration.getStartDate());
         parameters.put("IterationEndDate", iteration.getEndDate());
      } else if (object instanceof UserStory) {
         UserStory story = (UserStory)object;

         try {
            ds = new UserStoryDataSource(story, session);
         } catch (HibernateException he) {
            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRStory.jasper");
         parameters.put("StoryName", story.getName());
         Person cust = story.getCustomer(); parameters.put("StoryCustomerName", (cust != null) ? cust.getName() : null);
         parameters.put("StoryEstimatedHours", new java.lang.Double(story.getEstimatedHours()));
         parameters.put("StoryDescription", story.getDescription());
      } else if (object instanceof Task) {
         Task task = (Task)object;

         try {
            ds = new TaskDataSource(task, session);
         } catch (HibernateException he) {
            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRTask.jasper");
         parameters.put("TaskName", task.getName());
         parameters.put("TaskDescription", task.getDescription());
         double actual = task.getActualHours();
         parameters.put("TaskPercentage", new java.lang.Integer((int)((actual * 100) / (actual + task.getRemainingHours()))));
         parameters.put("TaskDisposition", task.getDisposition());
         parameters.put("TaskType", task.getType());
         parameters.put("TaskAcceptor", getPersonName(session, new Integer(task.getAcceptorId())));
         parameters.put("TaskEstimate", new java.lang.Double(task.getEstimatedHours()));
         parameters.put("TaskCompleted", new java.lang.Boolean(task.isCompleted()));
      } else if (object instanceof Person) {
         Person person = (Person)object;

         try {
            ds = new PersonDataSource(person, session);
         } catch (HibernateException he) {
            throw new ExportException(he);
         }

         reportStream = PdfReportExporter.class.getClassLoader().getResourceAsStream("org/nxplanner/export/reports/JRPerson.jasper");
         parameters.put("PersonName", person.getName());
      }

      if (ds == null) {
         throw new ExportException("Could not instantiate data source");
      }

      if (reportStream == null) {
         throw new ExportException("Could not open compiled report");
      }

      try {
         JasperReport report = JasperManager.loadReport(reportStream);
         return JasperManager.runReportToPdf(report, parameters, ds);
      } catch (JRException jre) {
         throw new ExportException(jre);
      }
   }
View Full Code Here

TOP

Related Classes of org.nxplanner.export.ExportException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.