forked from p85126437/datagear
[analysis]DataSet重命名为DataSetResult、DataSetFactory重命名为DataSet,并修改相关命名;[web]完善数据集、图表管理功能;
This commit is contained in:
parent
cf68ba0552
commit
e4655ac29b
|
@ -24,7 +24,7 @@ public class Chart extends AbstractIdentifiable
|
|||
|
||||
private Map<String, ?> propertyValues;
|
||||
|
||||
private ChartDataSetFactory[] chartDataSetFactories;
|
||||
private ChartDataSet[] chartDataSets;
|
||||
|
||||
public Chart()
|
||||
{
|
||||
|
@ -37,13 +37,13 @@ public class Chart extends AbstractIdentifiable
|
|||
}
|
||||
|
||||
public Chart(String id, RenderContext renderContext, ChartPlugin<?> plugin, Map<String, ?> propertyValues,
|
||||
ChartDataSetFactory[] chartDataSetFactories)
|
||||
ChartDataSet[] chartDataSets)
|
||||
{
|
||||
super(id);
|
||||
this.renderContext = renderContext;
|
||||
this.plugin = plugin;
|
||||
this.propertyValues = propertyValues;
|
||||
this.chartDataSetFactories = chartDataSetFactories;
|
||||
this.chartDataSets = chartDataSets;
|
||||
}
|
||||
|
||||
public RenderContext getRenderContext()
|
||||
|
@ -76,34 +76,35 @@ public class Chart extends AbstractIdentifiable
|
|||
this.propertyValues = propertyValues;
|
||||
}
|
||||
|
||||
public ChartDataSetFactory[] getChartDataSetFactories()
|
||||
public ChartDataSet[] getChartDataSets()
|
||||
{
|
||||
return chartDataSetFactories;
|
||||
return chartDataSets;
|
||||
}
|
||||
|
||||
public void setChartDataSetFactories(ChartDataSetFactory[] chartDataSetFactories)
|
||||
public void setChartDataSets(ChartDataSet[] chartDataSets)
|
||||
{
|
||||
this.chartDataSetFactories = chartDataSetFactories;
|
||||
this.chartDataSets = chartDataSets;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据集。
|
||||
* 获取此图表的所有{@linkplain DataSetResult}。
|
||||
*
|
||||
* @param dataSetParamValues
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
public DataSet[] getDataSets(Map<String, ?> dataSetParamValues) throws DataSetException
|
||||
public DataSetResult[] getDataSetResults(Map<String, ?> dataSetParamValues) throws DataSetException
|
||||
{
|
||||
if (this.chartDataSetFactories == null || this.chartDataSetFactories.length == 0)
|
||||
return new DataSet[0];
|
||||
if (this.chartDataSets == null || this.chartDataSets.length == 0)
|
||||
return new DataSetResult[0];
|
||||
|
||||
DataSet[] dataSets = new DataSet[this.chartDataSetFactories.length];
|
||||
DataSetResult[] dataSets = new DataSetResult[this.chartDataSets.length];
|
||||
|
||||
for (int i = 0; i < this.chartDataSetFactories.length; i++)
|
||||
for (int i = 0; i < this.chartDataSets.length; i++)
|
||||
{
|
||||
DataSet dataSet = this.chartDataSetFactories[i].getDataSetFactory().getDataSet(dataSetParamValues);
|
||||
dataSets[i] = dataSet;
|
||||
DataSetResult dataSetResult = this.chartDataSets[i].getDataSet()
|
||||
.getResult(dataSetParamValues);
|
||||
dataSets[i] = dataSetResult;
|
||||
}
|
||||
|
||||
return dataSets;
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.analysis;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 图表数据集。
|
||||
* <p>
|
||||
* 此类描述图表关联的某个{@linkplain DataSet}以及对其{@linkplain DataSet#getProperties()}设置的对应标记,这些标记通常是{@linkplain DataSign#getName()}。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class ChartDataSet
|
||||
{
|
||||
/** 数据集 */
|
||||
private DataSet dataSet;
|
||||
|
||||
/** 数据集属性-标记映射表 */
|
||||
private Map<String, Set<String>> propertySigns;
|
||||
|
||||
public ChartDataSet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ChartDataSet(DataSet dataSet)
|
||||
{
|
||||
super();
|
||||
this.dataSet = dataSet;
|
||||
}
|
||||
|
||||
public DataSet getDataSet()
|
||||
{
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
public void setDataSet(DataSet dataSet)
|
||||
{
|
||||
this.dataSet = dataSet;
|
||||
}
|
||||
|
||||
public boolean hasPropertySign()
|
||||
{
|
||||
return (this.propertySigns != null && !this.propertySigns.isEmpty());
|
||||
}
|
||||
|
||||
public Map<String, Set<String>> getPropertySigns()
|
||||
{
|
||||
return propertySigns;
|
||||
}
|
||||
|
||||
public void setPropertySigns(Map<String, Set<String>> propertySigns)
|
||||
{
|
||||
this.propertySigns = propertySigns;
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.analysis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 图表数据集工厂。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class ChartDataSetFactory
|
||||
{
|
||||
/** 数据集工厂 */
|
||||
private DataSetFactory dataSetFactory;
|
||||
|
||||
/** 数据标记集 */
|
||||
private List<DataSign> dataSigns;
|
||||
|
||||
public ChartDataSetFactory()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ChartDataSetFactory(DataSetFactory dataSetFactory, List<DataSign> dataSigns)
|
||||
{
|
||||
super();
|
||||
this.dataSetFactory = dataSetFactory;
|
||||
this.dataSigns = dataSigns;
|
||||
}
|
||||
|
||||
public DataSetFactory getDataSetFactory()
|
||||
{
|
||||
return dataSetFactory;
|
||||
}
|
||||
|
||||
public void setDataSetFactory(DataSetFactory dataSetFactory)
|
||||
{
|
||||
this.dataSetFactory = dataSetFactory;
|
||||
}
|
||||
|
||||
public List<DataSign> getDataSigns()
|
||||
{
|
||||
return dataSigns;
|
||||
}
|
||||
|
||||
public void setDataSigns(List<DataSign> dataSigns)
|
||||
{
|
||||
this.dataSigns = dataSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain #getDataSigns()}的名称分隔字符串。
|
||||
* <p>
|
||||
* 如果{@linkplain #getDataSigns()}为{@code null},则返回空字符串。
|
||||
* </p>
|
||||
*
|
||||
* @param splitter
|
||||
* @return
|
||||
*/
|
||||
public String getDataSignNamesText(String splitter)
|
||||
{
|
||||
if (this.dataSigns == null)
|
||||
return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < this.dataSigns.size(); i++)
|
||||
{
|
||||
DataSign dataSign = this.dataSigns.get(i);
|
||||
|
||||
if (i > 0)
|
||||
sb.append(splitter);
|
||||
|
||||
sb.append(dataSign.getName());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从{@linkplain ChartPlugin#getDataSigns()}查找并设置{@linkplain DataSign}列表。
|
||||
* <p>
|
||||
* 如果{@code chartPlugin}或{@code names}任一为{@code null},此方法什么也不做。
|
||||
* </p>
|
||||
*
|
||||
* @param chartPlugin
|
||||
* @param names
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public void setDataSigns(ChartPlugin<?> chartPlugin, String... names) throws IllegalArgumentException
|
||||
{
|
||||
List<DataSign> source = (chartPlugin == null ? null : chartPlugin.getDataSigns());
|
||||
setDataSigns(source, names);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从源列表中查找并设置{@linkplain DataSign}列表。
|
||||
* <p>
|
||||
* 如果{@code source}或{@code names}任一为{@code null},此方法什么也不做。
|
||||
* </p>
|
||||
*
|
||||
* @param source
|
||||
* @param names
|
||||
* @throws IllegalArgumentException
|
||||
* 当{@code source}中找不到指定名称的元素时
|
||||
*/
|
||||
public void setDataSigns(List<DataSign> source, String... names) throws IllegalArgumentException
|
||||
{
|
||||
if (source == null || names == null)
|
||||
return;
|
||||
|
||||
List<DataSign> dataSigns = new ArrayList<DataSign>();
|
||||
|
||||
for (String name : names)
|
||||
{
|
||||
DataSign dataSign = null;
|
||||
|
||||
for (DataSign myDataSign : source)
|
||||
{
|
||||
if (myDataSign.getName().equals(name))
|
||||
{
|
||||
dataSign = myDataSign;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dataSign == null)
|
||||
throw new IllegalArgumentException(
|
||||
"No " + DataSign.class.getSimpleName() + " found for name '" + name + "'");
|
||||
}
|
||||
|
||||
this.dataSigns = dataSigns;
|
||||
}
|
||||
}
|
|
@ -101,11 +101,11 @@ public interface ChartPlugin<T extends RenderContext> extends Identifiable
|
|||
*
|
||||
* @param renderContext
|
||||
* @param chartPropertyValues
|
||||
* @param chartDataSetFactories
|
||||
* @param chartDataSets
|
||||
* @return
|
||||
* @throws RenderException
|
||||
*/
|
||||
Chart renderChart(T renderContext, Map<String, ?> chartPropertyValues, ChartDataSetFactory... chartDataSetFactories)
|
||||
Chart renderChart(T renderContext, Map<String, ?> chartPropertyValues, ChartDataSet... chartDataSets)
|
||||
throws RenderException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -93,57 +93,57 @@ public class Dashboard extends AbstractIdentifiable
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取此看板的所有数据集。
|
||||
* 获取此看板的所有数据集结果。
|
||||
*
|
||||
* @param dataSetParamValues
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
public Map<String, DataSet[]> getDataSets(Map<String, ?> dataSetParamValues) throws DataSetException
|
||||
public Map<String, DataSetResult[]> getDataSetResults(Map<String, ?> dataSetParamValues) throws DataSetException
|
||||
{
|
||||
Map<String, DataSet[]> dataSetsMap = new HashMap<String, DataSet[]>();
|
||||
Map<String, DataSetResult[]> resultsMap = new HashMap<String, DataSetResult[]>();
|
||||
|
||||
if (this.charts == null || this.charts.isEmpty())
|
||||
return dataSetsMap;
|
||||
return resultsMap;
|
||||
|
||||
for (Chart chart : this.charts)
|
||||
{
|
||||
DataSet[] dataSets = chart.getDataSets(dataSetParamValues);
|
||||
DataSetResult[] results = chart.getDataSetResults(dataSetParamValues);
|
||||
|
||||
if (dataSets != null)
|
||||
dataSetsMap.put(chart.getId(), dataSets);
|
||||
if (results != null)
|
||||
resultsMap.put(chart.getId(), results);
|
||||
}
|
||||
|
||||
return dataSetsMap;
|
||||
return resultsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取此看板指定图表ID集的数据集。
|
||||
* 获取此看板指定图表ID集的数据集结果。
|
||||
*
|
||||
* @param chartIds
|
||||
* @param dataSetParamValues
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
public Map<String, DataSet[]> getDataSets(Collection<String> chartIds, Map<String, ?> dataSetParamValues)
|
||||
throws DataSetException
|
||||
public Map<String, DataSetResult[]> getDataSetResults(Collection<String> chartIds,
|
||||
Map<String, ?> dataSetParamValues) throws DataSetException
|
||||
{
|
||||
Map<String, DataSet[]> dataSetsMap = new HashMap<String, DataSet[]>();
|
||||
Map<String, DataSetResult[]> resultsMap = new HashMap<String, DataSetResult[]>();
|
||||
|
||||
if (this.charts == null || this.charts.isEmpty())
|
||||
return dataSetsMap;
|
||||
return resultsMap;
|
||||
|
||||
for (Chart chart : this.charts)
|
||||
{
|
||||
if (!chartIds.contains(chart.getId()))
|
||||
continue;
|
||||
|
||||
DataSet[] dataSets = chart.getDataSets(dataSetParamValues);
|
||||
DataSetResult[] results = chart.getDataSetResults(dataSetParamValues);
|
||||
|
||||
if (dataSets != null)
|
||||
dataSetsMap.put(chart.getId(), dataSets);
|
||||
if (results != null)
|
||||
resultsMap.put(chart.getId(), results);
|
||||
}
|
||||
|
||||
return dataSetsMap;
|
||||
return resultsMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,29 +13,69 @@ import java.util.Map;
|
|||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface DataSet
|
||||
public interface DataSet extends Identifiable
|
||||
{
|
||||
/**
|
||||
* 获取数据。
|
||||
* 获取属性列表。
|
||||
* <p>
|
||||
* 此列表描述{@linkplain #getResult(DataSetParamValues)}返回的{@linkplain DataSetResult#getDatas()}元素的属性信息。
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<?> getDatas();
|
||||
List<DataSetProperty> getProperties();
|
||||
|
||||
/**
|
||||
* 获取输出项值集合,返回{@code null}或空表示没有输出项值。
|
||||
* 获取指定名称的属性,没有则返回{@code null}。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, ?> getExportValues();
|
||||
|
||||
/**
|
||||
* 获取{@linkplain #getDatas()}中单条数据指定名称的属性值。
|
||||
*
|
||||
* @param data
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DataSetProperty getProperty(String name);
|
||||
|
||||
/**
|
||||
* 获取参数列表。
|
||||
* <p>
|
||||
* 返回{@code null}或空列表,表示没有。
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DataSetParam> getParams();
|
||||
|
||||
/**
|
||||
* 获取指定名称的参数,没有则返回{@code null}。
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DataSetParam getParam(String name);
|
||||
|
||||
/**
|
||||
* 获取输出列表。
|
||||
* <p>
|
||||
* 返回{@code null}或空列表,表示没有。
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DataSetExport> getExports();
|
||||
|
||||
/**
|
||||
* 获取指定名称的输出,没有则返回{@code null}。
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DataSetExport getExport(String name);
|
||||
|
||||
/**
|
||||
* 获取{@linkplain DataSetResult}。
|
||||
*
|
||||
* @param paramValues
|
||||
* 由{@linkplain #getParams()}所描述的参数值映射表,其关键字是{@linkplain DataSetParam#getName()}
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
Object getDataPropertyValue(Object data, String name) throws DataSetException;
|
||||
DataSetResult getResult(Map<String, ?> paramValues) throws DataSetException;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.io.Serializable;
|
|||
/**
|
||||
* 数据集输出项。
|
||||
* <p>
|
||||
* 此类描述{@linkplain DataSetFactory}创建的{@linkplain DataSet}可输出的数据信息。
|
||||
* 此类描述{@linkplain DataSet}创建的{@linkplain DataSetResult}可输出的数据信息。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
|
@ -35,12 +35,12 @@ public abstract class DataSetExport extends DataNameAndType implements Serializa
|
|||
/**
|
||||
* 获取输出项值。
|
||||
*
|
||||
* @param dataSetFactory
|
||||
* @param dataSet
|
||||
* @param dataSetResult
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
public abstract Object getExportValue(DataSetFactory dataSetFactory, DataSet dataSet) throws DataSetException;
|
||||
public abstract Object getExportValue(DataSet dataSet, DataSetResult dataSetResult) throws DataSetException;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.datagear.analysis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据集工厂。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface DataSetFactory extends Identifiable
|
||||
{
|
||||
/**
|
||||
* 获取属性列表。
|
||||
* <p>
|
||||
* 此列表描述{@linkplain #getDataSet(DataSetParamValues)}返回的{@linkplain DataSet#getDatas()}元素的属性信息。
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DataSetProperty> getProperties();
|
||||
|
||||
/**
|
||||
* 获取指定名称的属性,没有则返回{@code null}。
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DataSetProperty getProperty(String name);
|
||||
|
||||
/**
|
||||
* 获取参数列表。
|
||||
* <p>
|
||||
* 返回{@code null}或空列表,表示没有。
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DataSetParam> getParams();
|
||||
|
||||
/**
|
||||
* 获取指定名称的参数,没有则返回{@code null}。
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DataSetParam getParam(String name);
|
||||
|
||||
/**
|
||||
* 获取输出列表。
|
||||
* <p>
|
||||
* 返回{@code null}或空列表,表示没有。
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DataSetExport> getExports();
|
||||
|
||||
/**
|
||||
* 获取指定名称的输出,没有则返回{@code null}。
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
DataSetExport getExport(String name);
|
||||
|
||||
/**
|
||||
* 获取{@linkplain DataSet}。
|
||||
*
|
||||
* @param paramValues
|
||||
* 由{@linkplain #getParams()}所描述的参数值映射表,其关键字是{@linkplain DataSetParam#getName()}
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
DataSet getDataSet(Map<String, ?> paramValues) throws DataSetException;
|
||||
}
|
|
@ -7,7 +7,7 @@ package org.datagear.analysis;
|
|||
/**
|
||||
* 数据集参数。
|
||||
* <p>
|
||||
* 此类描述{@linkplain DataSetFactory}创建{@linkplain DataSet}所需要的输入参数信息。
|
||||
* 此类描述{@linkplain DataSet}创建{@linkplain DataSetResult}所需要的输入参数信息。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.datagear.analysis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据集结果。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface DataSetResult
|
||||
{
|
||||
/**
|
||||
* 获取数据列表。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<?> getDatas();
|
||||
|
||||
/**
|
||||
* 获取输出项值集合,返回{@code null}或空表示没有输出项值。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, ?> getExportValues();
|
||||
|
||||
/**
|
||||
* 获取{@linkplain #getDatas()}中单条数据指定名称的属性值。
|
||||
*
|
||||
* @param data
|
||||
* @param name
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
Object getDataPropertyValue(Object data, String name) throws DataSetException;
|
||||
}
|
|
@ -17,7 +17,7 @@ import org.datagear.util.i18n.Label;
|
|||
/**
|
||||
* 数据标记。
|
||||
* <p>
|
||||
* {@linkplain ChartPlugin}使用此类标记{@linkplain DataSetFactory}产生的数据,并依此进行图表绘制。
|
||||
* {@linkplain ChartPlugin}使用此类标记{@linkplain DataSet}产生的数据,并依此进行图表绘制。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
|
|
|
@ -14,20 +14,20 @@ import java.util.Map;
|
|||
|
||||
import org.datagear.analysis.AbstractIdentifiable;
|
||||
import org.datagear.analysis.DataNameAndType;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.DataSetException;
|
||||
import org.datagear.analysis.DataSetExport;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetParam;
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
|
||||
/**
|
||||
* 抽象{@linkplain DataSetFactory}。
|
||||
* 抽象{@linkplain DataSet}。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractDataSetFactory extends AbstractIdentifiable implements DataSetFactory
|
||||
public abstract class AbstractDataSet extends AbstractIdentifiable implements DataSet
|
||||
{
|
||||
private List<DataSetProperty> properties;
|
||||
|
||||
|
@ -35,12 +35,12 @@ public abstract class AbstractDataSetFactory extends AbstractIdentifiable implem
|
|||
|
||||
private List<DataSetExport> exports;
|
||||
|
||||
public AbstractDataSetFactory()
|
||||
public AbstractDataSet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractDataSetFactory(String id, List<DataSetProperty> properties)
|
||||
public AbstractDataSet(String id, List<DataSetProperty> properties)
|
||||
{
|
||||
super(id);
|
||||
this.properties = properties;
|
||||
|
@ -115,7 +115,7 @@ public abstract class AbstractDataSetFactory extends AbstractIdentifiable implem
|
|||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
protected Map<String, ?> getExportValues(DataSet dataSet) throws DataSetException
|
||||
protected Map<String, ?> getExportValues(DataSetResult dataSetResult) throws DataSetException
|
||||
{
|
||||
if (!hasExport())
|
||||
return null;
|
||||
|
@ -124,7 +124,7 @@ public abstract class AbstractDataSetFactory extends AbstractIdentifiable implem
|
|||
|
||||
for (DataSetExport expt : this.exports)
|
||||
{
|
||||
Object value = expt.getExportValue(this, dataSet);
|
||||
Object value = expt.getExportValue(this, dataSetResult);
|
||||
exportValues.put(expt.getName(), value);
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ import java.util.Map;
|
|||
|
||||
import org.datagear.analysis.AbstractIdentifiable;
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPluginManager;
|
||||
import org.datagear.analysis.RenderContext;
|
||||
|
@ -39,7 +39,7 @@ public class ChartWidget<T extends RenderContext> extends AbstractIdentifiable
|
|||
|
||||
private Map<String, ?> chartPropertyValues = new HashMap<String, Object>();
|
||||
|
||||
private ChartDataSetFactory[] chartDataSetFactories = new ChartDataSetFactory[0];
|
||||
private ChartDataSet[] chartDataSets = new ChartDataSet[0];
|
||||
|
||||
/** 图表更新间隔毫秒数 */
|
||||
private int updateInterval = -1;
|
||||
|
@ -49,12 +49,12 @@ public class ChartWidget<T extends RenderContext> extends AbstractIdentifiable
|
|||
super();
|
||||
}
|
||||
|
||||
public ChartWidget(String id, String name, ChartPlugin<T> chartPlugin, ChartDataSetFactory... chartDataSetFactories)
|
||||
public ChartWidget(String id, String name, ChartPlugin<T> chartPlugin, ChartDataSet... chartDataSets)
|
||||
{
|
||||
super(id);
|
||||
this.name = name;
|
||||
this.chartPlugin = chartPlugin;
|
||||
this.chartDataSetFactories = chartDataSetFactories;
|
||||
this.chartDataSets = chartDataSets;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
|
@ -87,14 +87,14 @@ public class ChartWidget<T extends RenderContext> extends AbstractIdentifiable
|
|||
this.chartPropertyValues = chartPropertyValues;
|
||||
}
|
||||
|
||||
public ChartDataSetFactory[] getChartDataSetFactories()
|
||||
public ChartDataSet[] getChartDataSets()
|
||||
{
|
||||
return chartDataSetFactories;
|
||||
return chartDataSets;
|
||||
}
|
||||
|
||||
public void setChartDataSetFactories(ChartDataSetFactory[] chartDataSetFactories)
|
||||
public void setChartDataSets(ChartDataSet[] chartDataSets)
|
||||
{
|
||||
this.chartDataSetFactories = chartDataSetFactories;
|
||||
this.chartDataSets = chartDataSets;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +140,7 @@ public class ChartWidget<T extends RenderContext> extends AbstractIdentifiable
|
|||
if (this.chartPropertyValues != null)
|
||||
propertyValues.putAll(this.chartPropertyValues);
|
||||
|
||||
return this.chartPlugin.renderChart(renderContext, propertyValues, this.chartDataSetFactories);
|
||||
return this.chartPlugin.renderChart(renderContext, propertyValues, this.chartDataSets);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -678,8 +678,8 @@ public class JsonChartPluginPropertiesResolver
|
|||
|
||||
dataSign.setOccurRequired(convertToBoolean(map.get(DATA_SIGN_PROPERTY_OCCUR_REQUIRED), true));
|
||||
dataSign.setOccurMultiple(convertToBoolean(map.get(DATA_SIGN_PROPERTY_OCCUR_MULTIPLE), true));
|
||||
dataSign.setNameLabel(convertToLabel(map.get(CHART_PROPERTY_NAME_LABEL)));
|
||||
dataSign.setDescLabel(convertToLabel(map.get(CHART_PROPERTY_DESC_LABEL)));
|
||||
dataSign.setNameLabel(convertToLabel(map.get(DATA_SIGN_PROPERTY_NAME_LABEL)));
|
||||
dataSign.setDescLabel(convertToLabel(map.get(DATA_SIGN_PROPERTY_DESC_LABEL)));
|
||||
|
||||
return dataSign;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.io.Serializable;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.DataSetException;
|
||||
import org.datagear.analysis.DataSetExport;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
import org.datagear.analysis.DataType;
|
||||
import org.datagear.util.StringUtil;
|
||||
|
@ -36,7 +36,7 @@ import org.datagear.util.StringUtil;
|
|||
* <li>SUM(<i>columnName</i>):总和<i>columnName</i>列值;</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* “FIRST”、“LAST”、“MAX”、“MIN”、“AVG”、“SUM”不区分大小写,<i>columnName</i>必须在所属的{@linkplain DataSetFactory#getExports()}中。
|
||||
* “FIRST”、“LAST”、“MAX”、“MIN”、“AVG”、“SUM”不区分大小写,<i>columnName</i>必须在所属的{@linkplain DataSet#getExports()}中。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
|
@ -92,28 +92,28 @@ public class MacroDataSetExport extends DataSetExport
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object getExportValue(DataSetFactory dataSetFactory, DataSet dataSet) throws DataSetException
|
||||
public Object getExportValue(DataSet dataSet, DataSetResult dataSetResult) throws DataSetException
|
||||
{
|
||||
Macro macro = resolveMacro(getMacro());
|
||||
return getExportValue(dataSetFactory, dataSet, macro, getMacro());
|
||||
return getExportValue(dataSet, dataSetResult, macro, getMacro());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定宏的输出值。
|
||||
*
|
||||
* @param dataSetFactory
|
||||
* @param dataSet
|
||||
* @param dataSetResult
|
||||
* @param macro
|
||||
* @param macroString
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
*/
|
||||
protected Object getExportValue(DataSetFactory dataSetFactory, DataSet dataSet, Macro macro, String macroString)
|
||||
protected Object getExportValue(DataSet dataSet, DataSetResult dataSetResult, Macro macro, String macroString)
|
||||
throws DataSetException
|
||||
{
|
||||
String macroName = macro.getName();
|
||||
String propertyName = macro.getProperty();
|
||||
List<?> datas = dataSet.getDatas();
|
||||
List<?> datas = dataSetResult.getDatas();
|
||||
boolean isEmptyData = (datas == null || datas.isEmpty());
|
||||
|
||||
if (MACRO_FIRST.equalsIgnoreCase(macroName))
|
||||
|
@ -121,27 +121,27 @@ public class MacroDataSetExport extends DataSetExport
|
|||
if (isEmptyData)
|
||||
return null;
|
||||
|
||||
getDataSetPropertyNotNull(dataSetFactory, propertyName);
|
||||
getDataSetPropertyNotNull(dataSet, propertyName);
|
||||
|
||||
Object first = datas.get(0);
|
||||
return dataSet.getDataPropertyValue(first, propertyName);
|
||||
return dataSetResult.getDataPropertyValue(first, propertyName);
|
||||
}
|
||||
else if (MACRO_LAST.equalsIgnoreCase(macroName))
|
||||
{
|
||||
if (isEmptyData)
|
||||
return null;
|
||||
|
||||
getDataSetPropertyNotNull(dataSetFactory, propertyName);
|
||||
getDataSetPropertyNotNull(dataSet, propertyName);
|
||||
|
||||
Object last = datas.get(datas.size() - 1);
|
||||
return dataSet.getDataPropertyValue(last, propertyName);
|
||||
return dataSetResult.getDataPropertyValue(last, propertyName);
|
||||
}
|
||||
else if (MACRO_MAX.equalsIgnoreCase(macroName))
|
||||
{
|
||||
if (isEmptyData)
|
||||
return null;
|
||||
|
||||
DataSetProperty property = getDataSetPropertyNotNull(dataSetFactory, propertyName);
|
||||
DataSetProperty property = getDataSetPropertyNotNull(dataSet, propertyName);
|
||||
|
||||
if (!DataType.isNumber(property.getType()))
|
||||
throw new MacroEvalException(macroString, "Property [" + propertyName + "] must be number type");
|
||||
|
@ -151,7 +151,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
for (int i = 0, len = datas.size(); i < len; i++)
|
||||
{
|
||||
Object row = datas.get(i);
|
||||
BigDecimal my = DataType.castBigDecimal(dataSet.getDataPropertyValue(row, propertyName));
|
||||
BigDecimal my = DataType.castBigDecimal(dataSetResult.getDataPropertyValue(row, propertyName));
|
||||
|
||||
if (my == null)
|
||||
continue;
|
||||
|
@ -166,7 +166,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
if (isEmptyData)
|
||||
return null;
|
||||
|
||||
DataSetProperty property = getDataSetPropertyNotNull(dataSetFactory, propertyName);
|
||||
DataSetProperty property = getDataSetPropertyNotNull(dataSet, propertyName);
|
||||
|
||||
if (!DataType.isNumber(property.getType()))
|
||||
throw new MacroEvalException(macroString, "Property [" + propertyName + "] must be number type");
|
||||
|
@ -176,7 +176,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
for (int i = 0, len = datas.size(); i < len; i++)
|
||||
{
|
||||
Object row = datas.get(i);
|
||||
BigDecimal my = DataType.castBigDecimal(dataSet.getDataPropertyValue(row, propertyName));
|
||||
BigDecimal my = DataType.castBigDecimal(dataSetResult.getDataPropertyValue(row, propertyName));
|
||||
|
||||
if (my == null)
|
||||
continue;
|
||||
|
@ -191,7 +191,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
if (isEmptyData)
|
||||
return null;
|
||||
|
||||
DataSetProperty columnMeta = getDataSetPropertyNotNull(dataSetFactory, propertyName);
|
||||
DataSetProperty columnMeta = getDataSetPropertyNotNull(dataSet, propertyName);
|
||||
|
||||
if (!DataType.isNumber(columnMeta.getType()))
|
||||
throw new MacroEvalException(macroString, "Property [" + propertyName + "] must be number type");
|
||||
|
@ -202,7 +202,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Object row = datas.get(i);
|
||||
BigDecimal my = DataType.castBigDecimal(dataSet.getDataPropertyValue(row, propertyName));
|
||||
BigDecimal my = DataType.castBigDecimal(dataSetResult.getDataPropertyValue(row, propertyName));
|
||||
|
||||
if (my == null)
|
||||
continue;
|
||||
|
@ -219,7 +219,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
if (isEmptyData)
|
||||
return null;
|
||||
|
||||
DataSetProperty columnMeta = getDataSetPropertyNotNull(dataSetFactory, propertyName);
|
||||
DataSetProperty columnMeta = getDataSetPropertyNotNull(dataSet, propertyName);
|
||||
|
||||
if (!DataType.isNumber(columnMeta.getType()))
|
||||
throw new MacroEvalException(macroString, "Property [" + propertyName + "] must be number type");
|
||||
|
@ -229,7 +229,7 @@ public class MacroDataSetExport extends DataSetExport
|
|||
for (int i = 0, len = datas.size(); i < len; i++)
|
||||
{
|
||||
Object row = datas.get(i);
|
||||
BigDecimal my = DataType.castBigDecimal(dataSet.getDataPropertyValue(row, propertyName));
|
||||
BigDecimal my = DataType.castBigDecimal(dataSetResult.getDataPropertyValue(row, propertyName));
|
||||
|
||||
if (my == null)
|
||||
continue;
|
||||
|
@ -240,21 +240,21 @@ public class MacroDataSetExport extends DataSetExport
|
|||
return sum;
|
||||
}
|
||||
else
|
||||
return getExportValueExt(dataSetFactory, dataSet, macro, macroString);
|
||||
return getExportValueExt(dataSet, dataSetResult, macro, macroString);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展宏的输出值。
|
||||
*
|
||||
* @param dataSetFactory
|
||||
* @param dataSet
|
||||
* @param dataSetResult
|
||||
* @param macro
|
||||
* @param macroString
|
||||
* @return
|
||||
* @throws DataSetException
|
||||
* @throws UnsupportedMacroException
|
||||
*/
|
||||
protected Object getExportValueExt(DataSetFactory dataSetFactory, DataSet dataSet, Macro macro, String macroString)
|
||||
protected Object getExportValueExt(DataSet dataSet, DataSetResult dataSetResult, Macro macro, String macroString)
|
||||
throws DataSetException, UnsupportedMacroException
|
||||
{
|
||||
throw new UnsupportedMacroException(macroString);
|
||||
|
@ -263,14 +263,14 @@ public class MacroDataSetExport extends DataSetExport
|
|||
/**
|
||||
* 获取指定名称的{@linkplain ColumnMeta},没有则抛出异常。
|
||||
*
|
||||
* @param dataSetFactory
|
||||
* @param dataSet
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
protected DataSetProperty getDataSetPropertyNotNull(DataSetFactory dataSetFactory, String name)
|
||||
protected DataSetProperty getDataSetPropertyNotNull(DataSet dataSet, String name)
|
||||
throws DataSetPropertyNotFoundException
|
||||
{
|
||||
DataSetProperty columnMeta = dataSetFactory.getProperty(name);
|
||||
DataSetProperty columnMeta = dataSet.getProperty(name);
|
||||
|
||||
if (columnMeta == null)
|
||||
throw new DataSetPropertyNotFoundException(name);
|
||||
|
|
|
@ -10,11 +10,11 @@ package org.datagear.analysis.support;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.DataSetException;
|
||||
|
||||
/**
|
||||
* 映射表{@linkplain DataSet}。
|
||||
* 映射表{@linkplain DataSetResult}。
|
||||
* <p>
|
||||
* 它的{@linkplain #getDatas()}元素为映射表对象。
|
||||
* </p>
|
||||
|
@ -22,7 +22,7 @@ import org.datagear.analysis.DataSetException;
|
|||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class MapDataSet implements DataSet
|
||||
public class MapDataSet implements DataSetResult
|
||||
{
|
||||
private List<Map<String, ?>> datas;
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.DataSetException;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetParam;
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
import org.datagear.analysis.support.ParameterSqlResolver.ParameterSql;
|
||||
|
@ -24,16 +24,16 @@ import org.datagear.util.JdbcUtil.QueryResultSet;
|
|||
import org.datagear.util.resource.ConnectionFactory;
|
||||
|
||||
/**
|
||||
* SQL {@linkplain DataSetFactory}。
|
||||
* SQL {@linkplain DataSet}。
|
||||
* <p>
|
||||
* 它的{@linkplain #setSql(String)}中可以包含<code>${parameter}</code>格式的参数(<code>parameter</code>必须是在{@linkplain #getParams()}中预定义的),
|
||||
* 在{@linkplain #getDataSet(DataSetParamValues)}中会被替换为具体的参数值。
|
||||
* 在{@linkplain #getResult(DataSetParamValues)}中会被替换为具体的参数值。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SqlDataSetFactory extends AbstractDataSetFactory
|
||||
public class SqlDataSet extends AbstractDataSet
|
||||
{
|
||||
protected static final SqlDataSetSupport SQL_DATA_SET_SUPPORT = new SqlDataSetSupport();
|
||||
|
||||
|
@ -41,12 +41,12 @@ public class SqlDataSetFactory extends AbstractDataSetFactory
|
|||
|
||||
private String sql;
|
||||
|
||||
public SqlDataSetFactory()
|
||||
public SqlDataSet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SqlDataSetFactory(String id, List<DataSetProperty> properties, ConnectionFactory connectionFactory,
|
||||
public SqlDataSet(String id, List<DataSetProperty> properties, ConnectionFactory connectionFactory,
|
||||
String sql)
|
||||
{
|
||||
super(id, properties);
|
||||
|
@ -75,7 +75,7 @@ public class SqlDataSetFactory extends AbstractDataSetFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public DataSet getDataSet(Map<String, ?> paramValues) throws DataSetException
|
||||
public DataSetResult getResult(Map<String, ?> paramValues) throws DataSetException
|
||||
{
|
||||
Connection cn = null;
|
||||
|
||||
|
@ -106,14 +106,14 @@ public class SqlDataSetFactory extends AbstractDataSetFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取指定SQL的{@linkplain DataSet}。
|
||||
* 获取指定SQL的{@linkplain DataSetResult}。
|
||||
*
|
||||
* @param cn
|
||||
* @param sql
|
||||
* @param paramValues
|
||||
* @return
|
||||
*/
|
||||
protected DataSet getDataSet(Connection cn, String sql, Map<String, ?> paramValues) throws DataSetException
|
||||
protected DataSetResult getDataSet(Connection cn, String sql, Map<String, ?> paramValues) throws DataSetException
|
||||
{
|
||||
ParameterSql parameterSql = getSqlDataSetSupport().resolveParameterSql(sql);
|
||||
sql = parameterSql.getSql();
|
||||
|
@ -139,14 +139,14 @@ public class SqlDataSetFactory extends AbstractDataSetFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* 将{@linkplain ResultSet}转换为{@linkplain DataSet}。
|
||||
* 将{@linkplain ResultSet}转换为{@linkplain DataSetResult}。
|
||||
*
|
||||
* @param cn
|
||||
* @param rs
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public DataSet toDataSet(Connection cn, ResultSet rs) throws SQLException
|
||||
public DataSetResult toDataSet(Connection cn, ResultSet rs) throws SQLException
|
||||
{
|
||||
List<Map<String, ?>> datas = getSqlDataSetSupport().resolveDatas(cn, rs, getProperties());
|
||||
MapDataSet dataSet = new MapDataSet(datas);
|
|
@ -10,7 +10,7 @@ package org.datagear.analysis.support.html;
|
|||
import java.util.Map;
|
||||
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.RenderContext;
|
||||
|
||||
|
@ -32,10 +32,10 @@ public class HtmlChart extends Chart
|
|||
}
|
||||
|
||||
public HtmlChart(String id, HtmlRenderContext renderContext, ChartPlugin<?> chartPlugin,
|
||||
Map<String, ?> chartPropertyValues, ChartDataSetFactory[] chartDataSetFactories, String elementId,
|
||||
Map<String, ?> chartPropertyValues, ChartDataSet[] chartDataSets, String elementId,
|
||||
String varName)
|
||||
{
|
||||
super(id, renderContext, chartPlugin, chartPropertyValues, chartDataSetFactories);
|
||||
super(id, renderContext, chartPlugin, chartPropertyValues, chartDataSets);
|
||||
this.elementId = elementId;
|
||||
this.varName = varName;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.io.Reader;
|
|||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.RenderContext;
|
||||
import org.datagear.analysis.RenderException;
|
||||
import org.datagear.analysis.support.AbstractChartPlugin;
|
||||
|
@ -53,10 +53,10 @@ import org.datagear.util.i18n.Label;
|
|||
* id : "...",
|
||||
* elementId : "[图表HTML元素ID]",
|
||||
* varName : "[图表变量名]",
|
||||
* plugin : "插件ID",
|
||||
* plugin : { id : "插件ID", ... },
|
||||
* renderContext : { attributes : {...} },
|
||||
* propertyValues : {...},
|
||||
* dataSetFactories : [{...}, ...]
|
||||
* chartDataSets : [{...}, ...]
|
||||
* };
|
||||
* [图表脚本内容]
|
||||
* [图表变量名].render();
|
||||
|
@ -109,6 +109,8 @@ import org.datagear.util.i18n.Label;
|
|||
*/
|
||||
public class HtmlChartPlugin<T extends HtmlRenderContext> extends AbstractChartPlugin<T>
|
||||
{
|
||||
protected static final HtmlChartScriptObjectWriter HTML_CHART_SCRIPT_OBJECT_WRITER = new HtmlChartScriptObjectWriter();
|
||||
|
||||
/** 默认图表对象引用占位符 */
|
||||
public static final String DEFAULT_SCRIPT_CHART_REF_PLACEHOLDER = "$CHART";
|
||||
|
||||
|
@ -136,8 +138,6 @@ public class HtmlChartPlugin<T extends HtmlRenderContext> extends AbstractChartP
|
|||
/** 图表脚本换行符 */
|
||||
private String newLine = "\r\n";
|
||||
|
||||
private HtmlChartScriptObjectWriter htmlChartScriptObjectWriter = new HtmlChartScriptObjectWriter();
|
||||
|
||||
public HtmlChartPlugin()
|
||||
{
|
||||
super();
|
||||
|
@ -199,19 +199,9 @@ public class HtmlChartPlugin<T extends HtmlRenderContext> extends AbstractChartP
|
|||
this.newLine = newLine;
|
||||
}
|
||||
|
||||
public HtmlChartScriptObjectWriter getHtmlChartScriptObjectWriter()
|
||||
{
|
||||
return htmlChartScriptObjectWriter;
|
||||
}
|
||||
|
||||
public void setHtmlChartScriptObjectWriter(HtmlChartScriptObjectWriter htmlChartScriptObjectWriter)
|
||||
{
|
||||
this.htmlChartScriptObjectWriter = htmlChartScriptObjectWriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HtmlChart renderChart(T renderContext, Map<String, ?> chartPropertyValues,
|
||||
ChartDataSetFactory... chartDataSetFactories) throws RenderException
|
||||
public HtmlChart renderChart(T renderContext, Map<String, ?> chartPropertyValues, ChartDataSet... chartDataSets)
|
||||
throws RenderException
|
||||
{
|
||||
boolean notRenderElement = HtmlRenderAttributes.getChartNotRenderElement(renderContext);
|
||||
String chartElementId = HtmlRenderAttributes.getChartElementId(renderContext);
|
||||
|
@ -240,7 +230,7 @@ public class HtmlChartPlugin<T extends HtmlRenderContext> extends AbstractChartP
|
|||
chartVarName = HtmlRenderAttributes.generateChartVarName(nextSequence);
|
||||
}
|
||||
|
||||
HtmlChart chart = new HtmlChart(IDUtil.uuid(), renderContext, this, chartPropertyValues, chartDataSetFactories,
|
||||
HtmlChart chart = new HtmlChart(IDUtil.uuid(), renderContext, this, chartPropertyValues, chartDataSets,
|
||||
chartElementId, chartVarName);
|
||||
|
||||
try
|
||||
|
@ -333,10 +323,15 @@ public class HtmlChartPlugin<T extends HtmlRenderContext> extends AbstractChartP
|
|||
*/
|
||||
protected void writeChartScriptObject(T renderContext, HtmlChart chart) throws IOException
|
||||
{
|
||||
this.htmlChartScriptObjectWriter.write(renderContext.getWriter(), chart,
|
||||
getHtmlChartScriptObjectWriter().write(renderContext.getWriter(), chart,
|
||||
HtmlRenderAttributes.getChartRenderContextVarName(renderContext));
|
||||
}
|
||||
|
||||
protected HtmlChartScriptObjectWriter getHtmlChartScriptObjectWriter()
|
||||
{
|
||||
return HTML_CHART_SCRIPT_OBJECT_WRITER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写图表脚本内容。
|
||||
*
|
||||
|
|
|
@ -14,18 +14,18 @@ import java.util.Map;
|
|||
|
||||
import org.datagear.analysis.AbstractIdentifiable;
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartProperty;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetException;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.DataSign;
|
||||
import org.datagear.analysis.Icon;
|
||||
import org.datagear.analysis.RenderContext;
|
||||
import org.datagear.analysis.RenderException;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.AbstractDataSetFactory;
|
||||
import org.datagear.analysis.support.AbstractDataSet;
|
||||
import org.datagear.util.StringUtil;
|
||||
import org.datagear.util.i18n.Label;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class HtmlChartScriptObjectWriter extends AbstractHtmlScriptObjectWriter
|
|||
? new AttributesHtmlRenderContext(htmlChart.getRenderContext())
|
||||
: new RefHtmlRenderContext(chartRenderContextVarName)),
|
||||
new IdChartPlugin(htmlChart.getPlugin()), htmlChart.getPropertyValues(),
|
||||
JsonChartDataSetFactory.valuesOf(htmlChart.getChartDataSetFactories()), htmlChart.getElementId(),
|
||||
JsonChartDataSet.valuesOf(htmlChart.getChartDataSets()), htmlChart.getElementId(),
|
||||
htmlChart.getVarName());
|
||||
}
|
||||
}
|
||||
|
@ -169,45 +169,45 @@ public class HtmlChartScriptObjectWriter extends AbstractHtmlScriptObjectWriter
|
|||
|
||||
@Override
|
||||
public Chart renderChart(RenderContext renderContext, Map<String, ?> chartPropertyValues,
|
||||
ChartDataSetFactory... chartDataSetFactories) throws RenderException
|
||||
ChartDataSet... chartDataSets) throws RenderException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
protected static class JsonChartDataSetFactory extends ChartDataSetFactory
|
||||
protected static class JsonChartDataSet extends ChartDataSet
|
||||
{
|
||||
public JsonChartDataSetFactory(DataSetFactory dataSetFactory, List<DataSign> dataSigns)
|
||||
public JsonChartDataSet(ChartDataSet chartDataSet)
|
||||
{
|
||||
super(new JsonDataSetFactory(dataSetFactory), dataSigns);
|
||||
super(new JsonDataSet(chartDataSet.getDataSet()));
|
||||
setPropertySigns(chartDataSet.getPropertySigns());
|
||||
}
|
||||
|
||||
public static JsonChartDataSetFactory[] valuesOf(ChartDataSetFactory[] chartDataSetFactories)
|
||||
public static JsonChartDataSet[] valuesOf(ChartDataSet[] chartDataSets)
|
||||
{
|
||||
if (chartDataSetFactories == null)
|
||||
if (chartDataSets == null)
|
||||
return null;
|
||||
|
||||
JsonChartDataSetFactory[] jsonDataSetFactories = new JsonChartDataSetFactory[chartDataSetFactories.length];
|
||||
JsonChartDataSet[] jsonDataSets = new JsonChartDataSet[chartDataSets.length];
|
||||
|
||||
for (int i = 0; i < chartDataSetFactories.length; i++)
|
||||
jsonDataSetFactories[i] = new JsonChartDataSetFactory(chartDataSetFactories[i].getDataSetFactory(),
|
||||
chartDataSetFactories[i].getDataSigns());
|
||||
for (int i = 0; i < chartDataSets.length; i++)
|
||||
jsonDataSets[i] = new JsonChartDataSet(chartDataSets[i]);
|
||||
|
||||
return jsonDataSetFactories;
|
||||
return jsonDataSets;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class JsonDataSetFactory extends AbstractDataSetFactory
|
||||
protected static class JsonDataSet extends AbstractDataSet
|
||||
{
|
||||
public JsonDataSetFactory(DataSetFactory dataSetFactory)
|
||||
public JsonDataSet(DataSet dataSet)
|
||||
{
|
||||
super(dataSetFactory.getId(), dataSetFactory.getProperties());
|
||||
setParams(dataSetFactory.getParams());
|
||||
setExports(dataSetFactory.getExports());
|
||||
super(dataSet.getId(), dataSet.getProperties());
|
||||
setParams(dataSet.getParams());
|
||||
setExports(dataSet.getExports());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSet getDataSet(Map<String, ?> paramValues) throws DataSetException
|
||||
public DataSetResult getResult(Map<String, ?> paramValues) throws DataSetException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
package org.datagear.analysis.support.html;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.RenderException;
|
||||
import org.datagear.analysis.support.ChartWidget;
|
||||
|
@ -26,9 +26,9 @@ public class HtmlChartWidget<T extends HtmlRenderContext> extends ChartWidget<T>
|
|||
}
|
||||
|
||||
public HtmlChartWidget(String id, String name, HtmlChartPlugin<T> chartPlugin,
|
||||
ChartDataSetFactory... chartDataSetFactories)
|
||||
ChartDataSet... chartDataSets)
|
||||
{
|
||||
super(id, name, chartPlugin, chartDataSetFactories);
|
||||
super(id, name, chartPlugin, chartDataSets);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartProperty;
|
||||
import org.datagear.analysis.DataSign;
|
||||
import org.datagear.analysis.PropertyType;
|
||||
|
@ -209,7 +209,7 @@ public class JsonChartPluginPropertiesResolverTest
|
|||
|
||||
@Override
|
||||
public Chart renderChart(RenderContext renderContext, Map<String, ?> chartPropertyValues,
|
||||
ChartDataSetFactory... chartDataSetFactories) throws RenderException
|
||||
ChartDataSet... chartDataSets) throws RenderException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.DataSetParam;
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
import org.datagear.analysis.DataType;
|
||||
|
@ -24,20 +24,20 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlDataSetFactory}单元测试类。
|
||||
* {@linkplain SqlDataSet}单元测试类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SqlDataSetFactoryTest extends DBTestSupport
|
||||
public class SqlDataSetTest extends DBTestSupport
|
||||
{
|
||||
@Test
|
||||
public void getDataSetTest() throws Exception
|
||||
public void getResultTest() throws Exception
|
||||
{
|
||||
Connection cn = null;
|
||||
|
||||
long recordId = 999999999;
|
||||
String recordName = SqlDataSetFactory.class.getSimpleName();
|
||||
String recordName = SqlDataSet.class.getSimpleName();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -66,17 +66,17 @@ public class SqlDataSetFactoryTest extends DBTestSupport
|
|||
List<DataSetParam> dataSetParams = Arrays.asList(new DataSetParam("id", DataType.INTEGER, true),
|
||||
new DataSetParam("name", DataType.STRING, true));
|
||||
|
||||
SqlDataSetFactory sqlDataSetFactory = new SqlDataSetFactory("1", dataSetProperties, connectionFactory, sql);
|
||||
sqlDataSetFactory.setParams(dataSetParams);
|
||||
SqlDataSet sqlDataSet = new SqlDataSet("1", dataSetProperties, connectionFactory, sql);
|
||||
sqlDataSet.setParams(dataSetParams);
|
||||
|
||||
Map<String, Object> dataSetParamValues = new HashMap<String, Object>();
|
||||
dataSetParamValues.put("id", recordId);
|
||||
dataSetParamValues.put("name", "name-for-test");
|
||||
|
||||
DataSet dataSet = sqlDataSetFactory.getDataSet(dataSetParamValues);
|
||||
DataSetResult dataSetResult = sqlDataSet.getResult(dataSetParamValues);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, ?>> datas = (List<Map<String, ?>>) dataSet.getDatas();
|
||||
List<Map<String, ?>> datas = (List<Map<String, ?>>) dataSetResult.getDatas();
|
||||
|
||||
Assert.assertEquals(1, datas.size());
|
||||
|
|
@ -12,7 +12,7 @@ import java.io.StringWriter;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.JsonChartPluginPropertiesResolver;
|
||||
import org.datagear.analysis.support.LocationResource;
|
||||
|
@ -45,8 +45,8 @@ public class HtmlChartPluginTest
|
|||
HtmlRenderAttributes.setChartTheme(renderContext, SimpleDashboardThemeSource.THEME_LIGHT.getChartTheme());
|
||||
HtmlRenderAttributes.setLocale(renderContext, Locale.getDefault());
|
||||
|
||||
htmlChartPlugin.renderChart(renderContext, null, (ChartDataSetFactory[]) null);
|
||||
htmlChartPlugin.renderChart(renderContext, null, (ChartDataSetFactory[]) null);
|
||||
htmlChartPlugin.renderChart(renderContext, null, (ChartDataSet[]) null);
|
||||
htmlChartPlugin.renderChart(renderContext, null, (ChartDataSet[]) null);
|
||||
|
||||
String html = stringWriter.toString();
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class HtmlChartPluginTest
|
|||
DefaultHtmlRenderContext renderContext = new DefaultHtmlRenderContext(new WebContext("", ""), stringWriter);
|
||||
HtmlRenderAttributes.setChartRenderContextVarName(renderContext, "chartRenderContext");
|
||||
|
||||
htmlChartPlugin.renderChart(renderContext, null, (ChartDataSetFactory[]) null);
|
||||
htmlChartPlugin.renderChart(renderContext, null, (ChartDataSet[]) null);
|
||||
|
||||
String html = stringWriter.toString();
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.datagear.analysis.support.html;
|
|||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.SimpleChartWidgetSource;
|
||||
|
@ -34,7 +34,7 @@ public class HtmlTplDashboardWidgetFmkRendererTest
|
|||
HtmlChartPlugin<HtmlRenderContext> chartPlugin = HtmlChartPluginTest.createHtmlChartPlugin();
|
||||
|
||||
HtmlChartWidget<HtmlRenderContext> htmlChartWidget = new HtmlChartWidget<HtmlRenderContext>("chart-widget-01",
|
||||
"chart-widget-01", chartPlugin, (ChartDataSetFactory[]) null);
|
||||
"chart-widget-01", chartPlugin, (ChartDataSet[]) null);
|
||||
|
||||
DashboardWidgetResManager resManager = new DashboardWidgetResManager(
|
||||
"src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/freemarker");
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.StringWriter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.SimpleChartWidgetSource;
|
||||
|
@ -47,7 +47,7 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
HtmlChartPlugin<HtmlRenderContext> chartPlugin = HtmlChartPluginTest.createHtmlChartPlugin();
|
||||
|
||||
HtmlChartWidget<HtmlRenderContext> htmlChartWidget = new HtmlChartWidget<HtmlRenderContext>("chart-widget-01",
|
||||
"chart-widget-01", chartPlugin, (ChartDataSetFactory[]) null);
|
||||
"chart-widget-01", chartPlugin, (ChartDataSet[]) null);
|
||||
|
||||
DashboardWidgetResManager resManager = new DashboardWidgetResManager(
|
||||
"src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/html");
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
package org.datagear.management.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.support.ChartWidget;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlChartWidget;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
import org.datagear.util.i18n.Label;
|
||||
|
||||
/**
|
||||
* HTML {@linkplain ChartWidget}实体。
|
||||
|
@ -38,17 +40,20 @@ public class HtmlChartWidgetEntity extends HtmlChartWidget<HtmlRenderContext>
|
|||
/** 权限 */
|
||||
private int dataPermission = PERMISSION_NOT_LOADED;
|
||||
|
||||
/** 插件名称,展示用 */
|
||||
private String chartPluginName = "";
|
||||
|
||||
public HtmlChartWidgetEntity()
|
||||
{
|
||||
super();
|
||||
super.setChartDataSetFactories(new ChartDataSetFactory[0]);
|
||||
super.setChartDataSets(new ChartDataSet[0]);
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntity(String id, String name, HtmlChartPlugin<HtmlRenderContext> chartPlugin,
|
||||
ChartDataSetFactory[] chartDataSetFactories, User createUser)
|
||||
ChartDataSet[] chartDataSets, User createUser)
|
||||
{
|
||||
super(id, name, chartPlugin, chartDataSetFactories);
|
||||
super(id, name, chartPlugin, chartDataSets);
|
||||
this.createUser = createUser;
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
@ -96,4 +101,29 @@ public class HtmlChartWidgetEntity extends HtmlChartWidget<HtmlRenderContext>
|
|||
{
|
||||
this.dataPermission = dataPermission;
|
||||
}
|
||||
|
||||
public String getChartPluginName()
|
||||
{
|
||||
return chartPluginName;
|
||||
}
|
||||
|
||||
public void setChartPluginName(String chartPluginName)
|
||||
{
|
||||
this.chartPluginName = chartPluginName;
|
||||
}
|
||||
|
||||
public void updateChartPluginName(Locale locale)
|
||||
{
|
||||
String name = null;
|
||||
HtmlChartPlugin<HtmlRenderContext> plugin = getHtmlChartPlugin();
|
||||
|
||||
if (plugin != null)
|
||||
{
|
||||
Label nameLabel = plugin.getNameLabel();
|
||||
if (nameLabel != null)
|
||||
name = nameLabel.getValue(locale);
|
||||
}
|
||||
|
||||
setChartPluginName(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,16 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
import org.datagear.analysis.support.SqlDataSetFactory;
|
||||
import org.datagear.analysis.support.SqlDataSet;
|
||||
import org.datagear.util.resource.ConnectionFactory;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlDataSetFactoryEntity}实体。
|
||||
* {@linkplain SqlDataSetEntity}实体。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SqlDataSetFactoryEntity extends SqlDataSetFactory
|
||||
implements CreateUserEntity<String>, DataPermissionEntity<String>
|
||||
public class SqlDataSetEntity extends SqlDataSet implements CreateUserEntity<String>, DataPermissionEntity<String>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -40,14 +39,14 @@ public class SqlDataSetFactoryEntity extends SqlDataSetFactory
|
|||
/** 权限 */
|
||||
private int dataPermission = PERMISSION_NOT_LOADED;
|
||||
|
||||
public SqlDataSetFactoryEntity()
|
||||
public SqlDataSetEntity()
|
||||
{
|
||||
super();
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntity(String id, List<DataSetProperty> properties,
|
||||
SchemaConnectionFactory connectionFactory, String sql, String name, User createUser)
|
||||
public SqlDataSetEntity(String id, List<DataSetProperty> properties, SchemaConnectionFactory connectionFactory,
|
||||
String sql, String name, User createUser)
|
||||
{
|
||||
super(id, properties, connectionFactory, sql);
|
||||
this.name = name;
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.management.service;
|
||||
|
||||
import org.datagear.analysis.support.SqlDataSet;
|
||||
import org.datagear.management.domain.SqlDataSetEntity;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlDataSetEntity}业务服务接口。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface SqlDataSetEntityService extends DataPermissionEntityService<String, SqlDataSetEntity>
|
||||
{
|
||||
/**
|
||||
* 获取可用于执行分析的{@linkplain SqlDataSet}。
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
SqlDataSet getSqlDataSet(String id);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.management.service;
|
||||
|
||||
import org.datagear.analysis.support.SqlDataSetFactory;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlDataSetFactoryEntity}业务服务接口。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface SqlDataSetFactoryEntityService extends DataPermissionEntityService<String, SqlDataSetFactoryEntity>
|
||||
{
|
||||
/**
|
||||
* 获取可用于执行分析的{@linkplain SqlDataSetFactory}。
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
SqlDataSetFactory getSqlDataSetFactory(String id);
|
||||
}
|
|
@ -8,14 +8,18 @@
|
|||
package org.datagear.management.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPluginManager;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.RenderContext;
|
||||
import org.datagear.analysis.support.ChartWidget;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
|
@ -25,10 +29,12 @@ import org.datagear.management.domain.User;
|
|||
import org.datagear.management.service.AuthorizationService;
|
||||
import org.datagear.management.service.HtmlChartWidgetEntityService;
|
||||
import org.datagear.management.service.PermissionDeniedException;
|
||||
import org.datagear.management.service.SqlDataSetFactoryEntityService;
|
||||
import org.datagear.management.service.SqlDataSetEntityService;
|
||||
import org.datagear.util.StringUtil;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
/**
|
||||
* {@linkplain HtmlChartWidgetEntityService}实现类。
|
||||
*
|
||||
|
@ -45,7 +51,7 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
|
||||
private ChartPluginManager chartPluginManager;
|
||||
|
||||
private SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService;
|
||||
private SqlDataSetEntityService sqlDataSetEntityService;
|
||||
|
||||
private AuthorizationService authorizationService;
|
||||
|
||||
|
@ -55,21 +61,21 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
}
|
||||
|
||||
public HtmlChartWidgetEntityServiceImpl(SqlSessionFactory sqlSessionFactory, ChartPluginManager chartPluginManager,
|
||||
SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService, AuthorizationService authorizationService)
|
||||
SqlDataSetEntityService sqlDataSetEntityService, AuthorizationService authorizationService)
|
||||
{
|
||||
super(sqlSessionFactory);
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.sqlDataSetEntityService = sqlDataSetEntityService;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntityServiceImpl(SqlSessionTemplate sqlSessionTemplate,
|
||||
ChartPluginManager chartPluginManager, SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService,
|
||||
ChartPluginManager chartPluginManager, SqlDataSetEntityService sqlDataSetEntityService,
|
||||
AuthorizationService authorizationService)
|
||||
{
|
||||
super(sqlSessionTemplate);
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.sqlDataSetEntityService = sqlDataSetEntityService;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
|
@ -83,14 +89,14 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
this.chartPluginManager = chartPluginManager;
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntityService getSqlDataSetFactoryEntityService()
|
||||
public SqlDataSetEntityService getSqlDataSetEntityService()
|
||||
{
|
||||
return sqlDataSetFactoryEntityService;
|
||||
return sqlDataSetEntityService;
|
||||
}
|
||||
|
||||
public void setSqlDataSetFactoryEntityService(SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService)
|
||||
public void setSqlDataSetEntityService(SqlDataSetEntityService sqlDataSetEntityService)
|
||||
{
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.sqlDataSetEntityService = sqlDataSetEntityService;
|
||||
}
|
||||
|
||||
public AuthorizationService getAuthorizationService()
|
||||
|
@ -112,8 +118,6 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
if (entity == null)
|
||||
return null;
|
||||
|
||||
postProcessSelect(entity);
|
||||
|
||||
return (ChartWidget<T>) entity;
|
||||
}
|
||||
|
||||
|
@ -135,7 +139,7 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
boolean success = super.add(entity, params);
|
||||
|
||||
if (success)
|
||||
saveWidgetDataSetFactoryRelations(entity);
|
||||
saveWidgetDataSetRelations(entity);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -146,7 +150,7 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
boolean success = super.update(entity, params);
|
||||
|
||||
if (success)
|
||||
saveWidgetDataSetFactoryRelations(entity);
|
||||
saveWidgetDataSetRelations(entity);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -162,15 +166,15 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
return deleted;
|
||||
}
|
||||
|
||||
protected void saveWidgetDataSetFactoryRelations(HtmlChartWidgetEntity entity)
|
||||
protected void saveWidgetDataSetRelations(HtmlChartWidgetEntity entity)
|
||||
{
|
||||
deleteMybatis("deleteDataSetRelationById", entity.getId());
|
||||
|
||||
List<WidgetDataSetFactoryRelation> relations = WidgetDataSetFactoryRelation.valuesOf(entity);
|
||||
List<WidgetDataSetRelation> relations = getWidgetDataSetRelations(entity);
|
||||
|
||||
if (!relations.isEmpty())
|
||||
{
|
||||
for (WidgetDataSetFactoryRelation relation : relations)
|
||||
for (WidgetDataSetRelation relation : relations)
|
||||
insertMybatis("insertDataSetRelation", relation);
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +183,20 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
protected void postProcessSelects(List<HtmlChartWidgetEntity> list)
|
||||
{
|
||||
// 查询操作仅用于展示,不必完全加载
|
||||
// super.postProcessSelects(list);
|
||||
if (list == null)
|
||||
return;
|
||||
|
||||
for (HtmlChartWidgetEntity e : list)
|
||||
{
|
||||
HtmlChartPlugin<HtmlRenderContext> plugin = e.getHtmlChartPlugin();
|
||||
|
||||
if (plugin != null)
|
||||
{
|
||||
HtmlChartPlugin<HtmlRenderContext> full = getHtmlChartPlugin(plugin.getId());
|
||||
plugin.setNameLabel(full.getNameLabel());
|
||||
plugin.setDescLabel(full.getDescLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -189,48 +206,7 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
return;
|
||||
|
||||
setHtmlChartPlugin(obj);
|
||||
setChartDataSetFactories(obj);
|
||||
}
|
||||
|
||||
protected void setChartDataSetFactories(HtmlChartWidgetEntity widget)
|
||||
{
|
||||
List<WidgetDataSetFactoryRelation> relations = selectListMybatis("getDataSetRelations", widget.getId());
|
||||
|
||||
ChartDataSetFactory[] chartDataSetFactories = new ChartDataSetFactory[relations.size()];
|
||||
|
||||
for (int i = 0; i < relations.size(); i++)
|
||||
{
|
||||
WidgetDataSetFactoryRelation relation = relations.get(i);
|
||||
|
||||
DataSetFactory dataSetFactory = this.sqlDataSetFactoryEntityService
|
||||
.getSqlDataSetFactory(relation.getDataSetFactoryId());
|
||||
|
||||
if (dataSetFactory == null)
|
||||
continue;
|
||||
|
||||
ChartDataSetFactory chartDataSetFactory = new ChartDataSetFactory();
|
||||
chartDataSetFactory.setDataSetFactory(dataSetFactory);
|
||||
chartDataSetFactory.setDataSigns(widget.getChartPlugin(), relation.splitDataSigns());
|
||||
|
||||
chartDataSetFactories[i] = chartDataSetFactory;
|
||||
}
|
||||
|
||||
widget.setChartDataSetFactories(chartDataSetFactories);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected void setHtmlChartPlugin(HtmlChartWidgetEntity obj)
|
||||
{
|
||||
HtmlChartPlugin<HtmlRenderContext> htmlChartPlugin = obj.getHtmlChartPlugin();
|
||||
|
||||
if (htmlChartPlugin != null)
|
||||
{
|
||||
htmlChartPlugin = (HtmlChartPlugin<HtmlRenderContext>) (ChartPlugin) this.chartPluginManager
|
||||
.get(htmlChartPlugin.getId());
|
||||
|
||||
obj.setHtmlChartPlugin(htmlChartPlugin);
|
||||
}
|
||||
|
||||
setChartDataSets(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -245,27 +221,149 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
return SQL_NAMESPACE;
|
||||
}
|
||||
|
||||
public static class WidgetDataSetFactoryRelation
|
||||
protected void setHtmlChartPlugin(HtmlChartWidgetEntity obj)
|
||||
{
|
||||
HtmlChartPlugin<HtmlRenderContext> htmlChartPlugin = obj.getHtmlChartPlugin();
|
||||
|
||||
if (htmlChartPlugin != null)
|
||||
{
|
||||
htmlChartPlugin = getHtmlChartPlugin(htmlChartPlugin.getId());
|
||||
obj.setHtmlChartPlugin(htmlChartPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected HtmlChartPlugin<HtmlRenderContext> getHtmlChartPlugin(String id)
|
||||
{
|
||||
return (HtmlChartPlugin<HtmlRenderContext>) (ChartPlugin) this.chartPluginManager.get(id);
|
||||
}
|
||||
|
||||
protected void setChartDataSets(HtmlChartWidgetEntity widget)
|
||||
{
|
||||
Map<String, Object> sqlParams = buildParamMapWithIdentifierQuoteParameter();
|
||||
sqlParams.put("widgetId", widget.getId());
|
||||
|
||||
List<WidgetDataSetRelation> relations = selectListMybatis("getDataSetRelations", sqlParams);
|
||||
|
||||
List<ChartDataSet> chartDataSets = new ArrayList<ChartDataSet>(relations.size());
|
||||
|
||||
for (int i = 0; i < relations.size(); i++)
|
||||
{
|
||||
ChartDataSet chartDataSet = toChartDataSet(relations.get(i));
|
||||
|
||||
if (chartDataSet != null)
|
||||
chartDataSets.add(chartDataSet);
|
||||
}
|
||||
|
||||
widget.setChartDataSets(chartDataSets.toArray(new ChartDataSet[chartDataSets.size()]));
|
||||
}
|
||||
|
||||
protected ChartDataSet toChartDataSet(WidgetDataSetRelation relation)
|
||||
{
|
||||
if (relation == null || StringUtil.isEmpty(relation.getDataSetId()))
|
||||
return null;
|
||||
|
||||
DataSet dataSet = this.sqlDataSetEntityService.getSqlDataSet(relation.getDataSetId());
|
||||
|
||||
if (dataSet == null)
|
||||
return null;
|
||||
|
||||
ChartDataSet chartDataSet = new ChartDataSet(dataSet);
|
||||
chartDataSet.setPropertySigns(toPropertySigns(relation.getPropertySignsJson()));
|
||||
|
||||
return chartDataSet;
|
||||
}
|
||||
|
||||
protected Map<String, Set<String>> toPropertySigns(String json)
|
||||
{
|
||||
Map<String, Set<String>> propertySigns = new HashMap<String, Set<String>>();
|
||||
|
||||
if (!StringUtil.isEmpty(json))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> jsonMap = (Map<String, Object>) JSON.parse(json);
|
||||
|
||||
for (Map.Entry<String, Object> entry : jsonMap.entrySet())
|
||||
{
|
||||
Set<String> signs = new HashSet<String>();
|
||||
|
||||
Object valueObj = entry.getValue();
|
||||
|
||||
if (valueObj instanceof String)
|
||||
signs.add((String) valueObj);
|
||||
else if (valueObj instanceof Collection<?>)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<String> valueCollection = (Collection<String>) valueObj;
|
||||
signs.addAll(valueCollection);
|
||||
}
|
||||
else if (valueObj instanceof Object[])
|
||||
{
|
||||
Object[] valueArray = (Object[]) valueObj;
|
||||
for (Object value : valueArray)
|
||||
{
|
||||
if (value instanceof String)
|
||||
signs.add((String) value);
|
||||
}
|
||||
}
|
||||
|
||||
propertySigns.put(entry.getKey(), signs);
|
||||
}
|
||||
}
|
||||
|
||||
return propertySigns;
|
||||
}
|
||||
|
||||
protected List<WidgetDataSetRelation> getWidgetDataSetRelations(HtmlChartWidgetEntity obj)
|
||||
{
|
||||
List<WidgetDataSetRelation> list = new ArrayList<WidgetDataSetRelation>();
|
||||
|
||||
if (obj == null)
|
||||
return list;
|
||||
|
||||
ChartDataSet[] chartDataSets = obj.getChartDataSets();
|
||||
|
||||
if (chartDataSets == null)
|
||||
return list;
|
||||
|
||||
for (int i = 0; i < chartDataSets.length; i++)
|
||||
{
|
||||
ChartDataSet chartDataSet = chartDataSets[i];
|
||||
|
||||
String propertySignsJson = "";
|
||||
if (chartDataSet.hasPropertySign())
|
||||
propertySignsJson = JSON.toJSONString(chartDataSet.getPropertySigns());
|
||||
|
||||
WidgetDataSetRelation relation = new WidgetDataSetRelation(obj.getId(), chartDataSet.getDataSet().getId(),
|
||||
i + 1);
|
||||
relation.setPropertySignsJson(propertySignsJson);
|
||||
|
||||
list.add(relation);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static class WidgetDataSetRelation
|
||||
{
|
||||
private String widgetId;
|
||||
|
||||
private String dataSetFactoryId;
|
||||
private String dataSetId;
|
||||
|
||||
private String dataSignsText;
|
||||
private String propertySignsJson;
|
||||
|
||||
private int order;
|
||||
|
||||
public WidgetDataSetFactoryRelation()
|
||||
public WidgetDataSetRelation()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public WidgetDataSetFactoryRelation(String widgetId, String dataSetFactoryId, String dataSignsText, int order)
|
||||
public WidgetDataSetRelation(String widgetId, String dataSetId, int order)
|
||||
{
|
||||
super();
|
||||
this.widgetId = widgetId;
|
||||
this.dataSetFactoryId = dataSetFactoryId;
|
||||
this.dataSignsText = dataSignsText;
|
||||
this.dataSetId = dataSetId;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
|
@ -279,37 +377,24 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
this.widgetId = widgetId;
|
||||
}
|
||||
|
||||
public String getDataSetFactoryId()
|
||||
public String getDataSetId()
|
||||
{
|
||||
return dataSetFactoryId;
|
||||
return dataSetId;
|
||||
}
|
||||
|
||||
public void setDataSetFactoryId(String dataSetFactoryId)
|
||||
public void setDataSetId(String dataSetId)
|
||||
{
|
||||
this.dataSetFactoryId = dataSetFactoryId;
|
||||
this.dataSetId = dataSetId;
|
||||
}
|
||||
|
||||
public String getDataSignsText()
|
||||
public String getPropertySignsJson()
|
||||
{
|
||||
return dataSignsText;
|
||||
return propertySignsJson;
|
||||
}
|
||||
|
||||
public void setDataSignsText(String dataSignsText)
|
||||
public void setPropertySignsJson(String propertySignsJson)
|
||||
{
|
||||
this.dataSignsText = dataSignsText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆分{@linkplain #getDataSignsText()}。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] splitDataSigns()
|
||||
{
|
||||
if (this.dataSignsText == null)
|
||||
return new String[0];
|
||||
|
||||
return StringUtil.split(this.dataSignsText, DATA_SIGN_SPLITTER, true);
|
||||
this.propertySignsJson = propertySignsJson;
|
||||
}
|
||||
|
||||
public int getOrder()
|
||||
|
@ -321,31 +406,5 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
{
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public static List<WidgetDataSetFactoryRelation> valuesOf(HtmlChartWidgetEntity obj)
|
||||
{
|
||||
List<WidgetDataSetFactoryRelation> list = new ArrayList<WidgetDataSetFactoryRelation>();
|
||||
|
||||
if (obj == null)
|
||||
return list;
|
||||
|
||||
ChartDataSetFactory[] chartDataSetFactories = obj.getChartDataSetFactories();
|
||||
|
||||
if (chartDataSetFactories == null)
|
||||
return list;
|
||||
|
||||
for (int i = 0; i < chartDataSetFactories.length; i++)
|
||||
{
|
||||
ChartDataSetFactory chartDataSetFactory = chartDataSetFactories[i];
|
||||
|
||||
WidgetDataSetFactoryRelation relation = new WidgetDataSetFactoryRelation(obj.getId(),
|
||||
chartDataSetFactory.getDataSetFactory().getId(),
|
||||
chartDataSetFactory.getDataSignNamesText(DATA_SIGN_SPLITTER), i + 1);
|
||||
|
||||
list.add(relation);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,32 +12,31 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetExport;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.DataSetParam;
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
import org.datagear.analysis.support.SqlDataSetFactory;
|
||||
import org.datagear.analysis.support.SqlDataSet;
|
||||
import org.datagear.connection.ConnectionSource;
|
||||
import org.datagear.management.domain.SchemaConnectionFactory;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
import org.datagear.management.domain.SqlDataSetEntity;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.AuthorizationService;
|
||||
import org.datagear.management.service.PermissionDeniedException;
|
||||
import org.datagear.management.service.SchemaService;
|
||||
import org.datagear.management.service.SqlDataSetFactoryEntityService;
|
||||
import org.datagear.management.service.SqlDataSetEntityService;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
* {@linkplain SqlDataSetFactoryEntityService}实现类。
|
||||
* {@linkplain SqlDataSetEntityService}实现类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SqlDataSetFactoryEntityServiceImpl
|
||||
extends AbstractMybatisDataPermissionEntityService<String, SqlDataSetFactoryEntity>
|
||||
implements SqlDataSetFactoryEntityService
|
||||
public class SqlDataSetEntityServiceImpl extends AbstractMybatisDataPermissionEntityService<String, SqlDataSetEntity>
|
||||
implements SqlDataSetEntityService
|
||||
{
|
||||
protected static final String SQL_NAMESPACE = SqlDataSetFactoryEntity.class.getName();
|
||||
protected static final String SQL_NAMESPACE = SqlDataSetEntity.class.getName();
|
||||
|
||||
private ConnectionSource connectionSource;
|
||||
|
||||
|
@ -45,12 +44,12 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
|
||||
private AuthorizationService authorizationService;
|
||||
|
||||
public SqlDataSetFactoryEntityServiceImpl()
|
||||
public SqlDataSetEntityServiceImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntityServiceImpl(SqlSessionFactory sqlSessionFactory, ConnectionSource connectionSource,
|
||||
public SqlDataSetEntityServiceImpl(SqlSessionFactory sqlSessionFactory, ConnectionSource connectionSource,
|
||||
SchemaService schemaService, AuthorizationService authorizationService)
|
||||
{
|
||||
super(sqlSessionFactory);
|
||||
|
@ -59,7 +58,7 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntityServiceImpl(SqlSessionTemplate sqlSessionTemplate, ConnectionSource connectionSource,
|
||||
public SqlDataSetEntityServiceImpl(SqlSessionTemplate sqlSessionTemplate, ConnectionSource connectionSource,
|
||||
SchemaService schemaService, AuthorizationService authorizationService)
|
||||
{
|
||||
super(sqlSessionTemplate);
|
||||
|
@ -99,29 +98,36 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public SqlDataSetFactory getSqlDataSetFactory(String id)
|
||||
public SqlDataSet getSqlDataSet(String id)
|
||||
{
|
||||
return getById(id);
|
||||
SqlDataSetEntity entity = getById(id);
|
||||
|
||||
SchemaConnectionFactory connectionFactory = entity.getConnectionFactory();
|
||||
|
||||
connectionFactory.setSchema(this.schemaService.getById(connectionFactory.getSchema().getId()));
|
||||
connectionFactory.setConnectionSource(this.connectionSource);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean add(SqlDataSetFactoryEntity entity, Map<String, Object> params)
|
||||
protected boolean add(SqlDataSetEntity entity, Map<String, Object> params)
|
||||
{
|
||||
boolean success = super.add(entity, params);
|
||||
|
||||
if (success)
|
||||
saveDataSetFactoryChildren(entity);
|
||||
saveDataSetChildren(entity);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean update(SqlDataSetFactoryEntity entity, Map<String, Object> params)
|
||||
protected boolean update(SqlDataSetEntity entity, Map<String, Object> params)
|
||||
{
|
||||
boolean success = super.update(entity, params);
|
||||
|
||||
if (success)
|
||||
saveDataSetFactoryChildren(entity);
|
||||
saveDataSetChildren(entity);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -129,11 +135,11 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
@Override
|
||||
public String getResourceType()
|
||||
{
|
||||
return SqlDataSetFactoryEntity.AUTHORIZATION_RESOURCE_TYPE;
|
||||
return SqlDataSetEntity.AUTHORIZATION_RESOURCE_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlDataSetFactoryEntity getByStringId(User user, String id) throws PermissionDeniedException
|
||||
public SqlDataSetEntity getByStringId(User user, String id) throws PermissionDeniedException
|
||||
{
|
||||
return super.getById(user, id);
|
||||
}
|
||||
|
@ -145,32 +151,27 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
|
||||
if (deleted)
|
||||
{
|
||||
this.authorizationService.deleteByResource(SqlDataSetFactoryEntity.AUTHORIZATION_RESOURCE_TYPE, id);
|
||||
this.authorizationService.deleteByResource(SqlDataSetEntity.AUTHORIZATION_RESOURCE_TYPE, id);
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessSelects(List<SqlDataSetFactoryEntity> list)
|
||||
protected void postProcessSelects(List<SqlDataSetEntity> list)
|
||||
{
|
||||
// XXX 查询操作仅用于展示,不必完全加载
|
||||
// super.postProcessSelects(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessSelect(SqlDataSetFactoryEntity obj)
|
||||
protected void postProcessSelect(SqlDataSetEntity obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
SchemaConnectionFactory connectionFactory = obj.getConnectionFactory();
|
||||
|
||||
connectionFactory.setSchema(this.schemaService.getById(connectionFactory.getSchema().getId()));
|
||||
connectionFactory.setConnectionSource(this.connectionSource);
|
||||
|
||||
Map<String, Object> sqlParams = buildParamMapWithIdentifierQuoteParameter();
|
||||
sqlParams.put("dataSetFactoryId", obj.getId());
|
||||
sqlParams.put("dataSetId", obj.getId());
|
||||
|
||||
List<DataSetPropertyPO> propertyPOs = selectListMybatis("getPropertyPOs", sqlParams);
|
||||
List<DataSetProperty> dataSetProperties = DataSetPropertyPO.to(propertyPOs);
|
||||
|
@ -197,14 +198,14 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
return SQL_NAMESPACE;
|
||||
}
|
||||
|
||||
protected void saveDataSetFactoryChildren(SqlDataSetFactory entity)
|
||||
protected void saveDataSetChildren(SqlDataSet entity)
|
||||
{
|
||||
saveDataSetPropertyPOs(entity);
|
||||
saveDataSetParamPOs(entity);
|
||||
saveDataSetExportPOs(entity);
|
||||
}
|
||||
|
||||
protected void saveDataSetPropertyPOs(SqlDataSetFactory entity)
|
||||
protected void saveDataSetPropertyPOs(SqlDataSet entity)
|
||||
{
|
||||
deleteMybatis("deletePropertyPOs", entity.getId());
|
||||
|
||||
|
@ -217,7 +218,7 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
protected void saveDataSetParamPOs(SqlDataSetFactory entity)
|
||||
protected void saveDataSetParamPOs(SqlDataSet entity)
|
||||
{
|
||||
deleteMybatis("deleteParamPOs", entity.getId());
|
||||
|
||||
|
@ -230,7 +231,7 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
protected void saveDataSetExportPOs(SqlDataSetFactory entity)
|
||||
protected void saveDataSetExportPOs(SqlDataSet entity)
|
||||
{
|
||||
deleteMybatis("deleteExportPOs", entity.getId());
|
||||
|
||||
|
@ -243,33 +244,33 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
public static abstract class DataSetFactoryChildPO<T>
|
||||
public static abstract class DataSetChildPO<T>
|
||||
{
|
||||
private String dataSetFactoryId;
|
||||
private String dataSetId;
|
||||
private T child;
|
||||
private int order = 0;
|
||||
|
||||
public DataSetFactoryChildPO()
|
||||
public DataSetChildPO()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DataSetFactoryChildPO(String dataSetFactoryId, T child, int order)
|
||||
public DataSetChildPO(String dataSetId, T child, int order)
|
||||
{
|
||||
super();
|
||||
this.dataSetFactoryId = dataSetFactoryId;
|
||||
this.dataSetId = dataSetId;
|
||||
this.child = child;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getDataSetFactoryId()
|
||||
public String getDataSetId()
|
||||
{
|
||||
return dataSetFactoryId;
|
||||
return dataSetId;
|
||||
}
|
||||
|
||||
public void setDataSetFactoryId(String dataSetFactoryId)
|
||||
public void setDataSetId(String dataSetId)
|
||||
{
|
||||
this.dataSetFactoryId = dataSetFactoryId;
|
||||
this.dataSetId = dataSetId;
|
||||
}
|
||||
|
||||
public T getChild()
|
||||
|
@ -292,13 +293,13 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
this.order = order;
|
||||
}
|
||||
|
||||
public static <T> List<T> to(List<? extends DataSetFactoryChildPO<T>> pos)
|
||||
public static <T> List<T> to(List<? extends DataSetChildPO<T>> pos)
|
||||
{
|
||||
List<T> childs = new ArrayList<T>();
|
||||
|
||||
if (pos != null)
|
||||
{
|
||||
for (DataSetFactoryChildPO<T> po : pos)
|
||||
for (DataSetChildPO<T> po : pos)
|
||||
childs.add(po.getChild());
|
||||
}
|
||||
|
||||
|
@ -306,16 +307,16 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
public static class DataSetPropertyPO extends DataSetFactoryChildPO<DataSetProperty>
|
||||
public static class DataSetPropertyPO extends DataSetChildPO<DataSetProperty>
|
||||
{
|
||||
public DataSetPropertyPO()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DataSetPropertyPO(String dataSetFactoryId, DataSetProperty child, int order)
|
||||
public DataSetPropertyPO(String dataSetId, DataSetProperty child, int order)
|
||||
{
|
||||
super(dataSetFactoryId, child, order);
|
||||
super(dataSetId, child, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -330,17 +331,17 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
super.setChild(child);
|
||||
}
|
||||
|
||||
public static List<DataSetPropertyPO> from(DataSetFactory dataSetFactory)
|
||||
public static List<DataSetPropertyPO> from(DataSet dataSet)
|
||||
{
|
||||
List<DataSetPropertyPO> pos = new ArrayList<DataSetPropertyPO>();
|
||||
|
||||
List<DataSetProperty> properties = dataSetFactory.getProperties();
|
||||
List<DataSetProperty> properties = dataSet.getProperties();
|
||||
|
||||
if (properties != null)
|
||||
{
|
||||
for (int i = 0; i < properties.size(); i++)
|
||||
{
|
||||
DataSetPropertyPO po = new DataSetPropertyPO(dataSetFactory.getId(), properties.get(i), i);
|
||||
DataSetPropertyPO po = new DataSetPropertyPO(dataSet.getId(), properties.get(i), i);
|
||||
pos.add(po);
|
||||
}
|
||||
}
|
||||
|
@ -349,16 +350,16 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
public static class DataSetParamPO extends DataSetFactoryChildPO<DataSetParam>
|
||||
public static class DataSetParamPO extends DataSetChildPO<DataSetParam>
|
||||
{
|
||||
public DataSetParamPO()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DataSetParamPO(String dataSetFactoryId, DataSetParam child, int order)
|
||||
public DataSetParamPO(String dataSetId, DataSetParam child, int order)
|
||||
{
|
||||
super(dataSetFactoryId, child, order);
|
||||
super(dataSetId, child, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -373,17 +374,17 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
super.setChild(child);
|
||||
}
|
||||
|
||||
public static List<DataSetParamPO> from(DataSetFactory dataSetFactory)
|
||||
public static List<DataSetParamPO> from(DataSet dataSet)
|
||||
{
|
||||
List<DataSetParamPO> pos = new ArrayList<DataSetParamPO>();
|
||||
|
||||
List<DataSetParam> params = dataSetFactory.getParams();
|
||||
List<DataSetParam> params = dataSet.getParams();
|
||||
|
||||
if (params != null)
|
||||
{
|
||||
for (int i = 0; i < params.size(); i++)
|
||||
{
|
||||
DataSetParamPO po = new DataSetParamPO(dataSetFactory.getId(), params.get(i), i);
|
||||
DataSetParamPO po = new DataSetParamPO(dataSet.getId(), params.get(i), i);
|
||||
pos.add(po);
|
||||
}
|
||||
}
|
||||
|
@ -392,16 +393,16 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
public static class DataSetExportPO extends DataSetFactoryChildPO<DataSetExport>
|
||||
public static class DataSetExportPO extends DataSetChildPO<DataSetExport>
|
||||
{
|
||||
public DataSetExportPO()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DataSetExportPO(String dataSetFactoryId, DataSetExport child, int order)
|
||||
public DataSetExportPO(String dataSetId, DataSetExport child, int order)
|
||||
{
|
||||
super(dataSetFactoryId, child, order);
|
||||
super(dataSetId, child, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -416,17 +417,17 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
super.setChild(child);
|
||||
}
|
||||
|
||||
public static List<DataSetExportPO> from(DataSetFactory dataSetFactory)
|
||||
public static List<DataSetExportPO> from(DataSet dataSet)
|
||||
{
|
||||
List<DataSetExportPO> pos = new ArrayList<DataSetExportPO>();
|
||||
|
||||
List<DataSetExport> exports = dataSetFactory.getExports();
|
||||
List<DataSetExport> exports = dataSet.getExports();
|
||||
|
||||
if (exports != null)
|
||||
{
|
||||
for (int i = 0; i < exports.size(); i++)
|
||||
{
|
||||
DataSetExportPO po = new DataSetExportPO(dataSetFactory.getId(), exports.get(i), i);
|
||||
DataSetExportPO po = new DataSetExportPO(dataSet.getId(), exports.get(i), i);
|
||||
pos.add(po);
|
||||
}
|
||||
}
|
|
@ -163,38 +163,38 @@ ALTER TABLE DATAGEAR_SQL_HISTORY ADD FOREIGN KEY (SQLHIS_SCHEMA_ID) REFERENCES D
|
|||
--version[1.5.0], DO NOT EDIT THIS LINE!
|
||||
-----------------------------------------
|
||||
|
||||
--数据集
|
||||
CREATE TABLE DATAGEAR_DATA_SET_FACTORY
|
||||
--SQL数据集
|
||||
CREATE TABLE DATAGEAR_SQL_DATA_SET
|
||||
(
|
||||
DSF_ID VARCHAR(50) NOT NULL,
|
||||
DSF_NAME VARCHAR(100) NOT NULL,
|
||||
DSF_SCHEMA_ID VARCHAR(50) NOT NULL,
|
||||
DSF_SQL VARCHAR(1000) NOT NULL,
|
||||
DSF_CREATE_USER_ID VARCHAR(50),
|
||||
DSF_CREATE_TIME TIMESTAMP,
|
||||
PRIMARY KEY (DSF_ID)
|
||||
DS_ID VARCHAR(50) NOT NULL,
|
||||
DS_NAME VARCHAR(100) NOT NULL,
|
||||
DS_SCHEMA_ID VARCHAR(50) NOT NULL,
|
||||
DS_SQL VARCHAR(1000) NOT NULL,
|
||||
DS_CREATE_USER_ID VARCHAR(50),
|
||||
DS_CREATE_TIME TIMESTAMP,
|
||||
PRIMARY KEY (DS_ID)
|
||||
);
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY ADD FOREIGN KEY (DSF_SCHEMA_ID) REFERENCES DATAGEAR_SCHEMA (SCHEMA_ID);
|
||||
ALTER TABLE DATAGEAR_SQL_DATA_SET ADD FOREIGN KEY (DS_SCHEMA_ID) REFERENCES DATAGEAR_SCHEMA (SCHEMA_ID);
|
||||
|
||||
--数据集属性
|
||||
CREATE TABLE DATAGEAR_DATA_SET_FACTORY_PROP
|
||||
CREATE TABLE DATAGEAR_DATA_SET_PROP
|
||||
(
|
||||
PROP_DSF_ID VARCHAR(50) NOT NULL,
|
||||
PROP_DS_ID VARCHAR(50) NOT NULL,
|
||||
PROP_NAME VARCHAR(100) NOT NULL,
|
||||
PROP_TYPE VARCHAR(50) NOT NULL,
|
||||
PROP_LABEL VARCHAR(100),
|
||||
PROP_ORDER INTEGER
|
||||
);
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY_PROP ADD FOREIGN KEY (PROP_DSF_ID) REFERENCES DATAGEAR_DATA_SET_FACTORY (DSF_ID) ON DELETE CASCADE;
|
||||
ALTER TABLE DATAGEAR_DATA_SET_PROP ADD FOREIGN KEY (PROP_DS_ID) REFERENCES DATAGEAR_SQL_DATA_SET (DS_ID) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY_PROP ADD CONSTRAINT UK_DSF_PROP_DSF_ID_NAME UNIQUE (PROP_DSF_ID, PROP_NAME);
|
||||
ALTER TABLE DATAGEAR_DATA_SET_PROP ADD CONSTRAINT UK_DS_PROP_DS_ID_NAME UNIQUE (PROP_DS_ID, PROP_NAME);
|
||||
|
||||
--数据集参数
|
||||
CREATE TABLE DATAGEAR_DATA_SET_FACTORY_PAR
|
||||
CREATE TABLE DATAGEAR_DATA_SET_PAR
|
||||
(
|
||||
PAR_DSF_ID VARCHAR(50) NOT NULL,
|
||||
PAR_DS_ID VARCHAR(50) NOT NULL,
|
||||
PAR_NAME VARCHAR(100) NOT NULL,
|
||||
PAR_TYPE VARCHAR(100) NOT NULL,
|
||||
PAR_REQUIRED VARCHAR(10),
|
||||
|
@ -202,22 +202,22 @@ CREATE TABLE DATAGEAR_DATA_SET_FACTORY_PAR
|
|||
PAR_ORDER INTEGER
|
||||
);
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY_PAR ADD FOREIGN KEY (PAR_DSF_ID) REFERENCES DATAGEAR_DATA_SET_FACTORY (DSF_ID) ON DELETE CASCADE;
|
||||
ALTER TABLE DATAGEAR_DATA_SET_PAR ADD FOREIGN KEY (PAR_DS_ID) REFERENCES DATAGEAR_SQL_DATA_SET (DS_ID) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY_PAR ADD CONSTRAINT UK_DSF_PAR_DSF_ID_NAME UNIQUE (PAR_DSF_ID, PAR_NAME);
|
||||
ALTER TABLE DATAGEAR_DATA_SET_PAR ADD CONSTRAINT UK_DS_PAR_DS_ID_NAME UNIQUE (PAR_DS_ID, PAR_NAME);
|
||||
|
||||
--数据集输出
|
||||
CREATE TABLE DATAGEAR_DATA_SET_FACTORY_EXPT
|
||||
CREATE TABLE DATAGEAR_DATA_SET_EXPT
|
||||
(
|
||||
EXPT_DSF_ID VARCHAR(50) NOT NULL,
|
||||
EXPT_DS_ID VARCHAR(50) NOT NULL,
|
||||
EXPT_NAME VARCHAR(100) NOT NULL,
|
||||
EXPT_TYPE VARCHAR(50) NOT NULL,
|
||||
EXPT_ORDER INTEGER
|
||||
);
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY_EXPT ADD FOREIGN KEY (EXPT_DSF_ID) REFERENCES DATAGEAR_DATA_SET_FACTORY (DSF_ID) ON DELETE CASCADE;
|
||||
ALTER TABLE DATAGEAR_DATA_SET_EXPT ADD FOREIGN KEY (EXPT_DS_ID) REFERENCES DATAGEAR_SQL_DATA_SET (DS_ID) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE DATAGEAR_DATA_SET_FACTORY_EXPT ADD CONSTRAINT UK_DSF_EXPT_DSF_ID_NAME UNIQUE (EXPT_DSF_ID, EXPT_NAME);
|
||||
ALTER TABLE DATAGEAR_DATA_SET_EXPT ADD CONSTRAINT UK_DS_EXPT_DS_ID_NAME UNIQUE (EXPT_DS_ID, EXPT_NAME);
|
||||
|
||||
--图表
|
||||
CREATE TABLE DATAGEAR_HTML_CHART_WIDGET
|
||||
|
@ -232,19 +232,17 @@ CREATE TABLE DATAGEAR_HTML_CHART_WIDGET
|
|||
);
|
||||
|
||||
--图表-数据集信息
|
||||
CREATE TABLE DATAGEAR_HCW_DSF
|
||||
CREATE TABLE DATAGEAR_HCW_DS
|
||||
(
|
||||
HCW_ID VARCHAR(50) NOT NULL,
|
||||
DSF_ID VARCHAR(50) NOT NULL,
|
||||
DATA_SIGNS_TEXT VARCHAR(500),
|
||||
DSF_ORDER INTEGER
|
||||
DS_ID VARCHAR(50) NOT NULL,
|
||||
DS_PROPERTY_SIGNS VARCHAR(500),
|
||||
DS_ORDER INTEGER
|
||||
);
|
||||
|
||||
ALTER TABLE DATAGEAR_HCW_DSF ADD FOREIGN KEY (HCW_ID) REFERENCES DATAGEAR_HTML_CHART_WIDGET (HCW_ID) ON DELETE CASCADE;
|
||||
ALTER TABLE DATAGEAR_HCW_DS ADD FOREIGN KEY (HCW_ID) REFERENCES DATAGEAR_HTML_CHART_WIDGET (HCW_ID) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE DATAGEAR_HCW_DSF ADD FOREIGN KEY (DSF_ID) REFERENCES DATAGEAR_DATA_SET_FACTORY (DSF_ID);
|
||||
|
||||
ALTER TABLE DATAGEAR_HCW_DSF ADD CONSTRAINT UK_HCW_DSF_ID UNIQUE (HCW_ID, DSF_ID);
|
||||
ALTER TABLE DATAGEAR_HCW_DS ADD FOREIGN KEY (DS_ID) REFERENCES DATAGEAR_SQL_DATA_SET (DS_ID);
|
||||
|
||||
--看板
|
||||
CREATE TABLE DATAGEAR_HTML_DASHBOARD
|
||||
|
|
|
@ -16,6 +16,17 @@
|
|||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertDataSetRelation">
|
||||
INSERT INTO DATAGEAR_HCW_DS
|
||||
(
|
||||
HCW_ID, DS_ID, DS_PROPERTY_SIGNS, DS_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{widgetId}, #{dataSetId}, #{propertySignsJson, jdbcType=VARCHAR}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE DATAGEAR_HTML_CHART_WIDGET SET
|
||||
HCW_NAME = #{entity.name},
|
||||
|
@ -31,6 +42,12 @@
|
|||
HCW_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDataSetRelationById">
|
||||
DELETE FROM DATAGEAR_HCW_DS
|
||||
WHERE
|
||||
HCW_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getById" resultType="org.datagear.management.domain.HtmlChartWidgetEntity">
|
||||
SELECT
|
||||
T.*
|
||||
|
@ -40,6 +57,18 @@
|
|||
T.${_iq_}id${_iq_} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDataSetRelations" resultType="org.datagear.management.service.impl.HtmlChartWidgetEntityServiceImpl$WidgetDataSetRelation">
|
||||
SELECT
|
||||
HCW_ID AS ${_iq_}widgetId${_iq_},
|
||||
DS_ID AS ${_iq_}dataSetId${_iq_},
|
||||
DS_PROPERTY_SIGNS AS ${_iq_}propertySignsJson${_iq_},
|
||||
DS_ORDER AS ${_iq_}order${_iq_}
|
||||
FROM
|
||||
DATAGEAR_HCW_DS
|
||||
WHERE
|
||||
HCW_ID = #{widgetId}
|
||||
</select>
|
||||
|
||||
<select id="getDataIdPermissions" resultType="org.datagear.management.domain.DataIdPermission">
|
||||
SELECT
|
||||
T.DATA_ID as ${_iq_}dataId${_iq_},
|
||||
|
@ -85,35 +114,6 @@
|
|||
<include refid="common.pagingQueryFoot" />
|
||||
</select>
|
||||
|
||||
<delete id="deleteDataSetRelationById">
|
||||
DELETE FROM DATAGEAR_HCW_DSF
|
||||
WHERE
|
||||
HCW_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<insert id="insertDataSetRelation">
|
||||
INSERT INTO DATAGEAR_HCW_DSF
|
||||
(
|
||||
HCW_ID, DSF_ID, DATA_SIGNS_TEXT, DSF_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{widgetId}, #{dataSetFactoryId}, #{dataSignsText}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getDataSetRelations" resultType="org.datagear.management.service.impl.HtmlChartWidgetEntityServiceImpl$WidgetDataSetFactoryRelation">
|
||||
SELECT
|
||||
HCW_ID AS ${_iq_}widgetId${_iq_},
|
||||
DSF_ID AS ${_iq_}dataSetFactoryId${_iq_},
|
||||
DATA_SIGNS_TEXT AS ${_iq_}dataSignsText${_iq_},
|
||||
DSF_ORDER AS ${_iq_}order${_iq_}
|
||||
FROM
|
||||
DATAGEAR_HCW_DSF
|
||||
WHERE
|
||||
HCW_ID = #{widgetId}
|
||||
</select>
|
||||
|
||||
<sql id="queryViewDataPermission">
|
||||
<choose><when test="DP_CURRENT_USER == null">
|
||||
<include refid="queryView" />
|
||||
|
@ -166,8 +166,6 @@
|
|||
AND
|
||||
(
|
||||
${_iq_}name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.realName${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
</if>
|
||||
<include refid="common.queryCondition" />
|
||||
|
|
|
@ -94,11 +94,11 @@
|
|||
<insert id="insertDataSetRelation">
|
||||
INSERT INTO DATAGEAR_HD_DSF
|
||||
(
|
||||
HD_ID, DSF_ID, DSF_ORDER
|
||||
HD_ID, DS_ID, DS_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{widgetId}, #{dataSetFactoryId}, #{order}
|
||||
#{widgetId}, #{dataSetId}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
@ -154,8 +154,6 @@
|
|||
AND
|
||||
(
|
||||
${_iq_}name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.realName${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
</if>
|
||||
<include refid="common.queryCondition" />
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="org.datagear.management.domain.SqlDataSetFactoryEntity">
|
||||
<mapper namespace="org.datagear.management.domain.SqlDataSetEntity">
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO DATAGEAR_DATA_SET_FACTORY
|
||||
INSERT INTO DATAGEAR_SQL_DATA_SET
|
||||
(
|
||||
DSF_ID, DSF_NAME, DSF_SCHEMA_ID, DSF_SQL,
|
||||
DSF_CREATE_USER_ID, DSF_CREATE_TIME
|
||||
DS_ID, DS_NAME, DS_SCHEMA_ID, DS_SQL,
|
||||
DS_CREATE_USER_ID, DS_CREATE_TIME
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
|
@ -17,72 +17,72 @@
|
|||
</insert>
|
||||
|
||||
<insert id="insertPropertyPO">
|
||||
INSERT INTO DATAGEAR_DATA_SET_FACTORY_PROP
|
||||
INSERT INTO DATAGEAR_DATA_SET_PROP
|
||||
(
|
||||
PROP_DSF_ID, PROP_NAME, PROP_TYPE, PROP_LABEL, PROP_ORDER
|
||||
PROP_DS_ID, PROP_NAME, PROP_TYPE, PROP_LABEL, PROP_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{dataSetFactoryId}, #{child.name}, #{child.type}, #{child.label, jdbcType=VARCHAR}, #{order}
|
||||
#{dataSetId}, #{child.name}, #{child.type}, #{child.label, jdbcType=VARCHAR}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertParamPO">
|
||||
INSERT INTO DATAGEAR_DATA_SET_FACTORY_PAR
|
||||
INSERT INTO DATAGEAR_DATA_SET_PAR
|
||||
(
|
||||
PAR_DSF_ID, PAR_NAME, PAR_TYPE, PAR_REQUIRED, PAR_DEFAULT_VALUE, PAR_ORDER
|
||||
PAR_DS_ID, PAR_NAME, PAR_TYPE, PAR_REQUIRED, PAR_DEFAULT_VALUE, PAR_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{dataSetFactoryId}, #{child.name}, #{child.type}, #{child.required}, #{child.defaultValue, jdbcType=VARCHAR}, #{order}
|
||||
#{dataSetId}, #{child.name}, #{child.type}, #{child.required}, #{child.defaultValue, jdbcType=VARCHAR}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertExportPO">
|
||||
INSERT INTO DATAGEAR_DATA_SET_FACTORY_EXPT
|
||||
INSERT INTO DATAGEAR_DATA_SET_EXPT
|
||||
(
|
||||
EXPT_DSF_ID, EXPT_NAME, EXPT_TYPE, PROP_ORDER
|
||||
EXPT_DS_ID, EXPT_NAME, EXPT_TYPE, PROP_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{dataSetFactoryId}, #{child.name}, #{child.type}, #{order}
|
||||
#{dataSetId}, #{child.name}, #{child.type}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE DATAGEAR_DATA_SET_FACTORY SET
|
||||
DSF_NAME = #{entity.name},
|
||||
DSF_SCHEMA_ID = #{entity.schemaConnectionFactory.schema.id},
|
||||
DSF_SQL = #{entity.sql}
|
||||
UPDATE DATAGEAR_SQL_DATA_SET SET
|
||||
DS_NAME = #{entity.name},
|
||||
DS_SCHEMA_ID = #{entity.schemaConnectionFactory.schema.id},
|
||||
DS_SQL = #{entity.sql}
|
||||
WHERE
|
||||
DSF_ID = #{entity.id}
|
||||
DS_ID = #{entity.id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM DATAGEAR_DATA_SET_FACTORY
|
||||
DELETE FROM DATAGEAR_SQL_DATA_SET
|
||||
WHERE
|
||||
DSF_ID = #{id}
|
||||
DS_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePropertyPOs">
|
||||
DELETE FROM DATAGEAR_DATA_SET_FACTORY_PROP
|
||||
DELETE FROM DATAGEAR_DATA_SET_PROP
|
||||
WHERE
|
||||
PROP_DSF_ID = #{dataSetFactoryId}
|
||||
PROP_DS_ID = #{dataSetId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteParamPOs">
|
||||
DELETE FROM DATAGEAR_DATA_SET_FACTORY_PAR
|
||||
DELETE FROM DATAGEAR_DATA_SET_PAR
|
||||
WHERE
|
||||
PAR_DSF_ID = #{dataSetFactoryId}
|
||||
PAR_DS_ID = #{dataSetId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteExportPOs">
|
||||
DELETE FROM DATAGEAR_DATA_SET_FACTORY_EXPT
|
||||
DELETE FROM DATAGEAR_DATA_SET_EXPT
|
||||
WHERE
|
||||
EXPT_DSF_ID = #{dataSetFactoryId}
|
||||
EXPT_DS_ID = #{dataSetId}
|
||||
</delete>
|
||||
|
||||
<select id="getById" resultType="org.datagear.management.domain.SqlDataSetFactoryEntity">
|
||||
<select id="getById" resultType="org.datagear.management.domain.SqlDataSetEntity">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
|
@ -91,47 +91,47 @@
|
|||
T.${_iq_}id${_iq_} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getPropertyPOs" resultType="org.datagear.management.service.impl.SqlDataSetFactoryEntityServiceImpl$DataSetPropertyPO">
|
||||
<select id="getPropertyPOs" resultType="org.datagear.management.service.impl.SqlDataSetEntityServiceImpl$DataSetPropertyPO">
|
||||
SELECT
|
||||
PROP_DSF_ID AS ${_iq_}dataSetFactoryId${_iq_},
|
||||
PROP_DS_ID AS ${_iq_}dataSetId${_iq_},
|
||||
PROP_NAME AS ${_iq_}child.name${_iq_},
|
||||
PROP_TYPE AS ${_iq_}child.type${_iq_},
|
||||
PROP_LABEL AS ${_iq_}child.label${_iq_},
|
||||
PROP_ORDER AS ${_iq_}order${_iq_}
|
||||
FROM
|
||||
DATAGEAR_DATA_SET_FACTORY_PROP
|
||||
DATAGEAR_DATA_SET_PROP
|
||||
WHERE
|
||||
PROP_DSF_ID = #{dataSetFactoryId}
|
||||
PROP_DS_ID = #{dataSetId}
|
||||
ORDER BY
|
||||
PROP_ORDER ASC
|
||||
</select>
|
||||
|
||||
<select id="getParamPOs" resultType="org.datagear.management.service.impl.SqlDataSetFactoryEntityServiceImpl$DataSetParamPO">
|
||||
<select id="getParamPOs" resultType="org.datagear.management.service.impl.SqlDataSetEntityServiceImpl$DataSetParamPO">
|
||||
SELECT
|
||||
PAR_DSF_ID AS ${_iq_}dataSetFactoryId${_iq_},
|
||||
PAR_DS_ID AS ${_iq_}dataSetId${_iq_},
|
||||
PAR_NAME AS ${_iq_}child.name${_iq_},
|
||||
PAR_TYPE AS ${_iq_}child.type${_iq_},
|
||||
PAR_REQUIRED AS ${_iq_}child.required${_iq_},
|
||||
PAR_DEFAULT_VALUE AS ${_iq_}child.defaultValue${_iq_},
|
||||
PAR_ORDER AS ${_iq_}order${_iq_}
|
||||
FROM
|
||||
DATAGEAR_DATA_SET_FACTORY_PAR
|
||||
DATAGEAR_DATA_SET_PAR
|
||||
WHERE
|
||||
PAR_DSF_ID = #{dataSetFactoryId}
|
||||
PAR_DS_ID = #{dataSetId}
|
||||
ORDER BY
|
||||
PAR_ORDER ASC
|
||||
</select>
|
||||
|
||||
<select id="getExportPOs" resultType="org.datagear.management.service.impl.SqlDataSetFactoryEntityServiceImpl$DataSetExportPO">
|
||||
<select id="getExportPOs" resultType="org.datagear.management.service.impl.SqlDataSetEntityServiceImpl$DataSetExportPO">
|
||||
SELECT
|
||||
EXPT_DSF_ID AS ${_iq_}dataSetFactoryId${_iq_},
|
||||
EXPT_DS_ID AS ${_iq_}dataSetId${_iq_},
|
||||
EXPT_NAME AS ${_iq_}child.name${_iq_},
|
||||
EXPT_TYPE AS ${_iq_}child.type${_iq_},
|
||||
EXPT_ORDER AS ${_iq_}order${_iq_}
|
||||
FROM
|
||||
DATAGEAR_DATA_SET_FACTORY_EXPT
|
||||
DATAGEAR_DATA_SET_EXPT
|
||||
WHERE
|
||||
EXPT_DSF_ID = #{dataSetFactoryId}
|
||||
EXPT_DS_ID = #{dataSetId}
|
||||
ORDER BY
|
||||
EXPT_ORDER ASC
|
||||
</select>
|
||||
|
@ -150,7 +150,7 @@
|
|||
<foreach item="item" collection="ids" separator=" OR ">T.DATA_ID = #{item}</foreach>
|
||||
</select>
|
||||
|
||||
<select id="query" resultType="org.datagear.management.domain.SqlDataSetFactoryEntity">
|
||||
<select id="query" resultType="org.datagear.management.domain.SqlDataSetEntity">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
|
@ -169,7 +169,7 @@
|
|||
<include refid="queryCondition" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQuery" resultType="org.datagear.management.domain.SqlDataSetFactoryEntity">
|
||||
<select id="pagingQuery" resultType="org.datagear.management.domain.SqlDataSetEntity">
|
||||
<include refid="common.pagingQueryHead" />
|
||||
SELECT
|
||||
T.*
|
||||
|
@ -205,31 +205,31 @@
|
|||
|
||||
<sql id="queryViewDataPermissionId">
|
||||
SELECT
|
||||
A.DSF_ID AS DP_AUTH_DATA_ID,
|
||||
A.DSF_CREATE_USER_ID AS DP_AUTH_DATA_CREATOR_ID
|
||||
A.DS_ID AS DP_AUTH_DATA_ID,
|
||||
A.DS_CREATE_USER_ID AS DP_AUTH_DATA_CREATOR_ID
|
||||
FROM
|
||||
DATAGEAR_DATA_SET_FACTORY A
|
||||
DATAGEAR_SQL_DATA_SET A
|
||||
</sql>
|
||||
|
||||
<sql id="queryView">
|
||||
SELECT
|
||||
A.DSF_ID AS ${_iq_}id${_iq_},
|
||||
A.DSF_NAME AS ${_iq_}name${_iq_},
|
||||
A.DS_ID AS ${_iq_}id${_iq_},
|
||||
A.DS_NAME AS ${_iq_}name${_iq_},
|
||||
B.SCHEMA_ID AS ${_iq_}schemaConnectionFactory.schema.id${_iq_},
|
||||
B.SCHEMA_TITLE AS ${_iq_}schemaConnectionFactory.schema.title${_iq_},
|
||||
A.DSF_SQL AS ${_iq_}sql${_iq_},
|
||||
A.DS_SQL AS ${_iq_}sql${_iq_},
|
||||
<include refid="common.fieldsForCreateUser" />,
|
||||
A.DSF_CREATE_TIME AS ${_iq_}createTime${_iq_}
|
||||
A.DS_CREATE_TIME AS ${_iq_}createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_DATA_SET_FACTORY A
|
||||
DATAGEAR_SQL_DATA_SET A
|
||||
INNER JOIN
|
||||
DATAGEAR_SCHEMA B
|
||||
ON
|
||||
A.DSF_SCHEMA_ID = B.SCHEMA_ID
|
||||
A.DS_SCHEMA_ID = B.SCHEMA_ID
|
||||
LEFT JOIN
|
||||
DATAGEAR_USER USR
|
||||
ON
|
||||
A.DSF_CREATE_USER_ID = USR.USER_ID
|
||||
A.DS_CREATE_USER_ID = USR.USER_ID
|
||||
</sql>
|
||||
|
||||
<sql id="queryCondition">
|
||||
|
@ -238,9 +238,6 @@
|
|||
AND
|
||||
(
|
||||
${_iq_}name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}schemaConnectionFactory.schema.title${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.realName${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
</if>
|
||||
<include refid="common.queryCondition" />
|
||||
|
|
|
@ -11,12 +11,18 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.DataSign;
|
||||
import org.datagear.analysis.Icon;
|
||||
import org.datagear.analysis.RenderException;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.AbstractChartPlugin;
|
||||
import org.datagear.analysis.support.html.DirectoryHtmlChartPluginManager;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
|
@ -61,15 +67,15 @@ public class AbstractChartPluginAwareController extends AbstractDataAnalysisCont
|
|||
}
|
||||
|
||||
/**
|
||||
* 查找插件信息列表。
|
||||
* 查找插件视图对象列表。
|
||||
*
|
||||
* @param request
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
protected List<HtmlChartPluginInfo> findHtmlChartPluginInfos(HttpServletRequest request, String keyword)
|
||||
protected List<HtmlChartPluginVO> findHtmlChartPluginVOs(HttpServletRequest request, String keyword)
|
||||
{
|
||||
List<HtmlChartPluginInfo> pluginInfos = new ArrayList<HtmlChartPluginInfo>();
|
||||
List<HtmlChartPluginVO> pluginViews = new ArrayList<HtmlChartPluginVO>();
|
||||
|
||||
List<ChartPlugin<HtmlRenderContext>> plugins = getDirectoryHtmlChartPluginManager()
|
||||
.getAll(HtmlRenderContext.class);
|
||||
|
@ -84,49 +90,71 @@ public class AbstractChartPluginAwareController extends AbstractDataAnalysisCont
|
|||
if (plugin instanceof HtmlChartPlugin<?>)
|
||||
{
|
||||
HtmlChartPlugin<HtmlRenderContext> htmlChartPlugin = (HtmlChartPlugin<HtmlRenderContext>) plugin;
|
||||
pluginInfos.add(toHtmlChartPluginInfo(htmlChartPlugin, renderStyle, locale));
|
||||
pluginViews.add(toHtmlChartPluginVO(htmlChartPlugin, renderStyle, locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return KeywordMatcher.<HtmlChartPluginInfo> match(pluginInfos, keyword,
|
||||
new KeywordMatcher.MatchValue<HtmlChartPluginInfo>()
|
||||
return KeywordMatcher.<HtmlChartPluginVO> match(pluginViews, keyword,
|
||||
new KeywordMatcher.MatchValue<HtmlChartPluginVO>()
|
||||
{
|
||||
@Override
|
||||
public String[] get(HtmlChartPluginInfo t)
|
||||
public String[] get(HtmlChartPluginVO t)
|
||||
{
|
||||
return new String[] { t.getName(), t.getDesc() };
|
||||
return new String[] { (t.getNameLabel() == null ? null : t.getNameLabel().getValue()),
|
||||
(t.getDescLabel() == null ? null : t.getDescLabel().getValue()) };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected HtmlChartPluginInfo toHtmlChartPluginInfo(HtmlChartPlugin<?> chartPlugin, RenderStyle renderStyle,
|
||||
protected HtmlChartPluginVO toHtmlChartPluginVO(HtmlChartPlugin<?> chartPlugin, RenderStyle renderStyle,
|
||||
Locale locale)
|
||||
{
|
||||
HtmlChartPluginInfo pluginInfo = new HtmlChartPluginInfo();
|
||||
HtmlChartPluginVO pluginVO = new HtmlChartPluginVO();
|
||||
|
||||
pluginInfo.setId(chartPlugin.getId());
|
||||
pluginVO.setId(chartPlugin.getId());
|
||||
|
||||
Label nameLabel = chartPlugin.getNameLabel();
|
||||
if (nameLabel != null)
|
||||
pluginInfo.setName(nameLabel.getValue(locale));
|
||||
|
||||
Label descLabel = chartPlugin.getDescLabel();
|
||||
if (descLabel != null)
|
||||
pluginInfo.setDesc(descLabel.getValue(locale));
|
||||
|
||||
Label manualLabel = chartPlugin.getManualLabel();
|
||||
if (manualLabel != null)
|
||||
pluginInfo.setManual(manualLabel.getValue(locale));
|
||||
pluginVO.setNameLabel(toConcreteLabel(chartPlugin.getNameLabel(), locale));
|
||||
pluginVO.setDescLabel(toConcreteLabel(chartPlugin.getDescLabel(), locale));
|
||||
pluginVO.setManualLabel(toConcreteLabel(chartPlugin.getManualLabel(), locale));
|
||||
|
||||
Icon icon = chartPlugin.getIcon(renderStyle);
|
||||
pluginInfo.setHasIcon(icon != null);
|
||||
if (pluginInfo.isHasIcon())
|
||||
pluginInfo.setIconUrl(resolveIconUrl(chartPlugin));
|
||||
pluginVO.setHasIcon(icon != null);
|
||||
if (pluginVO.isHasIcon())
|
||||
pluginVO.setIconUrl(resolveIconUrl(chartPlugin));
|
||||
|
||||
pluginInfo.setVersion(chartPlugin.getVersion());
|
||||
pluginVO.setVersion(chartPlugin.getVersion());
|
||||
|
||||
return pluginInfo;
|
||||
List<DataSign> dataSigns = chartPlugin.getDataSigns();
|
||||
if (dataSigns != null)
|
||||
{
|
||||
List<DataSign> dataSignVOs = new ArrayList<DataSign>(dataSigns.size());
|
||||
for (DataSign dataSign : dataSigns)
|
||||
{
|
||||
DataSign view = new DataSign(dataSign.getName(), dataSign.isOccurRequired(),
|
||||
dataSign.isOccurMultiple());
|
||||
view.setNameLabel(toConcreteLabel(dataSign.getNameLabel(), locale));
|
||||
view.setDescLabel(toConcreteLabel(dataSign.getDescLabel(), locale));
|
||||
|
||||
dataSignVOs.add(view);
|
||||
}
|
||||
|
||||
pluginVO.setDataSigns(dataSignVOs);
|
||||
}
|
||||
|
||||
return pluginVO;
|
||||
}
|
||||
|
||||
protected Label toConcreteLabel(Label label, Locale locale)
|
||||
{
|
||||
if (label == null)
|
||||
return null;
|
||||
|
||||
String value = label.getValue(locale);
|
||||
if (value == null)
|
||||
value = "";
|
||||
|
||||
return new Label(value);
|
||||
}
|
||||
|
||||
protected String resolveIconUrl(HtmlChartPlugin<?> plugin)
|
||||
|
@ -134,74 +162,28 @@ public class AbstractChartPluginAwareController extends AbstractDataAnalysisCont
|
|||
return "/analysis/chartPlugin/icon/" + plugin.getId();
|
||||
}
|
||||
|
||||
public static class HtmlChartPluginInfo implements Serializable
|
||||
/**
|
||||
* {@linkplain HtmlChartPlugin}视图对象。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public static class HtmlChartPluginVO extends AbstractChartPlugin<HtmlRenderContext> implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String desc;
|
||||
|
||||
private String manual;
|
||||
|
||||
private boolean hasIcon;
|
||||
|
||||
private String iconUrl;
|
||||
|
||||
private String version;
|
||||
|
||||
public HtmlChartPluginInfo()
|
||||
public HtmlChartPluginVO()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public HtmlChartPluginInfo(String id, String name)
|
||||
public HtmlChartPluginVO(String id, Label nameLabel)
|
||||
{
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDesc()
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc)
|
||||
{
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getManual()
|
||||
{
|
||||
return manual;
|
||||
}
|
||||
|
||||
public void setManual(String manual)
|
||||
{
|
||||
this.manual = manual;
|
||||
super(id, nameLabel);
|
||||
}
|
||||
|
||||
public boolean isHasIcon()
|
||||
|
@ -224,14 +206,11 @@ public class AbstractChartPluginAwareController extends AbstractDataAnalysisCont
|
|||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
@Override
|
||||
public Chart renderChart(HtmlRenderContext renderContext, Map<String, ?> chartPropertyValues,
|
||||
ChartDataSet... chartDataSets) throws RenderException
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
this.version = version;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.datagear.persistence.PersistenceManager;
|
|||
import org.datagear.util.StringUtil;
|
||||
import org.datagear.web.OperationMessage;
|
||||
import org.datagear.web.convert.ClassDataConverter;
|
||||
import org.datagear.web.freemarker.WriteJsonTemplateDirectiveModel;
|
||||
import org.datagear.web.util.WebUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
@ -25,6 +26,8 @@ import org.springframework.context.NoSuchMessageException;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import freemarker.template.TemplateModel;
|
||||
|
||||
/**
|
||||
* 抽象控制器。
|
||||
*
|
||||
|
@ -564,6 +567,17 @@ public abstract class AbstractController
|
|||
return operationMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转换为可作为页面使用<code><@writeJson var=... /></code>的对象。
|
||||
*
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
protected TemplateModel toWriteJsonTemplateModel(Object object)
|
||||
{
|
||||
return WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断对象、字符串、数组、集合、Map是否为空。
|
||||
*
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
package org.datagear.web.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.datagear.analysis.ChartDataSetFactory;
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPluginManager;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
import org.datagear.management.domain.HtmlChartWidgetEntity;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
import org.datagear.management.domain.SqlDataSetEntity;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.HtmlChartWidgetEntityService;
|
||||
import org.datagear.persistence.PagingData;
|
||||
|
@ -84,17 +85,17 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
{
|
||||
HtmlChartWidgetEntity chart = new HtmlChartWidgetEntity();
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = findHtmlChartPluginInfos(request, null);
|
||||
List<HtmlChartPluginVO> pluginVOs = findHtmlChartPluginVOs(request, null);
|
||||
|
||||
if (pluginInfos.size() > 0)
|
||||
if (pluginVOs.size() > 0)
|
||||
{
|
||||
String defaultChartPluginId = pluginInfos.get(0).getId();
|
||||
String defaultChartPluginId = pluginVOs.get(0).getId();
|
||||
chart.setHtmlChartPlugin((HtmlChartPlugin<HtmlRenderContext>) this.chartPluginManager
|
||||
.<HtmlRenderContext> get(defaultChartPluginId));
|
||||
}
|
||||
|
||||
model.addAttribute("chart", chart);
|
||||
model.addAttribute("pluginInfos", pluginInfos);
|
||||
model.addAttribute("pluginVOs", toWriteJsonTemplateModel(pluginVOs));
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.addChart");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
|
||||
|
||||
|
@ -130,10 +131,10 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
if (chart == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = findHtmlChartPluginInfos(request, null);
|
||||
List<HtmlChartPluginVO> pluginVOs = findHtmlChartPluginVOs(request, null);
|
||||
|
||||
model.addAttribute("chart", chart);
|
||||
model.addAttribute("pluginInfos", pluginInfos);
|
||||
model.addAttribute("pluginVOs", toWriteJsonTemplateModel(pluginVOs));
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.editChart");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveEdit");
|
||||
|
||||
|
@ -147,8 +148,6 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
entity.setId(IDUtil.uuid());
|
||||
entity.setCreateUser(user);
|
||||
inflateHtmlChartWidgetEntity(entity, request);
|
||||
|
||||
checkSaveEntity(entity);
|
||||
|
@ -169,10 +168,10 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
if (chart == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = findHtmlChartPluginInfos(request, null);
|
||||
List<HtmlChartPluginVO> pluginVOs = findHtmlChartPluginVOs(request, null);
|
||||
|
||||
model.addAttribute("chart", chart);
|
||||
model.addAttribute("pluginInfos", pluginInfos);
|
||||
model.addAttribute("pluginVOs", toWriteJsonTemplateModel(pluginVOs));
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.viewChart");
|
||||
model.addAttribute(KEY_READONLY, true);
|
||||
|
||||
|
@ -222,10 +221,22 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
PagingQuery pagingQuery = getPagingQuery(request);
|
||||
|
||||
PagingData<HtmlChartWidgetEntity> pagingData = this.htmlChartWidgetEntityService.pagingQuery(user, pagingQuery);
|
||||
setChartPluginNames(request, pagingData.getItems());
|
||||
|
||||
return pagingData;
|
||||
}
|
||||
|
||||
protected void setChartPluginNames(HttpServletRequest request, List<HtmlChartWidgetEntity> entities)
|
||||
{
|
||||
if (entities == null)
|
||||
return;
|
||||
|
||||
Locale locale = WebUtils.getLocale(request);
|
||||
|
||||
for (HtmlChartWidgetEntity entity : entities)
|
||||
entity.updateChartPluginName(locale);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected void inflateHtmlChartWidgetEntity(HtmlChartWidgetEntity entity, HttpServletRequest request)
|
||||
{
|
||||
|
@ -239,33 +250,34 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
entity.setHtmlChartPlugin(htmlChartPlugin);
|
||||
}
|
||||
|
||||
inflateChartDataSetFactories(entity, request);
|
||||
inflateChartDataSets(entity, request);
|
||||
}
|
||||
|
||||
protected void inflateChartDataSetFactories(HtmlChartWidgetEntity entity, HttpServletRequest request)
|
||||
protected void inflateChartDataSets(HtmlChartWidgetEntity entity, HttpServletRequest request)
|
||||
{
|
||||
String[] dataSetIds = request.getParameterValues("dataSetId");
|
||||
|
||||
if (dataSetIds == null || dataSetIds.length == 0)
|
||||
return;
|
||||
|
||||
ChartDataSetFactory[] chartDataSetFactories = new ChartDataSetFactory[dataSetIds.length];
|
||||
ChartDataSet[] chartDataSets = new ChartDataSet[dataSetIds.length];
|
||||
|
||||
for (int i = 0; i < dataSetIds.length; i++)
|
||||
{
|
||||
String myDataSignParam = "dataSign_" + i;
|
||||
String[] myDataSigns = request.getParameterValues(myDataSignParam);
|
||||
|
||||
SqlDataSetFactoryEntity sqlDataSetFactory = new SqlDataSetFactoryEntity();
|
||||
sqlDataSetFactory.setId(dataSetIds[i]);
|
||||
SqlDataSetEntity sqlDataSet = new SqlDataSetEntity();
|
||||
sqlDataSet.setId(dataSetIds[i]);
|
||||
|
||||
ChartDataSetFactory chartDataSetFactory = new ChartDataSetFactory();
|
||||
ChartDataSet chartDataSet = new ChartDataSet();
|
||||
|
||||
chartDataSetFactory.setDataSetFactory(sqlDataSetFactory);
|
||||
chartDataSetFactory.setDataSigns(entity.getChartPlugin(), myDataSigns);
|
||||
chartDataSet.setDataSet(sqlDataSet);
|
||||
|
||||
chartDataSets[i] = chartDataSet;
|
||||
}
|
||||
|
||||
entity.setChartDataSetFactories(chartDataSetFactories);
|
||||
entity.setChartDataSets(chartDataSets);
|
||||
}
|
||||
|
||||
protected void checkSaveEntity(HtmlChartWidgetEntity chart)
|
||||
|
|
|
@ -116,7 +116,7 @@ public class ChartPluginController extends AbstractChartPluginAwareController
|
|||
IOUtil.close(out);
|
||||
}
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = new ArrayList<HtmlChartPluginInfo>();
|
||||
List<HtmlChartPluginVO> pluginInfos = new ArrayList<HtmlChartPluginVO>();
|
||||
|
||||
HtmlChartPluginLoader loader = getDirectoryHtmlChartPluginManager().getHtmlChartPluginLoader();
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class ChartPluginController extends AbstractChartPluginAwareController
|
|||
Set<HtmlChartPlugin<?>> loaded = loader.loads(zipFile);
|
||||
|
||||
for (HtmlChartPlugin<?> chartPlugin : loaded)
|
||||
pluginInfos.add(toHtmlChartPluginInfo(chartPlugin, renderStyle, locale));
|
||||
pluginInfos.add(toHtmlChartPluginVO(chartPlugin, renderStyle, locale));
|
||||
}
|
||||
catch (HtmlChartPluginLoadException e)
|
||||
{
|
||||
|
@ -196,11 +196,11 @@ public class ChartPluginController extends AbstractChartPluginAwareController
|
|||
|
||||
@RequestMapping(value = "/queryData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public List<HtmlChartPluginInfo> queryData(HttpServletRequest request, HttpServletResponse response,
|
||||
public List<HtmlChartPluginVO> queryData(HttpServletRequest request, HttpServletResponse response,
|
||||
final org.springframework.ui.Model springModel,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) throws Exception
|
||||
{
|
||||
return findHtmlChartPluginInfos(request, keyword);
|
||||
return findHtmlChartPluginVOs(request, keyword);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/icon/{pluginId}", produces = CONTENT_TYPE_JSON)
|
||||
|
|
|
@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.datagear.analysis.DataSet;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.html.DefaultHtmlRenderContext;
|
||||
import org.datagear.analysis.support.html.HtmlDashboard;
|
||||
|
@ -459,7 +459,7 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
*/
|
||||
@RequestMapping(value = "/showData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public Map<String, DataSet[]> showData(HttpServletRequest request, HttpServletResponse response,
|
||||
public Map<String, DataSetResult[]> showData(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model model) throws Exception
|
||||
{
|
||||
WebContext webContext = createWebContext(request);
|
||||
|
@ -479,9 +479,9 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
Map<String, ?> dataSetParamValues = new HashMap<String, Object>();
|
||||
|
||||
if (chartsId == null || chartsId.length == 0)
|
||||
return dashboard.getDataSets(dataSetParamValues);
|
||||
return dashboard.getDataSetResults(dataSetParamValues);
|
||||
else
|
||||
return dashboard.getDataSets(Arrays.asList(chartsId), dataSetParamValues);
|
||||
return dashboard.getDataSetResults(Arrays.asList(chartsId), dataSetParamValues);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,17 +13,17 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.datagear.analysis.DataSetProperty;
|
||||
import org.datagear.analysis.DataType;
|
||||
import org.datagear.analysis.support.AbstractDataSetFactory;
|
||||
import org.datagear.analysis.support.AbstractDataSet;
|
||||
import org.datagear.analysis.support.SqlDataSetSupport;
|
||||
import org.datagear.connection.ConnectionSource;
|
||||
import org.datagear.dbmodel.DatabaseModelResolver;
|
||||
import org.datagear.dbmodel.ModelSqlSelectService;
|
||||
import org.datagear.dbmodel.ModelSqlSelectService.ModelSqlResult;
|
||||
import org.datagear.management.domain.Schema;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
import org.datagear.management.domain.SqlDataSetEntity;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.SchemaService;
|
||||
import org.datagear.management.service.SqlDataSetFactoryEntityService;
|
||||
import org.datagear.management.service.SqlDataSetEntityService;
|
||||
import org.datagear.model.Model;
|
||||
import org.datagear.model.Property;
|
||||
import org.datagear.persistence.PagingData;
|
||||
|
@ -58,7 +58,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
public static final String DATA_SET_PROPERTY_LABELS_SPLITTER = ",";
|
||||
|
||||
@Autowired
|
||||
private SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService;
|
||||
private SqlDataSetEntityService sqlDataSetEntityService;
|
||||
|
||||
@Autowired
|
||||
private ModelSqlSelectService modelSqlSelectService;
|
||||
|
@ -75,24 +75,24 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
|
||||
public DataSetController(MessageSource messageSource, ClassDataConverter classDataConverter,
|
||||
SchemaService schemaService, ConnectionSource connectionSource,
|
||||
SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService, ModelSqlSelectService modelSqlSelectService,
|
||||
SqlDataSetEntityService sqlDataSetEntityService, ModelSqlSelectService modelSqlSelectService,
|
||||
DatabaseModelResolver databaseModelResolver)
|
||||
{
|
||||
super(messageSource, classDataConverter, schemaService, connectionSource);
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.sqlDataSetEntityService = sqlDataSetEntityService;
|
||||
this.modelSqlSelectService = modelSqlSelectService;
|
||||
this.databaseModelResolver = databaseModelResolver;
|
||||
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntityService getSqlDataSetFactoryEntityService()
|
||||
public SqlDataSetEntityService getSqlDataSetEntityService()
|
||||
{
|
||||
return sqlDataSetFactoryEntityService;
|
||||
return sqlDataSetEntityService;
|
||||
}
|
||||
|
||||
public void setSqlDataSetFactoryEntityService(SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService)
|
||||
public void setSqlDataSetEntityService(SqlDataSetEntityService sqlDataSetEntityService)
|
||||
{
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.sqlDataSetEntityService = sqlDataSetEntityService;
|
||||
}
|
||||
|
||||
public ModelSqlSelectService getModelSqlSelectService()
|
||||
|
@ -128,7 +128,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
@RequestMapping("/add")
|
||||
public String add(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
SqlDataSetFactoryEntity dataSet = new SqlDataSetFactoryEntity();
|
||||
SqlDataSetEntity dataSet = new SqlDataSetEntity();
|
||||
|
||||
model.addAttribute("dataSet", dataSet);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dataSet.addDataSet");
|
||||
|
@ -140,7 +140,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
@RequestMapping(value = "/saveAdd", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveAdd(HttpServletRequest request, HttpServletResponse response,
|
||||
SqlDataSetFactoryEntity dataSet)
|
||||
SqlDataSetEntity dataSet)
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
|
||||
checkSaveEntity(dataSet);
|
||||
|
||||
this.sqlDataSetFactoryEntityService.add(user, dataSet);
|
||||
this.sqlDataSetEntityService.add(user, dataSet);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
SqlDataSetFactoryEntity dataSet = this.sqlDataSetFactoryEntityService.getByIdForEdit(user, id);
|
||||
SqlDataSetEntity dataSet = this.sqlDataSetEntityService.getByIdForEdit(user, id);
|
||||
|
||||
if (dataSet == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
@ -178,7 +178,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
@RequestMapping(value = "/saveEdit", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveEdit(HttpServletRequest request, HttpServletResponse response,
|
||||
SqlDataSetFactoryEntity dataSet)
|
||||
SqlDataSetEntity dataSet)
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
|
||||
checkSaveEntity(dataSet);
|
||||
|
||||
this.sqlDataSetFactoryEntityService.update(user, dataSet);
|
||||
this.sqlDataSetEntityService.update(user, dataSet);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
SqlDataSetFactoryEntity dataSet = this.sqlDataSetFactoryEntityService.getById(user, id);
|
||||
SqlDataSetEntity dataSet = this.sqlDataSetEntityService.getById(user, id);
|
||||
|
||||
if (dataSet == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
@ -211,6 +211,46 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
return "/analysis/dataSet/dataSet_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getById", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public SqlDataSetEntity getById(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model model, @RequestParam("id") String id)
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
SqlDataSetEntity dataSet = this.sqlDataSetEntityService.getById(user, id);
|
||||
|
||||
if (dataSet == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getByIds", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public List<SqlDataSetEntity> getByIds(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model model, @RequestParam("id") String[] ids)
|
||||
{
|
||||
List<SqlDataSetEntity> dataSets = new ArrayList<SqlDataSetEntity>();
|
||||
|
||||
if (!isEmpty(ids))
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
for (String id : ids)
|
||||
{
|
||||
SqlDataSetEntity dataSet = this.sqlDataSetEntityService.getById(user, id);
|
||||
|
||||
if (dataSet == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
dataSets.add(dataSet);
|
||||
}
|
||||
}
|
||||
|
||||
return dataSets;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> delete(HttpServletRequest request, HttpServletResponse response,
|
||||
|
@ -221,7 +261,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
for (int i = 0; i < ids.length; i++)
|
||||
{
|
||||
String id = ids[i];
|
||||
this.sqlDataSetFactoryEntityService.deleteById(user, id);
|
||||
this.sqlDataSetEntityService.deleteById(user, id);
|
||||
}
|
||||
|
||||
return buildOperationMessageDeleteSuccessResponseEntity(request);
|
||||
|
@ -251,15 +291,14 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
|
||||
@RequestMapping(value = "/pagingQueryData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public PagingData<SqlDataSetFactoryEntity> pagingQueryData(HttpServletRequest request, HttpServletResponse response,
|
||||
public PagingData<SqlDataSetEntity> pagingQueryData(HttpServletRequest request, HttpServletResponse response,
|
||||
final org.springframework.ui.Model springModel) throws Exception
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
PagingQuery pagingQuery = getPagingQuery(request, WebUtils.COOKIE_PAGINATION_SIZE);
|
||||
|
||||
PagingData<SqlDataSetFactoryEntity> pagingData = this.sqlDataSetFactoryEntityService.pagingQuery(user,
|
||||
pagingQuery);
|
||||
PagingData<SqlDataSetEntity> pagingData = this.sqlDataSetEntityService.pagingQuery(user, pagingQuery);
|
||||
|
||||
return pagingData;
|
||||
}
|
||||
|
@ -328,7 +367,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
return modelSqlResult;
|
||||
}
|
||||
|
||||
protected void inflateDataSetProperties(HttpServletRequest request, AbstractDataSetFactory dataSetFactory)
|
||||
protected void inflateDataSetProperties(HttpServletRequest request, AbstractDataSet dataSet)
|
||||
{
|
||||
String labelsText = request.getParameter("dataSetPropertyLabelsText");
|
||||
if (labelsText == null)
|
||||
|
@ -354,7 +393,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
dataSetProperties.add(dataSetProperty);
|
||||
}
|
||||
|
||||
dataSetFactory.setProperties(dataSetProperties);
|
||||
dataSet.setProperties(dataSetProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -402,7 +441,7 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
return dataSetProperties;
|
||||
}
|
||||
|
||||
protected void checkSaveEntity(SqlDataSetFactoryEntity dataSet)
|
||||
protected void checkSaveEntity(SqlDataSetEntity dataSet)
|
||||
{
|
||||
if (isBlank(dataSet.getName()))
|
||||
throw new IllegalInputException();
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
id : 'datagear-chart-line',
|
||||
nameLabel : '折线图',
|
||||
descLabel : '折线图',
|
||||
dataSigns :
|
||||
[
|
||||
{ name : "x-value", nameLabel : "横坐标" },
|
||||
{ name : "y-value", nameLabel : "纵坐标" },
|
||||
],
|
||||
version: "0.1.0",
|
||||
order : 0
|
||||
}
|
|
@ -313,7 +313,7 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="sqlDataSetFactoryEntityService" class="org.datagear.management.service.impl.SqlDataSetFactoryEntityServiceImpl">
|
||||
<bean id="sqlDataSetEntityService" class="org.datagear.management.service.impl.SqlDataSetEntityServiceImpl">
|
||||
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
|
||||
<property name="connectionSource" ref="connectionSource" />
|
||||
<property name="schemaService" ref="schemaService" />
|
||||
|
@ -327,7 +327,7 @@
|
|||
<bean id="htmlChartWidgetEntityService" class="org.datagear.management.service.impl.HtmlChartWidgetEntityServiceImpl">
|
||||
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
|
||||
<property name="chartPluginManager" ref="directoryHtmlChartPluginManager" />
|
||||
<property name="sqlDataSetFactoryEntityService" ref="sqlDataSetFactoryEntityService" />
|
||||
<property name="sqlDataSetEntityService" ref="sqlDataSetEntityService" />
|
||||
<property name="authorizationService" ref="authorizationService" />
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -637,7 +637,7 @@ chart.viewChart=\u67E5\u770B\u56FE\u8868
|
|||
chart.selectChart=\u9009\u62E9\u56FE\u8868
|
||||
chart.name=\u540D\u79F0
|
||||
chart.htmlChartPlugin=\u56FE\u8868\u7C7B\u578B
|
||||
chart.sqlDataSetFactoryEntities=\u6570\u636E\u96C6
|
||||
chart.chartDataSets=\u6570\u636E\u96C6
|
||||
chart.updateInterval=\u66F4\u65B0\u95F4\u9694
|
||||
chart.createUser=\u521B\u5EFA\u7528\u6237
|
||||
chart.createTime=\u521B\u5EFA\u65F6\u95F4
|
||||
|
|
|
@ -33,30 +33,21 @@ readonly 是否只读操作,允许为null
|
|||
</div>
|
||||
<div class="form-item-value">
|
||||
<ul class="chart-plugin-list ui-widget ui-helper-clearfix">
|
||||
<#list pluginInfos as pi>
|
||||
<li class="ui-state-default ui-corner-all" chart-plugin-id="${pi.id?html}" title="${pi.name?html}">
|
||||
<#if pi.hasIcon>
|
||||
<a class="plugin-icon" style="background-image: url(${contextPath}/${pi.iconUrl})"> </a>
|
||||
<#else>
|
||||
<a class="plugin-name">${pi.name?html}</a>
|
||||
</#if>
|
||||
</li>
|
||||
</#list>
|
||||
</ul>
|
||||
<input type="hidden" name="htmlChartPlugin.id" class="ui-widget ui-widget-content" value="${(chart.htmlChartPlugin.id)!''?html}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='chart.sqlDataSetFactoryEntities' /></label>
|
||||
<label><@spring.message code='chart.chartDataSets' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="data-set-wrapper ui-widget ui-widget-content ui-corner-all">
|
||||
<#if (chart.sqlDataSetFactoryEntities)??>
|
||||
<#list chart.sqlDataSetFactoryEntities as ds>
|
||||
<#if (chart.chartDataSets)??>
|
||||
<#list chart.chartDataSets as cds>
|
||||
<div class='data-set-item ui-widget ui-widget-content ui-corner-all ui-state-default'>
|
||||
<input type='hidden' name='dataSetId' value="${ds.id?html}" />
|
||||
<span class='data-set-name'>${ds.name?html}</span>
|
||||
<input type='hidden' name='dataSetId' value="${(cds.dataSet.id)!''?html}" />
|
||||
<span class='data-set-name'>${(cds.dataSet.name)!''?html}</span>
|
||||
<#if !readonly>
|
||||
<div class='delete-icon'><span class=' ui-icon ui-icon-close'> </span></div>
|
||||
</#if>
|
||||
|
@ -67,6 +58,10 @@ readonly 是否只读操作,允许为null
|
|||
<#if !readonly>
|
||||
<button type="button" class="add-data-set-button"><@spring.message code='add' /></button>
|
||||
</#if>
|
||||
<div class='data-sign-select-panel ui-widget ui-widget-content ui-corner-all ui-front ui-widget-shadow'>
|
||||
<div class="select-panel-head ui-widget-header ui-corner-all">选择数据标记</div>
|
||||
<div class="select-panel-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
|
@ -93,7 +88,84 @@ readonly 是否只读操作,允许为null
|
|||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element());
|
||||
|
||||
po.chartPluginVOs = <@writeJson var=pluginVOs />;
|
||||
|
||||
po.getChartPlugin = function(id)
|
||||
{
|
||||
if(!po.chartPluginVOs)
|
||||
return;
|
||||
|
||||
for(var i=0; i<po.chartPluginVOs.length; i++)
|
||||
{
|
||||
var cp = po.chartPluginVOs[i];
|
||||
if(cp.id == id)
|
||||
return cp;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
po.getCurrentChartPlugin = function()
|
||||
{
|
||||
var id = po.element("input[name='htmlChartPlugin.id']").val();
|
||||
return po.getChartPlugin(id);
|
||||
};
|
||||
|
||||
po.initChartPluginList = function()
|
||||
{
|
||||
if(!po.chartPluginVOs)
|
||||
return;
|
||||
|
||||
var $wapper = po.element(".chart-plugin-list");
|
||||
$wapper.empty();
|
||||
|
||||
for(var i=0; i<po.chartPluginVOs.length; i++)
|
||||
{
|
||||
var cp = po.chartPluginVOs[i];
|
||||
|
||||
var $li = $("<li class='ui-state-default ui-corner-all' />")
|
||||
.attr("chart-plugin-id", cp.id).attr("title", cp.nameLabel.value)
|
||||
.appendTo($wapper);
|
||||
|
||||
if(cp.hasIcon)
|
||||
$("<a class='plugin-icon'> </a>").css("background-image", "url(${contextPath}/"+cp.iconUrl+")").appendTo($li);
|
||||
else
|
||||
$("<a class='plugin-name'></a>").text(cp.nameLabel.value).appendTo($li);
|
||||
}
|
||||
};
|
||||
|
||||
po.initChartPluginList();
|
||||
|
||||
po.renderChartDataSetItem = function($parent, chartPlugin, chartDataSet)
|
||||
{
|
||||
var dataSet = chartDataSet.dataSet;
|
||||
var propertySigns = (chartDataSet.propertySigns || {});
|
||||
var dataSetProperties = (dataSet.properties || []);
|
||||
|
||||
var $item = $("<div class='data-set-item ui-widget ui-widget-content ui-corner-all ui-state-default' />").appendTo($parent);
|
||||
$("<input type='hidden' name='dataSetId' />").attr("value", dataSet.id).appendTo($item);
|
||||
|
||||
var $head = $("<div class='item-head ui-widget-header' />").appendTo($item);
|
||||
$("<span class='data-set-name' />").text(dataSet.name).appendTo($head);
|
||||
<#if !readonly>
|
||||
$("<div class='delete-icon''><span class=' ui-icon ui-icon-close'> </span></div>").attr("title", "<@spring.message code='delete' />").appendTo($head);
|
||||
</#if>
|
||||
|
||||
var $signs = $("<div class='item-signs' />").appendTo($item);
|
||||
for(var i=0; i<dataSetProperties.length; i++)
|
||||
{
|
||||
var dsp = dataSetProperties[i];
|
||||
|
||||
var $signItem = $("<div class='item-signs-item' />").appendTo($signs);
|
||||
$("<div class='sign-item-name' />").text(dsp.name).attr("title", (dsp.label || "")).appendTo($signItem);
|
||||
$("<div class='sign-item-values ui-widget ui-widget-content ui-corner-all' />").appendTo($signItem);
|
||||
<#if !readonly>
|
||||
$("<button type='button' class='sign-add-button ui-button ui-corner-all ui-widget ui-button-icon-only add-schema-button'><span class='ui-icon ui-icon-plus'></span><span class='ui-button-icon-space'> </span></button>").attr("title", "<@spring.message code='add' />").appendTo($signItem);
|
||||
</#if>
|
||||
}
|
||||
};
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/analysis/chart/" + action;
|
||||
|
@ -149,20 +221,43 @@ readonly 是否只读操作,允许为null
|
|||
if(!dataSets)
|
||||
return;
|
||||
|
||||
var $wrapper = po.element(".data-set-wrapper");
|
||||
var data = $.getPropertyParamString(dataSets, "id");
|
||||
|
||||
for(var i=0; i<dataSets.length; i++)
|
||||
$.get("${contextPath}/analysis/dataSet/getByIds", data, function(dataSets)
|
||||
{
|
||||
var dataSet = dataSets[i];
|
||||
var $wrapper = po.element(".data-set-wrapper");
|
||||
|
||||
var $item = $("<div class='data-set-item ui-widget ui-widget-content ui-corner-all ui-state-default' />").appendTo($wrapper);
|
||||
$("<input type='hidden' name='dataSetId'>").attr("value", dataSet.id).appendTo($item);
|
||||
$("<span class='data-set-name' />").text(dataSet.name).appendTo($item);
|
||||
$("<div class='delete-icon'><span class=' ui-icon ui-icon-close'> </span></div>").appendTo($item);
|
||||
}
|
||||
for(var i=0; i<dataSets.length; i++)
|
||||
{
|
||||
var dataSet = dataSets[i];
|
||||
|
||||
po.renderChartDataSetItem($wrapper, null, { "dataSet" : dataSet });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
po.element(".data-set-wrapper").on("click", ".delete-icon", function(){ $(this).parent().remove(); });
|
||||
po.element(".data-set-wrapper").on("click", ".delete-icon", function(){ $(this).parent().parent().remove(); });
|
||||
po.element(".data-set-wrapper").on("click", ".sign-add-button", function()
|
||||
{
|
||||
var chartPlugin = po.getCurrentChartPlugin();
|
||||
var dataSigns = (chartPlugin ? (chartPlugin.dataSigns || []) : []);
|
||||
|
||||
var $panel = po.element(".data-sign-select-panel");
|
||||
var $panelContent = po.element("> .select-panel-content", $panel);
|
||||
$panelContent.empty();
|
||||
|
||||
for(var i=0; i<dataSigns.length; i++)
|
||||
{
|
||||
var dataSign = dataSigns[i];
|
||||
|
||||
$("<button type='button' class='data-sign-item ui-button ui-corner-all' />")
|
||||
.attr("value", dataSign.name)
|
||||
.text(dataSign.nameLabel.value || dataSign.name).appendTo($panelContent);
|
||||
}
|
||||
|
||||
$panel.show();
|
||||
$panel.position({ my : "left top", at : "left bottom+3", of : this});
|
||||
});
|
||||
|
||||
po.element(".data-set-wrapper").sortable();
|
||||
|
||||
|
|
|
@ -149,9 +149,9 @@ selectonly 是否选择操作,允许为null
|
|||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chart.name' />"), "name"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.htmlChartPlugin' />", "htmlChartPlugin.id"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.htmlChartPlugin' />", "chartPluginName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.updateInterval' />", "updateInterval"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chart.createUser' />"), "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.createUser' />", "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.createTime' />", "createUser.createTime")
|
||||
];
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ selectonly 是否选择操作,允许为null
|
|||
|
||||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chartPlugin.name' />"), "name"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chartPlugin.desc' />"), "desc"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chartPlugin.name' />"), "nameLabel.value"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chartPlugin.desc' />"), "descLabel.value"),
|
||||
columnIcon,
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chartPlugin.version' />", "version")
|
||||
];
|
||||
|
|
|
@ -173,7 +173,7 @@ selectonly 是否选择操作,允许为null
|
|||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='dashboard.name' />"), "name"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='dashboard.createUser' />"), "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='dashboard.createUser' />", "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='dashboard.createTime' />", "createUser.createTime")
|
||||
];
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ readonly 是否只读操作,允许为null
|
|||
<label><@spring.message code='dataSet.dataSource' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="schemaConnectionFactory.schema.title" class="ui-widget ui-widget-content" value="${(dataSet.schemaConnectionFactory.schema.title)!''?html}" readonly="readonly" />
|
||||
<input type="hidden" name="schemaConnectionFactory.schema.id" class="ui-widget ui-widget-content" value="${(dataSet.schemaConnectionFactory.schema.id)!''?html}" />
|
||||
<input type="text" name="schemaConnectionFactory.schema.title" class="ui-widget ui-widget-content" value="${(dataSet.connectionFactory.schema.title)!''?html}" readonly="readonly" />
|
||||
<input type="hidden" name="schemaConnectionFactory.schema.id" class="ui-widget ui-widget-content" value="${(dataSet.connectionFactory.schema.id)!''?html}" />
|
||||
<#if !readonly>
|
||||
<button type="button" class="select-schema-button"><@spring.message code='select' /></button>
|
||||
</#if>
|
||||
|
|
|
@ -164,9 +164,9 @@ selectonly 是否选择操作,允许为null
|
|||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='dataSet.name' />"), "name"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='dataSet.dataSource' />"), "connectionFactory.schema.title"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='dataSet.dataSource' />", "connectionFactory.schema.title"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='dataSet.sql' />", "sql"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='dataSet.createUser' />"), "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='dataSet.createUser' />", "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='dataSet.createTime' />", "createUser.createTime")
|
||||
];
|
||||
|
||||
|
|
|
@ -2023,6 +2023,70 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-head{
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-signs{
|
||||
margin-top: 0.3em;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-signs .item-signs-item{
|
||||
padding: 0.2em 0;
|
||||
position: relative;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-signs .item-signs-item .sign-item-name{
|
||||
display: inline-block;
|
||||
width: 25%;
|
||||
overflow: hidden;
|
||||
padding: 1px 1px;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-signs .item-signs-item .sign-item-values{
|
||||
display: inline-block;
|
||||
width: 75%;
|
||||
height: 1.55em;
|
||||
overflow: hidden;
|
||||
padding: 1px 1px;
|
||||
padding-right: 2.5em;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-signs .item-signs-item .sign-item-values.ui-widget-content{
|
||||
background: none;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .item-signs .item-signs-item .sign-add-button{
|
||||
position: absolute;
|
||||
top: 0.35em;
|
||||
right: 0.1em;
|
||||
height: 1.2em;
|
||||
border: 0px;
|
||||
padding: 0.4em 0.5em;
|
||||
}
|
||||
.page-form-chart .data-sign-select-panel{
|
||||
position: absolute;
|
||||
display: none;
|
||||
padding: 0.3em 0.3em;
|
||||
width: 30%;
|
||||
height: 40%;
|
||||
}
|
||||
.page-form-chart .data-sign-select-panel .select-panel-head{
|
||||
padding: 0.3em 0.1em;
|
||||
}
|
||||
.page-form-chart .data-sign-select-panel .select-panel-content{
|
||||
position: absolute;
|
||||
left: 0.41em;
|
||||
right: 0.41em;
|
||||
top: 3em;
|
||||
bottom: 0.5em;
|
||||
padding: 0.5em 0.5em;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.page-form-chart .data-sign-select-panel .select-panel-content .data-sign-item{
|
||||
margin-right: 1em;
|
||||
margin-bottom: 0.41em;
|
||||
}
|
||||
.page-form-chart .add-data-set-button{
|
||||
vertical-align: top;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
{
|
||||
var util = (window.chartUtil || (window.chartUtil = {}));
|
||||
util.echarts = (util.echarts || {});
|
||||
util.dataset = (util.dataset || {});
|
||||
|
||||
/**
|
||||
* 获取图表主题。
|
||||
|
@ -40,6 +39,17 @@
|
|||
{
|
||||
return this.propertyValue(chart, "name", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取/设置图表的"updateInterval"属性值。
|
||||
*
|
||||
* @param chart
|
||||
* @param value 可选,要设置的属性值
|
||||
*/
|
||||
util.propertyValueUpdateInterval = function(chart, value)
|
||||
{
|
||||
return this.propertyValue(chart, "updateInterval", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取/设置图表属性值。
|
||||
|
@ -75,7 +85,134 @@
|
|||
else
|
||||
return renderContext.attributes[attrName] = attrValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取指定标记的第一个数据集属性,没有则返回null。
|
||||
*
|
||||
* @param chartDataSet 图表数据集对象
|
||||
* @param dataSign 数据标记对象、标记名称
|
||||
*/
|
||||
util.dataSetPropertyOfSign = function(chartDataSet, dataSign)
|
||||
{
|
||||
var properties = this.dataSetPropertiesOfSign(chartDataSet, dataSign);
|
||||
|
||||
return (properties.length > 0 ? properties[0] : null);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取指定标记的数据集属性数组。
|
||||
*
|
||||
* @param chartDataSet 图表数据集对象
|
||||
* @param dataSign 数据标记对象、标记名称
|
||||
*/
|
||||
util.dataSetPropertiesOfSign = function(chartDataSet, dataSign)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
dataSign = (dataSign.name || dataSign);
|
||||
var dataSetProperties = (chartDataSet.dataSet.properties || []);
|
||||
var propertySigns = (chartDataSet.propertySigns || {});
|
||||
|
||||
var signPropertyNames = [];
|
||||
|
||||
for(var pname : propertySigns)
|
||||
{
|
||||
var mySigns = (propertySigns[pname] || []);
|
||||
|
||||
for(var i=0; i<mySigns.length; i++)
|
||||
{
|
||||
if(mySigns[i] == dataSign || mySigns[i].name == dataSign)
|
||||
{
|
||||
signPropertyNames.push(pname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(var i=0; i<signPropertyNames.length; i++)
|
||||
{
|
||||
for(var j=0; j<dataSetProperties.length; j++)
|
||||
{
|
||||
if(dataSetProperties[j].name == signPropertyNames[i])
|
||||
re.push(dataSetProperties[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return re;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取结果数据属性值数组。
|
||||
*
|
||||
* @param result 数据集结果对象、对象数组
|
||||
* @param property 属性对象、属性名、属性对象数组、属性名数组
|
||||
*/
|
||||
util.dataPropertyValues = function(result, property)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
if(property == null)
|
||||
return re;
|
||||
|
||||
var datas = (result.length != null ? result : (result.datas || []));
|
||||
|
||||
if(property.length > 0)
|
||||
{
|
||||
for(var i=0; i<property.length; i++)
|
||||
{
|
||||
var myValues = [];
|
||||
|
||||
var cm = property[i];
|
||||
|
||||
var name = (cm.name || cm);
|
||||
|
||||
for(var j=0; j< datas.length; j++)
|
||||
myValues[j] = datas[j][name];
|
||||
|
||||
re[i] = myValues;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = (property.name || property);
|
||||
|
||||
for(var i=0; i< datas.length; i++)
|
||||
re[i] = datas[i][name];
|
||||
}
|
||||
|
||||
return re;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取结果数据的名称/值对象数组:[{name: ..., value: ...}, ...]。
|
||||
*
|
||||
* @param result 数据集结果对象、对象数组
|
||||
* @param nameProperty 名称属性对象、属性名
|
||||
* @param valueProperty 值属性对象、属性名
|
||||
*/
|
||||
util.dataNameValueObjects = function(result, nameProperty, valueProperty)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
var datas = (result.length != null ? result : (result.datas || []));
|
||||
|
||||
nameProperty = (nameProperty.name || nameProperty);
|
||||
valueProperty = (valueProperty.name || valueProperty);
|
||||
|
||||
for(var i=0; i< datas.length; i++)
|
||||
{
|
||||
var obj =
|
||||
{
|
||||
"name" : datas[i][nameProperty],
|
||||
"value" : datas[i][valueProperty]
|
||||
};
|
||||
|
||||
re[i] = obj;
|
||||
}
|
||||
|
||||
return re;
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化Echarts对象。
|
||||
*
|
||||
|
@ -234,179 +371,5 @@
|
|||
|
||||
return renderStyle;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取数据集数组的第一个元素,没有则返回undefined。
|
||||
*
|
||||
* @param dataSets
|
||||
*/
|
||||
util.dataset.first = function(dataSets)
|
||||
{
|
||||
return (dataSets && dataSets.length > 0 ? dataSets[0] : undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取指定名称的列元信息对象,没有则返回undefined。
|
||||
*
|
||||
* @param dataSet
|
||||
* @param name
|
||||
*/
|
||||
util.dataset.columnMetaByName = function(dataSet, name)
|
||||
{
|
||||
var columnMetas = dataSet.meta.columnMetas;
|
||||
|
||||
for(var i=0; i<columnMetas.length; i++)
|
||||
{
|
||||
if(columnMetas[i].name === name)
|
||||
return columnMetas[i];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取第一个维度列元信息对象,没有则返回undefined。
|
||||
*
|
||||
* @param dataSet
|
||||
*/
|
||||
util.dataset.columnMetaByDimension = function(dataSet)
|
||||
{
|
||||
var columnMetas = dataSet.meta.columnMetas;
|
||||
|
||||
for(var i=0; i<columnMetas.length; i++)
|
||||
{
|
||||
if(columnMetas[i].dataCategory === "DIMENSION")
|
||||
return columnMetas[i];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取维度列元信息对象数组。
|
||||
*
|
||||
* @param dataSet
|
||||
*/
|
||||
util.dataset.columnMetasByDimension = function(dataSet)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
var columnMetas = dataSet.meta.columnMetas;
|
||||
|
||||
for(var i=0; i<columnMetas.length; i++)
|
||||
{
|
||||
if(columnMetas[i].dataCategory === "DIMENSION")
|
||||
re.push(columnMetas[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取第一个量度列元信息对象。
|
||||
*
|
||||
* @param dataSet
|
||||
*/
|
||||
util.dataset.columnMetaByScalar = function(dataSet)
|
||||
{
|
||||
var columnMetas = dataSet.meta.columnMetas;
|
||||
|
||||
for(var i=0; i<columnMetas.length; i++)
|
||||
{
|
||||
if(columnMetas[i].dataCategory === "SCALAR")
|
||||
return columnMetas[i];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取量度列元信息对象数组。
|
||||
*
|
||||
* @param dataSet
|
||||
*/
|
||||
util.dataset.columnMetasByScalar = function(dataSet)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
var columnMetas = dataSet.meta.columnMetas;
|
||||
|
||||
for(var i=0; i<columnMetas.length; i++)
|
||||
{
|
||||
if(columnMetas[i].dataCategory === "SCALAR")
|
||||
re.push(columnMetas[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取列值数组。
|
||||
*
|
||||
* @param dataSet
|
||||
* @param columnMeta 列元信息对象、列名、列元信息对象数组、列名数组
|
||||
*/
|
||||
util.dataset.columnValues = function(dataSet, columnMeta)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
if(columnMeta == null)
|
||||
return re;
|
||||
|
||||
var datas = dataSet.datas;
|
||||
|
||||
if(columnMeta.length > 0)
|
||||
{
|
||||
for(var i=0; i<columnMeta.length; i++)
|
||||
{
|
||||
var myValues = [];
|
||||
|
||||
var cm = columnMeta[i];
|
||||
|
||||
var name = (cm.name || cm);
|
||||
|
||||
for(var j=0; j< datas.length; j++)
|
||||
myValues[j] = datas[j][name];
|
||||
|
||||
re[i] = myValues;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = (columnMeta.name || columnMeta);
|
||||
|
||||
for(var i=0; i< datas.length; i++)
|
||||
re[i] = datas[i][name];
|
||||
}
|
||||
|
||||
return re;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 获取列值的名称/值对象数组:[{name: ..., value: ...}, ...]。
|
||||
*
|
||||
* @param dataSet
|
||||
* @param nameColumnMeta 名称列元信息对象、列名
|
||||
* @param valueColumnMeta 值列元信息对象、列名
|
||||
*/
|
||||
util.dataset.columnNameValues = function(dataSet, nameColumnMeta, valueColumnMeta)
|
||||
{
|
||||
var re = [];
|
||||
|
||||
var datas = dataSet.datas;
|
||||
|
||||
var nameColumn = (nameColumnMeta.name || nameColumnMeta);
|
||||
var valueColumn = (valueColumnMeta.name || valueColumnMeta);
|
||||
|
||||
for(var i=0; i< datas.length; i++)
|
||||
{
|
||||
var obj =
|
||||
{
|
||||
"name" : datas[i][nameColumn],
|
||||
"value" : datas[i][valueColumn]
|
||||
};
|
||||
|
||||
re[i] = obj;
|
||||
}
|
||||
|
||||
return re;
|
||||
};
|
||||
})
|
||||
(window);
|
Loading…
Reference in New Issue