Initial OpenECOMP MSO commit
[so.git] / bpmn / MSOURN-plugin / src / main / java / com / att / camunda / bpm / 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 com.att.camunda.bpm.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 com.att.camunda.bpm.plugin.urnmap.db.*;
33 import org.camunda.bpm.cockpit.db.CommandExecutor;
34
35 import com.att.camunda.bpm.plugin.urnmap.db.URNData;
36
37 public class ProcessInstanceResource extends AbstractPluginResource {
38
39   public ProcessInstanceResource(String engineName) {
40     super(engineName);
41   }
42
43   @GET
44   public List<URNData> getUrnDataMap() {    
45     List<URNData> list = getQueryService()
46             .executeQuery(
47                     "cockpit.urnMap.retrieveUrnKeyValuePair",
48                     new QueryParameters<URNData>());
49     
50     System.out.println("urnmap-plugin project - Results Retrieved: ");
51     System.out.println("URNName: " + "          " + "URNValue: " );
52     for(URNData d: list)
53     {
54         System.out.println(  d.getURNName() + "         "  + d.getURNValue());
55     }
56    
57     return list;
58   }
59   
60   @PUT
61   //public void insertNewRow(String key_, String value_) 
62   public void insertNewRow(String temp) 
63    {  
64          System.out.println("AddNewRow: XXXXXXXXXXXXXXXXX ---> " + temp);
65          StringTokenizer st = new StringTokenizer(temp, "|");
66          String key_ = "";
67          String value_ = "";
68          
69          while(st.hasMoreTokens()) { 
70                   key_ = st.nextToken(); 
71                   value_ = st.nextToken(); 
72                  System.out.println(key_ + "\t" + value_); 
73                  } 
74                          
75        System.out.println("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key_ + " , Value: " + value_);
76           URNData nRow = new URNData();
77           nRow.setVer_("1");     
78           nRow.setURNName(key_);
79           nRow.setURNValue(value_);
80           
81          getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class);
82          
83          System.out.println("AddNewRow: XXXXXX    END   XXXXXXXXXXX");
84    }
85   
86   @POST
87  // public void getPersistData(List<URNData > myList) {  
88   public void getPersistData(URNData d) {  
89           
90           System.out.println("getPersistData:  UrnName: " + d.getURNName() + " , URNValue: " + d.getURNValue() );
91             
92                 getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class);
93                 //getQueryService().executeQuery("cockpit.sample.persistURNData", d, ProcessInstanceCountDto.class);
94              
95                     
96             System.out.println("XXXXXXXXXX - END - XXXXXXXXXXXXXXX");
97         }
98 }