移除DataSetResultTransformer类设计,它增加了DataSet概念的复杂性,后续再考虑采用组合数据集设计来实现相同的功能

This commit is contained in:
datagear 2020-08-26 19:27:49 +08:00
parent 7d51ae5541
commit aff81fb518
4 changed files with 2 additions and 155 deletions

View File

@ -21,7 +21,7 @@ import org.datagear.analysis.DataSetResult;
* @author datagear@163.com
*
*/
public abstract class AbstractJsonFileDataSet extends AbstractJsonSourceDataSet
public abstract class AbstractJsonFileDataSet extends AbstractJsonDataSet
{
public static final String DEFAULT_ENCODING = "UTF-8";
@ -54,7 +54,7 @@ public abstract class AbstractJsonFileDataSet extends AbstractJsonSourceDataSet
}
@Override
protected DataSetResult getOrginalResult(Map<String, ?> paramValues) throws DataSetException
public DataSetResult getResult(Map<String, ?> paramValues) throws DataSetException
{
File jsonFile = getJsonFile(paramValues);
Object data = getJsonDataSetSupport().resolveResultData(jsonFile, getEncoding());

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
*/
/**
*
*/
package org.datagear.analysis.support;
import java.util.List;
import java.util.Map;
import org.datagear.analysis.DataSetException;
import org.datagear.analysis.DataSetProperty;
import org.datagear.analysis.DataSetResult;
/**
* 抽象JSON源数据集
* <p>
* JSON源数据集的一个特点是源数据是无法编辑的因此需要定义{@linkplain DataSetResultTransformer}逻辑
* </p>
*
* @author datagear@163.com
*
*/
public abstract class AbstractJsonSourceDataSet extends AbstractJsonDataSet
{
private DataSetResultTransformer dataSetResultTransformer;
public AbstractJsonSourceDataSet()
{
super();
}
public AbstractJsonSourceDataSet(String id, String name)
{
super(id, name);
}
public AbstractJsonSourceDataSet(String id, String name, List<DataSetProperty> properties)
{
super(id, name, properties);
}
/**
* 获取{@linkplain DataSetResultTransformer}
*
* @return 可能为{@code null}
*/
public DataSetResultTransformer getDataSetResultTransformer()
{
return dataSetResultTransformer;
}
public void setDataSetResultTransformer(DataSetResultTransformer dataSetResultTransformer)
{
this.dataSetResultTransformer = dataSetResultTransformer;
}
@Override
public DataSetResult getResult(Map<String, ?> paramValues) throws DataSetException
{
DataSetResult result = getOrginalResult(paramValues);
if (this.dataSetResultTransformer == null)
return result;
return this.dataSetResultTransformer.transform(result);
}
/**
* 获取原始的{@linkplain DataSetResult}
*
* @param paramValues
* @return
* @throws DataSetException
*/
protected abstract DataSetResult getOrginalResult(Map<String, ?> paramValues) throws DataSetException;
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
*/
/**
*
*/
package org.datagear.analysis.support;
import org.datagear.analysis.DataSetException;
/**
* {@linkplain DataSetResultTransformer}转换异常
*
* @author datagear@163.com
*
*/
public class DataSetResultTransformException extends DataSetException
{
private static final long serialVersionUID = 1L;
public DataSetResultTransformException()
{
super();
}
public DataSetResultTransformException(String message)
{
super(message);
}
public DataSetResultTransformException(Throwable cause)
{
super(cause);
}
public DataSetResultTransformException(String message, Throwable cause)
{
super(message, cause);
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
*/
/**
*
*/
package org.datagear.analysis.support;
import org.datagear.analysis.DataSet;
import org.datagear.analysis.DataSetResult;
/**
* {@linkplain DataSetResult}转换器
* <p>
* 某些类型的{@linkplain DataSet}是从不可控制的数据源中读取数据的比如API调用JSON文件CSV文件
* 此类即为这些场景提供支持使{@linkplain DataSet}支持对数据源的数据进行转换
* </p>
*
* @author datagear@163.com
*
*/
public interface DataSetResultTransformer
{
/**
* 转换为新的{@linkplain DataSetResult}
*
* @param orginalResult
* @return 已转换的{@linkplain DataSetResult}
* @throws DataSetResultTransformException
*/
DataSetResult transform(DataSetResult orginalResult) throws DataSetResultTransformException;
}