diff options
author | Rob Daugherty <rd472p@att.com> | 2018-03-14 02:07:32 -0400 |
---|---|---|
committer | Rob Daugherty <rd472p@att.com> | 2018-03-14 04:08:41 -0400 |
commit | 38f720752af4d4aad8c4e467a288d9048659f688 (patch) | |
tree | e81066a8b5c77272e30fb57a64999573c4db4d86 /bpmn/MSOURN-plugin | |
parent | aee3d223f92a6f250f43e17558a2dfd576ff7294 (diff) |
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 <rd472p@att.com>
Diffstat (limited to 'bpmn/MSOURN-plugin')
17 files changed, 1049 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="urnMap-plugin" default="deploy.jboss"> + + <property file="build.properties" /> + <property file="${user.home}/.camunda/build.properties" /> + <property name="target.dir" value="target" /> + + <condition property="mvn.executable" value="mvn.bat" else="mvn"> + <os family="windows"/> + </condition> + + <target name="deploy.jboss" depends="package.mvn, install.cockpit.plugin" description="Copies the cockit plugin to the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'" /> + + <target name="deploy.tomcat" depends="package.mvn" description="Copies the cockpit plugin to the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'"> + <fail unless="deploy.tomcat.dir" message="No deployment folder has been configured. Please copy the file '${basedir}/build.properties.example' to '${basedir}/build.properties' or '${user.home}/.camunda/build.properties' and change it according to your environment." /> + <copy file="${target.dir}/${ant.project.name}.jar" todir="${deploy.tomcat.dir}/camunda/WEB-INF/lib" /> + <touch file="${deploy.tomcat.dir}/camunda/WEB-INF/web.xml"/> + </target> + + <target name="package.mvn"> + <exec executable="${mvn.executable}" dir="." failonerror="true"> + <env key="MAVEN_OPTS" value="-Xmx1024m -Xms512m -DskipTests=true -Dmaven.test.skip=true" /> + <arg line="clean package" /> + </exec> + </target> + + <target name="install.cockpit.plugin"> + <fail unless="deploy.jboss.dir" message="No deployment folder has been configured. Please copy the file '${basedir}/build.properties.example' to '${basedir}/build.properties' or '${user.home}/.camunda/build.properties' and change it according to your environment." /> + <path id="cockpit.file.id"> + <fileset dir="${deploy.jboss.dir}"> + <include name="camunda-webapp-*.war"/> + </fileset> + </path> + <property name="cockpit.file" refid="cockpit.file.id"/> + <war destfile="${cockpit.file}" update="true"> + <zipfileset file="${target.dir}/${ant.project.name}.jar" fullpath="WEB-INF/lib/${ant.project.name}.jar" /> + </war> + </target> + + <target name="undeploy.jboss" description="Deletes the cockpit plugin from the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'"> + <path id="cockpit.file.id"> + <fileset dir="${deploy.jboss.dir}"> + <include name="camunda-webapp-*.war"/> + </fileset> + </path> + <property name="cockpit.file" refid="cockpit.file.id"/> + <basename property="cockpit.filename" file="${cockpit.file}"/> + <move file="${cockpit.file}" todir="${java.io.tmpdir}"/> + <zip destfile="${cockpit.file}"> + <zipfileset src="${java.io.tmpdir}/${cockpit.filename}"> + <exclude name="WEB-INF/lib/${ant.project.name}.jar"/> + </zipfileset> + </zip> + </target> + + <target name="undeploy.tomcat" description="Deletes the cockpit plugin from the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'"> + <delete file="${deploy.tomcat.dir}/camunda/WEB-INF/lib/${ant.project.name}.jar" /> + </target> + +</project> 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 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.so</groupId>
+ <artifactId>bpmn</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.so</groupId>
+ <artifactId>cockpit-urnmap-plugin</artifactId>
+
+ <packaging>jar</packaging>
+
+ <name>MSO URN Mapping Cockpit Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.camunda.bpm.webapp</groupId>
+ <artifactId>camunda-webapp</artifactId>
+ <classifier>classes</classifier>
+ <version>${camunda.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <!-- TODO Upate it to ee version -->
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine</artifactId>
+ <version>${camunda.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
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<Class<?>> getResourceClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ classes.add(URNMapPluginRootResource.class);
+
+ return classes;
+ }
+
+ @Override
+ public List<String> 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<? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequired() {
+ List<CommandInterceptor> defaultCommandInterceptorsTxRequired = new ArrayList<CommandInterceptor>();
+ 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> T executeQueryCommand(Command<T> 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<URNData> getProperties() {
+ ProcessEngineImpl processEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
+ ProcessEngineConfigurationImpl processEngineConfiguration = processEngine.getProcessEngineConfiguration();
+
+ MyBatisQueryCommandExecutor commandExecutor = new MyBatisQueryCommandExecutor(processEngineConfiguration, "mappings.xml");
+ return commandExecutor.executeQueryCommand(new Command<List<URNData>>() {
+
+ @SuppressWarnings("unchecked")
+ public List<URNData> execute(CommandContext commandContext) {
+ return (List<URNData>) 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<URNData> getUrnDataMap() {
+ List<URNData> list = getQueryService()
+ .executeQuery(
+ "cockpit.urnMap.retrieveUrnKeyValuePair",
+ new QueryParameters<URNData>());
+
+ 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<URNData > 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<URNData> getUrnDataMap()
+ {
+ List<URNData> 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<URNData> getUrnDataMapOLD()
+ {
+
+ List<URNData> list = getQueryService()
+ .executeQuery("cockpit.urnMap.retrieveUrnKeyValuePair", new QueryParameters<URNData>());
+
+ 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 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+
+<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
+
+<configuration>
+ <settings>
+ <setting name="lazyLoadingEnabled" value="false" />
+ </settings>
+ <mappers>
+ <mapper resource="org/openecomp/camunda/bpm/plugin/urnmap/queries/urnMap.xml" />
+ </mappers>
+</configuration>
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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + 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========================================================= + --> + + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + +<mapper namespace="cockpit.urnMap"> + <resultMap id="urnDataMap" type="org.openecomp.camunda.bpm.plugin.urnmap.db.URNData"> + <result property="URNName" column="URNNAME" jdbcType="VARCHAR"/> + <result property="URNValue" column="URNVALUE" jdbcType="VARCHAR" /> + </resultMap> + + <select id="retrieveUrnKeyValuePair" resultMap="urnDataMap"> + select NAME_ URNName, VALUE_ URNValue from MSO_URN_MAPPING + </select> + + + <!-- INSERT cockpit.InsertURNData keyProperty="NAME_" --> + <resultMap id="insertNewRow" type="org.openecomp.camunda.bpm.plugin.urnmap.db.URNData"> + <result property="URNName" column="NAME_" jdbcType="VARCHAR" /> + <result property="URNValue" column="VALUE_" jdbcType="VARCHAR" /> + <result property="1" column="REV_" jdbcType="INTEGER"/> + </resultMap> + + <insert id="insertNewRow" parameterType="org.openecomp.camunda.bpm.plugin.urnmap.db.URNData"> + insert into MSO_URN_MAPPING (NAME_, VALUE_, REV_) + values ( + #{URNName}, #{URNValue}, 1 + ) + </insert> + +<!-- UPDATE cockpit.InsertURNData --> + <resultMap id="saveURNMappingDataMap" type="org.openecomp.camunda.bpm.plugin.urnmap.db.URNData"> + <result property="URNName" column="NAME_" jdbcType="VARCHAR" /> + <result property="URNValue" column="VALUE_" jdbcType="VARCHAR" /> + <result property="1" column="REV_" jdbcType="INTEGER"/> + </resultMap> + + <update id="persistURNData"> + update MSO_URN_MAPPING set + NAME_ = #{URNName}, + VALUE_ = #{URNValue}, + REV_ = 1 + where NAME_=#{URNName} +</update> +</mapper> 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 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + 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========================================================= + --> + +<div class="form-group container"> + <form novalidate="novalidate" class="simple-form" name="urnMapper"> + <div class="panel panel-default"> + <div class="panel-heading" style="padding:3px;background:#871020 !important;color:#fff"> <h3 style="margin:1px" class="heading">Process Engine - URN Mapping</h3></div> + <div class="panel-body"> + <div class="well"> + <div class="input-group well" style="padding:5px"> + <input id="new_key" class="form-control input-md" placeholder="New URN Key" size="25" type="text" name="URNName" value="" ng-blur="enableAddRowBtn()"> + <span class="input-group-btn" style="width:0px;"></span> + <input type="text" class="form-control input-md" size="55" style="margin-left:-1px" id="new_value" placeholder="New URN Value" name="URNValue" /> + <span class="input-group-btn" style="width:0px;"></span> + <span class="input-group-btn"> + <button class="btn btn-primary" type="button" id="addRow_BTN" data-ng-click="addNewRow(); setTimeout( retrieveData(), 1000);" disabled data-original-title="" title="">Add!</button> + </span> + </div> + <div> + <table cellpadding="0" cellspacing="0" class="table responsive" widht="100%"> + <tbody> + <tr data-ng-repeat="urnData in UrnDataMap"> + <td> + <div class="input-group"> + <input id="{{ urnData.urnname }}_key" type="text" style="border:0px solid #bfbfbf" size="25" class="form-control input-md" ng-blur="SaveRow( urnData )" value="{{ urnData.urnName }}" data-ng-model= "urnData.urnname" data-ng-change="enableButton(urnData)"/> + <span class="input-group-btn" style="width:0px;"></span> + <input id="{{ urnData.urnname }}_value" type="text" style="border:0px solid #dfdfdf;border-left:1px solid #bfbfbf" size="55" class="form-control input-md" ng-blur="SaveRow( urnData )" value="{{ urnData.urnvalue }}" data-ng-model="urnData.urnvalue" data-ng-change="enableButton(urnData)"/> + <span class="input-group-btn"> + <button disabled="true" class="btn btn-primary" type="button" id="btn_{{ urnData.urnname }}_key" data-ng-click="SaveRow( urnData ); setTimeout( retrieveData(), 1000);"> + <span class="glyphicon glyphicon-floppy-disk"></span> + </button> + </span> + </div><!-- /input-group --> + </td> + <!-- + <td><button id="btn_{{ urnData.urnname }}_key" data-ng-click="SaveRow( urnData )" disabled>SaveRecord</button> </td> + --> + </tr> + </tbody> + </table> + </div> + </div> + </div> + </div> + </form> +</div> 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 |