From 38f720752af4d4aad8c4e467a288d9048659f688 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Wed, 14 Mar 2018 02:07:32 -0400 Subject: AT&T 1712 and 1802 release code This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty --- bpmn/MSOURN-plugin/build.properties | 7 + bpmn/MSOURN-plugin/build.xml | 60 ++++++ bpmn/MSOURN-plugin/pom.xml | 65 +++++++ .../camunda/bpmn/plugin/urnmap/URNMapPlugin.java | 53 ++++++ .../urnmap/db/MyBatisExtendedSessionFactory.java | 89 +++++++++ .../urnmap/db/MyBatisQueryCommandExecutor.java | 44 +++++ .../camunda/bpmn/plugin/urnmap/db/URNData.java | 47 +++++ .../camunda/bpmn/plugin/urnmap/db/URNService.java | 48 +++++ .../urnmap/resources/ProcessInstanceResource.java | 96 ++++++++++ .../urnmap/resources/URNMapPluginRootResource.java | 42 +++++ .../bpmn/plugin/urnmap/resources/URNResource.java | 205 +++++++++++++++++++++ ...rg.camunda.bpm.cockpit.plugin.spi.CockpitPlugin | 1 + bpmn/MSOURN-plugin/src/main/resources/mappings.xml | 32 ++++ .../camunda/bpm/plugin/urnmap/queries/urnMap.xml | 64 +++++++ .../plugin-webapp/urnMap-plugin/app/dashboard.html | 63 +++++++ .../plugin-webapp/urnMap-plugin/app/plugin.js | 132 +++++++++++++ .../resources/plugin-webapp/urnMap-plugin/info.txt | 1 + 17 files changed, 1049 insertions(+) create mode 100644 bpmn/MSOURN-plugin/build.properties create mode 100644 bpmn/MSOURN-plugin/build.xml create mode 100644 bpmn/MSOURN-plugin/pom.xml create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisQueryCommandExecutor.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNData.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNService.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNMapPluginRootResource.java create mode 100644 bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java create mode 100644 bpmn/MSOURN-plugin/src/main/resources/META-INF/services/org.camunda.bpm.cockpit.plugin.spi.CockpitPlugin create mode 100644 bpmn/MSOURN-plugin/src/main/resources/mappings.xml create mode 100644 bpmn/MSOURN-plugin/src/main/resources/org/openecomp/camunda/bpm/plugin/urnmap/queries/urnMap.xml create mode 100644 bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/dashboard.html create mode 100644 bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/plugin.js create mode 100644 bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/info.txt (limited to 'bpmn/MSOURN-plugin') diff --git a/bpmn/MSOURN-plugin/build.properties b/bpmn/MSOURN-plugin/build.properties new file mode 100644 index 0000000000..7e5fb9f22f --- /dev/null +++ b/bpmn/MSOURN-plugin/build.properties @@ -0,0 +1,7 @@ +# Copy this file to 'build.properties' and modify it to match your system +# Alternatively, you can also copy it to '${user.home}/.camunda/build.properties' +# to have a central configuration that works with all camunda BPM projects + +# Defines the deployment folder in a camunda BPM installation (backslashes need to be escaped or replaced by forward slashes). +#deploy.jboss.dir=C:/camunda/camunda-bpm-jboss-7.3.0/server/jboss-as-${jboss-version}/standalone/deployments +deploy.jboss.dir=C:/D2/jboss-ee/server/jboss-as-7.2.0.Final/standalone/deployments \ No newline at end of file diff --git a/bpmn/MSOURN-plugin/build.xml b/bpmn/MSOURN-plugin/build.xml new file mode 100644 index 0000000000..f2dbc55e52 --- /dev/null +++ b/bpmn/MSOURN-plugin/build.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOURN-plugin/pom.xml b/bpmn/MSOURN-plugin/pom.xml new file mode 100644 index 0000000000..0dc8d6dee5 --- /dev/null +++ b/bpmn/MSOURN-plugin/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + + + org.onap.so + bpmn + 1.2.0-SNAPSHOT + + + org.onap.so + cockpit-urnmap-plugin + + jar + + MSO URN Mapping Cockpit Plugin + + + + org.camunda.bpm.webapp + camunda-webapp + classes + ${camunda.version} + + + commons-fileupload + commons-fileupload + + + + + commons-fileupload + commons-fileupload + 1.3.2 + + + javax.ws.rs + javax.ws.rs-api + 2.0 + + + + org.camunda.bpm + camunda-engine + ${camunda.version} + + + com.h2database + h2 + test + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + org.onap.so + common + ${project.version} + compile + + + diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java new file mode 100644 index 0000000000..a7a6354bc8 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/URNMapPlugin.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.cockpit.plugin.spi.impl.AbstractCockpitPlugin; +import org.openecomp.camunda.bpmn.plugin.urnmap.resources.URNMapPluginRootResource; + + + +public class URNMapPlugin extends AbstractCockpitPlugin{ + public static final String ID = "urnMap-plugin"; + + public String getId() { + return ID; + } + + @Override + public Set> getResourceClasses() { + Set> classes = new HashSet>(); + + classes.add(URNMapPluginRootResource.class); + + return classes; + } + + @Override + public List getMappingFiles() { + return Arrays.asList("org/openecomp/camunda/bpm/plugin/urnmap/queries/urnMap.xml"); + } +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java new file mode 100644 index 0000000000..9e43ee3512 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.db; + +import org.camunda.bpm.engine.ProcessEngineConfiguration; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration; +import org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor; +import org.camunda.bpm.engine.impl.interceptor.CommandInterceptor; +import org.camunda.bpm.engine.impl.interceptor.LogInterceptor; +import org.camunda.bpm.engine.impl.util.ReflectUtil; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class MyBatisExtendedSessionFactory extends StandaloneProcessEngineConfiguration { + + private String resourceName; + + protected void init() { + throw new IllegalArgumentException( + "Normal 'init' on process engine only used for extended MyBatis mappings is not allowed, please use 'initFromProcessEngineConfiguration'. You cannot construct a process engine with this configuration."); + } + + /** + * initialize the {@link ProcessEngineConfiguration} from an existing one, + * just using the database settings and initialize the database / MyBatis + * stuff. + */ + public void initFromProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration, String resourceName) { + this.resourceName = resourceName; + + setDatabaseType(processEngineConfiguration.getDatabaseType()); + setDataSource(processEngineConfiguration.getDataSource()); + setDatabaseTablePrefix(processEngineConfiguration.getDatabaseTablePrefix()); + + initDataSource(); + //initVariableTypes(); + initCommandContextFactory(); + initTransactionFactory(); + initTransactionContextFactory(); + initCommandExecutors(); + initSqlSessionFactory(); + initIncidentHandlers(); + initIdentityProviderSessionFactory(); + initSessionFactories(); + } + + /** + * In order to always open a new command context set the property + * "alwaysOpenNew" to true inside the CommandContextInterceptor. + * + * If you execute the custom queries inside the process engine + * (for example in a service task), you have to do this. + */ + @Override + protected Collection getDefaultCommandInterceptorsTxRequired() { + List defaultCommandInterceptorsTxRequired = new ArrayList(); + defaultCommandInterceptorsTxRequired.add(new LogInterceptor()); + defaultCommandInterceptorsTxRequired.add(new CommandContextInterceptor(commandContextFactory, this, true)); + return defaultCommandInterceptorsTxRequired; + } + + @Override + protected InputStream getMyBatisXmlConfigurationSteam() { + return ReflectUtil.getResourceAsStream(resourceName); + } + +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisQueryCommandExecutor.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisQueryCommandExecutor.java new file mode 100644 index 0000000000..f81d8c604d --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisQueryCommandExecutor.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.db; + +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.interceptor.Command; + +/** + * Helper to initialize a minimized process engine which does all the transaction and MyBatis mapping stuff for us + * and can be used to execute queries. + */ +public class MyBatisQueryCommandExecutor { + + private MyBatisExtendedSessionFactory myBatisExtendedSessionFactory; + + public MyBatisQueryCommandExecutor(ProcessEngineConfigurationImpl processEngineConfiguration, String mappingResourceName) { + myBatisExtendedSessionFactory = new MyBatisExtendedSessionFactory(); + myBatisExtendedSessionFactory.initFromProcessEngineConfiguration(processEngineConfiguration, mappingResourceName); + } + + public T executeQueryCommand(Command command) { + return myBatisExtendedSessionFactory.getCommandExecutorTxRequired().execute(command); + } + + +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNData.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNData.java new file mode 100644 index 0000000000..b2dcefb304 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNData.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.db; + +public class URNData { + + private String URNName; + private String URNValue; + private String Ver_; + public String getURNName() { + return URNName; + } + public void setURNName(String uRNName) { + URNName = uRNName; + } + public String getURNValue() { + return URNValue; + } + public void setURNValue(String uRNValue) { + URNValue = uRNValue; + } + public String getVer_() { + return Ver_; + } + public void setVer_(String ver_) { + Ver_ = ver_; + } + +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNService.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNService.java new file mode 100644 index 0000000000..31b2e62b53 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/URNService.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.db; + +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngines; +import org.camunda.bpm.engine.impl.ProcessEngineImpl; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; + +public class URNService { + + + public List getProperties() { + ProcessEngineImpl processEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine(); + ProcessEngineConfigurationImpl processEngineConfiguration = processEngine.getProcessEngineConfiguration(); + + MyBatisQueryCommandExecutor commandExecutor = new MyBatisQueryCommandExecutor(processEngineConfiguration, "mappings.xml"); + return commandExecutor.executeQueryCommand(new Command>() { + + @SuppressWarnings("unchecked") + public List execute(CommandContext commandContext) { + return (List) commandContext.getDbSqlSession().selectList("retrieveUrnKeyValuePair", null); + } + }); + } + +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java new file mode 100644 index 0000000000..7d432067ba --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/ProcessInstanceResource.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.resources; + +import java.util.List; +import java.util.StringTokenizer; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; + +import org.camunda.bpm.cockpit.db.QueryParameters; +import org.camunda.bpm.cockpit.plugin.resource.AbstractPluginResource; +import org.camunda.bpm.cockpit.db.CommandExecutor; +import org.openecomp.camunda.bpmn.plugin.urnmap.db.*; + +public class ProcessInstanceResource extends AbstractPluginResource { + + public ProcessInstanceResource(String engineName) { + super(engineName); + } + + @GET + public List getUrnDataMap() { + List list = getQueryService() + .executeQuery( + "cockpit.urnMap.retrieveUrnKeyValuePair", + new QueryParameters()); + + System.out.println("urnmap-plugin project - Results Retrieved: "); + System.out.println("URNName: " + " " + "URNValue: " ); + for(URNData d: list) + { + System.out.println( d.getURNName() + " " + d.getURNValue()); + } + + return list; + } + + @PUT + //public void insertNewRow(String key_, String value_) + public void insertNewRow(String temp) + { + System.out.println("AddNewRow: XXXXXXXXXXXXXXXXX ---> " + temp); + StringTokenizer st = new StringTokenizer(temp, "|"); + String key_ = ""; + String value_ = ""; + + while(st.hasMoreTokens()) { + key_ = st.nextToken(); + value_ = st.nextToken(); + System.out.println(key_ + "\t" + value_); + } + + System.out.println("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key_ + " , Value: " + value_); + URNData nRow = new URNData(); + nRow.setVer_("1"); + nRow.setURNName(key_); + nRow.setURNValue(value_); + + getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class); + + System.out.println("AddNewRow: XXXXXX END XXXXXXXXXXX"); + } + + @POST + // public void getPersistData(List myList) { + public void getPersistData(URNData d) { + + System.out.println("getPersistData: UrnName: " + d.getURNName() + " , URNValue: " + d.getURNValue() ); + + getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class); + //getQueryService().executeQuery("cockpit.sample.persistURNData", d, ProcessInstanceCountDto.class); + + + System.out.println("XXXXXXXXXX - END - XXXXXXXXXXXXXXX"); + } +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNMapPluginRootResource.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNMapPluginRootResource.java new file mode 100644 index 0000000000..539df0e319 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNMapPluginRootResource.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.resources; + +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +import org.camunda.bpm.cockpit.plugin.resource.AbstractPluginRootResource; +import org.openecomp.camunda.bpmn.plugin.urnmap.URNMapPlugin; + +@SuppressWarnings("deprecation") +@Path("plugin/" + URNMapPlugin.ID) +public class URNMapPluginRootResource extends AbstractPluginRootResource +{ + public URNMapPluginRootResource() { + super(URNMapPlugin.ID); + //super(""); + } + + @Path("{engineName}/process-instance") + public URNResource getProcessInstanceResource(@PathParam("engineName") String engineName) { + return subResource(new URNResource(engineName), engineName); + } +} diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java new file mode 100644 index 0000000000..1304fc24a7 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/resources/URNResource.java @@ -0,0 +1,205 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.camunda.bpmn.plugin.urnmap.resources; +/*** +import java.beans.Statement; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +*/ +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.sql.DataSource; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; + +import org.camunda.bpm.cockpit.db.QueryParameters; +import org.camunda.bpm.cockpit.plugin.resource.AbstractCockpitPluginResource; + + +//import org.camunda.bpm.cockpit.plugin.resource.AbstractPluginResource; +import org.openecomp.camunda.bpmn.plugin.urnmap.db.URNData; +import org.openecomp.mso.logger.MsoLogger; + + +//public class ProcessInstanceResource extends AbstractPluginResource { +public class URNResource extends AbstractCockpitPluginResource{ + public URNResource(String engineName) { + super(engineName); + } + + private Connection conn; + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + @GET + public List getUrnDataMap() + { + List list = new ArrayList(); + + try { + + conn = getDBConnection(); + PreparedStatement psData = conn + .prepareStatement("select * from MSO_URN_MAPPING order by NAME_"); + + ResultSet r = psData.executeQuery(); + + while(r.next()) + { + URNData d = new URNData(); + d.setURNName(r.getString("NAME_")); + d.setURNValue(r.getString("VALUE_")); + d.setVer_( r.getString("REV_")); + + list.add(d); + } + + psData.close(); + conn.close(); + + } catch (Exception e) + { + + e.printStackTrace(); + } + + for(URNData d: list) + { + msoLogger.debug( d.getURNName() + " " + d.getURNValue()); + //msoLogger.debug("Started Executing " + getTaskName()); + msoLogger.debug("Started Executing " + d.getURNName() + " " + d.getURNValue()); + } + + return list; + } + + public List getUrnDataMapOLD() + { + + List list = getQueryService() + .executeQuery("cockpit.urnMap.retrieveUrnKeyValuePair", new QueryParameters()); + + msoLogger.debug("urnmap-plugin project - Results Retrieved: "); + msoLogger.debug("URNName: " + " " + "URNValue: " ); + + for(URNData d: list) + { + //msoLogger.debug( d.getURNName() + " " + d.getURNValue()); + msoLogger.debug( d.getURNName() + " " + d.getURNValue()); + } + + return list; + } + + public Connection getDBConnection() + { + try { + + if(conn == null) + { + Context ctx = new InitialContext(); + DataSource ds = (DataSource)ctx.lookup("java:jboss/datasources/ProcessEngine");//jboss + conn = ds.getConnection(); + + } + + } catch (Exception e) + { + + e.printStackTrace(); + } + + return conn; + } + + @PUT + public void insertNewRow(String temp) + { + msoLogger.debug("AddNewRow: XXXXXXXXXXXXXXXXX ---> " + temp); + msoLogger.debug("AddNewRow: EngineName ---> " + engineName); + + StringTokenizer st = new StringTokenizer(temp, "|"); + String key_ = ""; + String value_ = ""; + + while(st.hasMoreTokens()) { + key_ = st.nextToken(); + value_ = st.nextToken(); + msoLogger.debug(key_ + "\t" + value_); + } + + msoLogger.debug("AddNewRow: XXXXXXXXXXXXXXXXX ---> key: " + key_ + " , Value: " + value_); + final URNData nRow = new URNData(); + nRow.setVer_("1"); + final String myKey = key_; + final String myValue = value_; + + msoLogger.debug("----------- START ----------------------"); + try { + + conn = getDBConnection(); + PreparedStatement psData = conn + .prepareStatement("Insert into MSO_URN_MAPPING values ('" + key_ + "', '" + value_ + "', '1')"); + + psData.executeUpdate(); + + psData.close(); + conn.close(); + //} + + } catch (Exception e) + { + + e.printStackTrace(); + } + // getQueryService().executeQuery("cockpit.urnMap.insertNewRow", nRow, URNData.class); + } + + @POST + public void getPersistData(URNData d) { + + //getQueryService().executeQuery("cockpit.urnMap.persistURNData", d, URNData.class); + + try { + + conn = getDBConnection(); + PreparedStatement psData = conn + .prepareStatement("UPDATE MSO_URN_MAPPING set VALUE_ ='"+ d.getURNValue() + "' WHERE NAME_='" + d.getURNName() + "'"); + + psData.executeUpdate(); + + psData.close(); + conn.close(); + } catch (Exception e) + { + + e.printStackTrace(); + } + + } +} diff --git a/bpmn/MSOURN-plugin/src/main/resources/META-INF/services/org.camunda.bpm.cockpit.plugin.spi.CockpitPlugin b/bpmn/MSOURN-plugin/src/main/resources/META-INF/services/org.camunda.bpm.cockpit.plugin.spi.CockpitPlugin new file mode 100644 index 0000000000..9a5055af22 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/resources/META-INF/services/org.camunda.bpm.cockpit.plugin.spi.CockpitPlugin @@ -0,0 +1 @@ +org.openecomp.camunda.bpm.plugin.urnmap.URNMapPlugin \ No newline at end of file diff --git a/bpmn/MSOURN-plugin/src/main/resources/mappings.xml b/bpmn/MSOURN-plugin/src/main/resources/mappings.xml new file mode 100644 index 0000000000..c66704ed15 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/resources/mappings.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/bpmn/MSOURN-plugin/src/main/resources/org/openecomp/camunda/bpm/plugin/urnmap/queries/urnMap.xml b/bpmn/MSOURN-plugin/src/main/resources/org/openecomp/camunda/bpm/plugin/urnmap/queries/urnMap.xml new file mode 100644 index 0000000000..d0b58618e4 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/resources/org/openecomp/camunda/bpm/plugin/urnmap/queries/urnMap.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + insert into MSO_URN_MAPPING (NAME_, VALUE_, REV_) + values ( + #{URNName}, #{URNValue}, 1 + ) + + + + + + + + + + + update MSO_URN_MAPPING set + NAME_ = #{URNName}, + VALUE_ = #{URNValue}, + REV_ = 1 + where NAME_=#{URNName} + + diff --git a/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/dashboard.html b/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/dashboard.html new file mode 100644 index 0000000000..cc794e5518 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/dashboard.html @@ -0,0 +1,63 @@ + + +
+
+
+

Process Engine - URN Mapping

+
+
+
+ + + + + + + +
+
+ + + + + + + +
+
+ + + + + + +
+
+
+
+
+
+
+
diff --git a/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/plugin.js b/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/plugin.js new file mode 100644 index 0000000000..702f6cd3f5 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/app/plugin.js @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ + +define(['angular'], function(angular) { + + var DashboardController = ["$scope", "$http", "Uri", function($scope, $http, Uri) { + + $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance")) + .success(function(data) { + $scope.UrnDataMap = data; + }); + + //enable saveRow button + $scope.enableButton=function(urnData) + { + document.getElementById("btn_" + urnData.urnname + "_key").disabled = false; + }; + + $scope.enableAddRowBtn=function() + { + if(document.getElementById("new_key").value.trim().length >0) + document.getElementById("addRow_BTN").disabled = false; + else + document.getElementById("addRow_BTN").disabled = true; + }; + + + $scope.addNewRow = function() + { + var newKey = document.getElementById("new_key").value.trim(); + var newValue = document.getElementById("new_value").value.trim(); + var x; + + for (var i=0;i<$scope.UrnDataMap.length;i++) + { + var n = $scope.UrnDataMap[i].urnname.localeCompare(newKey); + if(n == 0){ + x = "match"; + } + } + + if(Boolean(x)) + { + alert("URN Name already exists, please check the KEY!"); + } + else + { + if(newKey.length >0 ) + { + + var temp = newKey + "|" + newValue; + + $http.put(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"), temp); + + document.getElementById("new_key").value = ""; + document.getElementById("new_value").value = ""; + + } + + } + //this.enableAddRowBtn; + document.getElementById("addRow_BTN").disabled = true; + + $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance")) + .success(function(data) { + $scope.UrnDataMap = data; + }); + + + } + + $scope.retrieveData = function() { + + $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance")) + .success(function(data) { + $scope.UrnDataMap = data; + }); + } + + $scope.SaveRow = function(user) + { + $http.post(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"), user); + + document.getElementById("btn_" + user.urnname + "_key").disabled = true; + document.getElementById(user.urnname + "_status").style.display = ""; + this.enableAddRowBtn; + + $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance")) + .success(function(data) { + $scope.UrnDataMap = data; + }); + + }; + }]; + + var Configuration = ['ViewsProvider', function(ViewsProvider) { + + ViewsProvider.registerDefaultView('cockpit.dashboard', { + id: 'process-definitions', + label: 'Deployed Processes', + url: 'plugin://urnMap-plugin/static/app/dashboard.html', + controller: DashboardController, + // make sure we have a higher priority than the default plugin + priority: 12 + }); + }]; +//START +//END + + var ngModule = angular.module('cockpit.plugin.urnMap-plugin', []); + + ngModule.config(Configuration); + + return ngModule; +}); diff --git a/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/info.txt b/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/info.txt new file mode 100644 index 0000000000..09b62620e6 --- /dev/null +++ b/bpmn/MSOURN-plugin/src/main/resources/plugin-webapp/urnMap-plugin/info.txt @@ -0,0 +1 @@ +# Client side assets of the urnMap-plugin \ No newline at end of file -- cgit 1.2.3-korg