lynnbond commented on code in PR #2143:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2143#discussion_r1127279258


##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherClient.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.api.cypher;
+
+import org.apache.hugegraph.util.E;
+import org.apache.hugegraph.util.Log;
+import org.apache.commons.configuration2.Configuration;
+import org.apache.tinkerpop.gremlin.driver.*;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.slf4j.Logger;
+
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.ThreadSafe;
+
+import java.util.*;
+import java.util.concurrent.ExecutionException;
+import java.util.function.Supplier;
+
+@ThreadSafe
+public final class CypherClient {
+    private static final Logger LOG = Log.logger(CypherClient.class);
+    private String userName;
+    private String password;
+    private String token;
+    private Supplier<Configuration> configurationSupplier;
+
+    CypherClient(String userName, String password,
+                 Supplier<Configuration> configurationSupplier) {
+        this.userName = userName;
+        this.password = password;
+        this.configurationSupplier = configurationSupplier;
+    }
+
+    CypherClient(String token, Supplier<Configuration> configurationSupplier) {
+        this.token = token;
+        this.configurationSupplier = configurationSupplier;
+    }
+
+    public CypherModel submitQuery(String cypherQuery, @Nullable Map<String, 
String> aliases) {
+        E.checkArgument(cypherQuery != null && !cypherQuery.isEmpty(),
+                        "The cypher-query parameter can't be null or empty");
+
+        Cluster cluster = Cluster.open(getConfig());
+        Client client = cluster.connect();
+
+        if (aliases != null && !aliases.isEmpty()) {
+            client = client.alias(aliases);
+        }
+
+        RequestMessage request = createRequest(cypherQuery);
+        CypherModel res = null;
+
+        try {
+            List<Object> list = this.doQueryList(client, request);
+            res = CypherModel.dataOf(request.getRequestId().toString(), list);
+        } catch (Exception e) {
+            LOG.error(String.format("Failed to submit cypher-query: [ %s ], 
cause by:"

Review Comment:
   It's an error message, there isn't a method that allows me to use {} and 
print the stack trace at the same time.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to