-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportFactory.java
More file actions
39 lines (36 loc) · 1.5 KB
/
ReportFactory.java
File metadata and controls
39 lines (36 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Reports;
import Reports.AbstratReports.Report;
import Utilz.BaseConstants;
import Utilz.SqlExecutor;
import Utilz.SqlProperties;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
public class ReportFactory {
public static Report create(SqlProperties prop, SqlExecutor sqlExecutor) {
Report report = null;
if (prop.getProperty("excel") != null) {
try {
Constructor c = Class.forName("Reports." + prop.getProperty("description").trim()).getConstructor(SqlProperties.class, SqlExecutor.class);
report = (Report) c.newInstance(prop, sqlExecutor);
report.addProperty("path", prop.getProperty("excel"));
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
System.out.println("Класс не существует");
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} else {
report = new RegularMonitor(prop, sqlExecutor);
report.addProperty("path", BaseConstants.getPath());
}
;
//report.setIntervalDate(prop.getProperty("date1"), prop.getProperty("date2"));
return report;
}
}