diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/DataSet.java b/datagear-analysis/src/main/java/org/datagear/analysis/DataSet.java index 2c9180b9..01b29278 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/DataSet.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/DataSet.java @@ -15,6 +15,13 @@ import java.util.Map; */ public interface DataSet extends Identifiable { + /** + * 获取名称。 + * + * @return + */ + String getName(); + /** * 获取属性列表。 *

diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/AbstractDataSet.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/AbstractDataSet.java index 91371aad..be25d651 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/AbstractDataSet.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/AbstractDataSet.java @@ -14,12 +14,12 @@ import java.util.Map; import org.datagear.analysis.AbstractIdentifiable; import org.datagear.analysis.DataNameAndType; -import org.datagear.analysis.DataSetResult; +import org.datagear.analysis.DataSet; import org.datagear.analysis.DataSetException; import org.datagear.analysis.DataSetExport; -import org.datagear.analysis.DataSet; import org.datagear.analysis.DataSetParam; import org.datagear.analysis.DataSetProperty; +import org.datagear.analysis.DataSetResult; /** * 抽象{@linkplain DataSet}。 @@ -29,6 +29,8 @@ import org.datagear.analysis.DataSetProperty; */ public abstract class AbstractDataSet extends AbstractIdentifiable implements DataSet { + private String name; + private List properties; private List params; @@ -40,12 +42,24 @@ public abstract class AbstractDataSet extends AbstractIdentifiable implements Da super(); } - public AbstractDataSet(String id, List properties) + public AbstractDataSet(String id, String name, List properties) { super(id); + this.name = name; this.properties = properties; } + @Override + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + @Override public List getProperties() { diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/SimpleDashboardThemeSource.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/SimpleDashboardThemeSource.java index 4d2c8823..539eeabe 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/SimpleDashboardThemeSource.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/SimpleDashboardThemeSource.java @@ -31,7 +31,7 @@ public class SimpleDashboardThemeSource implements DashboardThemeSource public static final DashboardTheme THEME_DARK = new DashboardTheme("#000", "#EEE", "#333", new ChartTheme("#101010", "#EEE", "#202020", "#AAA", "#888", "#444", "#F58400", new String[] { "#5EF6FE", - "#12CDD2", "#019DA2", "#24666C", "#73A373", "#EA7E53", "#EEDD78", "#73B9BC", "#7289AB", "#91CA8C" }, + "#91CA8C", "#EA7E53", "#24666C", "#73A373", "#019DA2", "#EEDD78", "#73B9BC", "#7289AB", "#12CDD2" }, new Theme("#000", "#EEE", "#333"))); private Map dashboardThemes; diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/SqlDataSet.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/SqlDataSet.java index feb2f47f..efeb5f81 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/SqlDataSet.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/SqlDataSet.java @@ -13,11 +13,11 @@ import java.sql.SQLException; import java.util.List; import java.util.Map; -import org.datagear.analysis.DataSetResult; -import org.datagear.analysis.DataSetException; import org.datagear.analysis.DataSet; +import org.datagear.analysis.DataSetException; import org.datagear.analysis.DataSetParam; import org.datagear.analysis.DataSetProperty; +import org.datagear.analysis.DataSetResult; import org.datagear.analysis.support.ParameterSqlResolver.ParameterSql; import org.datagear.util.JdbcUtil; import org.datagear.util.JdbcUtil.QueryResultSet; @@ -46,10 +46,10 @@ public class SqlDataSet extends AbstractDataSet super(); } - public SqlDataSet(String id, List properties, ConnectionFactory connectionFactory, + public SqlDataSet(String id, String name, List properties, ConnectionFactory connectionFactory, String sql) { - super(id, properties); + super(id, name, properties); this.connectionFactory = connectionFactory; this.sql = sql; } diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java index eb19acbc..c5d5487f 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java @@ -42,7 +42,7 @@ public class DirectoryHtmlChartPluginManager extends ConcurrentChartPluginManage private HtmlChartPluginLoader htmlChartPluginLoader = new HtmlChartPluginLoader(); - private long readCheckForReloadTimeThreashold = 5 * 60 * 1000; + private long readCheckForReloadTimeThreashold = (LOGGER.isDebugEnabled() ? 0 : 5 * 60 * 1000); private Map pluginIdFileNameMap = new HashMap(); diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartScriptObjectWriter.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartScriptObjectWriter.java index 15e6d26b..6498ede4 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartScriptObjectWriter.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartScriptObjectWriter.java @@ -107,7 +107,7 @@ public class HtmlChartScriptObjectWriter extends AbstractHtmlScriptObjectWriter { public JsonDataSet(DataSet dataSet) { - super(dataSet.getId(), dataSet.getProperties()); + super(dataSet.getId(), dataSet.getName(), dataSet.getProperties()); setParams(dataSet.getParams()); setExports(dataSet.getExports()); } diff --git a/datagear-analysis/src/test/java/org/datagear/analysis/support/SqlDataSetTest.java b/datagear-analysis/src/test/java/org/datagear/analysis/support/SqlDataSetTest.java index 8e78f14b..9be80e85 100644 --- a/datagear-analysis/src/test/java/org/datagear/analysis/support/SqlDataSetTest.java +++ b/datagear-analysis/src/test/java/org/datagear/analysis/support/SqlDataSetTest.java @@ -14,9 +14,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.datagear.analysis.DataSetResult; import org.datagear.analysis.DataSetParam; import org.datagear.analysis.DataSetProperty; +import org.datagear.analysis.DataSetResult; import org.datagear.analysis.DataType; import org.datagear.util.JdbcUtil; import org.datagear.util.resource.SimpleConnectionFactory; @@ -66,7 +66,7 @@ public class SqlDataSetTest extends DBTestSupport List dataSetParams = Arrays.asList(new DataSetParam("id", DataType.INTEGER, true), new DataSetParam("name", DataType.STRING, true)); - SqlDataSet sqlDataSet = new SqlDataSet("1", dataSetProperties, connectionFactory, sql); + SqlDataSet sqlDataSet = new SqlDataSet("1", "1", dataSetProperties, connectionFactory, sql); sqlDataSet.setParams(dataSetParams); Map dataSetParamValues = new HashMap(); diff --git a/datagear-management/src/main/java/org/datagear/management/domain/SqlDataSetEntity.java b/datagear-management/src/main/java/org/datagear/management/domain/SqlDataSetEntity.java index a1ec14f7..02474bbe 100644 --- a/datagear-management/src/main/java/org/datagear/management/domain/SqlDataSetEntity.java +++ b/datagear-management/src/main/java/org/datagear/management/domain/SqlDataSetEntity.java @@ -27,9 +27,6 @@ public class SqlDataSetEntity extends SqlDataSet implements CreateUserEntity properties, SchemaConnectionFactory connectionFactory, - String sql, String name, User createUser) + public SqlDataSetEntity(String id, String name, List properties, + SchemaConnectionFactory connectionFactory, + String sql, User createUser) { - super(id, properties, connectionFactory, sql); - this.name = name; + super(id, name, properties, connectionFactory, sql); this.createTime = new Date(); } @@ -78,16 +75,6 @@ public class SqlDataSetEntity extends SqlDataSet implements CreateUserEntity 0) - { - for(var i=0; i< property.length; i++) - re[i] = (re[i].length > 0 ? re[i][0] : null); + if(!dataSetResults || !dataSetResults.length || dataSetResults.length < index) + return {}; - return re; - } - else - return (re.length > 0 ? re[0] : null); + return dataSetResults[index]; }; /** - * 获取结果数据属性值数组。 + * 获取数据集结果指定属性、指定行的单元格值。 * * @param result 数据集结果对象、对象数组 - * @param property 属性对象、属性名、属性对象数组、属性名数组 - * @param count 获取结果数据的最多行数,可选,默认为全部 + * @param property 数据集属性对象、属性名 + * @param row 行索引,以0开始,默认为0 */ - util.dataPropertyValues = function(result, property, count) + util.resultCell = function(result, property, row) + { + if(row == null) + row = 0; + + var re = this.resultRowArrays(result, property, row+1); + + return (re.length > row ? re[row] : undefined); + }; + + /** + * 将数据集结果的行对象按照指定properties顺序转换为行值数组。 + * + * @param result 数据集结果对象、对象数组 + * @param properties 数据集属性对象数组、属性名数组、属性对象、属性名 + * @param count 获取的最多行数,可选,默认为全部 + * @return properties为数组时:[[..., ...], ...];properties非数组时:[..., ...] + */ + util.resultRowArrays = function(result, properties, count) { var re = []; - if(property == null) + if(properties == null) return re; var datas = (result.length != null ? result : (result.datas || [])); + var getCount = datas.length; if(count != null && count < getCount) getCount = count; - if(property.length > 0) + if(properties.length > 0) { - for(var i=0; i 0) + { + for(var i=0; i