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.JsonParser;
46 import com.fasterxml.jackson.core.JsonProcessingException;
47 import com.fasterxml.jackson.databind.JsonNode;
48 import com.fasterxml.jackson.databind.ObjectMapper;
50 public class DesignDBService {
52 private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class);
53 private SvcLogicResource serviceLogic;
54 private static DesignDBService dgGeneralDBService = null;
55 private static DBResourceManager jdbcDataSource;
57 DbService dbservice = null;
58 private static Properties props;
59 public static DesignDBService initialise() {
60 if (dgGeneralDBService == null) {
61 dgGeneralDBService = new DesignDBService();
63 return dgGeneralDBService;
65 private DesignDBService() {
66 if (serviceLogic == null) {
67 serviceLogic = new SqlResource();
71 public String execute(String action, String payload, String requestID) throws Exception {
73 log.info("Received execute request for action : " + action + " with Payload : "+ payload );
74 RequestValidator.validate(action, payload);
75 String response = null;
76 dbservice = new DbService();
78 case DesignServiceConstants.GETDESIGNS:
79 response = getDesigns(payload,requestID );
81 case DesignServiceConstants.ADDINCART:
82 response= setInCart(payload, requestID);
84 case DesignServiceConstants.GETARTIFACTREFERENCE:
85 response= getArtifactReference(payload, requestID);
87 case DesignServiceConstants.GETARTIFACT:
88 response= getArtifact(payload, requestID);
90 case DesignServiceConstants.GETGUIREFERENCE:
91 response= getGuiReference(payload, requestID);
93 case DesignServiceConstants.GETSTATUS:
94 response= getStatus(payload, requestID);
96 case DesignServiceConstants.SETSTATUS:
97 response= setStatus(payload, requestID);
99 case DesignServiceConstants.UPLOADARTIFACT:
100 response= uploadArtifact(payload, requestID);
102 case DesignServiceConstants.SETPROTOCOLREFERENCE:
103 response= setProtocolReference(payload, requestID);
106 throw new Exception(" Action " + action + " not found while processing request ");
112 private String setInCart(String payload, String requestID) throws Exception {
114 ObjectMapper objectMapper = new ObjectMapper();
115 JsonNode payloadObject = objectMapper.readTree(payload);
116 ArrayList<String> argList = new ArrayList<>();
117 argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue());
118 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
120 String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID IN "
121 + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? " ;
123 if(payloadObject.get(DesignServiceConstants.VNF_TYPE) != null &&! payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) {
124 queryString = queryString + " AND VNFC_TYPE = ? ) AND USER = ? " ;
125 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
128 queryString = queryString + " ) AND USER = ? " ;
131 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
133 log.info("Query String :" + queryString);
134 boolean data = dbservice.updateDBData(queryString, argList);
137 throw new Exception("Error while updating ProtocolReference");
139 return "{\"update\" : \"success\" } ";
142 private String setProtocolReference(String payload, String requestID) throws Exception {
144 ObjectMapper objectMapper = new ObjectMapper();
145 JsonNode payloadObject = objectMapper.readTree(payload);
146 ArrayList<String> argList = new ArrayList<>();
148 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
149 argList.add(payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue());
150 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
151 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
153 String queryString = " DELETE FROM PROTOCOL_REFERENCE WHERE ACTION = ? AND ACTION_LEVEL AND VNF_TYPE= ? AND PROTOCOL = ? " ;
155 log.info("Delete Query String :" + queryString);
156 boolean data = dbservice.updateDBData(queryString, argList);
158 log.info("Record Deleted");
160 if((payloadObject.get(DesignServiceConstants.TEMPLATE) != null && !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty()))
161 argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue());
165 String insertString = "INSERT INTO PROTOCOL_REFERENCE VALUES (?,?,?,?,?,SYSDATE()) ";
167 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
168 queryString = queryString + " AND VNFC_TYPE = ? )" ;
171 queryString = queryString + " ) ";
173 log.info("Query String :" + queryString);
174 data = dbservice.updateDBData(queryString, argList);
177 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 objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
184 JsonNode payloadObject = objectMapper.readTree(payload);
185 log.info("Got upload Aritfact with Payload : " + payloadObject.asText());
187 ArtifactHandlerClient ac = new ArtifactHandlerClient();
188 String requestString = ac.createArtifactData(payload, requestID);
189 ac.execute(requestString, "POST");
190 int sdc_artifact_id = getSDCArtifactIDbyRequestID(requestID);
191 int sdc_reference_id = getSDCReferenceID(payload);
192 createArtifactTrackingRecord(payload, requestID,sdc_artifact_id, sdc_reference_id );
193 String status = getDataFromActionStatus(payload, "STATUS");
194 if(status == null || status.isEmpty())
195 setActionStatus(payload, "Not Tested");
196 linkstatusRelationShip(sdc_artifact_id,sdc_reference_id, payload);
203 return "{\"update\" : \"success\" } ";
207 private void linkstatusRelationShip(int sdc_artifact_id, int sdc_reference_id, String payload) throws Exception {
209 ObjectMapper objectMapper = new ObjectMapper();
210 JsonNode payloadObject = objectMapper.readTree(payload);
211 ArrayList<String> argList = new ArrayList<>();
212 argList.add(String.valueOf(sdc_artifact_id));
213 argList.add(String.valueOf(sdc_reference_id));
214 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
215 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
216 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
218 String queryString = "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " +
219 "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , "
220 + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? " ;
222 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && ! payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
223 queryString = queryString + " AND VNFC_TYPE = ? ) )" ;
226 queryString = queryString + " ) ) ";
228 log.info("Query String :" + queryString);
229 boolean data = dbservice.updateDBData(queryString, argList);
232 throw new Exception("Error while updating RealtionShip table");
235 private int getSDCReferenceID(String payload) throws Exception {
237 String vnfc_type = null;
238 ObjectMapper objectMapper = new ObjectMapper();
239 JsonNode payloadObject = objectMapper.readTree(payload);
240 ArrayList<String> argList = new ArrayList<>();
241 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
243 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue());
244 argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue());
246 String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ? "
247 + " AND ARTIFACT_TYPE = ? AND ARTIFACT_NAME = ? " ;
249 if(payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject.get(DesignServiceConstants.ACTION).textValue().isEmpty()){
250 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
251 queryString = queryString + " AND ACTION = ? ";
253 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
254 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
255 queryString = queryString + " AND VNFC_TYPE = ? ";
259 log.info("Query String :" + queryString);
260 ResultSet data = dbservice.getDBData(queryString, argList);
261 int sdc_reference_id = 0;
263 sdc_reference_id = data.getInt("ASDC_REFERENCE_ID");
265 log.info("Got sdc_reference_id = " + sdc_reference_id );
266 return sdc_reference_id;
270 private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
271 String status = null ;
272 ObjectMapper objectMapper = new ObjectMapper();
273 JsonNode payloadObject = objectMapper.readTree(payload);
274 ArrayList<String> argList = new ArrayList<>();
275 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
276 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
277 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
278 String queryString = " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
279 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
280 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
281 queryString = queryString + " AND VNFC_TYPE = ? ";
283 log.info("Query String :" + queryString);
284 ResultSet data = dbservice.getDBData(queryString, argList);
286 status = data.getString("STATUS");
288 log.info("DT_ACTION_STATUS Status = " + status );
292 private boolean setActionStatus(String payload, String status) throws Exception {
293 ObjectMapper objectMapper = new ObjectMapper();
294 JsonNode payloadObject = objectMapper.readTree(payload);
295 ArrayList<String> argList = new ArrayList<>();
296 argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
297 argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
300 String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); ";
301 if(payloadObject.get(DesignServiceConstants.VNFC_TYPE) !=null && !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()){
302 argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
307 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
308 if(payloadObject.get(DesignServiceConstants.TECHNOLOGY) !=null && !payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()){
309 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
316 boolean updateStatus = dbservice.updateDBData(insertQuery, argList);
318 throw new Exception("Error while updating Action Status");
322 private void createArtifactTrackingRecord(String payload, String requestID, int sdc_artifact_id, int sdc_reference_id) throws Exception {
323 String vnfc_type = null;
324 ObjectMapper objectMapper = new ObjectMapper();
325 JsonNode payloadObject = objectMapper.readTree(payload);
327 ArrayList<String> argList = new ArrayList<>();
328 argList.add(String.valueOf(sdc_artifact_id));
329 argList.add(String.valueOf(sdc_reference_id));
330 argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
331 if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null &&! payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty())
332 argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
336 if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null &&! payloadObject.get(DesignServiceConstants.PROTOCOL).textValue().isEmpty())
337 argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
342 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' )" ;
344 log.info("Query String :" + queryString);
345 boolean data = dbservice.updateDBData(queryString, argList);
347 throw new Exception("Error Updating DT_ARTIFACT_TRACKING ");
352 private int getSDCArtifactIDbyRequestID(String requestID) throws Exception {
353 log.info("Starting getArtifactIDbyRequestID DB Operation");
356 ArrayList<String> argList = new ArrayList<>();
357 argList.add("TLSUUID" + requestID);
358 String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? ";
359 log.info("Query String :" + queryString);
360 ResultSet data = dbservice.getDBData(queryString, argList);
362 artifact_id = data.getInt("ASDC_ARTIFACTS_ID");
369 log.info("Got SDC_ARTIFACTS_ID As :" + artifact_id);
374 private String getArtifact(String payload, String requestID) throws Exception {
375 String fn = "DBService.getStatus ";
376 log.info("Starting getArtifact DB Operation");
378 String vnfc_type = null;
379 ObjectMapper objectMapper = new ObjectMapper();
380 JsonNode payloadObject = objectMapper.readTree(payload);
381 ArrayList<String> argList = new ArrayList<>();
382 argList.add(payloadObject.get("artifact-name").textValue());
383 argList.add(payloadObject.get("artifact-type").textValue());
385 String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " +
386 " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ? " ;
388 log.info("Query String :" + queryString);
389 ResultSet data = dbservice.getDBData(queryString, argList);
390 String artifact_content = null;
391 int hightestVerion = -1 ;
393 int version = data.getInt("INTERNAL_VERSION");
394 if(hightestVerion < version)
395 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);
406 ObjectMapper mapper = new ObjectMapper();
407 String jsonString = mapper.writeValueAsString(designResponse);
408 log.info("Info : " + jsonString);
411 catch(SQLException e)
413 log.error("Error while DB operation : " + e.getMessage());
419 log.error("Error while DB operation : " + e.getMessage());
425 private String setStatus(String payload, String requestID) throws Exception {
426 String fn = "DBService.getStatus ";
427 log.info("Starting getStatus DB Operation");
429 String vnfc_type = null;
430 ObjectMapper objectMapper = new ObjectMapper();
431 JsonNode payloadObject = objectMapper.readTree(payload);
434 ArrayList<String> argList = new ArrayList<>();
435 argList.add(payloadObject.get("artifact_status").textValue());
436 argList.add(payloadObject.get("action_status").textValue());
438 argList.add(payloadObject.get("userID").textValue());
439 argList.add(payloadObject.get("vnf-type").textValue());
441 String queryString = " 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 String :" + queryString);
453 DesignResponse designResponse = new DesignResponse();
454 designResponse.setUserId(payloadObject.get("userID").textValue());
455 List<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
456 boolean update = dbservice.updateDBData(queryString, argList);
458 throw new Exception("Sorry .....Something went wrong while updating the Status");
460 ObjectMapper mapper = new ObjectMapper();
461 String jsonString = mapper.writeValueAsString(designResponse);
462 log.info("Info : " + jsonString);
465 catch(SQLException e)
467 log.error("Error while DB operation : " + e.getMessage());
473 log.error("Error while DB operation : " + e.getMessage());
478 private String getStatus(String payload, String requestID) throws Exception {
479 String fn = "DBService.getStatus ";
480 log.info("Starting getStatus DB Operation");
482 String vnfc_type = null;
483 ObjectMapper objectMapper = new ObjectMapper();
484 JsonNode payloadObject = objectMapper.readTree(payload);
485 String UserID = payloadObject.get("userID").textValue();
486 String vnf_type = payloadObject.get("vnf-type").textValue();
487 if(payloadObject.get("vnfc-type") != null )
488 vnfc_type = payloadObject.get("vnfc-type").textValue();
489 ArrayList<String> argList = new ArrayList<>();
492 argList.add(vnf_type);
494 String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE, DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS "
495 + "from DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " +
496 " where DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
497 + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
498 + " and DAS.VNF_TYPE = ? " ;
500 if(vnfc_type !=null && ! vnfc_type.isEmpty()){
501 argList.add(vnfc_type);
502 queryString = queryString + " and DAS.VNFC_TYPE = ? ";
505 log.info("Query String :" + queryString);
507 DesignResponse designResponse = new DesignResponse();
508 designResponse.setUserId(UserID);
509 List<StatusInfo> statusInfoList = new ArrayList<StatusInfo>();
510 ResultSet data = dbservice.getDBData(queryString, argList);
512 StatusInfo statusInfo = new StatusInfo();
513 statusInfo.setAction(data.getString("ACTION"));
514 statusInfo.setAction_status(data.getString("STATUS"));
515 statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS"));
516 statusInfo.setVnf_type(data.getString("VNF_TYPE"));
517 statusInfo.setVnfc_type(data.getString("VNFC_TYPE"));
518 statusInfoList.add(statusInfo);
521 if(statusInfoList.size() < 1)
522 throw new Exception("OOPS !!!! No VNF information available for VNF-TYPE : " + vnf_type + " for User : " + UserID);
523 designResponse.setStatusInfoList(statusInfoList);
524 ObjectMapper mapper = new ObjectMapper();
525 String jsonString = mapper.writeValueAsString(designResponse);
526 log.info("Info : " + jsonString);
529 catch(SQLException e)
531 log.error("Error while DB operation : " + e.getMessage());
537 log.error("Error while DB operation : " + e.getMessage());
538 log.error("Exception : ",e);
542 private String getGuiReference(String payload, String requestID) {
543 // TODO Auto-generated method stub
546 private String getArtifactReference(String payload, String requestID) {
547 // TODO Auto-generated method stub
550 private String getAddInCart(String payload, String requestID) {
551 // TODO Auto-generated method stub
555 // private String getDesigns(String payload, String requestID) throws SQLException, JsonProcessingException, IOException, SvcLogicException {
557 // String fn = "DBService.getDesigns ";
558 // QueryStatus status = null;
559 // ObjectMapper objectMapper = new ObjectMapper();
560 // JsonNode jnode = objectMapper.readTree(payload);
561 // String UserId = jnode.get("userID").textValue();
562 // SvcLogicContext localContext = new SvcLogicContext();
563 // localContext.setAttribute("requestID", requestID);
564 // localContext.setAttribute("userID", UserId);
565 // if (serviceLogic != null && localContext != null) {
566 // String queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART from " +
567 // DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
568 // " AR where DAT.SDC_REFERENCE_ID= AR.SDC_REFERENCE_ID and DAT.USER = $userID" ;
570 // log.info(fn + "Query String : " + queryString);
572 // status = serviceLogic.query("SQL", true, null, queryString, null, null, localContext);
573 // } catch (SvcLogicException e1) {
574 // // TODO Auto-generated catch block
575 // e1.printStackTrace();
578 // if(status.toString().equals("FAILURE"))
579 // throw new SvcLogicException("Error - while getting FlowReferenceData ");
581 // Properties props = localContext.toProperties();
582 // log.info("SvcLogicContext contains the following : " + props.toString());
583 // for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) {
584 // String propName = (String) e.nextElement();
585 // log.info(propName+" = "+props.getProperty(propName));
593 private String getDesigns(String payload, String requestID) throws Exception {
595 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 String filterKey =null;
605 if(payloadObject.hasNonNull("filter"))
606 filterKey = payloadObject.get("filter").textValue();
607 ArrayList<String> argList = new ArrayList<>();
611 queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from " +
612 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
613 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? and AR.ARTIFACT_NAME like '%"+filterKey+"%' GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
615 queryString = "SELECT AR.VNF_TYPE, AR.VNFC_TYPE, DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from " +
616 DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , " + DesignServiceConstants.DB_SDC_REFERENCE +
617 " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID and DAT.USER = ? GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
619 DesignResponse designResponse = new DesignResponse();
620 designResponse.setUserId(UserID);
621 List<DesignInfo> designInfoList = new ArrayList<DesignInfo>();
622 ResultSet data = dbservice.getDBData(queryString, argList);
624 DesignInfo designInfo = new DesignInfo();
625 designInfo.setInCart(data.getString("IN_CART"));
626 designInfo.setProtocol(data.getString("PROTOCOL"));
627 designInfo.setVnf_type(data.getString("VNF_TYPE"));
628 designInfo.setVnfc_type(data.getString("VNFC_TYPE"));
629 designInfo.setAction(data.getString("ACTION"));
630 designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE"));
631 designInfo.setArtifact_name(data.getString("ARTIFACT_NAME"));
632 designInfoList.add(designInfo);
634 if(designInfoList.size() < 1)
635 throw new Exception(" Welcome to CDT, Looks like you dont have Design Yet... Lets create some....");
636 designResponse.setDesignInfoList(designInfoList);
637 ObjectMapper mapper = new ObjectMapper();
638 String jsonString = mapper.writeValueAsString(designResponse);
639 log.info("Info : " + jsonString);
644 log.error("Error while Starting getDesgins DB operation : ",e);