ee1736feebb3292bff5fe14517ff8c078f18955a
[so.git] / common / src / main / java / org / onap / so / client / aai / AAIResourcesClient.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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.so.client.aai;
22
23 import java.util.Optional;
24
25 import org.onap.aai.domain.yang.Relationship;
26 import org.onap.so.client.aai.entities.AAIEdgeLabel;
27 import org.onap.so.client.aai.entities.AAIResultWrapper;
28 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
29 import org.onap.so.client.graphinventory.GraphInventoryResourcesClient;
30 import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel;
31 import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri;
32
33 public class AAIResourcesClient extends GraphInventoryResourcesClient<AAIResourcesClient, AAIResourceUri, AAIEdgeLabel, AAIResultWrapper, AAITransactionalClient, AAISingleTransactionClient> {
34         
35         private AAIClient aaiClient;
36         
37         public AAIResourcesClient() {
38                 super(new AAIClient());
39                 aaiClient = (AAIClient) super.client;
40         }
41         
42         public AAIResourcesClient(AAIVersion version) {
43                 super(new AAIClient(version));
44                 aaiClient = (AAIClient) super.client;
45         }
46
47         @Override
48         public AAIResultWrapper createWrapper(String json) {
49                 return new AAIResultWrapper(json);
50         }
51
52         @Override
53         public AAITransactionalClient beginTransaction() {
54                 return new AAITransactionalClient(this, aaiClient);
55         }
56
57         @Override
58         public AAISingleTransactionClient beginSingleTransaction() {
59                 return new AAISingleTransactionClient(this, aaiClient);
60         }
61         
62         @Override
63         protected Relationship buildRelationship(GraphInventoryResourceUri uri) {
64                 return super.buildRelationship(uri, Optional.empty());
65         }
66         
67         @Override
68         protected Relationship buildRelationship(GraphInventoryResourceUri uri, GraphInventoryEdgeLabel label) {
69                 return super.buildRelationship(uri, Optional.of(label));
70         }
71         
72         @Override
73         protected Relationship buildRelationship(GraphInventoryResourceUri uri, Optional<GraphInventoryEdgeLabel> label) {
74                 return super.buildRelationship(uri, label);
75         }
76         
77 }