forked from p81075629/datagear
DataSetQuery.resultDataCount重构为resultFetchSize;DataSet的isReady、getResult允许DataSetQuery参数为null
This commit is contained in:
parent
6845a9d026
commit
7f8a948c1f
|
@ -35,7 +35,7 @@ public class ChartDataSet
|
|||
private boolean attachment = false;
|
||||
|
||||
/**数据集查询*/
|
||||
private DataSetQuery query = new DataSetQuery();
|
||||
private DataSetQuery query = null;
|
||||
|
||||
public ChartDataSet()
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ public interface DataSet extends Identifiable
|
|||
* 通常是:{@linkplain DataSetQuery#getParamValues()}包含{@linkplain #getParams()}中的所有{@linkplain DataSetParam#isRequired()}参数值。
|
||||
* </p>
|
||||
*
|
||||
* @param query
|
||||
* @param query 允许为{@code null}
|
||||
* @return
|
||||
*/
|
||||
boolean isReady(DataSetQuery query);
|
||||
|
@ -81,7 +81,7 @@ public interface DataSet extends Identifiable
|
|||
* 返回结果中的数据项应已转换为与{@linkplain #getProperties()}的{@linkplain DataSetProperty#getType()}类型一致。
|
||||
* </p>
|
||||
*
|
||||
* @param query 应是已通过{@linkplain #isReady(DataSetQuery)}校验的
|
||||
* @param query 应是已通过{@linkplain #isReady(DataSetQuery)}校验的(可能为{@code null})
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@ public class DataSetQuery
|
|||
private ResultDataFormat resultDataFormat = null;
|
||||
|
||||
/** 结果数据最大返回数目 */
|
||||
private int resultDataCount = -1;
|
||||
private int resultFetchSize = -1;
|
||||
|
||||
public DataSetQuery()
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ public class DataSetQuery
|
|||
super();
|
||||
this.paramValues = query.paramValues;
|
||||
this.resultDataFormat = query.resultDataFormat;
|
||||
this.resultDataCount = query.resultDataCount;
|
||||
this.resultFetchSize = query.resultFetchSize;
|
||||
}
|
||||
|
||||
public Map<String, ?> getParamValues()
|
||||
|
@ -90,14 +90,14 @@ public class DataSetQuery
|
|||
*
|
||||
* @return {@code <0} 表示不限定数目
|
||||
*/
|
||||
public int getResultDataCount()
|
||||
public int getResultFetchSize()
|
||||
{
|
||||
return resultDataCount;
|
||||
return resultFetchSize;
|
||||
}
|
||||
|
||||
public void setResultDataCount(int resultDataCount)
|
||||
public void setResultFetchSize(int resultFetchSize)
|
||||
{
|
||||
this.resultDataCount = resultDataCount;
|
||||
this.resultFetchSize = resultFetchSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,13 +154,13 @@ public class DataSetQuery
|
|||
*
|
||||
* @param paramValues
|
||||
* @param resultDataFormat
|
||||
* @param resultDataCount
|
||||
* @param resultFetchSize
|
||||
* @return
|
||||
*/
|
||||
public static DataSetQuery valueOf(Map<String, ?> paramValues, ResultDataFormat resultDataFormat, int resultDataCount)
|
||||
public static DataSetQuery valueOf(Map<String, ?> paramValues, ResultDataFormat resultDataFormat, int resultFetchSize)
|
||||
{
|
||||
DataSetQuery query = valueOf(paramValues, resultDataFormat);
|
||||
query.setResultDataCount(resultDataCount);
|
||||
query.setResultFetchSize(resultFetchSize);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public interface ResolvableDataSet extends DataSet
|
|||
/**
|
||||
* 解析{@linkplain ResolvedDataSetResult}。
|
||||
*
|
||||
* @param query
|
||||
* @param query 应是已通过{@linkplain #isReady(DataSetQuery)}校验的(可能为{@code null})
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
package org.datagear.analysis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.datagear.analysis.support.DataFormat;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +15,7 @@ import org.datagear.analysis.support.DataFormat;
|
|||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class ResultDataFormat implements Serializable
|
||||
public class ResultDataFormat extends DataFormat
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -39,20 +37,14 @@ public class ResultDataFormat implements Serializable
|
|||
/** 日期格式化类型 */
|
||||
private String dateType = TYPE_NONE;
|
||||
|
||||
/** 日期格式 */
|
||||
private String dateFormat = DataFormat.DEFAULT_DATE_FORMAT;
|
||||
|
||||
/** 时间格式化类型 */
|
||||
private String timeType = TYPE_NONE;
|
||||
|
||||
/** 时间格式 */
|
||||
private String timeFormat = DataFormat.DEFAULT_TIME_FORMAT;
|
||||
|
||||
/** 时间戳格式化类型 */
|
||||
private String timestampType = TYPE_NONE;
|
||||
|
||||
/** 时间戳格式 */
|
||||
private String timestampFormat = DataFormat.DEFAULT_TIMESTAMP_FORMAT;
|
||||
|
||||
/**是否格式化数值*/
|
||||
private boolean formatNumber = false;
|
||||
|
||||
public ResultDataFormat()
|
||||
{
|
||||
|
@ -74,14 +66,10 @@ public class ResultDataFormat implements Serializable
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDateFormat()
|
||||
{
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat)
|
||||
{
|
||||
this.dateFormat = dateFormat;
|
||||
return super.getDateFormat();
|
||||
}
|
||||
|
||||
public String getTimeType()
|
||||
|
@ -99,14 +87,10 @@ public class ResultDataFormat implements Serializable
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getTimeFormat()
|
||||
{
|
||||
return timeFormat;
|
||||
}
|
||||
|
||||
public void setTimeFormat(String timeFormat)
|
||||
{
|
||||
this.timeFormat = timeFormat;
|
||||
return super.getTimeFormat();
|
||||
}
|
||||
|
||||
public String getTimestampType()
|
||||
|
@ -124,13 +108,28 @@ public class ResultDataFormat implements Serializable
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getTimestampFormat()
|
||||
{
|
||||
return timestampFormat;
|
||||
return super.getTimestampFormat();
|
||||
}
|
||||
|
||||
public void setTimestampFormat(String timestampFormat)
|
||||
public boolean isFormatNumber()
|
||||
{
|
||||
this.timestampFormat = timestampFormat;
|
||||
return formatNumber;
|
||||
}
|
||||
|
||||
public void setFormatNumber(boolean formatNumber)
|
||||
{
|
||||
this.formatNumber = formatNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当{@linkplain #formatNumber}为{@code true}时的数值格式。
|
||||
*/
|
||||
@Override
|
||||
public String getNumberFormat()
|
||||
{
|
||||
return super.getNumberFormat();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ public abstract class AbstractCsvDataSet extends AbstractResolvableDataSet imple
|
|||
if (properties == null || properties.isEmpty())
|
||||
properties = resolveProperties(rawDataPropertyNames, rawData);
|
||||
|
||||
return resolveResult(rawData, properties);
|
||||
return resolveResult(rawData, properties, query.getResultDataFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,7 +270,7 @@ public abstract class AbstractCsvDataSet extends AbstractResolvableDataSet imple
|
|||
if(isNameRow(i))
|
||||
continue;
|
||||
|
||||
if (isReachResultDataCount(query, data.size()))
|
||||
if (isReachResultFetchSize(query, data.size()))
|
||||
break;
|
||||
|
||||
Map<String, String> row = new HashMap<>();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.datagear.analysis.DataSetProperty;
|
|||
import org.datagear.analysis.DataSetQuery;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.ResolvedDataSetResult;
|
||||
import org.datagear.analysis.ResultDataFormat;
|
||||
|
||||
/**
|
||||
* 抽象{@linkplain DataSet}。
|
||||
|
@ -141,8 +142,7 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da
|
|||
if (!hasParam())
|
||||
return true;
|
||||
|
||||
if (query == null)
|
||||
query = DataSetQuery.valueOf();
|
||||
query = toNonNullDataSetQuery(query);
|
||||
|
||||
List<DataSetParam> params = getParams();
|
||||
Map<String, ?> paramValues = query.getParamValues();
|
||||
|
@ -155,22 +155,30 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为非{@code null}的{@linkplain DataSetQuery}。
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
protected DataSetQuery toNonNullDataSetQuery(DataSetQuery query)
|
||||
{
|
||||
return (query == null ? DataSetQuery.valueOf() : query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析结果。
|
||||
*
|
||||
* @param cn
|
||||
* @param rs
|
||||
* @param rawData
|
||||
* {@code Collection<Map<String, ?>>}、{@code Map<String, ?>[]}、{@code Map<String, ?>}、{@code null}
|
||||
* @param properties
|
||||
* @param dataSetOption
|
||||
* 允许为{@code null}
|
||||
* @param format 允许为{@code null}
|
||||
* @return {@code List<Map<String, ?>>}、{@code Map<String, ?>[]}、{@code Map<String, ?>}、{@code null}
|
||||
* @throws Throwable
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected ResolvedDataSetResult resolveResult(Object rawData, List<DataSetProperty> properties) throws Throwable
|
||||
protected ResolvedDataSetResult resolveResult(Object rawData, List<DataSetProperty> properties,
|
||||
ResultDataFormat format) throws Throwable
|
||||
{
|
||||
Object data = null;
|
||||
|
||||
|
@ -182,13 +190,13 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da
|
|||
{
|
||||
Collection<Map<String, ?>> rawCollection = (Collection<Map<String, ?>>) rawData;
|
||||
|
||||
data = convertRawData(rawCollection, properties);
|
||||
data = convertRawDataToResult(rawCollection, properties, format);
|
||||
}
|
||||
else if (rawData instanceof Map<?, ?>[])
|
||||
{
|
||||
Map<?, ?>[] rawArray = (Map<?, ?>[]) rawData;
|
||||
List<Map<String, ?>> rawCollection = (List) Arrays.asList(rawArray);
|
||||
List<Map<String, Object>> dataList = convertRawData(rawCollection, properties);
|
||||
List<Map<String, Object>> dataList = convertRawDataToResult(rawCollection, properties, format);
|
||||
|
||||
data = dataList.toArray(new Map<?, ?>[dataList.size()]);
|
||||
}
|
||||
|
@ -196,7 +204,7 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da
|
|||
{
|
||||
Map<?, ?> rawMap = (Map<?, ?>) rawData;
|
||||
List<Map<String, ?>> rawCollection = (List) Arrays.asList(rawMap);
|
||||
List<Map<String, Object>> dataList = convertRawData(rawCollection, properties);
|
||||
List<Map<String, Object>> dataList = convertRawDataToResult(rawCollection, properties, format);
|
||||
|
||||
data = dataList.get(0);
|
||||
}
|
||||
|
@ -212,11 +220,12 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da
|
|||
*
|
||||
* @param rawData
|
||||
* @param properties
|
||||
* @param format 允许为{@code null}
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
protected List<Map<String, Object>> convertRawData(Collection<? extends Map<String, ?>> rawData,
|
||||
List<DataSetProperty> properties) throws Throwable
|
||||
protected List<Map<String, Object>> convertRawDataToResult(Collection<? extends Map<String, ?>> rawData,
|
||||
List<DataSetProperty> properties, ResultDataFormat format) throws Throwable
|
||||
{
|
||||
DataSetPropertyValueConverter converter = createDataSetPropertyValueConverter();
|
||||
|
||||
|
@ -261,6 +270,63 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da
|
|||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有{@linkplain DataSetQuery#getResultFetchSize()}。
|
||||
*
|
||||
* @param query 允许为{@code null}
|
||||
* @return
|
||||
*/
|
||||
protected boolean hasResultFetchSize(DataSetQuery query)
|
||||
{
|
||||
if (query == null)
|
||||
return false;
|
||||
|
||||
int maxCount = query.getResultFetchSize();
|
||||
|
||||
if (maxCount < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 给定数目是否已到达{@linkplain DataSetQuery#getResultFetchSize()}。
|
||||
*
|
||||
* @param query
|
||||
* 允许为{@code null}
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
protected boolean isReachResultFetchSize(DataSetQuery query, int count)
|
||||
{
|
||||
if (query == null)
|
||||
return false;
|
||||
|
||||
int maxCount = query.getResultFetchSize();
|
||||
|
||||
if (maxCount < 0)
|
||||
return false;
|
||||
|
||||
return count >= maxCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算结果数据最大数目。
|
||||
*
|
||||
* @param query
|
||||
* @param defaultSize
|
||||
* @return
|
||||
*/
|
||||
protected int evalResultFetchSize(DataSetQuery dataSetOption, int defaultSize)
|
||||
{
|
||||
if (dataSetOption == null)
|
||||
return defaultSize;
|
||||
|
||||
int maxCount = dataSetOption.getResultFetchSize();
|
||||
|
||||
return (maxCount < 0 ? defaultSize : Math.min(maxCount, defaultSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找与名称数组对应的{@linkplain DataSetProperty}列表。
|
||||
* <p>
|
||||
|
|
|
@ -354,7 +354,7 @@ public abstract class AbstractExcelDataSet extends AbstractResolvableDataSet imp
|
|||
if (properties == null || properties.isEmpty())
|
||||
properties = resolveProperties(rawDataPropertyNames, rawData);
|
||||
|
||||
return resolveResult(rawData, properties);
|
||||
return resolveResult(rawData, properties, query.getResultDataFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -499,7 +499,7 @@ public abstract class AbstractExcelDataSet extends AbstractResolvableDataSet imp
|
|||
if (isNameRow(i) || !isDataRow(i))
|
||||
continue;
|
||||
|
||||
if (isReachResultDataCount(query, data.size()))
|
||||
if (isReachResultFetchSize(query, data.size()))
|
||||
break;
|
||||
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
|
|
|
@ -163,7 +163,7 @@ public abstract class AbstractJsonDataSet extends AbstractResolvableDataSet impl
|
|||
if (properties == null || properties.isEmpty())
|
||||
properties = resolveProperties(rawData);
|
||||
|
||||
return resolveResult(rawData, properties);
|
||||
return resolveResult(rawData, properties, query.getResultDataFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,7 +210,7 @@ public abstract class AbstractJsonDataSet extends AbstractResolvableDataSet impl
|
|||
}
|
||||
}
|
||||
|
||||
if (data != null && hasResultDataCount(query))
|
||||
if (data != null && hasResultFetchSize(query))
|
||||
{
|
||||
if (data instanceof Collection<?>)
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ public abstract class AbstractJsonDataSet extends AbstractResolvableDataSet impl
|
|||
|
||||
for (Object ele : collection)
|
||||
{
|
||||
if (isReachResultDataCount(query, dataList.size()))
|
||||
if (isReachResultFetchSize(query, dataList.size()))
|
||||
break;
|
||||
|
||||
dataList.add(ele);
|
||||
|
@ -230,7 +230,7 @@ public abstract class AbstractJsonDataSet extends AbstractResolvableDataSet impl
|
|||
else if (data instanceof Object[])
|
||||
{
|
||||
Object[] array = (Object[]) data;
|
||||
Object[] dataArray = new Object[evalResultDataCount(query, array.length)];
|
||||
Object[] dataArray = new Object[evalResultFetchSize(query, array.length)];
|
||||
|
||||
for (int i = 0; i < dataArray.length; i++)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,8 @@ public abstract class AbstractResolvableDataSet extends AbstractDataSet implemen
|
|||
@Override
|
||||
public DataSetResult getResult(DataSetQuery query) throws DataSetException
|
||||
{
|
||||
query = toNonNullDataSetQuery(query);
|
||||
|
||||
List<DataSetProperty> properties = getProperties();
|
||||
|
||||
if (properties == null || properties.isEmpty())
|
||||
|
@ -58,6 +60,7 @@ public abstract class AbstractResolvableDataSet extends AbstractDataSet implemen
|
|||
public ResolvedDataSetResult resolve(DataSetQuery query)
|
||||
throws DataSetException
|
||||
{
|
||||
query = toNonNullDataSetQuery(query);
|
||||
return resolveResult(query, null);
|
||||
}
|
||||
|
||||
|
@ -73,61 +76,4 @@ public abstract class AbstractResolvableDataSet extends AbstractDataSet implemen
|
|||
* @throws DataSetException
|
||||
*/
|
||||
protected abstract ResolvedDataSetResult resolveResult(DataSetQuery query, List<DataSetProperty> properties) throws DataSetException;
|
||||
|
||||
/**
|
||||
* 是否有{@linkplain DataSetQuery#getResultDataCount()}。
|
||||
*
|
||||
* @param query 允许为{@code null}
|
||||
* @return
|
||||
*/
|
||||
protected boolean hasResultDataCount(DataSetQuery query)
|
||||
{
|
||||
if (query == null)
|
||||
return false;
|
||||
|
||||
int maxCount = query.getResultDataCount();
|
||||
|
||||
if (maxCount < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 给定数目是否已到达{@linkplain DataSetQuery#getResultDataCount()}。
|
||||
*
|
||||
* @param query
|
||||
* 允许为{@code null}
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
protected boolean isReachResultDataCount(DataSetQuery query, int count)
|
||||
{
|
||||
if (query == null)
|
||||
return false;
|
||||
|
||||
int maxCount = query.getResultDataCount();
|
||||
|
||||
if (maxCount < 0)
|
||||
return false;
|
||||
|
||||
return count >= maxCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算结果数据数目。
|
||||
*
|
||||
* @param query
|
||||
* @param defaultCount
|
||||
* @return
|
||||
*/
|
||||
protected int evalResultDataCount(DataSetQuery dataSetOption, int defaultCount)
|
||||
{
|
||||
if (dataSetOption == null)
|
||||
return defaultCount;
|
||||
|
||||
int maxCount = dataSetOption.getResultDataCount();
|
||||
|
||||
return (maxCount < 0 ? defaultCount : Math.min(maxCount, defaultCount));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright 2018 datagear.tech
|
||||
*
|
||||
* Licensed under the LGPLv3 license:
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.html
|
||||
*/
|
||||
|
||||
package org.datagear.analysis.support;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.datagear.analysis.ResultDataFormat;
|
||||
|
||||
/**
|
||||
* {@linkplain ResultDataFormat}支持格式化类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class ResultDataFormatter
|
||||
{
|
||||
private ResultDataFormat resultDataFormat;
|
||||
|
||||
private SimpleDateFormat _dateFormat = null;
|
||||
private SimpleDateFormat _timeFormat = null;
|
||||
private SimpleDateFormat _timestampFormat = null;
|
||||
private DecimalFormat _numberFormat = null;
|
||||
|
||||
public ResultDataFormatter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ResultDataFormatter(ResultDataFormat resultDataFormat)
|
||||
{
|
||||
super();
|
||||
setResultDataFormat(resultDataFormat);
|
||||
}
|
||||
|
||||
public ResultDataFormat getResultDataFormat()
|
||||
{
|
||||
return resultDataFormat;
|
||||
}
|
||||
|
||||
public void setResultDataFormat(ResultDataFormat resultDataFormat)
|
||||
{
|
||||
this.resultDataFormat = resultDataFormat;
|
||||
|
||||
if(ResultDataFormat.TYPE_STRING.equals(resultDataFormat.getDateType()))
|
||||
this._dateFormat = new SimpleDateFormat(resultDataFormat.getDateFormat());
|
||||
|
||||
if(ResultDataFormat.TYPE_STRING.equals(resultDataFormat.getTimeType()))
|
||||
this._timeFormat = new SimpleDateFormat(resultDataFormat.getTimeFormat());
|
||||
|
||||
if(ResultDataFormat.TYPE_STRING.equals(resultDataFormat.getTimestampType()))
|
||||
this._timestampFormat = new SimpleDateFormat(resultDataFormat.getTimestampFormat());
|
||||
|
||||
if(resultDataFormat.isFormatNumber())
|
||||
this._numberFormat = new DecimalFormat(resultDataFormat.getNumberFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化。
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Object format(Object value)
|
||||
{
|
||||
Object re = value;
|
||||
|
||||
if(value instanceof java.sql.Timestamp)
|
||||
{
|
||||
String type = this.resultDataFormat.getTimestampType();
|
||||
|
||||
if(ResultDataFormat.TYPE_NONE.equals(type))
|
||||
{
|
||||
|
||||
}
|
||||
else if(ResultDataFormat.TYPE_STRING.equals(type))
|
||||
{
|
||||
value = this._timestampFormat.format((java.sql.Timestamp)value);
|
||||
}
|
||||
else if(ResultDataFormat.TYPE_NUMBER.equals(type))
|
||||
{
|
||||
((java.sql.Timestamp)value).getTime();
|
||||
}
|
||||
}
|
||||
else if(value instanceof java.sql.Time)
|
||||
{
|
||||
String type = this.resultDataFormat.getTimeType();
|
||||
|
||||
if(ResultDataFormat.TYPE_NONE.equals(type))
|
||||
{
|
||||
|
||||
}
|
||||
else if(ResultDataFormat.TYPE_STRING.equals(type))
|
||||
{
|
||||
value = this._timeFormat.format((java.sql.Time)value);
|
||||
}
|
||||
else if(ResultDataFormat.TYPE_NUMBER.equals(type))
|
||||
{
|
||||
((java.sql.Time)value).getTime();
|
||||
}
|
||||
}
|
||||
else if(value instanceof java.util.Date)
|
||||
{
|
||||
String type = this.resultDataFormat.getDateType();
|
||||
|
||||
if(ResultDataFormat.TYPE_NONE.equals(type))
|
||||
{
|
||||
|
||||
}
|
||||
else if(ResultDataFormat.TYPE_STRING.equals(type))
|
||||
{
|
||||
value = this._dateFormat.format((java.util.Date)value);
|
||||
}
|
||||
else if(ResultDataFormat.TYPE_NUMBER.equals(type))
|
||||
{
|
||||
((java.util.Date)value).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
return re;
|
||||
}
|
||||
}
|
|
@ -191,7 +191,7 @@ public class SqlDataSet extends AbstractResolvableDataSet implements ResolvableD
|
|||
if (properties == null || properties.isEmpty())
|
||||
properties = resolveProperties(cn, rs, rawData);
|
||||
|
||||
return resolveResult(rawData, properties);
|
||||
return resolveResult(rawData, properties, query.getResultDataFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,7 +258,7 @@ public class SqlDataSet extends AbstractResolvableDataSet implements ResolvableD
|
|||
|
||||
while (rs.next())
|
||||
{
|
||||
if (isReachResultDataCount(query, data.size()))
|
||||
if (isReachResultFetchSize(query, data.size()))
|
||||
break;
|
||||
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
|
|
|
@ -144,6 +144,13 @@ public class HtmlChartScriptObjectWriter extends AbstractHtmlScriptObjectWriter
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public DataSetResult getResult()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static ChartDataSetJson[] valuesOf(ChartDataSet[] chartDataSets)
|
||||
{
|
||||
if (chartDataSets == null)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="result-data-max-count" title="<@spring.message code='dataSet.previewResultDataMaxCount' />">
|
||||
<input type="text" class="resultDataCountInput ui-widget ui-widget-content ui-corner-all" />
|
||||
<input type="text" class="resultFetchSizeInput ui-widget ui-widget-content ui-corner-all" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -643,7 +643,7 @@ po.previewOptions.url = "...";
|
|||
$panel.position({ my : "right top", at : "left+5 top", of : po.element(".workspace-operation-wrapper")});
|
||||
};
|
||||
|
||||
po.resultDataCountDefault = 100;
|
||||
po.resultFetchSizeDefault = 100;
|
||||
|
||||
//预览设置项
|
||||
po.previewOptions =
|
||||
|
@ -654,7 +654,7 @@ po.previewOptions.url = "...";
|
|||
data:
|
||||
{
|
||||
dataSet: {},
|
||||
query: { resultDataCount: po.resultDataCountDefault }
|
||||
query: { resultFetchSize: po.resultFetchSizeDefault }
|
||||
},
|
||||
//预览操作前置回调函数,返回false阻止
|
||||
beforePreview: function(){},
|
||||
|
@ -671,9 +671,9 @@ po.previewOptions.url = "...";
|
|||
success: function(previewResponse){}
|
||||
};
|
||||
|
||||
po.resultDataCountVal = function(val)
|
||||
po.resultFetchSizeVal = function(val)
|
||||
{
|
||||
var $input = po.element(".resultDataCountInput");
|
||||
var $input = po.element(".resultFetchSizeInput");
|
||||
|
||||
if(val === undefined)
|
||||
{
|
||||
|
@ -681,7 +681,7 @@ po.previewOptions.url = "...";
|
|||
var validVal = val;
|
||||
|
||||
if(isNaN(validVal))
|
||||
validVal = po.resultDataCountDefault;
|
||||
validVal = po.resultFetchSizeDefault;
|
||||
else if(validVal < 1)
|
||||
validVal = 1;
|
||||
|
||||
|
@ -778,8 +778,8 @@ po.previewOptions.url = "...";
|
|||
$panel.hide();
|
||||
});
|
||||
|
||||
po.resultDataCountVal(po.resultDataCountDefault);
|
||||
po.element(".resultDataCountInput").on("keydown", function(e)
|
||||
po.resultFetchSizeVal(po.resultFetchSizeDefault);
|
||||
po.element(".resultFetchSizeInput").on("keydown", function(e)
|
||||
{
|
||||
//防止提交数据集表单
|
||||
if(e.keyCode == $.ui.keyCode.ENTER)
|
||||
|
@ -815,7 +815,7 @@ po.previewOptions.url = "...";
|
|||
var table = po.previewResultTableElement();
|
||||
var initDataTable = !$.isDatatTable(table);
|
||||
|
||||
po.previewOptions.data.query.resultDataCount = po.resultDataCountVal();
|
||||
po.previewOptions.data.query.resultFetchSize = po.resultFetchSizeVal();
|
||||
|
||||
$.ajaxJson(
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue