2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.design.dbervices;
27 import java.io.IOException;
28 import java.security.SecureRandom;
29 import java.sql.ResultSet;
30 import java.sql.SQLException;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.Properties;
35 import org.openecomp.appc.design.data.ArtifactInfo;
36 import org.openecomp.appc.design.data.DesignInfo;
37 import org.openecomp.appc.design.data.DesignResponse;
38 import org.openecomp.appc.design.data.StatusInfo;
39 import org.openecomp.appc.design.services.util.ArtifactHandlerClient;
40 import org.openecomp.appc.design.services.util.DesignServiceConstants;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
42 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
43 import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
44 import com.att.eelf.configuration.EELFLogger;
45 import com.att.eelf.configuration.EELFManager;
46 import com.fasterxml.jackson.core.JsonProcessingException;
47 import com.fasterxml.jackson.databind.JsonNode;
48 import com.fasterxml.jackson.databind.ObjectMapper;
49 import com.fasterxml.jackson.databind.node.ObjectNode;
51 public class DesignDBService {
53 private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class);
54 private SvcLogicResource serviceLogic;
55 private static DesignDBService dgGeneralDBService = null;
56 private static DBResourceManager jdbcDataSource;
58 DbService dbservice = null;
59 private static Properties props;
60 public static DesignDBService initialise() {
61 if (dgGeneralDBService == null) {
62 dgGeneralDBService = new DesignDBService();
64 return dgGeneralDBService;
66 private DesignDBService() {
67 if (serviceLogic == null) {
68 serviceLogic = new SqlResource();
72 public String execute(String action, String payload, String requestID) throws Exception {
74 log.info("Received execute request for action : " + action + " with Payload : "+ payload );
75 RequestValidator.validate(action, payload);
76 String response = null;
77 dbservice = new DbService();
79 case DesignServiceConstants.GETDESIGNS:
80 response = getDesigns(payload,requestID );
82 case DesignServiceConstants.ADDINCART:
83 response= setInCart(payload, requestID);
85 case DesignServiceConstants.GETARTIFACTREFERENCE:
86 response= getArtifactReference(payload, requestID);
88 case DesignServiceConstants.GETARTIFACT:
89 response= getArtifact(payload, requestID);
91 case DesignServiceConstants.GETGUIREFERENCE:
92 response= getGuiReference(payload, requestID);
94 case DesignServiceConstants.GETSTATUS:
95 response= getStatus(payload, requestID);
97 case DesignServiceConstants.SETSTATUS:
98 response= setStatus(payload, requestID);
100 case DesignServiceConstants.UPLOADARTIFACT:
101 response= uploadArtifact(payload, requestID);
103 case DesignServiceConstants.SETPROTOCOLREFERENCE:
104 response= setProtocolReference(payload, requestID);
107 throw new Exception(" Action " + action + " not found while processing request ");
113 private String setInCart(String payload, String requestID) throws Exception {
115 ObjectMapper objectMapper = new ObjectMapper();
116 JsonNode payloadObject = objectMapper.readTree(payload);
117 ArrayList<String> argList = new ArrayList<>();
118 argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue());
119 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
121 String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID IN "
122 + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? " ;
124 if(payloadObject.get(DesignServiceConstants.VNF_TYPE) != null &&! payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) {
125 queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? " ;
126 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
129 queryString = queryString + " ) AND USER = ? " ;
132 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
134 log.info("Query String :" + queryString);
135 boolean data = dbservice.updateDBData(queryString, argList);
138 throw new Exception("Error while updating ProtocolReference");
140 return "{\"update\" : \"success\" } ";
143 private String setProtocolReference(String payload, String requestID) throws Exception {
145 ObjectMapper objectMapper = new ObjectMapper();
146 JsonNode payloadObject = objectMapper.readTree(payload);
147 ArrayList<String> argList = new ArrayList<>();
149 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
150 argList.add(payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue());
151 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
152 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
154 String queryString = " DELETE FROM PROTOCOL_REFERENCE WHERE ACTION = ? AND ACTION_LEVEL AND VNF_TYPE= ? AND PROTOCOL = ? " ;
156 log.info("Delete Query String :" + queryString);
157 boolean data = dbservice.updateDBData(queryString, argList);
159 log.info("Record Deleted");
161 if((payloadObject.get(DesignServiceConstants.TEMPLATE) != null && !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty()))
162 argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue());
166 String insertString = "INSERT INTO PROTOCOL_REFERENCE VALUES (?,?,?,?,?,SYSDATE()) ";
168 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
169 queryString = queryString + " AND VNFC_TYPE = ? )" ;
172 queryString = queryString + " ) ";
174 log.info("Query String :" + queryString);
175 data = dbservice.updateDBData(queryString, argList);
178 throw new Exception("Error while updating ProtocolReference");
180 return "{\"update\" : \"success\" } ";
182 private String uploadArtifact(String payload, String requestID) throws Exception {
184 ObjectMapper objectMapper = new ObjectMapper();
185 JsonNode payloadObject = objectMapper.readTree(payload);
186 log.info("Got upload Aritfact with Payload : " + payloadObject.asText());
188 ArtifactHandlerClient ac = new ArtifactHandlerClient();
189 String requestString = ac.createArtifactData(payload, requestID);
190 ac.execute(requestString, "POST");
191 int sdc_artifact_id = getSDCArtifactIDbyRequestID(requestID);
192 int sdc_reference_id = getSDCReferenceID(payload);
193 createArtifactTrackingRecord(payload, requestID,sdc_artifact_id, sdc_reference_id );
194 String status = getDataFromActionStatus(payload, "STATUS");
195 if(status == null || status.isEmpty())
196 setActionStatus(payload, "Not Tested");
197 linkstatusRelationShip(sdc_artifact_id,sdc_reference_id, payload);
204 return "{\"update\" : \"success\" } ";
208 private void linkstatusRelationShip(int sdc_artifact_id, int sdc_reference_id, String payload) throws Exception {
210 ObjectMapper objectMapper = new ObjectMapper();
211 JsonNode payloadObject = objectMapper.readTree(payload);
212 ArrayList<String> argList = new ArrayList<>();
213 argList.add(String.valueOf(sdc_artifact_id));
214 argList.add(String.valueOf(sdc_reference_id));
215 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
216 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
217 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
219 String queryString = "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " +
220 "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , "
221 + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? " ;
223 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
224 queryString = queryString + " AND VNFC_TYPE = ? ) )" ;
227 queryString = queryString + " ) ) ";
229 log.info("Query String :" + queryString);
230 boolean data = dbservice.updateDBData(queryString, argList);
233 throw new Exception("Error while updating RealtionShip table");
236 private int getSDCReferenceID(String payload) throws Exception {
238 String vnfc_type = null;
239 ObjectMapper objectMapper = new ObjectMapper();
240 JsonNode payloadObject = objectMapper.readTree(payload);
241 ArrayList<String> argList = new ArrayList<>();
242 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
244 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue());
245 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue());
247 String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? "
248 + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? " ;
250 if(payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()){
251 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
252 queryString = queryString + " AND ACTION = ? ";
254 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
255 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
256 queryString = queryString + " AND VNFC_TYPE = ? ";
260 log.info("Query String :" + queryString);
261 ResultSet data = dbservice.getDBData(queryString, argList);
262 int sdc_reference_id = 0;
264 sdc_reference_id = data.getInt("ASDC_REFERENCE_ID");
266 log.info("Got sdc_reference_id = " + sdc_reference_id );
267 return sdc_reference_id;
271 private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
272 String status = null ;
273 ObjectMapper objectMapper = new ObjectMapper();
274 JsonNode payloadObject = objectMapper.readTree(payload);
275 ArrayList<String> argList = new ArrayList<>();
276 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
277 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
278 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
279 String queryString = " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
280 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
281 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
282 queryString = queryString + " AND VNFC_TYPE = ? ";
284 log.info("Query String :" + queryString);
285 ResultSet data = dbservice.getDBData(queryString, argList);
287 status = data.getString("STATUS");
289 log.info("DT_ACTION_STATUS Status = " + status );
293 private boolean setActionStatus(String payload, String status) throws Exception {
294 ObjectMapper objectMapper = new ObjectMapper();
295 JsonNode payloadObject = objectMapper.readTree(payload);
296 ArrayList<String> argList = new ArrayList<>();
297 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
298 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
301 String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); ";
302 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
303 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
308 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
309 if(payloadObject.get(DesignServiceConstants.TECHNOLOGY) !=null && !payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()){
310 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
317 boolean updateStatus = dbservice.updateDBData(insertQuery, argList);
319 throw new Exception("Error while updating Action Status");
323 private void createArtifactTrackingRecord(String payload, String requestID, int sdc_artifact_id, int sdc_reference_id) throws Exception {
324 String vnfc_type = null;
325 ObjectMapper objectMapper = new ObjectMapper();
326 JsonNode payloadObject = objectMapper.readTree(payload);
328 ArrayList<String> argList = new ArrayList<>();
329 argList.add(String.valueOf(sdc_artifact_id));
330 argList.add(String.valueOf(sdc_reference_id));
331 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
332 if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null &&! payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty())
333 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
337 if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null &&! payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty())
338 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
343 String queryString = "INSERT INTO DT_ARTIFACT_TRACKING (ASDC_ARTIFACTS_ID, ASDC_REFERENCE_ID, USER, TECHNOLOGY, CREATION_DATE, UPDATED_DATE, ARTIFACT_STATUS, PROTOCOL, IN_CART) VALUES (? , ? , ?, ?, sysdate() , sysdate(), 'Created', ? ,'N' )" ;
345 log.info("Query String :" + queryString);
346 boolean data = dbservice.updateDBData(queryString, argList);
348 throw new Exception("Error Updating DT_ARTIFACT_TRACKING ");
353 private int getSDCArtifactIDbyRequestID(String requestID) throws Exception {
354 log.info("Starting getArtifactIDbyRequestID DB Operation");
357 ArrayList<String> argList = new ArrayList<>();
358 argList.add("TLSUUID" + requestID);
359 String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? ";
360 log.info("Query String :" + queryString);
361 ResultSet data = dbservice.getDBData(queryString, argList);
363 artifact_id = data.getInt("ASDC_ARTIFACTS_ID");
370 log.info("Got SDC_ARTIFACTS_ID As :" + artifact_id);
375 private String getArtifact(String payload, String requestID) throws Exception {
376 String fn = "DBService.getStatus ";
377 log.info("Starting getArtifact DB Operation");
379 String vnfc_type = null;
380 ObjectMapper objectMapper = new ObjectMapper();
381 JsonNode payloadObject = objectMapper.readTree(payload);
382 ArrayList<String> argList = new ArrayList<>();
383 argList.add(payloadObject.get("artifact-name").textValue());
384 argList.add(payloadObject.get("artifact-type").textValue());
386 String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " +
387 " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? " ;
389 log.info("Query String :" + queryString);
390 ResultSet data = dbservice.getDBData(queryString, argList);
391 String artifact_content = null;
392 int hightestVerion = 0 ;
394 int version = data.getInt("INTERNAL_VERSION");
395 if(hightestVerion < version)
396 artifact_content = data.getString("ARTIFACT_CONTENT");
399 if(artifact_content == null || artifact_content.isEmpty())
400 throw new Exception("Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue());
401 DesignResponse designResponse = new DesignResponse();
402 designResponse.setUserId(payloadObject.get("userID").textValue());
403 List<ArtifactInfo> artifactInfoList = new ArrayList<ArtifactInfo>();
404 ArtifactInfo artifactInfo = new ArtifactInfo();
405 artifactInfo.setArtifact_content(artifact_content);
406 artifactInfoList.add(artifactInfo);
407 designResponse.setArtifactInfo(artifactInfoList);
409 ObjectMapper mapper = new ObjectMapper();
410 String jsonString = mapper.writeValueAsString(designResponse);
411 log.info("Info : " + jsonString);
414 catch(SQLException e)
416 log.error("Error while DB operation : " + e.getMessage());
422 log.error("Error while DB operation : " + e.getMessage());
428 private String setStatus(String payload, String requestID) throws Exception {
429 String fn = "DBService.getStatus ";
430 log.info("Starting getStatus DB Operation");
432 String vnfc_type = null;
433 ObjectMapper objectMapper = new ObjectMapper();
434 JsonNode payloadObject = objectMapper.readTree(payload);
437 ArrayList<String> argList = new ArrayList<>();
438 argList.add(payloadObject.get("artifact_status").textValue());
439 argList.add(payloadObject.get("action_status").textValue());
441 argList.add(payloadObject.get("userID").textValue());
442 argList.add(payloadObject.get("vnf-type").textValue());
444 String queryString = " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? "
445 + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
446 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
447 + " and DAS.VNF_TYPE = ? " ;
449 if(payloadObject.get("vnfc-type") !=null && !payloadObject.get("vnfc-type").textValue().isEmpty()){
450 argList.add(payloadObject.get("vnfc-type").textValue());
451 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
454 log.info("Query String :" + queryString);
456 DesignResponse designResponse = new DesignResponse();
457 designResponse.setUserId(payloadObject.get("userID").textValue());
458 List<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
459 boolean update = dbservice.updateDBData(queryString, argList);
461 throw new Exception("Sorry .....Something went wrong while updating the Status");
463 ObjectMapper mapper = new ObjectMapper();
464 String jsonString = mapper.writeValueAsString(designResponse);
465 log.info("Info : " + jsonString);
468 catch(SQLException e)
470 log.error("Error while DB operation : " + e.getMessage());
476 log.error("Error while DB operation : " + e.getMessage());
481 private String getStatus(String payload, String requestID) throws Exception {
482 String fn = "DBService.getStatus ";
483 log.info("Starting getStatus DB Operation");
485 String vnfc_type = null;
486 ObjectMapper objectMapper = new ObjectMapper();
487 JsonNode payloadObject = objectMapper.readTree(payload);
488 String UserID = payloadObject.get("userID").textValue();
489 String vnf_type = payloadObject.get("vnf-type").textValue();
490 if(payloadObject.get("vnfc-type") != null )
491 vnfc_type = payloadObject.get("vnfc-type").textValue();
492 ArrayList<String> argList = new ArrayList<>();
495 argList.add(vnf_type);
497 String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS "
498 + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " +
499 " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
500 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
501 + " and DAS.VNF_TYPE = ? " ;
503 if(vnfc_type !=null && ! vnfc_type.isEmpty()){
504 argList.add(vnfc_type);
505 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
508 log.info("Query String :" + queryString);
510 DesignResponse designResponse = new DesignResponse();
511 designResponse.setUserId(UserID);
512 List<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
513 ResultSet data = dbservice.getDBData(queryString, argList);
515 StatusInfo statusInfo = new StatusInfo();
516 statusInfo.setAction(data.getString("ACTION"));
517 statusInfo.setAction_status(data.getString("STATUS"));
518 statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS"));
519 statusInfo.setVnf_type(data.getString("VNF_TYPE"));
520 statusInfo.setVnfc_type(data.getString("VNFC_TYPE"));
521 statusInfoList.add(statusInfo);
524 if(statusInfoList.size() < 1)
525 throw new Exception("OOPS !!!! No VNF information available for VNF-TYPE : " + vnf_type + " for User : " + UserID);
526 designResponse.setStatusInfoList(statusInfoList);
527 ObjectMapper mapper = new ObjectMapper();
528 String jsonString = mapper.writeValueAsString(designResponse);
529 log.info("Info : " + jsonString);
532 catch(SQLException e)
534 log.error("Error while DB operation : " + e.getMessage());
540 log.error("Error while DB operation : " + e.getMessage());
545 private String getGuiReference(String payload, String requestID) {
546 // TODO Auto-generated method stub
549 private String getArtifactReference(String payload, String requestID) {
550 // TODO Auto-generated method stub
553 private String getAddInCart(String payload, String requestID) {
554 // TODO Auto-generated method stub
558 // private String getDesigns(String payload, String requestID) throws SQLException, JsonProcessingException, IOException, SvcLogicException {
560 // String fn = "DBService.getDesigns ";
561 // QueryStatus status = null;
562 // ObjectMapper objectMapper = new ObjectMapper();
563 // JsonNode jnode = objectMapper.readTree(payload);
564 // String UserId = jnode.get("userID").textValue();
565 // SvcLogicContext localContext = new SvcLogicContext();
566 // localContext.setAttribute("requestID", requestID);
567 // localContext.setAttribute("userID", UserId);
568 // if (serviceLogic != null && localContext != null) {
569 // String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART from " +
570 // DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
571 // " AR where DAT.SDC_REFERENCE_ID= AR.SDC_REFERENCE_ID and DAT.USER = $userID" ;
573 // log.info(fn + "Query String : " + queryString);
575 // status = serviceLogic.query("SQL", true, null, queryString, null, null, localContext);
576 // } catch (SvcLogicException e1) {
577 // // TODO Auto-generated catch block
578 // e1.printStackTrace();
581 // if(status.toString().equals("FAILURE"))
582 // throw new SvcLogicException("Error - while getting FlowReferenceData ");
584 // Properties props = localContext.toProperties();
585 // log.info("SvcLogicContext contains the following : " + props.toString());
586 // for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) {
587 // String propName = (String) e.nextElement();
588 // log.info(propName+" = "+props.getProperty(propName));
596 private String getDesigns(String payload, String requestID) throws Exception {
598 String fn = "DBService.getDesigns ";
599 log.info("Starting getDesgins DB Operation");
603 ObjectMapper objectMapper = new ObjectMapper();
604 JsonNode payloadObject = objectMapper.readTree(payload);
605 String UserID = payloadObject.get("userID").textValue();
606 ArrayList<String> argList = new ArrayList<>();
609 String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from " +
610 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
611 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? ";
613 DesignResponse designResponse = new DesignResponse();
614 designResponse.setUserId(UserID);
615 List<DesignInfo> designInfoList = new ArrayList<DesignInfo>();
616 ResultSet data = dbservice.getDBData(queryString, argList);
618 DesignInfo designInfo = new DesignInfo();
619 designInfo.setInCart(data.getString("IN_CART"));
620 designInfo.setProtocol(data.getString("PROTOCOL"));
621 designInfo.setVnf_type(data.getString("VNF_TYPE"));
622 designInfo.setVnfc_type(data.getString("VNFC_TYPE"));
623 designInfo.setAction(data.getString("ACTION"));
624 designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE"));
625 designInfo.setArtifact_name(data.getString("ARTIFACT_NAME"));
626 designInfoList.add(designInfo);
628 if(designInfoList.size() < 1)
629 throw new Exception(" Welcome to CDT, Looks like you dont have Design Yet... Lets create some....");
630 designResponse.setDesignInfoList(designInfoList);
631 ObjectMapper mapper = new ObjectMapper();
632 String jsonString = mapper.writeValueAsString(designResponse);
633 log.info("Info : " + jsonString);