From e1ae56c72fa016eddcb52f8046524c20f09cc1a6 Mon Sep 17 00:00:00 2001 From: sunqi310 Date: Thu, 27 Oct 2016 17:17:53 +0800 Subject: TOSCA-152 Add metadata and service Template original Id property for service Template table Change-Id: Ie7e443ecdbf8833e60eb87794208e437d63ffdf2 Issue-id: TOSCA-152 Signed-off-by: sunqi310 --- .../catalog/db/entity/ServiceTemplateData.java | 21 +++++++++++++++++++++ .../catalog/db/resource/TemplateManagerTest.java | 16 +++++++++++++++- .../catalog/db/util/H2DbServerUtil.java | 2 +- .../src/test/resources/db/catalog.mv.db | Bin 12288 -> 16384 bytes .../sql/catalog-resource-createObj-mysql.sql | 4 +++- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/ServiceTemplateData.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/ServiceTemplateData.java index ddaa5fce..7348b868 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/ServiceTemplateData.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/ServiceTemplateData.java @@ -56,6 +56,12 @@ public class ServiceTemplateData extends BaseData { @Column(name = "OPERATIONS") private String operations; + @Column(name = "METADATA") + private String metadata; + + @Column(name = "SERVICETEMPLATEORIGINALID") + private String serviceTemplateOriginalId; + public String getRowData() { return rowData; } @@ -136,4 +142,19 @@ public class ServiceTemplateData extends BaseData { return serviceTemplateId; } + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getServiceTemplateOriginalId() { + return serviceTemplateOriginalId; + } + + public void setServiceTemplateOriginalId(String serviceTemplateOriginalId) { + this.serviceTemplateOriginalId = serviceTemplateOriginalId; + } } diff --git a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/resource/TemplateManagerTest.java b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/resource/TemplateManagerTest.java index 93faff11..b977832f 100644 --- a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/resource/TemplateManagerTest.java +++ b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/resource/TemplateManagerTest.java @@ -75,6 +75,8 @@ public class TemplateManagerTest { serviceData.setOperations("SDFSDFDSERWERWE"); serviceData.setVendor("ZTE"); serviceData.setVersion("v1.0"); + serviceData.setMetadata("metadata"); + serviceData.setServiceTemplateOriginalId("NS_01"); NodeTemplateData nodeData = new NodeTemplateData(); nodeData.setName("node"); nodeData.setNodeTemplateId("30001"); @@ -112,6 +114,8 @@ public class TemplateManagerTest { serviceData.setServiceTemplateId("20001"); serviceData.setVendor("ZTE"); serviceData.setVersion("v1.0"); + serviceData.setMetadata("metadata"); + serviceData.setServiceTemplateOriginalId("NS_01"); NodeTemplateData nodeData = new NodeTemplateData(); nodeData.setName("node"); nodeData.setServiceTemplateId("20001"); @@ -136,7 +140,17 @@ public class TemplateManagerTest { } Assert.assertTrue(list.size() > 0); } - + @Test + public void testQueryServiceTemplateByIdAndMetadataIsNotNull() { + ArrayList list = new ArrayList(); + try { + list = manager.queryServiceTemplateById("20001"); + } catch (CatalogResourceException e1) { + Assert.fail("Exception" + e1.getMessage()); + } + Assert + .assertTrue(list.size() > 0 && "NS_01".equals(list.get(0).getServiceTemplateOriginalId())); + } @Test public void testQueryServiceTemplate() { diff --git a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/util/H2DbServerUtil.java b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/util/H2DbServerUtil.java index d609182c..327de491 100644 --- a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/util/H2DbServerUtil.java +++ b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/db/util/H2DbServerUtil.java @@ -56,7 +56,7 @@ public class H2DbServerUtil { /** * test. */ - public static void main() { + public static void main(String args[]) { H2DbServer.startUp(); H2DbServerUtil.initTable(); H2DbServer.shutDown(); diff --git a/catalog-core/catalog-mgr/src/test/resources/db/catalog.mv.db b/catalog-core/catalog-mgr/src/test/resources/db/catalog.mv.db index b1d596f4..02d0712e 100644 Binary files a/catalog-core/catalog-mgr/src/test/resources/db/catalog.mv.db and b/catalog-core/catalog-mgr/src/test/resources/db/catalog.mv.db differ diff --git a/catalog-core/catalog-mgr/src/test/resources/sql/catalog-resource-createObj-mysql.sql b/catalog-core/catalog-mgr/src/test/resources/sql/catalog-resource-createObj-mysql.sql index b2d5edf8..209c2598 100644 --- a/catalog-core/catalog-mgr/src/test/resources/sql/catalog-resource-createObj-mysql.sql +++ b/catalog-core/catalog-mgr/src/test/resources/sql/catalog-resource-createObj-mysql.sql @@ -46,7 +46,9 @@ CREATE TABLE catalog_service_template_table ( INPUTS LONGTEXT NULL, ROWDATA LONGTEXT NULL, OPERATIONS LONGTEXT NULL, - DOWNLOADURI VARCHAR(200) NULL, + DOWNLOADURI VARCHAR(200) NULL, + SERVICETEMPLATEORIGINALID VARCHAR(100) NULL, + METADATA LONGTEXT NULL, CONSTRAINT CATALOG_SERVICE_TEMPLATE_TABLE_OID PRIMARY KEY(SERVICETEMPLATEID) ); -- cgit 1.2.3-korg