2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.camunda.bpmn.plugin.urnmap.resources;
23 import java.beans.Statement;
24 import java.sql.DriverManager;
25 import java.sql.ResultSet;
26 import java.sql.SQLException;
28 import java.sql.Connection;
29 import java.sql.PreparedStatement;
30 import java.sql.ResultSet;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.StringTokenizer;
35 import javax.naming.Context;
36 import javax.naming.InitialContext;
37 import javax.sql.DataSource;
38 import javax.ws.rs.GET;
39 import javax.ws.rs.POST;
40 import javax.ws.rs.PUT;
42 import org.camunda.bpm.cockpit.db.QueryParameters;
43 import org.camunda.bpm.cockpit.plugin.resource.AbstractCockpitPluginResource;
46 //import org.camunda.bpm.cockpit.plugin.resource.AbstractPluginResource;
47 import org.openecomp.camunda.bpmn.plugin.urnmap.db.URNData;
48 import org.openecomp.mso.logger.MsoLogger;
51 //public class ProcessInstanceResource extends AbstractPluginResource {
52 public class URNResource extends AbstractCockpitPluginResource{
53 public URNResource(String engineName) {
57 private Connection conn;
58 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
60 public List<URNData> getUrnDataMap()
62 List<URNData> list = new ArrayList();
66 conn = getDBConnection();
67 PreparedStatement psData = conn
68 .prepareStatement("select * from MSO_URN_MAPPING order by NAME_");
70 ResultSet r = psData.executeQuery();
74 URNData d = new URNData();
75 d.setURNName(r.getString("NAME_"));
76 d.setURNValue(r.getString("VALUE_"));
77 d.setVer_( r.getString("REV_"));
93 msoLogger.debug( d.getURNName() + " " + d.getURNValue());
94 //msoLogger.debug("Started Executing " + getTaskName());
95 msoLogger.debug("Started Executing " + d.getURNName() + " " + d.getURNValue());
101 public List<URNData> getUrnDataMapOLD()
104 List<URNData> list = getQueryService()
105 .executeQuery("cockpit.urnMap.retrieveUrnKeyValuePair", new QueryParameters<URNData>());
107 msoLogger.debug("urnmap-plugin project - Results Retrieved: ");
108 msoLogger.debug("URNName: " + " " + "URNValue: " );
112 //msoLogger.debug( d.getURNName() + " " + d.getURNValue());
113 msoLogger.debug( d.getURNName() + " " + d.getURNValue());
119 public Connection getDBConnection()
125 Context ctx = new InitialContext();
126 DataSource ds = (DataSource)ctx.lookup("java:jboss/datasources/ProcessEngine");//jboss
127 conn = ds.getConnection();
131 } catch (Exception e)
141 public void insertNewRow(String temp)
143 msoLogger.debug("AddNewRow: XXXXXXXXXXXXXXXXX ---> " + temp);
144 msoLogger.debug("AddNewRow: EngineName ---> " + engineName);
146 StringTokenizer st = new StringTokenizer(temp, "|");
150 while(st.hasMoreTokens()) {
151 key_ = st.nextToken();
152 value_ = st.nextToken();
153 msoLogger.debug(key_ + "\t" + value_);
156 msoLogger.debug("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key_ + " , Value: " + value_);
157 final URNData nRow = new URNData();
159 final String myKey = key_;
160 final String myValue = value_;
162 msoLogger.debug("----------- START ----------------------");
165 conn = getDBConnection();
166 PreparedStatement psData = conn
167 .prepareStatement("Insert into MSO_URN_MAPPING values ('" + key_ + "', '" + value_ + "', '1')");
169 psData.executeUpdate();
175 } catch (Exception e)
180 // getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class);
184 public void getPersistData(URNData d) {
186 //getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class);
190 conn = getDBConnection();
191 PreparedStatement psData = conn
192 .prepareStatement("UPDATE MSO_URN_MAPPING set VALUE_ ='"+ d.getURNValue() + "' WHERE NAME_='" + d.getURNName() + "'");
194 psData.executeUpdate();
198 } catch (Exception e)