summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler
diff options
context:
space:
mode:
authorRamya Balaji <rb111y@att.com>2017-09-19 20:58:45 -0400
committerRamya Balaji <rb111y@att.com>2017-09-19 21:07:43 -0400
commit598e7357e2ef9e12e2aeed6a9e63fd1272b69c12 (patch)
tree7db05d2647f321d43d5f7ac53747e80a1a78e67e /appc-inbound/appc-artifact-handler
parenteac0b6f973d747299dc667c0495886094b5972a1 (diff)
Changes to ProtocolReference table insert
Added Code to check if record exists previously in table. If so, make an update else insert. Issue-ID:APPC-220 Change-Id: I3825128d8381a4f0c7e62926be6ecec9ab178194 Signed-off-by: Ramya Balaji <rb111y@att.com>
Diffstat (limited to 'appc-inbound/appc-artifact-handler')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java39
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java6
2 files changed, 44 insertions, 1 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
index a619a00a8..5cc92f3e1 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
@@ -443,5 +443,44 @@ public class DBService {
status = serviceLogic.save("SQL", false, false, key, null, null, context);
if ((status == null) || status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing insertProtocolReference ");
+
}
+
+ public boolean isProtocolReferenceUpdateRequired(SvcLogicContext context, String vnfType, String protocol,
+ String action, String action_level, String template) throws SvcLogicException {
+ SvcLogicContext localContext = new SvcLogicContext();
+ String fn = "DBService.isProtocolReferenceUpdateRequired";
+ log.info(fn + "Starting DB operation for isProtocolReferenceUpdateRequired");
+ String key = "";
+ QueryStatus status = null;
+
+ key = "select COUNT(*) from PROTOCOL_REFERENCE where ACTION='" + action + "' and ACTION_LEVEL='" + action_level
+ + "' and VNF_TYPE='" + vnfType + "'";
+ status = serviceLogic.query("SQL", false, null, key, null, null, localContext);
+ String countStr = localContext.getAttribute("COUNT(*)");
+ int count = Integer.parseInt(countStr);
+ if (count > 0)
+ return true;
+ else
+ return false;
+ }
+
+ public void updateProtocolReference(SvcLogicContext context, String vnfType, String protocol, String action,
+ String action_level, String template) throws SvcLogicException {
+
+ String fn = "DBService.isProtocolReferenceUpdateRequired";
+ log.info(fn + "Starting DB operation for isProtocolReferenceUpdateRequired");
+ String key = "";
+ QueryStatus status = null;
+
+ key = "update PROTOCOL_REFERENCE set UPDATED_DATE=now(), template='" + template + "' where ACTION='" + action
+ + "' and ACTION_LEVEL='" + action_level + "' and VNF_TYPE='" + vnfType + "'";
+ status = serviceLogic.save("SQL", false, false, key, null, null, context);
+ if (status == QueryStatus.FAILURE) {
+ log.info("updateProtocolReference:: Error updating protocol reference");
+ throw new SvcLogicException("Error - updating PROTOCOL_REFERENCE_TABLE in updateProtocolReference");
+ }
+ return;
+ }
+
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
index fec7fbbb6..5df455a8e 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
@@ -501,7 +501,11 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
if (content.has(SdcArtifactHandlerConstants.TEMPLATE)
&& !content.isNull(SdcArtifactHandlerConstants.TEMPLATE))
template = content.getString(SdcArtifactHandlerConstants.TEMPLATE);
- dbservice.insertProtocolReference(context, vnfType, protocol, action, actionLevel, template);
+ boolean isUpdateNeeded=dbservice.isProtocolReferenceUpdateRequired(context, vnfType, protocol, action, actionLevel, template);
+ if (isUpdateNeeded)
+ dbservice.updateProtocolReference(context, vnfType, protocol, action, actionLevel, template);
+ else
+ dbservice.insertProtocolReference(context, vnfType,protocol,action,actionLevel,template);
} catch (Exception e) {
log.error("Error inserting record into protocolReference: " + e.toString());
throw e;