Reduce the number of problems in aai-common by removing unused imports
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / parsers / query / RelationshipQueryParser.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.aai.parsers.query;
22
23 import java.io.UnsupportedEncodingException;
24
25 import org.onap.aai.config.SpringContextAware;
26 import org.onap.aai.edges.EdgeIngestor;
27 import org.onap.aai.exceptions.AAIException;
28 import org.onap.aai.introspection.Introspector;
29 import org.onap.aai.introspection.Loader;
30 import org.onap.aai.introspection.ModelType;
31 import org.onap.aai.parsers.relationship.RelationshipToURI;
32 import org.onap.aai.parsers.uri.URIParser;
33 import org.onap.aai.query.builder.QueryBuilder;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.springframework.context.ApplicationContext;
37
38 /**
39  * The Class RelationshipQueryParser.
40  */
41 public class RelationshipQueryParser extends LegacyQueryParser {
42
43     private static final Logger logger = LoggerFactory.getLogger(RelationshipQueryParser.class);
44
45     private Introspector relationship = null;
46
47     private ModelType modelType = null;
48
49     private EdgeIngestor edgeRules = null;
50
51     /**
52      * Instantiates a new relationship query parser.
53      *
54      * @param loader the loader
55      * @param queryBuilder the query builder
56      * @param obj the obj
57      * @throws UnsupportedEncodingException the unsupported encoding exception
58      * @throws AAIException the AAI exception
59      */
60     public RelationshipQueryParser(Loader loader, QueryBuilder queryBuilder, Introspector obj)
61             throws UnsupportedEncodingException, AAIException {
62         super(loader, queryBuilder);
63         this.relationship = obj;
64         this.modelType = obj.getModelType();
65         initBeans();
66         RelationshipToURI rToUri = new RelationshipToURI(loader, obj);
67         this.uri = rToUri.getUri();
68         URIParser parser = new URIParser(loader, uri);
69         parser.parse(this);
70     }
71
72     private void initBeans() {
73         ApplicationContext ctx = SpringContextAware.getApplicationContext();
74         if (ctx == null) {
75             logger.warn("Unable to retrieve the spring context");
76         } else {
77             EdgeIngestor ei = ctx.getBean(EdgeIngestor.class);
78             this.edgeRules = ei;
79         }
80     }
81
82 }