Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement connection management, gremlin query, execute histroy and g… #3

Merged
merged 7 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Apache License

1. Definitions.

"License" shall mean the conditions and conditions for use, reproduction,
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
Expand Down
2 changes: 1 addition & 1 deletion hubble-be/assembly/descriptor/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
</dependencySet>
</dependencySets>

</assembly>
</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ private String handleMessage(String message, Object[] args) {
strArgs[i] = args[i].toString();
Linary marked this conversation as resolved.
Show resolved Hide resolved
}
}
String msg = message;
try {
msg = this.messageSourceHandler.getMessage(message, strArgs);
message = this.messageSourceHandler.getMessage(message, strArgs);
} catch (Throwable e) {
log.error(e.getMessage(), e);
}
return msg;
return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class CacheConfig {

public enum Caches {

GREMLIN_QUERY_EXPLAIN;
// No used
GREMLIN_QUERY;

private int maxSize = DEFAULT_MAXSIZE;
private int ttl = DEFAULT_TTL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ private void checkParamsValid(ExecuteHistory newEntity) {
Ex.check(newEntity.getDuration() != null,
"common.param.cannot-be-null", "duration");
Ex.check(newEntity.getCreateTime() == null,
"common.param.must-be-null", "createTime");
"common.param.must-be-null", "create_time");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void checkParamsValid(GraphConnection newEntity, boolean creating) {
newEntity.getUsername(), newEntity.getPassword());

Ex.check(newEntity.getCreateTime() == null,
"common.param.must-be-null", "createTime");
"common.param.must-be-null", "create_time");
}

private void checkEntityUnique(GraphConnection newEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void checkParamsValid(GremlinCollection newEntity,
this.checkParamsNotEmpty("content", newEntity.getContent(), creating);

Ex.check(newEntity.getCreateTime() == null,
"common.param.must-be-null", "createTime");
"common.param.must-be-null", "create_time");
}

private void checkEntityUnique(GremlinCollection newEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.springframework.web.bind.annotation.RestController;

import com.baidu.hugegraph.entity.AdjacentQuery;
import com.baidu.hugegraph.entity.ExecutePlan;
import com.baidu.hugegraph.entity.GremlinQuery;
import com.baidu.hugegraph.entity.GremlinResult;
import com.baidu.hugegraph.service.GremlinQueryService;
Expand All @@ -51,11 +50,7 @@ public class GremlinQueryController extends BaseController {
@PostMapping
public GremlinResult execute(@RequestBody GremlinQuery query) {
this.checkParamsValid(query);
// Get execute plan used for pre handle
ExecutePlan plan = this.service.explain(query);
String gremlin = plan.optimize(query.getContent());
query.setContent(gremlin);
return this.service.executeQuery(query, plan);
return this.service.executeQuery(query);
}

@PutMapping
Expand All @@ -71,8 +66,10 @@ private void checkParamsValid(GremlinQuery query) {
}

private void checkParamsValid(AdjacentQuery query) {
Ex.check(query.getConnectionId() != null,
"common.param.cannot-be-null", "connection_id");
Ex.check(query.getVertexId() != null,
"common.param.cannot-be-null", "vertexId");
"common.param.cannot-be-null", "vertex_id");
if (query.getConditions() != null && !query.getConditions().isEmpty()) {
for (AdjacentQuery.Condition condition : query.getConditions()) {
Ex.check(!StringUtils.isEmpty(condition.getKey()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package com.baidu.hugegraph.controller;

import java.util.concurrent.TimeUnit;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -74,7 +76,7 @@ public UserInfo config(@RequestParam(value = "locale",

Cookie cookie = new Cookie(Constant.COOKIE_USER, userInfo.getUsername());
cookie.setPath(request.getContextPath());
cookie.setMaxAge(3 * 24 * 60 * 60);
cookie.setMaxAge((int) TimeUnit.SECONDS.convert(3, TimeUnit.DAYS));
response.addCookie(cookie);
return userInfo;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.baidu.hugegraph.entity;

import java.util.Collection;
import java.util.List;

import com.baidu.hugegraph.structure.graph.Edge;
Expand All @@ -36,8 +37,6 @@
@Builder
public class GremlinResult {

@JsonProperty("type")
private Type type;
@JsonProperty("data")
private List<Object> data;
@JsonProperty("graph_view")
Expand All @@ -50,19 +49,8 @@ public class GremlinResult {
public static class GraphView {

@JsonProperty("vertices")
private List<Vertex> vertices;
private Collection<Vertex> vertices;
@JsonProperty("edges")
private List<Edge> edges;
}

public enum Type {

SINGLE,

VERTEX,

EDGE,

PATH;
private Collection<Edge> edges;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public IPage<GraphConnection> list(String content, Boolean graphOrderAsc,
if (!StringUtils.isEmpty(content)) {
query.like("name", content).or().like("graph", content);
}
/*
* The results will order by create_time when graph_order is null,
* otherwise order by graph firstly then by create_time.
*/
if (graphOrderAsc != null) {
if (graphOrderAsc) {
query.orderByAsc("graph");
Expand Down
Loading