Skip to content
This repository was archived by the owner on Feb 12, 2019. It is now read-only.

Commit 6ef2e16

Browse files
committed
creates delete converter
1 parent 8cb8576 commit 6ef2e16

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,45 @@
1+
/*
2+
* Copyright (c) 2017 Otávio Santana and others
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
115
package org.jnosql.artemis.graph.query;
216

3-
public class DeleteQueryConverter {
17+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
18+
import org.apache.tinkerpop.gremlin.structure.Vertex;
19+
import org.jnosql.aphrodite.antlr.method.DeleteMethodFactory;
20+
import org.jnosql.artemis.reflection.ClassRepresentation;
21+
import org.jnosql.query.Condition;
22+
import org.jnosql.query.DeleteQuery;
23+
import org.jnosql.query.Where;
24+
25+
import java.util.List;
26+
import java.util.function.Function;
27+
28+
class DeleteQueryConverter extends AbstractQueryConvert implements Function<GraphQueryMethod, List<Vertex>> {
29+
30+
@Override
31+
public List<Vertex> apply(GraphQueryMethod graphQuery) {
32+
DeleteMethodFactory factory = DeleteMethodFactory.get();
33+
DeleteQuery deleteQuery = factory.apply(graphQuery.getMethod(), graphQuery.getEntityName());
34+
ClassRepresentation representation = graphQuery.getRepresentation();
35+
GraphTraversal<Vertex, Vertex> traversal = graphQuery.getTraversal();
36+
if (deleteQuery.getWhere().isPresent()) {
37+
Where where = deleteQuery.getWhere().get();
38+
39+
Condition condition = where.getCondition();
40+
traversal.filter(getPredicate(graphQuery, condition, representation));
41+
}
42+
43+
44+
}
445
}

0 commit comments

Comments
 (0)