diff options
Diffstat (limited to 'calamus-engine')
13 files changed, 338 insertions, 142 deletions
diff --git a/calamus-engine/pom.xml b/calamus-engine/pom.xml index 98ad6bf..48711fa 100755 --- a/calamus-engine/pom.xml +++ b/calamus-engine/pom.xml @@ -245,6 +245,7 @@ <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-test</artifactId> + <scope>test</scope> <exclusions> <exclusion> <groupId>javax.transaction</groupId> @@ -314,19 +315,22 @@ </exclusion> </exclusions> </dependency> - <!-- + <dependency> - <groupId>org.jboss.seam.transaction</groupId> - <artifactId>seam-transaction</artifactId> - <version>${seam.tx.version}</version> - <exclusions> - <exclusion> - <artifactId>solder-api</artifactId> - <groupId>org.jboss.solder</groupId> - </exclusion> - </exclusions> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>4.0.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-orm</artifactId> + <version>4.0.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.kie</groupId> + <artifactId>kie-spring</artifactId> + <version>${drools.version}</version> </dependency> - --> <!-- test: arquillian --> <!-- diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusDbConfig.java b/calamus-engine/src/main/java/io/trygvis/engine/CalamusDbConfig.java new file mode 100644 index 0000000..39772c8 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/CalamusDbConfig.java @@ -0,0 +1,129 @@ +package io.trygvis.engine; + +import bitronix.tm.BitronixTransactionManager; +import bitronix.tm.TransactionManagerServices; +import bitronix.tm.resource.jdbc.PoolingDataSource; +import com.googlecode.flyway.core.Flyway; +import com.googlecode.flyway.core.api.MigrationInfo; +import com.googlecode.flyway.core.api.MigrationInfoService; +import org.jbpm.process.audit.JPAAuditLogService; +import org.kie.api.io.Resource; +import org.kie.api.io.ResourceType; +import org.kie.api.runtime.manager.RuntimeEnvironment; +import org.kie.internal.io.ResourceFactory; +import org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean; +import org.kie.spring.factorybeans.RuntimeManagerFactoryBean; +import org.slf4j.Logger; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.DependsOn; +import org.springframework.context.annotation.Lazy; +import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy; +import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.jta.JtaTransactionManager; +import org.springframework.transaction.support.TransactionTemplate; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import static java.lang.String.format; +import static org.slf4j.LoggerFactory.getLogger; + +/** + * http://planet.jboss.org/post/jbpm_6_with_spring + */ +@Configuration +@EnableTransactionManagement +public class CalamusDbConfig { + private final Logger log = getLogger(getClass()); + + @Bean + public DataSource dataSource() { + PoolingDataSource ds = new PoolingDataSource(); + ds.setUniqueName("jdbc/jbpm-ds"); + ds.setClassName(bitronix.tm.resource.jdbc.lrc.LrcXADataSource.class.getCanonicalName()); + ds.setMaxPoolSize(3); + ds.setAllowLocalTransactions(true); + ds.getDriverProperties().put("user", "jbpm"); + ds.getDriverProperties().put("password", "jbpm"); + ds.getDriverProperties().put("url", "jdbc:postgresql://localhost/jbpm"); + ds.getDriverProperties().put("driverClassName", org.postgresql.Driver.class.getCanonicalName()); + ds.init(); + + return new TransactionAwareDataSourceProxy(new LazyConnectionDataSourceProxy(ds)); +// return ds; + } + + public static class DbMigrations { + } + + @Bean + public DbMigrations dbMigrations(DataSource dataSource) { + runFlyway(log, dataSource, "", "public"); + return new DbMigrations(); + } + + private static void runFlyway(Logger log, DataSource dataSource, String prefix, String schema) { + log.info("Running migrations for {}", schema); + + Flyway flyway = new Flyway(); + flyway.setDataSource(dataSource); + flyway.setSchemas(schema); + flyway.setLocations("db/" + prefix); + flyway.setInitOnMigrate(true); + MigrationInfoService info = flyway.info(); + log.info(format("%-15s %-10s %-19s %s", "Version", "State", "Installed on", "Description")); + for (MigrationInfo mi : info.all()) { + Date installedOn = mi.getInstalledOn(); + log.info(format("%-15s %-10s %-19s %s", + mi.getVersion(), + trimToEmpty(mi.getState().getDisplayName()), + installedOn != null ? new Date(installedOn.getTime()).toString() : "", + trimToEmpty(mi.getDescription()))); + } + flyway.migrate(); + } + + private static String trimToEmpty(String string) { + if (string == null) { + return ""; + } + + return string.trim(); + } + + @Bean(destroyMethod = "shutdown") + public BitronixTransactionManager bitronixTransactionManager() { +// bitronix.tm.Configuration configuration = TransactionManagerServices.getConfiguration(); + return TransactionManagerServices.getTransactionManager(); + } + + @Bean + public PlatformTransactionManager platformTransactionManager(BitronixTransactionManager transactionManager) { + return new JtaTransactionManager(transactionManager, transactionManager); + } + + @Bean + public TransactionTemplate transactionTemplate(PlatformTransactionManager platformTransactionManager) { + return new TransactionTemplate(platformTransactionManager); + } + + @Bean + @DependsOn("dbMigrations") + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + LocalContainerEntityManagerFactoryBean x = new LocalContainerEntityManagerFactoryBean(); + x.setPersistenceUnitName("org.jbpm.persistence.jpa"); + return x; + } + + @Bean + public JPAAuditLogService jpaAuditLogService(EntityManagerFactory entityManagerFactory) { + return new JPAAuditLogService(entityManagerFactory); + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java index cc2ff41..5b0e8ec 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java @@ -1,34 +1,20 @@ package io.trygvis.engine; -import bitronix.tm.TransactionManagerServices; -import bitronix.tm.resource.jdbc.PoolingDataSource; -import com.googlecode.flyway.core.Flyway; -import com.googlecode.flyway.core.api.MigrationInfo; -import com.googlecode.flyway.core.api.MigrationInfoService; -import org.jbpm.bpmn2.handler.ServiceTaskHandler; -import org.jbpm.process.audit.AuditLoggerFactory; -import org.kie.api.KieBase; -import org.kie.api.runtime.Environment; -import org.kie.api.runtime.EnvironmentName; import org.kie.api.runtime.process.ProcessInstance; -import org.kie.internal.KnowledgeBaseFactory; -import org.kie.internal.io.ResourceFactory; -import org.kie.internal.persistence.jpa.JPAKnowledgeService; import org.kie.internal.runtime.StatefulKnowledgeSession; -import org.kie.internal.utils.KieHelper; import org.slf4j.Logger; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.transaction.support.TransactionTemplate; import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import javax.sql.DataSource; -import java.util.Date; -import static java.lang.String.format; import static org.slf4j.LoggerFactory.getLogger; public class CalamusJbpm { private final Logger log = getLogger(getClass()); + private final TransactionTemplate transactionTemplate; + private final EntityManagerFactory emf; private final StatefulKnowledgeSession session; @@ -44,74 +30,45 @@ public class CalamusJbpm { } public CalamusJbpm() { - PoolingDataSource ds = new PoolingDataSource(); - ds.setUniqueName("jdbc/jbpm-ds"); - ds.setClassName(bitronix.tm.resource.jdbc.lrc.LrcXADataSource.class.getCanonicalName()); - ds.setMaxPoolSize(3); - ds.setAllowLocalTransactions(true); - ds.getDriverProperties().put("user", "jbpm"); - ds.getDriverProperties().put("password", "jbpm"); - ds.getDriverProperties().put("url", "jdbc:postgresql://localhost/jbpm"); - ds.getDriverProperties().put("driverClassName", org.postgresql.Driver.class.getCanonicalName()); - ds.init(); - - runFlyway(log, ds, "", "public"); - - emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); - Environment env = KnowledgeBaseFactory.newEnvironment(); - env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); - env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager()); - - KieBase kieBase = new KieHelper() - .addResource(ResourceFactory.newClassPathResource("Deploy.bpmn2")) - .build(); - - session = JPAKnowledgeService.newStatefulKnowledgeSession(kieBase, null, env); - session.addEventListener(AuditLoggerFactory.newJPAInstance(env)); - - session.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler()); - session.getWorkItemManager().registerWorkItemHandler("Upgrade App", new UpgradeAppWorkItemHandler()); - session.getWorkItemManager().registerWorkItemHandler("Restart App", new RestartAppWorkItemHandler()); + AnnotationConfigApplicationContext spring = new AnnotationConfigApplicationContext(CalamusDbConfig.class, CalamusJbpmConfig.class); + +// emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); +// Environment env = KnowledgeBaseFactory.newEnvironment(); +// env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); +// env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager()); + +// KieBase kieBase = new KieHelper() +// .addResource(ResourceFactory.newClassPathResource("Deploy.bpmn2")) +// .build(); + +// RuntimeEnvironment runtimeEnvironment = spring.getBean(RuntimeEnvironment.class); +// +// KieBase kieBase = runtimeEnvironment.getKieBase(); + + transactionTemplate = spring.getBean(TransactionTemplate.class); + emf = spring.getBean(EntityManagerFactory.class); + session = null; +// session = JPAKnowledgeService.newStatefulKnowledgeSession(kieBase, null, env); +// session.addEventListener(AuditLoggerFactory.newJPAInstance(env)); + +// session.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler()); +// session.getWorkItemManager().registerWorkItemHandler("Upgrade App", new UpgradeAppWorkItemHandler()); +// session.getWorkItemManager().registerWorkItemHandler("Restart App", new RestartAppWorkItemHandler()); } - public StatefulKnowledgeSession getSession() { - return session; + public TransactionTemplate getTransactionTemplate() { + return transactionTemplate; } public EntityManagerFactory getEntityManagerFactory() { return emf; } - public void startProcess(CalamusProcess process) { - ProcessInstance processInstance = session.startProcess(process.name); - } - - private static void runFlyway(Logger log, DataSource dataSource, String prefix, String schema) { - log.info("Running migrations for {}", schema); - - Flyway flyway = new Flyway(); - flyway.setDataSource(dataSource); - flyway.setSchemas(schema); - flyway.setLocations("db/" + prefix); - flyway.setInitOnMigrate(true); - MigrationInfoService info = flyway.info(); - log.info(format("%-15s %-10s %-19s %s", "Version", "State", "Installed on", "Description")); - for (MigrationInfo mi : info.all()) { - Date installedOn = mi.getInstalledOn(); - log.info(format("%-15s %-10s %-19s %s", - mi.getVersion(), - trimToEmpty(mi.getState().getDisplayName()), - installedOn != null ? new Date(installedOn.getTime()).toString() : "", - trimToEmpty(mi.getDescription()))); - } - flyway.migrate(); + public StatefulKnowledgeSession getSession() { + return session; } - private static String trimToEmpty(String string) { - if (string == null) { - return ""; - } - - return string.trim(); + public void startProcess(CalamusProcess process) { + ProcessInstance processInstance = session.startProcess(process.name); } } diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpmConfig.java b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpmConfig.java new file mode 100644 index 0000000..98ba550 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpmConfig.java @@ -0,0 +1,63 @@ +package io.trygvis.engine; + +import org.jbpm.process.audit.JPAAuditLogService; +import org.kie.api.io.Resource; +import org.kie.api.io.ResourceType; +import org.kie.api.runtime.manager.RuntimeEnvironment; +import org.kie.internal.io.ResourceFactory; +import org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean; +import org.kie.spring.factorybeans.RuntimeManagerFactoryBean; +import org.slf4j.Logger; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +import static org.slf4j.LoggerFactory.getLogger; + +/** + * http://planet.jboss.org/post/jbpm_6_with_spring + */ +@Configuration +public class CalamusJbpmConfig { + private final Logger log = getLogger(getClass()); + + @Bean + @Lazy + public RuntimeEnvironmentFactoryBean runtimeEnvironment(DataSource dataSource, CalamusDbConfig.DbMigrations dbMigrations, EntityManagerFactory entityManagerFactory, PlatformTransactionManager platformTransactionManager) { + System.out.println("CalamusConfig.runtimeEnvironmentFactoryBean"); + System.out.println("dataSource = " + dataSource); + System.out.println("dbMigrations = " + dbMigrations); + System.out.println("entityManagerFactory = " + entityManagerFactory); + System.out.println("platformTransactionManager = " + platformTransactionManager); + RuntimeEnvironmentFactoryBean x = new RuntimeEnvironmentFactoryBean(); + x.setType("DEFAULT"); + + Map<Resource, ResourceType> assets = new HashMap<>(); + assets.put(ResourceFactory.newClassPathResource("/Deploy.bpmn2"), ResourceType.BPMN2); + x.setAssets(assets); + + x.setEntityManagerFactory(entityManagerFactory); + x.setTransactionManager(platformTransactionManager); + + return x; + } + +// @Bean +// public RuntimeManagerFactoryBean runtimeManagerFactoryBean(RuntimeEnvironment runtimeEnvironment) { +// RuntimeManagerFactoryBean x = new RuntimeManagerFactoryBean(); +// x.setIdentifier("spring-rm"); +// x.setRuntimeEnvironment(runtimeEnvironment); +// return x; +// } + + @Bean + public JPAAuditLogService jpaAuditLogService(EntityManagerFactory entityManagerFactory) { + return new JPAAuditLogService(entityManagerFactory); + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/Main.java b/calamus-engine/src/main/java/io/trygvis/engine/Main.java index c77bb7d..c5916e0 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/Main.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/Main.java @@ -18,7 +18,7 @@ public class Main { // transaction.commit(); try (MqClient buildResultClient = new MqClient(brokerUrl, "jenkins.build-result", new JenkinsBuildResultMessageListener(session)); - MqClient newDeployClient = new MqClient(brokerUrl, "nexus.new-artifact", new NexusNewArtifactMessageListener(calamus.getEntityManagerFactory(), session))) { + MqClient newDeployClient = new MqClient(brokerUrl, "nexus.new-artifact", new NexusNewArtifactMessageListener(calamus.getTransactionTemplate(), calamus.getEntityManagerFactory(), session))) { while (true) { Thread.sleep(1000); diff --git a/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java b/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java index 22b2c4c..0813c27 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java @@ -3,10 +3,11 @@ package io.trygvis.engine; import io.trygvis.engine.domain.Artifact; import io.trygvis.engine.domain.Process; import io.trygvis.engine.domain.ProcessTrigger; -import org.kie.api.runtime.Environment; -import org.kie.api.runtime.EnvironmentName; import org.kie.internal.runtime.StatefulKnowledgeSession; import org.slf4j.Logger; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; import javax.jms.JMSException; import javax.jms.Message; @@ -14,7 +15,6 @@ import javax.jms.MessageListener; import javax.jms.TextMessage; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; import javax.persistence.NoResultException; import javax.persistence.TypedQuery; import java.io.IOException; @@ -26,10 +26,12 @@ import static org.slf4j.LoggerFactory.getLogger; public class NexusNewArtifactMessageListener implements MessageListener { private final Logger log = getLogger(getClass()); + private final TransactionTemplate transactionTemplate; private final EntityManagerFactory entityManagerFactory; private final StatefulKnowledgeSession session; - public NexusNewArtifactMessageListener(EntityManagerFactory entityManagerFactory, StatefulKnowledgeSession session) { + public NexusNewArtifactMessageListener(TransactionTemplate transactionTemplate, EntityManagerFactory entityManagerFactory, StatefulKnowledgeSession session) { + this.transactionTemplate = transactionTemplate; this.entityManagerFactory = entityManagerFactory; this.session = session; } @@ -54,41 +56,51 @@ public class NexusNewArtifactMessageListener implements MessageListener { log.info("Artifact event: groupId={}, artifactId={}, version={}, classifier={}, extension={}", groupId, artifactId, version, classifier, extension); - // Check for any processes that will be started because of this - EntityManager entityManager = entityManagerFactory.createEntityManager(); - - TypedQuery<Artifact> query = entityManager.createQuery("FROM Artifact WHERE groupId=:groupId AND artifactId=:artifactId AND version=:version AND extension=:extension", Artifact.class); - query.setParameter("groupId", groupId); - query.setParameter("artifactId", artifactId); - query.setParameter("version", version); - query.setParameter("extension", extension); - Artifact artifact; - try { - artifact = query.getSingleResult(); - } catch (NoResultException e) { - log.info("New artifact!"); - artifact = new Artifact(groupId, artifactId, version, classifier, extension); - entityManager.persist(artifact); - } - - for (Process process : entityManager.createQuery("FROM Process", Process.class).getResultList()) { - System.out.println("process.name = " + process.getName()); - - for (ProcessTrigger trigger : process.getProcessTriggers()) { - System.out.println("trigger.getMvel() = " + trigger.getMvel()); - boolean match = trigger.matches(artifact); - System.out.println("match = " + match); + transactionTemplate.execute(new TransactionCallbackWithoutResult() { + @Override + protected void doInTransactionWithoutResult(TransactionStatus status) { + processMessage(groupId, artifactId, version, classifier, extension); } - } - - /* - String type; - Object event; - long processInstanceId; - jbpm.signalEvent(type, event, processInstanceId); - */ + }); } catch (JMSException | IOException e) { e.printStackTrace(); } } + + private void processMessage(String groupId, String artifactId, String version, String classifier, String extension) { + // Check for any processes that will be started because of this + EntityManager entityManager = entityManagerFactory.createEntityManager(); + + TypedQuery<Artifact> query = entityManager.createQuery("FROM Artifact WHERE groupId=:groupId AND artifactId=:artifactId AND version=:version AND extension=:extension", Artifact.class); + query.setParameter("groupId", groupId); + query.setParameter("artifactId", artifactId); + query.setParameter("version", version); + query.setParameter("extension", extension); + Artifact artifact; + try { + artifact = query.getSingleResult(); + log.info("Existing artifact: {}", artifact); + } catch (NoResultException e) { + artifact = new Artifact(groupId, artifactId, version, classifier, extension); + log.info("New artifact: {}", artifact); + entityManager.persist(artifact); + } + + for (Process process : entityManager.createQuery("FROM Process", Process.class).getResultList()) { + System.out.println("process.name = " + process.getName()); + + for (ProcessTrigger trigger : process.getProcessTriggers()) { + System.out.println("trigger.getMvel() = " + trigger.getMvel()); + boolean match = trigger.matches(artifact); + System.out.println("match = " + match); + } + } + + /* + String type; + Object event; + long processInstanceId; + jbpm.signalEvent(type, event, processInstanceId); + */ + } } diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java b/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java index f1357b4..e8b1faa 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java @@ -1,16 +1,16 @@ package io.trygvis.engine.domain; -import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.MappedSuperclass; import javax.persistence.SequenceGenerator; -@Entity -@SequenceGenerator(name = "calamusSeq", sequenceName = "calamus_seq") +@MappedSuperclass public abstract class AbstractEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO, generator = "calamusSeq") + @SequenceGenerator(name = "calamusSeq", sequenceName = "calamus_seq") private Long id; public Long getId() { diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java b/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java index 2fb9beb..8e01d92 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java @@ -2,11 +2,9 @@ package io.trygvis.engine.domain; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import java.util.Optional; +import static io.trygvis.engine.domain.Artifact.Level.UNTESTED; import static java.util.Optional.ofNullable; @Entity @@ -26,6 +24,16 @@ public class Artifact extends AbstractEntity { @Column(length = 100, nullable = false) private String extension; + @Column(nullable = false) + private Level level; + + @Column(length = 40) + private String gitHash; + + public enum Level { + UNTESTED + } + protected Artifact() { } @@ -35,6 +43,7 @@ public class Artifact extends AbstractEntity { this.version = version; this.classifier = classifier; this.extension = extension; + this.level = UNTESTED; } public String getGroupId() { @@ -56,4 +65,25 @@ public class Artifact extends AbstractEntity { public String getExtension() { return extension; } + + public Level getLevel() { + return level; + } + + public String getGitHash() { + return gitHash; + } + + @Override + public String toString() { + return "Artifact{" + + "groupId='" + groupId + '\'' + + ", artifactId='" + artifactId + '\'' + + ", version='" + version + '\'' + + ", classifier='" + classifier + '\'' + + ", extension='" + extension + '\'' + + ", level='" + level + '\'' + + ", gitHash='" + gitHash + '\'' + + "} " + super.toString(); + } } diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java b/calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java index 16192f2..ccd96cf 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java @@ -12,7 +12,7 @@ public class Process extends AbstractEntity { @Column(length = 100, nullable = false) private String name; - @OneToMany + @OneToMany(mappedBy = "process") private List<ProcessTrigger> processTriggers = new ArrayList<>(); public String getName() { diff --git a/calamus-engine/src/main/resources/META-INF/persistence.xml b/calamus-engine/src/main/resources/META-INF/persistence.xml index 5591390..0150ad9 100644 --- a/calamus-engine/src/main/resources/META-INF/persistence.xml +++ b/calamus-engine/src/main/resources/META-INF/persistence.xml @@ -20,7 +20,8 @@ <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL82Dialect"/> <property name="hibernate.max_fetch_depth" value="3"/> - <property name="hibernate.hbm2ddl.auto" value="update"/> + <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/> + <!--<property name="hibernate.hbm2ddl.auto" value="update"/>--> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform"/> diff --git a/calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql b/calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql index 4d2a194..e13e6fb 100644 --- a/calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql +++ b/calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql @@ -1,6 +1,3 @@ -DROP SCHEMA public CASCADE; -CREATE SCHEMA public; - CREATE TABLE Attachment ( AttachmentId INT8 NOT NULL, accessType INT4, diff --git a/calamus-engine/src/main/resources/db/public/V001_001__baseline.sql b/calamus-engine/src/main/resources/db/public/V001_001__baseline.sql index 3e39c06..5270d2c 100644 --- a/calamus-engine/src/main/resources/db/public/V001_001__baseline.sql +++ b/calamus-engine/src/main/resources/db/public/V001_001__baseline.sql @@ -9,8 +9,8 @@ CREATE TABLE artifact ( version VARCHAR(100) NOT NULL, classifier VARCHAR(100), extension VARCHAR(100) NOT NULL, - git_hash CHAR(40) NOT NULL, - level VARCHAR(100) NOT NULL + level VARCHAR(100) NOT NULL, + git_hash CHAR(40) ); DROP TABLE IF EXISTS process; @@ -22,16 +22,16 @@ CREATE TABLE process ( DROP TABLE IF EXISTS process_trigger; CREATE TABLE process_trigger ( - id BIGINT NOT NULL PRIMARY KEY, - process_id BIGINT NOT NULL REFERENCES process, - mvel VARCHAR(1000) NOT NULL + id BIGINT NOT NULL PRIMARY KEY, + process BIGINT NOT NULL REFERENCES process, + mvel VARCHAR(1000) NOT NULL ); INSERT INTO process (id, name, process_id) VALUES ((SELECT nextval('calamus_seq')), 'Deploy', 'io.trygvis.calamus.Deploy'); -INSERT INTO process_trigger (id, process_id, mvel) +INSERT INTO process_trigger (id, process, mvel) VALUES ((SELECT nextval('calamus_seq')), (SELECT diff --git a/calamus-engine/src/main/resources/logback.xml b/calamus-engine/src/main/resources/logback.xml index 743dd8b..46502f3 100644 --- a/calamus-engine/src/main/resources/logback.xml +++ b/calamus-engine/src/main/resources/logback.xml @@ -7,6 +7,9 @@ </appender> <logger name="org.hibernate.hql.internal" level="INFO"/> + <logger name="com.googlecode.flyway" level="INFO"/> + <logger name="org.hibernate.type" level="INFO"/> + <logger name="org.hibernate.id" level="INFO"/> <root level="DEBUG"> <appender-ref ref="CONSOLE"/> |