[jboss-svn-commits] JBL Code SVN: r35645 - in labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main: java/org/jboss/community/sbs/plugin/reports/monthly and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 21 09:32:38 EDT 2010


Author: lkrzyzanek
Date: 2010-10-21 09:32:36 -0400 (Thu, 21 Oct 2010)
New Revision: 35645

Added:
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/DbReportDAOImpl.java
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportBean.java
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportDAO.java
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManager.java
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManagerImpl.java
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/struts/MonthlyReportsAction.java
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/resources/templates/admin/monthly-reports.ftl
Modified:
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/plugin.xml
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/schema.xml
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/spring.xml
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/struts.xml
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/resources/plugin_i18n.properties
Log:
Added GUI, business logic and DAO - not completly implemented yet

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/DbReportDAOImpl.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/DbReportDAOImpl.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/DbReportDAOImpl.java	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,82 @@
+/*
+ * JBoss Community http://jboss.org/
+ *
+ * Copyright (c) 2010 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.community.sbs.plugin.reports.dao;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
+
+import com.jivesoftware.base.database.dao.JiveJdbcDaoSupport;
+import com.jivesoftware.base.database.sequence.SequenceManager;
+
+/**
+ * DB Implementation of {@link ReportDAO}
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public class DbReportDAOImpl extends JiveJdbcDaoSupport implements ReportDAO {
+
+  public static final int DB_REPORT_SEQ = 6000;
+
+  private static final String SELECT_ALL_REPORTS = "SELECT id, fromDate, toDate, redHatUsersSnapshot, status, statusMessage FROM reportsMonthly";
+
+  private static final String SELECT_REPORT_BY_ID = SELECT_ALL_REPORTS + " WHERE id = ?";
+
+  private static final String INSERT_REPORT = "INSERT INTO reportsMonthly (id, fromDate, toDate, redHatUsersSnapshot, status, statusMessage) "
+      + "VALUES (?, ?, ?, ?, ?, ?)";
+
+  @Override
+  public void createReport(ReportBean bean) {
+    bean.setId(SequenceManager.nextID(DB_REPORT_SEQ));
+
+    getSimpleJdbcTemplate().update(INSERT_REPORT, bean.getId(), bean.getFrom(), bean.getTo(),
+        bean.getRedHatUsersSnapshot(), bean.getStatus(), bean.getStatusMessage());
+  }
+
+  private final ReportBeanMapper reportBeanMapper = new ReportBeanMapper();
+
+  @Override
+  public List<ReportBean> getAllReports() {
+    return getSimpleJdbcTemplate().query(SELECT_ALL_REPORTS, reportBeanMapper);
+  }
+
+  @Override
+  public ReportBean getReport(long id) {
+    return getSimpleJdbcTemplate().queryForObject(SELECT_REPORT_BY_ID, reportBeanMapper, id);
+  }
+
+  private class ReportBeanMapper implements ParameterizedRowMapper<ReportBean> {
+    @Override
+    public ReportBean mapRow(ResultSet rs, int rowNum) throws SQLException {
+      ReportBean bean = new ReportBean();
+      bean.setId(rs.getLong(1));
+      bean.setFrom(rs.getLong(2));
+      bean.setTo(rs.getLong(3));
+      bean.setRedHatUsersSnapshot(rs.getLong(4));
+      bean.setStatus(rs.getInt(5));
+      bean.setStatusMessage(rs.getString(6));
+      return bean;
+    }
+  }
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/DbReportDAOImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportBean.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportBean.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportBean.java	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,123 @@
+/*
+ * JBoss Community http://jboss.org/
+ *
+ * Copyright (c) 2010 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.community.sbs.plugin.reports.dao;
+
+/**
+ * Bean contains data about report
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public class ReportBean {
+
+  /**
+   * Internal ID
+   */
+  private long id = -1;
+
+  /**
+   * Report range - from
+   */
+  private long from;
+
+  /**
+   * Report range - to
+   */
+  private long to;
+
+  /**
+   * RedHat Users Snapshot
+   */
+  private long redHatUsersSnapshot;
+
+  /**
+   * Configuration ID
+   */
+  private long configurationId;
+
+  /**
+   * Status of report
+   */
+  private int status;
+
+  /**
+   * Status message like "Processing SBS report"
+   */
+  private String statusMessage;
+
+  public long getId() {
+    return id;
+  }
+
+  public void setId(long id) {
+    this.id = id;
+  }
+
+  public long getFrom() {
+    return from;
+  }
+
+  public void setFrom(long from) {
+    this.from = from;
+  }
+
+  public long getTo() {
+    return to;
+  }
+
+  public void setTo(long to) {
+    this.to = to;
+  }
+
+  public long getRedHatUsersSnapshot() {
+    return redHatUsersSnapshot;
+  }
+
+  public void setRedHatUsersSnapshot(long redHatUsersSnapshot) {
+    this.redHatUsersSnapshot = redHatUsersSnapshot;
+  }
+
+
+  public int getStatus() {
+    return status;
+  }
+
+  public void setStatus(int status) {
+    this.status = status;
+  }
+
+  public String getStatusMessage() {
+    return statusMessage;
+  }
+
+  public void setStatusMessage(String statusMessage) {
+    this.statusMessage = statusMessage;
+  }
+
+  public long getConfigurationId() {
+    return configurationId;
+  }
+
+  public void setConfigurationId(long configurationId) {
+    this.configurationId = configurationId;
+  }
+
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportDAO.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportDAO.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportDAO.java	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,53 @@
+/*
+ * JBoss Community http://jboss.org/
+ *
+ * Copyright (c) 2010 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.community.sbs.plugin.reports.dao;
+
+import java.util.List;
+
+/**
+ * DAO For RedHat users
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public interface ReportDAO {
+
+  /**
+   * Insert new report
+   */
+  public void createReport(ReportBean report);
+
+  /**
+   * Get list of all reports
+   * 
+   * @return
+   */
+  public List<ReportBean> getAllReports();
+
+  /**
+   * Get report
+   * 
+   * @param id report id
+   * @return report bean
+   */
+  public ReportBean getReport(long id);
+
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/dao/ReportDAO.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManager.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManager.java	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,45 @@
+/*
+ * JBoss Community http://jboss.org/
+ *
+ * Copyright (c) 2010 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.community.sbs.plugin.reports.monthly;
+
+import java.io.InputStream;
+import java.util.Date;
+
+/**
+ * 
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public interface MonthlyReportManager {
+
+  /**
+   * Generate report in separate thread.<br/>
+   * Wrapper for
+   * {@link ReportGenerator#generateReport(InputStream, Date, Date, Date, SystemConfigProvider)}
+   * 
+   * @param from
+   * @param to
+   * @param redHatUsersSnapshot
+   */
+  public void generateReport(Date from, Date to, Date redHatUsersSnapshot);
+
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManager.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManagerImpl.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManagerImpl.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManagerImpl.java	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,79 @@
+/*
+ * JBoss Community http://jboss.org/
+ *
+ * Copyright (c) 2010 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.community.sbs.plugin.reports.monthly;
+
+import java.util.Date;
+
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.jboss.community.sbs.plugin.reports.dao.ReportBean;
+import org.jboss.community.sbs.plugin.reports.dao.ReportDAO;
+
+/**
+ * Implementation of {@link MonthlyReportManager} which uses
+ * {@link ReportGenerator}
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public class MonthlyReportManagerImpl implements MonthlyReportManager {
+
+  private static final Logger log = LogManager.getLogger(MonthlyReportManagerImpl.class);
+
+  private ReportDAO reportDAO;
+
+  private ReportGenerator reportGenerator;
+
+  @Override
+  public void generateReport(Date from, Date to, Date redHatUsersSnapshot) {
+    log.info("Generate report (" + from + " - " + to + "). RH UsersSnapshot: " + redHatUsersSnapshot);
+
+    ReportBean report = new ReportBean();
+    report.setFrom(from.getTime());
+    report.setTo(to.getTime());
+    report.setRedHatUsersSnapshot(redHatUsersSnapshot.getTime());
+    // create Status enum
+    report.setStatus(0);
+    report.setStatusMessage("Pending in queue");
+
+    reportDAO.createReport(report);
+
+    // TODO implement new thread and start report generation.
+
+  }
+
+  public void setReportDAO(ReportDAO reportDAO) {
+    this.reportDAO = reportDAO;
+  }
+
+  public ReportDAO getReportDAO() {
+    return reportDAO;
+  }
+
+  public void setReportGenerator(ReportGenerator reportGenerator) {
+    this.reportGenerator = reportGenerator;
+  }
+
+  public ReportGenerator getReportGenerator() {
+    return reportGenerator;
+  }
+
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/MonthlyReportManagerImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/struts/MonthlyReportsAction.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/struts/MonthlyReportsAction.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/struts/MonthlyReportsAction.java	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,167 @@
+/*
+ * JBoss.org http://jboss.org/
+ *
+ * Copyright (c) 2010  Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.community.sbs.plugin.reports.struts;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.jboss.community.sbs.plugin.reports.dao.ReportBean;
+import org.jboss.community.sbs.plugin.reports.dao.ReportDAO;
+import org.jboss.community.sbs.plugin.reports.monthly.MonthlyReportManager;
+
+import com.jivesoftware.community.action.JiveActionSupport;
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.validator.annotations.Validation;
+
+/**
+ * Action for viewing/creating Red Hat monthly reports
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ * 
+ */
+ at Validation
+public class MonthlyReportsAction extends JiveActionSupport implements Preparable {
+
+  public static final String DATE_PATTERN = "yyyy-MM-dd";
+
+  /**
+   * List of available reports
+   */
+  private List<ReportBean> reports;
+
+  /**
+   * Report range - from
+   */
+  private String from;
+
+  /**
+   * Report range - to
+   */
+  private String to;
+
+  /**
+   * RedHat Users Snapshot
+   */
+  private String redHatUsersSnapshot;
+
+  private ReportDAO reportDAO;
+
+  private MonthlyReportManager monthlyReportManager;
+
+  public void prepare() {
+    reports = reportDAO.getAllReports();
+  }
+
+  private void resetForm() {
+    from = null;
+    to = null;
+    redHatUsersSnapshot = null;
+  }
+
+  @Override
+  public void validate() {
+    if (StringUtils.trimToNull(from) == null) {
+      addActionError(getText("plugin.reports.admin.monthlyrep.error.required", new String[] { "Form" }));
+    }
+    if (StringUtils.trimToNull(to) == null) {
+      addActionError(getText("plugin.reports.admin.monthlyrep.error.required", new String[] { "To" }));
+    }
+    if (StringUtils.trimToNull(redHatUsersSnapshot) == null) {
+      addActionError(getText("plugin.reports.admin.monthlyrep.error.required",
+          new String[] { "Red Hat Users Snapshot" }));
+    }
+  }
+
+  @Override
+  public String execute() {
+    Date fromDate = null, toDate = null, redHatUsersSnapshotDate = null;
+    SimpleDateFormat formatter = new SimpleDateFormat(DATE_PATTERN);
+    formatter.setLenient(true);
+
+    try {
+      fromDate = formatter.parse(from);
+    } catch (ParseException e) {
+      addActionError(getText("plugin.reports.admin.monthlyrep.error.dateFormat", new String[] { DATE_PATTERN }));
+    }
+    try {
+      toDate = formatter.parse(to);
+    } catch (ParseException e) {
+      addActionError(getText("plugin.reports.admin.monthlyrep.error.dateFormat", new String[] { DATE_PATTERN }));
+    }
+    try {
+      redHatUsersSnapshotDate = formatter.parse(redHatUsersSnapshot);
+    } catch (ParseException e) {
+      addActionError(getText("plugin.reports.admin.monthlyrep.error.dateFormat", new String[] { DATE_PATTERN }));
+    }
+    if (hasActionErrors()) {
+      return INPUT;
+    }
+
+    monthlyReportManager.generateReport(fromDate, toDate, redHatUsersSnapshotDate);
+
+    reports = reportDAO.getAllReports();
+
+    addActionMessage(getText("plugin.reports.admin.monthlyrep.text.addedToQueue"));
+    resetForm();
+    return SUCCESS;
+  }
+
+  public void setReportDAO(ReportDAO reportDAO) {
+    this.reportDAO = reportDAO;
+  }
+
+  public void setMonthlyReportManager(MonthlyReportManager monthlyReportManager) {
+    this.monthlyReportManager = monthlyReportManager;
+  }
+
+  public List<ReportBean> getReports() {
+    return reports;
+  }
+
+  public String getFrom() {
+    return from;
+  }
+
+  public void setFrom(String from) {
+    this.from = from;
+  }
+
+  public String getTo() {
+    return to;
+  }
+
+  public void setTo(String to) {
+    this.to = to;
+  }
+
+  public String getRedHatUsersSnapshot() {
+    return redHatUsersSnapshot;
+  }
+
+  public void setRedHatUsersSnapshot(String redHatUsersSnapshot) {
+    this.redHatUsersSnapshot = redHatUsersSnapshot;
+  }
+
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/struts/MonthlyReportsAction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/plugin.xml	2010-10-21 13:15:33 UTC (rev 35644)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/plugin.xml	2010-10-21 13:32:36 UTC (rev 35645)
@@ -17,6 +17,9 @@
                      
           <item id="reports-jbossreports-rhusers" name="plugin.reports.admin.rhusers.name"
             url="redhat-users.jspa" description="plugin.reports.admin.rhusers.description" />
+            
+          <item id="reports-jbossreports-monthly" name="plugin.reports.admin.monthlyrep.name"
+            url="monthly-reports.jspa" description="plugin.reports.admin.monthlyrep.description" />
 
         </section>
       </tab>

Added: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/resources/templates/admin/monthly-reports.ftl
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/resources/templates/admin/monthly-reports.ftl	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/resources/templates/admin/monthly-reports.ftl	2010-10-21 13:32:36 UTC (rev 35645)
@@ -0,0 +1,51 @@
+<html>
+  <head>
+    <#assign pageTitle=action.getText('plugin.reports.admin.monthlyrep.name') />
+    <title>${pageTitle}</title>
+    <content tag="pagetitle">${pageTitle}</content>
+    <content tag="pageID">reports-jbossreports-monthly</content>
+  </head>
+  <body>
+    <#include "/template/global/include/form-message.ftl" />
+
+    <table>
+    <@s.form theme="simple" action="create-monthly-report">
+      <tr><td><@s.text name="plugin.reports.admin.monthlyrep.from"/><span>*</span>:</td>
+          <td><@s.textfield name="from" required="true"/></td></tr>
+      <tr><td><@s.text name="plugin.reports.admin.monthlyrep.to"/><span>*</span>:</td>
+          <td><@s.textfield name="to" required="true"/></td></tr>
+      <tr><td><@s.text name="plugin.reports.admin.monthlyrep.snapshot"/><span>*</span>:</td>
+          <td><@s.textfield name="redHatUsersSnapshot" required="true"/></td></tr>
+      <tr><td></td><td><@s.submit value="${action.getText('plugin.reports.admin.monthlyrep.createreport')}"/>
+    </@s.form>
+    </table>
+
+    <h3><@s.text name="plugin.reports.admin.monthlyrep.reports.caption"/></h3>
+    <div class="jive-table" style="border: 0pt none;">
+      <table style="border: 1px solid #BBBBBB">
+        <thead>
+          <tr>
+            <th><@s.text name="plugin.reports.admin.monthlyrep.from"/></th>
+            <th><@s.text name="plugin.reports.admin.monthlyrep.to"/></th>
+            <th><@s.text name="plugin.reports.admin.monthlyrep.reports.column.snapshot"/></th>
+            <th><@s.text name="plugin.reports.admin.monthlyrep.reports.column.version"/></th>
+            <th><@s.text name="plugin.reports.admin.monthlyrep.reports.column.status"/></th>
+            <th><@s.text name="plugin.reports.admin.monthlyrep.reports.column.action"/></th>
+          </tr>
+        </thead>
+        <tbody>
+        <#list reports as report>
+        <tr>
+          <td>${report.from}</td>
+          <td>${report.to}</td>
+          <td>${report.redHatUsersSnapshot}</td>
+          <td>${report.configurationId}</td>
+          <td>${report.status}</td>
+          <td>${report.statusMessage}</td>
+        </tr>
+        </#list>
+        </tbody>
+      </table>
+    </div>
+  </body>
+</html>

Modified: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/schema.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/schema.xml	2010-10-21 13:15:33 UTC (rev 35644)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/schema.xml	2010-10-21 13:32:36 UTC (rev 35645)
@@ -5,4 +5,17 @@
     <column name="created" type="bigint" nullable="false" description="Time when snapshot is created" />
     <index type="primary" name="reportsRHUsers_pk" column="userID,created" />
   </table>
+
+  <table name="reportsMonthly" description="Monthly reports agregated across ">
+    <column name="id" type="bigint" nullable="false" description="Primary key" />
+    <column name="fromDate" type="bigint" nullable="false" description="Report from" />
+    <column name="toDate" type="bigint" nullable="false" description="Report to" />
+    <column name="redHatUsersSnapshot" type="bigint" nullable="false" description="Red Hat Users Snapshot" />
+    <!-- TODO: ConfigurationID <column name="configurationId" type="bigint" nullable="false" description="Red Hat Users Snapshot" 
+      /> -->
+    <column name="status" type="int" nullable="false" description="Status of report" />
+    <column name="statusMessage" type="varchar" size="100" nullable="true" description="Status message" />
+    <column name="reportData" type="blob" nullable="true" description="Report data" />
+    <index type="primary" name="reportsMonthly_pk" column="id" />
+  </table>
 </schema>

Modified: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/spring.xml	2010-10-21 13:15:33 UTC (rev 35644)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/spring.xml	2010-10-21 13:32:36 UTC (rev 35645)
@@ -12,4 +12,21 @@
     </property>
   </bean>
 
+  <bean id="reportDAO" class="org.jboss.community.sbs.plugin.reports.dao.DbReportDAOImpl">
+    <property name="dataSource">
+      <util:property-path path="dataSourceFactory.dataSource" />
+    </property>
+  </bean>
+
+  <bean id="monthlyReportManager" class="org.jboss.community.sbs.plugin.reports.monthly.MonthlyReportManagerImpl">
+    <property name="reportDAO" ref="reportDAO" />
+    <property name="reportGenerator" ref="reportGenerator" />
+  </bean>
+
+  <bean id="reportGenerator" class="org.jboss.community.sbs.plugin.reports.monthly.ReportGenerator">
+    <property name="dataSource">
+      <util:property-path path="dataSourceFactory.dataSource" />
+    </property>
+  </bean>
+
 </beans>

Modified: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/struts.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/struts.xml	2010-10-21 13:15:33 UTC (rev 35644)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/plugin/struts.xml	2010-10-21 13:32:36 UTC (rev 35645)
@@ -28,5 +28,25 @@
       </result>
     </action>
 
+
+    <action name="monthly-reports" class="org.jboss.community.sbs.plugin.reports.struts.MonthlyReportsAction"
+      method="input">
+      <result name="input" type="freemarker">
+        /plugins/reports/resources/templates/admin/monthly-reports.ftl
+      </result>
+    </action>
+
+    <action name="create-monthly-report" class="org.jboss.community.sbs.plugin.reports.struts.MonthlyReportsAction"
+      method="execute">
+      <interceptor-ref name="paramsPrepareParamsStack"/>
+
+      <result name="input" type="freemarker">
+        /plugins/reports/resources/templates/admin/monthly-reports.ftl
+      </result>
+      <result name="success" type="freemarker">
+        /plugins/reports/resources/templates/admin/monthly-reports.ftl
+      </result>
+    </action>
+
   </package>
 </struts>

Modified: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/resources/plugin_i18n.properties
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/resources/plugin_i18n.properties	2010-10-21 13:15:33 UTC (rev 35644)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/resources/plugin_i18n.properties	2010-10-21 13:32:36 UTC (rev 35645)
@@ -18,4 +18,20 @@
 plugin.reports.admin.rhusers.snapshot.column.firstname=Firstname
 plugin.reports.admin.rhusers.snapshot.column.lastname=Lastname
 plugin.reports.admin.rhusers.snapshot.dateRequired=Snaphost date is required
-plugin.reports.admin.rhusers.snapshot.userNotFound=User {0} not found in SBS.
\ No newline at end of file
+plugin.reports.admin.rhusers.snapshot.userNotFound=User {0} not found in SBS.
+
+plugin.reports.admin.monthlyrep.name=Monthly Reports
+plugin.reports.admin.monthlyrep.description=View and create Monthly Reports
+plugin.reports.admin.monthlyrep.from=From
+plugin.reports.admin.monthlyrep.to=To
+plugin.reports.admin.monthlyrep.snapshot=Red Hat Users Snapshot
+plugin.reports.admin.monthlyrep.createreport=Create report
+plugin.reports.admin.monthlyrep.error.dateFormat=Date must be in {0} format.
+plugin.reports.admin.monthlyrep.error.required=Field {0} is required.
+plugin.reports.admin.monthlyrep.text.addedToQueue=Monthly report generation started. Please reload this page after a while and check Status column. 
+
+plugin.reports.admin.monthlyrep.reports.caption=Available reports
+plugin.reports.admin.monthlyrep.reports.column.snapshot=Snapshot
+plugin.reports.admin.monthlyrep.reports.column.version=Version
+plugin.reports.admin.monthlyrep.reports.column.status=Status
+plugin.reports.admin.monthlyrep.reports.column.action=Action



More information about the jboss-svn-commits mailing list