2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.parsers.query;
24 import org.apache.tinkerpop.gremlin.structure.Vertex;
25 import org.onap.aai.db.props.AAIProperties;
26 import org.onap.aai.introspection.Loader;
27 import org.onap.aai.introspection.LoaderFactory;
28 import org.onap.aai.query.builder.QueryBuilder;
33 * The Class QueryParser.
35 public abstract class QueryParser {
37 protected Loader loader = null;
38 protected Loader latestLoader = null;
39 protected QueryBuilder<Vertex> queryBuilder = null;
41 protected QueryBuilder<Vertex> parentQueryBuilder = null;
43 protected URI uri = null;
45 protected String resultResource = "";
47 protected String parentResourceType = "";
49 protected String containerResource = "";
52 * Instantiates a new query parser.
54 * @param loader the loader
55 * @param queryBuilder the query builder
58 protected QueryParser(Loader loader, QueryBuilder<Vertex> queryBuilder, URI uri) {
60 this.queryBuilder = queryBuilder;
62 this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
66 * Instantiates a new query parser.
68 * @param loader the loader
69 * @param queryBuilder the query builder
71 protected QueryParser(Loader loader, QueryBuilder<Vertex> queryBuilder) {
72 this.queryBuilder = queryBuilder;
74 this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
78 * Gets the container type.
80 * @return the container type
82 public String getContainerType() {
84 return this.containerResource;
88 * Gets the parent result type.
90 * @return the parent result type
92 public String getParentResultType() {
93 return this.parentResourceType;
97 * Gets the result type.
99 * @return the result type
101 public String getResultType() {
102 return this.resultResource;
106 * Gets the query builder.
108 * @return the query builder
110 public QueryBuilder<Vertex> getQueryBuilder() {
111 return this.queryBuilder;
119 public URI getUri() {
124 * Gets the parent query builder.
126 * @return the parent query builder
128 public QueryBuilder<Vertex> getParentQueryBuilder() {
129 if (this.parentQueryBuilder != null) {
130 return this.parentQueryBuilder;
132 return this.queryBuilder;
137 * Checks if is dependent.
139 * @return true, if is dependent
141 public boolean isDependent() {
142 return !this.queryBuilder.getQuery().toString().equals(this.queryBuilder.getParentQuery().getQuery().toString());