PNF ingestion in SO catalogdb
[so.git] / asdc-controller / src / main / java / org / onap / so / asdc / client / test / emulators / ResourceInfoImpl.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.asdc.client.test.emulators;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.apache.commons.lang3.builder.EqualsBuilder;
27 import org.apache.commons.lang3.builder.HashCodeBuilder;
28 import org.onap.sdc.api.notification.IArtifactInfo;
29 import org.onap.sdc.api.notification.IResourceInstance;
30
31 import com.fasterxml.jackson.annotation.JsonIgnore;
32
33 public class ResourceInfoImpl implements IResourceInstance{
34         public ResourceInfoImpl (){}
35         private String resourceInstanceName;
36         private String resourceCustomizationUUID;
37         private String resourceName;
38         private String resourceVersion;
39         private String resourceType;
40         private String resourceUUID;
41         private String resourceInvariantUUID;
42         private String category;
43         private String subcategory;
44         private List<ArtifactInfoImpl> artifacts;
45         
46         private ResourceInfoImpl(IResourceInstance resourceInstance){
47                 resourceInstanceName = resourceInstance.getResourceInstanceName();
48                 resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
49                 resourceName = resourceInstance.getResourceName();
50                 resourceVersion = resourceInstance.getResourceVersion();
51                 resourceType = resourceInstance.getResourceType();
52                 resourceUUID = resourceInstance.getResourceUUID();
53                 resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
54                 category = resourceInstance.getCategory();
55                 subcategory = resourceInstance.getSubcategory();
56                 artifacts = ArtifactInfoImpl.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
57         }
58         
59         public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources){
60                  List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
61                  if( resources != null ){
62                          for( IResourceInstance resourceInstance : resources ){
63                                  buildResources.add(new ResourceInfoImpl(resourceInstance));
64                          }
65                  }
66                  return buildResources;
67         }
68         
69         @Override
70         public String getResourceInstanceName() {
71                 return resourceInstanceName;
72         }
73
74         public void setResourceInstanceName(String resourceInstanceName) {
75                 this.resourceInstanceName = resourceInstanceName;
76         }
77         
78         @Override
79         public String getResourceName() {
80                 return resourceName;
81         }
82
83         public void setResourceName(String resourceName) {
84                 this.resourceName = resourceName;
85         }
86
87         @Override
88         public String getResourceVersion() {
89                 return resourceVersion;
90         }
91
92         public void setResourceVersion(String resourceVersion) {
93                 this.resourceVersion = resourceVersion;
94         }
95
96         @Override
97         public String getResourceType() {
98                 return resourceType;
99         }
100
101         public void setResoucreType(String resourceType) {
102                 this.resourceType = resourceType;
103         }
104
105         @Override
106         public String getResourceUUID() {
107                 return resourceUUID;
108         }
109
110         public void setResourceUUID(String resourceUUID) {
111                 this.resourceUUID = resourceUUID;
112         }
113
114         @Override
115         public List<IArtifactInfo> getArtifacts() {
116                 List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
117                 if( artifacts != null ){
118                         temp.addAll(artifacts);
119                 }
120                 return temp;
121         }
122
123         public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
124                 this.artifacts = artifacts;
125         }
126         
127         @JsonIgnore
128         public List<ArtifactInfoImpl> getArtifactsImpl() {
129                 return artifacts;
130         }
131         
132         @Override
133         public String getResourceInvariantUUID() {
134                 return resourceInvariantUUID;
135         }
136         
137         public void setResourceInvariantUUID(String resourceInvariantUUID) {
138                 this.resourceInvariantUUID = resourceInvariantUUID;
139         }
140         public String getResourceCustomizationUUID() {
141                 return resourceCustomizationUUID;
142         }
143
144         public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
145                 this.resourceCustomizationUUID = resourceCustomizationUUID;
146         }
147
148         public String getCategory() {
149                 return category;
150         }
151
152         public void setCategory(String category) {
153                 this.category = category;
154         }
155
156         public String getSubcategory() {
157                 return subcategory;
158         }
159
160         public void setSubcategory(String subcategory) {
161                 this.subcategory = subcategory;
162         }
163
164         @Override
165         public boolean equals(final Object other) {
166                 if (!(other instanceof ResourceInfoImpl)) {
167                         return false;
168                 }
169                 ResourceInfoImpl castOther = (ResourceInfoImpl) other;
170                 return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
171                                 .append(resourceVersion, castOther.resourceVersion).isEquals();
172         }
173
174         @Override
175         public int hashCode() {
176                 return new HashCodeBuilder().append(resourceInstanceName).append(resourceCustomizationUUID).append(resourceName)
177                                 .append(resourceVersion).append(resourceType).append(resourceUUID).append(resourceInvariantUUID)
178                                 .append(category).append(subcategory).append(artifacts).toHashCode();
179         }
180 }