Remove unnecessary use of Calendar.getInstance()
[so.git] / bpmn / MSOURN-plugin / src / main / java / org / openecomp / camunda / bpmn / plugin / urnmap / resources / ProcessInstanceResource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.camunda.bpmn.plugin.urnmap.resources;
22
23 import java.util.List;
24 import java.util.StringTokenizer;
25
26 import javax.ws.rs.GET;
27 import javax.ws.rs.POST;
28 import javax.ws.rs.PUT;
29
30 import org.camunda.bpm.cockpit.db.QueryParameters;
31 import org.camunda.bpm.cockpit.plugin.resource.AbstractPluginResource;
32 import org.camunda.bpm.cockpit.db.CommandExecutor;
33 import org.openecomp.camunda.bpmn.plugin.urnmap.db.*;
34
35 public class ProcessInstanceResource extends AbstractPluginResource {
36
37   public ProcessInstanceResource(String engineName) {
38     super(engineName);
39   }
40
41   @GET
42   public List<URNData> getUrnDataMap() {    
43     List<URNData> list = getQueryService()
44             .executeQuery(
45                     "cockpit.urnMap.retrieveUrnKeyValuePair",
46                     new QueryParameters<URNData>());
47     
48     System.out.println("urnmap-plugin project - Results Retrieved: ");
49     System.out.println("URNName: " + "          " + "URNValue: " );
50     for(URNData d: list)
51     {
52         System.out.println(  d.getURNName() + "         "  + d.getURNValue());
53     }
54    
55     return list;
56   }
57   
58   @PUT
59   //public void insertNewRow(String key_, String value_) 
60   public void insertNewRow(String temp) 
61    {  
62          System.out.println("AddNewRow: XXXXXXXXXXXXXXXXX ---> " + temp);
63          StringTokenizer st = new StringTokenizer(temp, "|");
64          String key_ = "";
65          String value_ = "";
66          
67          while(st.hasMoreTokens()) { 
68                   key_ = st.nextToken(); 
69                   value_ = st.nextToken(); 
70                  System.out.println(key_ + "\t" + value_); 
71                  } 
72                          
73        System.out.println("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key_ + " , Value: " + value_);
74           URNData nRow = new URNData();
75           nRow.setVer_("1");     
76           nRow.setURNName(key_);
77           nRow.setURNValue(value_);
78           
79          getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class);
80          
81          System.out.println("AddNewRow: XXXXXX    END   XXXXXXXXXXX");
82    }
83   
84   @POST
85  // public void getPersistData(List<URNData > myList) {  
86   public void getPersistData(URNData d) {  
87           
88           System.out.println("getPersistData:  UrnName: " + d.getURNName() + " , URNValue: " + d.getURNValue() );
89             
90                 getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class);
91                 //getQueryService().executeQuery("cockpit.sample.persistURNData", d, ProcessInstanceCountDto.class);
92              
93                     
94             System.out.println("XXXXXXXXXX - END - XXXXXXXXXXXXXXX");
95         }
96 }