2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.openecomp.sdnc.uebclient;
24 import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
25 import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
26 import org.openecomp.sdc.toscaparser.api.Metadata;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public class SdncServiceModel extends SdncBaseModel {
32 private static final Logger LOG = LoggerFactory
33 .getLogger(SdncServiceModel.class);
35 private String UUID = null;
36 private String serviceInstanceNamePrefix = null;
37 private String filename = null;
39 public SdncServiceModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata) {
41 super(sdcCsarHelper, metadata);
43 UUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_UUID);
45 // extract service topology template input data
46 addParameter("ecomp_naming",extractBooleanInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING));
47 addParameter("naming_policy",extractInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_NAMINGPOLICY));
50 public String getServiceUUID() {
51 return ("\"" + UUID + "\"");
53 public void setServiceUUID(String serviceUUID) {
54 this.UUID = serviceUUID;
56 public String getServiceInstanceNamePrefix() {
57 return serviceInstanceNamePrefix;
59 public void setServiceInstanceNamePrefix(String serviceInstanceNamePrefix) {
60 if (serviceInstanceNamePrefix != null && !serviceInstanceNamePrefix.isEmpty()) {
61 this.serviceInstanceNamePrefix = serviceInstanceNamePrefix;
62 params.put("service_instance_name_prefix", "\"" + serviceInstanceNamePrefix + "\"");
65 public String getFilename() {
68 public void setFilename(String filename) {
69 this.filename = filename;
72 public String getSql(String model_yaml) {
74 StringBuilder sb = new StringBuilder();
75 sb.append("INSERT into SERVICE_MODEL (service_uuid, model_yaml, filename, ");
78 for (String paramKey : params.keySet()) {
81 if (paramCount < params.size()) sb.append(", ");
84 sb.append(") values (" + getServiceUUID() + ", \"" + model_yaml + "\", \"" + filename + "\", ");
87 for (String paramKey : params.keySet()) {
89 String paramValue = params.get(paramKey);
90 sb.append(paramValue);
91 if (paramCount < params.size()) sb.append(", ");