summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluxin <luxin7@huawei.com>2017-09-01 14:47:07 +0800
committerluxin <luxin7@huawei.com>2017-09-01 14:47:07 +0800
commit47d3c331a04ce44b756973217f85a4a04ea45be0 (patch)
treefef9655fc837cfcdb8525abe34757109f895de45
parent8f15590f99d86626665545cc8be77115ca6bb9ba (diff)
Add NS mysql table
Add NS mysql table and mybatis mapper file Change-Id: Ieea386e4898f2a20a5644dfcc8bea545bd98505c Issue-Id:VFC-216 Signed-off-by: luxin <luxin7@huawei.com>
-rw-r--r--ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql14
-rw-r--r--ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java139
-rw-r--r--ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java39
-rw-r--r--ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml143
4 files changed, 334 insertions, 1 deletions
diff --git a/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql b/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql
index af5e0a3..e53f856 100644
--- a/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql
+++ b/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql
@@ -1,5 +1,5 @@
#*******************************************************************************
-# Copyright 2016 Huawei Technologies Co., Ltd.
+# Copyright 2016-2017 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -174,6 +174,18 @@ CREATE TABLE vnfinfo (
VNFM_ID VARCHAR(256) NULL,
CONSTRAINT vnfinfo PRIMARY KEY (VNF_INSTANCE_ID)
);
+
+DROP TABLE IF EXISTS ns;
+CREATE TABLE ns (
+ ID VARCHAR(256) NOT NULL,
+ NAME VARCHAR(256) NULL,
+ NSD_ID VARCHAR(256) NULL,
+ DESCRIPTION VARCHAR(1024) NULL,
+ STATUS VARCHAR(256) NULL,
+ CTEATE_TIME VARCHAR(256) NULL,
+ LAST_UPDATE VARCHAR(256) NULL,
+ CONSTRAINT ns PRIMARY KEY (ID)
+);
DROP TABLE IF EXISTS vnfstatus;
CREATE TABLE vnfstatus (
diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java
new file mode 100644
index 0000000..a413134
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.resmanagement.service.entity;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version VFC 1.0 Sep 1, 2017
+ */
+public class NsEntity implements Serializable {
+
+ /** */
+ private String id;
+
+ /** */
+ private String name;
+
+ /** */
+ private String nsdId;
+
+ /** */
+ private String description;
+
+ /** */
+ private String status;
+
+ /** */
+ private String cteateTime;
+
+ /** */
+ private String lastUpdate;
+
+ private static final long serialVersionUID = 1L;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNsdId() {
+ return nsdId;
+ }
+
+ public void setNsdId(String nsdId) {
+ this.nsdId = nsdId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getCteateTime() {
+ return cteateTime;
+ }
+
+ public void setCteateTime(String cteateTime) {
+ this.cteateTime = cteateTime;
+ }
+
+ public String getLastUpdate() {
+ return lastUpdate;
+ }
+
+ public void setLastUpdate(String lastUpdate) {
+ this.lastUpdate = lastUpdate;
+ }
+
+ public static NsEntity toEntity(JSONObject jsonObject) {
+ NsEntity nsEntity = new NsEntity();
+ nsEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ nsEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ nsEntity.setNsdId(JsonUtil.getJsonFieldStr(jsonObject, "nsdId"));
+ nsEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description"));
+ nsEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ nsEntity.setCteateTime(JsonUtil.getJsonFieldStr(jsonObject, "cteateTime"));
+ nsEntity.setLastUpdate(JsonUtil.getJsonFieldStr(jsonObject, "lastUpdate"));
+ return nsEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject nsResJson = new JSONObject();
+ nsResJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ nsResJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ nsResJson.put("nsdId", StringUtils.trimToEmpty(this.getNsdId()));
+ nsResJson.put("description", StringUtils.trimToEmpty(this.getDescription()));
+ nsResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
+ nsResJson.put("cteateTime", StringUtils.trimToEmpty(this.getCteateTime()));
+ nsResJson.put("lastUpdate", StringUtils.trimToEmpty(this.getLastUpdate()));
+ return nsResJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java
new file mode 100644
index 0000000..69db361
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity;
+
+public interface NsEntityMapper {
+
+ int deleteByPrimaryKey(String id);
+
+ int insert(NsEntity record);
+
+ int insertSelective(NsEntity record);
+
+ NsEntity selectByPrimaryKey(String id);
+
+ List<NsEntity> getAllNs(Map<String, Object> condition);
+
+ int updateByPrimaryKeySelective(NsEntity record);
+
+ int updateByPrimaryKey(NsEntity record);
+}
diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml
new file mode 100644
index 0000000..a792694
--- /dev/null
+++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2017, Huawei Technologies Co., Ltd.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="org.onap.vfc.nfvo.resmanagement.service.mapper.NsEntityMapper" >
+ <resultMap id="BaseResultMap" type="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >
+ <id column="ID" property="id" jdbcType="VARCHAR" />
+ <result column="NAME" property="name" jdbcType="VARCHAR" />
+ <result column="NSD_ID" property="nsdId" jdbcType="VARCHAR" />
+ <result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
+ <result column="STATUS" property="status" jdbcType="VARCHAR" />
+ <result column="CTEATE_TIME" property="cteateTime" jdbcType="VARCHAR" />
+ <result column="LAST_UPDATE" property="lastUpdate" jdbcType="VARCHAR" />
+ </resultMap>
+
+ <sql id="Base_Column_List" >
+ ID, NAME, NSD_ID, DESCRIPTION, STATUS, CTEATE_TIME, LAST_UPDATE
+ </sql>
+ <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+ select
+ <include refid="Base_Column_List" />
+ from ns
+ where ID = #{id,jdbcType=VARCHAR}
+ </select>
+ <select id="getAllNs" resultMap="BaseResultMap" parameterType="java.util.Map">
+ select
+ <include refid="Base_Column_List" />
+ from vnf
+ <where>
+ <if test="id != null">
+ AND ID = #{id,jdbcType=VARCHAR}
+ </if>
+ </where>
+ </select>
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+ delete from ns
+ where ID = #{id,jdbcType=VARCHAR}
+ </delete>
+ <insert id="insert" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >
+ insert into ns (ID, NAME, NSD_ID,
+ DESCRIPTION, STATUS, CTEATE_TIME,
+ LAST_UPDATE)
+ values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{nsdId,jdbcType=VARCHAR},
+ #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{cteateTime,jdbcType=VARCHAR},
+ #{lastUpdate,jdbcType=VARCHAR})
+ </insert>
+ <insert id="insertSelective" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >
+ insert into ns
+ <trim prefix="(" suffix=")" suffixOverrides="," >
+ <if test="id != null" >
+ ID,
+ </if>
+ <if test="name != null" >
+ NAME,
+ </if>
+ <if test="nsdId != null" >
+ NSD_ID,
+ </if>
+ <if test="description != null" >
+ DESCRIPTION,
+ </if>
+ <if test="status != null" >
+ STATUS,
+ </if>
+ <if test="cteateTime != null" >
+ CTEATE_TIME,
+ </if>
+ <if test="lastUpdate != null" >
+ LAST_UPDATE,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides="," >
+ <if test="id != null" >
+ #{id,jdbcType=VARCHAR},
+ </if>
+ <if test="name != null" >
+ #{name,jdbcType=VARCHAR},
+ </if>
+ <if test="nsdId != null" >
+ #{nsdId,jdbcType=VARCHAR},
+ </if>
+ <if test="description != null" >
+ #{description,jdbcType=VARCHAR},
+ </if>
+ <if test="status != null" >
+ #{status,jdbcType=VARCHAR},
+ </if>
+ <if test="cteateTime != null" >
+ #{cteateTime,jdbcType=VARCHAR},
+ </if>
+ <if test="lastUpdate != null" >
+ #{lastUpdate,jdbcType=VARCHAR},
+ </if>
+ </trim>
+ </insert>
+ <update id="updateByPrimaryKeySelective" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >
+ update ns
+ <set >
+ <if test="name != null" >
+ NAME = #{name,jdbcType=VARCHAR},
+ </if>
+ <if test="nsdId != null" >
+ NSD_ID = #{nsdId,jdbcType=VARCHAR},
+ </if>
+ <if test="description != null" >
+ DESCRIPTION = #{description,jdbcType=VARCHAR},
+ </if>
+ <if test="status != null" >
+ STATUS = #{status,jdbcType=VARCHAR},
+ </if>
+ <if test="cteateTime != null" >
+ CTEATE_TIME = #{cteateTime,jdbcType=VARCHAR},
+ </if>
+ <if test="lastUpdate != null" >
+ LAST_UPDATE = #{lastUpdate,jdbcType=VARCHAR},
+ </if>
+ </set>
+ where ID = #{id,jdbcType=VARCHAR}
+ </update>
+ <update id="updateByPrimaryKey" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >
+ update ns
+ set NAME = #{name,jdbcType=VARCHAR},
+ NSD_ID = #{nsdId,jdbcType=VARCHAR},
+ DESCRIPTION = #{description,jdbcType=VARCHAR},
+ STATUS = #{status,jdbcType=VARCHAR},
+ CTEATE_TIME = #{cteateTime,jdbcType=VARCHAR},
+ LAST_UPDATE = #{lastUpdate,jdbcType=VARCHAR}
+ where ID = #{id,jdbcType=VARCHAR}
+ </update>
+</mapper> \ No newline at end of file