use of com.serotonin.m2m2.reports.vo.ReportVO in project ma-modules-public by infiniteautomation.
the class ReportsDwr method runReport.
@DwrPermission(custom = ReportPermissionDefinition.PERMISSION)
public ProcessResult runReport(String xid, String name, List<ReportPointVO> points, String template, int includeEvents, boolean includeUserComments, int dateRangeType, int relativeDateType, int previousPeriodCount, int previousPeriodType, int pastPeriodCount, int pastPeriodType, boolean fromNone, int fromYear, int fromMonth, int fromDay, int fromHour, int fromMinute, boolean toNone, int toYear, int toMonth, int toDay, int toHour, int toMinute, boolean email, boolean includeData, boolean zipData, List<RecipientListEntryBean> recipients) {
ProcessResult response = new ProcessResult();
// Basic validation
// TODO Replace with vo.validate()
validateData(response, name, points, dateRangeType, relativeDateType, previousPeriodCount, pastPeriodCount);
if (!response.getHasMessages()) {
ReportVO report = new ReportVO();
report.setXid(xid);
report.setName(name);
report.setUserId(Common.getUser().getId());
report.setPoints(points);
report.setTemplate(template);
report.setIncludeEvents(includeEvents);
report.setIncludeUserComments(includeUserComments);
report.setDateRangeType(dateRangeType);
report.setRelativeDateType(relativeDateType);
report.setPreviousPeriodCount(previousPeriodCount);
report.setPreviousPeriodType(previousPeriodType);
report.setPastPeriodCount(pastPeriodCount);
report.setPastPeriodType(pastPeriodType);
report.setFromNone(fromNone);
report.setFromYear(fromYear);
report.setFromMonth(fromMonth);
report.setFromDay(fromDay);
report.setFromHour(fromHour);
report.setFromMinute(fromMinute);
report.setToNone(toNone);
report.setToYear(toYear);
report.setToMonth(toMonth);
report.setToDay(toDay);
report.setToHour(toHour);
report.setToMinute(toMinute);
// Never allow schedule when running from UI
report.setSchedule(false);
report.setEmail(email);
report.setIncludeData(includeData);
report.setZipData(zipData);
report.setRecipients(recipients);
String host = "";
WebContext webContext = WebContextFactory.get();
int port;
if (webContext != null) {
HttpServletRequest req = webContext.getHttpServletRequest();
host = req.getServerName();
port = req.getLocalPort();
} else {
port = Common.envProps.getInt("web.port", 8080);
}
ReportWorkItem.queueReport(host, port, report);
}
return response;
}
use of com.serotonin.m2m2.reports.vo.ReportVO in project ma-modules-public by infiniteautomation.
the class ReportLaunchServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
User user = Common.getUser(request);
if (user != null) {
ReportDao dao = ReportDao.instance;
ReportVO report = null;
int id = getIntRequestParameter(request, "reportId", -1);
if (id != -1)
report = dao.getReport(id);
String xid = request.getParameter("reportXid");
if (xid != null)
report = dao.getReport(xid);
if (report != null && (user.getId() == report.getUserId() || Permissions.hasAdmin(user))) {
ReportJob.scheduleReportJob(request.getServerName(), request.getLocalPort(), report);
try {
response.getWriter().write("Report " + report.getName() + " scheduled");
} catch (Exception e) {
response.setStatus(500);
}
}
}
}
use of com.serotonin.m2m2.reports.vo.ReportVO in project ma-modules-public by infiniteautomation.
the class Upgrade2 method upgrade.
@Override
protected void upgrade() throws Exception {
runScript(new String[] { "alter table reportInstances add template varchar(40);", "alter table reportInstances add reportId int;", "update reportInstances set reportId=-1;", "alter table reportInstances add mapping blob;", "alter table reportInstancePoints add xid varchar(50);", "update reportInstancePoints set xid='legacyReport';" });
ReportDao dao = ReportDao.instance;
UserDao ud = UserDao.instance;
List<ReportVO> reports = dao.getReports();
List<ReportInstance> reportInstances;
List<User> users = ud.getUsers();
for (User u : users) {
reportInstances = dao.getReportInstances(u.getId());
for (ReportInstance ri : reportInstances) {
for (ReportVO report : reports) {
if (ri.getName().equals(report.getName())) {
ri.setReportId(report.getId());
dao.saveReportInstance(ri);
break;
}
}
}
}
// Alter the column back to have no default
Map<String, String[]> scripts = new HashMap<String, String[]>();
scripts.put(DatabaseProxy.DatabaseType.DERBY.name(), new String[] { "alter table reportInstances alter column reportId NOT NULL; ", "alter table reportInstancePoints alter column xid NOT NULL;" });
scripts.put(DatabaseProxy.DatabaseType.MYSQL.name(), new String[] { "ALTER TABLE reportInstances CHANGE COLUMN `reportId` `reportId` int NOT NULL;", "ALTER TABLE reportInstancePoints CHANGE COLUMN `xid` `xid` VARCHAR(50) NOT NULL;" });
scripts.put(DatabaseProxy.DatabaseType.MSSQL.name(), new String[] { "alter table reportInstances alter column reportId int NOT NULL;", "alter table reportInstancePoints alter column xid varchar(50) NOT NULL;" });
scripts.put(DatabaseProxy.DatabaseType.H2.name(), new String[] { "alter table reportInstances alter column reportId int NOT NULL;", "alter table reportInstancePoints alter column xid varchar(50) NOT NULL;" });
runScript(scripts);
}
Aggregations