Add NS mysql table 79/9879/1
authorluxin <luxin7@huawei.com>
Fri, 1 Sep 2017 06:47:07 +0000 (14:47 +0800)
committerluxin <luxin7@huawei.com>
Fri, 1 Sep 2017 06:47:07 +0000 (14:47 +0800)
Add NS mysql table and mybatis mapper file

Change-Id: Ieea386e4898f2a20a5644dfcc8bea545bd98505c
Issue-Id:VFC-216
Signed-off-by: luxin <luxin7@huawei.com>
ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql
ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java [new file with mode: 0644]
ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java [new file with mode: 0644]
ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml [new file with mode: 0644]

index af5e0a3..e53f856 100644 (file)
@@ -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 (file)
index 0000000..a413134
--- /dev/null
@@ -0,0 +1,139 @@
+/*\r
+ * Copyright 2017 Huawei Technologies Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.vfc.nfvo.resmanagement.service.entity;\r
+\r
+import java.io.Serializable;\r
+\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil;\r
+\r
+import net.sf.json.JSONObject;\r
+\r
+/**\r
+ * <br>\r
+ * <p>\r
+ * </p>\r
+ * \r
+ * @author\r
+ * @version VFC 1.0 Sep 1, 2017\r
+ */\r
+public class NsEntity implements Serializable {\r
+\r
+    /**  */\r
+    private String id;\r
+\r
+    /**  */\r
+    private String name;\r
+\r
+    /**  */\r
+    private String nsdId;\r
+\r
+    /**  */\r
+    private String description;\r
+\r
+    /**  */\r
+    private String status;\r
+\r
+    /**  */\r
+    private String cteateTime;\r
+\r
+    /**  */\r
+    private String lastUpdate;\r
+\r
+    private static final long serialVersionUID = 1L;\r
+\r
+    public String getId() {\r
+        return id;\r
+    }\r
+\r
+    public void setId(String id) {\r
+        this.id = id;\r
+    }\r
+\r
+    public String getName() {\r
+        return name;\r
+    }\r
+\r
+    public void setName(String name) {\r
+        this.name = name;\r
+    }\r
+\r
+    public String getNsdId() {\r
+        return nsdId;\r
+    }\r
+\r
+    public void setNsdId(String nsdId) {\r
+        this.nsdId = nsdId;\r
+    }\r
+\r
+    public String getDescription() {\r
+        return description;\r
+    }\r
+\r
+    public void setDescription(String description) {\r
+        this.description = description;\r
+    }\r
+\r
+    public String getStatus() {\r
+        return status;\r
+    }\r
+\r
+    public void setStatus(String status) {\r
+        this.status = status;\r
+    }\r
+\r
+    public String getCteateTime() {\r
+        return cteateTime;\r
+    }\r
+\r
+    public void setCteateTime(String cteateTime) {\r
+        this.cteateTime = cteateTime;\r
+    }\r
+\r
+    public String getLastUpdate() {\r
+        return lastUpdate;\r
+    }\r
+\r
+    public void setLastUpdate(String lastUpdate) {\r
+        this.lastUpdate = lastUpdate;\r
+    }\r
+\r
+    public static NsEntity toEntity(JSONObject jsonObject) {\r
+        NsEntity nsEntity = new NsEntity();\r
+        nsEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));\r
+        nsEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));\r
+        nsEntity.setNsdId(JsonUtil.getJsonFieldStr(jsonObject, "nsdId"));\r
+        nsEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description"));\r
+        nsEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));\r
+        nsEntity.setCteateTime(JsonUtil.getJsonFieldStr(jsonObject, "cteateTime"));\r
+        nsEntity.setLastUpdate(JsonUtil.getJsonFieldStr(jsonObject, "lastUpdate"));\r
+        return nsEntity;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        JSONObject nsResJson = new JSONObject();\r
+        nsResJson.put("id", StringUtils.trimToEmpty(this.getId()));\r
+        nsResJson.put("name", StringUtils.trimToEmpty(this.getName()));\r
+        nsResJson.put("nsdId", StringUtils.trimToEmpty(this.getNsdId()));\r
+        nsResJson.put("description", StringUtils.trimToEmpty(this.getDescription()));\r
+        nsResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));\r
+        nsResJson.put("cteateTime", StringUtils.trimToEmpty(this.getCteateTime()));\r
+        nsResJson.put("lastUpdate", StringUtils.trimToEmpty(this.getLastUpdate()));\r
+        return nsResJson.toString();\r
+    }\r
+}\r
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 (file)
index 0000000..69db361
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * Copyright 2017 Huawei Technologies Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.vfc.nfvo.resmanagement.service.mapper;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity;\r
+\r
+public interface NsEntityMapper {\r
+\r
+    int deleteByPrimaryKey(String id);\r
+\r
+    int insert(NsEntity record);\r
+\r
+    int insertSelective(NsEntity record);\r
+\r
+    NsEntity selectByPrimaryKey(String id);\r
+\r
+    List<NsEntity> getAllNs(Map<String, Object> condition);\r
+\r
+    int updateByPrimaryKeySelective(NsEntity record);\r
+\r
+    int updateByPrimaryKey(NsEntity record);\r
+}\r
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 (file)
index 0000000..a792694
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<!--\r
+    Copyright 2017, Huawei Technologies Co., Ltd.\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+        http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+ -->\r
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >\r
+<mapper namespace="org.onap.vfc.nfvo.resmanagement.service.mapper.NsEntityMapper" >\r
+  <resultMap id="BaseResultMap" type="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >\r
+    <id column="ID" property="id" jdbcType="VARCHAR" />\r
+    <result column="NAME" property="name" jdbcType="VARCHAR" />\r
+    <result column="NSD_ID" property="nsdId" jdbcType="VARCHAR" />\r
+    <result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />\r
+    <result column="STATUS" property="status" jdbcType="VARCHAR" />\r
+    <result column="CTEATE_TIME" property="cteateTime" jdbcType="VARCHAR" />\r
+    <result column="LAST_UPDATE" property="lastUpdate" jdbcType="VARCHAR" />\r
+  </resultMap>\r
+  \r
+  <sql id="Base_Column_List" >\r
+    ID, NAME, NSD_ID, DESCRIPTION, STATUS, CTEATE_TIME, LAST_UPDATE\r
+  </sql>\r
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >\r
+    select \r
+    <include refid="Base_Column_List" />\r
+    from ns\r
+    where ID = #{id,jdbcType=VARCHAR}\r
+  </select>\r
+  <select id="getAllNs" resultMap="BaseResultMap" parameterType="java.util.Map">\r
+        select\r
+        <include refid="Base_Column_List" />\r
+        from vnf\r
+        <where>\r
+            <if test="id != null">\r
+                AND ID = #{id,jdbcType=VARCHAR}\r
+            </if>\r
+        </where>\r
+  </select>\r
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >\r
+    delete from ns\r
+    where ID = #{id,jdbcType=VARCHAR}\r
+  </delete>\r
+  <insert id="insert" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >\r
+    insert into ns (ID, NAME, NSD_ID, \r
+      DESCRIPTION, STATUS, CTEATE_TIME, \r
+      LAST_UPDATE)\r
+    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{nsdId,jdbcType=VARCHAR}, \r
+      #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{cteateTime,jdbcType=VARCHAR}, \r
+      #{lastUpdate,jdbcType=VARCHAR})\r
+  </insert>\r
+  <insert id="insertSelective" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >\r
+    insert into ns\r
+    <trim prefix="(" suffix=")" suffixOverrides="," >\r
+      <if test="id != null" >\r
+        ID,\r
+      </if>\r
+      <if test="name != null" >\r
+        NAME,\r
+      </if>\r
+      <if test="nsdId != null" >\r
+        NSD_ID,\r
+      </if>\r
+      <if test="description != null" >\r
+        DESCRIPTION,\r
+      </if>\r
+      <if test="status != null" >\r
+        STATUS,\r
+      </if>\r
+      <if test="cteateTime != null" >\r
+        CTEATE_TIME,\r
+      </if>\r
+      <if test="lastUpdate != null" >\r
+        LAST_UPDATE,\r
+      </if>\r
+    </trim>\r
+    <trim prefix="values (" suffix=")" suffixOverrides="," >\r
+      <if test="id != null" >\r
+        #{id,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="name != null" >\r
+        #{name,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="nsdId != null" >\r
+        #{nsdId,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="description != null" >\r
+        #{description,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="status != null" >\r
+        #{status,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="cteateTime != null" >\r
+        #{cteateTime,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="lastUpdate != null" >\r
+        #{lastUpdate,jdbcType=VARCHAR},\r
+      </if>\r
+    </trim>\r
+  </insert>\r
+  <update id="updateByPrimaryKeySelective" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >\r
+    update ns\r
+    <set >\r
+      <if test="name != null" >\r
+        NAME = #{name,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="nsdId != null" >\r
+        NSD_ID = #{nsdId,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="description != null" >\r
+        DESCRIPTION = #{description,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="status != null" >\r
+        STATUS = #{status,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="cteateTime != null" >\r
+        CTEATE_TIME = #{cteateTime,jdbcType=VARCHAR},\r
+      </if>\r
+      <if test="lastUpdate != null" >\r
+        LAST_UPDATE = #{lastUpdate,jdbcType=VARCHAR},\r
+      </if>\r
+    </set>\r
+    where ID = #{id,jdbcType=VARCHAR}\r
+  </update>\r
+  <update id="updateByPrimaryKey" parameterType="org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity" >\r
+    update ns\r
+    set NAME = #{name,jdbcType=VARCHAR},\r
+      NSD_ID = #{nsdId,jdbcType=VARCHAR},\r
+      DESCRIPTION = #{description,jdbcType=VARCHAR},\r
+      STATUS = #{status,jdbcType=VARCHAR},\r
+      CTEATE_TIME = #{cteateTime,jdbcType=VARCHAR},\r
+      LAST_UPDATE = #{lastUpdate,jdbcType=VARCHAR}\r
+    where ID = #{id,jdbcType=VARCHAR}\r
+  </update>\r
+</mapper>
\ No newline at end of file