1 |
package org.openconcerto.modules.customersupport;
|
1 |
package org.openconcerto.modules.customersupport;
|
2 |
|
2 |
|
3 |
import java.io.File;
|
3 |
import java.io.File;
|
4 |
import java.io.IOException;
|
4 |
import java.io.IOException;
|
5 |
import java.sql.Date;
|
5 |
import java.sql.Date;
|
6 |
import java.sql.SQLException;
|
6 |
import java.sql.SQLException;
|
7 |
import java.util.Arrays;
|
7 |
import java.util.Arrays;
|
8 |
import java.util.Calendar;
|
8 |
import java.util.Calendar;
|
9 |
import java.util.List;
|
9 |
import java.util.List;
|
10 |
import java.util.Set;
|
10 |
import java.util.Set;
|
11 |
|
11 |
|
12 |
import org.openconcerto.erp.config.Gestion;
|
12 |
import org.openconcerto.erp.config.Gestion;
|
13 |
import org.openconcerto.erp.config.MainFrame;
|
13 |
import org.openconcerto.erp.config.MainFrame;
|
14 |
import org.openconcerto.erp.modules.AbstractModule;
|
14 |
import org.openconcerto.erp.modules.AbstractModule;
|
15 |
import org.openconcerto.erp.modules.ComponentsContext;
|
15 |
import org.openconcerto.erp.modules.ComponentsContext;
|
16 |
import org.openconcerto.erp.modules.DBContext;
|
16 |
import org.openconcerto.erp.modules.DBContext;
|
17 |
import org.openconcerto.erp.modules.MenuContext;
|
17 |
import org.openconcerto.erp.modules.MenuContext;
|
18 |
import org.openconcerto.erp.modules.ModuleFactory;
|
18 |
import org.openconcerto.erp.modules.ModuleFactory;
|
19 |
import org.openconcerto.erp.modules.ModuleManager;
|
19 |
import org.openconcerto.erp.modules.ModuleManager;
|
20 |
import org.openconcerto.erp.modules.ModulePackager;
|
20 |
import org.openconcerto.erp.modules.ModulePackager;
|
21 |
import org.openconcerto.erp.modules.RuntimeModuleFactory;
|
21 |
import org.openconcerto.erp.modules.RuntimeModuleFactory;
|
22 |
import org.openconcerto.sql.Configuration;
|
22 |
import org.openconcerto.sql.Configuration;
|
23 |
import org.openconcerto.sql.element.GlobalMapper;
|
23 |
import org.openconcerto.sql.element.GlobalMapper;
|
24 |
import org.openconcerto.sql.element.SQLElement;
|
24 |
import org.openconcerto.sql.element.SQLElement;
|
25 |
import org.openconcerto.sql.element.SQLElementDirectory;
|
25 |
import org.openconcerto.sql.element.SQLElementDirectory;
|
26 |
import org.openconcerto.sql.model.FieldPath;
|
26 |
import org.openconcerto.sql.model.FieldPath;
|
27 |
import org.openconcerto.sql.model.SQLRequestLog;
|
27 |
import org.openconcerto.sql.model.SQLRequestLog;
|
28 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
28 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
29 |
import org.openconcerto.sql.model.SQLRowValues;
|
29 |
import org.openconcerto.sql.model.SQLRowValues;
|
30 |
import org.openconcerto.sql.model.Where;
|
30 |
import org.openconcerto.sql.model.Where;
|
31 |
import org.openconcerto.sql.model.graph.Path;
|
31 |
import org.openconcerto.sql.model.graph.Path;
|
32 |
import org.openconcerto.sql.ui.ConnexionPanel;
|
32 |
import org.openconcerto.sql.ui.ConnexionPanel;
|
33 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
33 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
34 |
import org.openconcerto.sql.view.ListeAddPanel;
|
34 |
import org.openconcerto.sql.view.ListeAddPanel;
|
35 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
35 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
36 |
import org.openconcerto.sql.view.list.IListe;
|
36 |
import org.openconcerto.sql.view.list.IListe;
|
37 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
37 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
38 |
import org.openconcerto.utils.CollectionUtils;
|
38 |
import org.openconcerto.utils.CollectionUtils;
|
39 |
|
39 |
|
40 |
public final class Module extends AbstractModule {
|
40 |
public final class Module extends AbstractModule {
|
41 |
|
41 |
|
42 |
public static final String TABLE_CUSTOMER_SUPPORT_TICKET = "CUSTOMER_SUPPORT_TICKET";
|
42 |
public static final String TABLE_CUSTOMER_SUPPORT_TICKET = "CUSTOMER_SUPPORT_TICKET";
|
43 |
public static final String TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY = "CUSTOMER_SUPPORT_TICKET_HISTORY";
|
43 |
public static final String TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY = "CUSTOMER_SUPPORT_TICKET_HISTORY";
|
44 |
|
44 |
|
45 |
public Module(ModuleFactory f) throws IOException {
|
45 |
public Module(ModuleFactory f) throws IOException {
|
46 |
super(f);
|
46 |
super(f);
|
47 |
}
|
47 |
}
|
48 |
|
48 |
|
49 |
@Override
|
49 |
@Override
|
50 |
protected void install(DBContext ctxt) throws SQLException, IOException {
|
50 |
protected void install(DBContext ctxt) throws SQLException, IOException {
|
51 |
super.install(ctxt);
|
51 |
super.install(ctxt);
|
52 |
// TODO use version to upgrade
|
52 |
// TODO use version to upgrade
|
53 |
if (ctxt.getRoot().getTable(TABLE_CUSTOMER_SUPPORT_TICKET) == null) {
|
53 |
if (ctxt.getRoot().getTable(TABLE_CUSTOMER_SUPPORT_TICKET) == null) {
|
54 |
final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_CUSTOMER_SUPPORT_TICKET);
|
54 |
final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_CUSTOMER_SUPPORT_TICKET);
|
55 |
|
55 |
|
56 |
createTable.addIntegerColumn("NUMBER", 0);
|
56 |
createTable.addIntegerColumn("NUMBER", 0);
|
57 |
createTable.addVarCharColumn("LABEL", 256);
|
57 |
createTable.addVarCharColumn("LABEL", 256);
|
58 |
//
|
58 |
//
|
59 |
createTable.addForeignColumn("CLIENT");
|
59 |
createTable.addForeignColumn("CLIENT");
|
60 |
createTable.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
|
60 |
createTable.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
|
61 |
//
|
61 |
//
|
62 |
createTable.addVarCharColumn("INFOS", 4096);
|
62 |
createTable.addVarCharColumn("INFOS", 4096);
|
63 |
//
|
63 |
//
|
64 |
createTable.addVarCharColumn("RATING", 200);
|
64 |
createTable.addVarCharColumn("RATING", 200);
|
65 |
createTable.addVarCharColumn("TYPE", 128);
|
65 |
createTable.addVarCharColumn("TYPE", 128);
|
66 |
createTable.addVarCharColumn("STATUS", 128);
|
66 |
createTable.addVarCharColumn("STATUS", 128);
|
67 |
createTable.addDateAndTimeColumn("REMIND_DATE");
|
67 |
createTable.addDateAndTimeColumn("REMIND_DATE");
|
68 |
createTable.addDateAndTimeColumn("DATE");
|
68 |
createTable.addDateAndTimeColumn("DATE");
|
69 |
createTable.addBooleanColumn("CLOSED_AND_ARCHIVED", Boolean.FALSE, false);
|
69 |
createTable.addBooleanColumn("CLOSED_AND_ARCHIVED", Boolean.FALSE, false);
|
70 |
|
70 |
|
71 |
// Suivi
|
71 |
// Suivi
|
72 |
final SQLCreateTable createHistory = ctxt.getCreateTable(TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
|
72 |
final SQLCreateTable createHistory = ctxt.getCreateTable(TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
|
73 |
createHistory.addDateAndTimeColumn("DATE");
|
73 |
createHistory.addDateAndTimeColumn("DATE");
|
74 |
createHistory.addForeignColumn(createTable);
|
74 |
createHistory.addForeignColumn(createTable);
|
75 |
createHistory.addVarCharColumn("INFORMATION", 10240);
|
75 |
createHistory.addVarCharColumn("INFORMATION", 10240);
|
76 |
createHistory.addIntegerColumn("ATTACHMENTS", 0);
|
76 |
createHistory.addIntegerColumn("ATTACHMENTS", 0);
|
77 |
createHistory.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
|
77 |
createHistory.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
|
78 |
|
78 |
|
79 |
// STATUT
|
79 |
// STATUT
|
80 |
// NOUVEAU, OUVERT, FERME, REJETE, EN COURS
|
80 |
// NOUVEAU, OUVERT, FERME, REJETE, EN COURS
|
81 |
try {
|
81 |
try {
|
82 |
List<String> status = Arrays.asList("En cours", "Fermé", "Nouveau", "Ouvert", "Rejeté");
|
82 |
List<String> status = Arrays.asList("En cours", "Fermé", "Nouveau", "Ouvert", "Rejeté");
|
83 |
for (String s : status) {
|
83 |
for (String s : status) {
|
84 |
|
84 |
|
85 |
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("COMPLETION"));
|
85 |
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("COMPLETION"));
|
86 |
rowVals.put("CHAMP", TABLE_CUSTOMER_SUPPORT_TICKET + ".STATUS");
|
86 |
rowVals.put("CHAMP", TABLE_CUSTOMER_SUPPORT_TICKET + ".STATUS");
|
87 |
rowVals.put("LABEL", s);
|
87 |
rowVals.put("LABEL", s);
|
88 |
rowVals.insert(true, false);
|
88 |
rowVals.insert(true, false);
|
89 |
}
|
89 |
}
|
90 |
|
90 |
|
91 |
List<String> prio = Arrays.asList("Basse", "Normale", "Haute");
|
91 |
List<String> prio = Arrays.asList("Basse", "Normale", "Haute");
|
92 |
for (String p : prio) {
|
92 |
for (String p : prio) {
|
93 |
|
93 |
|
94 |
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("COMPLETION"));
|
94 |
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("COMPLETION"));
|
95 |
rowVals.put("CHAMP", TABLE_CUSTOMER_SUPPORT_TICKET + ".RATING");
|
95 |
rowVals.put("CHAMP", TABLE_CUSTOMER_SUPPORT_TICKET + ".RATING");
|
96 |
rowVals.put("LABEL", p);
|
96 |
rowVals.put("LABEL", p);
|
97 |
rowVals.insert(true, false);
|
97 |
rowVals.insert(true, false);
|
98 |
}
|
98 |
}
|
99 |
|
99 |
|
100 |
} catch (SQLException e) {
|
100 |
} catch (SQLException e) {
|
101 |
throw new IllegalStateException("erreur lors de l'ajout des status", e);
|
101 |
throw new IllegalStateException("erreur lors de l'ajout des status", e);
|
102 |
}
|
102 |
}
|
103 |
}
|
103 |
}
|
104 |
}
|
104 |
}
|
105 |
|
105 |
|
106 |
@Override
|
106 |
@Override
|
107 |
protected void setupElements(final SQLElementDirectory dir) {
|
107 |
protected void setupElements(final SQLElementDirectory dir) {
|
108 |
super.setupElements(dir);
|
108 |
super.setupElements(dir);
|
109 |
final CustomerSupportTicketSQLElement element = new CustomerSupportTicketSQLElement(this);
|
109 |
final CustomerSupportTicketSQLElement element = new CustomerSupportTicketSQLElement(this);
|
110 |
GlobalMapper.getInstance().map(element.getCode() + ".default", new CustomerSupportTicketGroup());
|
110 |
GlobalMapper.getInstance().map(element.getCode() + ".default", new CustomerSupportTicketGroup());
|
111 |
dir.addSQLElement(element);
|
111 |
dir.addSQLElement(element);
|
112 |
dir.addSQLElement(new CustomerTicketHistorySQLElement(this));
|
112 |
dir.addSQLElement(new CustomerTicketHistorySQLElement(this));
|
113 |
}
|
113 |
}
|
114 |
|
114 |
|
115 |
@Override
|
115 |
@Override
|
116 |
protected void setupComponents(ComponentsContext ctxt) {
|
116 |
protected void setupComponents(ComponentsContext ctxt) {
|
117 |
// nothing
|
117 |
// nothing
|
118 |
}
|
118 |
}
|
119 |
|
119 |
|
120 |
@Override
|
120 |
@Override
|
121 |
protected void setupMenu(final MenuContext ctxt) {
|
121 |
protected void setupMenu(final MenuContext ctxt) {
|
122 |
ctxt.addMenuItem(new CustomerSupportTicketListAction(), MainFrame.LIST_MENU);
|
122 |
ctxt.addMenuItem(new CustomerSupportTicketListAction(), MainFrame.LIST_MENU);
|
123 |
ctxt.addMenuItem(new CustomerSupportTicketHistoryListAction(), MainFrame.LIST_MENU);
|
123 |
ctxt.addMenuItem(new CustomerSupportTicketHistoryListAction(), MainFrame.LIST_MENU);
|
124 |
}
|
124 |
}
|
125 |
|
125 |
|
126 |
@Override
|
126 |
@Override
|
127 |
protected void start() {
|
127 |
protected void start() {
|
128 |
|
128 |
|
129 |
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET);
|
129 |
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET);
|
130 |
// Filter
|
130 |
// Filter
|
131 |
final SQLTableModelSourceOnline source = elt.getTableSource(true);
|
131 |
final SQLTableModelSourceOnline source = elt.getTableSource(true);
|
132 |
source.getColumns().remove(source.getColumn(elt.getTable().getField("CLOSED_AND_ARCHIVED")));
|
132 |
source.getColumns().remove(source.getColumn(elt.getTable().getField("CLOSED_AND_ARCHIVED")));
|
133 |
Where wAttente = new Where(elt.getTable().getField("CLOSED_AND_ARCHIVED"), "=", Boolean.FALSE);
|
133 |
Where wAttente = new Where(elt.getTable().getField("CLOSED_AND_ARCHIVED"), "=", Boolean.FALSE);
|
134 |
source.getReq().setWhere(wAttente);
|
134 |
source.getReq().setWhere(wAttente);
|
135 |
|
135 |
|
136 |
// Filter
|
136 |
// Filter
|
137 |
BaseSQLTableModelColumn dateRemind = new BaseSQLTableModelColumn("Date de rappel", Date.class) {
|
137 |
BaseSQLTableModelColumn dateRemind = new BaseSQLTableModelColumn("Date de rappel", Date.class) {
|
138 |
|
138 |
|
139 |
@Override
|
139 |
@Override
|
140 |
protected Object show_(SQLRowAccessor r) {
|
140 |
protected Object show_(SQLRowAccessor r) {
|
141 |
|
141 |
|
142 |
Calendar c = r.getDate("REMIND_DATE");
|
142 |
Calendar c = r.getDate("REMIND_DATE");
|
143 |
if (c == null) {
|
143 |
if (c == null) {
|
144 |
return null;
|
144 |
return null;
|
145 |
} else {
|
145 |
} else {
|
146 |
return new Date(c.getTime().getTime());
|
146 |
return new Date(c.getTime().getTime());
|
147 |
}
|
147 |
}
|
148 |
|
148 |
|
149 |
}
|
149 |
}
|
150 |
|
150 |
|
151 |
@Override
|
151 |
@Override
|
152 |
public Set<FieldPath> getPaths() {
|
152 |
public Set<FieldPath> getPaths() {
|
153 |
Path p = new Path(elt.getTable());
|
153 |
Path p = new Path(elt.getTable());
|
154 |
return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
|
154 |
return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
|
155 |
}
|
155 |
}
|
156 |
};
|
156 |
};
|
157 |
|
157 |
|
158 |
dateRemind.setRenderer(new RemindDateRenderer());
|
158 |
dateRemind.setRenderer(new RemindDateRenderer());
|
159 |
source.getColumns().add(dateRemind);
|
159 |
source.getColumns().add(dateRemind);
|
160 |
|
160 |
|
161 |
final ListeAddPanel pane = new ListeAddPanel(elt, new IListe(source), "Open");
|
161 |
final ListeAddPanel pane = new ListeAddPanel(elt, new IListe(source), "Open");
|
162 |
pane.getListe().setOpaque(false);
|
162 |
pane.getListe().setOpaque(false);
|
163 |
pane.setOpaque(false);
|
163 |
pane.setOpaque(false);
|
164 |
MainFrame.getInstance().getTabbedPane().addTab("Ticket support ouvert", pane);
|
164 |
MainFrame.getInstance().getTabbedPane().addTab("Ticket support ouvert", pane);
|
165 |
|
165 |
|
166 |
}
|
166 |
}
|
167 |
|
167 |
|
168 |
@Override
|
168 |
@Override
|
169 |
protected void stop() {
|
169 |
protected void stop() {
|
170 |
// nothing to stop
|
170 |
// nothing to stop
|
171 |
}
|
171 |
}
|
172 |
|
172 |
|
173 |
public static void main(String[] args) throws IOException {
|
- |
|
174 |
System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
|
- |
|
175 |
final File propsFile = new File("module.properties");
|
- |
|
176 |
System.out.println(propsFile.getAbsolutePath());
|
- |
|
177 |
final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
|
- |
|
178 |
SQLRequestLog.setEnabled(true);
|
- |
|
179 |
SQLRequestLog.showFrame();
|
- |
|
180 |
// uncomment to create and use the jar
|
- |
|
181 |
final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
|
- |
|
182 |
modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
|
- |
|
183 |
ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
|
- |
|
184 |
ModuleManager.getInstance().addFactoryAndStart(factory, false);
|
- |
|
185 |
Gestion.main(args);
|
- |
|
186 |
}
|
- |
|
187 |
|
- |
|
188 |
}
|
173 |
}
|