c66428a68dada3a065b8127d9f88211f8ad944be
[clamp.git] / src / main / java / org / onap / clamp / clds / model / CldsAsdcResourceBasicInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); 
9  * you may not use this file except in compliance with the License. 
10  * You may obtain a copy of the License at
11  * 
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software 
15  * distributed under the License is distributed on an "AS IS" BASIS, 
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17  * See the License for the specific language governing permissions and 
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.model;
25
26 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
27
28 import java.math.BigDecimal;
29 import java.util.logging.Logger;
30
31 @JsonIgnoreProperties(ignoreUnknown = true)
32 public class CldsAsdcResourceBasicInfo implements Comparable<CldsAsdcResourceBasicInfo> {
33     private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName());
34
35     private String uuid;
36     private String invariantUUID;
37     private String name;
38     private String version;
39     private String toscaModelURL;
40     private String category;
41     private String subCategory;
42     private String resourceType;
43     private String lifecycleState;
44     private String lastUpdaterUserId;
45
46     @Override
47     public int compareTo(CldsAsdcResourceBasicInfo in) {
48         // Compares this object with the specified object for order.
49         // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
50         // first compare based on name
51         int rtn = name.compareToIgnoreCase(in.name);
52
53         if (rtn == 0) {
54             BigDecimal myVersion = convertVersion(version);
55             BigDecimal inVersion = convertVersion(in.version);
56             rtn = myVersion.compareTo(inVersion);
57         }
58         return rtn;
59     }
60
61     /**
62      * Convert version String into a BigDecimal
63      *
64      * @param version
65      * @return
66      */
67     private BigDecimal convertVersion(String version) {
68         BigDecimal rtn = new BigDecimal(0.0);
69         try {
70             rtn = new BigDecimal(version);
71         } catch (NumberFormatException nfe) {
72             logger.warning("ASDC version=" + version + " is not decimal for name=" + name);
73         }
74         return rtn;
75     }
76
77     public String getUuid() {
78         return uuid;
79     }
80
81     public void setUuid(String uuid) {
82         this.uuid = uuid;
83     }
84
85     public String getInvariantUUID() {
86         return invariantUUID;
87     }
88
89     public void setInvariantUUID(String invariantUUID) {
90         this.invariantUUID = invariantUUID;
91     }
92
93     public String getName() {
94         return name;
95     }
96
97     public void setName(String name) {
98         this.name = name;
99     }
100
101     public String getVersion() {
102         return version;
103     }
104
105     public void setVersion(String version) {
106         this.version = version;
107     }
108
109     public String getToscaModelURL() {
110         return toscaModelURL;
111     }
112
113     public void setToscaModelURL(String toscaModelURL) {
114         this.toscaModelURL = toscaModelURL;
115     }
116
117     public String getCategory() {
118         return category;
119     }
120
121     public void setCategory(String category) {
122         this.category = category;
123     }
124
125     public String getSubCategory() {
126         return subCategory;
127     }
128
129     public void setSubCategory(String subCategory) {
130         this.subCategory = subCategory;
131     }
132
133     public String getResourceType() {
134         return resourceType;
135     }
136
137     public void setResourceType(String resourceType) {
138         this.resourceType = resourceType;
139     }
140
141     public String getLifecycleState() {
142         return lifecycleState;
143     }
144
145     public void setLifecycleState(String lifecycleState) {
146         this.lifecycleState = lifecycleState;
147     }
148
149     public String getLastUpdaterUserId() {
150         return lastUpdaterUserId;
151     }
152
153     public void setLastUpdaterUserId(String lastUpdaterUserId) {
154         this.lastUpdaterUserId = lastUpdaterUserId;
155     }
156
157     public Logger getLOGGER() {
158         return logger;
159     }
160 }