aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
blob: 83ef0f914873e21bfd6648e6d593b7a00fb5b10e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
/*-
 * ============LICENSE_START=======================================================
 * ONAP : APPC
 * ================================================================================
 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Copyright (C) 2017 Amdocs
 * =============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.appc.design.dbervices;

import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.onap.appc.design.data.ArtifactInfo;
import org.onap.appc.design.data.DesignInfo;
import org.onap.appc.design.data.DesignResponse;
import org.onap.appc.design.data.StatusInfo;
import org.onap.appc.design.services.util.ArtifactHandlerClient;
import org.onap.appc.design.services.util.DesignServiceConstants;
import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;

public class DesignDBService {

    private static final EELFLogger log = EELFManager.getInstance().getLogger(DesignDBService.class);
    private static DesignDBService dgGeneralDBService;

    private static final String SUCCESS_JSON = "{\"update\" : \"success\" } ";
    private static final String STATUS = "STATUS";
    private static final String INFO_STR = "Info : ";
    private static final String DB_OPERATION_ERROR = "Error while DB operation : ";
    private static final String VNFC_TYPE = "vnfc-type";
    private static final String QUERY_STR = "Query String :";
    private static final String USER_ID = "userID";

    private SvcLogicResource serviceLogic;
    private DbService dbservice;

    public static DesignDBService initialise() {
        if (dgGeneralDBService == null) {
            dgGeneralDBService = new DesignDBService();
        }
        return dgGeneralDBService;
    }

    private DesignDBService() {
        if (serviceLogic == null) {
            serviceLogic = new SqlResource();
        }
    }

    public String execute(String action, String payload, String requestID) throws Exception {

        log.info("Received execute request for action : " + action + "  with Payload : " + payload);
        RequestValidator.validate(action, payload);
        String response;
        dbservice = new DbService();
        switch (action) {
            case DesignServiceConstants.GETDESIGNS:
                response = getDesigns(payload, requestID);
                break;
            case DesignServiceConstants.ADDINCART:
                response = setInCart(payload, requestID);
                break;
            case DesignServiceConstants.GETARTIFACTREFERENCE:
                response = getArtifactReference(payload, requestID);
                break;
            case DesignServiceConstants.GETARTIFACT:
                response = getArtifact(payload, requestID);
                break;
            case DesignServiceConstants.GETGUIREFERENCE:
                response = getGuiReference(payload, requestID);
                break;
            case DesignServiceConstants.GETSTATUS:
                response = getStatus(payload, requestID);
                break;
            case DesignServiceConstants.SETSTATUS:
                response = setStatus(payload, requestID);
                break;
            case DesignServiceConstants.UPLOADARTIFACT:
                response = uploadArtifact(payload, requestID);
                break;
            case DesignServiceConstants.SETPROTOCOLREFERENCE:
                response = setProtocolReference(payload, requestID);
                break;
            default:
                throw new DBException(" Action " + action + " not found while processing request ");

        }
        return response;
    }

    private String setInCart(String payload, String requestID) throws Exception {

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);
        ArrayList<String> argList = new ArrayList<>();
        argList.add(payloadObject.get(DesignServiceConstants.INCART).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());

        String queryString = "UPDATE DT_ARTIFACT_TRACKING SET INCART= ? WHERE ASDC_REFERENCE_ID  IN "
            + " (SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE_ID WHERE VNF_TYPE = ? ";

        if (payloadObject.get(DesignServiceConstants.VNF_TYPE) != null && !payloadObject
            .get(DesignServiceConstants.VNF_TYPE).textValue().isEmpty()) {
            queryString = queryString + "  AND VNFC_TYPE = ? ) AND USER = ? ";
            argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
        } else {
            queryString = queryString + "  ) AND USER = ? ";
        }
        argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
        log.info(QUERY_STR + queryString);
        boolean data = dbservice.updateDBData(queryString, argList);

        if (!data) {
            throw new DBException("Error while updating ProtocolReference");
        }
        return SUCCESS_JSON;
    }

    private String setProtocolReference(String payload, String requestID) throws Exception {

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);
        ArrayList<String> argList = new ArrayList<>();

        argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.ACTION_LEVEL).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());

        String queryString = " DELETE FROM PROTOCOL_REFERENCE WHERE ACTION = ? AND ACTION_LEVEL AND VNF_TYPE= ?  AND PROTOCOL = ? ";

        log.info("Delete Query String :" + queryString);
        boolean data;

        log.info("Record Deleted");

        if (payloadObject.get(DesignServiceConstants.TEMPLATE) != null &&
            !payloadObject.get(DesignServiceConstants.TEMPLATE).textValue().isEmpty()) {

            argList.add(payloadObject.get(DesignServiceConstants.TEMPLATE).textValue());
        } else {
            argList.add("NO");
        }

        if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null &&
            !payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {

            queryString = queryString + " AND  VNFC_TYPE =  ? )";
        } else {
            queryString = queryString + " ) ";
        }
        log.info(QUERY_STR + queryString);
        data = dbservice.updateDBData(queryString, argList);

        if (!data) {
            throw new DBException("Error while updating ProtocolReference");
        }
        return SUCCESS_JSON;
    }

    private String uploadArtifact(String payload, String requestID) throws Exception {

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        JsonNode payloadObject = objectMapper.readTree(payload);
        log.info("Got upload Aritfact with Payload : " + payloadObject.asText());
        try {
            ArtifactHandlerClient ac = new ArtifactHandlerClient();
            String requestString = ac.createArtifactData(payload, requestID);
            ac.execute(requestString, "POST");
            int sdcArtifactId = getSDCArtifactIDbyRequestID(requestID);
            int sdcReferenceId = getSDCReferenceID(payload);
            createArtifactTrackingRecord(payload, requestID, sdcArtifactId, sdcReferenceId);
            String status = getDataFromActionStatus(payload, STATUS);
            if (status == null || status.isEmpty()) {
              log.info("Action Status is: "+ status);
              setActionStatus(payload, "Not Tested");
            }
            linkstatusRelationShip(sdcArtifactId, sdcReferenceId, payload);

        } catch (Exception e) {
            log.error("An error occured in uploadArtifact", e);
            throw e;
        }
        return SUCCESS_JSON;

    }

    private void linkstatusRelationShip(int sdcArtifactId, int sdcReferenceId, String payload) throws Exception {

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);
        ArrayList<String> argList = new ArrayList<>();
        argList.add(String.valueOf(sdcArtifactId));
        argList.add(String.valueOf(sdcReferenceId));
        argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());

        String queryString =
            "INSERT INTO DT_STATUS_RELATIONSHIP (DT_ARTIFACT_TRACKING_ID,DT_ACTION_STATUS_ID) VALUES " +
                "(( SELECT DT_ARTIFACT_TRACKING_ID FROM DT_ARTIFACT_TRACKING WHERE ASDC_ARTIFACTS_ID = ? AND ASDC_REFERENCE_ID = ? ) , "
                + "( SELECT DT_ACTION_STATUS_ID FROM DT_ACTION_STATUS WHERE  VNF_TYPE = ? AND ACTION = ?  AND USER = ? ";

        if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
            .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
            queryString = queryString + " AND  VNFC_TYPE =  ? GROUP BY VNF_TYPE HAVING COUNT(VNF_TYPE)>=1 ) )";
        } else {
            queryString = queryString + " GROUP BY VNF_TYPE HAVING COUNT(VNF_TYPE)>=1 ) ) ";
        }
        log.info(QUERY_STR + queryString);
        boolean data = dbservice.updateDBData(queryString, argList);

        if (!data) {
            throw new DBException("Error while updating RelationShip table");
        }

    }

    private int getSDCReferenceID(String payload) throws Exception {

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);
        ArrayList<String> argList = new ArrayList<>();
        argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());

        argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_TYPE).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.ARTIFACT_NAME).textValue());

        String queryString = " SELECT ASDC_REFERENCE_ID FROM ASDC_REFERENCE WHERE VNF_TYPE = ?  "
            + " AND ARTIFACT_TYPE = ?  AND ARTIFACT_NAME = ? ";

        if (payloadObject.get(DesignServiceConstants.ACTION) != null && !payloadObject
            .get(DesignServiceConstants.ACTION).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
            queryString = queryString + " AND ACTION = ? ";
        }
        if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
            .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
            queryString = queryString + " AND VNFC_TYPE = ? ";

        }

        log.info(QUERY_STR + queryString);
        ResultSet data = dbservice.getDBData(queryString, argList);
        int sdcReferenceId = 0;
        while (data.next()) {
            sdcReferenceId = data.getInt("ASDC_REFERENCE_ID");
        }
        log.info("Got sdcReferenceId= " + sdcReferenceId);
        return sdcReferenceId;
    }

    private String getDataFromActionStatus(String payload, String dataValue) throws Exception {
        String status = null;
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);
        ArrayList<String> argList = new ArrayList<>();
        argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
        String queryString =
            " SELECT " + dataValue + " FROM DT_ACTION_STATUS WHERE VNF_TYPE = ? AND ACTION = ? AND USER = ? ";
        if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
            .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
            queryString = queryString + " AND VNFC_TYPE = ? ";
        }
        log.info(QUERY_STR + queryString);
        ResultSet data = dbservice.getDBData(queryString, argList);
        while (data.next()) {
            status = data.getString(STATUS);
        }
        log.info("DT_ACTION_STATUS Status = " + status);
        return status;
    }

    private void setActionStatus(String payload, String status) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);
        ArrayList<String> argList = new ArrayList<>();
        argList.add(payloadObject.get(DesignServiceConstants.ACTION).textValue());
        argList.add(payloadObject.get(DesignServiceConstants.VNF_TYPE).textValue());

        String insertQuery = " INSERT INTO DT_ACTION_STATUS (ACTION, VNF_TYPE, VNFC_TYPE, USER, TECHNOLOGY, UPDATED_DATE, STATUS) VALUES (?,?,?,?,?,sysdate() , ?); ";
        if (payloadObject.get(DesignServiceConstants.VNFC_TYPE) != null && !payloadObject
            .get(DesignServiceConstants.VNFC_TYPE).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
            log.info("Vnfc-Type: " + payloadObject.get(DesignServiceConstants.VNFC_TYPE).textValue());
        } else {
            argList.add(null);
        }
        argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
        if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null && !payloadObject
            .get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
        } else {
            argList.add(null);
        }
        argList.add(status);

        log.info("QueryString: " + insertQuery);
        log.info("Arguments List: " + argList);
        boolean updateStatus = dbservice.updateDBData(insertQuery, argList);
        if (!updateStatus)
            throw new DBException("Error while updating Action Status");
    }

    private void createArtifactTrackingRecord(String payload, String requestID, int sdcArtifactId, int sdcReferenceId)
        throws Exception {

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode payloadObject = objectMapper.readTree(payload);

        ArrayList<String> argList = new ArrayList<>();
        argList.add(String.valueOf(sdcArtifactId));
        argList.add(String.valueOf(sdcReferenceId));
        argList.add(payloadObject.get(DesignServiceConstants.USER_ID).textValue());
        if (payloadObject.get(DesignServiceConstants.TECHNOLOGY) != null && !payloadObject
            .get(DesignServiceConstants.TECHNOLOGY).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.TECHNOLOGY).textValue());
        } else {
            argList.add("");
        }

        if (payloadObject.get(DesignServiceConstants.PROTOCOL) != null && !payloadObject
            .get(DesignServiceConstants.PROTOCOL).textValue().isEmpty()) {
            argList.add(payloadObject.get(DesignServiceConstants.PROTOCOL).textValue());
        } else {
            argList.add("");
        }

        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' )";

        log.info(QUERY_STR + queryString);
        boolean data = dbservice.updateDBData(queryString, argList);
        if (!data) {
            throw new DBException("Error Updating DT_ARTIFACT_TRACKING ");
        }
    }

    private int getSDCArtifactIDbyRequestID(String requestID) throws Exception {
        log.info("Starting getArtifactIDbyRequestID DB Operation");
        int artifactId = 0;
        try {
            ArrayList<String> argList = new ArrayList<>();
            argList.add("TLSUUID" + requestID);
            String queryString = " SELECT ASDC_ARTIFACTS_ID FROM ASDC_ARTIFACTS where SERVICE_UUID = ? ";
            log.info(QUERY_STR + queryString);
            ResultSet data = dbservice.getDBData(queryString, argList);
            while (data.next()) {
                artifactId = data.getInt("ASDC_ARTIFACTS_ID");
            }
        } catch (Exception e) {
            log.error("An error occurred in getSDCArtifactIDbyRequestID", e);
            throw e;
        }
        log.info("Got SDC_ARTIFACTS_ID As :" + artifactId);
        return artifactId;
    }


    private String getArtifact(String payload, String requestID) throws Exception {
        log.info("Starting getArtifact DB Operation");
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            JsonNode payloadObject = objectMapper.readTree(payload);
            ArrayList<String> argList = new ArrayList<>();
            argList.add(payloadObject.get("artifact-name").textValue());
            argList.add(payloadObject.get("artifact-type").textValue());

            String queryString = "SELECT INTERNAL_VERSION, ARTIFACT_CONTENT FROM ASDC_ARTIFACTS where " +
                " ARTIFACT_NAME = ? AND ARTIFACT_TYPE = ?  ";

            log.info(QUERY_STR + queryString);
            ResultSet data = dbservice.getDBData(queryString, argList);
            String artifactContent = null;
            int hightestVerion = -1;
            while (data.next()) {
                int version = data.getInt("INTERNAL_VERSION");
                if (hightestVerion < version) {
                    artifactContent = data.getString("ARTIFACT_CONTENT");
                }
            }
            if (artifactContent == null || artifactContent.isEmpty()) {
                throw new DBException(
                    "Sorry !!! I dont have any artifact Named : " + payloadObject.get("artifact-name").textValue());
            }
            DesignResponse designResponse = new DesignResponse();
            List<ArtifactInfo> artifactInfoList = new ArrayList<>();
            ArtifactInfo artifactInfo = new ArtifactInfo();
            artifactInfo.setArtifact_content(artifactContent);
            artifactInfoList.add(artifactInfo);
            designResponse.setArtifactInfo(artifactInfoList);
            ObjectMapper mapper = new ObjectMapper();
            String jsonString = mapper.writeValueAsString(designResponse);
            log.info(INFO_STR + jsonString);
            return jsonString;
        } catch (Exception e) {
            log.error(DB_OPERATION_ERROR, e);
            throw e;
        }
    }

    private String setStatus(String payload, String requestID) throws Exception {

        log.info("Starting getStatus DB Operation");
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            JsonNode payloadObject = objectMapper.readTree(payload);

            ArrayList<String> argList = new ArrayList<>();
            argList.add(payloadObject.get("artifact_status").textValue());
            argList.add(payloadObject.get("action_status").textValue());

            argList.add(payloadObject.get(USER_ID).textValue());
            argList.add(payloadObject.get("vnf-type").textValue());

            String queryString =
                " UPDATE DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR  SET DAT.ARTIFACT_STATUS = ? , DAS.DT_ACTION_STATUS = ? "
                    + " where  DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
                    + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
                    + " and  DAS.VNF_TYPE = ? ";

            if (payloadObject.get(VNFC_TYPE) != null && !payloadObject.get(VNFC_TYPE).textValue().isEmpty()) {
                argList.add(payloadObject.get(VNFC_TYPE).textValue());
                queryString = queryString + " and DAS.VNFC_TYPE = ? ";
            }

            log.info(QUERY_STR + queryString);

            DesignResponse designResponse = new DesignResponse();
            designResponse.setUserId(payloadObject.get(USER_ID).textValue());
            boolean update = dbservice.updateDBData(queryString, argList);
            if (!update) {
                throw new DBException("Sorry .....Something went wrong while updating the Status");
            }

            ObjectMapper mapper = new ObjectMapper();
            String jsonString = mapper.writeValueAsString(designResponse);
            log.info(INFO_STR + jsonString);
            return jsonString;
        } catch (Exception e) {
            log.error(DB_OPERATION_ERROR, e);
            throw e;
        }
    }

    private String getStatus(String payload, String requestID) throws Exception {
        log.info("Starting getStatus DB Operation");
        try {
            String vnfcType = null;
            ObjectMapper objectMapper = new ObjectMapper();
            JsonNode payloadObject = objectMapper.readTree(payload);
            String userID = payloadObject.get(USER_ID).textValue();
            String vnfType = payloadObject.get("vnf-type").textValue();
            if (payloadObject.get(VNFC_TYPE) != null) {
                vnfcType = payloadObject.get(VNFC_TYPE).textValue();
            }
            ArrayList<String> argList = new ArrayList<>();

            argList.add(userID);
            argList.add(vnfType);

            String queryString = "SELECT DAS.VNF_TYPE, DAS.VNFC_TYPE,  DAS.STATUS, DAS.ACTION, DAT.ARTIFACT_STATUS "
                + "from  DT_ACTION_STATUS DAS , DT_ARTIFACT_TRACKING DAT, DT_STATUS_RELATIONSHIP DSR " +
                " where  DAT.USER = DAS.USER and DSR.DT_ARTIFACT_TRACKING_ID = DAT.DT_ARTIFACT_TRACKING_ID "
                + " and DSR.DT_ACTION_STATUS_ID = DAS.DT_ACTION_STATUS_ID and DAT.USER = ? "
                + " and  DAS.VNF_TYPE = ? ";

            if (vnfcType != null && !vnfcType.isEmpty()) {
                argList.add(vnfcType);
                queryString = queryString + " and DAS.VNFC_TYPE = ? ";
            }

            log.info(QUERY_STR + queryString);

            DesignResponse designResponse = new DesignResponse();
            designResponse.setUserId(userID);
            List<StatusInfo> statusInfoList = new ArrayList<>();
            ResultSet data = dbservice.getDBData(queryString, argList);
            while (data.next()) {
                StatusInfo statusInfo = new StatusInfo();
                statusInfo.setAction(data.getString("ACTION"));
                statusInfo.setAction_status(data.getString(STATUS));
                statusInfo.setArtifact_status(data.getString("ARTIFACT_STATUS"));
                statusInfo.setVnf_type(data.getString("VNF_TYPE"));
                statusInfo.setVnfc_type(data.getString("VNFC_TYPE"));
                statusInfoList.add(statusInfo);
            }

            if (statusInfoList.isEmpty()) {
                throw new DBException(
                    "OOPS !!!! No VNF information available for VNF-TYPE : " + vnfType + " for User : " + userID);
            }
            designResponse.setStatusInfoList(statusInfoList);
            ObjectMapper mapper = new ObjectMapper();
            String jsonString = mapper.writeValueAsString(designResponse);
            log.info(INFO_STR + jsonString);
            return jsonString;
        } catch (SQLException e) {
            log.error(DB_OPERATION_ERROR, e);
            throw e;
        } catch (Exception e) {
            log.error(DB_OPERATION_ERROR + e.getMessage());
            log.error("Exception : ", e);
            throw e;
        }
    }

    private String getGuiReference(String payload, String requestID) {
        // TODO Auto-generated method stub
        return null;
    }

    private String getArtifactReference(String payload, String requestID) {
        // TODO Auto-generated method stub
        return null;
    }

    private String getDesigns(String payload, String requestID) throws Exception {

        String queryString;
        log.info("Starting getDesigns DB Operation");

        try {
            ObjectMapper objectMapper = new ObjectMapper();
            JsonNode payloadObject = objectMapper.readTree(payload);
            String userID = payloadObject.get(USER_ID).textValue();
            String filterKey = null;
            if (payloadObject.hasNonNull("filter")) {
                filterKey = payloadObject.get("filter").textValue();
            }
            ArrayList<String> argList = new ArrayList<>();
            argList.add(userID);

            if (filterKey != null) {
                queryString =
                    "SELECT AR.VNF_TYPE, AR.VNFC_TYPE,  DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from  "
                        +
                        DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , "
                        + DesignServiceConstants.DB_SDC_REFERENCE +
                        " 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";
            } else {
                queryString =
                    "SELECT AR.VNF_TYPE, AR.VNFC_TYPE,  DAT.PROTOCOL, DAT.IN_CART, AR.ACTION, AR.ARTIFACT_NAME, AR.ARTIFACT_TYPE from  "
                        +
                        DesignServiceConstants.DB_DT_ARTIFACT_TRACKING + " DAT , "
                        + DesignServiceConstants.DB_SDC_REFERENCE +
                        " AR where DAT.ASDC_REFERENCE_ID= AR.ASDC_REFERENCE_ID  and DAT.USER = ? GROUP BY AR.VNF_TYPE,AR.ARTIFACT_NAME";
            }
            DesignResponse designResponse = new DesignResponse();
            designResponse.setUserId(userID);
            List<DesignInfo> designInfoList = new ArrayList<>();
            ResultSet data = dbservice.getDBData(queryString, argList);
            while (data.next()) {
                DesignInfo designInfo = new DesignInfo();
                designInfo.setInCart(data.getString("IN_CART"));
                designInfo.setProtocol(data.getString("PROTOCOL"));
                designInfo.setVnf_type(data.getString("VNF_TYPE"));
                designInfo.setVnfc_type(data.getString("VNFC_TYPE"));
                designInfo.setAction(data.getString("ACTION"));
                designInfo.setArtifact_type(data.getString("ARTIFACT_TYPE"));
                designInfo.setArtifact_name(data.getString("ARTIFACT_NAME"));
                designInfoList.add(designInfo);
            }
            if (designInfoList.isEmpty()) {
                throw new DBException(
                    " Welcome to CDT, Looks like you dont have Design Yet... Lets create some....");
            }
            designResponse.setDesignInfoList(designInfoList);
            ObjectMapper mapper = new ObjectMapper();
            String jsonString = mapper.writeValueAsString(designResponse);
            log.info(INFO_STR + jsonString);
            return jsonString;
        } catch (Exception e) {
            log.error("Error while Starting getDesgins DB operation : ", e);
            throw e;
        }
    }
}