|
|
|
@ -1,31 +1,31 @@
|
|
|
|
|
package com.fr.plugin.db.redis.core; |
|
|
|
|
|
|
|
|
|
import com.fr.base.Parameter; |
|
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
|
import com.fr.base.TableData; |
|
|
|
|
import com.fr.base.TemplateUtils; |
|
|
|
|
import com.fr.config.holder.Conf; |
|
|
|
|
import com.fr.config.holder.factory.Holders; |
|
|
|
|
import com.fanruan.api.conf.HolderKit; |
|
|
|
|
import com.fr.config.holder.factory.XmlHolders; |
|
|
|
|
import com.fr.data.AbstractParameterTableData; |
|
|
|
|
import com.fr.data.core.DataCoreXmlUtils; |
|
|
|
|
import com.fanruan.api.xml.XmlKit; |
|
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
|
import com.fr.data.impl.NameDatabaseConnection; |
|
|
|
|
import com.fr.file.DatasourceManager; |
|
|
|
|
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection; |
|
|
|
|
import com.fanruan.api.data.ConnectionKit; |
|
|
|
|
import com.fr.general.data.DataModel; |
|
|
|
|
import com.fr.general.xml.GeneralXMLTools; |
|
|
|
|
import com.fanruan.api.xml.XmlKit; |
|
|
|
|
import com.fr.intelli.record.Focus; |
|
|
|
|
import com.fr.intelli.record.Original; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fanruan.api.log.LogKit; |
|
|
|
|
import com.fr.plugin.db.redis.core.order.OrderValue; |
|
|
|
|
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue; |
|
|
|
|
import com.fr.plugin.db.redis.util.RedisUtils; |
|
|
|
|
import com.fr.record.analyzer.EnableMetrics; |
|
|
|
|
import com.fr.script.Calculator; |
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
import com.fanruan.api.util.ArrayKit; |
|
|
|
|
import com.fanruan.api.util.StringKit; |
|
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
|
import com.fr.config.holder.Conf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
@ -35,10 +35,10 @@ import java.util.Map;
|
|
|
|
|
public class RedisTableData extends AbstractParameterTableData { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 7017455818551800001L; |
|
|
|
|
private Conf<Connection> database = Holders.obj(null, Connection.class); |
|
|
|
|
private Conf<Connection> database = HolderKit.obj(null, Connection.class); |
|
|
|
|
private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG); |
|
|
|
|
private Conf<String> query = Holders.simple(StringUtils.EMPTY); |
|
|
|
|
private Conf<String> script = Holders.simple(StringUtils.EMPTY); |
|
|
|
|
private Conf<String> query = HolderKit.simple(StringKit.EMPTY); |
|
|
|
|
private Conf<String> script = HolderKit.simple(StringKit.EMPTY); |
|
|
|
|
|
|
|
|
|
public void setDatabase(Connection c) { |
|
|
|
|
this.database.set(c); |
|
|
|
@ -89,7 +89,7 @@ public class RedisTableData extends AbstractParameterTableData {
|
|
|
|
|
Connection connection = database.get(); |
|
|
|
|
if (connection instanceof NameDatabaseConnection) { |
|
|
|
|
String name = ((NameDatabaseConnection) connection).getName(); |
|
|
|
|
RedisDatabaseConnection rc = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class); |
|
|
|
|
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class); |
|
|
|
|
if (rc != null) { |
|
|
|
|
OrderValue orderValue = dbIndex.get(); |
|
|
|
|
DataModel model = new RedisTableDataModel(calculator, ps, rc, |
|
|
|
@ -97,7 +97,7 @@ public class RedisTableData extends AbstractParameterTableData {
|
|
|
|
|
RedisUtils.calculateQuery(query.get(), ps), |
|
|
|
|
RedisUtils.calculateQuery(script.get(), ps), |
|
|
|
|
rowCount); |
|
|
|
|
FineLoggerFactory.getLogger().info("Build data model spend time {} ms.", System.currentTimeMillis() - start); |
|
|
|
|
LogKit.info("Build data model spend time {} ms.", System.currentTimeMillis() - start); |
|
|
|
|
return model; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -114,13 +114,13 @@ public class RedisTableData extends AbstractParameterTableData {
|
|
|
|
|
String tmpVal; |
|
|
|
|
|
|
|
|
|
if (OrderValue.XML_TAG.equals(tmpName)) { |
|
|
|
|
OrderValue orderValue = (OrderValue) GeneralXMLTools.readXMLable(reader); |
|
|
|
|
OrderValue orderValue = (OrderValue) XmlKit.readXMLable(reader); |
|
|
|
|
if (orderValue != null) { |
|
|
|
|
setOrderValue(orderValue); |
|
|
|
|
} |
|
|
|
|
} else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) { |
|
|
|
|
if (reader.getAttrAsString("class", null) != null) { |
|
|
|
|
com.fr.data.impl.Connection con = DataCoreXmlUtils.readXMLConnection(reader); |
|
|
|
|
com.fr.data.impl.Connection con = XmlKit.readXMLConnection(reader); |
|
|
|
|
this.setDatabase(con); |
|
|
|
|
} |
|
|
|
|
} else if ("Query".equals(tmpName)) { |
|
|
|
@ -140,9 +140,9 @@ public class RedisTableData extends AbstractParameterTableData {
|
|
|
|
|
@Override |
|
|
|
|
public void writeXML(XMLPrintWriter writer) { |
|
|
|
|
super.writeXML(writer); |
|
|
|
|
GeneralXMLTools.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG); |
|
|
|
|
XmlKit.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG); |
|
|
|
|
if (this.database.get() != null) { |
|
|
|
|
DataCoreXmlUtils.writeXMLConnection(writer, this.database.get()); |
|
|
|
|
XmlKit.writeXMLConnection(writer, this.database.get()); |
|
|
|
|
} |
|
|
|
|
writer.startTAG("Query").textNode(getQuery()).end(); |
|
|
|
|
writer.startTAG("Script").textNode(getScript()).end(); |
|
|
|
|