2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aai.query.builder;
23 import org.apache.tinkerpop.gremlin.process.traversal.P;
24 import org.apache.tinkerpop.gremlin.process.traversal.Step;
25 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
26 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
27 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
28 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
29 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
30 import org.apache.tinkerpop.gremlin.structure.Vertex;
31 import org.onap.aai.db.props.AAIProperties;
32 import org.onap.aai.introspection.Introspector;
33 import org.onap.aai.introspection.Loader;
34 import org.onap.aai.schema.enums.ObjectMetadata;
36 import java.util.HashMap;
37 import java.util.List;
39 import java.util.Optional;
40 import java.util.stream.Collectors;
42 public class HistoryTraversalURIOptimizedQuery<E> extends TraversalURIOptimizedQuery {
44 protected Map<Integer, String> stepToAaiUri = new HashMap<>();
46 public HistoryTraversalURIOptimizedQuery(Loader loader, GraphTraversalSource source) {
47 super(loader, source);
50 public HistoryTraversalURIOptimizedQuery(Loader loader, GraphTraversalSource source, Vertex start) {
51 super(loader, source, start);
54 protected HistoryTraversalURIOptimizedQuery(GraphTraversal traversal, Loader loader, GraphTraversalSource source,
55 GraphTraversalBuilder gtb) {
56 super(traversal, loader, source, gtb);
59 protected HistoryTraversalURIOptimizedQuery(GraphTraversal traversal, Loader loader, GraphTraversalSource source,
60 GraphTraversalBuilder gtb, Map<Integer, String> stepToAaiUri) {
61 super(traversal, loader, source, gtb, stepToAaiUri);
65 protected void vertexHas(String key, Object value) {
66 super.vertexHas(key, value);
67 touchHistoryProperties(key, value);
71 protected void vertexHasNot(String key) {
72 super.vertexHasNot(key);
73 touchHistoryProperties(key);
77 protected void vertexHas(String key) {
79 touchHistoryProperties(key);
82 private void touchHistoryProperties(String key){
83 if(key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
84 traversal.where(__.properties(key));
88 private void touchHistoryProperties(String key, Object value){
89 if(key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
90 traversal.where(__.properties(key).hasValue(value));