[jbpm-commits] JBoss JBPM SVN: r5758 - in jbpm4/trunk/modules: db/src and 11 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Oct 20 00:16:33 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-10-20 00:16:28 -0400 (Tue, 20 Oct 2009)
New Revision: 5758
Added:
jbpm4/trunk/modules/db/src/test/
jbpm4/trunk/modules/db/src/test/java/
jbpm4/trunk/modules/db/src/test/java/org/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java
jbpm4/trunk/modules/db/src/test/resources/
jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/db/src/test/resources/logging.properties
Modified:
jbpm4/trunk/modules/db/.classpath
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
Log:
[JBPM-2509] add langid property to processes that do not have it
Modified: jbpm4/trunk/modules/db/.classpath
===================================================================
--- jbpm4/trunk/modules/db/.classpath 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/db/.classpath 2009-10-20 04:16:28 UTC (rev 5758)
@@ -2,6 +2,8 @@
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java 2009-10-20 04:16:28 UTC (rev 5758)
@@ -24,9 +24,12 @@
import java.util.List;
import org.hibernate.Session;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.RepositoryService;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
-import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.repository.DeploymentProperty;
/**
* Adds the "langid" property to each deployed process.
@@ -37,16 +40,31 @@
private static final long serialVersionUID = 1L;
+ @SuppressWarnings("unchecked")
public Void execute(Environment environment) throws Exception {
Session session = environment.get(Session.class);
- // find process definitions without a langid property
- List processDefinitions = session.createCriteria(JpdlProcessDefinition.class).list();
+ // find deployments without a langid property
+ List<DeploymentImpl> deployments = session.createQuery("from "
+ + DeploymentImpl.class.getName()
+ + " d\n"
+ + "where not exists(\n"
+ + " from "
+ + DeploymentProperty.class.getName()
+ + " p\n"
+ + " where p.deployment = d\n"
+ + " and p.key = '"
+ + DeploymentImpl.KEY_PROCESS_LANGUAGE_ID
+ + "')").list();
// initialize missing langid property to "jpdl-4.0"
- for (Object element : processDefinitions) {
- JpdlProcessDefinition processDefinition = (JpdlProcessDefinition) element;
- // TODO how?
+ RepositoryService repositoryService = environment.get(RepositoryService.class);
+ for (DeploymentImpl deployment : deployments) {
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .deploymentId(deployment.getId())
+ .list();
+ for (ProcessDefinition processDefinition : processDefinitions) {
+ deployment.setProcessLanguageId(processDefinition.getName(), "jpdl-4.0");
+ }
}
return null;
}
-
}
Added: jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java
===================================================================
--- jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java (rev 0)
+++ jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db.internal.upgrade;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class AddLangIdCmdTest extends JbpmTestCase {
+
+ private String deploymentId;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromString("process.jpdl.xml", "<process name='"
+ + getName()
+ + "'>"
+ + " <start/>"
+ + "</process>")
+ .deploy();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+ super.tearDown();
+ }
+
+ public void testAddLangId() {
+ processEngine.execute(new Command<Void>() {
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ DeploymentImpl deployment = (DeploymentImpl) environment.get(Session.class)
+ .load(DeploymentImpl.class, Long.valueOf(deploymentId));
+ Object langId = deployment.removeObjectProperty(getName(), DeploymentImpl.KEY_PROCESS_LANGUAGE_ID);
+ assertEquals("jpdl-4.2", langId);
+ return null;
+ }
+ });
+
+ processEngine.execute(new AddLangIdCmd());
+
+ processEngine.execute(new Command<Void>() {
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ DeploymentImpl deployment = (DeploymentImpl) environment.get(Session.class)
+ .load(DeploymentImpl.class, Long.valueOf(deploymentId));
+ assertEquals("jpdl-4.0", deployment.getProcessLanguageId(getName()));
+ return null;
+ }
+ });
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Property changes on: jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/logging.properties 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-20 04:16:28 UTC (rev 5758)
@@ -151,7 +151,7 @@
public Set<String> getResourceNames() {
if (resources==null) {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
return resources.keySet();
}
@@ -217,6 +217,20 @@
objectProperties.add(deploymentProperty);
}
+ public Object removeObjectProperty(String objectName, String key) {
+ if (objectProperties != null) {
+ for (DeploymentProperty deploymentProperty : objectProperties) {
+ if (deploymentProperty.getObjectName().equals(objectName)
+ && deploymentProperty.getKey().equals(key)) {
+ Object value = deploymentProperty.getValue();
+ objectProperties.remove(deploymentProperty);
+ return value;
+ }
+ }
+ }
+ return null;
+ }
+
public Object getObjectProperty(String objectName, String key) {
if (objectProperties!=null) {
for (DeploymentProperty deploymentProperty: objectProperties) {
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-10-20 04:16:28 UTC (rev 5758)
@@ -26,7 +26,7 @@
<set name="objectProperties"
table="JBPM4_DEPLOYPROPS"
- cascade="all">
+ cascade="all-delete-orphan">
<key column="DEPLOYMENT_" />
<one-to-many class="org.jbpm.pvm.internal.repository.DeploymentProperty" />
</set>
More information about the jbpm-commits
mailing list