完成部分metaDetail函数
This commit is contained in:
parent
2f831d9b4e
commit
7783f78a95
@ -92,7 +92,7 @@ task copyAssets(type: Copy) {
|
||||
into "./build/output/assets/"
|
||||
}
|
||||
|
||||
def currVersion = "0.0.8"
|
||||
def currVersion = "0.0.9"
|
||||
task copyJar(type: Copy, dependsOn: [":backend:copyLibs",":backend:jar"]) {
|
||||
from "./build/libs/$project.name-${project.version}.jar"
|
||||
into "./build/output/libs"
|
||||
|
@ -2,7 +2,7 @@
|
||||
"agentHttpAddr": "127.0.0.1:18005",
|
||||
"privKey":"3eadae5557a15593bba8e9af03cb085d4b3fcfec2b7ce26c226f0733145adfd0",
|
||||
"pubKey":"045546b5f6f5caef3c975e5da97ce5413eabfa48d69c9c74e9a2b6eb5c80d5651decff98b81c2f8409bdce3b5271ab7042625f09e641d848edc70755f780417202",
|
||||
"script": "./build/registry-0.0.8.ypk",
|
||||
"script": "./build/registry-0.0.9.ypk",
|
||||
"killContract": "Registry",
|
||||
"createParam": {
|
||||
"privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"host": "023.node.internetapi.cn",
|
||||
"privateKey": "e85ce2f4d8882ff343d32ce42adde91d09e29c321452dd4ef9f07ebe76d1c6a5",
|
||||
"publicKey": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926",
|
||||
"ypkPath": "./backend/build/registry-0.0.7.ypk",
|
||||
"ypkPath": "./backend/build/registry-0.0.9.ypk",
|
||||
"killBeforeStart": "Registry",
|
||||
"createParam": {
|
||||
"privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
|
||||
|
@ -1,10 +1,13 @@
|
||||
package org.bdware.sc.registry;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bdware.sc.util.ExceptionUtil;
|
||||
|
||||
import javax.json.Json;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -103,7 +106,7 @@ public class DBConnector {
|
||||
connect();
|
||||
pstmt = jdbcConnection.prepareStatement(sql);
|
||||
pstmt.setString(1, doid);
|
||||
ResultSet rs = null;
|
||||
ResultSet rs;
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
ret = rs.getString("sample");
|
||||
@ -117,4 +120,92 @@ public class DBConnector {
|
||||
connClose(jdbcConnection);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String queryInfoByMetaID(String doid) {
|
||||
String ret = "";
|
||||
String sql = "SELECT description FROM registry.meta_data WHERE doid = ?;";
|
||||
|
||||
// execute sql
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
connect();
|
||||
pstmt = jdbcConnection.prepareStatement(sql);
|
||||
pstmt.setString(1, doid);
|
||||
ResultSet rs;
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
ret = rs.getString("description");
|
||||
}
|
||||
pstmt.execute();
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
LOGGER.debug(ExceptionUtil.exceptionToString(e));
|
||||
}
|
||||
pstmtClose(pstmt);
|
||||
connClose(jdbcConnection);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static JsonObject queryMetaStandardByDate(Timestamp startTime, Timestamp endTime, int offset, int count) {
|
||||
String sql = "select * from registry.meta_data where \"createTime\" >= ? and \"createTime\" <= ? limit ? offset ? ;";
|
||||
|
||||
// execute sql
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
connect();
|
||||
pstmt = jdbcConnection.prepareStatement(sql);
|
||||
pstmt.setInt(3, count);
|
||||
pstmt.setInt(4, offset);
|
||||
pstmt.setObject(1, startTime);
|
||||
pstmt.setObject(2, endTime);
|
||||
|
||||
String[] columns = {
|
||||
"name",
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"creator",
|
||||
"updater",
|
||||
"registryID",
|
||||
"controlType",
|
||||
"status",
|
||||
"version",
|
||||
"doid",
|
||||
"description",
|
||||
"fields"
|
||||
};
|
||||
|
||||
System.out.println(pstmt);
|
||||
|
||||
ResultSet rs = null;
|
||||
int total = 0;
|
||||
JsonObject ret = new JsonObject();
|
||||
JsonArray data = new JsonArray();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
total ++;
|
||||
JsonObject row = new JsonObject();
|
||||
for (String col : columns) {
|
||||
if (col.equals("createTime") || col.equals("updateTime"))
|
||||
row.addProperty(col, rs.getTimestamp(col).toString());
|
||||
else if (col.equals("status"))
|
||||
row.addProperty(col, rs.getBoolean(col));
|
||||
else
|
||||
row.addProperty(col, rs.getString(col));
|
||||
}
|
||||
data.add(row);
|
||||
}
|
||||
ret.addProperty("total", total);
|
||||
ret.add("data", data);
|
||||
rs.close();
|
||||
|
||||
pstmtClose(pstmt);
|
||||
connClose(jdbcConnection);
|
||||
|
||||
return ret;
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
LOGGER.debug(ExceptionUtil.exceptionToString(e));
|
||||
}
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.bdware.sc.engine.JSONTool;
|
||||
import wrp.jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
import java.sql.SQLException;
|
||||
import org.bdware.sc.util.JsonUtil;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -13,6 +15,8 @@ import static org.bdware.sc.engine.JSONTool.convertMirrorToJson;
|
||||
|
||||
|
||||
public class RegistryDB {
|
||||
private static int stateCode;
|
||||
|
||||
public static void init(ScriptObjectMirror arg, String requester) {
|
||||
try {
|
||||
JsonObject jsonData = convertMirrorToJson(arg).getAsJsonObject();
|
||||
@ -32,14 +36,50 @@ public class RegistryDB {
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getRegistryInfo(ScriptObjectMirror scriptMirrorObject) {
|
||||
JsonObject jo = convertMirrorToJson(scriptMirrorObject).getAsJsonObject();
|
||||
JsonObject ret = new JsonObject();
|
||||
String info = DBConnector.queryInfoByMetaID(jo.get("doid").getAsString());
|
||||
if(!info.equals("")) {
|
||||
ret = JsonUtil.parseStringAsJsonObject(info);
|
||||
stateCode = 0;
|
||||
} else {
|
||||
stateCode = -1;
|
||||
}
|
||||
return JSONTool.convertJsonElementToMirror(ret);
|
||||
}
|
||||
|
||||
public static Object querySampleByMetaID(ScriptObjectMirror scriptMirrorObject) {
|
||||
JsonObject jo = convertMirrorToJson(scriptMirrorObject).getAsJsonObject();
|
||||
JsonObject ret = new JsonObject();
|
||||
String sample = DBConnector.querySampleByMetaID(jo.get("localMetaID").getAsString());
|
||||
if(!sample.equals("")) {
|
||||
ret = JsonUtil.parseStringAsJsonObject(sample);
|
||||
stateCode = 0;
|
||||
} else {
|
||||
stateCode = -1;
|
||||
}
|
||||
System.out.println(sample);
|
||||
return JSONTool.convertJsonElementToMirror(ret);
|
||||
}
|
||||
|
||||
public static Object queryMetaStandardsByTimeAndOffset(ScriptObjectMirror scriptMirrorObject) {
|
||||
JsonObject jo = convertMirrorToJson(scriptMirrorObject).getAsJsonObject();
|
||||
Timestamp startTime = new Timestamp(jo.get("createStartDate").getAsLong());
|
||||
Timestamp endTime = new Timestamp(jo.get("createEndDate").getAsLong());
|
||||
int offset = jo.get("offset").getAsInt();
|
||||
int count = jo.get("count").getAsInt();
|
||||
JsonObject ret = DBConnector.queryMetaStandardByDate(startTime, endTime, offset, count);
|
||||
if(ret == null) {
|
||||
stateCode = -1;
|
||||
} else {
|
||||
stateCode = 0;
|
||||
return JSONTool.convertJsonElementToMirror(ret);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getLastExecuteStatus() {
|
||||
return stateCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,9 +12,11 @@ import wrp.jdk.nashorn.internal.scripts.JO;
|
||||
|
||||
public class RuleExecutor {
|
||||
private static int executeCode;
|
||||
private static String executeMsg;
|
||||
|
||||
public static Object executeRule(ScriptObjectMirror som) {
|
||||
executeCode = 0;
|
||||
executeMsg = "success";
|
||||
JsonObject jo = JSONTool.convertMirrorToJson(som).getAsJsonObject();
|
||||
Object val = som.get("localDataSample");
|
||||
JsonObject rule = jo.get("mapRule").getAsJsonObject();
|
||||
@ -39,6 +41,7 @@ public class RuleExecutor {
|
||||
e.printStackTrace();
|
||||
//TODO GREP....
|
||||
executeCode = 1;
|
||||
executeMsg = e.getMessage();
|
||||
return "exception:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
@ -46,5 +49,8 @@ public class RuleExecutor {
|
||||
public static int getLastExecuteStatus() {
|
||||
return executeCode;
|
||||
}
|
||||
public static String getLastExecuteMsg() {
|
||||
return executeMsg;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,56 +1,100 @@
|
||||
module metaStandardDetail {
|
||||
export function getRegistryInfo(arg) {
|
||||
return {
|
||||
"code":0, "registryID":"macjw.ab", "description":"这是xx市的注册表,添加更多Registry描述"
|
||||
};
|
||||
arg = convertArgToJson(arg);
|
||||
var ret = {};
|
||||
ret.registryID = arg.registryID;
|
||||
ret.description = org.bdware.sc.registry.RegistryDB.getRegistryInfo(arg);
|
||||
ret.code = org.bdware.sc.registry.RegistryDB.getLastExecuteStatus();
|
||||
return ret;
|
||||
// return {
|
||||
// "code":0,
|
||||
// "registryID":"macjw.ab",
|
||||
// "description":"这是xx市的注册表,添加更多Registry描述"
|
||||
// };
|
||||
}
|
||||
|
||||
export function verifyRule(arg) {
|
||||
return {
|
||||
"code":0, "msg":"success"
|
||||
}
|
||||
|
||||
|
||||
|
||||
arg = convertArgToJson(arg);
|
||||
var ret = {};
|
||||
org.bdware.sc.registry.RuleExecutor.executeRule(arg);
|
||||
ret.code = org.bdware.sc.registry.RuleExecutor.getLastExecuteStatus();
|
||||
ret.msg = org.bdware.sc.registry.RuleExecutor.getLastExecuteMsg();
|
||||
return ret;
|
||||
// return {
|
||||
// "code":0,
|
||||
// "msg":"success"
|
||||
// }
|
||||
}
|
||||
|
||||
export function getFieldTypeList(arg) {
|
||||
return {
|
||||
"code":0, "data":[
|
||||
{
|
||||
"typeName":"string", "lable":"字符串", "formDesc":{
|
||||
"固定值":{
|
||||
"type":"input"
|
||||
}, "默认值":{
|
||||
"type":"input"
|
||||
}, "最小长度":{
|
||||
"type":"input"
|
||||
}, "最大长度":{
|
||||
"type":"input"
|
||||
}, "必备项":{
|
||||
"type":"select", "options":["是", "否"]
|
||||
}, }
|
||||
}, {
|
||||
"typeName":"boolean", "lable":"真假", "formDesc":{
|
||||
"固定值":{
|
||||
"type":"input"
|
||||
}, "默认值":{
|
||||
"type":"input"
|
||||
}, "必备项":{
|
||||
"type":"select", "options":["是", "否"]
|
||||
}, }
|
||||
}, ]
|
||||
"code":0,
|
||||
"data":[
|
||||
{
|
||||
"typeName":"string",
|
||||
"lable":"字符串",
|
||||
"formDesc":{
|
||||
"固定值":{
|
||||
"type":"input"
|
||||
},
|
||||
"默认值":{
|
||||
"type":"input"
|
||||
},
|
||||
"最小长度":{
|
||||
"type":"input"
|
||||
},
|
||||
"最大长度":{
|
||||
"type":"input"
|
||||
},
|
||||
"必备项":{
|
||||
"type":"select",
|
||||
"options":[
|
||||
"是",
|
||||
"否"
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
"typeName":"boolean",
|
||||
"lable":"真假",
|
||||
"formDesc":{
|
||||
"固定值":{
|
||||
"type":"input"
|
||||
},
|
||||
"默认值":{
|
||||
"type":"input"
|
||||
},
|
||||
"必备项":{
|
||||
"type":"select",
|
||||
"options":[
|
||||
"是",
|
||||
"否"
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export function listRemoteRegistry() {
|
||||
var ret = [
|
||||
{
|
||||
"registryID":"macjw", "name":"jw市市级注册"
|
||||
}, {
|
||||
"registryID":"macjw.de.cd", "name":"jw市de县cd镇注册表"
|
||||
}
|
||||
arg = convertArgToJson(arg);
|
||||
var ret = [];
|
||||
|
||||
var ret = [{
|
||||
"registryID":"macjw",
|
||||
"name":"jw市市级注册"
|
||||
},
|
||||
{
|
||||
"registryID":"macjw.de.cd",
|
||||
"name":"jw市de县cd镇注册表"
|
||||
}
|
||||
];
|
||||
return {
|
||||
"total":10, "data":ret, "code":0
|
||||
"total":10,
|
||||
"data":ret,
|
||||
"code":0
|
||||
};
|
||||
}
|
||||
// 如果是offset+count,就按顺序,
|
||||
@ -59,94 +103,22 @@ module metaStandardDetail {
|
||||
// updateStartDate updateEndDate
|
||||
// 如果是keyword:... 就模糊搜索
|
||||
// registryID
|
||||
//{"createStartDate":16111,"createEndDate":12222,"offset":0,"count":5}
|
||||
// {"createStartDate":1651334400000,"createEndDate":1653790428000,"offset":0,"count":2}
|
||||
|
||||
export function listMetaStandard(arg) {
|
||||
var ret = [];
|
||||
ret.push(
|
||||
{
|
||||
"name":"CO传感数据",
|
||||
"createDate":167227222,
|
||||
"updateDate":1111111,
|
||||
"creator":"xxx",
|
||||
"updater":"aabbcc",
|
||||
"registryID":"macjw.ab",
|
||||
"controlType":"private",
|
||||
"typeList":[
|
||||
"public",
|
||||
"private"
|
||||
],
|
||||
"status":"off",
|
||||
"version":"2.1",
|
||||
"doId":"ab.ccd/aaaaa-aaa",
|
||||
"desc":"元数据标准说明",
|
||||
"fields":[
|
||||
{
|
||||
"name":"owner",
|
||||
"type":"string",
|
||||
"description":"简要的说明",
|
||||
"constraint":{
|
||||
"固定值":"xxxxx",
|
||||
"最大长度":50,
|
||||
"必备项":"是"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name":"pubkey",
|
||||
"type":"string",
|
||||
"description":"pubkey简要的说明2",
|
||||
"constraint":{
|
||||
"固定值":"jjjjjjj", "最大长度":50
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"BF传感数据", "createDate":167226222, "updateDate":1111311, "creator":"xxx", "updater":"aabbcc", "registryID":"macjw", "controlType":"public", "typeList":["public", "private"], "status":"on", "version":"2.1", "doId":"ab.ccd/aabbbaa-aaa", "desc":"元数据标准说明", "fields":[
|
||||
{
|
||||
"name":"repository", "type":"string", "description":"简要的说明", "constraint":{
|
||||
"固定值":"xxx", "最大长度":50, "必备项":"是", }
|
||||
}, {
|
||||
"name":"format", "type":"boolean", "description":"简要的说明2", "constraint":{
|
||||
"必备项":"否"
|
||||
}
|
||||
}, {
|
||||
"name":"registertime", "type":"string", "description":"registertime简要的说明333333333", "constraint":{
|
||||
"固定值":"ooooo", "默认值":"hhhhhhhh", "最小长度":10, "必备项":"否", }
|
||||
}, ]
|
||||
}, {
|
||||
"name":"AA传感数据", "createDate":167227222, "updateDate":1111111, "creator":"xxx", "updater":"aabbcc", "registryID":"macjw.ab", "controlType":"private", "typeList":["public", "private"], "status":"off", "version":"2.1", "doId":"ab.ccd/adddda-aaa", "desc":"元数据标准说明", "fields":[
|
||||
{
|
||||
"name":"owner", "type":"string", "description":"简要的说明", "constraint":{
|
||||
"固定值":"xxxxx", "最大长度":50, "必备项":"是", }
|
||||
}, {
|
||||
"name":"pubkey", "type":"string", "description":"pubkey简要的说明2", "constraint":{
|
||||
"固定值":"jjjjjjj", "最大长度":50
|
||||
}
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"name":"HHH传感数据", "createDate":167227222, "updateDate":1111111, "creator":"xxx", "updater":"aabbcc", "registryID":"macjw.ac", "controlType":"private", "typeList":["public", "private"], "status":"on", "version":"2.1", "doId":"ab.ccd/aggga-aaa", "desc":"元数据标准说明", "fields":[
|
||||
{
|
||||
"name":"owner", "type":"string", "description":"简要的说明", "constraint":{
|
||||
"固定值":"xxxxx", "最大长度":50, "必备项":"是", }
|
||||
}, {
|
||||
"name":"pubkey", "type":"string", "description":"pubkey简要的说明2", "constraint":{
|
||||
"固定值":"jjjjjjj", "最大长度":50
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
return {
|
||||
"total":10, "data":ret, "code":0
|
||||
};
|
||||
arg = convertArgToJson(arg);
|
||||
var ret = org.bdware.sc.registry.RegistryDB.queryMetaStandardsByTimeAndOffset(arg);
|
||||
ret.code = org.bdware.sc.registry.RegistryDB.getLastExecuteStatus();
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function updateMetaStandardDetail(arg) {
|
||||
var ret = [];
|
||||
//通知对应的远程注册表,需要更新这个关系。
|
||||
return {
|
||||
"total":10, "data":ret, "code":0
|
||||
"total":10,
|
||||
"data":ret,
|
||||
"code":0
|
||||
};
|
||||
}
|
||||
|
||||
@ -154,11 +126,22 @@ module metaStandardDetail {
|
||||
export function listMetaStandardRelaction(arg) {
|
||||
var ret = [];
|
||||
ret.push({
|
||||
"name":"煤矿传感数据映射", "localMetaStandardDoid":"xx.xx/adfa", "remoteMetaStandardDoid":"ab.ccd/aaaaa-aaa", "createDate":167227222, "updateDate":1111111, "creator":"aabbcc", "updater":"aabbcc", "mapRule":{
|
||||
"owner":"${val.大小}", "pubkey":"function(val){}", }
|
||||
"name":"煤矿传感数据映射",
|
||||
"localMetaStandardDoid":"xx.xx/adfa",
|
||||
"remoteMetaStandardDoid":"ab.ccd/aaaaa-aaa",
|
||||
"createDate":167227222,
|
||||
"updateDate":1111111,
|
||||
"creator":"aabbcc",
|
||||
"updater":"aabbcc",
|
||||
"mapRule":{
|
||||
"owner":"${val.大小}",
|
||||
"pubkey":"function(val){}",
|
||||
}
|
||||
});
|
||||
return {
|
||||
"total":10, "data":ret, "code":0
|
||||
"total":10,
|
||||
"data":ret,
|
||||
"code":0
|
||||
};
|
||||
}
|
||||
|
||||
@ -167,20 +150,6 @@ module metaStandardDetail {
|
||||
arg = convertArgToJson(arg);
|
||||
arg.localDataSample = org.bdware.sc.registry.RegistryDB.querySampleByMetaID(arg);
|
||||
return getMapResult(arg);
|
||||
|
||||
// return {
|
||||
// "code":0,
|
||||
// "data":{
|
||||
// "localData": {
|
||||
// "大小":"500KB", "姓名":"小东"
|
||||
// },
|
||||
// "remoteData":{
|
||||
// "size":"500000Byte", "name":"*东"
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//TODO 返回映射格式有误
|
||||
// return {"code":1,"....."}
|
||||
}
|
||||
|
||||
//{"localDataSample":{},"mapRule":{},"remoteMetaID":"xxx"}
|
||||
|
Loading…
Reference in New Issue
Block a user