Merge remote-tracking branch 'origin/dev_2.1.0' into dev_2.1.0

dev_2.1.0
xueqingkun 1 year ago
commit c72e96f355

@ -36,6 +36,42 @@
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.2</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>com.vesoft</groupId>
<artifactId>client</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>

@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication
@MapperScan(basePackages = {"com.supervision.**.mapper"})
@EnableNeo4jRepositories("com.**.repo")

@ -0,0 +1,35 @@
package com.supervision.nebula.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.List;
/**
* @author fulin
*/
@Configuration
@ConfigurationProperties(prefix = "nebula")
@EnableConfigurationProperties(NebulaGraphProperties.class)
@Data
public class NebulaGraphProperties {
private String userName;
private String password;
/**
* ip:prot
*/
private List<String> hostAddresses;
private int minConnSize;
private int maxConnSize;
private int timeout;
private int idleTime;
}

@ -0,0 +1,28 @@
package com.supervision.nebula.config;
import com.vesoft.nebula.client.graph.net.Session;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* @author fulin
* session
**/
@Component
@RequiredArgsConstructor
public class NebulaSession {
private final NebulaGraphProperties nebulaGraphProperties;
@Bean
public Session session() throws Exception {
SessionPool sessionPool = new SessionPool(nebulaGraphProperties.getMaxConnSize(),
nebulaGraphProperties.getMinConnSize(),
nebulaGraphProperties.getHostAddresses().get(0),
nebulaGraphProperties.getUserName(),
nebulaGraphProperties.getPassword());
return sessionPool.borrow();
}
}

@ -0,0 +1,120 @@
package com.supervision.nebula.config;
import com.vesoft.nebula.client.graph.NebulaPoolConfig;
import com.vesoft.nebula.client.graph.data.HostAddress;
import com.vesoft.nebula.client.graph.exception.AuthFailedException;
import com.vesoft.nebula.client.graph.exception.ClientServerIncompatibleException;
import com.vesoft.nebula.client.graph.exception.IOErrorException;
import com.vesoft.nebula.client.graph.exception.NotValidConnectionException;
import com.vesoft.nebula.client.graph.net.NebulaPool;
import com.vesoft.nebula.client.graph.net.Session;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.PreDestroy;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
/**
* @author fulin
* SessionPool
*/
@Slf4j
public class SessionPool {
private final Queue<Session> queue;
private final String userName;
private final String passWord;
private final int minCountSession;
private final int maxCountSession;
private final NebulaPool pool;
/**
*
*
* @param maxCountSession
* @param minCountSession
* @param hostAndPort
* @param userName
* @param passWord
* @throws UnknownHostException
* @throws NotValidConnectionException
* @throws IOErrorException
* @throws AuthFailedException
*/
public SessionPool(int maxCountSession, int minCountSession, String hostAndPort, String userName, String passWord) throws UnknownHostException, NotValidConnectionException, IOErrorException, AuthFailedException, ClientServerIncompatibleException {
this.minCountSession = minCountSession;
this.maxCountSession = maxCountSession;
this.userName = userName;
this.passWord = passWord;
this.queue = new LinkedBlockingQueue<>(minCountSession);
this.pool = this.initGraphClient(hostAndPort, maxCountSession, minCountSession);
initSession();
}
public Session borrow() {
Session se = queue.poll();
if (se != null) {
return se;
}
try {
return this.pool.getSession(userName, passWord, true);
} catch (Exception e) {
log.error("execute borrow session fail, detail: ", e);
throw new RuntimeException(e);
}
}
@PreDestroy
public void release() {
Queue<Session> queue = this.queue;
for (Session se : queue) {
if (se != null) {
boolean success = this.queue.offer(se);
if (!success) {
se.release();
}
}
}
}
public void close() {
this.pool.close();
}
private void initSession() throws NotValidConnectionException, IOErrorException, AuthFailedException, ClientServerIncompatibleException {
for (int i = 0; i < minCountSession; i++) {
queue.offer(this.pool.getSession(userName, passWord, true));
}
}
private NebulaPool initGraphClient(String hostAndPort, int maxConnSize, int minCount) throws UnknownHostException {
List<HostAddress> hostAndPorts = getGraphHostPort(hostAndPort);
NebulaPool pool = new NebulaPool();
NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
nebulaPoolConfig = nebulaPoolConfig.setMaxConnSize(maxConnSize);
nebulaPoolConfig = nebulaPoolConfig.setMinConnSize(minCount);
nebulaPoolConfig = nebulaPoolConfig.setIdleTime(1000 * 600);
pool.init(hostAndPorts, nebulaPoolConfig);
return pool;
}
private List<HostAddress> getGraphHostPort(String hostAndPort) {
String[] split = hostAndPort.split(",");
return Arrays.stream(split).map(item -> {
String[] splitList = item.split(":");
return new HostAddress(splitList[0], Integer.parseInt(splitList[1]));
}).collect(Collectors.toList());
}
}

@ -0,0 +1,18 @@
package com.supervision.nebula.constant;
import lombok.Getter;
/**
*
*
* @author fulin
*/
@Getter
public enum AttributeEnum {
// 实体类型
TAGS,
// 关系类型
EDGES,
// 空间
SPACES;
}

@ -0,0 +1,32 @@
package com.supervision.nebula.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author fulin
*/
@AllArgsConstructor
@Getter
public enum ConditionEnum {
// 比较判断
("EQUAL", "=="),
("CONTAINS", "CONTAINS"),
("STARTS", "STARTS WITH"),
("ENDS", "ENDS WITH");
private String name;
private String code;
public static String getCode(String name) {
ConditionEnum[] values = ConditionEnum.values();
for (ConditionEnum conditionEnum : values) {
if (name.equalsIgnoreCase(conditionEnum.getName())) {
return conditionEnum.getCode();
}
}
return "";
}
}

@ -0,0 +1,59 @@
package com.supervision.nebula.constant;
import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;
/**
* @author fulin
*/
@Getter
@AllArgsConstructor
public enum EdgeDirectionEnum {
// 边方向
("OUTFLOW", "", ">", "OUT"),
("INFLOW", "<", "", "IN"),
("TWO-WAY", "", "", "BOTH");
private String name;
private String left;
private String right;
private String direct;
/**
* @return java.util.List<java.lang.String>
* @Description
* @Param [name]
**/
public static List<String> getLeftAndRight(String name) {
EdgeDirectionEnum[] values = EdgeDirectionEnum.values();
List<String> results = CollectionUtil.newArrayList();
for (EdgeDirectionEnum edgeDirectionEnum : values) {
if (name.equalsIgnoreCase(edgeDirectionEnum.getName())) {
results.add(edgeDirectionEnum.getLeft());
results.add(edgeDirectionEnum.getRight());
return results;
}
}
results.add("");
results.add("");
return results;
}
public static String getDirection(String name) {
EdgeDirectionEnum[] values = EdgeDirectionEnum.values();
for (EdgeDirectionEnum edgeDirectionEnum : values) {
if (name.equalsIgnoreCase(edgeDirectionEnum.getName())) {
return edgeDirectionEnum.getDirect();
}
}
return "BOTH";
}
}

@ -0,0 +1,19 @@
package com.supervision.nebula.constant;
import com.google.common.base.Joiner;
/**
* GQL
*
* @author fulin by 2022/3/28
*/
public class GqlConstant {
public static final String UNKNOWN = "unknown";
public static final String ID = "id";
public static final Joiner GQL_UNION_JOINER = Joiner.on(" UNION ");
public static final Joiner GQL_UNION_COMMA = Joiner.on(",");
private GqlConstant() {
}
}

@ -0,0 +1,55 @@
package com.supervision.nebula.controller;
import com.github.pagehelper.PageInfo;
import com.supervision.nebula.dto.graph.GraphPageAttribute;
import com.supervision.nebula.dto.graph.GraphShowAttribute;
import com.supervision.nebula.dto.graph.GraphShowInfo;
import com.supervision.nebula.service.AttributeService;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.vo.AttributeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/attribute")
@Api(tags = "属性查询控制器")
@RequiredArgsConstructor
public class AttributeController {
private final GraphCommonService graphCommonService;
private final AttributeService attributeService;
@PostMapping("/list")
@ApiOperation("属性查询(spaces tags edges列表)")
public List<AttributeVo> showAttribute(@RequestBody GraphShowAttribute graphShowAttribute) {
return attributeService.showAttribute(graphShowAttribute);
}
@PostMapping("/page")
@ApiOperation("属性分页查询 tags edges 分页列表")
public PageInfo<AttributeVo.DataBean> pageListAttribute(@RequestBody GraphPageAttribute graphPageAttribute) {
return attributeService.pageListAttribute(graphPageAttribute);
}
@PostMapping("/listProperty")
@ApiOperation("属性的子属性列表查询 tag edge 的属性列表查询")
public List<AttributeVo> showAttributeInfo(@RequestBody GraphShowInfo graphShowInfo) {
return attributeService.showAttributeInfo(graphShowInfo);
}
@PostMapping("/propertyInfo")
@ApiOperation("属性的详细信息")
public List<AttributeVo> showCreateAttributeInfo(@RequestBody GraphShowInfo graphShowInfo) {
return attributeService.showCreateAttributeInfo(graphShowInfo);
}
}

@ -0,0 +1,52 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.graph.GraphAddAttribute;
import com.supervision.nebula.dto.graph.GraphDelAttribute;
import com.supervision.nebula.dto.graph.GraphDropAttribute;
import com.supervision.nebula.service.AttributeService;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.CommonVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author fulin
*/
@RestController
@RequestMapping("/attribute")
@Api(tags = "属性编辑控制器")
@RequiredArgsConstructor
public class AttributeManageController {
private final GraphCommonService graphCommonService;
private final AttributeService attributeService;
@PostMapping("/dropAttribute")
@ApiOperation("删除属性(删除 space空间 tag标签 edge边类型)")
public List<CommonVo> dropAttribute(@RequestBody GraphDropAttribute graphDropAttribute) {
return attributeService.dropAttribute(graphDropAttribute);
}
@PostMapping("/addAttributeProperty")
@ApiOperation("增加属性的子属性(tag标签的属性 edge边类型的属性)")
public List<CommonVo> addAttributeProperty(@RequestBody GraphAddAttribute graphAddAttribute) {
return attributeService.addAttributeProperty(graphAddAttribute);
}
@PostMapping("/delAttributeProperty")
@ApiOperation("删除属性的子属性(tag标签的属性 edge边类型的属性)")
public List<CommonVo> delAttributeProperty(@RequestBody GraphDelAttribute graphDelAttribute) {
return graphCommonService.executeJson(NebulaUtil.delAttributeProperty(graphDelAttribute), CommonVo.class);
}
}

@ -0,0 +1,37 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.NebulaVertexJsonResult;
import com.supervision.nebula.dto.graph.GraphSpace;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.util.NebulaUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author fulin
* @Descriptin:
* @ClassName: VertexController
*/
@RestController
@Api(tags = "边edge查询控制器")
@RequestMapping("/edge")
@RequiredArgsConstructor
public class EdgeController {
private final GraphCommonService graphCommonService;
@PostMapping("/listEdge")
@ApiOperation("查询插入的边edge(绑定关系查询)")
public List<NebulaVertexJsonResult> listEdge(@RequestBody GraphSpace graphSpace) {
return graphCommonService.executeJson(NebulaUtil.listEdge(graphSpace), NebulaVertexJsonResult.class);
}
}

@ -0,0 +1,47 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.graph.GraphDeleteEdge;
import com.supervision.nebula.dto.graph.GraphInsertEdge;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.CommonVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author fulin
* @Descriptin:
* @ClassName: VertexController
*/
@RestController
@Api(tags = "边edge管理控制器")
@RequestMapping("/edge")
@RequiredArgsConstructor
public class EdgeManageController {
private final GraphCommonService graphCommonService;
@PostMapping("/insertEdge")
@ApiOperation("插入边edge(关系编辑-绑定两个点的关系)")
public List<CommonVo> insertEdge(@RequestBody GraphInsertEdge graphInsertEdge) {
String vidType = graphCommonService.getVidType(graphInsertEdge.getSpace());
return graphCommonService.executeJson(NebulaUtil.insertEdge(graphInsertEdge, vidType), CommonVo.class);
}
@PostMapping("/deleteEdge")
@ApiOperation("删除边edge(解除关系编辑-解除两个点的关系)")
public List<CommonVo> deleteEdge(@RequestBody GraphDeleteEdge graphDeleteEdge) {
String vidType = graphCommonService.getVidType(graphDeleteEdge.getSpace());
return graphCommonService.executeJson(NebulaUtil.deleteEdge(graphDeleteEdge, vidType), CommonVo.class);
}
}

@ -0,0 +1,57 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.ImportBean;
import com.supervision.nebula.entity.GraphFile;
import com.supervision.nebula.service.GraphFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* (GraphFile)
*
* @author makejava
* @since 2022-08-23 09:09:26
*/
@RestController
@Api(tags = "文件控制器")
@RequestMapping("graphFile")
public class GraphFileController {
@Resource
private GraphFileService graphFileService;
/**
*
*
* @param file
* @return
*/
@ApiOperation("文件上传--可以不做,这里为了预览数据")
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public GraphFile uploadFile(@RequestParam("file") MultipartFile file) {
return this.graphFileService.uploadFile(file);
}
@ApiOperation("文件导入--执行nebula import插件")
@PostMapping("/import")
public Boolean importFile(@RequestBody ImportBean importBean) throws IOException {
return this.graphFileService.importFile(importBean);
}
@ApiOperation("模板下载,可以填充数据")
@GetMapping("/template")
public void template(@RequestParam String space, HttpServletResponse response) {
graphFileService.template(space, response);
}
}

@ -0,0 +1,64 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.graph.GraphCreateSpace;
import com.supervision.nebula.dto.graph.GraphShowAttribute;
import com.supervision.nebula.dto.graph.GraphSpace;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.service.SpaceService;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.AttributeVo;
import com.supervision.nebula.vo.CommonVo;
import com.supervision.nebula.vo.DetailSpace;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author fulin
* space
*/
@RestController
@Api(tags = "图谱space控制器")
@RequestMapping("/space")
@RequiredArgsConstructor
public class SpaceController {
private final GraphCommonService graphCommonService;
private final SpaceService spaceService;
@PostMapping("/create")
@ApiOperation("创建图谱")
public List<CommonVo> createSpace(@RequestBody GraphCreateSpace graphCreateSpace) {
return spaceService.createSpace(graphCreateSpace);
}
@PostMapping("/use")
@ApiOperation("切换图谱")
public List<CommonVo> useSpace(@RequestBody GraphCreateSpace graphCreateSpace) {
return graphCommonService.executeJson(NebulaUtil.useSpace(graphCreateSpace.getSpace()), CommonVo.class);
}
@PostMapping("/list")
@ApiOperation("卡片展示列表(图谱详情)")
public List<DetailSpace> detailSpace(@RequestBody GraphShowAttribute graphShowAttribute) {
return spaceService.detailSpace(graphShowAttribute);
}
@PostMapping("/info")
@ApiOperation("查询某个空间的信息")
public List<AttributeVo> spaceInfo(@RequestBody GraphSpace graphSpace) {
return spaceService.spaceInfo(graphSpace.getSpace());
}
}

@ -0,0 +1,31 @@
package com.supervision.nebula.controller;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.supervision.nebula.service.GraphCommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(tags = "子图查询控制器")
@RequestMapping("/subGraph")
@RequiredArgsConstructor
public class SubGraphController {
private final GraphCommonService graphCommonService;
@PostMapping("querySubGraph")
@ApiOperation("子图查询")
public JSONObject querySubGraph() {
String subgraphQuery = "use subgraph;GET SUBGRAPH 100 STEPS FROM \"player101\" YIELD VERTICES AS `vertices_`, EDGES AS `edges_`;";
String s = graphCommonService.executeJson(subgraphQuery);
return JSONUtil.parseObj(s);
}
}

@ -0,0 +1,43 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.graph.GraphCreateIndex;
import com.supervision.nebula.dto.graph.GraphCreateTagEdge;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.CommonVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author fulin
* tag
*/
@RestController
@Api(tags = "标签tag edge 新增控制器")
@RequestMapping("/tagEdge")
public class TagEdgeController {
@Autowired
GraphCommonService graphCommonService;
@PostMapping("/createTagEdge")
@ApiOperation("创建tag 或者 edge")
public List<CommonVo> createTagEdge(@RequestBody GraphCreateTagEdge graphCreateTagEdge) {
return graphCommonService.executeJson(NebulaUtil.createTagEdge(graphCreateTagEdge), CommonVo.class);
}
@PostMapping("/createIndex")
@ApiOperation("创建索引")
public List<CommonVo> createIndex(@RequestBody GraphCreateIndex graphCreateIndex) {
return graphCommonService.executeJson(NebulaUtil.createIndex(graphCreateIndex), CommonVo.class);
}
}

@ -0,0 +1,69 @@
package com.supervision.nebula.controller;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.supervision.nebula.dto.NebulaJsonConverter;
import com.supervision.nebula.dto.NebulaVertexJsonResult;
import com.supervision.nebula.dto.graph.*;
import com.supervision.nebula.service.VertexService;
import com.supervision.nebula.vo.AttributeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
*
* @author fulin
*/
@RestController
@Api(tags = "点查询(实体)控制器")
@RequestMapping("/vertex")
@RequiredArgsConstructor
public class VertexController {
private final VertexService vertexService;
@PostMapping("/vertexList")
@ApiOperation("查询创建的点列表")
public List<NebulaVertexJsonResult> vertexList(@RequestBody GraphSpace graphSpace) {
return vertexService.vertexList(graphSpace.getSpace());
}
@PostMapping("/vertexTagsQuery")
@ApiOperation("根据tag标签查询点")
public List<NebulaVertexJsonResult> vertexTagsQuery(@RequestBody GraphVertexTatsQuery graphVertexTatsQuery) {
return vertexService.vertexTagsQuery(graphVertexTatsQuery);
}
@PostMapping("/vertexTagAttributeQuery")
@ApiOperation("根据tag标签属性查询点(先要保证该标签属性已经建立索引)")
public List<NebulaVertexJsonResult> vertexTagAttributeQuery(@RequestBody GraphVertexTatAttributeQuery graphVertexTatAttributeQuery) {
return vertexService.vertexTagAttributeQuery(graphVertexTatAttributeQuery);
}
@PostMapping("/expandQuery")
@ApiOperation("根据点以及边信息扩展查询")
public GraphData vertexExpandQuery(@RequestBody GraphExpand graphExpand) {
List<NebulaVertexJsonResult> data = vertexService.vertexExpandQuery(graphExpand);
JSONArray objects = JSONUtil.parseArray(JSONUtil.toJsonStr(data));
return NebulaJsonConverter.toGraphDataMain(objects, new ArrayList<AttributeVo>());
}
@PostMapping("/page")
@ApiOperation("查询创建的点分页列表")
public Map<String, Object> vertexPage(@RequestBody GraphVertexTatsQuery graphVertexTatsQuery) {
return vertexService.vertexPage(graphVertexTatsQuery);
}
}

@ -0,0 +1,44 @@
package com.supervision.nebula.controller;
import com.supervision.nebula.dto.graph.GraphCreateVertex;
import com.supervision.nebula.dto.graph.GraphDeleteVertex;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.CommonVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author fulin
*
*/
@RestController
@Api(tags = "点编辑(实体)控制器")
@RequestMapping("/vertex")
@RequiredArgsConstructor
public class VertexManageController {
private final GraphCommonService graphCommonService;
@PostMapping("/createVertex")
@ApiOperation("创建点(需要附加标签tag信息)")
public List<CommonVo> createVertex(@RequestBody GraphCreateVertex graphCreateVertex) {
String vidType = graphCommonService.getVidType(graphCreateVertex.getSpace());
return graphCommonService.executeJson(NebulaUtil.createPoint(graphCreateVertex, vidType), CommonVo.class);
}
@PostMapping("/deleteVertex")
@ApiOperation("删除点(根据点id删除)")
public List<CommonVo> deleteVertex(@RequestBody GraphDeleteVertex graphDeleteVertex) {
String vidType = graphCommonService.getVidType(graphDeleteVertex.getSpace());
return graphCommonService.executeJson(NebulaUtil.deleteVertex(graphDeleteVertex, vidType), CommonVo.class);
}
}

@ -0,0 +1,15 @@
package com.supervision.nebula.dto;
import lombok.Data;
@Data
public class EdgeCombo {
/**
* id
*/
private Integer fileId;
/**
*
*/
private EdgeElement edgeElement;
}

@ -0,0 +1,27 @@
package com.supervision.nebula.dto;
import lombok.Data;
import java.util.List;
@Data
public class EdgeElement {
/**
*
*/
private String elementName;
/**
*
*/
private Integer srcId;
/**
*
*/
private Integer dstId;
private Integer rank;
/**
*
*/
private List<Property> properties;
}

@ -0,0 +1,21 @@
package com.supervision.nebula.dto;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Map;
/**
* -
*
* @author fulin by 2022/3/29
*/
@Builder
@Data
@EqualsAndHashCode(of = "id")
public class FailureTroubleshootingVo {
private String id;
private String tag;
private Map<String, String> properties;
}

@ -0,0 +1,22 @@
package com.supervision.nebula.dto;
import lombok.Data;
import java.util.List;
@Data
public class ImportBean {
/**
*
*/
private String space;
/**
*
*/
private List<VertexCombo> vertices;
/**
*
*/
private List<EdgeCombo> edges;
}

@ -0,0 +1,23 @@
package com.supervision.nebula.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: ImportDto
*/
@Data
@ApiModel("数据导入入参")
public class ImportDto {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "attribute可选值: tag标签/edge边类型", example = "tag", required = true)
private String attribute;
@ApiModelProperty(value = "属性名称", example = "t1", required = true)
private String attributeName;
}

@ -0,0 +1,156 @@
package com.supervision.nebula.dto;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.google.common.collect.Sets;
import com.supervision.nebula.constant.GqlConstant;
import com.supervision.nebula.dto.graph.GraphData;
import com.supervision.nebula.dto.graph.GraphEdge;
import com.supervision.nebula.dto.graph.GraphNode;
import com.supervision.nebula.dto.graph.NodeType;
import com.supervision.nebula.vo.AttributeVo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author fulin by 2022/3/30
*/
public class NebulaJsonConverter {
/**
* @param jsonArray
* @param attributeVos
* @return
*/
public static GraphData toGraphDataMain(JSONArray jsonArray, List<AttributeVo> attributeVos) {
final JSONObject jsonObject = jsonArray.getJSONObject(0);
final JSONArray data = jsonObject.getJSONArray("data");
if (ObjectUtil.isNull(data)) {
return new GraphData();
}
final Set<GraphNode> nodes = Sets.newHashSet();
final Set<GraphEdge> edges = Sets.newHashSet();
final List<NodeType> nodeTypeList = CollectionUtil.newArrayList();
final Set<String> tagSet = CollectionUtil.newHashSet();
//List<AttributeVo.DataBean> dataBeanList = attributeVos.get(0).getData();
for (int d = 0; d < data.size(); d++) {
final JSONObject dataJSONObject = data.getJSONObject(d);
// meta 数据结构: [[]]
final JSONArray meta = dataJSONObject.getJSONArray("meta");
final JSONArray row = dataJSONObject.getJSONArray("row");
for (int i = 0; i < meta.size(); i++) {
final JSONArray metaJSONArray = meta.getJSONArray(i);
final JSONArray rowJSONArray = row.getJSONArray(i);
for (int i1 = 0; i1 < metaJSONArray.size(); i1++) {
final JSONObject oneMeta = metaJSONArray.getJSONObject(i1);
final JSONObject oneRow = rowJSONArray.getJSONObject(i1);
final String type = oneMeta.getStr("type");
Object tagInfo = null;
Object edgeInfo = null;
switch (type) {
case "vertex":
String tag = GqlConstant.UNKNOWN;
String name = GqlConstant.UNKNOWN;
String color = "#289D73";
tagInfo = oneRow.entrySet();
for (Map.Entry<String, Object> entry : oneRow.entrySet()) {
final String key = entry.getKey();
if (key.endsWith("name")) {
final Object value = entry.getValue();
final String[] split = key.split("\\.");
tag = split[0];
name = value.toString();
break;
}
}
String nodeTypes = GqlConstant.UNKNOWN;
if (ObjectUtil.notEqual(GqlConstant.UNKNOWN, tag)) {
nodeTypes = tag;
}
nodes.add(GraphNode.builder()
.id(oneMeta.getStr("id"))
.tag(tag)
.label(name)
.nodeTypes(nodeTypes)
.tagInfo(tagInfo)
.build());
HashMap<String, String> colorMap = MapUtil.newHashMap();
colorMap.put("fill", color);
colorMap.put("size", "50");
//for (AttributeVo.DataBean dataBean : dataBeanList) {
// List<String> row1 = dataBean.getRow();
// if (CollectionUtil.isNotEmpty(row1)) {
// String tagName = row1.get(0);
// if (StrUtil.isNotBlank(tagName)) {
// if (tagName.equalsIgnoreCase(tag) && row1.size() > 1) {
// colorMap.put("fill", row1.get(1));
// colorMap.put("size", row1.get(2));
// }
// }
// }
//}
if (!tagSet.contains(tag)) {
nodeTypeList.add(
NodeType
.builder()
.id(oneMeta.getStr("id"))
.label(tag)
.style(colorMap)
.build()
);
}
tagSet.add(tag);
break;
case "edge":
final JSONObject id = oneMeta.getJSONObject("id");
edgeInfo = oneRow.entrySet();
int typeFX = Integer.parseInt(id.get("type").toString());
if (typeFX > 0) {
edges.add(
GraphEdge.builder()
.source(id.getStr("src"))
.target(id.getStr("dst"))
.label(id.getStr("name"))
.edgeInfo(edgeInfo)
.build()
);
}
if (typeFX < 0) {
edges.add(
GraphEdge.builder()
.source(id.getStr("dst"))
.target(id.getStr("src"))
.label(id.getStr("name"))
.edgeInfo(edgeInfo)
.build()
);
}
break;
default:
throw new RuntimeException("type not found");
}
}
}
}
return GraphData.builder()
.nodes(nodes)
.edges(edges)
.NodeTypes(nodeTypeList)
.build();
}
}

@ -0,0 +1,74 @@
package com.supervision.nebula.dto;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Nebula-Graph session json
* json
*
* @author fulin by 2022/3/29
*/
@Data
@ApiModel("返回类")
public class NebulaVertexJsonResult {
@ApiModelProperty(value = "空间名称")
private String spaceName;
@ApiModelProperty(value = "潜伏期")
private int latencyInUs;
@ApiModelProperty(value = "数据集合")
private List<OneData> data;
@ApiModelProperty(value = "字段")
private List<String> columns;
public Set<FailureTroubleshootingVo> toFailureTroubleshootingVos() {
final List<OneData> data = this.getData();
final Set<FailureTroubleshootingVo> r = Sets.newHashSetWithExpectedSize(data.size());
for (OneData oneData : data) {
final List<OneMeta> meta = oneData.getMeta();
final List<LinkedHashMap<String, String>> row = oneData.getRow();
for (int i = 0; i < meta.size(); i++) {
final Map<String, String> oneRow = row.get(i);
final Map<String, String> properties = Maps.newHashMapWithExpectedSize(oneRow.size());
String tag = "unknown";
for (Map.Entry<String, String> entry : oneRow.entrySet()) {
final String key = entry.getKey();
final String[] split = key.split("\\.");
tag = split[0];
properties.put(split[1], entry.getValue());
}
r.add(FailureTroubleshootingVo.builder()
.id(meta.get(i).getId())
.tag(tag)
.properties(properties)
.build());
}
}
return r;
}
@Data
public static class OneData {
@ApiModelProperty(value = "元数据")
private List<OneMeta> meta;
@ApiModelProperty(value = "属性名称: 属性值")
private List<LinkedHashMap<String, String>> row;
}
@Data
public static class OneMeta {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "类型")
private String type;
}
}

@ -0,0 +1,20 @@
package com.supervision.nebula.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Descriptin:
* @ClassName: PageBeanDto
*/
@ApiModel("分页参数入参")
@Data
public class PageBeanDto {
@ApiModelProperty(value = "页码:从1开始", example = "1", required = false)
private Integer pageNum = 1;
@ApiModelProperty(value = "分页条数", example = "10", required = false)
private Integer pageSize = 10;
}

@ -0,0 +1,19 @@
package com.supervision.nebula.dto;
import lombok.Data;
@Data
public class Property {
/**
*
*/
private String propName;
/**
* CSV
*/
private Integer csvIndex;
/**
*
*/
private String type;
}

@ -0,0 +1,115 @@
package com.supervision.nebula.dto;
import lombok.Data;
import java.util.List;
/**
* @ClassName= TemplateBean
*/
@Data
public class TemplateBean {
private String version = "v3";
private String description = "web console import";
private Boolean removeTempFiles = false;
private ClientSettings clientSettings;
private String logPath;
private List<File> files;
@Data
public static class File {
private String path;
private String failDataPath;
private Integer batchSize = 60;
private String limit;
private String inOrder;
private String type = "csv";
private CSV csv;
private Schema schema;
}
@Data
public static class CSV {
private Boolean withHeader = true;
private Boolean withLabel = false;
private String delimiter;
}
@Data
public static class Schema {
private String type = "vertex";
// private Vertex vertex;
private Edge edge;
}
@Data
public static class Edge {
private String name = "order";
private Boolean withRanking = false;
// private List<Prop> props;
// private SrcDst srcVID;
// private SrcDst dstVID;
// private Integer rank;
}
// @Data
// public static class SrcDst {
// private Integer index = 1;
// private String function = "";
// private String type = "string";
// private String prefix = "";
// }
// @Data
// public static class Vertex {
// private Vid vid;
// private List<Tag> tags;
// }
// @Data
// public static class Vid {
// private Integer index = 0;
// private String function;
// private String type = "string";
// private String prefix;
// }
// @Data
// public static class Tag {
// private String name = "item";
// private List<Prop> props;
// }
// @Data
// public static class Prop {
// private String name = "id_single_item";
// private String type = "string";
// private Integer index = 0;
// }
@Data
public static class ClientSettings {
private Integer retry = 3;
private Integer concurrency = 10;
private Integer channelBufferSize = 128;
private String space = "dataImport";
private String postStart;
private String preStop;
private Connection connection;
}
@Data
public static class Connection {
private String user = "root";
private String password = "nebula";
private String address = "127.0.0.1:9669";
}
}

@ -0,0 +1,24 @@
package com.supervision.nebula.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @ClassName: UserDto
*/
@Data
@ApiModel("用户入参")
@NoArgsConstructor
@AllArgsConstructor
public class UserDto {
@ApiModelProperty(value = "用户名", required = true, example = "test")
private String username;
@ApiModelProperty(value = "密码", required = true, example = "test")
private String password;
}

@ -0,0 +1,21 @@
package com.supervision.nebula.dto;
import lombok.Data;
import java.util.List;
@Data
public class VertexCombo {
/**
* id
*/
private Integer fileId;
/**
*
*/
private Integer vertexId;
/**
*
*/
private List<VertexElement> vertexElements;
}

@ -0,0 +1,17 @@
package com.supervision.nebula.dto;
import lombok.Data;
import java.util.List;
@Data
public class VertexElement {
/**
*
*/
private String elementName;
/**
*
*/
private List<Property> properties;
}

@ -0,0 +1,44 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Descriptin:
* @ClassName: AttributeBean
*/
@ApiModel("属性入参")
@Data
public class AttributeBean {
/**
*
**/
@ApiModelProperty(value = "tag/edge的属性名称", example = "p3", required = true)
private String propertyName;
/**
* (int bool string double .........)
**/
@ApiModelProperty(value = "索引长度:属性为string 必须有长度,其他类型不可传入 ", example = "30", required = true)
private String indexLength;
public String getPropertyName() {
return "`" + propertyName + "`" + getIndexLength();
}
private String getIndexLength() {
if (StrUtil.isNotBlank(indexLength)) {
return "(" + indexLength + ")";
}
return "";
}
private String getIndexFull() {
if (StrUtil.isNotBlank(indexLength)) {
return "(" + indexLength + ")";
}
return "";
}
}

@ -0,0 +1,60 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("修改属性实体")
public class GraphAddAttribute {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "attribute可选值: tag标签/edge边类型", example = "tag", required = true)
private String attribute;
@ApiModelProperty(value = "属性名称", example = "t1", required = true)
private String attributeName;
@ApiModelProperty(value = "tag/edge的属性名称", example = "p5")
private String propertyName;
@ApiModelProperty(value = "属性类型,add 必传该类型 可选值: int bool string double .........", example = "string", required = false)
private String propertyType;
@ApiModelProperty(value = "是否可为空: NOT NULL 或者 NULL", example = "NULL")
private String isNull;
@ApiModelProperty(value = "默认值")
private Object defaultValue;
@ApiModelProperty(value = "描述")
private String common;
public Object getDefaultValue() {
if (!ObjectUtil.isNull(defaultValue)) {
if (defaultValue instanceof String) {
return "DEFAULT '" + defaultValue + "'";
}
return "DEFAULT " + defaultValue;
}
return defaultValue;
}
public String getCommon() {
if (StrUtil.isNotBlank(common)) {
return "COMMENT '" + common + "'";
}
return common;
}
}

@ -0,0 +1,39 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("创建索引入参")
public class GraphCreateIndex {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "创建类型: tag/edge", example = "tag", required = true)
private String type;
@ApiModelProperty(value = "索引名称", example = "name_index", required = true)
private String indexName;
@ApiModelProperty(value = "tag/edge名称", example = "t1", required = true)
private String tagEdgeName;
@ApiModelProperty(value = "索引描述描述", example = "备注")
private String comment;
@ApiModelProperty(value = "属性集合")
private List<AttributeBean> attributeBeanList;
}

@ -0,0 +1,62 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("创建空间实体")
public class GraphCreateSpace {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
/**
*
**/
@ApiModelProperty(value = "空间中文名称", example = "付琳测试", required = true)
private String spaceChineseName;
/**
*
**/
@ApiModelProperty(value = "分片数量", example = "1")
private Integer partitionNum;
/**
*
**/
@ApiModelProperty(value = "副本数量", example = "1")
private Integer replicaFactor;
/**
*
**/
@ApiModelProperty(value = "点类型:INT64,FIXED_STRING", example = "INT64")
private String fixedType = "INT64";
/**
*
**/
@ApiModelProperty(value = "类型长度,FIXED_STRING 此字段必填 如32,64")
private String size = "";
/**
*
**/
@ApiModelProperty(value = "描述")
private String comment;
public String getSize() {
if (StrUtil.isNotBlank(size)) {
return "(" + size + ")";
}
return "";
}
}

@ -0,0 +1,39 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("创建tag edge入参")
public class GraphCreateTagEdge {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi")
private String space;
@ApiModelProperty(value = "创建类型: tag/edge", example = "tag")
private String type;
@ApiModelProperty(value = "tag/edge名称", example = "demo")
private String tagEdgeName;
@ApiModelProperty(value = "tag/edge描述", example = "备注")
private String tagEdgeComment;
@ApiModelProperty(value = "属性集合")
private List<PropertyBean> propertyList;
@ApiModelProperty(value = "颜色")
private String color;
}

@ -0,0 +1,38 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("创建点入参")
public class GraphCreateVertex {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "标签tag名称", example = "t1", required = true)
private String tagName;
@ApiModelProperty(value = "标签tag属性集合", required = false)
private List<String> tagList;
/**
* pointkey
**/
@ApiModelProperty(value = "点的VID", required = true)
private Object pointKey;
@ApiModelProperty(value = "标签tag的属性值集合", required = false)
private List<Object> tagValueList;
}

@ -0,0 +1,23 @@
package com.supervision.nebula.dto.graph;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
/**
*
*
* @author fulin by 2022/3/30
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GraphData {
private Collection<GraphNode> nodes;
private Collection<GraphEdge> edges;
private Collection<NodeType> NodeTypes;
}

@ -0,0 +1,31 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("删除属性实体")
public class GraphDelAttribute {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "attribute可选值: tag标签/edge边类型", example = "tag", required = true)
private String attribute;
@ApiModelProperty(value = "属性名称", example = "t1", required = true)
private String attributeName;
@ApiModelProperty(value = "tag/edge的属性名称 支持批量")
private List<String> propertyNameList;
}

@ -0,0 +1,32 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("删除边入参")
public class GraphDeleteEdge {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "边类型edge名称", example = "e1", required = true)
private String edgeName;
@ApiModelProperty(value = "点的起始VID", example = "11", required = true)
private Object srcVid;
@ApiModelProperty(value = "点的目的VID", example = "12", required = true)
private Object dstVid;
}

@ -0,0 +1,26 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("删除点入参")
public class GraphDeleteVertex {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "vertex 点id", required = true)
private Object vid;
}

@ -0,0 +1,26 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("删除属性实体")
public class GraphDropAttribute {
@ApiModelProperty(value = "空间名称", example = "flceshi1", required = true)
private String space;
@ApiModelProperty(value = "属性名称", example = "flceshi1", required = true)
private String attributeName;
@ApiModelProperty(value = "attribute可选值:space空间/tag标签/edge边类型", example = "space", required = true)
private String attribute;
}

@ -0,0 +1,26 @@
package com.supervision.nebula.dto.graph;
import lombok.*;
/**
* -
*
* @author fulin by 2022/3/30
*/
@Data
@Builder
@EqualsAndHashCode(of = {"source", "target"})
@AllArgsConstructor
@NoArgsConstructor
public class GraphEdge {
private String label;
private String source;
private String target;
private Object edgeInfo;
public GraphEdge(String edge, String tagStart, String tagEnd) {
this.label = edge;
this.source = tagStart;
this.target = tagEnd;
}
}

@ -0,0 +1,81 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("扩展查询入参实体")
public class GraphExpand {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "边类型集合", required = true)
private List<String> edgeList;
@ApiModelProperty(value = "方向: OUTFLOW(流出);INFLOW(流入);TWO-WAY(双向);", example = "TWO-WAY", required = true)
private String direction;
@ApiModelProperty(value = "步数开始(单步/范围的开始)", example = "1", required = true)
private Integer stepStart;
@ApiModelProperty(value = "步数结束(范围的结束;可无)", example = "2")
@Min(1)
private Integer stepEnd;
@ApiModelProperty(value = "结果条数", example = "100", required = true)
@Max(Integer.MAX_VALUE)
@Min(1)
private Integer resultSize = Integer.MAX_VALUE;
@ApiModelProperty(value = "扩展点id集合", required = true)
private List<Object> vidList;
@ApiModelProperty(value = "条件(可为空)", example = " l.name CONTAINS '1' ", required = false)
private String condition;
public String getStepEndResult() {
if (stepEnd != null) {
return ".." + stepEnd;
}
return "";
}
public String getVidList(String vidType) {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < vidList.size(); i++) {
Object vid = vidList.get(i);
if (vidType.contains("STRING")) {
stringBuffer.append("\"").append(vid).append("\"");
} else {
stringBuffer.append(vid);
}
if (vidList.size() > 1 && (i + 1) != vidList.size()) {
stringBuffer.append(",");
}
}
return stringBuffer.toString();
}
// l.degree CONTAINS 1 AND l.min_level == 2
public String getCondition() {
if (StrUtil.isNotBlank(condition)) {
return " AND ALL(l IN e WHERE " + condition + ")";
}
return "";
}
}

@ -0,0 +1,39 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("插入边入参")
public class GraphInsertEdge {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "边类型edge名称", example = "e1", required = true)
private String edgeName;
@ApiModelProperty(value = "边类型edge属性集合", required = false)
private List<String> edgeList;
@ApiModelProperty(value = "点的起始VID", example = "11", required = true)
private String srcVid;
@ApiModelProperty(value = "点的目的VID", example = "12", required = true)
private String dstVid;
@ApiModelProperty(value = "边edge的属性值集合", required = false)
private List<Object> edgeValueList;
}

@ -0,0 +1,29 @@
package com.supervision.nebula.dto.graph;
import lombok.*;
/**
* -
*
* @author fulin by 2022/3/30
*/
@Data
@Builder
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@AllArgsConstructor
public class GraphNode {
private String id;
private String tag;
private String label;
private String nodeTypes;
private Object tagInfo;
public GraphNode(String tag, String tagInfo) {
this.id = tag;
this.tag = tag;
this.label = tag;
this.nodeTypes = tag;
this.tagInfo = tagInfo;
}
}

@ -0,0 +1,24 @@
package com.supervision.nebula.dto.graph;
import com.supervision.nebula.dto.PageBeanDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("查询属性分页查询入参")
public class GraphPageAttribute extends PageBeanDto {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "attribute可选值:tags标签/edges边类型", example = "tags", required = true)
private String attribute;
}

@ -0,0 +1,39 @@
package com.supervision.nebula.dto.graph;
import com.supervision.nebula.dto.PageBeanDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("查询边分页入参")
public class GraphPageEdge extends PageBeanDto {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "边类型edge", required = false)
private String edge;
@ApiModelProperty(value = "起点或者终点ID", required = false)
private String vid;
}

@ -0,0 +1,25 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*
* @ClassName: GraphRelationInsert
*/
@Data
public class GraphRelationInsert {
@ApiModelProperty(value = "空间名称", example = "movies", required = true)
private String space;
@ApiModelProperty(value = "开始标签", required = true)
private String tagStart;
@ApiModelProperty(value = "边类型", required = true)
private String edge;
@ApiModelProperty(value = "结束标签", required = true)
private String tagEnd;
}

@ -0,0 +1,28 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("查询相关属性入参")
public class GraphShowAttribute {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = false)
private String space;
/**
* attributes: spaces/tags/edges
**/
@ApiModelProperty(value = "attribute可选值:spaces空间/tags标签/edges边类型", example = "spaces", required = true)
private String attribute;
}

@ -0,0 +1,27 @@
package com.supervision.nebula.dto.graph;
import com.supervision.nebula.dto.PageBeanDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("查询索引入参")
public class GraphShowIndex extends PageBeanDto {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
/**
* attribute: tag/edge
**/
@ApiModelProperty(value = "属性可选: tag/edge/fulltext", example = "tag", required = true)
private String attribute;
}

@ -0,0 +1,35 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("属性详情查询入参")
public class GraphShowInfo {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi")
private String space;
/**
* attribute: tag /edge
**/
@ApiModelProperty(value = "属性类型:tag/edge", example = "tag")
private String attribute;
/**
* attributeName: tag /edge
**/
@ApiModelProperty(value = "属性名称")
private String attributeName;
}

@ -0,0 +1,21 @@
package com.supervision.nebula.dto.graph;
import com.supervision.nebula.dto.PageBeanDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("通用入参实体")
public class GraphSpace extends PageBeanDto {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
}

@ -0,0 +1,48 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("修改边入参")
public class GraphUpdateEdge {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "边类型edge名称", example = "e1", required = true)
private String edgeName;
@ApiModelProperty(value = "边类型edge属性集合", required = false)
private List<String> edgeList;
@ApiModelProperty(value = "点的起始VID", required = true)
private Object srcVid;
@ApiModelProperty(value = "点的目的VID", required = true)
private Object dstVid;
@ApiModelProperty(value = "边edge的属性值集合", required = false)
private List<Object> edgeValueList;
}

@ -0,0 +1,26 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("修改空间备注入参实体")
public class GraphUpdateSpace {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "空间中文名称", example = "空间中文名称", required = true)
private String spaceChineseName;
@ApiModelProperty(value = "空间备注", example = "备注信息", required = true)
private String spaceComment;
}

@ -0,0 +1,31 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("修改tag颜色入参")
public class GraphUpdateTagColor {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi")
private String space;
@ApiModelProperty(value = "类型: tag/edge", example = "tag")
private String type;
@ApiModelProperty(value = "tag/edge名称", example = "demo")
private String tagEdgeName;
@ApiModelProperty(value = "颜色")
private String color;
}

@ -0,0 +1,38 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("修改点入参")
public class GraphUpdateVertex {
/**
*
**/
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "标签tag名称", example = "t1", required = true)
private String tagName;
@ApiModelProperty(value = "标签tag属性集合", required = true)
private List<String> tagList;
/**
* pointkey
**/
@ApiModelProperty(value = "点的VID", example = "11", required = true)
private Object pointKey;
@ApiModelProperty(value = "标签tag的属性值集合", required = true)
private List<Object> tagValueList;
}

@ -0,0 +1,24 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("归因分析查询入参")
public class GraphVertexAnalysisResult {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "查询关键字集合", required = true)
private List<String> wordList;
}

@ -0,0 +1,22 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("解析文字入参")
public class GraphVertexAnalysisWord {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "查询关键字", required = true)
private String word;
}

@ -0,0 +1,30 @@
package com.supervision.nebula.dto.graph;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("全文检索")
public class GraphVertexFullQuery {
@ApiModelProperty(value = "空间名称", example = "movies", required = true)
private String space;
@ApiModelProperty(value = "查询关键字", required = true)
private String word;
@ApiModelProperty(value = "标签集合", required = false)
private List<String> tagList;
@ApiModelProperty(value = "查询最大条数", required = true)
private Integer resultSize;
}

@ -0,0 +1,65 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("路径检索")
public class GraphVertexPathQuery {
@ApiModelProperty(value = "空间名称", example = "movies", required = true)
private String space;
@ApiModelProperty(value = "路径查找类型: SHORTEST最短 | ALL所有 | NOLOOP非循环", example = "ALL", required = true)
private String pathType;
@ApiModelProperty(value = "变类型集合", required = true)
private List<String> edgeList;
@ApiModelProperty(value = "点的起始VID", required = true)
private List<Object> srcVid;
@ApiModelProperty(value = "点的目的VID", required = true)
private List<Object> dstVid;
@ApiModelProperty(value = "查询方向: REVERSELY反向 | BIDIRECT双向 | 空 正向", example = "BIDIRECT", required = true)
private String direct;
@ApiModelProperty(value = "最大步数", example = "3", required = true)
private Integer step;
@ApiModelProperty(value = "查询最大条数", required = true)
private Integer resultSize;
@ApiModelProperty(value = "筛选条件", required = true)
private String condition;
public String getEdgeList() {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < edgeList.size(); i++) {
String edge = edgeList.get(i);
stringBuffer.append("`").append(edge).append("`");
if (edgeList.size() > 1 && (i + 1) != edgeList.size()) {
stringBuffer.append(",");
}
}
return stringBuffer.toString();
}
public String getCondition() {
if (StrUtil.isNotBlank(condition)) {
return "WHERE " + condition;
}
return "";
}
}

@ -0,0 +1,42 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("根据tag标签查询点入参实体")
public class GraphVertexTatAttributeQuery {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
@ApiModelProperty(value = "标签", example = "t1", required = true)
private String tag;
@ApiModelProperty(value = "执行条件", required = true)
private String condition;
@ApiModelProperty(value = "结果条数", example = "100", required = true)
@Max(Integer.MAX_VALUE)
@Min(1)
private Integer resultSize = Integer.MAX_VALUE;
public String getCondition() {
if (StrUtil.isNotBlank(condition)) {
return " where " + condition;
}
return "";
}
}

@ -0,0 +1,29 @@
package com.supervision.nebula.dto.graph;
import com.supervision.nebula.dto.PageBeanDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("根据tag标签查询点入参实体")
public class GraphVertexTatsQuery extends PageBeanDto {
@ApiModelProperty(value = "空间名称", example = "flceshi", required = true)
private String space;
//@ApiModelProperty(value = "标签集合", required = false)
//private List<String> tagList;
@ApiModelProperty(value = "标签", required = false)
private String tag;
@ApiModelProperty(value = "点id", required = false)
private Object pointKey;
}

@ -0,0 +1,38 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.map.MapUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* -
*
* @author fulin
* @since 2022/5/9 15:44
*/
@Data
@Builder
@AllArgsConstructor
public class NodeType implements Serializable {
private String id;
private String label;
private Map<String, String> style;
public NodeType() {
super();
}
public NodeType(String tagStart, String color) {
this.id = tagStart;
this.label = tagStart;
HashMap<String, String> style = MapUtil.newHashMap();
style.put("size", "50");
style.put("fill", color);
this.style = style;
}
}

@ -0,0 +1,53 @@
package com.supervision.nebula.dto.graph;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Descriptin:
* @ClassName: PropertyBean
*/
@ApiModel("属性实体")
@Data
public class PropertyBean {
/**
*
**/
@ApiModelProperty(value = "tag/edge属性名称", example = "name", required = true)
private String propertyName;
/**
* (int bool string double .........)
**/
@ApiModelProperty(value = "tag/edge属性类型可选:int bool string double", example = "string", required = true)
private String propertyType;
/**
*
**/
@ApiModelProperty(value = "属性描述", example = "名称")
private String propertyComment;
/**
* (NOT NULL NULL)
**/
@ApiModelProperty(value = "是否可为空: NOT NULL 或者 NULL", example = "NULL")
private String isNull;
/**
*
**/
@ApiModelProperty(value = "默认值", example = "NULL")
private Object defaultValue;
public Object getDefaultValue() {
if (!ObjectUtil.isNull(defaultValue)) {
if (defaultValue instanceof String) {
return "DEFAULT '" + defaultValue + "'";
}
return "DEFAULT " + defaultValue;
}
return defaultValue;
}
}

@ -0,0 +1,48 @@
package com.supervision.nebula.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* (GraphFile)
*
* @author makejava
* @since 2022-08-23 09:09:27
*/
@Data
public class GraphFile implements Serializable {
private static final long serialVersionUID = -70939095818612018L;
/**
* id
*/
private Integer id;
/**
* id
*/
private Integer userId;
/**
*
*/
private String fileName;
/**
*
*/
private String filePath;
/**
*
*/
private Date createdTime;
/**
*
*/
private String fileSize;
/**
* 2
*/
private String extend;
}

@ -0,0 +1,26 @@
package com.supervision.nebula.exception;
/**
* @author fulin by 2022/3/25
*/
public class GraphExecuteException extends RuntimeException {
public GraphExecuteException() {
}
public GraphExecuteException(String message) {
super(message);
}
public GraphExecuteException(String message, Throwable cause) {
super(message, cause);
}
public GraphExecuteException(Throwable cause) {
super(cause);
}
public GraphExecuteException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

@ -0,0 +1,177 @@
package com.supervision.nebula.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.supervision.nebula.constant.AttributeEnum;
import com.supervision.nebula.dto.graph.*;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.AttributeVo;
import com.supervision.nebula.vo.CommonVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
/**
* @Descriptin:
* @ClassName: AttributeService
*/
@Service
@RequiredArgsConstructor
public class AttributeService {
private final GraphCommonService graphCommonService;
/**
* @return java.util.List<com.hoteamsoft.common.vo.AttributeVo>
* @Description tag, tag
* @Param [graphShowAttribute]
**/
public List<AttributeVo> showAttribute(GraphShowAttribute graphShowAttribute) {
List<AttributeVo> list = graphCommonService.executeJson(NebulaUtil.showAttributes(graphShowAttribute), AttributeVo.class);
if (CollUtil.isNotEmpty(list)) {
if (AttributeEnum.TAGS.name().equalsIgnoreCase(graphShowAttribute.getAttribute())) {
list.forEach(attributeVo -> {
attributeVo.getData().forEach(dataBean -> {
String tag = dataBean.getRow().get(0);
GraphShowInfo graphShowInfo = GraphShowInfo.builder().space(graphShowAttribute.getSpace())
.attribute("tag").attributeName(tag).build();
List<AttributeVo> attributeVoList = graphCommonService.executeJson(NebulaUtil.showAttributeInfo(graphShowInfo), AttributeVo.class);
AttributeVo attributeVoSon = attributeVoList.get(0);
dataBean.getRow().add(JSONUtil.toJsonStr(attributeVoSon));
});
attributeVo.getColumns().add("sonTagAttributeVo");
});
//}
}
if (AttributeEnum.EDGES.name().equalsIgnoreCase(graphShowAttribute.getAttribute())) {
list.forEach(attributeVo -> {
attributeVo.getData().forEach(dataBean -> {
GraphShowInfo graphShowInfo = GraphShowInfo.builder().space(graphShowAttribute.getSpace())
.attribute("edge").attributeName(dataBean.getRow().get(0)).build();
List<AttributeVo> attributeVoList = graphCommonService.executeJson(NebulaUtil.showAttributeInfo(graphShowInfo), AttributeVo.class);
AttributeVo attributeVoSon = attributeVoList.get(0);
dataBean.getRow().add(JSONUtil.toJsonStr(attributeVoSon));
});
attributeVo.getColumns().add("sonEdgeAttributeVo");
});
}
}
return list;
}
/**
* @return java.util.List<com.hoteamsoft.common.vo.CommonVo>
* @Description
* @Param [graphDropAttribute]
**/
public List<CommonVo> dropAttribute(GraphDropAttribute graphDropAttribute) {
if (!"space".equalsIgnoreCase(graphDropAttribute.getAttribute())) {
graphCommonService.executeJson(NebulaUtil.dropIndex(graphDropAttribute), CommonVo.class);
}
return graphCommonService.executeJson(NebulaUtil.dropAttribute(graphDropAttribute), CommonVo.class);
}
/**
* @return com.github.pagehelper.PageInfo
* @Description
* @Param [graphPageAttribute]
**/
public PageInfo<AttributeVo.DataBean> pageListAttribute(GraphPageAttribute graphPageAttribute) {
List<AttributeVo> attributeVoList = graphCommonService.executeJson(NebulaUtil.showAttributes(new GraphShowAttribute(graphPageAttribute.getSpace(), graphPageAttribute.getAttribute())), AttributeVo.class);
AttributeVo attributeVo = attributeVoList.get(0);
List<AttributeVo.DataBean> data = attributeVo.getData();
if (CollectionUtil.isNotEmpty(data)) {
return startPage(data, graphPageAttribute.getPageNum(), graphPageAttribute.getPageSize());
}
return new PageInfo<>();
}
public <T> PageInfo<T> startPage(List<T> list, Integer pageNum, Integer pageSize) {
//创建Page类
Page<T> page = new Page<>(pageNum, pageSize);
//为Page类中的total属性赋值
page.setTotal(list.size());
//计算当前需要显示的数据下标起始值
int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, list.size());
//从链表中截取需要显示的子链表并加入到Page
page.addAll(list.subList(startIndex, endIndex));
//以Page创建PageInfo
return new PageInfo<>(page);
}
/**
* @return java.util.List<com.hoteamsoft.common.vo.CommonVo>
* @Description
* @Param [graphAddAttribute]
**/
public List<CommonVo> addAttributeProperty(GraphAddAttribute graphAddAttribute) {
return graphCommonService.executeJson(NebulaUtil.addAttributeProperty(graphAddAttribute), CommonVo.class);
}
/**
* @return java.util.List<com.hoteamsoft.common.vo.AttributeVo>
* @Description
* @Param [graphShowInfo]
**/
public List<AttributeVo> showAttributeInfo(GraphShowInfo graphShowInfo) {
return graphCommonService.executeJson(NebulaUtil.showAttributeInfo(graphShowInfo), AttributeVo.class);
}
private void cover(List<AttributeVo> attributeVoList) {
if (CollectionUtil.isEmpty(attributeVoList)) {
return;
}
AttributeVo attributeVo = attributeVoList.get(0);
if (ObjectUtil.isNull(attributeVo)) {
return;
}
List<AttributeVo.DataBean> data = attributeVo.getData();
List<String> columns = attributeVo.getColumns();
HashMap<String, List<String>> stringListHashMap = MapUtil.newHashMap();
List<String> valueList = CollectionUtil.newArrayList();
String key = columns.get(0);
for (AttributeVo.DataBean datum : data) {
String value = datum.getRow().get(0);
valueList.add(value);
}
stringListHashMap.put(key, valueList);
attributeVo.setFieldMap(stringListHashMap);
}
public List<AttributeVo> showCreateAttributeInfo(GraphShowInfo graphShowInfo) {
List<AttributeVo> attributeVoList = graphCommonService.executeJson(NebulaUtil.showCreateAttributeInfo(graphShowInfo), AttributeVo.class);
if (CollUtil.isNotEmpty(attributeVoList)) {
for (AttributeVo attributeVo : attributeVoList) {
for (AttributeVo.DataBean datum : attributeVo.getData()) {
attributeVo.getColumns().add("comment");
String row = datum.getRow().get(1);
String substring = row.substring(row.lastIndexOf(",") + 1);
if (StrUtil.isNotBlank(substring)) {
String replaceAll = substring.replace("=", ":");
String result = "{" + replaceAll + "}";
JSONObject entries = JSONUtil.parseObj(JSONUtil.toJsonStr(result));
if (entries.containsKey("comment")) {
Object comment = entries.get("comment");
datum.getRow().add(comment.toString());
} else {
datum.getRow().add("");
}
}
}
}
}
return attributeVoList;
}
}

@ -0,0 +1,67 @@
package com.supervision.nebula.service;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.supervision.nebula.dto.graph.GraphShowInfo;
import com.supervision.nebula.exception.GraphExecuteException;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.AttributeVo;
import com.vesoft.nebula.client.graph.exception.IOErrorException;
import com.vesoft.nebula.client.graph.net.Session;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class GraphCommonService {
private final Session session;
public <T> List<T> executeJson(String gql, Class<T> voClass) {
try {
log.info("执行 executeJson 方法gql={}", gql);
final String data = session.executeJson(gql);
final JSONObject jsonObject = JSONUtil.parseObj(data);
// 查询语句异常分析, 根据 json 返回结果解析 error 节点信息
final JSONObject error0 = jsonObject.getJSONArray("errors").getJSONObject(0);
final Integer code = error0.getInt("code");
if (code != 0) {
throw new GraphExecuteException("execute gql error, gql: " + gql +
" ,code:" + code + ", message:" + error0.getStr("message"));
}
JSONArray results = JSONUtil.parseArray(jsonObject.get("results"));
log.info("返回结果: {}", results);
return JSONUtil.toList(results, voClass);
} catch (IOErrorException e) {
log.error("executeJson ql[{}] error, msg [{}]", gql, e.getMessage());
throw new GraphExecuteException("execute gql error, gql: " + gql, e);
}
}
public String executeJson(String gql) {
try {
log.info("执行 executeJson 方法gql={}", gql);
return session.executeJson(gql);
} catch (IOErrorException e) {
log.error("executeJson ql[{}] error, msg [{}]", gql, e.getMessage());
throw new GraphExecuteException("execute gql error, gql: " + gql, e);
}
}
public String getVidType(String space) {
List<AttributeVo> spaceList = executeJson(NebulaUtil.showAttributeInfo(GraphShowInfo.builder()
.attribute("space").attributeName(space).space(space).build()), AttributeVo.class);
AttributeVo attributeVo = spaceList.get(0);
AttributeVo.DataBean dataBean = attributeVo.getData().get(0);
return dataBean.getRow().get(6);
}
}

@ -0,0 +1,35 @@
package com.supervision.nebula.service;
import com.supervision.nebula.dto.ImportBean;
import com.supervision.nebula.entity.GraphFile;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* (GraphFile)
*
* @author makejava
* @since 2022-08-23 09:09:27
*/
public interface GraphFileService {
/**
*
*
* @param multipartFile
* @return
*/
GraphFile uploadFile(MultipartFile multipartFile);
boolean importFile(ImportBean importBean) throws IOException;
/**
*
*
* @return void
* @Param [space]
**/
void template(String space, HttpServletResponse response);
}

@ -0,0 +1,73 @@
package com.supervision.nebula.service;
import cn.hutool.core.collection.CollectionUtil;
import com.supervision.nebula.constant.AttributeEnum;
import com.supervision.nebula.dto.graph.GraphCreateSpace;
import com.supervision.nebula.dto.graph.GraphShowAttribute;
import com.supervision.nebula.dto.graph.GraphShowInfo;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.AttributeVo;
import com.supervision.nebula.vo.CommonVo;
import com.supervision.nebula.vo.DetailSpace;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Descriptin:
* @ClassName: SpaceService
*/
@Service
@RequiredArgsConstructor
public class SpaceService {
private final GraphCommonService graphCommonService;
public List<CommonVo> createSpace(GraphCreateSpace graphCreateSpace) {
return graphCommonService.executeJson(NebulaUtil.createSpace(graphCreateSpace), CommonVo.class);
}
public List<DetailSpace> detailSpace(GraphShowAttribute graphShowAttribute) {
// 所有图空间
List<AttributeVo> spacesList = graphCommonService.executeJson(NebulaUtil.showAttributes(graphShowAttribute), AttributeVo.class);
AttributeVo attributeVo1 = spacesList.get(0);
List<DetailSpace> detailSpaceList = CollectionUtil.newArrayList();
DetailSpace detailSpace = null;
for (AttributeVo.DataBean datum : attributeVo1.getData()) {
int tagsNum = 0;
int edgesNum = 0;
detailSpace = new DetailSpace();
// 查询tags/edges
String spaceName = datum.getRow().get(0);
graphShowAttribute.setSpace(spaceName);
graphShowAttribute.setAttribute(AttributeEnum.TAGS.name());
List<AttributeVo> tagsList = graphCommonService.executeJson(NebulaUtil.showAttributes(graphShowAttribute), AttributeVo.class);
AttributeVo attributeVoTag = tagsList.get(0);
for (AttributeVo.DataBean attributeVoTagDatum : attributeVoTag.getData()) {
tagsNum += attributeVoTagDatum.getRow().size();
}
graphShowAttribute.setAttribute(AttributeEnum.EDGES.name());
List<AttributeVo> edgesList = graphCommonService.executeJson(NebulaUtil.showAttributes(graphShowAttribute), AttributeVo.class);
for (AttributeVo.DataBean dataBean : edgesList.get(0).getData()) {
edgesNum += dataBean.getRow().size();
}
detailSpace.setSpace(spaceName);
detailSpace.setTagsNum(tagsNum);
detailSpace.setEdgesNum(edgesNum);
detailSpaceList.add(detailSpace);
}
return detailSpaceList;
}
public List<AttributeVo> spaceInfo(String space) {
return graphCommonService.executeJson(NebulaUtil.showAttributeInfo(GraphShowInfo.builder()
.attribute("space").attributeName(space).space(space).build()), AttributeVo.class);
}
}

@ -0,0 +1,31 @@
package com.supervision.nebula.service;
import cn.hutool.core.date.DateUtil;
import com.supervision.nebula.vo.AttributeVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author fulin
* @since 2023/1/29 16:14
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class TaskService {
private final GraphCommonService graphCommonService;
/**
* ,session
*
* @author fulin 2023/1/29 16:20
*/
@Scheduled(cron = "0 0 23 * * ?")
public void nebulaNotExpired() {
graphCommonService.executeJson("SHOW SPACES;", AttributeVo.class);
log.info("延续session不过期:{}", DateUtil.now());
}
}

@ -0,0 +1,94 @@
package com.supervision.nebula.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.supervision.nebula.dto.NebulaVertexJsonResult;
import com.supervision.nebula.dto.graph.GraphExpand;
import com.supervision.nebula.dto.graph.GraphSpace;
import com.supervision.nebula.dto.graph.GraphVertexTatAttributeQuery;
import com.supervision.nebula.dto.graph.GraphVertexTatsQuery;
import com.supervision.nebula.util.NebulaUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @Descriptin:
* @ClassName: VertexService
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class VertexService {
private final GraphCommonService graphCommonService;
public List<NebulaVertexJsonResult> vertexList(String space) {
return graphCommonService.executeJson(NebulaUtil.queryMatch(space), NebulaVertexJsonResult.class);
}
public List<NebulaVertexJsonResult> vertexExpandQuery(GraphExpand graphExpand) {
String vidType = graphCommonService.getVidType(graphExpand.getSpace());
return graphCommonService.executeJson(NebulaUtil.expandQuery(graphExpand, vidType), NebulaVertexJsonResult.class);
}
/**
* tag
*/
public List<NebulaVertexJsonResult> vertexTagsQuery(GraphVertexTatsQuery graphVertexTatsQuery) {
String vidType = graphCommonService.getVidType(graphVertexTatsQuery.getSpace());
return graphCommonService.executeJson(NebulaUtil.vertexTagsQuery(graphVertexTatsQuery, vidType), NebulaVertexJsonResult.class);
}
/**
* tag
*/
public List<NebulaVertexJsonResult> vertexTagAttributeQuery(GraphVertexTatAttributeQuery graphVertexTatAttributeQuery) {
return graphCommonService.executeJson(NebulaUtil.vertexTagAttributeQuery(graphVertexTatAttributeQuery), NebulaVertexJsonResult.class);
}
/**
*
*/
public Map<String, Object> vertexPage(GraphVertexTatsQuery graphVertexTatsQuery) {
List<NebulaVertexJsonResult> list;
List<NebulaVertexJsonResult> countList;
if (StrUtil.isNotBlank(graphVertexTatsQuery.getTag()) || ObjectUtil.isNotNull(graphVertexTatsQuery.getPointKey())) {
String vidType = graphCommonService.getVidType(graphVertexTatsQuery.getSpace());
list = graphCommonService.executeJson(NebulaUtil.vertexTagsQueryPage(graphVertexTatsQuery, vidType), NebulaVertexJsonResult.class);
countList = graphCommonService.executeJson(NebulaUtil.vertexTagsQuery(graphVertexTatsQuery, vidType), NebulaVertexJsonResult.class);
} else {
GraphSpace graphSpace = new GraphSpace();
BeanUtil.copyProperties(graphVertexTatsQuery, graphSpace);
list = graphCommonService.executeJson(NebulaUtil.vertexPage(graphSpace), NebulaVertexJsonResult.class);
countList = graphCommonService.executeJson(NebulaUtil.queryMatch(graphVertexTatsQuery.getSpace()), NebulaVertexJsonResult.class);
}
int size = countList.get(0).getData().size();
Map<String, Object> result = MapUtil.newHashMap();
result.put("list", list);
result.put("count", size);
return result;
}
/**
*
*/
public List<NebulaVertexJsonResult> randomList(GraphSpace graphSpace) {
String space = graphSpace.getSpace();
List<NebulaVertexJsonResult> list = graphCommonService.executeJson(NebulaUtil.queryMatchLimit(space), NebulaVertexJsonResult.class);
NebulaVertexJsonResult nebulaVertexJsonResult = list.get(0);
List<NebulaVertexJsonResult.OneData> nebulaVertexJsonResultData = nebulaVertexJsonResult.getData();
nebulaVertexJsonResultData = RandomUtil.randomEleList(nebulaVertexJsonResultData, 10);
nebulaVertexJsonResult.setData(nebulaVertexJsonResultData);
return list;
}
}

@ -0,0 +1,320 @@
package com.supervision.nebula.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.csv.*;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.ZipUtil;
import com.supervision.nebula.constant.AttributeEnum;
import com.supervision.nebula.dto.*;
import com.supervision.nebula.dto.graph.GraphShowAttribute;
import com.supervision.nebula.dto.graph.GraphShowInfo;
import com.supervision.nebula.entity.GraphFile;
import com.supervision.nebula.exception.GraphExecuteException;
import com.supervision.nebula.service.AttributeService;
import com.supervision.nebula.service.GraphCommonService;
import com.supervision.nebula.service.GraphFileService;
import com.supervision.nebula.util.NebulaUtil;
import com.supervision.nebula.vo.AttributeVo;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* (GraphFile)
*
* @author makejava
* @since 2022-08-23 09:09:27
*/
@Service("graphFileService")
@Slf4j
public class GraphFileServiceImpl implements GraphFileService {
private static final String demoName = "示例导入.zip";
private static final String VID = ":VID(string)";
private static final String SRC_VID = ":SRC_VID(string)";
private static final String DST_VID = ":DST_VID(string)";
@Autowired
AttributeService attributeService;
@Autowired
GraphCommonService graphCommonService;
@Value("${path.uploadFilePath}")
private String filePath;
@Value("${path.importerPath}")
private String importerPath;
/**
*
* ,
*
* @param multipartFile
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public GraphFile uploadFile(MultipartFile multipartFile) {
if (multipartFile.isEmpty()) {
throw new GraphExecuteException("文件为空");
}
String fileName = multipartFile.getOriginalFilename();
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
if (!"csv".equalsIgnoreCase(suffix)) {
throw new GraphExecuteException("文件格式不支持");
}
Integer userId = Integer.parseInt("1");
String uploadFilePath = filePath + "/" + userId;
//判断路径是否存在,不存在则创建
makeDir(uploadFilePath);
File file = new File(uploadFilePath, fileName);
try {
multipartFile.transferTo(file);
} catch (IOException e) {
throw new GraphExecuteException("文件读写异常");
}
GraphFile graphFile = new GraphFile();
graphFile.setUserId(userId);
graphFile.setFileName(fileName);
graphFile.setFilePath(uploadFilePath + "/" + fileName);
graphFile.setFileSize(file.length() + "B");
graphFile.setCreatedTime(DateUtil.date());
//从文件中读取CSV数据
CsvReader reader = CsvUtil.getReader();
CsvData data = reader.read(file, StandardCharsets.UTF_8);
List<CsvRow> rows = data.getRows();
return graphFile;
}
@SneakyThrows
@Override
public boolean importFile(ImportBean importBean) {
long start = System.currentTimeMillis();
String randomString = RandomUtil.randomString(6);
String fileName = String.format("%s-%s", importBean.getSpace(), randomString);
//客户端配置
TemplateBean templateBean = new TemplateBean();
String logPath = filePath + "/logFile";
makeDir(logPath);
String logFile = String.format("%s/%s.log", logPath, fileName);
templateBean.setLogPath(logFile);
TemplateBean.ClientSettings clientSettings = new TemplateBean.ClientSettings();
clientSettings.setConnection(new TemplateBean.Connection());
clientSettings.setSpace(importBean.getSpace());
templateBean.setClientSettings(clientSettings);
//文件配置
List<TemplateBean.File> fileList = new ArrayList<>();
// 点
getVertex(importBean, fileList);
//边
getEdge(importBean, fileList);
templateBean.setFiles(fileList);
String yamlFilePath = filePath + "/yamlFile";
makeDir(yamlFilePath);
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(dumperOptions);
String yamlFile = String.format("%s/%s.yaml", yamlFilePath, fileName);
yaml.dump(templateBean, new FileWriter(yamlFile));
Process exec = Runtime.getRuntime().exec("./nebula-importer --config " + yamlFile, null, new File(importerPath));
if (exec.waitFor() < 0) {// 等待执行完成
return false;
}
long end = System.currentTimeMillis();
if (!FileUtil.exist(new File(logFile))) {
return false;
}
// 执行日志内容
BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(logFile)), StandardCharsets.UTF_8));
String line;
StringBuilder content = new StringBuilder();
while ((line = br.readLine()) != null) {
content.append(line).append("\n");
}
return true;
}
/**
*
*
* @return void
* @Param [space]
**/
@Override
public void template(String space, HttpServletResponse response) {
Map<String, List<String>> tagMap = MapUtil.newHashMap();
Map<String, List<String>> edgeMap = MapUtil.newHashMap();
// 查询所有tag edges
GraphShowAttribute graphShowAttribute = new GraphShowAttribute(space, AttributeEnum.TAGS.name());
List<AttributeVo> tagList = graphCommonService.executeJson(NebulaUtil.showAttributes(graphShowAttribute), AttributeVo.class);
graphShowAttribute.setAttribute(AttributeEnum.EDGES.name());
List<AttributeVo> edgeList = graphCommonService.executeJson(NebulaUtil.showAttributes(graphShowAttribute), AttributeVo.class);
if (CollectionUtil.isEmpty(tagList.get(0).getData()) && CollectionUtil.isEmpty(edgeList.get(0).getData())) {
throw new GraphExecuteException("请先添加 模式设计 数据");
}
// 查询每个属性的子属性
tagList.get(0).getData().stream().forEach(attributeVo -> {
attributeVo.getRow().forEach(row -> {
GraphShowInfo graphShowInfo = new GraphShowInfo();
graphShowInfo.setSpace(space);
graphShowInfo.setAttributeName(row);
graphShowInfo.setAttribute("tag");
List<AttributeVo> attributeVoList = graphCommonService.executeJson(NebulaUtil.showAttributeInfo(graphShowInfo), AttributeVo.class);
List<String> rows = CollectionUtil.newArrayList();
rows.add(VID);
attributeVoList.forEach(attributeVo1 -> attributeVo1.getData().forEach(dataBean -> {
String type = "int64".equalsIgnoreCase(dataBean.getRow().get(1)) ? "int" : dataBean.getRow().get(1);
rows.add(row + "." + dataBean.getRow().get(0) + ":" + type);
}));
tagMap.put(row, rows);
});
});
edgeList.get(0).getData().stream().forEach(attributeVo -> {
attributeVo.getRow().forEach(row -> {
GraphShowInfo graphShowInfo = new GraphShowInfo();
graphShowInfo.setSpace(space);
graphShowInfo.setAttributeName(row);
graphShowInfo.setAttribute("edge");
List<AttributeVo> attributeVoList = graphCommonService.executeJson(NebulaUtil.showAttributeInfo(graphShowInfo), AttributeVo.class);
List<String> rows = CollectionUtil.newArrayList();
rows.add(SRC_VID);
rows.add(DST_VID);
attributeVoList.forEach(attributeVo1 -> attributeVo1.getData().forEach(dataBean -> {
String type = "int64".equalsIgnoreCase(dataBean.getRow().get(1)) ? "int" : dataBean.getRow().get(1);
rows.add(row + "." + dataBean.getRow().get(0) + ":" + type);
}));
edgeMap.put(row, rows);
});
});
// 生成模板.csv
String randomNumbers = RandomUtil.randomNumbers(6);
String path = filePath + "/zipFile/" + randomNumbers;
tagMap.forEach((key, value) -> {
String fileName = "实体-" + key;
String pathname = path + "/" + fileName + ".csv";
CsvWriter csvWriter = CsvUtil.getWriter(new File(pathname), CharsetUtil.CHARSET_UTF_8);
csvWriter.write(Convert.toStrArray(value));
csvWriter.flush();
csvWriter.close();
});
edgeMap.forEach((key, value) -> {
String fileName = "关系-" + key;
String pathname = path + "/" + fileName + ".csv";
CsvWriter csvWriter = CsvUtil.getWriter(new File(pathname), CharsetUtil.CHARSET_UTF_8);
csvWriter.write(Convert.toStrArray(value));
csvWriter.flush();
csvWriter.close();
});
// 压缩包zip
String zipPath = path + demoName;
ZipUtil.zip(path, zipPath, CharsetUtil.CHARSET_UTF_8, false);
FileUtil.del(path);// 删除csv源文件
//返回压缩包
try {
BufferedInputStream bis;
OutputStream out = response.getOutputStream();
response.setContentType("text/html; charset=UTF-8");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=".concat(String.valueOf(URLEncoder.encode(randomNumbers + demoName, CharsetUtil.UTF_8))));
bis = new BufferedInputStream(Files.newInputStream(Paths.get(zipPath)));
//定义byte长度就是要转成zip文件的byte长度避免浪费资源
byte[] buffer = new byte[bis.available()];
bis.read(buffer);
out.flush();
out.write(buffer);
} catch (IOException e) {
e.printStackTrace();
}
}
private void makeDir(String logPath) {
File dir = new File(logPath);
if (!dir.exists()) {
dir.mkdirs();
}
}
private void getVertex(ImportBean importBean, List<TemplateBean.File> fileList) {
for (VertexCombo vertexCombo : importBean.getVertices()) {
TemplateBean.File file = new TemplateBean.File();
String failDataPath = filePath + "/failDataFile";
makeDir(failDataPath);
String randomString = RandomUtil.randomString(6);
file.setFailDataPath(String.format("%s/%s-%s", failDataPath, randomString, "DEMO"));
file.setPath("DEMO");
file.setCsv(new TemplateBean.CSV());
TemplateBean.Schema schema = new TemplateBean.Schema();
schema.setType("vertex");
file.setSchema(schema);
fileList.add(file);
}
}
private void getEdge(ImportBean importBean, List<TemplateBean.File> fileList) {
for (EdgeCombo edgeCombo : importBean.getEdges()) {
TemplateBean.File file = new TemplateBean.File();
String failDataPath = filePath + "/failDataFile";
makeDir(failDataPath);
String randomString = RandomUtil.randomString(6);
file.setFailDataPath(String.format("%s/%s-%s", failDataPath, randomString, "demo"));
file.setPath("demo");
file.setCsv(new TemplateBean.CSV());
TemplateBean.Schema schema = new TemplateBean.Schema();
schema.setType("edge");
TemplateBean.Edge edge = new TemplateBean.Edge();
EdgeElement edgeElement = edgeCombo.getEdgeElement();
edge.setName(edgeElement.getElementName());
// TemplateBean.SrcDst src = new TemplateBean.SrcDst();
// src.setIndex(edgeElement.getSrcId());
// edge.setSrcVID(src);
// TemplateBean.SrcDst dst = new TemplateBean.SrcDst();
// dst.setIndex(edgeElement.getDstId());
// edge.setDstVID(dst);
// edge.setRank(edgeElement.getRank());
// edge.setProps(getPropList(edgeElement.getProperties()));
schema.setEdge(edge);
file.setSchema(schema);
fileList.add(file);
}
}
}

@ -0,0 +1,896 @@
package com.supervision.nebula.util;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.google.common.base.Joiner;
import com.supervision.nebula.constant.AttributeEnum;
import com.supervision.nebula.constant.EdgeDirectionEnum;
import com.supervision.nebula.dto.graph.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import java.util.List;
@Slf4j
public class NebulaUtil {
/**
* @return java.lang.String
* @Description spaces/tags/edges
* @Param [GraphShowAttribute]
**/
public static String showAttributes(GraphShowAttribute graphShowAttribute) {
String showSpaces = "";
if (AttributeEnum.SPACES.name().equalsIgnoreCase(graphShowAttribute.getAttribute())) {
showSpaces = String.format("SHOW %s;", graphShowAttribute.getAttribute());
} else {
showSpaces = String.format("USE `%s`;SHOW %s;", graphShowAttribute.getSpace(), graphShowAttribute.getAttribute());
}
log.info("查询{}-gql语句:{}", graphShowAttribute.getAttribute(), showSpaces);
return showSpaces;
}
/**
* @return java.lang.String
* @Description tag/edge
* @Param [GraphShowIndex]
**/
public static String showIndexes(GraphShowIndex graphShowIndex) {
String showIndexes = String.format("USE `%s`;SHOW %s INDEXES;", graphShowIndex.getSpace(), graphShowIndex.getAttribute());
log.info("查询{}-gql语句:{}", graphShowIndex.getAttribute(), showIndexes);
return showIndexes;
}
/**
* @return java.lang.String
* @Description
* @Param [graphCreateSpace]
**/
public static String createSpace(GraphCreateSpace graphCreateSpace) {
String createSpace = String.format("CREATE SPACE `%s` (partition_num = %s, replica_factor = %s,vid_type = %s %s) COMMENT = '%s'",
graphCreateSpace.getSpace(), graphCreateSpace.getPartitionNum(), graphCreateSpace.getReplicaFactor(), graphCreateSpace.getFixedType(),
graphCreateSpace.getSize(), graphCreateSpace.getComment());
log.info("创建空间-gql语句:{}", createSpace);
return createSpace;
}
/**
* @return java.lang.String
* @Description
* @Param [spaceName]
**/
public static String useSpace(String spaceName) {
String useSpace = String.format("USE `%s`;", spaceName);
log.info("切换空间-gql语句:{}", useSpace);
return useSpace;
}
/**
* @return java.lang.String
* @Description
* @Param [spaceName]
**/
public static String spaceInfo(String spaceName) {
String spaceInfo = String.format("DESCRIBE SPACE `%s`;", spaceName);
log.info("空间信息-gql语句:{}", spaceInfo);
return spaceInfo;
}
/**
* @return java.lang.String
* @Description tag
* @Param [graphCreateTag]
**/
public static String createTagEdge(GraphCreateTagEdge graphCreateTagEdge) {
StringBuffer stringBuffer = new StringBuffer();
List<PropertyBean> propertyList = graphCreateTagEdge.getPropertyList();
if (CollectionUtil.isNotEmpty(propertyList)) {
for (int i = 0; i < propertyList.size(); i++) {
PropertyBean propertyBean = propertyList.get(i);
stringBuffer.append(" `" + propertyBean.getPropertyName() + "` " + propertyBean.getPropertyType() + " " +
"" + propertyBean.getIsNull() + " " + propertyBean.getDefaultValue() + " COMMENT '" + propertyBean.getPropertyComment() + "' ");
if (propertyList.size() > 1 && (i + 1) != propertyList.size()) {
stringBuffer.append(",");
}
}
}
String bufferString = stringBuffer.toString();
log.info("stringBuffer :{}", bufferString);
String createTag = "USE `" + graphCreateTagEdge.getSpace() + "`;CREATE " + graphCreateTagEdge.getType() + " `" + graphCreateTagEdge.getTagEdgeName() + "` " +
"( " + bufferString + " ) COMMENT = '" + graphCreateTagEdge.getTagEdgeComment() + "' ";
log.info("创建Tag-gql语句:{}", createTag);
return createTag;
}
/**
* @return java.lang.String
* @Description
* @Param [graphCreateVertex]
**/
public static String createPoint(GraphCreateVertex graphCreateVertex, String vidType) {
List<Object> tagValueList = graphCreateVertex.getTagValueList();
StringBuffer stringBuffer = getStringBuffer(tagValueList);
String bufferString = stringBuffer.toString();
log.info("stringBuffer :{}", bufferString);
StringBuffer stringBufferTagList = new StringBuffer();
List<String> tagList = graphCreateVertex.getTagList();
if (CollectionUtil.isNotEmpty(tagList)) {
for (int i = 0; i < tagList.size(); i++) {
String tagPropertyName = tagList.get(i);
stringBufferTagList.append(" `" + tagPropertyName + "` ");
if (tagList.size() > 1 && (i + 1) != tagList.size()) {
stringBufferTagList.append(",");
}
}
}
Object pointKey = graphCreateVertex.getPointKey();
if (vidType.contains("STRING")) {
pointKey = "'" + StringEscapeUtils.unescapeHtml(pointKey.toString()) + "'";
}
String createPoint = String.format("USE `%s`;INSERT VERTEX IF NOT EXISTS `%s`(%s) VALUES %s: (" + bufferString + ");"
, graphCreateVertex.getSpace(), graphCreateVertex.getTagName(), stringBufferTagList,
pointKey);
log.info("创建vertex-gql语句:{}", createPoint);
return createPoint;
}
/**
* @return java.lang.String
* @Description
* @Param [graphCreatePoint]
**/
public static String dropAttribute(GraphDropAttribute graphDropAttribute) {
String dropAttribute = String.format("USE `%s`;DROP %s IF EXISTS `%s`;", graphDropAttribute.getSpace(), graphDropAttribute.getAttribute(), graphDropAttribute.getAttributeName());
log.info("删除属性-gql语句:{}", dropAttribute);
return dropAttribute;
}
/**
* @return java.lang.String
* @Description
* @Param [graphDropAttribute]
**/
public static String dropIndex(GraphDropAttribute graphDropAttribute) {
String dropIndex = String.format("USE `%s`;DROP %s INDEX IF EXISTS `%s`;", graphDropAttribute.getSpace(), graphDropAttribute.getAttribute(), graphDropAttribute.getAttributeName());
log.info("删除索引-gql语句:{}", dropIndex);
return dropIndex;
}
/**
* @return java.lang.String
* @Description
* @Param [graphAddAttribute]
**/
public static String addAttributeProperty(GraphAddAttribute graphAddAttribute) {
String addAttributeProperty = String.format("USE `%s`;ALTER %s `%s` ADD (`%s` %s %s %s %s);"
, graphAddAttribute.getSpace(), graphAddAttribute.getAttribute(), graphAddAttribute.getAttributeName(),
graphAddAttribute.getPropertyName(), graphAddAttribute.getPropertyType(),
graphAddAttribute.getIsNull(), graphAddAttribute.getDefaultValue(), graphAddAttribute.getCommon());
log.info("增加某个属性的 子属性 -gql语句:{}", addAttributeProperty);
return addAttributeProperty;
}
/**
* @return java.lang.String
* @Description
* @Param [graphDelAttribute]
**/
public static String delAttributeProperty(GraphDelAttribute graphDelAttribute) {
StringBuffer stringBuffer = new StringBuffer();
List<String> propertyNameList = graphDelAttribute.getPropertyNameList();
for (int i = 0; i < propertyNameList.size(); i++) {
String value = propertyNameList.get(i);
stringBuffer.append("`" + value + "`");
if (propertyNameList.size() > 1 && (i + 1) != propertyNameList.size()) {
stringBuffer.append(",");
}
}
String delAttributeProperty = String.format("USE `%s`; ALTER %s `%s` DROP (%s);"
, graphDelAttribute.getSpace(), graphDelAttribute.getAttribute(),
graphDelAttribute.getAttributeName(), stringBuffer);
log.info("删除某个属性的 子属性 -gql语句:{}", delAttributeProperty);
return delAttributeProperty;
}
/**
* @return java.lang.String
* @Description
* @Param [graphShowInfo]
**/
public static String showAttributeInfo(GraphShowInfo graphShowInfo) {
String delAttributeProperty = String.format("USE `%s`; DESCRIBE %s `%s`;"
//String delAttributeProperty = String.format("USE `%s`; SHOW CREATE %s `%s`;"
, graphShowInfo.getSpace(), graphShowInfo.getAttribute(), graphShowInfo.getAttributeName());
log.info("查询属性的 子属性列表 -gql语句:{}", delAttributeProperty);
return delAttributeProperty;
}
/**
* @return java.lang.String
* @Description tagvertex
* @Param [tagList, space] ,
**/
public static String queryMatch(List<String> tagList, String space) {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < tagList.size(); i++) {
String tag = tagList.get(i);
stringBuffer.append("MATCH (v:`" + tag + "`) RETURN v limit " + Integer.MAX_VALUE + "");
if (tagList.size() > 1 && (i + 1) != tagList.size()) {
stringBuffer.append(" UNION ");
}
}
String bufferString = stringBuffer.toString();
log.info("bufferString: {}", bufferString);
String queryMatch = String.format("USE `%s`; " + bufferString + "", space);
log.info("match查询 -gql语句:{}", queryMatch);
return queryMatch;
}
public static String queryMatch(String space) {
String queryMatch = String.format("USE `%s`; match (v) return v limit " + Integer.MAX_VALUE + ";", space);
log.info("match查询 -gql语句:{}", queryMatch);
return queryMatch;
}
public static String queryMatchLimit(String space) {
String queryMatch = String.format("USE `%s`; match (v) return v limit 100 ;", space);
log.info("match查询 -gql语句:{}", queryMatch);
return queryMatch;
}
/**
* @return java.lang.String
* @Description
* @Param [graphDeleteVertex]
**/
public static String deleteVertex(GraphDeleteVertex graphDeleteVertex, String vidType) {
Object vid = graphDeleteVertex.getVid();
if (vidType.contains("STRING")) {
vid = "'" + vid.toString() + "'";
}
String deleteVertex = String.format("USE `%s`; DELETE VERTEX %s;", graphDeleteVertex.getSpace(), vid);
log.info("vertex点删除 -gql语句:{}", deleteVertex);
return deleteVertex;
}
/**
* @return java.lang.String
* @Description vertex
* @Param [graphDeleteVertex]
**/
public static String deleteVertexEdge(GraphDeleteVertex graphDeleteVertex, String vidType) {
Object vid = graphDeleteVertex.getVid();
if (vidType.contains("STRING")) {
vid = "'" + vid.toString() + "'";
}
String deleteVertexEdge = String.format("USE `%s`; DELETE VERTEX %s WITH EDGE;", graphDeleteVertex.getSpace(), vid);
log.info("vertex点删除后删除出入边 -gql语句:{}", deleteVertexEdge);
return deleteVertexEdge;
}
/**
* @return java.lang.String
* @Description ()
* @Param [graphInsertEdge]
**/
public static String insertEdge(GraphInsertEdge graphInsertEdge, String vidType) {
List<Object> edgeValueList = graphInsertEdge.getEdgeValueList();
StringBuffer stringBuffer = getStringBuffer(edgeValueList);
String bufferString = stringBuffer.toString();
log.info("stringBuffer :{}", bufferString);
Object srcVid = graphInsertEdge.getSrcVid();
Object dstVid = graphInsertEdge.getDstVid();
if (vidType.contains("STRING")) {
srcVid = "'" + srcVid.toString() + "'";
dstVid = "'" + dstVid.toString() + "'";
}
StringBuffer stringBufferEdge = new StringBuffer();
for (String edge : graphInsertEdge.getEdgeList()) {
stringBufferEdge.append("`").append(edge).append("`").append(",");
}
String str = stringBufferEdge.toString();
String insertEdge = String.format("USE `%s`; INSERT EDGE IF NOT EXISTS `%s` (%s) VALUES %s->%s:( %s );"
, graphInsertEdge.getSpace(), graphInsertEdge.getEdgeName(), StrUtil.isNotBlank(str) ? str.substring(0, str.length() - 1) : "",
srcVid, dstVid, bufferString);
log.info("插入边 -gql语句:{}", insertEdge);
return insertEdge;
}
/**
* @return java.lang.StringBuffer
* @Description "n1", 1
* @Param [edgeValueList]
**/
private static StringBuffer getStringBuffer(List<Object> edgeValueList) {
StringBuffer stringBuffer = new StringBuffer();
if (CollectionUtil.isNotEmpty(edgeValueList)) {
//stringBuffer.append("(");
for (int i = 0; i < edgeValueList.size(); i++) {
Object value = edgeValueList.get(i);
if (value instanceof String) {
stringBuffer.append("'").append(StringEscapeUtils.unescapeHtml((String) value)).append("'");
} else {
stringBuffer.append(value);
}
if (edgeValueList.size() > 1 && (i + 1) != edgeValueList.size()) {
stringBuffer.append(",");
}
}
//stringBuffer.append(")");
}
return stringBuffer;
}
/**
* @return java.lang.String
* @Description ,
* @Param [graphDeleteEdge]
**/
public static String deleteEdge(GraphDeleteEdge graphDeleteEdge, String vidType) {
Object srcVid = graphDeleteEdge.getSrcVid();
Object dstVid = graphDeleteEdge.getDstVid();
if (vidType.contains("STRING")) {
srcVid = "'" + srcVid.toString() + "'";
dstVid = "'" + dstVid.toString() + "'";
}
String deleteEdge = String.format("USE `%s`; DELETE EDGE `%s` %s -> %s @0;"
, graphDeleteEdge.getSpace(), graphDeleteEdge.getEdgeName(), srcVid, dstVid);
log.info("删除边 -gql语句:{}", deleteEdge);
return deleteEdge;
}
/**
* @return java.lang.String
* @Description
* @Param [graphSpace]
**/
public static String listEdge(GraphSpace graphSpace) {
String listEdge = String.format("USE `%s`;MATCH ()-[e]->()RETURN e LIMIT " + Integer.MAX_VALUE + " ;", graphSpace.getSpace());
log.info("查询创建的边 -gql语句:{}", listEdge);
return listEdge;
}
/**
* @return java.lang.String
* @Description
* @Param [graphExpand]
**/
public static String expandQuery(GraphExpand graphExpand, String vidType) {
StringBuffer stringBuffer = new StringBuffer();
List<String> edgeList = graphExpand.getEdgeList();
for (int i = 0; i < edgeList.size(); i++) {
String edge = edgeList.get(i);
stringBuffer.append(":");
stringBuffer.append("`").append(edge).append("`");
if (edgeList.size() > 1 && (i + 1) != edgeList.size()) {
stringBuffer.append("|");
}
}
String bufferString = stringBuffer.toString();
log.info("bufferString:{}", bufferString);
List<String> leftAndRight = EdgeDirectionEnum.getLeftAndRight(graphExpand.getDirection());
String expandQuery = String.format("USE `%s`;MATCH p=(v) %s- [e " + bufferString + " * %s %s]-%s (v2) WHERE id(v) IN [%s] %s RETURN p LIMIT " + graphExpand.getResultSize() + ";",
graphExpand.getSpace(), leftAndRight.get(0), graphExpand.getStepStart(), graphExpand.getStepEndResult(), leftAndRight.get(1), graphExpand.getVidList(vidType), StringEscapeUtils.unescapeHtml(graphExpand.getCondition()));
log.info("扩展查询 -gql语句:{}", expandQuery);
return expandQuery;
}
/**
* @return java.lang.String
* @Description
* @Param [graphExpand]
**/
public static String subgraphQuery(GraphExpand graphExpand, String vidType) {
String direction = EdgeDirectionEnum.getDirection(graphExpand.getDirection());
String expandQuery = String.format("USE `%s`;GET SUBGRAPH %s STEPS FROM %s %s %s YIELD VERTICES AS `vertices_`, EDGES AS `edges_`;",
graphExpand.getSpace(), graphExpand.getStepStart(), graphExpand.getVidList(vidType), direction, Joiner.on(",").join(graphExpand.getEdgeList()));
log.info("扩展查询 -gql语句:{}", expandQuery);
return expandQuery;
}
/**
* @return java.lang.String
* @Description tag
* @Param [graphVertexTatsQuery]
**/
public static String vertexTagsQuery(GraphVertexTatsQuery graphVertexTatsQuery, String vidType) {
String tag = "";
if (StrUtil.isNotBlank(graphVertexTatsQuery.getTag())) {
tag = ":`" + graphVertexTatsQuery.getTag() + "`";
}
Object pointKey = graphVertexTatsQuery.getPointKey();
if (ObjectUtil.isNotNull(pointKey)) {
if (vidType.contains("STRING")) {
pointKey = "WHERE id(v) IN ['" + pointKey.toString() + "']";
} else {
pointKey = "WHERE id(v) IN [" + pointKey.toString() + "]";
}
} else {
pointKey = "";
}
String vertexTagsQuery = String.format("USE `%s`;MATCH p=(v %s) %s return v limit " + Integer.MAX_VALUE + ";",
graphVertexTatsQuery.getSpace(), tag, pointKey);
log.info("根据tag标签查询点 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
public static String vertexTagsQueryPage(GraphVertexTatsQuery graphVertexTatsQuery, String vidType) {
int skip = (graphVertexTatsQuery.getPageNum() - 1) * graphVertexTatsQuery.getPageSize();
String tag = "";
if (StrUtil.isNotBlank(graphVertexTatsQuery.getTag())) {
tag = ":`" + graphVertexTatsQuery.getTag() + "`";
}
Object pointKey = graphVertexTatsQuery.getPointKey();
if (ObjectUtil.isNotNull(pointKey)) {
if (vidType.contains("STRING")) {
pointKey = "WHERE id(v) IN ['" + pointKey.toString() + "']";
} else {
pointKey = "WHERE id(v) IN [" + pointKey.toString() + "]";
}
} else {
pointKey = "";
}
String vertexTagsQuery = String.format("USE `%s`;MATCH p=(v %s) %s return v SKIP " + skip + " limit " + graphVertexTatsQuery.getPageSize() + ";",
graphVertexTatsQuery.getSpace(),//Joiner.on(":").join(graphVertexTatsQuery.getTagList()));
tag, pointKey);
log.info("根据tag标签分页查询点 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
/**
* @return java.lang.String
* @Description tag
* @Param [graphVertexTatAttributeQuery]
**/
public static String vertexTagAttributeQuery(GraphVertexTatAttributeQuery graphVertexTatAttributeQuery) {
String vertexTagsQuery = String.format("USE `%s`;match p=(v:`%s`) %s return v limit " + graphVertexTatAttributeQuery.getResultSize() + ";"
, graphVertexTatAttributeQuery.getSpace(), graphVertexTatAttributeQuery.getTag(), graphVertexTatAttributeQuery.getCondition());
log.info("根据tag标签属性查询点 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
/**
* @return java.lang.String
* @Description
* @Param [graphCreateIndex]
**/
public static String createIndex(GraphCreateIndex graphCreateIndex) {
List<String> propertyList = CollectionUtil.newArrayList();
for (AttributeBean attributeBean : graphCreateIndex.getAttributeBeanList()) {
propertyList.add(attributeBean.getPropertyName());
}
String vertexTagsQuery = String.format("USE `%s`;CREATE %s INDEX `%s` on `%s`(%s) COMMENT '%s';"
, graphCreateIndex.getSpace(), graphCreateIndex.getType(), graphCreateIndex.getIndexName(), graphCreateIndex.getTagEdgeName(),
Joiner.on(",").join(propertyList), graphCreateIndex.getComment());
log.info("创建索引 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
public static String createFullIndex(GraphCreateIndex graphCreateIndex) {
List<String> propertyList = CollectionUtil.newArrayList();
for (AttributeBean attributeBean : graphCreateIndex.getAttributeBeanList()) {
propertyList.add(attributeBean.getPropertyName());
}
String vertexTagsQuery = String.format("USE `%s`;CREATE FULLTEXT %s INDEX nebula_index_" + RandomUtil.randomNumbers(4) + " ON `%s`(name)"
, graphCreateIndex.getSpace(), graphCreateIndex.getType(), graphCreateIndex.getTagEdgeName());
log.info("创建全文索引 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
/**
* @return java.lang.String
* @Description
* @Param [graphShowInfo]
**/
public static String showCreateAttributeInfo(GraphShowInfo graphShowInfo) {
String showCreateAttributeInfo = String.format("USE `%s`; SHOW CREATE %s `%s`;"
, graphShowInfo.getSpace(), graphShowInfo.getAttribute(), graphShowInfo.getAttributeName());
log.info("查询属性的详细信息 -gql语句:{}", showCreateAttributeInfo);
return showCreateAttributeInfo;
}
public static String showAttributePage(GraphPageAttribute graphPageAttribute) {
int skip = (graphPageAttribute.getPageNum() - 1) * graphPageAttribute.getPageSize();
if (AttributeEnum.TAGS.name().equalsIgnoreCase(graphPageAttribute.getAttribute())) {
String showAttributePage = String.format("USE `%s`; MATCH (v) RETURN v SKIP %s LIMIT %s;"
, graphPageAttribute.getSpace(), skip, graphPageAttribute.getPageSize());
log.info("查询tag分页 -gql语句:{}", showAttributePage);
return showAttributePage;
}
if (AttributeEnum.EDGES.name().equalsIgnoreCase(graphPageAttribute.getAttribute())) {
String showAttributePage = String.format("USE `%s`;MATCH ()-[e]->() RETURN e SKIP %s LIMIT %s;"
, graphPageAttribute.getSpace(), skip, graphPageAttribute.getPageSize());
log.info("查询edge分页 -gql语句:{}", showAttributePage);
return showAttributePage;
}
return "";
}
public static <T> PageInfo<T> startPage(List<T> list, Integer pageNum, Integer pageSize) {
//创建Page类
Page page = new Page(pageNum, pageSize);
//为Page类中的total属性赋值
page.setTotal(list.size());
//计算当前需要显示的数据下标起始值
int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, list.size());
//从链表中截取需要显示的子链表并加入到Page
page.addAll(list.subList(startIndex, endIndex));
//以Page创建PageInfo
PageInfo pageInfo = new PageInfo<>(page);
return pageInfo;
}
/**
* @return java.lang.String
* @Description tag
* @Param [graphUpdateVertex]
**/
public static String updateVertex(GraphUpdateVertex graphUpdateVertex, String vidType) {
List<String> tagList = graphUpdateVertex.getTagList();
List<Object> tagValueList = graphUpdateVertex.getTagValueList();
if (tagList.size() != tagValueList.size()) {
return "";
}
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < tagList.size(); i++) {
String tag = tagList.get(i);
Object tagValue = tagValueList.get(i);
stringBuffer.append("`").append(tag).append("`").append(" = ");
if (tagValue instanceof String) {
stringBuffer.append("'").append(tagValue).append("'");
} else {
stringBuffer.append(tagValue);
}
if (tagList.size() > 1 && (i + 1) != tagList.size()) {
stringBuffer.append(",");
}
}
Object pointKey = graphUpdateVertex.getPointKey();
if (vidType.contains("STRING")) {
pointKey = "'" + pointKey.toString() + "'";
}
String updateVertex = String.format("USE `%s`; UPDATE VERTEX ON `%s` %s SET %s;"
, graphUpdateVertex.getSpace(), graphUpdateVertex.getTagName(), pointKey, stringBuffer);
log.info("修改点 -gql语句:{}", updateVertex);
return updateVertex;
}
/**
* @return java.lang.String
* @Description
* @Param [graphPageEdge]
**/
public static String edgePage(GraphPageEdge graphPageEdge) {
String edge = "";
if (StrUtil.isNotBlank(graphPageEdge.getEdge())) {
edge = ":`" + graphPageEdge.getEdge() + "`";
}
int skip = (graphPageEdge.getPageNum() - 1) * graphPageEdge.getPageSize();
String edgePage;
if (StrUtil.isBlank(graphPageEdge.getVid())) {
edgePage = String.format("USE `%s`;MATCH ()-[e %s]->()RETURN e SKIP " + skip +
" LIMIT " + graphPageEdge.getPageSize() + " ;", graphPageEdge.getSpace(), edge);
} else {
edgePage = String.format("USE `%s`;MATCH (m)-[e %s]->(n) where id(m)=='%s' RETURN e " +
"UNION MATCH (m)-[e %s]->(n) where id(n)=='%s' RETURN e SKIP " + skip +
" LIMIT " + graphPageEdge.getPageSize() + " ;", graphPageEdge.getSpace(), edge, graphPageEdge.getVid(), edge, graphPageEdge.getVid());
}
log.info("分页查询创建的边 -gql语句:{}", edgePage);
return edgePage;
}
/**
* @return java.lang.String
* @Description
* @Param [graphSpace]
**/
public static String vertexPage(GraphSpace graphSpace) {
int skip = (graphSpace.getPageNum() - 1) * graphSpace.getPageSize();
String queryMatch = String.format("USE `%s`; match (v) return v skip " + skip + " limit " + graphSpace.getPageSize() + ";", graphSpace.getSpace());
log.info("点的分页查询 -gql语句:{}", queryMatch);
return queryMatch;
}
/**
* @return java.lang.String
* @Description
* @Param [graphUpdateEdge]
**/
public static String updateEdge(GraphUpdateEdge graphUpdateEdge, String vidType) {
List<String> edgeList = graphUpdateEdge.getEdgeList();
List<Object> edgeValueList = graphUpdateEdge.getEdgeValueList();
if (edgeList.size() != edgeValueList.size()) {
return "";
}
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < edgeList.size(); i++) {
String tag = edgeList.get(i);
Object tagValue = edgeValueList.get(i);
stringBuffer.append("`").append(tag).append("`").append(" = ");
if (tagValue instanceof String) {
stringBuffer.append("'").append(tagValue).append("'");
} else {
stringBuffer.append(tagValue);
}
if (edgeList.size() > 1 && (i + 1) != edgeList.size()) {
stringBuffer.append(",");
}
}
Object srcVid = graphUpdateEdge.getSrcVid();
Object dstVid = graphUpdateEdge.getDstVid();
if (vidType.contains("STRING")) {
srcVid = "'" + srcVid.toString() + "'";
dstVid = "'" + dstVid.toString() + "'";
}
String updateVertex = String.format("USE `%s`; UPDATE EDGE ON `%s` %s -> %s@0 SET %s;"
, graphUpdateEdge.getSpace(), graphUpdateEdge.getEdgeName(), srcVid, dstVid
, stringBuffer);
log.info("关系编辑 -gql语句:{}", updateVertex);
return updateVertex;
}
/**
* @return java.lang.String
* @Description tag
* @Param [graphVertexTatAttributeQuery]
**/
public static String vertexAskQueryAnalysis(String tagName, String name) {
String vertexTagsQuery = String.format("match p=(v:`%s`)-[e]-(v2) where v.`%s`.`name` CONTAINS '%s' return nodes(p),relationships(p) "
, tagName, tagName, name);
log.info("根据tag标签属性查询点 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
//public static String vertexAskQueryAnalysis(String tagName, List<String> ids) {
// String vertexTagsQuery = String.format("match p=(v:`%s`)-[e]-(v2) where id(v2) in %s return nodes(p),relationships(p)"
// , tagName,JSONUtil.toJsonStr(ids),tagName,JSONUtil.toJsonStr(ids));
// log.info("根据tag标签属性查询点 -gql语句:{}", vertexTagsQuery);
// return vertexTagsQuery;
//}
public static String vertexAskQuery(String tagName, String name) {
String vertexTagsQuery = String.format("match p=(v:`%s`) where v.`%s`.`name` CONTAINS '%s' return nodes(p),relationships(p) "
, tagName, tagName, name);
log.info("根据tag标签属性查询点 -gql语句:{}", vertexTagsQuery);
return vertexTagsQuery;
}
/**
*
*
* @return java.lang.String
* @Param [graphPageEdge]
**/
public static String edgeCondition(GraphPageEdge graphPageEdge) {
String edge = "";
if (StrUtil.isNotBlank(graphPageEdge.getEdge())) {
edge = ":`" + graphPageEdge.getEdge() + "`";
}
String edgeCondition = "";
if (StrUtil.isBlank(graphPageEdge.getVid())) {
edgeCondition = String.format("USE `%s`;MATCH ()-[e %s]->() RETURN e limit " + Integer.MAX_VALUE + ";", graphPageEdge.getSpace(), edge);
} else {
edgeCondition = String.format("USE `%s`;MATCH (m)-[e %s]->(n) where id(m)=='%s' RETURN e " +
"UNION MATCH (m)-[e %s]->(n) where id(n)=='%s' RETURN e LIMIT " +
Integer.MAX_VALUE + ";", graphPageEdge.getSpace(), edge, graphPageEdge.getVid(), edge, graphPageEdge.getVid());
}
log.info("根据条件查询边 -gql语句:{}", edgeCondition);
return edgeCondition;
}
/**
*
*
* @return java.lang.String
* @Param [graphShowInfo]
**/
public static String infoIndex(GraphShowInfo graphShowInfo) {
String infoIndex = String.format("USE `%s`; DESCRIBE %s INDEX `%s`;", graphShowInfo.getSpace()
, graphShowInfo.getAttribute(), graphShowInfo.getAttributeName());
log.info("查询索引的详细信息 -gql语句:{}", infoIndex);
return infoIndex;
}
/**
*
*
* @return java.lang.String
* @Param [space]
**/
public static String rebuildFullIndex(String space) {
return "USE `" + space + "`;REBUILD FULLTEXT INDEX;";
}
/**
*
*
* @return java.lang.String
* @Param [tag, word]
**/
public static String fullQuery(String tag, String word) {
String fullQuery = String.format("LOOKUP ON `%s` WHERE WILDCARD(`%s`.name, \"*%s*\") YIELD id(vertex)"
, tag, tag, word);
return fullQuery;
}
/**
* id
*
* @return java.lang.String
* @Param [space, idList]
**/
public static String queryMatchVertex(String space, List<?> idList) {
String queryMatch = String.format("USE `%s`; match (v) WHERE id(v) IN %s RETURN v;"
, space, JSONUtil.toJsonStr(idList));
log.info("match查询 -gql语句:{}", queryMatch);
return queryMatch;
}
/**
*
*
* @return java.lang.String
* @Param [graphVertexPathQuery, vidType]
**/
public static String findPath(GraphVertexPathQuery graphVertexPathQuery, String vidType) {
List<Object> srcVidList = graphVertexPathQuery.getSrcVid();
List<Object> dstVidList = graphVertexPathQuery.getDstVid();
String srcVid = "";
String dstVid = "";
if (vidType.contains("STRING")) {
for (Object id : srcVidList) {
srcVid += "\"" + id.toString() + "\"" + ",";
}
for (Object id : dstVidList) {
dstVid += "\"" + id.toString() + "\"" + ",";
}
}
String queryMatch = String.format("USE `%s`; FIND %s PATH WITH PROP FROM %s TO %s OVER %s %s %s UPTO %s STEPS YIELD path AS p | limit %s;"
, graphVertexPathQuery.getSpace(), graphVertexPathQuery.getPathType(), srcVid.substring(0, srcVid.length() - 1)
, dstVid.substring(0, dstVid.length() - 1)
, graphVertexPathQuery.getEdgeList(), graphVertexPathQuery.getDirect(), StringEscapeUtils.unescapeHtml(graphVertexPathQuery.getCondition())
, graphVertexPathQuery.getStep(), graphVertexPathQuery.getResultSize());
log.info("match查询 -gql语句:{}", queryMatch);
return queryMatch;
}
/**
*
*
* @return java.lang.String
* @Param [graphCreateIndex, listenerHost]
**/
public static String addListener(GraphCreateIndex graphCreateIndex, String listenerHost) {
String addListener = String.format("USE `%s`; ADD LISTENER ELASTICSEARCH %s;"
, graphCreateIndex.getSpace(), listenerHost);
log.info("增加监听 -gql语句:{}", addListener);
return addListener;
}
/**
*
*
* @return java.lang.String
* @Param [graphCreateIndex]
**/
public static String showListener(GraphCreateIndex graphCreateIndex) {
return "USE " + graphCreateIndex.getSpace() + ";SHOW LISTENER;";
}
/**
*
*
* @return java.lang.String
* @Param [space]
**/
public static String showFullIndexes(String space) {
return "USE " + space + ";SHOW FULLTEXT INDEXES;";
}
/**
*
*
* @return java.lang.String
* @Param [graphDropAttribute, fullIndexName]
**/
public static String dropFullIndex(GraphDropAttribute graphDropAttribute, String fullIndexName) {
String dropFullIndex = String.format("USE `%s`; DROP FULLTEXT INDEX %s;"
, graphDropAttribute.getSpace(), fullIndexName);
log.info("删除全文索引 -gql语句:{}", dropFullIndex);
return dropFullIndex;
}
/**
*
*
* @return java.lang.String
* @Param [tag, ids]
**/
public static String vertexAskQueryByTag(String tag, List<String> ids) {
String vertexAskQueryByTag = String.format(" MATCH p=(v:`%s`)-[e]->(v2) WHERE id(v2) IN %s RETURN nodes(p) LIMIT 1000"
, tag, JSONUtil.toJsonStr(ids));
log.info("补充信息 -gql语句:{}", vertexAskQueryByTag);
return vertexAskQueryByTag;
}
/**
*
*
* @return java.lang.String
* @Param [space, ids]
**/
public static String commonNeighbor(String space, List<Object> ids) {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < ids.size(); i++) {
if (i + 1 < ids.size()) {
stringBuffer.append(" UNION GO FROM '" + ids.get(i) + "' OVER * REVERSELY YIELD src(edge) as id) INTERSECT(GO FROM '" + ids.get(i + 1) + "' OVER * YIELD dst(edge) as id ");
}
}
log.info(stringBuffer.toString());
String commonNeighbor = String.format("USE `%s`; (GO FROM '%s' OVER * YIELD dst(edge) as id %s UNION GO FROM '%s' OVER * REVERSELY YIELD src(edge) as id)",
space, ids.get(0), stringBuffer, ids.get(ids.size() - 1));
log.info("共同邻居 -gql语句:{}", commonNeighbor);
return commonNeighbor;
}
public static String findPathList(String space, List<String> row, List<Object> ids, String vidType) {
String str = JSONUtil.toJsonStr(row);
String idsStr = JSONUtil.toJsonStr(ids);
String findPathList = String.format("USE `%s`; FIND ALL PATH WITH PROP FROM %s TO %s OVER * BIDIRECT UPTO 1 STEPS YIELD path as p | limit 1000;"
, space, str.substring(1, str.length() - 1), idsStr.substring(1, idsStr.length() - 1));
log.info("match查询 -gql语句:{}", findPathList);
return findPathList;
}
}

@ -0,0 +1,53 @@
package com.supervision.nebula.util;
import lombok.Data;
/**
*
*/
@Data
public class R<T> {
// 返回体
private Integer code;
private String msg;
private T data;
/**
*
**/
public static R success(Object object) {
R result = new R();
result.setCode(ResultCode.SUCCESS.getCode());
result.setMsg(ResultCode.SUCCESS.getMsg());
result.setData(object);
return result;
}
public static <T> R<T> data(Object object) {
R result = new R();
result.setCode(ResultCode.SUCCESS.getCode());
result.setMsg(ResultCode.SUCCESS.getMsg());
result.setData(object);
return result;
}
/**
*
**/
public R fail(Object object) {
R result = new R();
result.setCode(ResultCode.FAIL.getCode());
result.setMsg(ResultCode.FAIL.getMsg());
result.setData(object);
return result;
}
public R result(Integer code, String msg, Object object) {
R result = new R();
result.setCode(code);
result.setMsg(msg);
result.setData(object);
return result;
}
}

@ -0,0 +1,32 @@
package com.supervision.nebula.util;
/**
* @Descriptin:
* @ClassName: ResultCode
*/
/**
*
*/
public enum ResultCode {
SUCCESS(10000, "成功"),
FAIL(1, "失败"),
UNKNOWN_ERROR(-1, "未知错误"),
NO_DATA(10001, "暂无数据");
private final Integer code;
private final String msg;
ResultCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}

@ -0,0 +1,121 @@
package com.supervision.nebula.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Map;
/**
* @Descriptin: 11
* @ClassName: aaa
*/
@ApiModel("属性查询返回类")
public class AttributeVo {
/**
* spaceName : flceshi
* latencyInUs : 1986
* data : [{"meta":[""],"row":["basketballplayer"]},{"meta":[""],"row":["demo_lw"]},{"meta":[""],"row":["flceshi"]},{"meta":[""],"row":["lubrication_faultId_detection"]},{"meta":[""],"row":["lubrication_faultId_detection_sample"]},{"meta":[""],"row":["wentao_teatSpace"]},{"meta":[""],"row":["电影"]}]
* columns : ["Name"]
* errors : {"code":0}
*/
@ApiModelProperty("空间名称")
private String spaceName;
@ApiModelProperty()
private int latencyInUs;
private ErrorsBean errors;
@ApiModelProperty("查询返回属性集合")
private List<DataBean> data;
@ApiModelProperty("返回字段名集合")
private List<String> columns;
private Map<String, List<String>> fieldMap;
public String getSpaceName() {
return spaceName;
}
public void setSpaceName(String spaceName) {
this.spaceName = spaceName;
}
public int getLatencyInUs() {
return latencyInUs;
}
public void setLatencyInUs(int latencyInUs) {
this.latencyInUs = latencyInUs;
}
public ErrorsBean getErrors() {
return errors;
}
public void setErrors(ErrorsBean errors) {
this.errors = errors;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public List<String> getColumns() {
return columns;
}
public void setColumns(List<String> columns) {
this.columns = columns;
}
public Map<String, List<String>> getFieldMap() {
return fieldMap;
}
public void setFieldMap(Map<String, List<String>> fieldMap) {
this.fieldMap = fieldMap;
}
public static class ErrorsBean {
/**
* code : 0
*/
@ApiModelProperty("错误码0正常")
private int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
public static class DataBean {
@ApiModelProperty("元数据")
private List<String> meta;
@ApiModelProperty("字段值集合")
private List<String> row;
public List<String> getMeta() {
return meta;
}
public void setMeta(List<String> meta) {
this.meta = meta;
}
public List<String> getRow() {
return row;
}
public void setRow(List<String> row) {
this.row = row;
}
}
}

@ -0,0 +1,64 @@
package com.supervision.nebula.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Descriptin:
* @ClassName: CommonVo
*/
@ApiModel("操作通用返回类")
public class CommonVo {
/**
* spaceName : flceshi
* latencyInUs : 2305
* errors : {"code":0}
*/
@ApiModelProperty("空间名称")
private String spaceName;
@ApiModelProperty()
private int latencyInUs;
private ErrorsBean errors;
public String getSpaceName() {
return spaceName;
}
public void setSpaceName(String spaceName) {
this.spaceName = spaceName;
}
public int getLatencyInUs() {
return latencyInUs;
}
public void setLatencyInUs(int latencyInUs) {
this.latencyInUs = latencyInUs;
}
public ErrorsBean getErrors() {
return errors;
}
public void setErrors(ErrorsBean errors) {
this.errors = errors;
}
public static class ErrorsBean {
/**
* code : 0
*/
@ApiModelProperty("错误码0正常")
private int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
}

@ -0,0 +1,27 @@
package com.supervision.nebula.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Descriptin:
* @ClassName: DetailSpace
*/
@ApiModel("图空间详情实体")
@Data
public class DetailSpace {
@ApiModelProperty("空间名称")
private String space;
@ApiModelProperty("标签个数")
private Integer tagsNum;
@ApiModelProperty("边类型个数")
private Integer edgesNum;
//@ApiModelProperty("空间备注")
//private String spaceComment;
}

@ -1,10 +1,8 @@
package com.supervision.config;
package com.supervision.neo4j.config;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -1,9 +1,7 @@
package com.supervision.controller;
package com.supervision.neo4j.controller;
import com.supervision.node.DiseaseNode;
import com.supervision.repo.DiseaseRepository;
import com.supervision.service.GraphService;
import com.supervision.neo4j.service.GraphService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@ -1,4 +1,4 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;

@ -1,9 +1,10 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;
import java.util.Set;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Property;
@Data
@NodeEntity("疾病分类名称")

@ -1,7 +1,6 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.*;
import java.util.HashSet;

@ -1,7 +1,10 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Property;
@NodeEntity("药品")

@ -1,7 +1,10 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Property;
@NodeEntity("知识库")
@Data

@ -1,9 +1,8 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;
import java.util.HashSet;
import java.util.Set;

@ -1,8 +1,10 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Property;
@Data
@NodeEntity("体格检查工具")

@ -1,4 +1,4 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;

@ -1,4 +1,4 @@
package com.supervision.node;
package com.supervision.neo4j.node;
import lombok.Data;
import org.neo4j.ogm.annotation.*;

@ -1,6 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.AncillaryNode;
import com.supervision.neo4j.node.AncillaryNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

@ -1,6 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.DiseaseNode;
import com.supervision.neo4j.node.DiseaseNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

@ -1,7 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.DiseaseNode;
import com.supervision.node.KnowledgeBaseNode;
import com.supervision.neo4j.node.KnowledgeBaseNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

@ -1,7 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.AncillaryNode;
import com.supervision.node.PhysicalNode;
import com.supervision.neo4j.node.PhysicalNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

@ -1,7 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.KnowledgeBaseNode;
import com.supervision.node.PhysicalToolNode;
import com.supervision.neo4j.node.PhysicalToolNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

@ -1,6 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.ProcessNode;
import com.supervision.neo4j.node.ProcessNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

@ -1,7 +1,6 @@
package com.supervision.repo;
package com.supervision.neo4j.repo;
import com.supervision.node.ProcessNode;
import com.supervision.node.TreatmentPlanNode;
import com.supervision.neo4j.node.TreatmentPlanNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save