diff options
author | sunqi310 <sun.qi310@zte.com.cn> | 2016-11-04 10:18:16 +0800 |
---|---|---|
committer | sunqi310 <sun.qi310@zte.com.cn> | 2016-11-04 10:18:16 +0800 |
commit | 6b830fad5e84002d862658f7fd1cdaa3ad346da4 (patch) | |
tree | 56fc284d8fd7006b97adc646d5db480735d586fc | |
parent | f87bce9b9ef9a1dea51b6cb537804a8a316927c0 (diff) |
TOSCA-169 Fix issue
Change-Id: Idd06e0cbd0b7959356f3eb2d24ebd754ab40786e
Issue-id: TOSCA-169
Signed-off-by: sunqi310 <sun.qi310@zte.com.cn>
3 files changed, 12 insertions, 5 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/NodeTemplateData.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/NodeTemplateData.java index c6da6a72..0457e068 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/NodeTemplateData.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/entity/NodeTemplateData.java @@ -17,6 +17,8 @@ package org.openo.commontosca.catalog.db.entity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -25,14 +27,15 @@ import javax.persistence.Table; @Entity @Table(name = "catalog_node_template_table") @JsonIgnoreProperties(ignoreUnknown = true) -public class NodeTemplateData extends BaseData { +public class NodeTemplateData extends BaseData implements Serializable{ + private static final long serialVersionUID = -2512216362645538471L; @Id @Column(name = "NODETEMPLATEID") private String nodeTemplateId; @Column(name = "NAME") private String name; - + @Id @Column(name = "SERVICETEMPLATEID") private String serviceTemplateId; diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/wrapper/TemplateHandler.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/wrapper/TemplateHandler.java index 12b3987b..43b8ae64 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/wrapper/TemplateHandler.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/db/wrapper/TemplateHandler.java @@ -46,7 +46,11 @@ public class TemplateHandler extends BaseHandler<TemplateData> { templateData.getServiceTemplate().setServiceTemplateId(serviceTemplateOid); } for (NodeTemplateData nodeData : templateData.getNodeTemplates()) { - nodeData.setNodeTemplateId(CatalogDbUtil.generateId()); + String nodeTemplateOid = nodeData.getNodeTemplateId(); + if (!CatalogDbUtil.isNotEmpty(nodeTemplateOid)) { + logger.info("TemplateHandler:nodeTemplate info does not have id,generate UUID."); + nodeData.setNodeTemplateId(CatalogDbUtil.generateId()); + } nodeData.setServiceTemplateId(serviceTemplateOid); } Object result = create(templateData, CatalogResuorceType.TEMPLATE.name()); diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql b/catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql index ed081375..2efd5650 100644 --- a/catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql +++ b/catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql @@ -77,12 +77,12 @@ DROP TABLE IF EXISTS catalog_node_template_table; CREATE TABLE catalog_node_template_table (
NODETEMPLATEID VARCHAR(200) NOT NULL,
NAME VARCHAR(100) NULL,
- SERVICETEMPLATEID VARCHAR(200) NULL,
+ SERVICETEMPLATEID VARCHAR(200) NOT NULL,
TYPE VARCHAR(50) NULL,
PROPERTIES LONGTEXT NULL,
RELATIONSHIPS LONGTEXT NULL,
- CONSTRAINT catalog_node_template_table PRIMARY KEY(NODETEMPLATEID)
+ CONSTRAINT catalog_node_template_table PRIMARY KEY(NODETEMPLATEID,SERVICETEMPLATEID)
);
DROP TABLE IF EXISTS catalog_model_substitution_mapping_table;
CREATE TABLE catalog_model_substitution_mapping_table (
|