|
|
@ -2,7 +2,6 @@ package com.fr.plugin.db.redis; |
|
|
|
|
|
|
|
|
|
|
|
import com.fanruan.api.cal.FormulaKit; |
|
|
|
import com.fanruan.api.cal.FormulaKit; |
|
|
|
import com.fanruan.api.data.ConnectionKit; |
|
|
|
import com.fanruan.api.data.ConnectionKit; |
|
|
|
import com.fanruan.api.data.TableDataKit; |
|
|
|
|
|
|
|
import com.fanruan.api.util.StringKit; |
|
|
|
import com.fanruan.api.util.StringKit; |
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider; |
|
|
|
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider; |
|
|
@ -39,7 +38,11 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat |
|
|
|
JSONObject data = new JSONObject(); |
|
|
|
JSONObject data = new JSONObject(); |
|
|
|
Connection database = redisTableData.getDatabase(); |
|
|
|
Connection database = redisTableData.getDatabase(); |
|
|
|
data.put(RedisConstants.DATABASE, database instanceof NameReference ? ((NameReference) database).getName() : StringKit.EMPTY); |
|
|
|
data.put(RedisConstants.DATABASE, database instanceof NameReference ? ((NameReference) database).getName() : StringKit.EMPTY); |
|
|
|
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().toString()); |
|
|
|
if (redisTableData.getOrderValue() instanceof FormulaOrderValue) { |
|
|
|
|
|
|
|
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().toString()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
data.put(RedisConstants.SCRIPT, redisTableData.getScript()); |
|
|
|
data.put(RedisConstants.SCRIPT, redisTableData.getScript()); |
|
|
|
data.put(RedisConstants.QUERY, redisTableData.getQuery()); |
|
|
|
data.put(RedisConstants.QUERY, redisTableData.getQuery()); |
|
|
|
data.put(RedisConstants.PARAMETERS, ParameterBean.createParameterBeans(redisTableData.getParameters(Calculator.createCalculator()))); |
|
|
|
data.put(RedisConstants.PARAMETERS, ParameterBean.createParameterBeans(redisTableData.getParameters(Calculator.createCalculator()))); |
|
|
@ -48,11 +51,11 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public RedisTableData deserialize(RedisTableData oldTableData, JSONObject data) { |
|
|
|
public RedisTableData deserialize(RedisTableData oldTableData, JSONObject data) { |
|
|
|
RedisTableData newTableData = oldTableData; |
|
|
|
RedisTableData newTableData = new RedisTableData(); |
|
|
|
String databaseName = data.getString(RedisConstants.DATABASE); |
|
|
|
String databaseName = data.getString(RedisConstants.DATABASE); |
|
|
|
String script = data.getString(RedisConstants.SCRIPT); |
|
|
|
String script = data.getString(RedisConstants.SCRIPT); |
|
|
|
String query = data.getString(RedisConstants.QUERY); |
|
|
|
String query = data.getString(RedisConstants.QUERY); |
|
|
|
if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) { |
|
|
|
if (StringKit.isNotEmpty(databaseName) && ConnectionKit.getConnection(databaseName) != null) { |
|
|
|
newTableData.setDatabase(ConnectionKit.createNameConnection(databaseName)); |
|
|
|
newTableData.setDatabase(ConnectionKit.createNameConnection(databaseName)); |
|
|
|
} |
|
|
|
} |
|
|
|
newTableData.setScript(script); |
|
|
|
newTableData.setScript(script); |
|
|
@ -64,7 +67,7 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
newTableData.setOrderValue(new FormulaOrderValue(FormulaKit.newFormula(order))); |
|
|
|
newTableData.setOrderValue(new FormulaOrderValue(FormulaKit.newFormula(order))); |
|
|
|
} |
|
|
|
} |
|
|
|
newTableData.setParameters(RedisUtils.analyzeParameter(oldTableData.getParameters(Calculator.createCalculator()), newTableData.getOrderValue(), script, query)); |
|
|
|
newTableData.setParameters(RedisUtils.analyzeParameter(data.getJSONArray(RedisConstants.PARAMETERS), newTableData.getOrderValue(), script, query)); |
|
|
|
return newTableData; |
|
|
|
return newTableData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|