21 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
/*
|
|
|
15 |
* Créé le 10 oct. 2011
|
|
|
16 |
*/
|
|
|
17 |
package org.openconcerto.erp.generationDoc.element;
|
|
|
18 |
|
|
|
19 |
import org.openconcerto.sql.Configuration;
|
|
|
20 |
import org.openconcerto.sql.element.ConfSQLElement;
|
|
|
21 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
22 |
import org.openconcerto.sql.element.UISQLComponent;
|
132 |
ilm |
23 |
import org.openconcerto.sql.model.DBRoot;
|
21 |
ilm |
24 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
|
|
26 |
import org.openconcerto.sql.model.SQLSelect;
|
132 |
ilm |
27 |
import org.openconcerto.utils.ListMap;
|
21 |
ilm |
28 |
|
|
|
29 |
import java.util.ArrayList;
|
|
|
30 |
import java.util.HashMap;
|
|
|
31 |
import java.util.HashSet;
|
|
|
32 |
import java.util.List;
|
|
|
33 |
import java.util.Map;
|
|
|
34 |
import java.util.Set;
|
|
|
35 |
|
|
|
36 |
public class TypeModeleSQLElement extends ConfSQLElement {
|
|
|
37 |
|
132 |
ilm |
38 |
public TypeModeleSQLElement(DBRoot root) {
|
|
|
39 |
super(root.getTable("TYPE_MODELE"), "un type_modele ", "type_modeles");
|
|
|
40 |
}
|
|
|
41 |
|
21 |
ilm |
42 |
public TypeModeleSQLElement() {
|
132 |
ilm |
43 |
this(Configuration.getInstance().getRoot());
|
21 |
ilm |
44 |
}
|
|
|
45 |
|
|
|
46 |
protected List<String> getListFields() {
|
|
|
47 |
final List<String> l = new ArrayList<String>();
|
|
|
48 |
l.add("NOM");
|
|
|
49 |
l.add("TABLE");
|
|
|
50 |
return l;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
protected List<String> getComboFields() {
|
|
|
54 |
final List<String> l = new ArrayList<String>();
|
|
|
55 |
l.add("NOM");
|
|
|
56 |
return l;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
@Override
|
132 |
ilm |
60 |
public ListMap<String, String> getShowAs() {
|
|
|
61 |
ListMap<String, String> map = new ListMap<String, String>();
|
|
|
62 |
map.putCollection(null, "NOM");
|
21 |
ilm |
63 |
return map;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
public SQLComponent createComponent() {
|
|
|
67 |
return new UISQLComponent(this) {
|
|
|
68 |
|
|
|
69 |
@Override
|
|
|
70 |
protected Set<String> createRequiredNames() {
|
|
|
71 |
final Set<String> s = new HashSet<String>();
|
|
|
72 |
// s.add("NOM");
|
|
|
73 |
// s.add("TABLE");
|
|
|
74 |
return s;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public void addViews() {
|
|
|
78 |
this.addView("NOM");
|
|
|
79 |
this.addView("TABLE");
|
|
|
80 |
}
|
|
|
81 |
};
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public String getDescription(SQLRow fromRow) {
|
|
|
85 |
return fromRow.getString("NOM");
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
Map<String, String> template;
|
|
|
89 |
|
|
|
90 |
public Map<String, String> getTemplateMapping() {
|
|
|
91 |
|
|
|
92 |
if (this.template == null) {
|
|
|
93 |
this.template = new HashMap<String, String>();
|
|
|
94 |
SQLSelect sel = new SQLSelect(getTable().getBase());
|
|
|
95 |
sel.addSelectStar(getTable());
|
|
|
96 |
List<SQLRow> rows = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
|
|
|
97 |
for (SQLRow sqlRow : rows) {
|
|
|
98 |
template.put(sqlRow.getString("TABLE"), sqlRow.getString("DEFAULT_MODELE"));
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
return template;
|
|
|
104 |
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
}
|