1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.model.core.impl;
17
18 import java.util.Collection;
19 import java.util.LinkedHashMap;
20 import java.util.Map;
21
22 import org.seasar.tuigwaa.database.DataRow;
23 import org.seasar.tuigwaa.database.DataTable;
24 import org.seasar.tuigwaa.model.common.DataServiceUtils;
25 import org.seasar.tuigwaa.system.Constants;
26
27 public abstract class AbstractLinkAttribute extends AbstractAttribute implements
28 LinkAttribute {
29
30 private String refEntityFilter;
31
32 public void setRefEntityFilter(String refEntityFilter) {
33 this.refEntityFilter = refEntityFilter;
34 }
35
36 public String getRefEntityFilter() {
37 return refEntityFilter;
38 }
39
40 public DataTable getDataTable() {
41 return DataServiceUtils.getDataTable(getRefEntity(), refEntityFilter);
42 }
43
44 public Collection getDataList() {
45 return getDataTable().getDataList();
46 }
47
48 /***
49 * 指定したモデル(テーブル)にある、各データの代表カラムの表示名と ID(主キー)の値を返す
50 */
51 public Map getLabelValueMap() {
52 DataTable table = getDataTable();
53 Map map = new LinkedHashMap();
54 while (table.hasNext()) {
55 DataRow row = (DataRow) table.next();
56
57 String repre = getRefEntity().getRepresentativeField();
58 if (repre == null) {
59 repre = getRefEntity().getFirstField().getName();
60 }
61 String label = "" + row.getCell(repre);
62 Long id = (Long) row.getCell(Constants.ENTITY_BUILTIN_ID);
63 String value = String.valueOf(id);
64 map.put(label, value);
65 }
66 return map;
67 }
68
69
70 }