2 * Copyright 2016 [ZTE] and others.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openo.commontosca.catalog.model.externalservice.entity.containerEntity;
18 import java.util.ArrayList;
19 import java.util.List;
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlAttribute;
24 import javax.xml.bind.annotation.XmlElement;
25 import javax.xml.bind.annotation.XmlElementWrapper;
26 import javax.xml.bind.annotation.XmlRootElement;
28 import org.openo.commontosca.catalog.common.ToolUtil;
32 @XmlAccessorType(XmlAccessType.NONE)
33 public class ContainerServiceNodeTemplate {
35 @XmlAttribute(name = "nodetemplateid")
38 @XmlAttribute(name = "nodetemplatename")
44 @XmlElementWrapper(name = "properties")
45 @XmlElement(name = "property")
46 private List<ContainerServiceCommonParam> properties;
48 @XmlElementWrapper(name = "relationshipInfos")
49 @XmlElement(name = "relationship")
50 private List<ContainerServiceRelationShip> relationShips;
52 @XmlElement(name = "Capabilities")
53 private ContainerServiceNodeTemplate.Capablitiies capabilities;
55 public ContainerServiceNodeTemplate.Capablitiies getCapabilities() {
59 public void setCapabilities(
60 ContainerServiceNodeTemplate.Capablitiies capabilities) {
61 this.capabilities = capabilities;
64 public String getId() {
68 public void setId(String id) {
72 public String getName() {
76 public void setName(String name) {
80 public String getType() {
84 public void setType(String type) {
88 public List<ContainerServiceCommonParam> getProperties() {
92 public void setProperties(List<ContainerServiceCommonParam> properties) {
93 this.properties = properties;
96 public List<ContainerServiceRelationShip> getRelationShips() {
100 public void setRelationShips(
101 List<ContainerServiceRelationShip> relationShips) {
102 this.relationShips = relationShips;
106 @XmlAccessorType(XmlAccessType.NONE)
107 public static class Capablitiies {
108 @XmlElement(name = "Capability")
109 private List<ContainerServiceNodeTemplate.Capability> capabilityList;
111 public List<ContainerServiceNodeTemplate.Capability> getCapabilityList() {
112 return capabilityList;
115 public void setCapabilityList(
116 List<ContainerServiceNodeTemplate.Capability> capabilityList) {
117 this.capabilityList = capabilityList;
122 @XmlAccessorType(XmlAccessType.NONE)
123 public static class Capability {
124 @XmlAttribute(name = "id")
125 private String flavorName;
127 @XmlElement(name = "Properties")
128 private ContainerServiceNodeTemplate.CapabilityProperties properties;
130 public String getFlavorName() {
134 public void setFlavorName(String flavorName) {
135 this.flavorName = flavorName;
138 public ContainerServiceNodeTemplate.CapabilityProperties getProperties() {
142 public void setProperties(
143 ContainerServiceNodeTemplate.CapabilityProperties properties) {
144 this.properties = properties;
150 @XmlAccessorType(XmlAccessType.NONE)
151 public static class CapabilityProperties {
152 @XmlElement(name = "Properties")
153 private ContainerServiceNodeTemplate.CapabilityProperty property;
155 public ContainerServiceNodeTemplate.CapabilityProperty getProperty() {
159 public void setProperty(
160 ContainerServiceNodeTemplate.CapabilityProperty property) {
161 this.property = property;
166 @XmlAccessorType(XmlAccessType.FIELD)
167 public static class CapabilityProperty {
175 private String rootDisk;
178 private String swapDisk;
181 private String tempDisk;
183 public String getvCPU() {
187 public void setvCPU(String vCPU) {
191 public String getvRAM() {
195 public void setvRAM(String vRAM) {
199 public String getRootDisk() {
203 public void setRootDisk(String rootDisk) {
204 this.rootDisk = rootDisk;
207 public String getSwapDisk() {
211 public void setSwapDisk(String swapDisk) {
212 this.swapDisk = swapDisk;
215 public String getTempDisk() {
219 public void setTempDisk(String tempDisk) {
220 this.tempDisk = tempDisk;
224 public class NTFlavor {
225 private String flavorName;
231 private String rootDisk;
233 private String swapDisk;
235 private String tempDisk;
237 public String getFlavorName() {
241 public void setFlavorName(String flavorName) {
242 this.flavorName = flavorName;
245 public String getvCPU() {
249 public void setvCPU(String vCPU) {
253 public String getvRAM() {
257 public void setvRAM(String vRAM) {
261 public String getRootDisk() {
265 public void setRootDisk(String rootDisk) {
266 this.rootDisk = rootDisk;
269 public String getSwapDisk() {
273 public void setSwapDisk(String swapDisk) {
274 this.swapDisk = swapDisk;
277 public String getTempDisk() {
281 public void setTempDisk(String tempDisk) {
282 this.tempDisk = tempDisk;
287 public List<NTFlavor> getNTFlavorList() {
288 if (null == this.capabilities
289 || ToolUtil.isEmptyCollection(capabilities.getCapabilityList())) {
293 List<NTFlavor> ntFlavors = new ArrayList<NTFlavor>();
294 List<Capability> capabilityList = capabilities.getCapabilityList();
295 for (Capability capabilty : capabilityList) {
296 NTFlavor ntFlavor = convertCap2Flavor(capabilty);
297 ntFlavors.add(ntFlavor);
303 private NTFlavor convertCap2Flavor(Capability capabilty) {
304 NTFlavor ntFlavor = new NTFlavor();
305 ntFlavor.setFlavorName(capabilty.getFlavorName());
306 if (null != capabilty.getProperties()
307 && null != capabilty.getProperties().getProperty()) {
308 CapabilityProperty property = capabilty.getProperties()
310 ntFlavor.setRootDisk(property.getRootDisk());
311 ntFlavor.setSwapDisk(property.getSwapDisk());
312 ntFlavor.setTempDisk(property.getTempDisk());
313 ntFlavor.setvCPU(property.getvCPU());
314 ntFlavor.setvRAM(property.getvRAM());