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;
25 import org.openecomp.aai.db.props.AAIProperties;
26 import org.openecomp.aai.introspection.Loader;
27 import org.openecomp.aai.introspection.LoaderFactory;
28 import org.openecomp.aai.query.builder.QueryBuilder;
31 * The Class QueryParser.
33 public abstract class QueryParser {
35 protected Loader loader = null;
36 protected Loader latestLoader = null;
37 protected QueryBuilder queryBuilder = null;
39 protected QueryBuilder parentQueryBuilder = null;
41 protected URI uri = null;
43 protected String resultResource = "";
45 protected String parentResourceType = "";
47 protected String containerResource = "";
50 * Instantiates a new query parser.
52 * @param loader the loader
53 * @param queryBuilder the query builder
56 protected QueryParser(Loader loader, QueryBuilder queryBuilder, URI uri) {
58 this.queryBuilder = queryBuilder;
60 this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
64 * Instantiates a new query parser.
66 * @param loader the loader
67 * @param queryBuilder the query builder
69 protected QueryParser(Loader loader, QueryBuilder queryBuilder) {
70 this.queryBuilder = queryBuilder;
72 this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
76 * Gets the container type.
78 * @return the container type
80 public String getContainerType() {
82 return this.containerResource;
86 * Gets the parent result type.
88 * @return the parent result type
90 public String getParentResultType() {
91 return this.parentResourceType;
95 * Gets the result type.
97 * @return the result type
99 public String getResultType() {
100 return this.resultResource;
104 * Gets the query builder.
106 * @return the query builder
108 public QueryBuilder getQueryBuilder() {
109 return this.queryBuilder;
117 public URI getUri() {
122 * Gets the parent query builder.
124 * @return the parent query builder
126 public QueryBuilder getParentQueryBuilder() {
127 if (this.parentQueryBuilder != null) {
128 return this.parentQueryBuilder;
130 return this.queryBuilder;
135 * Checks if is dependent.
137 * @return true, if is dependent
139 public boolean isDependent() {
140 return !this.queryBuilder.getQuery().toString().equals(this.queryBuilder.getParentQuery().getQuery().toString());