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;
|
}
|
|
}
|