summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-02-22 08:16:26 +0100
committersebdet <sebastien.determe@intl.att.com>2019-02-28 17:44:38 +0100
commitc2bcf2a333a66d401c6afe0589c117f0986a5bd2 (patch)
tree83ff67bcc644101de8f2af366b6d0cc39360cc92 /src/main
parentf08a27fede1086e17632dde816e0ae6214cab286 (diff)
Introduce new entities
Introduce new database entities to support the new Clamp model Change-Id: I6c8d7fdaf8201c2bc7878f8a807c89002525857f Issue-ID: CLAMP-299 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java22
-rw-r--r--src/main/java/org/onap/clamp/dao/LoopLogRepository.java33
-rw-r--r--src/main/java/org/onap/clamp/dao/LoopsRepository.java33
-rw-r--r--src/main/java/org/onap/clamp/dao/MicroServicePolicyRepository.java33
-rw-r--r--src/main/java/org/onap/clamp/dao/OperationalPolicyRepository.java33
-rw-r--r--src/main/java/org/onap/clamp/dao/model/LogType.java28
-rw-r--r--src/main/java/org/onap/clamp/dao/model/Loop.java199
-rw-r--r--src/main/java/org/onap/clamp/dao/model/LoopLog.java113
-rw-r--r--src/main/java/org/onap/clamp/dao/model/LoopState.java28
-rw-r--r--src/main/java/org/onap/clamp/dao/model/MicroServicePolicy.java126
-rw-r--r--src/main/java/org/onap/clamp/dao/model/OperationalPolicy.java90
-rw-r--r--src/main/resources/application-noaaf.properties18
-rw-r--r--src/main/resources/application.properties14
13 files changed, 758 insertions, 12 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java
index 749a2f6f..920b0f28 100644
--- a/src/main/java/org/onap/clamp/clds/Application.java
+++ b/src/main/java/org/onap/clamp/clds/Application.java
@@ -37,9 +37,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
@@ -50,18 +49,18 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
-
+import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
-@ComponentScan(basePackages = {
- "org.onap.clamp.clds"
-})
-@EnableAutoConfiguration(exclude = {
- DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class,
- SecurityAutoConfiguration.class,UserDetailsServiceAutoConfiguration .class
-})
+@ComponentScan(basePackages = { "org.onap.clamp" })
+@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
+ UserDetailsServiceAutoConfiguration.class })
+@EnableJpaRepositories(basePackages = { "org.onap.clamp" })
+@EntityScan(basePackages = { "org.onap.clamp" })
+@EnableTransactionManagement
@EnableConfigurationProperties
@EnableAsync
@EnableScheduling
@@ -106,7 +105,8 @@ public class Application extends SpringBootServletInitializer {
*/
@Bean
public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
- eelfLogger.info(ResourceFileUtil.getResourceAsString("boot-message.txt")+"(v"+ ClampVersioning.getCldsVersionFromProps()+")"+System.getProperty("line.separator"));
+ eelfLogger.info(ResourceFileUtil.getResourceAsString("boot-message.txt") + "(v"
+ + ClampVersioning.getCldsVersionFromProps() + ")" + System.getProperty("line.separator"));
ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(),
"/restservices/clds/v1/*");
registration.setName("CamelServlet");
diff --git a/src/main/java/org/onap/clamp/dao/LoopLogRepository.java b/src/main/java/org/onap/clamp/dao/LoopLogRepository.java
new file mode 100644
index 00000000..5f983b2a
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/LoopLogRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao;
+
+import org.onap.clamp.dao.model.LoopLog;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface LoopLogRepository extends CrudRepository<LoopLog, String> {
+
+}
diff --git a/src/main/java/org/onap/clamp/dao/LoopsRepository.java b/src/main/java/org/onap/clamp/dao/LoopsRepository.java
new file mode 100644
index 00000000..51019baa
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/LoopsRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao;
+
+import org.onap.clamp.dao.model.Loop;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface LoopsRepository extends CrudRepository<Loop, String> {
+
+}
diff --git a/src/main/java/org/onap/clamp/dao/MicroServicePolicyRepository.java b/src/main/java/org/onap/clamp/dao/MicroServicePolicyRepository.java
new file mode 100644
index 00000000..1bdaf3e5
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/MicroServicePolicyRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao;
+
+import org.onap.clamp.dao.model.MicroServicePolicy;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MicroServicePolicyRepository extends CrudRepository<MicroServicePolicy, String> {
+
+}
diff --git a/src/main/java/org/onap/clamp/dao/OperationalPolicyRepository.java b/src/main/java/org/onap/clamp/dao/OperationalPolicyRepository.java
new file mode 100644
index 00000000..cf03a812
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/OperationalPolicyRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao;
+
+import org.onap.clamp.dao.model.OperationalPolicy;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface OperationalPolicyRepository extends CrudRepository<OperationalPolicy, String> {
+
+}
diff --git a/src/main/java/org/onap/clamp/dao/model/LogType.java b/src/main/java/org/onap/clamp/dao/model/LogType.java
new file mode 100644
index 00000000..1a8ed36c
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/model/LogType.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao.model;
+
+public enum LogType {
+ INFO, WARNING, ERROR;
+}
diff --git a/src/main/java/org/onap/clamp/dao/model/Loop.java b/src/main/java/org/onap/clamp/dao/model/Loop.java
new file mode 100644
index 00000000..3473b54f
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/model/Loop.java
@@ -0,0 +1,199 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao.model;
+
+import com.google.gson.annotations.Expose;
+import com.vladmihalcea.hibernate.type.json.JsonStringType;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+
+@Entity
+@Table(name = "loops")
+//@JsonAdapter(JsonLoopAdapter.class)
+@TypeDef(name = "json", typeClass = JsonStringType.class)
+public class Loop implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -286522707701388642L;
+
+ @Id
+ @Expose
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ @Expose
+ @Column(name = "dcae_deployment_id")
+ private String dcaeDeploymentId;
+
+ @Expose
+ @Column(name = "dcae_deployment_status_url")
+ private String dcaeDeploymentStatusUrl;
+
+ @Expose
+ @Column(name = "svg_representation")
+ private String svgRepresentation;
+
+ @Expose
+ @Type(type = "json")
+ @Column(columnDefinition = "json", name = "global_properties_json")
+ private Map<String, Object> globalPropertiesJson;
+
+ @Expose
+ @Column(nullable = false, name = "blueprint_yaml")
+ private String blueprint;
+
+ @Expose
+ @Column(nullable = false, name = "last_computed_state")
+ @Enumerated(EnumType.STRING)
+ private LoopState lastComputedState;
+
+ @Expose
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
+ private Set<OperationalPolicy> operationalPolicies = new HashSet<>();
+
+ @Expose
+ @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
+ private Set<MicroServicePolicy> microServicePolicies = new HashSet<>();
+
+ @Expose
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
+ private Set<LoopLog> loopLogs = new HashSet<>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDcaeDeploymentId() {
+ return dcaeDeploymentId;
+ }
+
+ public void setDcaeDeploymentId(String dcaeDeploymentId) {
+ this.dcaeDeploymentId = dcaeDeploymentId;
+ }
+
+ public String getDcaeDeploymentStatusUrl() {
+ return dcaeDeploymentStatusUrl;
+ }
+
+ public void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) {
+ this.dcaeDeploymentStatusUrl = dcaeDeploymentStatusUrl;
+ }
+
+ public String getSvgRepresentation() {
+ return svgRepresentation;
+ }
+
+ public void setSvgRepresentation(String svgRepresentation) {
+ this.svgRepresentation = svgRepresentation;
+ }
+
+ public String getBlueprint() {
+ return blueprint;
+ }
+
+ public void setBlueprint(String blueprint) {
+ this.blueprint = blueprint;
+ }
+
+ public LoopState getLastComputedState() {
+ return lastComputedState;
+ }
+
+ public void setLastComputedState(LoopState lastComputedState) {
+ this.lastComputedState = lastComputedState;
+ }
+
+ public Set<OperationalPolicy> getOperationalPolicies() {
+ return operationalPolicies;
+ }
+
+ public void setOperationalPolicies(Set<OperationalPolicy> operationalPolicies) {
+ this.operationalPolicies = operationalPolicies;
+ }
+
+ public Set<MicroServicePolicy> getMicroServicePolicies() {
+ return microServicePolicies;
+ }
+
+ public void setMicroServicePolicies(Set<MicroServicePolicy> microServicePolicies) {
+ this.microServicePolicies = microServicePolicies;
+ }
+
+ public Map<String, Object> getGlobalPropertiesJson() {
+ return globalPropertiesJson;
+ }
+
+ public void setGlobalPropertiesJson(Map<String, Object> globalPropertiesJson) {
+ this.globalPropertiesJson = globalPropertiesJson;
+ }
+
+ public Set<LoopLog> getLoopLogs() {
+ return loopLogs;
+ }
+
+ public void setLoopLogs(Set<LoopLog> loopLogs) {
+ this.loopLogs = loopLogs;
+ }
+
+ public void addOperationalPolicy(OperationalPolicy opPolicy) {
+ opPolicy.setLoop(this);
+ operationalPolicies.add(opPolicy);
+ }
+
+ public void addMicroServicePolicy(MicroServicePolicy microServicePolicy) {
+ microServicePolicies.add(microServicePolicy);
+ microServicePolicy.getUsedByLoops().add(this);
+ }
+
+ public void addLog(LoopLog log) {
+ loopLogs.add(log);
+ log.setLoop(this);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/dao/model/LoopLog.java b/src/main/java/org/onap/clamp/dao/model/LoopLog.java
new file mode 100644
index 00000000..8f7fd68b
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/model/LoopLog.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao.model;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "loop_logs")
+public class LoopLog implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1988276670074437631L;
+
+ @Expose
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ @Expose
+ @Column(name = "log_type", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private LogType logType;
+
+ @Expose
+ @Column(name = "message", nullable = false)
+ private String message;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "loop_id", nullable = false)
+ private Loop loop;
+
+ @Expose
+ @Column(name = "log_instant", nullable = false)
+ private Instant logInstant = Instant.now();
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public LogType getLogType() {
+ return logType;
+ }
+
+ public void setLogType(LogType logType) {
+ this.logType = logType;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Loop getLoop() {
+ return loop;
+ }
+
+ public void setLoop(Loop loop) {
+ this.loop = loop;
+ }
+
+ public Instant getLogInstant() {
+ return logInstant;
+ }
+
+ public void setLogInstant(Instant logInstant) {
+ this.logInstant = logInstant;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/dao/model/LoopState.java b/src/main/java/org/onap/clamp/dao/model/LoopState.java
new file mode 100644
index 00000000..1cde0aa9
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/model/LoopState.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao.model;
+
+public enum LoopState {
+ DESIGN, SUBMITTED, DEPLOYED, RUNNING, STOPPED, IN_ERROR, WAITING;
+}
diff --git a/src/main/java/org/onap/clamp/dao/model/MicroServicePolicy.java b/src/main/java/org/onap/clamp/dao/model/MicroServicePolicy.java
new file mode 100644
index 00000000..7fa4a55d
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/model/MicroServicePolicy.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao.model;
+
+import com.google.gson.annotations.Expose;
+import com.vladmihalcea.hibernate.type.json.JsonStringType;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+
+@Entity
+@Table(name = "micro_service_policies")
+@TypeDef(name = "json", typeClass = JsonStringType.class)
+public class MicroServicePolicy implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6271238288583332616L;
+
+ @Expose
+ @Id
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ @Expose
+ @Type(type = "json")
+ @Column(columnDefinition = "json", name = "properties")
+ private Map<String, Object> properties;
+
+ @Expose
+ @Column(name = "shared", nullable = false)
+ private Boolean shared;
+
+ @Expose
+ @Column(name = "policy_tosca", nullable = false)
+ private String policyTosca;
+
+ @Expose
+ @Type(type = "json")
+ @Column(columnDefinition = "json", name = "json_representation", nullable = false)
+ private Map<String, Object> jsonRepresentation;
+
+ @ManyToMany(mappedBy = "microServicePolicies")
+ private Set<Loop> usedByLoops = new HashSet<>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ public Boolean getShared() {
+ return shared;
+ }
+
+ public void setShared(Boolean shared) {
+ this.shared = shared;
+ }
+
+ public String getPolicyTosca() {
+ return policyTosca;
+ }
+
+ public void setPolicyTosca(String policyTosca) {
+ this.policyTosca = policyTosca;
+ }
+
+ public Map<String, Object> getJsonRepresentation() {
+ return jsonRepresentation;
+ }
+
+ public void setJsonRepresentation(Map<String, Object> jsonRepresentation) {
+ this.jsonRepresentation = jsonRepresentation;
+ }
+
+ public Set<Loop> getUsedByLoops() {
+ return usedByLoops;
+ }
+
+ public void setUsedByLoops(Set<Loop> usedBy) {
+ this.usedByLoops = usedBy;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/dao/model/OperationalPolicy.java b/src/main/java/org/onap/clamp/dao/model/OperationalPolicy.java
new file mode 100644
index 00000000..d66fd940
--- /dev/null
+++ b/src/main/java/org/onap/clamp/dao/model/OperationalPolicy.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.dao.model;
+
+import com.google.gson.annotations.Expose;
+import com.vladmihalcea.hibernate.type.json.JsonStringType;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+
+@Entity
+@Table(name = "operational_policies")
+@TypeDef(name = "json", typeClass = JsonStringType.class)
+public class OperationalPolicy implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6117076450841538255L;
+
+ @Expose
+ @Id
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ @Expose
+ @Type(type = "json")
+ @Column(columnDefinition = "json", name = "configurations_json")
+ private Map<String, Object> configurationsJson;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "loop_id", nullable = false)
+ private Loop loop;
+
+ public Loop getLoop() {
+ return loop;
+ }
+
+ public void setLoop(Loop loop) {
+ this.loop = loop;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<String, Object> getConfigurationsJson() {
+ return configurationsJson;
+ }
+
+ public void setConfigurationsJson(Map<String, Object> configurationsJson) {
+ this.configurationsJson = configurationsJson;
+ }
+
+}
diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index 4dbcd459..7dd0314a 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -56,6 +56,7 @@ server.port=8080
server.servlet.context-path=/
#Modified engine-rest applicationpath
spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller
+spring.http.converters.preferred-json-mapper=gson
#The max number of active threads in this pool
server.tomcat.max-threads=200
@@ -94,6 +95,22 @@ spring.datasource.cldsdb.initialSize=0
# Automatically test whether a connection provided is good or not
spring.datasource.cldsdb.testOnBorrow=true
spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+# control the sql db initialization (from schema.sql and data.sql)
+spring.datasource.initialize=false
+
+spring.jpa.properties.javax.persistence.schema-generation.database.action=none
+s#pring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql
+# disable Hibernate DDL generation because the schema will be generated from a sql script
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
+spring.jpa.properties.hibernate.ddl-auto=validate
+spring.jpa.properties.hibernate.hbm2ddl.delimiter=;
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.properties.hibernate.use-new-id-generator-mappings=true
+
+# Whether to enable logging of SQL statements.
+spring.jpa.show-sql=true
#Async Executor default Parameters
async.core.pool.size=10
@@ -166,7 +183,6 @@ clamp.config.op.controller=amsterdam
clamp.config.op.policy.appc=APPC
#
# Sdc service properties
-#
clamp.config.sdc.csarFolder = /tmp/sdc-controllers
clamp.config.sdc.blueprint.parser.mapping = classpath:/clds/blueprint-parser-mapping.json
#
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 9852dc8c..8859c4b3 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -113,6 +113,20 @@ spring.datasource.cldsdb.initialSize=0
spring.datasource.cldsdb.testOnBorrow=true
spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+spring.jpa.properties.javax.persistence.schema-generation.database.action=none
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql
+# disable Hibernate DDL generation because the schema will be generated from a sql script
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
+spring.jpa.properties.hibernate.ddl-auto=validate
+spring.jpa.properties.hibernate.hbm2ddl.delimiter=;
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.properties.hibernate.use-new-id-generator-mappings=true
+
+# Whether to enable logging of SQL statements.
+spring.jpa.show-sql=true
+
#Async Executor default Parameters
async.core.pool.size=10
async.max.pool.size=20