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 com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import com.fasterxml.jackson.core.JsonParser;
30 import com.fasterxml.jackson.databind.JsonNode;
31 import com.fasterxml.jackson.databind.ObjectMapper;
32 import java.sql.ResultSet;
33 import java.sql.SQLException;
34 import java.util.ArrayList;
35 import java.util.List;
36 import org.onap.appc.design.data.ArtifactInfo;
37 import org.onap.appc.design.data.DesignInfo;
38 import org.onap.appc.design.data.DesignResponse;
39 import org.onap.appc.design.data.StatusInfo;
40 import org.onap.appc.design.services.util.ArtifactHandlerClient;
41 import org.onap.appc.design.services.util.DesignServiceConstants;
42 import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
43 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
45 public class DesignDBService {
47 private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class);
48 private static DesignDBService dgGeneralDBService;
50 private static final String SUCCESS_JSON = "{\"update\" : \"success\" } ";
51 private static final String STATUS = "STATUS";
52 private static final String INFO_STR = "Info : ";
53 private static final String DB_OPERATION_ERROR = "Error while DB operation : ";
54 private static final String VNFC_TYPE = "vnfc-type";
55 private static final String QUERY_STR = "Query String :";
56 private static final String USER_ID = "userID";
58 private SvcLogicResource serviceLogic;
59 private DbService dbservice;
61 public static DesignDBService initialise() {
62 if (dgGeneralDBService == null) {
63 dgGeneralDBService = new DesignDBService();
65 return dgGeneralDBService;
68 private DesignDBService() {
69 if (serviceLogic == null) {
70 serviceLogic = new SqlResource();
74 public String execute(String action, String payload, String requestID) throws Exception {
76 log.info("Received execute request for action : " + action + " with Payload : " + payload);
77 RequestValidator.validate(action, payload);
79 dbservice = new DbService();
81 case DesignServiceConstants.GETDESIGNS:
82 response = getDesigns(payload, requestID);
84 case DesignServiceConstants.ADDINCART:
85 response = setInCart(payload, requestID);
87 case DesignServiceConstants.GETARTIFACTREFERENCE:
88 response = getArtifactReference(payload, requestID);
90 case DesignServiceConstants.GETARTIFACT:
91 response = getArtifact(payload, requestID);
93 case DesignServiceConstants.GETGUIREFERENCE:
94 response = getGuiReference(payload, requestID);
96 case DesignServiceConstants.GETSTATUS:
97 response = getStatus(payload, requestID);
99 case DesignServiceConstants.SETSTATUS:
100 response = setStatus(payload, requestID);
102 case DesignServiceConstants.UPLOADARTIFACT:
103 response = uploadArtifact(payload, requestID);
105 case DesignServiceConstants.SETPROTOCOLREFERENCE:
106 response = setProtocolReference(payload, requestID);
109 throw new DBException(" Action " + action + " not found while processing request ");
115 private String setInCart(String payload, String requestID) throws Exception {
117 ObjectMapper objectMapper = new ObjectMapper();
118 JsonNode payloadObject = objectMapper.readTree(payload);
119 ArrayList<String> argList = new ArrayList<>();
120 argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue());
121 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
123 String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID IN "
124 + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? ";
126 if (payloadObject.get(DesignServiceConstants.VNF_TYPE) != null && !payloadObject
127 .get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) {
128 queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? ";
129 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
131 queryString = queryString + " ) AND USER = ? ";
133 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
134 log.info(QUERY_STR + queryString);
135 boolean data = dbservice.updateDBData(queryString, argList);
138 throw new DBException("Error while updating ProtocolReference");
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);
159 log.info("Record Deleted");
161 if (payloadObject.get(DesignServiceConstants.TEMPLATE) != null &&
162 !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty()) {
164 argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue());
169 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null &&
170 !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
172 queryString = queryString + " AND VNFC_TYPE = ? )";
174 queryString = queryString + " ) ";
176 log.info(QUERY_STR + queryString);
177 data = dbservice.updateDBData(queryString, argList);
180 throw new DBException("Error while updating ProtocolReference");
185 private String uploadArtifact(String payload, String requestID) throws Exception {
187 ObjectMapper objectMapper = new ObjectMapper();
188 objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
189 JsonNode payloadObject = objectMapper.readTree(payload);
190 log.info("Got upload Aritfact with Payload : " + payloadObject.asText());
192 ArtifactHandlerClient ac = new ArtifactHandlerClient();
193 String requestString = ac.createArtifactData(payload, requestID);
194 ac.execute(requestString, "POST");
195 int sdcArtifactId = getSDCArtifactIDbyRequestID(requestID);
196 int sdcReferenceId = getSDCReferenceID(payload);
197 createArtifactTrackingRecord(payload, requestID, sdcArtifactId, sdcReferenceId);
198 String status = getDataFromActionStatus(payload, STATUS);
199 if (status == null || status.isEmpty()) {
200 setActionStatus(payload, "Not Tested");
202 linkstatusRelationShip(sdcArtifactId, sdcReferenceId, payload);
204 } catch (Exception e) {
205 log.error("An error occured in uploadArtifact", e);
212 private void linkstatusRelationShip(int sdcArtifactId, int sdcReferenceId, String payload) throws Exception {
214 ObjectMapper objectMapper = new ObjectMapper();
215 JsonNode payloadObject = objectMapper.readTree(payload);
216 ArrayList<String> argList = new ArrayList<>();
217 argList.add(String.valueOf(sdcArtifactId));
218 argList.add(String.valueOf(sdcReferenceId));
219 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
220 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
221 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
224 "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " +
225 "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , "
226 + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
228 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
229 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
230 queryString = queryString + " AND VNFC_TYPE = ? ) )";
232 queryString = queryString + " ) ) ";
234 log.info(QUERY_STR + queryString);
235 boolean data = dbservice.updateDBData(queryString, argList);
238 throw new DBException("Error while updating RelationShip table");
243 private int getSDCReferenceID(String payload) throws Exception {
245 ObjectMapper objectMapper = new ObjectMapper();
246 JsonNode payloadObject = objectMapper.readTree(payload);
247 ArrayList<String> argList = new ArrayList<>();
248 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
250 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue());
251 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue());
253 String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? "
254 + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? ";
256 if (payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject
257 .get(DesignServiceConstants.ACTION).textValue().isEmpty()) {
258 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
259 queryString = queryString + " AND ACTION = ? ";
261 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
262 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
263 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
264 queryString = queryString + " AND VNFC_TYPE = ? ";
268 log.info(QUERY_STR + queryString);
269 ResultSet data = dbservice.getDBData(queryString, argList);
270 int sdcReferenceId = 0;
271 while (data.next()) {
272 sdcReferenceId = data.getInt("ASDC_REFERENCE_ID");
274 log.info("Got sdcReferenceId= " + sdcReferenceId);
275 return sdcReferenceId;
278 private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
279 String status = null;
280 ObjectMapper objectMapper = new ObjectMapper();
281 JsonNode payloadObject = objectMapper.readTree(payload);
282 ArrayList<String> argList = new ArrayList<>();
283 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
284 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
285 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
287 " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
288 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
289 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
290 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
291 queryString = queryString + " AND VNFC_TYPE = ? ";
293 log.info(QUERY_STR + queryString);
294 ResultSet data = dbservice.getDBData(queryString, argList);
295 while (data.next()) {
296 status = data.getString(STATUS);
298 log.info("DT_ACTION_STATUS Status = " + status);
302 private void setActionStatus(String payload, String status) throws Exception {
303 ObjectMapper objectMapper = new ObjectMapper();
304 JsonNode payloadObject = objectMapper.readTree(payload);
305 ArrayList<String> argList = new ArrayList<>();
306 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
307 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
309 String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); ";
310 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
311 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
312 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
316 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
317 if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null && !payloadObject
318 .get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) {
319 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
325 boolean updateStatus = dbservice.updateDBData(insertQuery, argList);
327 throw new DBException("Error while updating Action Status");
330 private void createArtifactTrackingRecord(String payload, String requestID, int sdcArtifactId, int sdcReferenceId)
333 ObjectMapper objectMapper = new ObjectMapper();
334 JsonNode payloadObject = objectMapper.readTree(payload);
336 ArrayList<String> argList = new ArrayList<>();
337 argList.add(String.valueOf(sdcArtifactId));
338 argList.add(String.valueOf(sdcReferenceId));
339 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
340 if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null && !payloadObject
341 .get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) {
342 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
347 if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null && !payloadObject
348 .get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) {
349 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
354 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' )";
356 log.info(QUERY_STR + queryString);
357 boolean data = dbservice.updateDBData(queryString, argList);
359 throw new DBException("Error Updating DT_ARTIFACT_TRACKING ");
363 private int getSDCArtifactIDbyRequestID(String requestID) throws Exception {
364 log.info("Starting getArtifactIDbyRequestID DB Operation");
367 ArrayList<String> argList = new ArrayList<>();
368 argList.add("TLSUUID" + requestID);
369 String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? ";
370 log.info(QUERY_STR + queryString);
371 ResultSet data = dbservice.getDBData(queryString, argList);
372 while (data.next()) {
373 artifactId = data.getInt("ASDC_ARTIFACTS_ID");
375 } catch (Exception e) {
376 log.error("An error occurred in getSDCArtifactIDbyRequestID", e);
379 log.info("Got SDC_ARTIFACTS_ID As :" + artifactId);
384 private String getArtifact(String payload, String requestID) throws Exception {
385 log.info("Starting getArtifact DB Operation");
387 ObjectMapper objectMapper = new ObjectMapper();
388 JsonNode payloadObject = objectMapper.readTree(payload);
389 ArrayList<String> argList = new ArrayList<>();
390 argList.add(payloadObject.get("artifact-name").textValue());
391 argList.add(payloadObject.get("artifact-type").textValue());
393 String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " +
394 " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? ";
396 log.info(QUERY_STR + queryString);
397 ResultSet data = dbservice.getDBData(queryString, argList);
398 String artifactContent = null;
399 int hightestVerion = -1;
400 while (data.next()) {
401 int version = data.getInt("INTERNAL_VERSION");
402 if (hightestVerion < version) {
403 artifactContent = data.getString("ARTIFACT_CONTENT");
406 if (artifactContent == null || artifactContent.isEmpty()) {
407 throw new DBException(
408 "Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue());
410 DesignResponse designResponse = new DesignResponse();
411 List<ArtifactInfo> artifactInfoList = new ArrayList<>();
412 ArtifactInfo artifactInfo = new ArtifactInfo();
413 artifactInfo.setArtifact_content(artifactContent);
414 artifactInfoList.add(artifactInfo);
415 designResponse.setArtifactInfo(artifactInfoList);
416 ObjectMapper mapper = new ObjectMapper();
417 String jsonString = mapper.writeValueAsString(designResponse);
418 log.info(INFO_STR + jsonString);
420 } catch (Exception e) {
421 log.error(DB_OPERATION_ERROR, e);
426 private String setStatus(String payload, String requestID) throws Exception {
428 log.info("Starting getStatus DB Operation");
430 ObjectMapper objectMapper = new ObjectMapper();
431 JsonNode payloadObject = objectMapper.readTree(payload);
433 ArrayList<String> argList = new ArrayList<>();
434 argList.add(payloadObject.get("artifact_status").textValue());
435 argList.add(payloadObject.get("action_status").textValue());
437 argList.add(payloadObject.get(USER_ID).textValue());
438 argList.add(payloadObject.get("vnf-type").textValue());
441 " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? "
442 + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
443 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
444 + " and DAS.VNF_TYPE = ? ";
446 if (payloadObject.get(VNFC_TYPE) != null && !payloadObject.get(VNFC_TYPE).textValue().isEmpty()) {
447 argList.add(payloadObject.get(VNFC_TYPE).textValue());
448 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
451 log.info(QUERY_STR + queryString);
453 DesignResponse designResponse = new DesignResponse();
454 designResponse.setUserId(payloadObject.get(USER_ID).textValue());
455 boolean update = dbservice.updateDBData(queryString, argList);
457 throw new DBException("Sorry .....Something went wrong while updating the Status");
460 ObjectMapper mapper = new ObjectMapper();
461 String jsonString = mapper.writeValueAsString(designResponse);
462 log.info(INFO_STR + jsonString);
464 } catch (Exception e) {
465 log.error(DB_OPERATION_ERROR, e);
470 private String getStatus(String payload, String requestID) throws Exception {
471 log.info("Starting getStatus DB Operation");
473 String vnfcType = null;
474 ObjectMapper objectMapper = new ObjectMapper();
475 JsonNode payloadObject = objectMapper.readTree(payload);
476 String userID = payloadObject.get(USER_ID).textValue();
477 String vnfType = payloadObject.get("vnf-type").textValue();
478 if (payloadObject.get(VNFC_TYPE) != null) {
479 vnfcType = payloadObject.get(VNFC_TYPE).textValue();
481 ArrayList<String> argList = new ArrayList<>();
484 argList.add(vnfType);
486 String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS "
487 + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " +
488 " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
489 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
490 + " and DAS.VNF_TYPE = ? ";
492 if (vnfcType != null && !vnfcType.isEmpty()) {
493 argList.add(vnfcType);
494 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
497 log.info(QUERY_STR + queryString);
499 DesignResponse designResponse = new DesignResponse();
500 designResponse.setUserId(userID);
501 List<StatusInfo> statusInfoList = new ArrayList<>();
502 ResultSet data = dbservice.getDBData(queryString, argList);
503 while (data.next()) {
504 StatusInfo statusInfo = new StatusInfo();
505 statusInfo.setAction(data.getString("ACTION"));
506 statusInfo.setAction_status(data.getString(STATUS));
507 statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS"));
508 statusInfo.setVnf_type(data.getString("VNF_TYPE"));
509 statusInfo.setVnfc_type(data.getString("VNFC_TYPE"));
510 statusInfoList.add(statusInfo);
513 if (statusInfoList.isEmpty()) {
514 throw new DBException(
515 "OOPS !!!! No VNF information available for VNF-TYPE : " + vnfType + " for User : " + userID);
517 designResponse.setStatusInfoList(statusInfoList);
518 ObjectMapper mapper = new ObjectMapper();
519 String jsonString = mapper.writeValueAsString(designResponse);
520 log.info(INFO_STR + jsonString);
522 } catch (SQLException e) {
523 log.error(DB_OPERATION_ERROR, e);
525 } catch (Exception e) {
526 log.error(DB_OPERATION_ERROR + e.getMessage());
527 log.error("Exception : ", e);
532 private String getGuiReference(String payload, String requestID) {
533 // TODO Auto-generated method stub
537 private String getArtifactReference(String payload, String requestID) {
538 // TODO Auto-generated method stub
542 private String getDesigns(String payload, String requestID) throws Exception {
545 log.info("Starting getDesigns DB Operation");
548 ObjectMapper objectMapper = new ObjectMapper();
549 JsonNode payloadObject = objectMapper.readTree(payload);
550 String userID = payloadObject.get(USER_ID).textValue();
551 String filterKey = null;
552 if (payloadObject.hasNonNull("filter")) {
553 filterKey = payloadObject.get("filter").textValue();
555 ArrayList<String> argList = new ArrayList<>();
558 if (filterKey != null) {
560 "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from "
562 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , "
563 + DesignServiceConstants.DB_SDC_REFERENCE +
564 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? and AR.ARTIFACT_NAME like '%"
565 + filterKey + "%' GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
568 "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from "
570 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , "
571 + DesignServiceConstants.DB_SDC_REFERENCE +
572 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
574 DesignResponse designResponse = new DesignResponse();
575 designResponse.setUserId(userID);
576 List<DesignInfo> designInfoList = new ArrayList<>();
577 ResultSet data = dbservice.getDBData(queryString, argList);
578 while (data.next()) {
579 DesignInfo designInfo = new DesignInfo();
580 designInfo.setInCart(data.getString("IN_CART"));
581 designInfo.setProtocol(data.getString("PROTOCOL"));
582 designInfo.setVnf_type(data.getString("VNF_TYPE"));
583 designInfo.setVnfc_type(data.getString("VNFC_TYPE"));
584 designInfo.setAction(data.getString("ACTION"));
585 designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE"));
586 designInfo.setArtifact_name(data.getString("ARTIFACT_NAME"));
587 designInfoList.add(designInfo);
589 if (designInfoList.isEmpty()) {
590 throw new DBException(
591 " Welcome to CDT, Looks like you dont have Design Yet... Lets create some....");
593 designResponse.setDesignInfoList(designInfoList);
594 ObjectMapper mapper = new ObjectMapper();
595 String jsonString = mapper.writeValueAsString(designResponse);
596 log.info(INFO_STR + jsonString);
598 } catch (Exception e) {
599 log.error("Error while Starting getDesgins DB operation : ", e);