aboutsummaryrefslogtreecommitdiffstats
path: root/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-12-05 11:50:42 -0500
committerDan Timoney <dtimoney@att.com>2017-12-05 11:50:42 -0500
commit13cbc4e6633e4cef9cc33d10c11b9b177213acd9 (patch)
tree1ef5785a6355f9491d7f2f9cf8fcbfaea3e66d40 /sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
parent7cb74a4e851ae85ffa8c7cd1ebe94007418b816c (diff)
SLI parser improvements
Update SLI parser to remove validation based on NODE_TYPE table, which is no longer needed (was introduced prior to use of XSD schema validation). Also, use checksums to avoid needless recompilation if version being loaded already exists in database. Change-Id: Idfcba94de8fb71b17d5e0c5e69e04dee266988b1 Issue-ID: CCSDK-152 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java')
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java101
1 files changed, 27 insertions, 74 deletions
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
index ab5773c0..74fa1dd6 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
@@ -326,80 +326,6 @@ public class SvcLogicDblibStore implements SvcLogicStore {
}
}
- @Override
- public void registerNodeType(String nodeType) throws SvcLogicException {
-
- String registerNodeSql = "INSERT INTO NODE_TYPES (nodetype) VALUES(?)";
-
- if (isValidNodeType(nodeType)) {
- return;
- }
-
- DbLibService dbSvc = getDbLibService();
- ArrayList<String> args = new ArrayList<>();
-
- args.add(nodeType);
-
- try {
- dbSvc.writeData(registerNodeSql, args, null);
- } catch (Exception e) {
- throw new SvcLogicException("Could not add node type to database", e);
- }
-
- }
-
- @Override
- public void unregisterNodeType(String nodeType) throws SvcLogicException {
-
- if (!isValidNodeType(nodeType)) {
- return;
- }
-
- String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?";
-
- DbLibService dbSvc = getDbLibService();
- ArrayList<String> args = new ArrayList<>();
-
- args.add(nodeType);
-
- try {
- dbSvc.writeData(unregisterNodeSql, args, null);
- } catch (Exception e) {
- throw new SvcLogicException(
- "Could not delete node type from database", e);
- }
-
- }
-
- @Override
- public boolean isValidNodeType(String nodeType) throws SvcLogicException {
-
- String validateNodeSql = "SELECT count(*) FROM NODE_TYPES WHERE nodetype = ?";
-
- DbLibService dbSvc = getDbLibService();
-
- ArrayList<String> args = new ArrayList<>();
-
- args.add(nodeType);
-
- boolean isValid = false;
-
- try (CachedRowSet results = dbSvc.getData(validateNodeSql, args, null)) {
-
- if (results != null && results.next()) {
- int cnt = results.getInt(1);
-
- if (cnt > 0) {
- isValid = true;
- }
- }
- } catch (Exception e) {
- throw new SvcLogicException("Cannot select node type from database", e);
- }
-
- return isValid;
- }
-
private DbLibService getDbLibService() {
// Get DbLibService interface object.
@@ -490,4 +416,31 @@ public class SvcLogicDblibStore implements SvcLogicStore {
INSTANCE = dbresource;
}
}
+
+ @Override
+ public void activate(String module, String rpc, String version, String mode) throws SvcLogicException {
+ DbLibService dbSvc = getDbLibService();
+
+ String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
+
+ String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+
+ ArrayList<String> args = new ArrayList<String>();
+
+ args.add(module);
+ args.add(rpc);
+ args.add(mode);
+
+ try {
+
+ dbSvc.writeData(deactivateSql, args, null);
+
+ args.add(version);
+ dbSvc.writeData(activateSql, args, null);
+
+ } catch (Exception e) {
+ throw new SvcLogicException("Could not activate graph", e);
+ }
+ }
+
}