wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package com.vci.client.uif.engine.client;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.vci.client.common.oq.OQTool;
import com.vci.client.oq.QTClient;
import com.vci.client.portal.utility.DataGridModel;
import com.vci.client.portal.utility.DataModelFactory;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.common.qt.object.Condition;
import com.vci.common.qt.object.QueryTemplate;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.omd.constants.FileObjectType;
 
public class FileTableDataProvider extends AbstractVCIJTableDataProvider<Map<String,String>> {
    /**
     * 查询关联文档oid
     */
    private String oid;
    /**
     * 
     */
    private IRegionPanel regionPanel = null;
    /**
     * 
     */
    private DataModelFactory factory = null;
    /**
     * 
     */
    private String type = "";
    /**
     * 
     */
    private String context = "";
    /**
     * 表格的列
     */
    private String[] headerColumns = new String[0];
    /**
     * 
     */
    private PLDefination defination;
    /**
     * 
     */
    private boolean showDetail = false;
    /***
     * 
     */
    private DataGridModel dataGridModel = null;
    
    /**
     * 
     * @param regionPanel
     * @param factory
     * @param type
     * @param context
     * @param defination
     * @param oid
     * @param showDetail
     */
    public FileTableDataProvider(IRegionPanel regionPanel, DataModelFactory factory, 
            String type, String context, PLDefination defination, String oid, boolean showDetail){
        this.regionPanel = regionPanel;
        this.factory = factory;
        this.type = type;
        this.context = context;
        this.defination = defination;
        this.oid = oid;
        this.showDetail = showDetail;
        
        //loadHeaderColumns();
        
    }
    
    @Override
    public String[] getSpecialColumns() {
        headerColumns = new String[2];
        //headerColumns[0] = "序号";
        headerColumns[0] = "名称";
        //headerColumns[2] = "版本";
        headerColumns[1] = "描述";
        return headerColumns;
    }
 
    @Override
    public int getTotal() {
        //文件总数在getData中查询设置
        return total;
    }
 
    @Override
    public VCIJTableNode<Map<String, String>> getNewRowNode(
            Map<String, String> paramT) {
        VCIJTableNode<Map<String, String>> tableNode = new VCIJTableNode<Map<String, String>>(paramT);
        HashMap<String, String> map = (HashMap<String, String>)paramT;
        for(String column : headerColumns){
            tableNode.setPropertyValue(column, map.get(column));
        }
        return tableNode;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public Map<String, String>[] getDatas(int pageIndex, int pageSize) {
        Map<String, String> dataMap[] = null;
        BusinessObject[] bos;
        try {
            bos = getDocumentFileData(oid);
            if(bos != null){
                total = bos.length;
            } else {
                total = 0;
                return new HashMap[0];
            }
            //得到当前页显示的条目数、起始位置和结束位置
            int firstItem = (pageIndex - 1) * pageSize + 1;
            int lastItem = (pageIndex) * pageSize;
            if(total <= lastItem){
                dataMap = new HashMap[total - firstItem + 1];
                for(int i = firstItem - 1; i < total; i++){
                    BusinessObject bo = bos[i];
                    HashMap<String, String> temp = new HashMap<String, String>();
                    temp.put("OID", bo.oid);
                    temp.put("序号", String.valueOf(i + 1));
                    temp.put("名称", bo.name);
                    temp.put("版本", bo.lcStatus);
                    temp.put("描述", bo.description);
                    temp.put("BTMNAME", bo.btName);
                    temp.put("TS", String.valueOf(bo.ts));
                    dataMap[i] = temp;
                }
            } else {
                dataMap = new HashMap[pageSize];
                for(int i = firstItem - 1; i < lastItem; i++){
                    BusinessObject bo = bos[i];
                    HashMap<String, String> temp = new HashMap<String, String>();
                    temp.put("OID", bo.oid);
                    temp.put("序号", String.valueOf(i + 1));
                    temp.put("名称", bo.name);
                    temp.put("版本", bo.lcStatus);
                    temp.put("描述", bo.description);
                    temp.put("BTMNAME", bo.btName);
                    temp.put("TS", String.valueOf(bo.ts));
                    dataMap[i] = temp;
                }
            }
            return dataMap;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new HashMap[0];
    }
    
    /**
     * 根据ID下载文件对象信息
     * @param docOid documentOID
     * @return
     * @throws VCIError
     * @throws VciException
     */
    public BusinessObject[] getDocumentFileData(String docOid) throws VCIError {
        Map<String, String> conditions = new HashMap<String, String>();
        conditions.put("documentoid", docOid);
        QueryTemplate qt2 = new QueryTemplate();
        qt2.setId("btmQuery");
        qt2.setBtmType(FileObjectType.FILE_DATA_TABLE);
        qt2.setType("btm");
        List<String> clauseList = new ArrayList<String>();
        clauseList.add("*");
        qt2.setClauseList(clauseList);
        
        Condition cond = OQTool.getCondition(conditions);
        qt2.setCondition(cond);
    
        BusinessObject[] bos = QTClient.getService().findBTMObjects(qt2.getId(),  OQTool.qtTOXMl(qt2).asXML());
        return bos;
    }
 
}