2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
21 package org.openecomp.aai.parsers.query;
23 import org.apache.tinkerpop.gremlin.structure.Vertex;
24 import org.openecomp.aai.db.props.AAIProperties;
25 import org.openecomp.aai.introspection.Loader;
26 import org.openecomp.aai.introspection.LoaderFactory;
27 import org.openecomp.aai.query.builder.QueryBuilder;
32 * The Class QueryParser.
34 public abstract class QueryParser {
36 protected Loader loader = null;
37 protected Loader latestLoader = null;
38 protected QueryBuilder<Vertex> queryBuilder = null;
40 protected QueryBuilder<Vertex> parentQueryBuilder = null;
42 protected URI uri = null;
44 protected String resultResource = "";
46 protected String parentResourceType = "";
48 protected String containerResource = "";
51 * Instantiates a new query parser.
53 * @param loader the loader
54 * @param queryBuilder the query builder
57 protected QueryParser(Loader loader, QueryBuilder<Vertex> queryBuilder, URI uri) {
59 this.queryBuilder = queryBuilder;
61 this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
65 * Instantiates a new query parser.
67 * @param loader the loader
68 * @param queryBuilder the query builder
70 protected QueryParser(Loader loader, QueryBuilder<Vertex> queryBuilder) {
71 this.queryBuilder = queryBuilder;
73 this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
77 * Gets the container type.
79 * @return the container type
81 public String getContainerType() {
83 return this.containerResource;
87 * Gets the parent result type.
89 * @return the parent result type
91 public String getParentResultType() {
92 return this.parentResourceType;
96 * Gets the result type.
98 * @return the result type
100 public String getResultType() {
101 return this.resultResource;
105 * Gets the query builder.
107 * @return the query builder
109 public QueryBuilder<Vertex> getQueryBuilder() {
110 return this.queryBuilder;
118 public URI getUri() {
123 * Gets the parent query builder.
125 * @return the parent query builder
127 public QueryBuilder<Vertex> getParentQueryBuilder() {
128 if (this.parentQueryBuilder != null) {
129 return this.parentQueryBuilder;
131 return this.queryBuilder;
136 * Checks if is dependent.
138 * @return true, if is dependent
140 public boolean isDependent() {
141 return !this.queryBuilder.getQuery().toString().equals(this.queryBuilder.getParentQuery().getQuery().toString());