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.onap.appc.design.dbervices;
27 import java.io.IOException;
28 import java.sql.ResultSet;
29 import java.sql.SQLException;
30 import java.util.ArrayList;
31 import java.util.List;
32 import java.util.Properties;
34 import org.onap.appc.design.data.ArtifactInfo;
35 import org.onap.appc.design.data.DesignInfo;
36 import org.onap.appc.design.data.DesignResponse;
37 import org.onap.appc.design.data.StatusInfo;
38 import org.onap.appc.design.services.util.ArtifactHandlerClient;
39 import org.onap.appc.design.services.util.DesignServiceConstants;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
41 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
42 import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
43 import com.att.eelf.configuration.EELFLogger;
44 import com.att.eelf.configuration.EELFManager;
45 import com.fasterxml.jackson.core.JsonProcessingException;
46 import com.fasterxml.jackson.databind.JsonNode;
47 import com.fasterxml.jackson.databind.ObjectMapper;
49 public class DesignDBService {
51 private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class);
52 private SvcLogicResource serviceLogic;
53 private static DesignDBService dgGeneralDBService = null;
54 private static DBResourceManager jdbcDataSource;
56 DbService dbservice = null;
57 private static Properties props;
58 public static DesignDBService initialise() {
59 if (dgGeneralDBService == null) {
60 dgGeneralDBService = new DesignDBService();
62 return dgGeneralDBService;
64 private DesignDBService() {
65 if (serviceLogic == null) {
66 serviceLogic = new SqlResource();
70 public String execute(String action, String payload, String requestID) throws Exception {
72 log.info("Received execute request for action : " + action + " with Payload : "+ payload );
73 RequestValidator.validate(action, payload);
74 String response = null;
75 dbservice = new DbService();
77 case DesignServiceConstants.GETDESIGNS:
78 response = getDesigns(payload,requestID );
80 case DesignServiceConstants.ADDINCART:
81 response= setInCart(payload, requestID);
83 case DesignServiceConstants.GETARTIFACTREFERENCE:
84 response= getArtifactReference(payload, requestID);
86 case DesignServiceConstants.GETARTIFACT:
87 response= getArtifact(payload, requestID);
89 case DesignServiceConstants.GETGUIREFERENCE:
90 response= getGuiReference(payload, requestID);
92 case DesignServiceConstants.GETSTATUS:
93 response= getStatus(payload, requestID);
95 case DesignServiceConstants.SETSTATUS:
96 response= setStatus(payload, requestID);
98 case DesignServiceConstants.UPLOADARTIFACT:
99 response= uploadArtifact(payload, requestID);
101 case DesignServiceConstants.SETPROTOCOLREFERENCE:
102 response= setProtocolReference(payload, requestID);
105 throw new Exception(" Action " + action + " not found while processing request ");
111 private String setInCart(String payload, String requestID) throws Exception {
113 ObjectMapper objectMapper = new ObjectMapper();
114 JsonNode payloadObject = objectMapper.readTree(payload);
115 ArrayList<String> argList = new ArrayList<>();
116 argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue());
117 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
119 String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID IN "
120 + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? " ;
122 if(payloadObject.get(DesignServiceConstants.VNF_TYPE) != null &&! payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) {
123 queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? " ;
124 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
127 queryString = queryString + " ) AND USER = ? " ;
130 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
132 log.info("Query String :" + queryString);
133 boolean data = dbservice.updateDBData(queryString, argList);
136 throw new Exception("Error while updating ProtocolReference");
138 return "{\"update\" : \"success\" } ";
141 private String setProtocolReference(String payload, String requestID) throws Exception {
143 ObjectMapper objectMapper = new ObjectMapper();
144 JsonNode payloadObject = objectMapper.readTree(payload);
145 ArrayList<String> argList = new ArrayList<>();
147 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
148 argList.add(payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue());
149 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
150 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
152 String queryString = " DELETE FROM PROTOCOL_REFERENCE WHERE ACTION = ? AND ACTION_LEVEL AND VNF_TYPE= ? AND PROTOCOL = ? " ;
154 log.info("Delete Query String :" + queryString);
155 boolean data = dbservice.updateDBData(queryString, argList);
157 log.info("Record Deleted");
159 if((payloadObject.get(DesignServiceConstants.TEMPLATE) != null && !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty()))
160 argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue());
164 String insertString = "INSERT INTO PROTOCOL_REFERENCE VALUES (?,?,?,?,?,SYSDATE()) ";
166 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
167 queryString = queryString + " AND VNFC_TYPE = ? )" ;
170 queryString = queryString + " ) ";
172 log.info("Query String :" + queryString);
173 data = dbservice.updateDBData(queryString, argList);
176 throw new Exception("Error while updating ProtocolReference");
178 return "{\"update\" : \"success\" } ";
180 private String uploadArtifact(String payload, String requestID) throws Exception {
182 ObjectMapper objectMapper = new ObjectMapper();
183 JsonNode payloadObject = objectMapper.readTree(payload);
184 log.info("Got upload Aritfact with Payload : " + payloadObject.asText());
186 ArtifactHandlerClient ac = new ArtifactHandlerClient();
187 String requestString = ac.createArtifactData(payload, requestID);
188 ac.execute(requestString, "POST");
189 int sdc_artifact_id = getSDCArtifactIDbyRequestID(requestID);
190 int sdc_reference_id = getSDCReferenceID(payload);
191 createArtifactTrackingRecord(payload, requestID,sdc_artifact_id, sdc_reference_id );
192 String status = getDataFromActionStatus(payload, "STATUS");
193 if(status == null || status.isEmpty())
194 setActionStatus(payload, "Not Tested");
195 linkstatusRelationShip(sdc_artifact_id,sdc_reference_id, payload);
202 return "{\"update\" : \"success\" } ";
206 private void linkstatusRelationShip(int sdc_artifact_id, int sdc_reference_id, String payload) throws Exception {
208 ObjectMapper objectMapper = new ObjectMapper();
209 JsonNode payloadObject = objectMapper.readTree(payload);
210 ArrayList<String> argList = new ArrayList<>();
211 argList.add(String.valueOf(sdc_artifact_id));
212 argList.add(String.valueOf(sdc_reference_id));
213 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
214 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
215 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
217 String queryString = "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " +
218 "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , "
219 + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? " ;
221 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
222 queryString = queryString + " AND VNFC_TYPE = ? ) )" ;
225 queryString = queryString + " ) ) ";
227 log.info("Query String :" + queryString);
228 boolean data = dbservice.updateDBData(queryString, argList);
231 throw new Exception("Error while updating RealtionShip table");
234 private int getSDCReferenceID(String payload) throws Exception {
236 String vnfc_type = null;
237 ObjectMapper objectMapper = new ObjectMapper();
238 JsonNode payloadObject = objectMapper.readTree(payload);
239 ArrayList<String> argList = new ArrayList<>();
240 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
242 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue());
243 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue());
245 String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? "
246 + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? " ;
248 if(payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()){
249 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
250 queryString = queryString + " AND ACTION = ? ";
252 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
253 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
254 queryString = queryString + " AND VNFC_TYPE = ? ";
258 log.info("Query String :" + queryString);
259 ResultSet data = dbservice.getDBData(queryString, argList);
260 int sdc_reference_id = 0;
262 sdc_reference_id = data.getInt("ASDC_REFERENCE_ID");
264 log.info("Got sdc_reference_id = " + sdc_reference_id );
265 return sdc_reference_id;
269 private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
270 String status = null ;
271 ObjectMapper objectMapper = new ObjectMapper();
272 JsonNode payloadObject = objectMapper.readTree(payload);
273 ArrayList<String> argList = new ArrayList<>();
274 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
275 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
276 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
277 String queryString = " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
278 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
279 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
280 queryString = queryString + " AND VNFC_TYPE = ? ";
282 log.info("Query String :" + queryString);
283 ResultSet data = dbservice.getDBData(queryString, argList);
285 status = data.getString("STATUS");
287 log.info("DT_ACTION_STATUS Status = " + status );
291 private boolean setActionStatus(String payload, String status) throws Exception {
292 ObjectMapper objectMapper = new ObjectMapper();
293 JsonNode payloadObject = objectMapper.readTree(payload);
294 ArrayList<String> argList = new ArrayList<>();
295 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
296 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
299 String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); ";
300 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
301 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
306 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
307 if(payloadObject.get(DesignServiceConstants.TECHNOLOGY) !=null && !payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()){
308 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
315 boolean updateStatus = dbservice.updateDBData(insertQuery, argList);
317 throw new Exception("Error while updating Action Status");
321 private void createArtifactTrackingRecord(String payload, String requestID, int sdc_artifact_id, int sdc_reference_id) throws Exception {
322 String vnfc_type = null;
323 ObjectMapper objectMapper = new ObjectMapper();
324 JsonNode payloadObject = objectMapper.readTree(payload);
326 ArrayList<String> argList = new ArrayList<>();
327 argList.add(String.valueOf(sdc_artifact_id));
328 argList.add(String.valueOf(sdc_reference_id));
329 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
330 if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null &&! payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty())
331 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
335 if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null &&! payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty())
336 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
341 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' )" ;
343 log.info("Query String :" + queryString);
344 boolean data = dbservice.updateDBData(queryString, argList);
346 throw new Exception("Error Updating DT_ARTIFACT_TRACKING ");
351 private int getSDCArtifactIDbyRequestID(String requestID) throws Exception {
352 log.info("Starting getArtifactIDbyRequestID DB Operation");
355 ArrayList<String> argList = new ArrayList<>();
356 argList.add("TLSUUID" + requestID);
357 String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? ";
358 log.info("Query String :" + queryString);
359 ResultSet data = dbservice.getDBData(queryString, argList);
361 artifact_id = data.getInt("ASDC_ARTIFACTS_ID");
368 log.info("Got SDC_ARTIFACTS_ID As :" + artifact_id);
373 private String getArtifact(String payload, String requestID) throws Exception {
374 String fn = "DBService.getStatus ";
375 log.info("Starting getArtifact DB Operation");
377 String vnfc_type = null;
378 ObjectMapper objectMapper = new ObjectMapper();
379 JsonNode payloadObject = objectMapper.readTree(payload);
380 ArrayList<String> argList = new ArrayList<>();
381 argList.add(payloadObject.get("artifact-name").textValue());
382 argList.add(payloadObject.get("artifact-type").textValue());
384 String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " +
385 " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? " ;
387 log.info("Query String :" + queryString);
388 ResultSet data = dbservice.getDBData(queryString, argList);
389 String artifact_content = null;
390 int hightestVerion = 0 ;
392 int version = data.getInt("INTERNAL_VERSION");
393 if(hightestVerion < version)
394 artifact_content = data.getString("ARTIFACT_CONTENT");
397 if(artifact_content == null || artifact_content.isEmpty())
398 throw new Exception("Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue());
399 DesignResponse designResponse = new DesignResponse();
400 designResponse.setUserId(payloadObject.get("userID").textValue());
401 List<ArtifactInfo> artifactInfoList = new ArrayList<ArtifactInfo>();
402 ArtifactInfo artifactInfo = new ArtifactInfo();
403 artifactInfo.setArtifact_content(artifact_content);
404 artifactInfoList.add(artifactInfo);
405 designResponse.setArtifactInfo(artifactInfoList);
407 ObjectMapper mapper = new ObjectMapper();
408 String jsonString = mapper.writeValueAsString(designResponse);
409 log.info("Info : " + jsonString);
412 catch(SQLException e)
414 log.error("Error while DB operation : " + e.getMessage());
420 log.error("Error while DB operation : " + e.getMessage());
426 private String setStatus(String payload, String requestID) throws Exception {
427 String fn = "DBService.getStatus ";
428 log.info("Starting getStatus DB Operation");
430 String vnfc_type = null;
431 ObjectMapper objectMapper = new ObjectMapper();
432 JsonNode payloadObject = objectMapper.readTree(payload);
435 ArrayList<String> argList = new ArrayList<>();
436 argList.add(payloadObject.get("artifact_status").textValue());
437 argList.add(payloadObject.get("action_status").textValue());
439 argList.add(payloadObject.get("userID").textValue());
440 argList.add(payloadObject.get("vnf-type").textValue());
442 String queryString = " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? "
443 + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
444 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
445 + " and DAS.VNF_TYPE = ? " ;
447 if(payloadObject.get("vnfc-type") !=null && !payloadObject.get("vnfc-type").textValue().isEmpty()){
448 argList.add(payloadObject.get("vnfc-type").textValue());
449 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
452 log.info("Query String :" + queryString);
454 DesignResponse designResponse = new DesignResponse();
455 designResponse.setUserId(payloadObject.get("userID").textValue());
456 List<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
457 boolean update = dbservice.updateDBData(queryString, argList);
459 throw new Exception("Sorry .....Something went wrong while updating the Status");
461 ObjectMapper mapper = new ObjectMapper();
462 String jsonString = mapper.writeValueAsString(designResponse);
463 log.info("Info : " + jsonString);
466 catch(SQLException e)
468 log.error("Error while DB operation : " + e.getMessage());
474 log.error("Error while DB operation : " + e.getMessage());
479 private String getStatus(String payload, String requestID) throws Exception {
480 String fn = "DBService.getStatus ";
481 log.info("Starting getStatus DB Operation");
483 String vnfc_type = null;
484 ObjectMapper objectMapper = new ObjectMapper();
485 JsonNode payloadObject = objectMapper.readTree(payload);
486 String UserID = payloadObject.get("userID").textValue();
487 String vnf_type = payloadObject.get("vnf-type").textValue();
488 if(payloadObject.get("vnfc-type") != null )
489 vnfc_type = payloadObject.get("vnfc-type").textValue();
490 ArrayList<String> argList = new ArrayList<>();
493 argList.add(vnf_type);
495 String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS "
496 + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " +
497 " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
498 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
499 + " and DAS.VNF_TYPE = ? " ;
501 if(vnfc_type !=null && ! vnfc_type.isEmpty()){
502 argList.add(vnfc_type);
503 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
506 log.info("Query String :" + queryString);
508 DesignResponse designResponse = new DesignResponse();
509 designResponse.setUserId(UserID);
510 List<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
511 ResultSet data = dbservice.getDBData(queryString, argList);
513 StatusInfo statusInfo = new StatusInfo();
514 statusInfo.setAction(data.getString("ACTION"));
515 statusInfo.setAction_status(data.getString("STATUS"));
516 statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS"));
517 statusInfo.setVnf_type(data.getString("VNF_TYPE"));
518 statusInfo.setVnfc_type(data.getString("VNFC_TYPE"));
519 statusInfoList.add(statusInfo);
522 if(statusInfoList.size() < 1)
523 throw new Exception("OOPS !!!! No VNF information available for VNF-TYPE : " + vnf_type + " for User : " + UserID);
524 designResponse.setStatusInfoList(statusInfoList);
525 ObjectMapper mapper = new ObjectMapper();
526 String jsonString = mapper.writeValueAsString(designResponse);
527 log.info("Info : " + jsonString);
530 catch(SQLException e)
532 log.error("Error while DB operation : " + e.getMessage());
538 log.error("Error while DB operation : " + e.getMessage());
539 log.error("Exception : ",e);
543 private String getGuiReference(String payload, String requestID) {
544 // TODO Auto-generated method stub
547 private String getArtifactReference(String payload, String requestID) {
548 // TODO Auto-generated method stub
551 private String getAddInCart(String payload, String requestID) {
552 // TODO Auto-generated method stub
556 // private String getDesigns(String payload, String requestID) throws SQLException, JsonProcessingException, IOException, SvcLogicException {
558 // String fn = "DBService.getDesigns ";
559 // QueryStatus status = null;
560 // ObjectMapper objectMapper = new ObjectMapper();
561 // JsonNode jnode = objectMapper.readTree(payload);
562 // String UserId = jnode.get("userID").textValue();
563 // SvcLogicContext localContext = new SvcLogicContext();
564 // localContext.setAttribute("requestID", requestID);
565 // localContext.setAttribute("userID", UserId);
566 // if (serviceLogic != null && localContext != null) {
567 // String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART from " +
568 // DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
569 // " AR where DAT.SDC_REFERENCE_ID= AR.SDC_REFERENCE_ID and DAT.USER = $userID" ;
571 // log.info(fn + "Query String : " + queryString);
573 // status = serviceLogic.query("SQL", true, null, queryString, null, null, localContext);
574 // } catch (SvcLogicException e1) {
575 // // TODO Auto-generated catch block
576 // e1.printStackTrace();
579 // if(status.toString().equals("FAILURE"))
580 // throw new SvcLogicException("Error - while getting FlowReferenceData ");
582 // Properties props = localContext.toProperties();
583 // log.info("SvcLogicContext contains the following : " + props.toString());
584 // for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) {
585 // String propName = (String) e.nextElement();
586 // log.info(propName+" = "+props.getProperty(propName));
594 private String getDesigns(String payload, String requestID) throws Exception {
596 String fn = "DBService.getDesigns ";
597 log.info("Starting getDesgins DB Operation");
601 ObjectMapper objectMapper = new ObjectMapper();
602 JsonNode payloadObject = objectMapper.readTree(payload);
603 String UserID = payloadObject.get("userID").textValue();
604 ArrayList<String> argList = new ArrayList<>();
607 String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from " +
608 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
609 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? ";
611 DesignResponse designResponse = new DesignResponse();
612 designResponse.setUserId(UserID);
613 List<DesignInfo> designInfoList = new ArrayList<DesignInfo>();
614 ResultSet data = dbservice.getDBData(queryString, argList);
616 DesignInfo designInfo = new DesignInfo();
617 designInfo.setInCart(data.getString("IN_CART"));
618 designInfo.setProtocol(data.getString("PROTOCOL"));
619 designInfo.setVnf_type(data.getString("VNF_TYPE"));
620 designInfo.setVnfc_type(data.getString("VNFC_TYPE"));
621 designInfo.setAction(data.getString("ACTION"));
622 designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE"));
623 designInfo.setArtifact_name(data.getString("ARTIFACT_NAME"));
624 designInfoList.add(designInfo);
626 if(designInfoList.size() < 1)
627 throw new Exception(" Welcome to CDT, Looks like you dont have Design Yet... Lets create some....");
628 designResponse.setDesignInfoList(designInfoList);
629 ObjectMapper mapper = new ObjectMapper();
630 String jsonString = mapper.writeValueAsString(designResponse);
631 log.info("Info : " + jsonString);
636 log.error("Error while Starting getDesgins DB operation : ",e);