Skip to content

Commit

Permalink
replace JPAAuditService use in MigrationManager with direct EntityMan… (
Browse files Browse the repository at this point in the history
#1311)

* replace JPAAuditService use in MigrationManager with direct EntityManager to avoid issues with spring setups

* removed not used dependency of old jackson library
  • Loading branch information
mswiderski committed Aug 24, 2018
1 parent 11128f7 commit be2ed83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 0 additions & 5 deletions jbpm-human-task/jbpm-human-task-jpa/pom.xml
Expand Up @@ -65,11 +65,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>


<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>

<dependency> <dependency>
<!-- only needed for metadata generation --> <!-- only needed for metadata generation -->
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
Expand Down
Expand Up @@ -41,7 +41,6 @@
import org.drools.persistence.api.SessionNotFoundException; import org.drools.persistence.api.SessionNotFoundException;
import org.drools.persistence.api.TransactionManager; import org.drools.persistence.api.TransactionManager;
import org.drools.persistence.api.TransactionManagerFactory; import org.drools.persistence.api.TransactionManagerFactory;
import org.jbpm.process.audit.JPAAuditLogService;
import org.jbpm.process.audit.ProcessInstanceLog; import org.jbpm.process.audit.ProcessInstanceLog;
import org.jbpm.process.instance.InternalProcessRuntime; import org.jbpm.process.instance.InternalProcessRuntime;
import org.jbpm.process.instance.timer.TimerInstance; import org.jbpm.process.instance.timer.TimerInstance;
Expand Down Expand Up @@ -329,15 +328,18 @@ private void validate() {
String auditPu = manager.getDeploymentDescriptor().getAuditPersistenceUnit(); String auditPu = manager.getDeploymentDescriptor().getAuditPersistenceUnit();


EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(auditPu); EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(auditPu);

EntityManager em = emf.createEntityManager();
JPAAuditLogService auditService = new JPAAuditLogService(emf);
try { try {
ProcessInstanceLog log = auditService.findProcessInstance(migrationSpec.getProcessInstanceId());
ProcessInstanceLog log = (ProcessInstanceLog) em.createQuery("FROM ProcessInstanceLog p WHERE p.processInstanceId = :processInstanceId")
.setParameter("processInstanceId", migrationSpec.getProcessInstanceId())
.getSingleResult();

if (log == null || log.getStatus() != ProcessInstance.STATE_ACTIVE) { if (log == null || log.getStatus() != ProcessInstance.STATE_ACTIVE) {
report.addEntry(Type.ERROR, "No process instance found or it is not active (id " + migrationSpec.getProcessInstanceId() + " in status " + (log == null ? "-1" : log.getStatus())); report.addEntry(Type.ERROR, "No process instance found or it is not active (id " + migrationSpec.getProcessInstanceId() + " in status " + (log == null ? "-1" : log.getStatus()));
} }
} finally { } finally {
auditService.dispose(); em.close();
} }
} }


Expand Down

0 comments on commit be2ed83

Please sign in to comment.