mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-06-27 03:20:10 +00:00
fix(builder): update version 0.5.1 #andy (#407)
This commit is contained in:
parent
783825700f
commit
918a1fb9ab
@ -30,6 +30,8 @@ import org.jgrapht.graph.builder.GraphTypeBuilder;
|
||||
@AllArgsConstructor
|
||||
public class LogicalPlan implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4487139289740223319L;
|
||||
|
||||
/** DAG (Directed Acyclic Graph) of the logical execution plan. */
|
||||
private final Graph<BaseLogicalNode<?>, DefaultEdge> dag;
|
||||
|
||||
|
@ -30,6 +30,8 @@ import org.jgrapht.graph.builder.GraphTypeBuilder;
|
||||
@AllArgsConstructor
|
||||
public class PhysicalPlan implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5866035535857620657L;
|
||||
|
||||
/** DAG (Directed Acyclic Graph) of the physical execution plan. */
|
||||
private final Graph<BaseProcessor<?>, DefaultEdge> dag;
|
||||
|
||||
|
@ -32,6 +32,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -41,14 +42,16 @@ public class LLMNlExtractProcessor extends BasePythonProcessor<LLMNlExtractNodeC
|
||||
|
||||
private ExecuteNode node;
|
||||
|
||||
private static final ThreadPoolExecutor executor =
|
||||
new ThreadPoolExecutor(
|
||||
30,
|
||||
60,
|
||||
60 * 60,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(1000),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
private static final RejectedExecutionHandler handler =
|
||||
(r, executor) -> {
|
||||
try {
|
||||
executor.getQueue().put(r);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
};
|
||||
|
||||
private static ThreadPoolExecutor executor;
|
||||
|
||||
public LLMNlExtractProcessor(String id, String name, LLMNlExtractNodeConfig config) {
|
||||
super(id, name, config);
|
||||
@ -58,6 +61,16 @@ public class LLMNlExtractProcessor extends BasePythonProcessor<LLMNlExtractNodeC
|
||||
public void doInit(BuilderContext context) throws BuilderException {
|
||||
super.doInit(context);
|
||||
this.node = context.getExecuteNodes().get(getId());
|
||||
if (executor == null) {
|
||||
executor =
|
||||
new ThreadPoolExecutor(
|
||||
context.getModelExecuteNum(),
|
||||
context.getModelExecuteNum(),
|
||||
60 * 60,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(100),
|
||||
handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,6 +146,10 @@ public class ParagraphSplitProcessor extends BasePythonProcessor<ParagraphSplitN
|
||||
case "json":
|
||||
className = "JSONReader";
|
||||
break;
|
||||
case "doc":
|
||||
case "docx":
|
||||
className = "DocxReader";
|
||||
break;
|
||||
}
|
||||
node.addTraceLog("invoke chunk operator:%s", className);
|
||||
pythonInterpreter.exec("from kag.builder.component.reader import " + className);
|
||||
|
@ -93,7 +93,7 @@ public class CommonUtils {
|
||||
return records;
|
||||
}
|
||||
|
||||
private static String labelPrefix(String namespace, String label) {
|
||||
public static String labelPrefix(String namespace, String label) {
|
||||
if (label.contains(DOT)) {
|
||||
return label;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
public class BuilderContext implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2446709406202543546L;
|
||||
|
||||
private long projectId;
|
||||
private String project;
|
||||
private String jobName;
|
||||
@ -41,6 +43,7 @@ public class BuilderContext implements Serializable {
|
||||
private int batchSize = 1;
|
||||
private int parallelism = 1;
|
||||
private boolean enableLeadTo;
|
||||
private Integer modelExecuteNum = 5;
|
||||
|
||||
private Map<String, ExecuteNode> executeNodes;
|
||||
private String schemaUrl;
|
||||
|
@ -39,10 +39,12 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
@ -53,8 +55,16 @@ public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
private Neo4jStoreClient client;
|
||||
private Project project;
|
||||
private static final String DOT = ".";
|
||||
ExecutorService nodeExecutor;
|
||||
ExecutorService edgeExecutor;
|
||||
ExecutorService executor;
|
||||
|
||||
RejectedExecutionHandler handler =
|
||||
(r, executor) -> {
|
||||
try {
|
||||
executor.getQueue().put(r);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
};
|
||||
|
||||
public Neo4jSinkWriter(String id, String name, Neo4jSinkNodeConfig config) {
|
||||
super(id, name, config);
|
||||
@ -69,22 +79,14 @@ public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
}
|
||||
client = new Neo4jStoreClient(context.getGraphStoreUrl());
|
||||
project = JSON.parseObject(context.getProject(), Project.class);
|
||||
nodeExecutor =
|
||||
executor =
|
||||
new ThreadPoolExecutor(
|
||||
NUM_THREADS,
|
||||
NUM_THREADS,
|
||||
2 * 60L,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(1000),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
edgeExecutor =
|
||||
new ThreadPoolExecutor(
|
||||
NUM_THREADS,
|
||||
NUM_THREADS,
|
||||
2 * 60L,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(1000),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
new LinkedBlockingQueue<>(100),
|
||||
handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,7 +117,7 @@ public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
try {
|
||||
node.addTraceLog("Start Writer Nodes processor...");
|
||||
List<Future<Void>> nodeFutures =
|
||||
submitTasks(nodeExecutor, subGraphRecord.getResultNodes(), this::writeNode);
|
||||
submitTasks(executor, subGraphRecord.getResultNodes(), this::writeNode);
|
||||
awaitAllTasks(nodeFutures);
|
||||
node.addTraceLog("Writer Nodes succeed");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
@ -125,7 +127,7 @@ public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
try {
|
||||
node.addTraceLog("Start Writer Edges processor...");
|
||||
List<Future<Void>> edgeFutures =
|
||||
submitTasks(edgeExecutor, subGraphRecord.getResultEdges(), this::writeEdge);
|
||||
submitTasks(executor, subGraphRecord.getResultEdges(), this::writeEdge);
|
||||
awaitAllTasks(edgeFutures);
|
||||
node.addTraceLog("Writer Edges succeed");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
@ -174,7 +176,10 @@ public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
try {
|
||||
Long statr = System.currentTimeMillis();
|
||||
RecordAlterOperationEnum operation = context.getOperation();
|
||||
if (node.getId() == null || node.getName() == null) {
|
||||
if (StringUtils.isBlank(node.getId())
|
||||
|| StringUtils.isBlank(node.getName())
|
||||
|| StringUtils.isBlank(node.getLabel())) {
|
||||
log.info(String.format("write Node ignore node:%s", JSON.toJSONString(node)));
|
||||
return;
|
||||
}
|
||||
String label = labelPrefix(node.getLabel());
|
||||
@ -212,7 +217,10 @@ public class Neo4jSinkWriter extends BaseSinkWriter<Neo4jSinkNodeConfig> {
|
||||
try {
|
||||
Long statr = System.currentTimeMillis();
|
||||
RecordAlterOperationEnum operation = context.getOperation();
|
||||
if (edge.getFrom() == null || edge.getTo() == null) {
|
||||
if (StringUtils.isBlank(edge.getFrom())
|
||||
|| StringUtils.isBlank(edge.getTo())
|
||||
|| StringUtils.isBlank(edge.getLabel())) {
|
||||
log.info(String.format("write Edge ignore edge:%s", JSON.toJSONString(edge)));
|
||||
return;
|
||||
}
|
||||
List<EdgeRecord> edgeRecords = Lists.newArrayList();
|
||||
|
@ -37,7 +37,7 @@ public class Neo4jDriverManager {
|
||||
Config config =
|
||||
Config.builder()
|
||||
.withMaxConnectionPoolSize(200)
|
||||
.withMaxConnectionLifetime(2, TimeUnit.HOURS)
|
||||
.withMaxConnectionLifetime(4, TimeUnit.HOURS)
|
||||
.withMaxTransactionRetryTime(300, TimeUnit.SECONDS)
|
||||
.withConnectionAcquisitionTimeout(300, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package com.antgroup.openspg.common.util.neo4j;
|
||||
|
||||
import com.antgroup.openspg.common.util.Md5Utils;
|
||||
import com.antgroup.openspg.common.util.tuple.Tuple2;
|
||||
import com.antgroup.openspg.core.schema.model.predicate.IndexTypeEnum;
|
||||
import com.antgroup.openspg.core.schema.model.predicate.Property;
|
||||
@ -21,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -35,8 +37,6 @@ import org.neo4j.driver.summary.ResultSummary;
|
||||
@Slf4j
|
||||
public class Neo4jGraphUtils {
|
||||
|
||||
private static final String ALL_GRAPH = "allGraph";
|
||||
|
||||
private Driver driver;
|
||||
private String database;
|
||||
private Neo4jIndexUtils neo4jIndex;
|
||||
@ -127,7 +127,7 @@ public class Neo4jGraphUtils {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void createAllGraph() {
|
||||
public void createAllGraph(String allGraph) {
|
||||
Session session = driver.session(SessionConfig.forDatabase(this.database));
|
||||
String existsQuery =
|
||||
String.format(
|
||||
@ -135,14 +135,14 @@ public class Neo4jGraphUtils {
|
||||
+ "WHERE exists "
|
||||
+ "CALL gds.graph.drop('%s') YIELD graphName "
|
||||
+ "RETURN graphName",
|
||||
ALL_GRAPH, ALL_GRAPH);
|
||||
allGraph, allGraph);
|
||||
|
||||
Result result = session.run(existsQuery);
|
||||
ResultSummary summary = result.consume();
|
||||
log.debug(
|
||||
"create pagerank graph exists graph_name: {} database: {} succeed "
|
||||
+ "executed: {} consumed: {}",
|
||||
ALL_GRAPH,
|
||||
allGraph,
|
||||
database,
|
||||
summary.resultAvailableAfter(TimeUnit.MILLISECONDS),
|
||||
summary.resultConsumedAfter(TimeUnit.MILLISECONDS));
|
||||
@ -152,13 +152,33 @@ public class Neo4jGraphUtils {
|
||||
"CALL gds.graph.project('%s','*','*') "
|
||||
+ "YIELD graphName, nodeCount AS nodes, relationshipCount AS rels "
|
||||
+ "RETURN graphName, nodes, rels",
|
||||
ALL_GRAPH);
|
||||
allGraph);
|
||||
|
||||
result = session.run(projectQuery);
|
||||
summary = result.consume();
|
||||
log.debug(
|
||||
"create pagerank graph graph_name: {} database: {} succeed " + "executed: {} consumed: {}",
|
||||
ALL_GRAPH,
|
||||
allGraph,
|
||||
database,
|
||||
summary.resultAvailableAfter(TimeUnit.MILLISECONDS),
|
||||
summary.resultConsumedAfter(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public void dropAllGraph(String allGraph) {
|
||||
Session session = driver.session(SessionConfig.forDatabase(this.database));
|
||||
String existsQuery =
|
||||
String.format(
|
||||
"CALL gds.graph.exists('%s') YIELD exists "
|
||||
+ "WHERE exists "
|
||||
+ "CALL gds.graph.drop('%s') YIELD graphName "
|
||||
+ "RETURN graphName",
|
||||
allGraph, allGraph);
|
||||
|
||||
Result result = session.run(existsQuery);
|
||||
ResultSummary summary = result.consume();
|
||||
log.debug(
|
||||
"drop pagerank graph graph_name: {} database: {} succeed executed: {} consumed: {}",
|
||||
allGraph,
|
||||
database,
|
||||
summary.resultAvailableAfter(TimeUnit.MILLISECONDS),
|
||||
summary.resultConsumedAfter(TimeUnit.MILLISECONDS));
|
||||
@ -167,12 +187,18 @@ public class Neo4jGraphUtils {
|
||||
public List<Map<String, Object>> getPageRankScores(
|
||||
List<Map<String, String>> startNodes, String targetType) {
|
||||
Session session = driver.session(SessionConfig.forDatabase(this.database));
|
||||
createAllGraph();
|
||||
return session.writeTransaction(tx -> getPageRankScores(tx, startNodes, targetType));
|
||||
String allGraph = "allGraph_" + Md5Utils.md5Of(UUID.randomUUID().toString());
|
||||
createAllGraph(allGraph);
|
||||
try {
|
||||
return session.writeTransaction(
|
||||
tx -> getPageRankScores(tx, allGraph, startNodes, targetType));
|
||||
} finally {
|
||||
dropAllGraph(allGraph);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getPageRankScores(
|
||||
Transaction tx, List<Map<String, String>> startNodes, String returnType) {
|
||||
Transaction tx, String allGraph, List<Map<String, String>> startNodes, String returnType) {
|
||||
List<String> matchClauses = new ArrayList<>();
|
||||
List<String> matchIdentifiers = new ArrayList<>();
|
||||
|
||||
@ -205,7 +231,7 @@ public class Neo4jGraphUtils {
|
||||
+ "RETURN id(m) AS g_id, gds.util.asNode(nodeId).id AS id, score "
|
||||
+ "ORDER BY score DESC",
|
||||
matchQuery,
|
||||
ALL_GRAPH,
|
||||
allGraph,
|
||||
matchIdentifierStr,
|
||||
Neo4jCommonUtils.escapeNeo4jIdentifier(returnType));
|
||||
|
||||
@ -231,6 +257,16 @@ public class Neo4jGraphUtils {
|
||||
});
|
||||
}
|
||||
|
||||
public void dropDatabase(String database) {
|
||||
Session session = driver.session(SessionConfig.forDatabase(this.database));
|
||||
session.writeTransaction(
|
||||
tx -> {
|
||||
tx.run(String.format("DROP DATABASE %s IF EXISTS", database));
|
||||
tx.commit();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteAllData(String database) {
|
||||
if (!this.database.equals(database)) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -17,12 +17,13 @@ services:
|
||||
command: [
|
||||
"java",
|
||||
"-Dfile.encoding=UTF-8",
|
||||
"-Xms4096m",
|
||||
"-Xmx4096m",
|
||||
"-Xms2048m",
|
||||
"-Xmx8192m",
|
||||
"-jar",
|
||||
"arks-sofaboot-0.0.1-SNAPSHOT-executable.jar",
|
||||
'--server.repository.impl.jdbc.host=mysql',
|
||||
'--server.repository.impl.jdbc.password=openspg',
|
||||
'--builder.model.execute.num=5',
|
||||
'--cloudext.graphstore.url=neo4j://release-openspg-neo4j:7687?user=neo4j&password=neo4j@openspg&database=neo4j',
|
||||
'--cloudext.searchengine.url=neo4j://release-openspg-neo4j:7687?user=neo4j&password=neo4j@openspg&database=neo4j'
|
||||
]
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
FROM mariadb:10.5.8
|
||||
|
||||
ADD sql/initdb.sql /docker-entrypoint-initdb.d
|
||||
ADD sql /docker-entrypoint-initdb.d
|
||||
|
||||
EXPOSE 3306
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
# or implied.
|
||||
|
||||
docker buildx build -f Dockerfile --platform linux/arm64/v8,linux/amd64 --push \
|
||||
-t openspg/openspg-mysql:0.5 \
|
||||
-t spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-mysql:0.5.1 \
|
||||
-t spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-mysql:latest \
|
||||
-t openspg/openspg-mysql:0.5.1 \
|
||||
-t openspg/openspg-mysql:latest \
|
||||
.
|
||||
|
@ -11,250 +11,73 @@
|
||||
|
||||
use openspg;
|
||||
|
||||
CREATE TABLE `kg_project_info` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`name` varchar(255) NOT NULL comment '项目名称',
|
||||
`description` varchar(1024) DEFAULT NULL comment '项目描述信息',
|
||||
`status` varchar(20) NOT NULL DEFAULT 'INVALID' comment 'DELETE:删除 VALID:有效 INVALID:无效',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`namespace` varchar(64) NOT NULL DEFAULT '' comment '命名空间',
|
||||
`biz_domain_id` bigint(20) DEFAULT NULL comment '业务域主键',
|
||||
`config` text DEFAULT NULL comment '项目配置信息',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_name`(`name`),
|
||||
KEY `idx_biz_domain_id`(`biz_domain_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '图谱项目信息表';
|
||||
CREATE TABLE `kg_reason_session` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`project_id` bigint(20) unsigned NOT NULL COMMENT '项目ID',
|
||||
`user_id` bigint(20) unsigned NOT NULL COMMENT '用户ID',
|
||||
`name` varchar(1024) NOT NULL COMMENT '会话名称',
|
||||
`description` longtext DEFAULT NULL COMMENT '会话描述信息',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_project_id` (`project_id`,`id`)
|
||||
) DEFAULT CHARSET=utf8mb4 COMMENT='图谱推理任务会话表';
|
||||
|
||||
CREATE TABLE `kg_reason_task` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`project_id` bigint(20) unsigned NOT NULL COMMENT '项目ID',
|
||||
`user_id` bigint(20) unsigned NOT NULL COMMENT '用户ID',
|
||||
`session_id` bigint(20) unsigned NOT NULL COMMENT '会话ID',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改时间',
|
||||
`mark` varchar(16) DEFAULT 'NULL' COMMENT '收藏状态',
|
||||
`status` varchar(32) DEFAULT NULL COMMENT '状态',
|
||||
`dsl` longtext DEFAULT NULL COMMENT 'DSL执行语句',
|
||||
`nl` longtext DEFAULT NULL COMMENT '自然语言查询语句',
|
||||
`params` longtext DEFAULT NULL COMMENT '参数',
|
||||
`result_message` longtext DEFAULT NULL COMMENT '执行结果,错误信息',
|
||||
`result_table` longtext DEFAULT NULL COMMENT '执行结果,表格数据',
|
||||
`result_nodes` longtext DEFAULT NULL COMMENT '执行结果,点数据',
|
||||
`result_edges` longtext DEFAULT NULL COMMENT '执行结果,边数据',
|
||||
`result_paths` longtext DEFAULT NULL COMMENT '执行结果,路径数据',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_session_id_id` (`session_id`,`id`),
|
||||
KEY `idx_project_user_mark` (`project_id`,`user_id`,`mark`),
|
||||
KEY `idx_user_mark_id` (`user_id`,`mark`,`id`)
|
||||
) DEFAULT CHARSET=utf8mb4 COMMENT='图谱推理任务表';
|
||||
|
||||
CREATE TABLE `kg_reason_tutorial` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`project_id` bigint(20) unsigned NOT NULL COMMENT '项目ID',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改时间',
|
||||
`enable` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态',
|
||||
`name` varchar(1024) DEFAULT NULL COMMENT '名称',
|
||||
`dsl` longtext DEFAULT NULL COMMENT 'DSL执行语句',
|
||||
`nl` longtext DEFAULT NULL COMMENT '自然语言查询语句',
|
||||
`params` longtext DEFAULT NULL COMMENT '参数',
|
||||
`description` longtext DEFAULT NULL COMMENT '描述信息',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_project_status` (`project_id`,`enable`)
|
||||
) DEFAULT CHARSET=utf8mb4 COMMENT='图谱推理教程信息表';
|
||||
|
||||
CREATE TABLE `kg_builder_job` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`project_id` bigint(20) unsigned NOT NULL COMMENT '项目ID',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改时间',
|
||||
`create_user` varchar(32) DEFAULT 'NULL' COMMENT '创建人',
|
||||
`modify_user` varchar(32) DEFAULT 'NULL' COMMENT '修改人',
|
||||
`task_id` bigint(20) unsigned DEFAULT NULL COMMENT '实例任务ID',
|
||||
`job_name` varchar(64) NOT NULL COMMENT '名称',
|
||||
`chunk_num` bigint(20) unsigned DEFAULT 0 COMMENT '分段数',
|
||||
`file_url` varchar(256) NOT NULL COMMENT '文件地址',
|
||||
`status` varchar(32) DEFAULT NULL COMMENT '状态',
|
||||
`type` varchar(32) DEFAULT NULL COMMENT '类型',
|
||||
`extension` longtext DEFAULT NULL COMMENT '扩展信息',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_project_id` (`project_id`),
|
||||
KEY `idx_task_id` (`task_id`)
|
||||
) DEFAULT CHARSET=utf8mb4 COMMENT='图谱构建任务表';
|
||||
|
||||
|
||||
CREATE TABLE `kg_biz_domain` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`name` varchar(100) DEFAULT NULL comment '名称',
|
||||
`status` varchar(20) DEFAULT NULL comment '状态。VALID - 有效 DELETE - 逻辑删除',
|
||||
`description` varchar(1024) DEFAULT NULL comment '描述',
|
||||
`global_config` varchar(10240) DEFAULT NULL comment '全局配置',
|
||||
PRIMARY KEY(`id`),
|
||||
KEY `idx_status`(`status`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '业务域表';
|
||||
|
||||
CREATE TABLE `kg_sys_lock` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`method_name` varchar(128) DEFAULT NULL comment '方法名',
|
||||
`method_value` varchar(128) DEFAULT NULL comment '方法值',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_mname`(`method_name`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '系统内置表,用于分布式锁实现';
|
||||
|
||||
CREATE TABLE `kg_ontology_entity` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`original_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '类型的原始ID',
|
||||
`name` varchar(255) NOT NULL comment '类型具体名称,比如‘Car’',
|
||||
`name_zh` varchar(255) NOT NULL comment '类型具体中文名称',
|
||||
`entity_category` varchar(20) NOT NULL comment '\'BASIC\':该类型为基本类型,\'ADVANCED\':该类型为实体类型',
|
||||
`layer` varchar(20) DEFAULT NULL comment '类型所属层次,“CORE”:核心层,“EXTENSION”:扩展层',
|
||||
`description` varchar(1024) DEFAULT NULL comment '当前类型的说明/描述信息',
|
||||
`description_zh` varchar(1024) DEFAULT NULL comment '当前类型的中文说明/描述信息即jsonLd中的\"@id\"',
|
||||
`status` char(1) NOT NULL DEFAULT '0' comment '9:删除 1:有效 0:无效 默认',
|
||||
`with_index` varchar(20) NOT NULL DEFAULT 'TRUE' comment 'TRUE\':该类型被索引,\'FALSE\':该类型不走索引',
|
||||
`scope` varchar(20) DEFAULT NULL comment '公有私有标识:PUBLIC,PRIVATE',
|
||||
`version` int(11) NOT NULL DEFAULT '0' comment '版本',
|
||||
`version_status` varchar(50) NOT NULL DEFAULT 'ONLINE' comment '迭代版本状态:ONLINE:线上版本、LATEST:最新版本、EFFICIENT:生效版本、HISTORY:历史版本、DISCARDED:废弃版本',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`transformer_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '算子ID',
|
||||
`operator_config` text DEFAULT NULL comment '算子配置,json格式文本',
|
||||
`config` mediumtext DEFAULT NULL comment '实体类型配置',
|
||||
`unique_name` varchar(255) DEFAULT NULL comment '唯一名称',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_name`(`name`),
|
||||
UNIQUE KEY `uk_origianl_id_version`(`original_id`, `version`),
|
||||
KEY `idx_version_status`(`version_status`),
|
||||
KEY `idx_originalid_versionstatus`(`original_id`, `version_status`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体类型';
|
||||
|
||||
CREATE TABLE `kg_ontology_entity_parent` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`entity_id` bigint(20) NOT NULL comment '类型唯一标识',
|
||||
`parent_id` bigint(20) NOT NULL comment '父类型唯一标识,根节点“-1”',
|
||||
`status` char(1) NOT NULL DEFAULT '0' comment '9:删除 1:有效 0:无效 默认',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`path` varchar(4096) DEFAULT NULL comment '继承路径',
|
||||
`deep_inherit` char(1) DEFAULT NULL comment '是否是深度继承,取值:Y,N',
|
||||
`history_path` varchar(4096) DEFAULT NULL comment '历史继承关系',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_type_parent_id`(`entity_id`, `parent_id`),
|
||||
KEY `idx_parent_id`(`parent_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体继承关系表';
|
||||
|
||||
CREATE TABLE `kg_ontology_entity_property_range` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`domain_id` bigint(20) unsigned NOT NULL comment '类型唯一标识或边属性边唯一标识',
|
||||
`property_name` varchar(255) NOT NULL comment '数据或者对象属性英文名',
|
||||
`range_id` bigint(20) unsigned NOT NULL comment '属性值域唯一标识或边属性属性值域唯一标识',
|
||||
`property_name_zh` varchar(255) NOT NULL comment '数据或者对象属性中文名',
|
||||
`constraint_id` bigint(20) unsigned NOT NULL comment '数据属性约束ID',
|
||||
`property_category` varchar(20) NOT NULL comment 'BASIC\':该属性为基本类型(实体),\'ADVANCED\':该属性为高级类型(边关系)',
|
||||
`map_type` varchar(20) NOT NULL DEFAULT 'TYPE' comment '标识映射是类型-》属性-》值域还是边的属性-》边属性的属性-》边属性的属性的值域,\"TYPE\":类型映射 \"EDGE\":边属性映射',
|
||||
`version` int(11) NOT NULL DEFAULT '0' comment '版本',
|
||||
`status` char(1) NOT NULL comment '9:删除 1:有效 0:无效 默认 和其他schema表对齐',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`original_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment 'spo多版本的原始ID',
|
||||
`store_property_name` varchar(255) DEFAULT NULL comment '数据属性对应的存储属性名',
|
||||
`transformer_id` bigint(20) NOT NULL DEFAULT '0' comment '算子ID',
|
||||
`property_desc` varchar(1024) DEFAULT NULL comment '属性描述',
|
||||
`property_desc_zh` varchar(1024) DEFAULT NULL comment '属性中文描述',
|
||||
`project_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '项目ID',
|
||||
`original_domain_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '类型或边的唯一原始标识',
|
||||
`original_range_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '类型的唯一原始标识',
|
||||
`version_status` varchar(50) DEFAULT NULL comment '迭代版本状态:ONLINE:线上版本、LATEST:最新版本、EFFICIENT:生效版本、HISTORY:历史版本、DISCARDED:废弃版本',
|
||||
`relation_source` varchar(2550) DEFAULT NULL comment '记录关系对应的属性(用于属性转关系)',
|
||||
`direction` varchar(10) DEFAULT NULL comment 'BOTH:表示双向边',
|
||||
`mask_type` varchar(20) DEFAULT NULL comment '数据加密规则。',
|
||||
`index_type` varchar(1024) DEFAULT NULL comment '索引规则。',
|
||||
`multiver_config` varchar(1024) DEFAULT NULL comment '多版本配置,json格式文本',
|
||||
`property_source` bigint(20) DEFAULT NULL comment '属性的来源,对应全局属性的id',
|
||||
`property_config` text DEFAULT NULL comment '针对属性的配置信息,如运营配置',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_spo`(`domain_id`, `property_name`, `range_id`, `map_type`, `version`),
|
||||
KEY `idx_original_id`(`original_id`),
|
||||
KEY `idx_version_status`(`version_status`),
|
||||
KEY `idx_relation`(`domain_id`, `property_category`, `map_type`, `version_status`),
|
||||
KEY `idx_property_name`(`property_name`),
|
||||
KEY `uk_spo_v2`(`original_domain_id`, `property_name`, `original_range_id`, `map_type`, `version`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体三元组表';
|
||||
|
||||
CREATE TABLE `kg_project_entity` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`project_id` bigint(20) unsigned NOT NULL comment '项目id',
|
||||
`entity_id` bigint(20) unsigned NOT NULL comment '本体类型id',
|
||||
`version` int(11) NOT NULL DEFAULT '0' comment '版本',
|
||||
`version_status` varchar(50) NOT NULL DEFAULT 'ONLINE' comment '迭代版本状态:ONLINE:线上版本、EFFICTIVE:生效版本、RELEASED:已发布版本、DISCARD:废弃版本',
|
||||
`referenced` char(1) NOT NULL comment '标志是否是引用的类型。Y:是,N:不是',
|
||||
`type` varchar(64) DEFAULT 'ENTITY_TYPE' comment '引入的资源类型,关系(RELATION_TYPE)和实体类型(ENTITY_TYPE),默认ENTITY_TYPE',
|
||||
`ref_source` varchar(64) DEFAULT NULL comment '引用来源,corekg:COREKG, 项目:PROJECT',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_project_id_entity_id`(`project_id`, `entity_id`, `version`),
|
||||
KEY `idx_version_status`(`version_status`),
|
||||
KEY `idx_projectid_versionstatus`(`project_id`, `version_status`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '项目和本体类型关联表';
|
||||
|
||||
CREATE TABLE `kg_ontology_semantic` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`resource_id` varchar(128) NOT NULL comment '关联资源id',
|
||||
`semantic_type` varchar(64) NOT NULL comment '谓词',
|
||||
`original_resource_id` varchar(64) NOT NULL comment '被关联资源id',
|
||||
`resource_type` varchar(64) DEFAULT NULL comment '资源类型:entity_type、relation_type、property,可为空,也可有其他类型',
|
||||
`status` int(11) NOT NULL comment '状态,0:删除 1:有效',
|
||||
`config` text DEFAULT NULL comment '预留,谓词额外信息',
|
||||
`rule_id` varchar(128) DEFAULT NULL comment '关联规则ID',
|
||||
`subject_meta_type` varchar(128) DEFAULT NULL comment '主体元概念名',
|
||||
`object_meta_type` varchar(128) DEFAULT NULL comment '客体元概念名',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_spo`(`resource_id`, `semantic_type`, `original_resource_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '语义关联维护表';
|
||||
|
||||
CREATE TABLE `kg_semantic_rule` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`name` varchar(255) DEFAULT NULL comment '名称',
|
||||
`expression` mediumtext NOT NULL comment '内容',
|
||||
`version_id` int(11) NOT NULL comment '版本号',
|
||||
`status` varchar(60) NOT NULL comment '状态',
|
||||
`user_no` varchar(255) NOT NULL comment '用户ID',
|
||||
`is_master` tinyint(4) DEFAULT NULL comment '是否主版本',
|
||||
`rule_id` varchar(512) DEFAULT NULL comment '规则ID',
|
||||
`effect_scope` varchar(60) DEFAULT NULL comment '生效范围',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_id_version`(`rule_id`, `version_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '语义规则表';
|
||||
|
||||
CREATE TABLE `kg_ontology_property_constraint` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`name` varchar(255) NOT NULL comment '该约束的名称,英文',
|
||||
`name_zh` varchar(255) NOT NULL comment '该约束的中文名称',
|
||||
`is_require` char(1) NOT NULL DEFAULT 'N' comment '空约束,属性值域是否可以为空,\"N\":可为空 \"Y\":不可为空',
|
||||
`up_down_boundary` char(1) NOT NULL DEFAULT '0' comment '\">\":1;\">=\":2;\"<\":3;\"<=\":4;1\">\"\"<\":5 \">\"\"<=\":6 \">=\"\"<\":7 \">=\"\"<=\":8,,默认0:无校验',
|
||||
`max_value` varchar(255) DEFAULT NULL comment '该属性在该类别下的最大值,仅当数值类型Number及其子类时有效',
|
||||
`min_value` varchar(255) DEFAULT NULL comment '该属性在该类别下的最小值,仅当值类型是Number及其子类时有效',
|
||||
`value_pattern` varchar(1024) DEFAULT NULL comment '正则表达的值规范,多用于文本类型Text',
|
||||
`description` varchar(1024) NOT NULL comment '当前约束的说明/描述信息',
|
||||
`description_zh` varchar(1024) NOT NULL comment '当前约束的中文说明/描述信息',
|
||||
`is_unique` char(1) DEFAULT 'N' comment 'Y:属性唯一约束, N:无唯一约束',
|
||||
`is_enum` char(1) DEFAULT 'N' comment 'Y 是枚举类型,N 不是',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`enum_value` text comment '枚举值',
|
||||
`is_multi_value` char(1) DEFAULT NULL comment '是否多值,Y:多值',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体属性约束表';
|
||||
|
||||
CREATE TABLE `kg_ontology_release` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`project_id` bigint(20) NOT NULL comment '项目ID',
|
||||
`version` int(11) NOT NULL comment '发布版本',
|
||||
`schema_view` longtext DEFAULT NULL comment '当前版本schema视图',
|
||||
`user_id` varchar(20) NOT NULL comment '发布人',
|
||||
`description` text NOT NULL comment '发布描述',
|
||||
`status` varchar(20) NOT NULL comment '状态',
|
||||
`change_procedure_id` text DEFAULT NULL comment '变更流程id',
|
||||
`operation_detail` text DEFAULT NULL comment '(废弃)本次发布的操作详情',
|
||||
`error_detail` text DEFAULT NULL comment '失败详情',
|
||||
`operation_info` mediumtext DEFAULT NULL comment '本次发布的操作详情',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_project_version`(`project_id`, `version`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体建模发布版本';
|
||||
|
||||
CREATE TABLE `kg_ontology_ext` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`resource_id` varchar(128) NOT NULL comment '实体类型id、关系类型id、属性id',
|
||||
`resource_type` varchar(64) NOT NULL comment '操作的类型枚举:实体类型、关系类型、属性',
|
||||
`ext_type` varchar(64) NOT NULL comment '扩展类型:标签、回流、颜色',
|
||||
`field` varchar(64) NOT NULL comment '扩展属性所属域,比如区分用户',
|
||||
`config` mediumtext DEFAULT NULL comment '配置内容',
|
||||
`creator` varchar(64) NOT NULL comment '创建者',
|
||||
`modifier` varchar(64) NOT NULL comment '更新者',
|
||||
`status` int(10) unsigned NOT NULL comment '状态 1:有效 0:无效',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_id_type_field`(`resource_id`, `resource_type`, `ext_type`, `field`)
|
||||
) AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = 'schema的扩展属性';
|
||||
|
||||
INSERT INTO kg_biz_domain (`id`,`gmt_create`,`gmt_modified`,`name`,`status`,`description`,`global_config`) VALUES(1,'2023-09-01 00:00:00','2023-09-01 00:00:00','defaultTenant','VALID','',null);
|
||||
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(1,1,'Thing','事物','ADVANCED','EXTENSION','Base class for all schema types, all of which inherit the type either directly or indirectly','所有schema类型的基类,它们都直接或者间接继承该类型','1','TRUE','PUBLIC',44,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,null,'Thing');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(2,2,'Text','文本','BASIC','CORE','文本','基本数据类型-文本','1','TRUE','PUBLIC',0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REQUIRE","name":"Required","nameZh":"值非空","value":null},{"id":"UNIQUE","name":"Unique","nameZh":"值唯一","value":null},{"id":"ENUM","name":"Enum","nameZh":"枚举","value":null},{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":null}]}','Text');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(4,4,'Integer','整型','BASIC','CORE','整型数字','基本数据类型-整型','1','TRUE','PUBLIC',0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REQUIRE","name":"Required","nameZh":"值非空","value":null},{"id":"ENUM","name":"Enum","nameZh":"枚举","value":null},{"id":"MINIMUM_GT","name":"Greater than","nameZh":"大于","value":null},{"id":"MINIMUM_GT_OE","name":"Greater than or equal","nameZh":"大于等于","value":null},{"id":"MAXIMUM_LT","name":"Less than","nameZh":"小于","value":null},{"id":"MAXIMUM_LT_OE","name":"Less than or equal","nameZh":"小于等于","value":null}]}','Integer');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(5,5,'Float','浮点数','BASIC','CORE','浮点数','基本数据类型-浮点数','1','TRUE','PUBLIC',0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REQUIRE","name":"Required","nameZh":"值非空","value":null},{"id":"ENUM","name":"Enum","nameZh":"枚举","value":null},{"id":"MINIMUM_GT","name":"Greater than","nameZh":"大于","value":null},{"id":"MINIMUM_GT_OE","name":"Greater than or equal","nameZh":"大于等于","value":null},{"id":"MAXIMUM_LT","name":"Less than","nameZh":"小于","value":null},{"id":"MAXIMUM_LT_OE","name":"Less than or equal","nameZh":"小于等于","value":null}]}','Float');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(10,10,'STD.ChinaMobile','国内手机号','STANDARD','CORE','中国国内使用的手机号码由11位数字组成','中国国内使用的手机号码由11位数字组成','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(16[5,6])|(17[0-8])|(18[0-9])|(19[1,5,8,9]))[0-9]{8}$"}],"spreadable":true}','STD.ChinaMobile');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(11,11,'STD.Email','电子邮箱','STANDARD','CORE','电子邮箱地址','电子邮箱地址','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[.][A-Za-z]{2,3}([.][A-Za-z]{2})?$"}],"spreadable":true}','STD.Email');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(13,13,'STD.IdCardNo','身份证','STANDARD','CORE','中国身份证号码一般由18位数字和字母组成','中国身份证号码一般由18位数字和字母组成','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^[1-9]{1}[0-9]{5}(19|20)[0-9]{2}((0[1-9]{1})|(1[0-2]{1}))((0[1-9]{1})|([1-2]{1}[0-9]{1}|(3[0-1]{1})))[0-9]{3}[0-9xX]{1}$"}],"spreadable":true}','STD.IdCardNo');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(14,14,'STD.MacAddress','MAC地址','STANDARD','CORE','网卡MAC地址','网卡MAC地址','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"([A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2}"}],"spreadable":true}','STD.MacAddress');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(19,19,'STD.Date','日期','STANDARD','CORE','8位数字组成的日期','8位数字组成的日期','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"[1,2][0-9][0-9][0-9](0[1-9]|1[0-2])(0[1-9]|[1,2][0-9]|3[0,1])"}]}','STD.Date');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(27,27,'STD.ChinaTelCode','国内通讯号','STANDARD','CORE','国内通讯号码包含常见座机和手机号码','国内通讯号码包含常见座机和手机号码','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^(400[0-9]{7})|(800[0-9]{7})|(0[0-9]{2,3}-[0-9]{7,8})|((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(16[5,6])|(17[0-8])|(18[0-9])|(19[1,5,8,9]))[0-9]{8}$"}],"spreadable":true}','STD.ChinaTelCode');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(29,29,'STD.Timestamp','时间戳','STANDARD','CORE','10位或者13位的时间戳','10位或者13位的时间戳','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^([0-9]{10})|([0-9]{13})$"}]}','STD.Timestamp');
|
||||
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(1,10,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,10','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(2,11,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,11','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(4,13,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,13','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(5,14,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,14','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(8,19,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,19','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(12,27,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,27','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(14,29,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,29','N', null);
|
||||
|
||||
INSERT INTO kg_ontology_entity_property_range (`id`,`domain_id`,`property_name`,`range_id`,`property_name_zh`,`constraint_id`,`property_category`,`map_type`,`version`,`status`,`gmt_create`,`gmt_modified`,`original_id`,`store_property_name`,`transformer_id`,`property_desc`,`property_desc_zh`,`project_id`,`original_domain_id`,`original_range_id`,`version_status`,`relation_source`,`direction`,`mask_type`,`multiver_config`,`property_source`,`property_config`) VALUES(1,1,'description',2,'描述',0,'BASIC','TYPE',44,'1','2022-03-21 19:24:54','2023-08-27 09:39:04',1,'description',0,null,null,0,1,2,'ONLINE',null,null,null,null,null,null);
|
||||
INSERT INTO kg_ontology_entity_property_range (`id`,`domain_id`,`property_name`,`range_id`,`property_name_zh`,`constraint_id`,`property_category`,`map_type`,`version`,`status`,`gmt_create`,`gmt_modified`,`original_id`,`store_property_name`,`transformer_id`,`property_desc`,`property_desc_zh`,`project_id`,`original_domain_id`,`original_range_id`,`version_status`,`relation_source`,`direction`,`mask_type`,`multiver_config`,`property_source`,`property_config`) VALUES(2,1,'id',2,'实体主键',0,'BASIC','TYPE',44,'1','2022-03-21 19:24:54','2023-08-27 09:39:04',2,'id',0,null,null,0,1,2,'ONLINE',null,null,null,null,null,null);
|
||||
INSERT INTO kg_ontology_entity_property_range (`id`,`domain_id`,`property_name`,`range_id`,`property_name_zh`,`constraint_id`,`property_category`,`map_type`,`version`,`status`,`gmt_create`,`gmt_modified`,`original_id`,`store_property_name`,`transformer_id`,`property_desc`,`property_desc_zh`,`project_id`,`original_domain_id`,`original_range_id`,`version_status`,`relation_source`,`direction`,`mask_type`,`multiver_config`,`property_source`,`property_config`) VALUES(3,1,'name',2,'名称',0,'BASIC','TYPE',44,'1','2022-03-21 19:24:54','2023-08-27 09:39:04',3,'name',0,null,null,0,1,2,'ONLINE',null,null,null,null,null,null);
|
||||
|
260
dev/release/mysql/sql/openspg-initdb.sql
Normal file
260
dev/release/mysql/sql/openspg-initdb.sql
Normal file
@ -0,0 +1,260 @@
|
||||
-- Copyright 2023 OpenSPG Authors
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
-- in compliance with the License. You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
-- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
-- or implied.
|
||||
|
||||
use openspg;
|
||||
|
||||
CREATE TABLE `kg_project_info` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`name` varchar(255) NOT NULL comment '项目名称',
|
||||
`description` varchar(1024) DEFAULT NULL comment '项目描述信息',
|
||||
`status` varchar(20) NOT NULL DEFAULT 'INVALID' comment 'DELETE:删除 VALID:有效 INVALID:无效',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`namespace` varchar(64) NOT NULL DEFAULT '' comment '命名空间',
|
||||
`biz_domain_id` bigint(20) DEFAULT NULL comment '业务域主键',
|
||||
`config` text DEFAULT NULL comment '项目配置信息',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_name`(`name`),
|
||||
KEY `idx_biz_domain_id`(`biz_domain_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '图谱项目信息表';
|
||||
|
||||
|
||||
CREATE TABLE `kg_biz_domain` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`name` varchar(100) DEFAULT NULL comment '名称',
|
||||
`status` varchar(20) DEFAULT NULL comment '状态。VALID - 有效 DELETE - 逻辑删除',
|
||||
`description` varchar(1024) DEFAULT NULL comment '描述',
|
||||
`global_config` varchar(10240) DEFAULT NULL comment '全局配置',
|
||||
PRIMARY KEY(`id`),
|
||||
KEY `idx_status`(`status`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '业务域表';
|
||||
|
||||
CREATE TABLE `kg_sys_lock` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`method_name` varchar(128) DEFAULT NULL comment '方法名',
|
||||
`method_value` varchar(128) DEFAULT NULL comment '方法值',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_mname`(`method_name`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '系统内置表,用于分布式锁实现';
|
||||
|
||||
CREATE TABLE `kg_ontology_entity` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`original_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '类型的原始ID',
|
||||
`name` varchar(255) NOT NULL comment '类型具体名称,比如‘Car’',
|
||||
`name_zh` varchar(255) NOT NULL comment '类型具体中文名称',
|
||||
`entity_category` varchar(20) NOT NULL comment 'BASIC:该类型为基本类型,ADVANCED:该类型为实体类型',
|
||||
`layer` varchar(20) DEFAULT NULL comment '类型所属层次,“CORE”:核心层,“EXTENSION”:扩展层',
|
||||
`description` varchar(1024) DEFAULT NULL comment '当前类型的说明/描述信息',
|
||||
`description_zh` varchar(1024) DEFAULT NULL comment '当前类型的中文说明/描述信息即jsonLd中的"@id"',
|
||||
`status` char(1) NOT NULL DEFAULT '0' comment '9:删除 1:有效 0:无效 默认',
|
||||
`with_index` varchar(20) NOT NULL DEFAULT 'TRUE' comment 'TRUE:该类型被索引,FALSE:该类型不走索引',
|
||||
`scope` varchar(20) DEFAULT NULL comment '公有私有标识:PUBLIC,PRIVATE',
|
||||
`version` int(11) NOT NULL DEFAULT '0' comment '版本',
|
||||
`version_status` varchar(50) NOT NULL DEFAULT 'ONLINE' comment '迭代版本状态:ONLINE:线上版本、LATEST:最新版本、EFFICIENT:生效版本、HISTORY:历史版本、DISCARDED:废弃版本',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`transformer_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '算子ID',
|
||||
`operator_config` text DEFAULT NULL comment '算子配置,json格式文本',
|
||||
`config` mediumtext DEFAULT NULL comment '实体类型配置',
|
||||
`unique_name` varchar(255) DEFAULT NULL comment '唯一名称',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_name`(`name`),
|
||||
UNIQUE KEY `uk_origianl_id_version`(`original_id`, `version`),
|
||||
KEY `idx_version_status`(`version_status`),
|
||||
KEY `idx_originalid_versionstatus`(`original_id`, `version_status`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体类型';
|
||||
|
||||
CREATE TABLE `kg_ontology_entity_parent` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`entity_id` bigint(20) NOT NULL comment '类型唯一标识',
|
||||
`parent_id` bigint(20) NOT NULL comment '父类型唯一标识,根节点“-1”',
|
||||
`status` char(1) NOT NULL DEFAULT '0' comment '9:删除 1:有效 0:无效 默认',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`path` varchar(4096) DEFAULT NULL comment '继承路径',
|
||||
`deep_inherit` char(1) DEFAULT NULL comment '是否是深度继承,取值:Y,N',
|
||||
`history_path` varchar(4096) DEFAULT NULL comment '历史继承关系',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_type_parent_id`(`entity_id`, `parent_id`),
|
||||
KEY `idx_parent_id`(`parent_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体继承关系表';
|
||||
|
||||
CREATE TABLE `kg_ontology_entity_property_range` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`domain_id` bigint(20) unsigned NOT NULL comment '类型唯一标识或边属性边唯一标识',
|
||||
`property_name` varchar(255) NOT NULL comment '数据或者对象属性英文名',
|
||||
`range_id` bigint(20) unsigned NOT NULL comment '属性值域唯一标识或边属性属性值域唯一标识',
|
||||
`property_name_zh` varchar(255) NOT NULL comment '数据或者对象属性中文名',
|
||||
`constraint_id` bigint(20) unsigned NOT NULL comment '数据属性约束ID',
|
||||
`property_category` varchar(20) NOT NULL comment 'BASIC:该属性为基本类型(实体),ADVANCED:该属性为高级类型(边关系)',
|
||||
`map_type` varchar(20) NOT NULL DEFAULT 'TYPE' comment '标识映射是类型-》属性-》值域还是边的属性-》边属性的属性-》边属性的属性的值域,"TYPE":类型映射 "EDGE":边属性映射',
|
||||
`version` int(11) NOT NULL DEFAULT '0' comment '版本',
|
||||
`status` char(1) NOT NULL comment '9:删除 1:有效 0:无效 默认 和其他schema表对齐',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`original_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment 'spo多版本的原始ID',
|
||||
`store_property_name` varchar(255) DEFAULT NULL comment '数据属性对应的存储属性名',
|
||||
`transformer_id` bigint(20) NOT NULL DEFAULT '0' comment '算子ID',
|
||||
`property_desc` varchar(1024) DEFAULT NULL comment '属性描述',
|
||||
`property_desc_zh` varchar(1024) DEFAULT NULL comment '属性中文描述',
|
||||
`project_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '项目ID',
|
||||
`original_domain_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '类型或边的唯一原始标识',
|
||||
`original_range_id` bigint(20) unsigned NOT NULL DEFAULT '0' comment '类型的唯一原始标识',
|
||||
`version_status` varchar(50) DEFAULT NULL comment '迭代版本状态:ONLINE:线上版本、LATEST:最新版本、EFFICIENT:生效版本、HISTORY:历史版本、DISCARDED:废弃版本',
|
||||
`relation_source` varchar(2550) DEFAULT NULL comment '记录关系对应的属性(用于属性转关系)',
|
||||
`direction` varchar(10) DEFAULT NULL comment 'BOTH:表示双向边',
|
||||
`mask_type` varchar(20) DEFAULT NULL comment '数据加密规则。',
|
||||
`index_type` varchar(1024) DEFAULT NULL comment '索引规则。',
|
||||
`multiver_config` varchar(1024) DEFAULT NULL comment '多版本配置,json格式文本',
|
||||
`property_source` bigint(20) DEFAULT NULL comment '属性的来源,对应全局属性的id',
|
||||
`property_config` text DEFAULT NULL comment '针对属性的配置信息,如运营配置',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_spo`(`domain_id`, `property_name`, `range_id`, `map_type`, `version`),
|
||||
KEY `idx_original_id`(`original_id`),
|
||||
KEY `idx_version_status`(`version_status`),
|
||||
KEY `idx_relation`(`domain_id`, `property_category`, `map_type`, `version_status`),
|
||||
KEY `idx_property_name`(`property_name`),
|
||||
KEY `idx_uk_spo_v2`(`original_domain_id`, `property_name`, `original_range_id`, `map_type`, `version`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体三元组表';
|
||||
|
||||
CREATE TABLE `kg_project_entity` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`project_id` bigint(20) unsigned NOT NULL comment '项目id',
|
||||
`entity_id` bigint(20) unsigned NOT NULL comment '本体类型id',
|
||||
`version` int(11) NOT NULL DEFAULT '0' comment '版本',
|
||||
`version_status` varchar(50) NOT NULL DEFAULT 'ONLINE' comment '迭代版本状态:ONLINE:线上版本、EFFICTIVE:生效版本、RELEASED:已发布版本、DISCARD:废弃版本',
|
||||
`referenced` char(1) NOT NULL comment '标志是否是引用的类型。Y:是,N:不是',
|
||||
`type` varchar(64) DEFAULT 'ENTITY_TYPE' comment '引入的资源类型,关系(RELATION_TYPE)和实体类型(ENTITY_TYPE),默认ENTITY_TYPE',
|
||||
`ref_source` varchar(64) DEFAULT NULL comment '引用来源,corekg:COREKG, 项目:PROJECT',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_project_id_entity_id`(`project_id`, `entity_id`, `version`),
|
||||
KEY `idx_version_status`(`version_status`),
|
||||
KEY `idx_projectid_versionstatus`(`project_id`, `version_status`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '项目和本体类型关联表';
|
||||
|
||||
CREATE TABLE `kg_ontology_semantic` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`resource_id` varchar(128) NOT NULL comment '关联资源id',
|
||||
`semantic_type` varchar(64) NOT NULL comment '谓词',
|
||||
`original_resource_id` varchar(64) NOT NULL comment '被关联资源id',
|
||||
`resource_type` varchar(64) DEFAULT NULL comment '资源类型:entity_type、relation_type、property,可为空,也可有其他类型',
|
||||
`status` int(11) NOT NULL comment '状态,0:删除 1:有效',
|
||||
`config` text DEFAULT NULL comment '预留,谓词额外信息',
|
||||
`rule_id` varchar(128) DEFAULT NULL comment '关联规则ID',
|
||||
`subject_meta_type` varchar(128) DEFAULT NULL comment '主体元概念名',
|
||||
`object_meta_type` varchar(128) DEFAULT NULL comment '客体元概念名',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_spo`(`resource_id`, `semantic_type`, `original_resource_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '语义关联维护表';
|
||||
|
||||
CREATE TABLE `kg_semantic_rule` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`name` varchar(255) DEFAULT NULL comment '名称',
|
||||
`expression` mediumtext NOT NULL comment '内容',
|
||||
`version_id` int(11) NOT NULL comment '版本号',
|
||||
`status` varchar(60) NOT NULL comment '状态',
|
||||
`user_no` varchar(255) NOT NULL comment '用户ID',
|
||||
`is_master` tinyint(4) DEFAULT NULL comment '是否主版本',
|
||||
`rule_id` varchar(512) DEFAULT NULL comment '规则ID',
|
||||
`effect_scope` varchar(60) DEFAULT NULL comment '生效范围',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_id_version`(`rule_id`, `version_id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '语义规则表';
|
||||
|
||||
CREATE TABLE `kg_ontology_property_constraint` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`name` varchar(255) NOT NULL comment '该约束的名称,英文',
|
||||
`name_zh` varchar(255) NOT NULL comment '该约束的中文名称',
|
||||
`is_require` char(1) NOT NULL DEFAULT 'N' comment '空约束,属性值域是否可以为空,"N":可为空 "Y":不可为空',
|
||||
`up_down_boundary` char(1) NOT NULL DEFAULT '0' comment '">":1;">=":2;"<":3;"<=":4;1">""<":5 ">""<=":6 ">=""<":7 ">=""<=":8,,默认0:无校验',
|
||||
`max_value` varchar(255) DEFAULT NULL comment '该属性在该类别下的最大值,仅当数值类型Number及其子类时有效',
|
||||
`min_value` varchar(255) DEFAULT NULL comment '该属性在该类别下的最小值,仅当值类型是Number及其子类时有效',
|
||||
`value_pattern` varchar(1024) DEFAULT NULL comment '正则表达的值规范,多用于文本类型Text',
|
||||
`description` varchar(1024) NOT NULL comment '当前约束的说明/描述信息',
|
||||
`description_zh` varchar(1024) NOT NULL comment '当前约束的中文说明/描述信息',
|
||||
`is_unique` char(1) DEFAULT 'N' comment 'Y:属性唯一约束, N:无唯一约束',
|
||||
`is_enum` char(1) DEFAULT 'N' comment 'Y 是枚举类型,N 不是',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`enum_value` text comment '枚举值',
|
||||
`is_multi_value` char(1) DEFAULT NULL comment '是否多值,Y:多值',
|
||||
PRIMARY KEY(`id`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体属性约束表';
|
||||
|
||||
CREATE TABLE `kg_ontology_release` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`project_id` bigint(20) NOT NULL comment '项目ID',
|
||||
`version` int(11) NOT NULL comment '发布版本',
|
||||
`schema_view` longtext DEFAULT NULL comment '当前版本schema视图',
|
||||
`user_id` varchar(20) NOT NULL comment '发布人',
|
||||
`description` text NOT NULL comment '发布描述',
|
||||
`status` varchar(20) NOT NULL comment '状态',
|
||||
`change_procedure_id` text DEFAULT NULL comment '变更流程id',
|
||||
`operation_detail` text DEFAULT NULL comment '(废弃)本次发布的操作详情',
|
||||
`error_detail` text DEFAULT NULL comment '失败详情',
|
||||
`operation_info` mediumtext DEFAULT NULL comment '本次发布的操作详情',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_project_version`(`project_id`, `version`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMMENT = '本体建模发布版本';
|
||||
|
||||
CREATE TABLE `kg_ontology_ext` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '创建时间',
|
||||
`gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
|
||||
`resource_id` varchar(128) NOT NULL comment '实体类型id、关系类型id、属性id',
|
||||
`resource_type` varchar(64) NOT NULL comment '操作的类型枚举:实体类型、关系类型、属性',
|
||||
`ext_type` varchar(64) NOT NULL comment '扩展类型:标签、回流、颜色',
|
||||
`field` varchar(64) NOT NULL comment '扩展属性所属域,比如区分用户',
|
||||
`config` mediumtext DEFAULT NULL comment '配置内容',
|
||||
`creator` varchar(64) NOT NULL comment '创建者',
|
||||
`modifier` varchar(64) NOT NULL comment '更新者',
|
||||
`status` int(10) unsigned NOT NULL comment '状态 1:有效 0:无效',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY `uk_id_type_field`(`resource_id`, `resource_type`, `ext_type`, `field`)
|
||||
) AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = 'schema的扩展属性';
|
||||
|
||||
INSERT INTO kg_biz_domain (`id`,`gmt_create`,`gmt_modified`,`name`,`status`,`description`,`global_config`) VALUES(1,'2023-09-01 00:00:00','2023-09-01 00:00:00','defaultTenant','VALID','',null);
|
||||
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(1,1,'Thing','事物','ADVANCED','EXTENSION','Base class for all schema types, all of which inherit the type either directly or indirectly','所有schema类型的基类,它们都直接或者间接继承该类型','1','TRUE','PUBLIC',44,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,null,'Thing');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(2,2,'Text','文本','BASIC','CORE','文本','基本数据类型-文本','1','TRUE','PUBLIC',0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REQUIRE","name":"Required","nameZh":"值非空","value":null},{"id":"UNIQUE","name":"Unique","nameZh":"值唯一","value":null},{"id":"ENUM","name":"Enum","nameZh":"枚举","value":null},{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":null}]}','Text');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(4,4,'Integer','整型','BASIC','CORE','整型数字','基本数据类型-整型','1','TRUE','PUBLIC',0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REQUIRE","name":"Required","nameZh":"值非空","value":null},{"id":"ENUM","name":"Enum","nameZh":"枚举","value":null},{"id":"MINIMUM_GT","name":"Greater than","nameZh":"大于","value":null},{"id":"MINIMUM_GT_OE","name":"Greater than or equal","nameZh":"大于等于","value":null},{"id":"MAXIMUM_LT","name":"Less than","nameZh":"小于","value":null},{"id":"MAXIMUM_LT_OE","name":"Less than or equal","nameZh":"小于等于","value":null}]}','Integer');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(5,5,'Float','浮点数','BASIC','CORE','浮点数','基本数据类型-浮点数','1','TRUE','PUBLIC',0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REQUIRE","name":"Required","nameZh":"值非空","value":null},{"id":"ENUM","name":"Enum","nameZh":"枚举","value":null},{"id":"MINIMUM_GT","name":"Greater than","nameZh":"大于","value":null},{"id":"MINIMUM_GT_OE","name":"Greater than or equal","nameZh":"大于等于","value":null},{"id":"MAXIMUM_LT","name":"Less than","nameZh":"小于","value":null},{"id":"MAXIMUM_LT_OE","name":"Less than or equal","nameZh":"小于等于","value":null}]}','Float');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(10,10,'STD.ChinaMobile','国内手机号','STANDARD','CORE','中国国内使用的手机号码由11位数字组成','中国国内使用的手机号码由11位数字组成','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(16[5,6])|(17[0-8])|(18[0-9])|(19[1,5,8,9]))[0-9]{8}$"}],"spreadable":true}','STD.ChinaMobile');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(11,11,'STD.Email','电子邮箱','STANDARD','CORE','电子邮箱地址','电子邮箱地址','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[.][A-Za-z]{2,3}([.][A-Za-z]{2})?$"}],"spreadable":true}','STD.Email');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(13,13,'STD.IdCardNo','身份证','STANDARD','CORE','中国身份证号码一般由18位数字和字母组成','中国身份证号码一般由18位数字和字母组成','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^[1-9]{1}[0-9]{5}(19|20)[0-9]{2}((0[1-9]{1})|(1[0-2]{1}))((0[1-9]{1})|([1-2]{1}[0-9]{1}|(3[0-1]{1})))[0-9]{3}[0-9xX]{1}$"}],"spreadable":true}','STD.IdCardNo');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(14,14,'STD.MacAddress','MAC地址','STANDARD','CORE','网卡MAC地址','网卡MAC地址','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"MULTIVALUE","name":"Multi value","nameZh":"多值","value":null},{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"([A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2}"}],"spreadable":true}','STD.MacAddress');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(19,19,'STD.Date','日期','STANDARD','CORE','8位数字组成的日期','8位数字组成的日期','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"[1,2][0-9][0-9][0-9](0[1-9]|1[0-2])(0[1-9]|[1,2][0-9]|3[0,1])"}]}','STD.Date');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(27,27,'STD.ChinaTelCode','国内通讯号','STANDARD','CORE','国内通讯号码包含常见座机和手机号码','国内通讯号码包含常见座机和手机号码','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^(400[0-9]{7})|(800[0-9]{7})|(0[0-9]{2,3}-[0-9]{7,8})|((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(16[5,6])|(17[0-8])|(18[0-9])|(19[1,5,8,9]))[0-9]{8}$"}],"spreadable":true}','STD.ChinaTelCode');
|
||||
INSERT INTO kg_ontology_entity (`id`,`original_id`,`name`,`name_zh`,`entity_category`,`layer`,`description`,`description_zh`,`status`,`with_index`,`scope`,`version`,`version_status`,`gmt_create`,`gmt_modified`,`transformer_id`,`operator_config`,`config`,`unique_name`) VALUES(29,29,'STD.Timestamp','时间戳','STANDARD','CORE','10位或者13位的时间戳','10位或者13位的时间戳','1','FALSE',null,0,'ONLINE','2023-09-01 00:00:00','2023-09-01 00:00:00',0,null,'{"constrains":[{"id":"REGULAR","name":"Regular match","nameZh":"正则匹配","value":"^([0-9]{10})|([0-9]{13})$"}]}','STD.Timestamp');
|
||||
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(1,10,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,10','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(2,11,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,11','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(4,13,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,13','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(5,14,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,14','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(8,19,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,19','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(12,27,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,27','N', null);
|
||||
INSERT INTO kg_ontology_entity_parent (`id`,`entity_id`,`parent_id`,`status`,`gmt_create`,`gmt_modified`,`path`,`deep_inherit`,`history_path`) VALUES(14,29,1,1,'2023-09-01 00:00:00','2023-09-01 00:00:00','1,29','N', null);
|
||||
|
||||
INSERT INTO kg_ontology_entity_property_range (`id`,`domain_id`,`property_name`,`range_id`,`property_name_zh`,`constraint_id`,`property_category`,`map_type`,`version`,`status`,`gmt_create`,`gmt_modified`,`original_id`,`store_property_name`,`transformer_id`,`property_desc`,`property_desc_zh`,`project_id`,`original_domain_id`,`original_range_id`,`version_status`,`relation_source`,`direction`,`mask_type`,`multiver_config`,`property_source`,`property_config`) VALUES(1,1,'description',2,'描述',0,'BASIC','TYPE',44,'1','2022-03-21 19:24:54','2023-08-27 09:39:04',1,'description',0,null,null,0,1,2,'ONLINE',null,null,null,null,null,null);
|
||||
INSERT INTO kg_ontology_entity_property_range (`id`,`domain_id`,`property_name`,`range_id`,`property_name_zh`,`constraint_id`,`property_category`,`map_type`,`version`,`status`,`gmt_create`,`gmt_modified`,`original_id`,`store_property_name`,`transformer_id`,`property_desc`,`property_desc_zh`,`project_id`,`original_domain_id`,`original_range_id`,`version_status`,`relation_source`,`direction`,`mask_type`,`multiver_config`,`property_source`,`property_config`) VALUES(2,1,'id',2,'实体主键',0,'BASIC','TYPE',44,'1','2022-03-21 19:24:54','2023-08-27 09:39:04',2,'id',0,null,null,0,1,2,'ONLINE',null,null,null,null,null,null);
|
||||
INSERT INTO kg_ontology_entity_property_range (`id`,`domain_id`,`property_name`,`range_id`,`property_name_zh`,`constraint_id`,`property_category`,`map_type`,`version`,`status`,`gmt_create`,`gmt_modified`,`original_id`,`store_property_name`,`transformer_id`,`property_desc`,`property_desc_zh`,`project_id`,`original_domain_id`,`original_range_id`,`version_status`,`relation_source`,`direction`,`mask_type`,`multiver_config`,`property_source`,`property_config`) VALUES(3,1,'name',2,'名称',0,'BASIC','TYPE',44,'1','2022-03-21 19:24:54','2023-08-27 09:39:04',3,'name',0,null,null,0,1,2,'ONLINE',null,null,null,null,null,null);
|
@ -19,6 +19,7 @@ ENV LANG C.UTF-8
|
||||
ARG TARGETPLATFORM
|
||||
ARG APT_INSTALL="apt-get install --no-install-recommends -y"
|
||||
|
||||
|
||||
RUN apt-get clean && apt-get update && \
|
||||
$APT_INSTALL ca-certificates && \
|
||||
$APT_INSTALL ca-certificates-java && \
|
||||
@ -43,10 +44,10 @@ RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
|
||||
RUN python3 -m venv /openspg_venv && \
|
||||
. /openspg_venv/bin/activate && \
|
||||
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture) && \
|
||||
pip3 install openspg-kag==0.5.1 && \
|
||||
pip3 install openspg-kag==0.5.1b3 && \
|
||||
pip3 install pemja==0.4.0 && \
|
||||
pip3 install -U "http://alps-common.oss-cn-hangzhou-zmf.aliyuncs.com/nscommon/shiji/nscommon-0.0.1.tar.gz" &&\
|
||||
echo "if (tty -s); then \n . /openspg_venv/bin/activate \nfi" >> ~/.bashrc
|
||||
|
||||
COPY openspg/ /openspg
|
||||
RUN git clone --depth=1 https://github.com/OpenSPG/KAG.git
|
||||
|
||||
COPY openspg/ /openspg
|
@ -10,7 +10,7 @@
|
||||
# or implied.
|
||||
|
||||
IMAGE="spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-python"
|
||||
VERSION="0.5"
|
||||
VERSION="0.5.1"
|
||||
cd ../../../../
|
||||
docker build -f openspg/dev/release/python/Dockerfile --platform linux/arm64/v8 --push \
|
||||
-t ${IMAGE}:${VERSION}-arm64 \
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
# for amd64
|
||||
docker build -f Dockerfile --platform linux/amd64 --push \
|
||||
-t openspg/openspg-python:0.5 \
|
||||
-t spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-python:0.5.1 \
|
||||
-t spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-python:latest \
|
||||
-t openspg/openspg-python:0.5.1 \
|
||||
-t openspg/openspg-python:latest \
|
||||
.
|
||||
|
@ -10,6 +10,6 @@
|
||||
# or implied.
|
||||
|
||||
docker buildx build -f Dockerfile --platform linux/arm64/v8,linux/amd64 --push \
|
||||
-t openspg/openspg-server:0.5 \
|
||||
-t openspg/openspg-server:latest \
|
||||
-t spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-server:0.5.1 \
|
||||
-t spg-registry.cn-hangzhou.cr.aliyuncs.com/spg/openspg-server:latest \
|
||||
.
|
||||
|
@ -28,11 +28,11 @@ management.endpoint.beans.enable=false
|
||||
management.endpoints.web.exposure.exclude=components,beans
|
||||
|
||||
# schema
|
||||
schema.uri=http://127.0.0.1
|
||||
schema.uri=http://127.0.0.1:8887
|
||||
|
||||
# repository
|
||||
server.repository.driver=com.antgroup.openspg.server.infra.dao.JdbcRepositoryClientDriver
|
||||
server.repository.impl.jdbc.url=jdbc:mysql://${server.repository.impl.jdbc.host}:${server.repository.impl.jdbc.port}/openspg?useUnicode=true&characterEncoding=utf8
|
||||
server.repository.impl.jdbc.url=jdbc:mysql://${server.repository.impl.jdbc.host}:${server.repository.impl.jdbc.port}/openspg?useUnicode=true&characterEncoding=utf8&autoReconnect=true
|
||||
server.repository.impl.jdbc.host=127.0.0.1
|
||||
server.repository.impl.jdbc.port=3306
|
||||
server.repository.impl.jdbc.username=root
|
||||
|
@ -27,6 +27,8 @@ public interface ProjectManager {
|
||||
|
||||
Project queryById(Long projectId);
|
||||
|
||||
Integer deleteById(Long projectId);
|
||||
|
||||
List<Project> query(ProjectQueryRequest request);
|
||||
|
||||
Paged<Project> queryPaged(ProjectQueryRequest request, int start, int size);
|
||||
|
@ -44,7 +44,7 @@ public class ProjectManagerImpl implements ProjectManager {
|
||||
@Override
|
||||
public Project create(ProjectCreateRequest request) {
|
||||
JSONObject config = setDatabase(request.getConfig(), request.getNamespace());
|
||||
createNeo4jDatabase(request.getNamespace(), config);
|
||||
setGraphStore(request.getNamespace(), config, true);
|
||||
Project project =
|
||||
new Project(
|
||||
null,
|
||||
@ -62,6 +62,7 @@ public class ProjectManagerImpl implements ProjectManager {
|
||||
public Project update(ProjectCreateRequest request) {
|
||||
Project project = projectRepository.queryById(request.getId());
|
||||
JSONObject config = setDatabase(request.getConfig(), project.getNamespace());
|
||||
setGraphStore(request.getNamespace(), config, false);
|
||||
config = setVectorDimensions(config, project);
|
||||
Project update = new Project(request.getId(), null, null, null, null, config.toJSONString());
|
||||
return projectRepository.update(update);
|
||||
@ -113,7 +114,31 @@ public class ProjectManagerImpl implements ProjectManager {
|
||||
return projectRepository.queryById(projectId);
|
||||
}
|
||||
|
||||
public void createNeo4jDatabase(String namespace, JSONObject config) {
|
||||
@Override
|
||||
public Integer deleteById(Long projectId) {
|
||||
Project project = projectRepository.queryById(projectId);
|
||||
if (project == null) {
|
||||
return 0;
|
||||
}
|
||||
deleteDatabase(project);
|
||||
|
||||
return projectRepository.deleteById(projectId);
|
||||
}
|
||||
|
||||
public void deleteDatabase(Project project) {
|
||||
JSONObject config = JSONObject.parseObject(project.getConfig());
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(url).build();
|
||||
String database = uriComponents.getQueryParams().getFirst(Neo4jConstants.DATABASE);
|
||||
JSONObject graphStore = config.getJSONObject(CommonConstants.GRAPH_STORE);
|
||||
String host = graphStore.getString(Neo4jConstants.URI);
|
||||
String user = graphStore.getString(Neo4jConstants.USER);
|
||||
String password = graphStore.getString(Neo4jConstants.PASSWORD);
|
||||
String dropDatabase = project.getNamespace().toLowerCase();
|
||||
Neo4jAdminUtils driver = new Neo4jAdminUtils(host, user, password, database);
|
||||
driver.neo4jGraph.dropDatabase(dropDatabase);
|
||||
}
|
||||
|
||||
public void setGraphStore(String namespace, JSONObject config, boolean createDatabase) {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(url).build();
|
||||
String database = uriComponents.getQueryParams().getFirst(Neo4jConstants.DATABASE);
|
||||
String host =
|
||||
@ -137,10 +162,11 @@ public class ProjectManagerImpl implements ProjectManager {
|
||||
} else {
|
||||
graphStore.put(Neo4jConstants.PASSWORD, password);
|
||||
}
|
||||
|
||||
Neo4jAdminUtils driver = new Neo4jAdminUtils(host, user, password, database);
|
||||
String projectDatabase = namespace.toLowerCase();
|
||||
driver.neo4jGraph.createDatabase(projectDatabase);
|
||||
if (createDatabase) {
|
||||
Neo4jAdminUtils driver = new Neo4jAdminUtils(host, user, password, database);
|
||||
String projectDatabase = namespace.toLowerCase();
|
||||
driver.neo4jGraph.createDatabase(projectDatabase);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,5 +28,7 @@ public interface ProjectRepository {
|
||||
|
||||
List<Project> query(ProjectQueryRequest request);
|
||||
|
||||
Integer deleteById(Long projectId);
|
||||
|
||||
Paged<Project> queryPaged(ProjectQueryRequest request, int start, int size);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
default-autowire="byName">
|
||||
|
||||
<bean id="appEnvConfig" class="com.antgroup.openspg.server.common.service.config.AppEnvConfig">
|
||||
<property name="schemaUri" value="${schema.uri}:${server.port}"/>
|
||||
<property name="schemaUri" value="${schema.uri}"/>
|
||||
<property name="graphStoreUrl" value="${cloudext.graphstore.url}"/>
|
||||
<property name="searchEngineUrl" value="${cloudext.searchengine.url}"/>
|
||||
</bean>
|
||||
|
@ -25,6 +25,22 @@ public interface ProjectDOMapper {
|
||||
|
||||
int deleteByPrimaryKey(Long id);
|
||||
|
||||
void deleteFromKgOntologyEntity(String namespace);
|
||||
|
||||
void deleteFromKgOntologyEntityPropertyRange(Long id);
|
||||
|
||||
void deleteFromKgProjectEntity(Long id);
|
||||
|
||||
void deleteFromKgOntologyRelease(Long id);
|
||||
|
||||
void deleteFromKgReasonSession(Long id);
|
||||
|
||||
void deleteFromKgReasonTask(Long id);
|
||||
|
||||
void deleteFromKgReasonTutorial(Long id);
|
||||
|
||||
void deleteFromKgBuilderJob(Long id);
|
||||
|
||||
int insert(ProjectDO record);
|
||||
|
||||
int insertSelective(ProjectDO record);
|
||||
|
@ -24,11 +24,13 @@ import com.antgroup.openspg.server.infra.dao.dataobject.ProjectDOExample;
|
||||
import com.antgroup.openspg.server.infra.dao.mapper.ProjectDOMapper;
|
||||
import com.antgroup.openspg.server.infra.dao.repository.common.convertor.ProjectConvertor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Repository
|
||||
public class ProjectRepositoryImpl implements ProjectRepository {
|
||||
@ -48,6 +50,8 @@ public class ProjectRepositoryImpl implements ProjectRepository {
|
||||
throw ProjectException.namespaceAlreadyExist(project.getNamespace());
|
||||
}
|
||||
ProjectDO projectDO = ProjectConvertor.toDO(project);
|
||||
projectDO.setGmtModified(new Date());
|
||||
projectDO.setGmtCreate(new Date());
|
||||
projectDOMapper.insert(projectDO);
|
||||
return projectDO.getId();
|
||||
}
|
||||
@ -65,6 +69,21 @@ public class ProjectRepositoryImpl implements ProjectRepository {
|
||||
return ProjectConvertor.toModel(projectDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public Integer deleteById(Long projectId) {
|
||||
ProjectDO projectDO = projectDOMapper.selectByPrimaryKey(projectId);
|
||||
projectDOMapper.deleteFromKgOntologyEntity(projectDO.getNamespace());
|
||||
projectDOMapper.deleteFromKgOntologyEntityPropertyRange(projectId);
|
||||
projectDOMapper.deleteFromKgProjectEntity(projectId);
|
||||
projectDOMapper.deleteFromKgOntologyRelease(projectId);
|
||||
projectDOMapper.deleteFromKgReasonSession(projectId);
|
||||
projectDOMapper.deleteFromKgReasonTask(projectId);
|
||||
projectDOMapper.deleteFromKgReasonTutorial(projectId);
|
||||
projectDOMapper.deleteFromKgBuilderJob(projectId);
|
||||
return projectDOMapper.deleteByPrimaryKey(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> query(ProjectQueryRequest request) {
|
||||
ProjectDOExample example = new ProjectDOExample();
|
||||
|
@ -107,8 +107,31 @@
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from kg_project_info
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
delete from kg_project_info where id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgOntologyEntity" parameterType="java.lang.String">
|
||||
DELETE FROM kg_ontology_entity WHERE name like concat(#{namespace}, '.%') ;
|
||||
</delete>
|
||||
<delete id="deleteFromKgOntologyEntityPropertyRange" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_ontology_entity_property_range WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgProjectEntity" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_project_entity WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgOntologyRelease" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_ontology_release WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgReasonSession" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_reason_session WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgReasonTask" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_reason_task WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgReasonTutorial" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_reason_tutorial WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteFromKgBuilderJob" parameterType="java.lang.Long">
|
||||
DELETE FROM kg_builder_job WHERE id = #{id,jdbcType=BIGINT};
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.antgroup.openspg.server.infra.dao.dataobject.ProjectDOExample">
|
||||
delete from kg_project_info
|
||||
|
@ -28,7 +28,7 @@
|
||||
</commentGenerator>
|
||||
|
||||
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
|
||||
connectionURL="jdbc:mysql://127.0.0.1:3306/openspg?useUnicode=true&characterEncoding=utf8"
|
||||
connectionURL="jdbc:mysql://127.0.0.1:3306/openspg?useUnicode=true&characterEncoding=utf8&autoReconnect=true"
|
||||
userId="root"
|
||||
password="openspg">
|
||||
</jdbcConnection>
|
||||
|
Loading…
x
Reference in New Issue
Block a user