AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / java / org / openecomp / mso / bpmn / infrastructure / aai / AAICreateResources.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.openecomp.mso.bpmn.infrastructure.aai;
22
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.Optional;
26
27 import org.openecomp.mso.client.aai.AAIObjectType;
28 import org.openecomp.mso.client.aai.AAIResourcesClient;
29 import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
30 import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
31
32 public class AAICreateResources {
33
34
35         public void createAAIProject (String projectName, String serviceInstance){
36                 AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName);
37                 AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance);
38                 AAIResourcesClient aaiRC = new AAIResourcesClient();      
39                 aaiRC.createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI);
40                 
41         }
42         
43         public void createAAIOwningEntity(String owningEntityId, String owningEntityName,String serviceInstance){
44                 AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId);
45                 AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance);
46                 Map<String, String> hashMap= new HashMap<>();
47                 hashMap.put("owning-entity-name", owningEntityName);    
48                 AAIResourcesClient aaiRC = new AAIResourcesClient();
49                 aaiRC.createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, serviceInstanceURI);
50         }
51
52         public boolean existsOwningEntity(String owningEntityId){
53                 AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId);
54                 AAIResourcesClient aaiRC = new AAIResourcesClient();      
55                 return aaiRC.exists(owningEntityURI);
56         }
57         
58         public void connectOwningEntityandServiceInstance (String owningEntityId, String serviceInstance){
59                 AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId);
60                 AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance);
61                 AAIResourcesClient aaiRC = new AAIResourcesClient();
62                 aaiRC.connect(owningEntityURI, serviceInstanceURI);
63         }
64         
65         public void createAAIPlatform(String platformName,String vnfId){
66                 AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName);
67                 AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId);
68                 AAIResourcesClient aaiRC = new AAIResourcesClient();                              
69                 aaiRC.createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI);
70         }
71         
72         public void createAAILineOfBusiness(String lineOfBusiness,String vnfId){
73                 AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness);
74                 AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF,vnfId);
75                 AAIResourcesClient aaiRC = new AAIResourcesClient();                              
76                 aaiRC.createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI);
77         }
78         public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId){
79                 AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId,serviceType,serviceInstanceId);
80                 AAIResourcesClient aaiRC = new AAIResourcesClient();      
81                 aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty());
82         }
83         
84 }