2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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.
20 * ============LICENSE_END=========================================================
23 package org.onap.appc.design.dbervices;
25 import com.att.eelf.configuration.EELFLogger;
26 import com.att.eelf.configuration.EELFManager;
27 import com.fasterxml.jackson.core.JsonParser;
28 import com.fasterxml.jackson.databind.JsonNode;
29 import com.fasterxml.jackson.databind.ObjectMapper;
30 import java.sql.ResultSet;
31 import java.sql.SQLException;
32 import java.util.ArrayList;
33 import java.util.List;
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.adaptors.resource.sql.SqlResource;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
43 public class DesignDBService {
45 private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class);
46 private static DesignDBService dgGeneralDBService;
48 private static final String SUCCESS_JSON = "{\"update\" : \"success\" } ";
49 private static final String STATUS = "STATUS";
50 private static final String INFO_STR = "Info : ";
51 private static final String DB_OPERATION_ERROR = "Error while DB operation : ";
52 private static final String VNFC_TYPE = "vnfc-type";
53 private static final String QUERY_STR = "Query String :";
54 private static final String USER_ID = "userID";
56 private SvcLogicResource serviceLogic;
57 private DbService dbservice;
59 public static DesignDBService initialise() {
60 if (dgGeneralDBService == null) {
61 dgGeneralDBService = new DesignDBService();
63 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);
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 DBException(" 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
125 .get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) {
126 queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? ";
127 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
129 queryString = queryString + " ) AND USER = ? ";
131 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
132 log.info(QUERY_STR + queryString);
133 boolean data = dbservice.updateDBData(queryString, argList);
136 throw new DBException("Error while updating ProtocolReference");
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);
157 log.info("Record Deleted");
159 if (payloadObject.get(DesignServiceConstants.TEMPLATE) != null &&
160 !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty()) {
162 argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue());
167 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null &&
168 !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
170 queryString = queryString + " AND VNFC_TYPE = ? )";
172 queryString = queryString + " ) ";
174 log.info(QUERY_STR + queryString);
175 data = dbservice.updateDBData(queryString, argList);
178 throw new DBException("Error while updating ProtocolReference");
183 private String uploadArtifact(String payload, String requestID) throws Exception {
185 ObjectMapper objectMapper = new ObjectMapper();
186 objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
187 JsonNode payloadObject = objectMapper.readTree(payload);
188 log.info("Got upload Aritfact with Payload : " + payloadObject.asText());
190 ArtifactHandlerClient ac = new ArtifactHandlerClient();
191 String requestString = ac.createArtifactData(payload, requestID);
192 ac.execute(requestString, "POST");
193 int sdcArtifactId = getSDCArtifactIDbyRequestID(requestID);
194 int sdcReferenceId = getSDCReferenceID(payload);
195 createArtifactTrackingRecord(payload, requestID, sdcArtifactId, sdcReferenceId);
196 String status = getDataFromActionStatus(payload, STATUS);
197 if (status == null || status.isEmpty()) {
198 log.info("Action Status is: "+ status);
199 setActionStatus(payload, "Not Tested");
201 linkstatusRelationShip(sdcArtifactId, sdcReferenceId, payload);
203 } catch (Exception e) {
204 log.error("An error occured in uploadArtifact", e);
211 private void linkstatusRelationShip(int sdcArtifactId, int sdcReferenceId, String payload) throws Exception {
213 ObjectMapper objectMapper = new ObjectMapper();
214 JsonNode payloadObject = objectMapper.readTree(payload);
215 ArrayList<String> argList = new ArrayList<>();
216 argList.add(String.valueOf(sdcArtifactId));
217 argList.add(String.valueOf(sdcReferenceId));
218 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
219 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
220 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
223 "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " +
224 "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , "
225 + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
227 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
228 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
229 queryString = queryString + " AND VNFC_TYPE = ? GROUP BY VNF_TYPE HAVING COUNT(VNF_TYPE)>=1 ) )";
231 queryString = queryString + " GROUP BY VNF_TYPE HAVING COUNT(VNF_TYPE)>=1 ) ) ";
233 log.info(QUERY_STR + queryString);
234 boolean data = dbservice.updateDBData(queryString, argList);
237 throw new DBException("Error while updating RelationShip table");
242 private int getSDCReferenceID(String payload) throws Exception {
244 ObjectMapper objectMapper = new ObjectMapper();
245 JsonNode payloadObject = objectMapper.readTree(payload);
246 ArrayList<String> argList = new ArrayList<>();
247 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
249 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue());
250 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue());
252 String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? "
253 + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? ";
255 if (payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject
256 .get(DesignServiceConstants.ACTION).textValue().isEmpty()) {
257 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
258 queryString = queryString + " AND ACTION = ? ";
260 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
261 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
262 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
263 queryString = queryString + " AND VNFC_TYPE = ? ";
267 log.info(QUERY_STR + queryString);
268 ResultSet data = dbservice.getDBData(queryString, argList);
269 int sdcReferenceId = 0;
270 while (data.next()) {
271 sdcReferenceId = data.getInt("ASDC_REFERENCE_ID");
273 log.info("Got sdcReferenceId= " + sdcReferenceId);
274 return sdcReferenceId;
277 private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
278 String status = null;
279 ObjectMapper objectMapper = new ObjectMapper();
280 JsonNode payloadObject = objectMapper.readTree(payload);
281 ArrayList<String> argList = new ArrayList<>();
282 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
283 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
284 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
286 " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
287 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
288 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
289 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
290 queryString = queryString + " AND VNFC_TYPE = ? ";
292 log.info(QUERY_STR + queryString);
293 ResultSet data = dbservice.getDBData(queryString, argList);
294 while (data.next()) {
295 status = data.getString(STATUS);
297 log.info("DT_ACTION_STATUS Status = " + status);
301 private void setActionStatus(String payload, String status) throws Exception {
302 ObjectMapper objectMapper = new ObjectMapper();
303 JsonNode payloadObject = objectMapper.readTree(payload);
304 ArrayList<String> argList = new ArrayList<>();
305 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
306 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
308 String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); ";
309 if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
310 .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
311 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
312 log.info("Vnfc-Type: " + 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 log.info("QueryString: " + insertQuery);
326 log.info("Arguments List: " + argList);
327 boolean updateStatus = dbservice.updateDBData(insertQuery, argList);
329 throw new DBException("Error while updating Action Status");
332 private void createArtifactTrackingRecord(String payload, String requestID, int sdcArtifactId, int sdcReferenceId)
335 ObjectMapper objectMapper = new ObjectMapper();
336 JsonNode payloadObject = objectMapper.readTree(payload);
338 ArrayList<String> argList = new ArrayList<>();
339 argList.add(String.valueOf(sdcArtifactId));
340 argList.add(String.valueOf(sdcReferenceId));
341 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
342 if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null && !payloadObject
343 .get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) {
344 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
349 if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null && !payloadObject
350 .get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) {
351 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
356 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' )";
358 log.info(QUERY_STR + queryString);
359 boolean data = dbservice.updateDBData(queryString, argList);
361 throw new DBException("Error Updating DT_ARTIFACT_TRACKING ");
365 private int getSDCArtifactIDbyRequestID(String requestID) throws Exception {
366 log.info("Starting getArtifactIDbyRequestID DB Operation");
369 ArrayList<String> argList = new ArrayList<>();
370 argList.add("TLSUUID" + requestID);
371 String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? ";
372 log.info(QUERY_STR + queryString);
373 ResultSet data = dbservice.getDBData(queryString, argList);
374 while (data.next()) {
375 artifactId = data.getInt("ASDC_ARTIFACTS_ID");
377 } catch (Exception e) {
378 log.error("An error occurred in getSDCArtifactIDbyRequestID", e);
381 log.info("Got SDC_ARTIFACTS_ID As :" + artifactId);
386 private String getArtifact(String payload, String requestID) throws Exception {
387 log.info("Starting getArtifact DB Operation");
389 ObjectMapper objectMapper = new ObjectMapper();
390 JsonNode payloadObject = objectMapper.readTree(payload);
391 ArrayList<String> argList = new ArrayList<>();
392 argList.add(payloadObject.get("artifact-name").textValue());
393 argList.add(payloadObject.get("artifact-type").textValue());
395 String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " +
396 " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? ";
398 log.info(QUERY_STR + queryString);
399 ResultSet data = dbservice.getDBData(queryString, argList);
400 String artifactContent = null;
401 int hightestVerion = -1;
402 while (data.next()) {
403 int version = data.getInt("INTERNAL_VERSION");
404 if (hightestVerion < version) {
405 artifactContent = data.getString("ARTIFACT_CONTENT");
408 if (artifactContent == null || artifactContent.isEmpty()) {
409 throw new DBException(
410 "Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue());
412 DesignResponse designResponse = new DesignResponse();
413 List<ArtifactInfo> artifactInfoList = new ArrayList<>();
414 ArtifactInfo artifactInfo = new ArtifactInfo();
415 artifactInfo.setArtifact_content(artifactContent);
416 artifactInfoList.add(artifactInfo);
417 designResponse.setArtifactInfo(artifactInfoList);
418 ObjectMapper mapper = new ObjectMapper();
419 String jsonString = mapper.writeValueAsString(designResponse);
420 log.info(INFO_STR + jsonString);
422 } catch (Exception e) {
423 log.error(DB_OPERATION_ERROR, e);
428 private String setStatus(String payload, String requestID) throws Exception {
430 log.info("Starting getStatus DB Operation");
432 ObjectMapper objectMapper = new ObjectMapper();
433 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(USER_ID).textValue());
440 argList.add(payloadObject.get("vnf-type").textValue());
443 " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? "
444 + " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
445 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
446 + " and DAS.VNF_TYPE = ? ";
448 if (payloadObject.get(VNFC_TYPE) != null && !payloadObject.get(VNFC_TYPE).textValue().isEmpty()) {
449 argList.add(payloadObject.get(VNFC_TYPE).textValue());
450 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
453 log.info(QUERY_STR + queryString);
455 DesignResponse designResponse = new DesignResponse();
456 designResponse.setUserId(payloadObject.get(USER_ID).textValue());
457 boolean update = dbservice.updateDBData(queryString, argList);
459 throw new DBException("Sorry .....Something went wrong while updating the Status");
462 ObjectMapper mapper = new ObjectMapper();
463 String jsonString = mapper.writeValueAsString(designResponse);
464 log.info(INFO_STR + jsonString);
466 } catch (Exception e) {
467 log.error(DB_OPERATION_ERROR, e);
472 private String getStatus(String payload, String requestID) throws Exception {
473 log.info("Starting getStatus DB Operation");
475 String vnfcType = null;
476 ObjectMapper objectMapper = new ObjectMapper();
477 JsonNode payloadObject = objectMapper.readTree(payload);
478 String userID = payloadObject.get(USER_ID).textValue();
479 String vnfType = payloadObject.get("vnf-type").textValue();
480 if (payloadObject.get(VNFC_TYPE) != null) {
481 vnfcType = payloadObject.get(VNFC_TYPE).textValue();
483 ArrayList<String> argList = new ArrayList<>();
486 argList.add(vnfType);
488 String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS "
489 + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " +
490 " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
491 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
492 + " and DAS.VNF_TYPE = ? ";
494 if (vnfcType != null && !vnfcType.isEmpty()) {
495 argList.add(vnfcType);
496 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
499 log.info(QUERY_STR + queryString);
501 DesignResponse designResponse = new DesignResponse();
502 designResponse.setUserId(userID);
503 List<StatusInfo> statusInfoList = new ArrayList<>();
504 ResultSet data = dbservice.getDBData(queryString, argList);
505 while (data.next()) {
506 StatusInfo statusInfo = new StatusInfo();
507 statusInfo.setAction(data.getString("ACTION"));
508 statusInfo.setAction_status(data.getString(STATUS));
509 statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS"));
510 statusInfo.setVnf_type(data.getString("VNF_TYPE"));
511 statusInfo.setVnfc_type(data.getString("VNFC_TYPE"));
512 statusInfoList.add(statusInfo);
515 if (statusInfoList.isEmpty()) {
516 throw new DBException(
517 "OOPS !!!! No VNF information available for VNF-TYPE : " + vnfType + " for User : " + userID);
519 designResponse.setStatusInfoList(statusInfoList);
520 ObjectMapper mapper = new ObjectMapper();
521 String jsonString = mapper.writeValueAsString(designResponse);
522 log.info(INFO_STR + jsonString);
524 } catch (SQLException e) {
525 log.error(DB_OPERATION_ERROR, e);
527 } catch (Exception e) {
528 log.error(DB_OPERATION_ERROR + e.getMessage());
529 log.error("Exception : ", e);
534 private String getGuiReference(String payload, String requestID) {
535 // TODO Auto-generated method stub
539 private String getArtifactReference(String payload, String requestID) {
540 // TODO Auto-generated method stub
544 private String getDesigns(String payload, String requestID) throws Exception {
547 log.info("Starting getDesigns DB Operation");
550 ObjectMapper objectMapper = new ObjectMapper();
551 JsonNode payloadObject = objectMapper.readTree(payload);
552 String userID = payloadObject.get(USER_ID).textValue();
553 String filterKey = null;
554 if (payloadObject.hasNonNull("filter")) {
555 filterKey = payloadObject.get("filter").textValue();
557 ArrayList<String> argList = new ArrayList<>();
560 if (filterKey != null) {
562 "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from "
564 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , "
565 + DesignServiceConstants.DB_SDC_REFERENCE +
566 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? and AR.ARTIFACT_NAME like '%"
567 + filterKey + "%' GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
570 "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from "
572 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , "
573 + DesignServiceConstants.DB_SDC_REFERENCE +
574 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
576 DesignResponse designResponse = new DesignResponse();
577 designResponse.setUserId(userID);
578 List<DesignInfo> designInfoList = new ArrayList<>();
579 ResultSet data = dbservice.getDBData(queryString, argList);
580 while (data.next()) {
581 DesignInfo designInfo = new DesignInfo();
582 designInfo.setInCart(data.getString("IN_CART"));
583 designInfo.setProtocol(data.getString("PROTOCOL"));
584 designInfo.setVnf_type(data.getString("VNF_TYPE"));
585 designInfo.setVnfc_type(data.getString("VNFC_TYPE"));
586 designInfo.setAction(data.getString("ACTION"));
587 designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE"));
588 designInfo.setArtifact_name(data.getString("ARTIFACT_NAME"));
589 designInfoList.add(designInfo);
591 if (designInfoList.isEmpty()) {
592 throw new DBException(
593 " Welcome to CDT, Looks like you dont have Design Yet... Lets create some....");
595 designResponse.setDesignInfoList(designInfoList);
596 ObjectMapper mapper = new ObjectMapper();
597 String jsonString = mapper.writeValueAsString(designResponse);
598 log.info(INFO_STR + jsonString);
600 } catch (Exception e) {
601 log.error("Error while Starting getDesgins DB operation : ", e);