|
|
|
@ -1,36 +1,71 @@
|
|
|
|
|
package com.fr.data; |
|
|
|
|
|
|
|
|
|
import javax.xml.namespace.QName; |
|
|
|
|
import com.fr.general.data.TableDataException; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
|
import org.apache.axis.client.Call; |
|
|
|
|
import org.apache.axis.client.Service; |
|
|
|
|
import com.fr.data.AbstractTableData; |
|
|
|
|
import com.fr.general.data.TableDataException; |
|
|
|
|
|
|
|
|
|
public class WebServiceTableData extends AbstractTableData{ |
|
|
|
|
private String[][] data; |
|
|
|
|
import javax.xml.namespace.QName; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
public WebServiceTableData() { |
|
|
|
|
this.data = this.createData(); |
|
|
|
|
} |
|
|
|
|
public class WebServiceTableData extends SimpleTableData { |
|
|
|
|
|
|
|
|
|
//获取列数
|
|
|
|
|
public int getColumnCount() throws TableDataException { |
|
|
|
|
return data[0].length; |
|
|
|
|
/** |
|
|
|
|
* 初始化列名数组 |
|
|
|
|
* |
|
|
|
|
* @return {col1,col2,col3...} |
|
|
|
|
* @throws TableDataException |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String[] initColumnNames() { |
|
|
|
|
String[] columnNames = new String[10]; |
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
|
columnNames[i] = "column#" + i; |
|
|
|
|
} |
|
|
|
|
return columnNames; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取列的名称为数组中第一行的值
|
|
|
|
|
public String getColumnName(int columnIndex) throws TableDataException { |
|
|
|
|
return data[0][columnIndex]; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 加载数据 |
|
|
|
|
* |
|
|
|
|
* @return 行列数据 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<Object[]> loadData() { |
|
|
|
|
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString(); |
|
|
|
|
FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: \n" + tableName); |
|
|
|
|
|
|
|
|
|
//获取行数为数据的长度-1
|
|
|
|
|
public int getRowCount() throws TableDataException { |
|
|
|
|
return data.length - 1; |
|
|
|
|
} |
|
|
|
|
// 保存得到的结果集
|
|
|
|
|
ArrayList<Object[]> valueList = new ArrayList(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// 调用 Web 服务获取数据
|
|
|
|
|
String[][] data = createData(); |
|
|
|
|
|
|
|
|
|
// 如果数据为空,直接返回空列表
|
|
|
|
|
if (data == null || data.length == 0) { |
|
|
|
|
return valueList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取值
|
|
|
|
|
public Object getValueAt(int rowIndex, int columnIndex) { |
|
|
|
|
return data[rowIndex + 1][columnIndex]; |
|
|
|
|
// 获得总列数
|
|
|
|
|
int colNum = data[0].length; |
|
|
|
|
|
|
|
|
|
// 用对象保存数据
|
|
|
|
|
Object[] objArray = null; |
|
|
|
|
for (int rowIndex = 1; rowIndex < data.length; rowIndex++) { |
|
|
|
|
objArray = new Object[colNum]; |
|
|
|
|
for (int i = 0; i < colNum; i++) { |
|
|
|
|
objArray[i] = data[rowIndex][i]; |
|
|
|
|
} |
|
|
|
|
// 在valueList中加入这一行数据
|
|
|
|
|
valueList.add(objArray); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return valueList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String[][] createData() { |
|
|
|
|