From bfcfcf5e3b4301bc94c27f47bfda61693edf3595 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 12 Apr 2014 17:55:28 +0200 Subject: wip --- .gitattributes | 8 + .gitignore | 13 + calamus-engine/pom.xml | 390 +++++++++++++ .../main/java/io/trygvis/engine/CalamusJbpm.java | 69 +++ .../src/main/java/io/trygvis/engine/Main.java | 13 + .../src/main/java/io/trygvis/engine/MqClient.java | 73 +++ .../trygvis/engine/RestartAppWorkItemHandler.java | 24 + .../trygvis/engine/UpgradeAppWorkItemHandler.java | 24 + .../io/trygvis/engine/service/AppInstance.java | 7 + .../java/io/trygvis/engine/service/AppService.java | 15 + calamus-engine/src/main/resources/Deploy.bpmn2 | 132 +++++ .../resources/META-INF/AppctlWorkDefinitions.wid | 19 + .../src/main/resources/META-INF/persistence.xml | 31 + .../main/resources/db/postgresql-jbpm-schema.sql | 633 +++++++++++++++++++++ .../main/resources/db/quartz_tables_postgres.sql | 165 ++++++ calamus-engine/src/main/resources/jndi.properties | 1 + .../src/test/java/io/trygvis/engine/MyTest.java | 90 +++ calamus-jenkins-plugin/.gitignore | 1 + .../calamus-jenkins-pipeline.ipr | 107 ++++ .../calamus-jenkins-pipeline.iws | 418 ++++++++++++++ calamus-jenkins-plugin/pom.xml | 71 +++ .../plugins/calamus/HelloWorldBuilder.java | 152 +++++ .../jenkinsci/plugins/calamus/JbpmRunListener.java | 42 ++ .../org/jenkinsci/plugins/calamus/MqClient.java | 48 ++ .../src/main/resources/index.jelly | 6 + .../plugins/calamus/HelloWorldBuilder/config.jelly | 15 + .../plugins/calamus/HelloWorldBuilder/global.jelly | 20 + .../calamus/HelloWorldBuilder/help-name.html | 6 + .../calamus/HelloWorldBuilder/help-useFrench.html | 6 + calamus-nexus-plugin/pom.xml | 75 +++ .../io/trygvis/calamus/nexus/CalamusConfig.java | 30 + .../trygvis/calamus/nexus/CalamusNexusPlugin.java | 17 + .../calamus/nexus/CalamusUiContributor.java | 17 + .../io/trygvis/calamus/nexus/EventListener.java | 51 ++ .../java/io/trygvis/calamus/nexus/MqClient.java | 51 ++ .../static/js/Calamus/CalamusConfigPanel.js | 3 + .../static/js/calamus-nexus-plugin-boot.js | 3 + demo/pom.xml | 12 + pom.xml | 23 + 39 files changed, 2881 insertions(+) create mode 100644 .gitattributes create mode 100755 .gitignore create mode 100755 calamus-engine/pom.xml create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/Main.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/MqClient.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java create mode 100644 calamus-engine/src/main/resources/Deploy.bpmn2 create mode 100644 calamus-engine/src/main/resources/META-INF/AppctlWorkDefinitions.wid create mode 100644 calamus-engine/src/main/resources/META-INF/persistence.xml create mode 100644 calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql create mode 100644 calamus-engine/src/main/resources/db/quartz_tables_postgres.sql create mode 100644 calamus-engine/src/main/resources/jndi.properties create mode 100644 calamus-engine/src/test/java/io/trygvis/engine/MyTest.java create mode 100644 calamus-jenkins-plugin/.gitignore create mode 100644 calamus-jenkins-plugin/calamus-jenkins-pipeline.ipr create mode 100644 calamus-jenkins-plugin/calamus-jenkins-pipeline.iws create mode 100644 calamus-jenkins-plugin/pom.xml create mode 100644 calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/HelloWorldBuilder.java create mode 100644 calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/JbpmRunListener.java create mode 100644 calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/MqClient.java create mode 100644 calamus-jenkins-plugin/src/main/resources/index.jelly create mode 100644 calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/config.jelly create mode 100644 calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/global.jelly create mode 100644 calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-name.html create mode 100644 calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-useFrench.html create mode 100644 calamus-nexus-plugin/pom.xml create mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusConfig.java create mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java create mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java create mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java create mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java create mode 100644 calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js create mode 100644 calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js create mode 100644 demo/pom.xml create mode 100644 pom.xml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9a8f287 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +* text=auto + +*.java text +*.scala text +*.sql text + +*.png binary +*.jpg binary diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..b64e034 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +target +.idea +*.iml +*.ipw +*.iws +.classpath +.project +.settings + +etc/config.properties + +*tmp* + diff --git a/calamus-engine/pom.xml b/calamus-engine/pom.xml new file mode 100755 index 0000000..4923295 --- /dev/null +++ b/calamus-engine/pom.xml @@ -0,0 +1,390 @@ + + 4.0.0 + + io.trygvis.calamus + calamus + 1.0-SNAPSHOT + + io.trygvis.jbpm-sandbox + calamus-engine + + 1.8 + 1.8 + UTF-8 + + 5.9.1 + + 4.2.11.Final + 1.7.4 + 1.0.9 + 6.1.0.Beta2 + 6.1.0.Beta2 + + 1.1.0.Final + 1.0.0.Final + 3.1.0.Final + 3.2.0.Final + 1.3.161 + 2.1.4 + 1.0.0.CR7 + + + + + + org.drools + drools-bom + pom + ${drools.version} + import + + + org.jbpm + jbpm-bom + pom + ${drools.version} + import + + + org.jboss.arquillian + arquillian-bom + 1.1.0.Final + import + pom + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + org.hibernate + hibernate-core + ${hibernate.version} + + + commons-io + commons-io + 2.1 + + + commons-codec + commons-codec + 1.4 + + + org.apache.maven.wagon + wagon-provider-api + 2.4 + + + javax.activation + activation + 1.1.1 + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + + javax.enterprise + cdi-api + 1.1-20130918 + + + + junit + junit + 4.11 + + + org.apache.httpcomponents + httpcore + 4.1.2 + + + org.javassist + javassist + 3.18.1-GA + + + org.codehaus.plexus + plexus-utils + 3.0.8 + + + org.sonatype.sisu + sisu-inject-plexus + 2.3.0 + + + org.jboss.logging + jboss-logging + 3.1.0.GA + + + + + + + + + org.apache.activemq + activemq-client + ${version.activemq} + + + org.apache.activemq + activemq-pool + ${version.activemq} + + + + org.kie + kie-api + + + org.jbpm + jbpm-flow + + + org.jbpm + jbpm-bpmn2 + + + org.jbpm + jbpm-flow-builder + + + org.jbpm + jbpm-runtime-manager + + + javax.transaction + jta + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + + + commons-logging + commons-logging + + + + + org.jbpm + jbpm-human-task-core + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + + + + + org.jbpm + jbpm-workitems + ${jbpm.version} + + + commons-logging + commons-logging + + + + + org.jbpm + jbpm-audit + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + + + + + + org.jbpm + jbpm-shared-services + ${jbpm.version} + + + javax.transaction + jta + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + + + + + org.jbpm + jbpm-test + + + javax.transaction + jta + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + + + + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + ch.qos.logback + logback-classic + 1.0.9 + + + javax.enterprise + cdi-api + + + org.jboss.weld.se + weld-se-core + 1.1.13.Final + + + org.hibernate + hibernate-entitymanager + + + org.hibernate + hibernate-core + + + com.h2database + h2 + 1.3.168 + + + org.postgresql + postgresql + 9.3-1101-jdbc41 + + + org.codehaus.btm + btm + ${btm.version} + + + javax.transaction + jta + + + + + + + + + junit + junit + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + enforce + + + + + + + org.hibernate.javax.persistence:hibernate-jpa-2.1-api + javax.transaction:jta + commons-logging:commons-logging + org.slf4j:slf4j-log4j12 + log4j:log4j + postgresql:postgresql + + + + + + + + + + diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java new file mode 100644 index 0000000..0a7be62 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java @@ -0,0 +1,69 @@ +package io.trygvis.engine; + +import bitronix.tm.TransactionManagerServices; +import bitronix.tm.resource.jdbc.PoolingDataSource; +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 javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +public class CalamusJbpm { + private final StatefulKnowledgeSession session; + + public static enum CalamusProcess { + DEPLOY("io.trygvis.bpm.Deploy"); + + private String name; + + CalamusProcess(String name) { + this.name = name; + } + } + + 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(); + + EntityManagerFactory 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()); + } + + public StatefulKnowledgeSession getSession() { + return session; + } + + public void startProcess(CalamusProcess process) { + ProcessInstance processInstance = session.startProcess(process.name); + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/Main.java b/calamus-engine/src/main/java/io/trygvis/engine/Main.java new file mode 100644 index 0000000..bc322e8 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/Main.java @@ -0,0 +1,13 @@ +package io.trygvis.engine; + +import static io.trygvis.engine.CalamusJbpm.CalamusProcess.DEPLOY; + +public class Main { + public static void main(String[] args) { + CalamusJbpm jbpm = new CalamusJbpm(); + + MqClient mqClient = new MqClient(jbpm.getSession(), "tcp://localhost:61616"); + + jbpm.startProcess(DEPLOY); + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java b/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java new file mode 100644 index 0000000..b609c9f --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java @@ -0,0 +1,73 @@ +package io.trygvis.engine; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.kie.internal.runtime.StatefulKnowledgeSession; + +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.Session; + +import static javax.jms.Session.AUTO_ACKNOWLEDGE; + +public class MqClient implements AutoCloseable { + + private Connection connection; +// private final ActiveMQConnectionFactory connectionFactory; +// private final StatefulKnowledgeSession jbpm; + + public MqClient(final StatefulKnowledgeSession jbpm, String brukerUrl) { +// this.jbpm = jbpm; + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brukerUrl); + + try { + connection = connectionFactory.createConnection(); + connection.start(); + + Session session = connection.createSession(false, AUTO_ACKNOWLEDGE); + + Destination destination = session.createQueue("jenkins.build-result"); + + MessageConsumer consumer = session.createConsumer(destination); + consumer.setMessageListener(new MessageListener() { + @Override + public void onMessage(Message message) { + if (!(message instanceof MapMessage)) { + return; + } + + MapMessage m = (MapMessage) message; + + try { + String jobName = m.getString("jobName"); + int buildNumber = m.getInt("buildNumber"); + String result = m.getString("result"); + +/* + String type; + Object event; + long processInstanceId; + jbpm.signalEvent(type, event, processInstanceId); +*/ + } catch (JMSException e) { + e.printStackTrace(); + } + } + }); + } catch (JMSException e) { + e.printStackTrace(); + } + } + + @Override + public void close() throws Exception { + if (connection != null) { + connection.close(); + this.connection = null; + } + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java b/calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java new file mode 100644 index 0000000..98733c7 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java @@ -0,0 +1,24 @@ +package io.trygvis.engine; + +import org.kie.api.runtime.process.WorkItem; +import org.kie.api.runtime.process.WorkItemHandler; +import org.kie.api.runtime.process.WorkItemManager; + +import java.util.HashMap; +import java.util.Map; + +public class RestartAppWorkItemHandler implements WorkItemHandler { + + @Override + public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { + System.out.println("RestartAppWorkItemHandler.executeWorkItem"); + + Map results = new HashMap<>(); + manager.completeWorkItem(workItem.getId(), results); + } + + @Override + public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { + System.out.println("RestartAppWorkItemHandler.abortWorkItem"); + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java b/calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java new file mode 100644 index 0000000..6202d6b --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java @@ -0,0 +1,24 @@ +package io.trygvis.engine; + +import org.kie.api.runtime.process.WorkItem; +import org.kie.api.runtime.process.WorkItemHandler; +import org.kie.api.runtime.process.WorkItemManager; + +import java.util.HashMap; +import java.util.Map; + +public class UpgradeAppWorkItemHandler implements WorkItemHandler { + + @Override + public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { + System.out.println("UpgradeAppWorkItemHandler.executeWorkItem"); + + Map results = new HashMap<>(); + manager.completeWorkItem(workItem.getId(), results); + } + + @Override + public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { + System.out.println("UpgradeAppWorkItemHandler.abortWorkItem"); + } +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java b/calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java new file mode 100644 index 0000000..0badb8c --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java @@ -0,0 +1,7 @@ +package io.trygvis.engine.service; + +public class AppInstance { + private String name; + private String host; + private String path; +} diff --git a/calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java b/calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java new file mode 100644 index 0000000..3ccde2b --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java @@ -0,0 +1,15 @@ +package io.trygvis.engine.service; + +public class AppService { + public void installApp(AppInstance instance) { + System.out.println("AppService.installApp"); + } + + public void restartApp(AppInstance instance) { + System.out.println("AppService.restartApp"); + } + + public void waitForUp(AppInstance instance) { + System.out.println("AppService.waitForAppUp"); + } +} diff --git a/calamus-engine/src/main/resources/Deploy.bpmn2 b/calamus-engine/src/main/resources/Deploy.bpmn2 new file mode 100644 index 0000000..2e29859 --- /dev/null +++ b/calamus-engine/src/main/resources/Deploy.bpmn2 @@ -0,0 +1,132 @@ + + + + + + + + + + AppInstance + + + AppInstance + + + AppInstance + + + + asd + + + + + + + SequenceFlow_1 + + + + + SequenceFlow_1 + SequenceFlow_3 + + + + + _DataInput_18 + _DataInput_19 + + + + + _DataInput_18 + + + _DataInput_19 + + + + + SequenceFlow_3 + SequenceFlow_4 + + + + + _DataInput_20 + _DataInput_21 + + + + + _DataInput_20 + + + _DataInput_21 + + + + + SequenceFlow_4 + SequenceFlow_5 + + + DataOutput_4 + appInstance + + + DataOutput_4 + + + + + + SequenceFlow_5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/calamus-engine/src/main/resources/META-INF/AppctlWorkDefinitions.wid b/calamus-engine/src/main/resources/META-INF/AppctlWorkDefinitions.wid new file mode 100644 index 0000000..62ce4a1 --- /dev/null +++ b/calamus-engine/src/main/resources/META-INF/AppctlWorkDefinitions.wid @@ -0,0 +1,19 @@ +import org.drools.core.process.core.datatype.impl.type.StringDataType; +[ + [ + "name" : "Upgrade App", + "parameters" : [ + "Host" : new StringDataType(), + "Path" : new StringDataType(), + ], + "displayName" : "Upgrade app" + ], + [ + "name" : "Restart App", + "parameters" : [ + "Host" : new StringDataType(), + "Path" : new StringDataType(), + ], + "displayName" : "Restart app" + ] +] diff --git a/calamus-engine/src/main/resources/META-INF/persistence.xml b/calamus-engine/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..a8a11af --- /dev/null +++ b/calamus-engine/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,31 @@ + + + + org.hibernate.ejb.HibernatePersistence + jdbc/jbpm-ds + META-INF/JBPMorm.xml + org.drools.persistence.info.SessionInfo + org.drools.persistence.info.WorkItemInfo + org.jbpm.persistence.processinstance.ProcessInstanceInfo + org.jbpm.persistence.correlation.CorrelationKeyInfo + org.jbpm.persistence.correlation.CorrelationPropertyInfo + org.jbpm.process.audit.ProcessInstanceLog + org.jbpm.process.audit.NodeInstanceLog + org.jbpm.process.audit.VariableInstanceLog + org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo + + + + + + + + + + diff --git a/calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql b/calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql new file mode 100644 index 0000000..e13e6fb --- /dev/null +++ b/calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql @@ -0,0 +1,633 @@ +CREATE TABLE Attachment ( + AttachmentId INT8 NOT NULL, + accessType INT4, + attachedAt TIMESTAMP, + attachmentContentId INT8 NOT NULL, + contentType VARCHAR(255), + name VARCHAR(255), + attachment_size INT4, + attachedBy_id VARCHAR(255), + TaskData_Attachments_Id INT8, + PRIMARY KEY (AttachmentId) +); + +CREATE TABLE BAMTaskSummary ( + BAMTaskId INT8 NOT NULL, + createdDate TIMESTAMP, + duration INT8, + endDate TIMESTAMP, + processInstanceId INT8 NOT NULL, + startDate TIMESTAMP, + status VARCHAR(255), + taskId INT8 NOT NULL, + taskName VARCHAR(255), + userId VARCHAR(255), + PRIMARY KEY (BAMTaskId) +); + +CREATE TABLE BooleanExpression ( + id INT8 NOT NULL, + expression TEXT, + type VARCHAR(255), + Escalation_Constraints_Id INT8, + PRIMARY KEY (id) +); + +CREATE TABLE Content ( + id INT8 NOT NULL, + content OID, +-- content BYTEA, + PRIMARY KEY (id) +); + +CREATE TABLE ContextMappingInfo ( + mappingId INT8 NOT NULL, + CONTEXT_ID VARCHAR(255) NOT NULL, + KSESSION_ID INT4 NOT NULL, + OPTLOCK INT4, + PRIMARY KEY (mappingId) +); + +CREATE TABLE CorrelationKeyInfo ( + keyId INT8 NOT NULL, + name VARCHAR(255), + processInstanceId INT8 NOT NULL, + OPTLOCK INT4, + PRIMARY KEY (keyId) +); + +CREATE TABLE CorrelationPropertyInfo ( + propertyId INT8 NOT NULL, + name VARCHAR(255), + value VARCHAR(255), + OPTLOCK INT4, + correlationKey_keyId INT8, + PRIMARY KEY (propertyId) +); + +CREATE TABLE Deadline ( + id INT8 NOT NULL, + deadline_date TIMESTAMP, + escalated INT2, + Deadlines_StartDeadLine_Id INT8, + Deadlines_EndDeadLine_Id INT8, + PRIMARY KEY (id) +); + +CREATE TABLE Delegation_delegates ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE ErrorInfo ( + id INT8 NOT NULL, + message VARCHAR(255), + stacktrace VARCHAR(5000), + timestamp TIMESTAMP, + REQUEST_ID INT8 NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE Escalation ( + id INT8 NOT NULL, + name VARCHAR(255), + Deadline_Escalation_Id INT8, + PRIMARY KEY (id) +); + +CREATE TABLE EventTypes ( + InstanceId INT8 NOT NULL, + eventTypes VARCHAR(255) +); + +CREATE TABLE I18NText ( + I18NTextId INT8 NOT NULL, + language VARCHAR(255), + shortText VARCHAR(255), + text TEXT, + Task_Subjects_Id INT8, + Task_Names_Id INT8, + Task_Descriptions_Id INT8, + Reassignment_Documentation_Id INT8, + Notification_Subjects_Id INT8, + Notification_Names_Id INT8, + Notification_Documentation_Id INT8, + Notification_Descriptions_Id INT8, + Deadline_Documentation_Id INT8, + PRIMARY KEY (I18NTextId) +); + +CREATE TABLE NodeInstanceLog ( + id INT8 NOT NULL, + connection VARCHAR(255), + log_date TIMESTAMP, + externalId VARCHAR(255), + nodeId VARCHAR(255), + nodeInstanceId VARCHAR(255), + nodeName VARCHAR(255), + nodeType VARCHAR(255), + processId VARCHAR(255), + processInstanceId INT8 NOT NULL, + type INT4 NOT NULL, + workItemId INT8, + PRIMARY KEY (id) +); + +CREATE TABLE Notification ( + DTYPE VARCHAR(31) NOT NULL, + NotificationId INT8 NOT NULL, + priority INT4 NOT NULL, + Escalation_Notifications_Id INT8, + PRIMARY KEY (NotificationId) +); + +CREATE TABLE Notification_BAs ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE Notification_Recipients ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE Notification_email_header ( + Notification_NotificationId INT8 NOT NULL, + emailHeaders_id INT8 NOT NULL, + mapkey VARCHAR(255) NOT NULL, + PRIMARY KEY (Notification_NotificationId, mapkey) +); + +CREATE TABLE OrganizationalEntity ( + DTYPE VARCHAR(31) NOT NULL, + id VARCHAR(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE PeopleAssignments_BAs ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE PeopleAssignments_ExclOwners ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE PeopleAssignments_PotOwners ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE PeopleAssignments_Recipients ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE PeopleAssignments_Stakeholders ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE ProcessInstanceInfo ( + InstanceId INT8 NOT NULL, + lastModificationDate TIMESTAMP, + lastReadDate TIMESTAMP, + processId VARCHAR(255), + processInstanceByteArray OID, +-- processInstanceByteArray BYTEA, + startDate TIMESTAMP, + state INT4 NOT NULL, + OPTLOCK INT4, + PRIMARY KEY (InstanceId) +); + +CREATE TABLE ProcessInstanceLog ( + id INT8 NOT NULL, + duration INT8, + end_date TIMESTAMP, + externalId VARCHAR(255), + user_identity VARCHAR(255), + outcome VARCHAR(255), + parentProcessInstanceId INT8, + processId VARCHAR(255), + processInstanceId INT8 NOT NULL, + processName VARCHAR(255), + processVersion VARCHAR(255), + start_date TIMESTAMP, + status INT4, + PRIMARY KEY (id) +); + +CREATE TABLE Reassignment ( + id INT8 NOT NULL, + Escalation_Reassignments_Id INT8, + PRIMARY KEY (id) +); + +CREATE TABLE Reassignment_potentialOwners ( + task_id INT8 NOT NULL, + entity_id VARCHAR(255) NOT NULL +); + +CREATE TABLE RequestInfo ( + id INT8 NOT NULL, + commandName VARCHAR(255), + deploymentId VARCHAR(255), + executions INT4 NOT NULL, + businessKey VARCHAR(255), + message VARCHAR(255), + requestData OID, +-- requestData BYTEA, + responseData OID, +-- responseData BYTEA, + retries INT4 NOT NULL, + status VARCHAR(255), + timestamp TIMESTAMP, + PRIMARY KEY (id) +); + +CREATE TABLE SessionInfo ( + id INT4 NOT NULL, + lastModificationDate TIMESTAMP, + rulesByteArray OID, +-- rulesByteArray BYTEA, + startDate TIMESTAMP, + OPTLOCK INT4, + PRIMARY KEY (id) +); + +CREATE TABLE Task ( + TaskId INT8 NOT NULL, + archived INT2, + allowedToDelegate VARCHAR(255), + formName VARCHAR(255), + priority INT4 NOT NULL, + subTaskStrategy VARCHAR(255), + activationTime TIMESTAMP, + createdOn TIMESTAMP, + deploymentId VARCHAR(255), + documentAccessType INT4, + documentContentId INT8 NOT NULL, + documentType VARCHAR(255), + expirationTime TIMESTAMP, + faultAccessType INT4, + faultContentId INT8 NOT NULL, + faultName VARCHAR(255), + faultType VARCHAR(255), + outputAccessType INT4, + outputContentId INT8 NOT NULL, + outputType VARCHAR(255), + parentId INT8 NOT NULL, + previousStatus INT4, + processId VARCHAR(255), + processInstanceId INT8 NOT NULL, + processSessionId INT4 NOT NULL, + skipable BOOLEAN NOT NULL, + status VARCHAR(255), + workItemId INT8 NOT NULL, + taskType VARCHAR(255), + OPTLOCK INT4, + taskInitiator_id VARCHAR(255), + actualOwner_id VARCHAR(255), + createdBy_id VARCHAR(255), + PRIMARY KEY (TaskId) +); + +CREATE TABLE TaskDef ( + TaskDefId INT8 NOT NULL, + name VARCHAR(255), + priority INT4 NOT NULL, + PRIMARY KEY (TaskDefId) +); + +CREATE TABLE TaskEvent ( + id INT8 NOT NULL, + logTime TIMESTAMP, + taskId INT8, + type VARCHAR(255), + userId VARCHAR(255), + PRIMARY KEY (id) +); + +CREATE TABLE VariableInstanceLog ( + id INT8 NOT NULL, + log_date TIMESTAMP, + externalId VARCHAR(255), + oldValue VARCHAR(255), + processId VARCHAR(255), + processInstanceId INT8 NOT NULL, + value VARCHAR(255), + variableId VARCHAR(255), + variableInstanceId VARCHAR(255), + PRIMARY KEY (id) +); + +CREATE TABLE WorkItemInfo ( + workItemId INT8 NOT NULL, + creationDate TIMESTAMP, + name VARCHAR(255), + processInstanceId INT8 NOT NULL, + state INT8 NOT NULL, + OPTLOCK INT4, + workItemByteArray OID, +-- workItemByteArray BYTEA, + PRIMARY KEY (workItemId) +); + +CREATE TABLE email_header ( + id INT8 NOT NULL, + body TEXT, + fromAddress VARCHAR(255), + language VARCHAR(255), + replyToAddress VARCHAR(255), + subject VARCHAR(255), + PRIMARY KEY (id) +); + +CREATE TABLE task_comment ( + id INT8 NOT NULL, + addedAt TIMESTAMP, + text TEXT, + addedBy_id VARCHAR(255), + TaskData_Comments_Id INT8, + PRIMARY KEY (id) +); + +ALTER TABLE Attachment +ADD CONSTRAINT FK1C93543D937BFB5 +FOREIGN KEY (attachedBy_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Attachment +ADD CONSTRAINT FK1C9354333CA892A +FOREIGN KEY (TaskData_Attachments_Id) +REFERENCES Task; + +ALTER TABLE BooleanExpression +ADD CONSTRAINT FKE3D208C06C97C90E +FOREIGN KEY (Escalation_Constraints_Id) +REFERENCES Escalation; + +ALTER TABLE CorrelationPropertyInfo +ADD CONSTRAINT FK761452A5D87156ED +FOREIGN KEY (correlationKey_keyId) +REFERENCES CorrelationKeyInfo; + +ALTER TABLE Deadline +ADD CONSTRAINT FK21DF3E78A9FE0EF4 +FOREIGN KEY (Deadlines_StartDeadLine_Id) +REFERENCES Task; + +ALTER TABLE Deadline +ADD CONSTRAINT FK21DF3E78695E4DDB +FOREIGN KEY (Deadlines_EndDeadLine_Id) +REFERENCES Task; + +ALTER TABLE Delegation_delegates +ADD CONSTRAINT FK47485D5772B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Delegation_delegates +ADD CONSTRAINT FK47485D57786553A5 +FOREIGN KEY (task_id) +REFERENCES Task; + +ALTER TABLE ErrorInfo +ADD CONSTRAINT FK8B1186B6724A467 +FOREIGN KEY (REQUEST_ID) +REFERENCES RequestInfo; + +ALTER TABLE Escalation +ADD CONSTRAINT FK67B2C6B5D1E5CC1 +FOREIGN KEY (Deadline_Escalation_Id) +REFERENCES Deadline; + +ALTER TABLE EventTypes +ADD CONSTRAINT FKB0E5621F7665489A +FOREIGN KEY (InstanceId) +REFERENCES ProcessInstanceInfo; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686BF4ACCD69 +FOREIGN KEY (Task_Subjects_Id) +REFERENCES Task; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686B424B187C +FOREIGN KEY (Task_Names_Id) +REFERENCES Task; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686BAB648139 +FOREIGN KEY (Task_Descriptions_Id) +REFERENCES Task; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686BB340A2AA +FOREIGN KEY (Reassignment_Documentation_Id) +REFERENCES Reassignment; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686BF0CDED35 +FOREIGN KEY (Notification_Subjects_Id) +REFERENCES Notification; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686BCC03ED3C +FOREIGN KEY (Notification_Names_Id) +REFERENCES Notification; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686B77C1C08A +FOREIGN KEY (Notification_Documentation_Id) +REFERENCES Notification; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686B18DDFE05 +FOREIGN KEY (Notification_Descriptions_Id) +REFERENCES Notification; + +ALTER TABLE I18NText +ADD CONSTRAINT FK2349686B78AF072A +FOREIGN KEY (Deadline_Documentation_Id) +REFERENCES Deadline; + +ALTER TABLE Notification +ADD CONSTRAINT FK2D45DD0BC0C0F29C +FOREIGN KEY (Escalation_Notifications_Id) +REFERENCES Escalation; + +ALTER TABLE Notification_BAs +ADD CONSTRAINT FK2DD68EE072B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Notification_BAs +ADD CONSTRAINT FK2DD68EE093F2090B +FOREIGN KEY (task_id) +REFERENCES Notification; + +ALTER TABLE Notification_Recipients +ADD CONSTRAINT FK98FD214E72B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Notification_Recipients +ADD CONSTRAINT FK98FD214E93F2090B +FOREIGN KEY (task_id) +REFERENCES Notification; + +ALTER TABLE Notification_email_header +ADD CONSTRAINT UK_F30FE3446CEA0510 UNIQUE (emailHeaders_id); + +ALTER TABLE Notification_email_header +ADD CONSTRAINT FKF30FE3448BED1339 +FOREIGN KEY (emailHeaders_id) +REFERENCES email_header; + +ALTER TABLE Notification_email_header +ADD CONSTRAINT FKF30FE344DD2D7416 +FOREIGN KEY (Notification_NotificationId) +REFERENCES Notification; + +ALTER TABLE PeopleAssignments_BAs +ADD CONSTRAINT FK9D8CF4EC72B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE PeopleAssignments_BAs +ADD CONSTRAINT FK9D8CF4EC786553A5 +FOREIGN KEY (task_id) +REFERENCES Task; + +ALTER TABLE PeopleAssignments_ExclOwners +ADD CONSTRAINT FKC77B97E472B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE PeopleAssignments_ExclOwners +ADD CONSTRAINT FKC77B97E4786553A5 +FOREIGN KEY (task_id) +REFERENCES Task; + +ALTER TABLE PeopleAssignments_PotOwners +ADD CONSTRAINT FK1EE418D72B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE PeopleAssignments_PotOwners +ADD CONSTRAINT FK1EE418D786553A5 +FOREIGN KEY (task_id) +REFERENCES Task; + +ALTER TABLE PeopleAssignments_Recipients +ADD CONSTRAINT FKC6F615C272B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE PeopleAssignments_Recipients +ADD CONSTRAINT FKC6F615C2786553A5 +FOREIGN KEY (task_id) +REFERENCES Task; + +ALTER TABLE PeopleAssignments_Stakeholders +ADD CONSTRAINT FK482F79D572B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE PeopleAssignments_Stakeholders +ADD CONSTRAINT FK482F79D5786553A5 +FOREIGN KEY (task_id) +REFERENCES Task; + +ALTER TABLE Reassignment +ADD CONSTRAINT FK724D056062A1E871 +FOREIGN KEY (Escalation_Reassignments_Id) +REFERENCES Escalation; + +ALTER TABLE Reassignment_potentialOwners +ADD CONSTRAINT FK90B59CFF72B3A123 +FOREIGN KEY (entity_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Reassignment_potentialOwners +ADD CONSTRAINT FK90B59CFF35D2FEE0 +FOREIGN KEY (task_id) +REFERENCES Reassignment; + +ALTER TABLE Task +ADD CONSTRAINT FK27A9A53C55C806 +FOREIGN KEY (taskInitiator_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Task +ADD CONSTRAINT FK27A9A5B723BE8B +FOREIGN KEY (actualOwner_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE Task +ADD CONSTRAINT FK27A9A55427E8F1 +FOREIGN KEY (createdBy_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE task_comment +ADD CONSTRAINT FK61F475A57A3215D9 +FOREIGN KEY (addedBy_id) +REFERENCES OrganizationalEntity; + +ALTER TABLE task_comment +ADD CONSTRAINT FK61F475A5F510CB46 +FOREIGN KEY (TaskData_Comments_Id) +REFERENCES Task; + +CREATE SEQUENCE ATTACHMENT_ID_SEQ; + +CREATE SEQUENCE BAM_TASK_ID_SEQ; + +CREATE SEQUENCE BOOLEANEXPR_ID_SEQ; + +CREATE SEQUENCE COMMENT_ID_SEQ; + +CREATE SEQUENCE CONTENT_ID_SEQ; + +CREATE SEQUENCE CONTEXT_MAPPING_INFO_ID_SEQ; + +CREATE SEQUENCE CORRELATION_KEY_ID_SEQ; + +CREATE SEQUENCE CORRELATION_PROP_ID_SEQ; + +CREATE SEQUENCE DEADLINE_ID_SEQ; + +CREATE SEQUENCE EMAILNOTIFHEAD_ID_SEQ; + +CREATE SEQUENCE ERROR_INFO_ID_SEQ; + +CREATE SEQUENCE ESCALATION_ID_SEQ; + +CREATE SEQUENCE I18NTEXT_ID_SEQ; + +CREATE SEQUENCE NODE_INST_LOG_ID_SEQ; + +CREATE SEQUENCE NOTIFICATION_ID_SEQ; + +CREATE SEQUENCE PROCESS_INSTANCE_INFO_ID_SEQ; + +CREATE SEQUENCE PROC_INST_LOG_ID_SEQ; + +CREATE SEQUENCE REASSIGNMENT_ID_SEQ; + +CREATE SEQUENCE REQUEST_INFO_ID_SEQ; + +CREATE SEQUENCE SESSIONINFO_ID_SEQ; + +CREATE SEQUENCE TASK_DEF_ID_SEQ; + +CREATE SEQUENCE TASK_EVENT_ID_SEQ; + +CREATE SEQUENCE TASK_ID_SEQ; + +CREATE SEQUENCE VAR_INST_LOG_ID_SEQ; + +CREATE SEQUENCE WORKITEMINFO_ID_SEQ; diff --git a/calamus-engine/src/main/resources/db/quartz_tables_postgres.sql b/calamus-engine/src/main/resources/db/quartz_tables_postgres.sql new file mode 100644 index 0000000..fd4466f --- /dev/null +++ b/calamus-engine/src/main/resources/db/quartz_tables_postgres.sql @@ -0,0 +1,165 @@ +-- Thanks to Patrick Lightbody for submitting this... +-- +-- In your Quartz properties file, you'll need to set +-- org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate + + +CREATE TABLE qrtz_job_details + ( + JOB_NAME VARCHAR(200) NOT NULL, + JOB_GROUP VARCHAR(200) NOT NULL, + DESCRIPTION VARCHAR(250) NULL, + JOB_CLASS_NAME VARCHAR(250) NOT NULL, + IS_DURABLE BOOL NOT NULL, + IS_VOLATILE BOOL NOT NULL, + IS_STATEFUL BOOL NOT NULL, + REQUESTS_RECOVERY BOOL NOT NULL, + JOB_DATA BYTEA NULL, + PRIMARY KEY (JOB_NAME,JOB_GROUP) +); + +CREATE TABLE qrtz_job_listeners + ( + JOB_NAME VARCHAR(200) NOT NULL, + JOB_GROUP VARCHAR(200) NOT NULL, + JOB_LISTENER VARCHAR(200) NOT NULL, + PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER), + FOREIGN KEY (JOB_NAME,JOB_GROUP) + REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP) +); + +CREATE TABLE qrtz_triggers + ( + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + JOB_NAME VARCHAR(200) NOT NULL, + JOB_GROUP VARCHAR(200) NOT NULL, + IS_VOLATILE BOOL NOT NULL, + DESCRIPTION VARCHAR(250) NULL, + NEXT_FIRE_TIME BIGINT NULL, + PREV_FIRE_TIME BIGINT NULL, + PRIORITY INTEGER NULL, + TRIGGER_STATE VARCHAR(16) NOT NULL, + TRIGGER_TYPE VARCHAR(8) NOT NULL, + START_TIME BIGINT NOT NULL, + END_TIME BIGINT NULL, + CALENDAR_NAME VARCHAR(200) NULL, + MISFIRE_INSTR SMALLINT NULL, + JOB_DATA BYTEA NULL, + PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), + FOREIGN KEY (JOB_NAME,JOB_GROUP) + REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP) +); + +CREATE TABLE qrtz_simple_triggers + ( + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + REPEAT_COUNT BIGINT NOT NULL, + REPEAT_INTERVAL BIGINT NOT NULL, + TIMES_TRIGGERED BIGINT NOT NULL, + PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), + FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) + REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP) +); + +CREATE TABLE qrtz_cron_triggers + ( + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + CRON_EXPRESSION VARCHAR(120) NOT NULL, + TIME_ZONE_ID VARCHAR(80), + PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), + FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) + REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP) +); + +CREATE TABLE qrtz_blob_triggers + ( + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + BLOB_DATA BYTEA NULL, + PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), + FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) + REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP) +); + +CREATE TABLE qrtz_trigger_listeners + ( + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + TRIGGER_LISTENER VARCHAR(200) NOT NULL, + PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER), + FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) + REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP) +); + + +CREATE TABLE qrtz_calendars + ( + CALENDAR_NAME VARCHAR(200) NOT NULL, + CALENDAR BYTEA NOT NULL, + PRIMARY KEY (CALENDAR_NAME) +); + + +CREATE TABLE qrtz_paused_trigger_grps + ( + TRIGGER_GROUP VARCHAR(200) NOT NULL, + PRIMARY KEY (TRIGGER_GROUP) +); + +CREATE TABLE qrtz_fired_triggers + ( + ENTRY_ID VARCHAR(95) NOT NULL, + TRIGGER_NAME VARCHAR(200) NOT NULL, + TRIGGER_GROUP VARCHAR(200) NOT NULL, + IS_VOLATILE BOOL NOT NULL, + INSTANCE_NAME VARCHAR(200) NOT NULL, + FIRED_TIME BIGINT NOT NULL, + PRIORITY INTEGER NOT NULL, + STATE VARCHAR(16) NOT NULL, + JOB_NAME VARCHAR(200) NULL, + JOB_GROUP VARCHAR(200) NULL, + IS_STATEFUL BOOL NULL, + REQUESTS_RECOVERY BOOL NULL, + PRIMARY KEY (ENTRY_ID) +); + +CREATE TABLE qrtz_scheduler_state + ( + INSTANCE_NAME VARCHAR(200) NOT NULL, + LAST_CHECKIN_TIME BIGINT NOT NULL, + CHECKIN_INTERVAL BIGINT NOT NULL, + PRIMARY KEY (INSTANCE_NAME) +); + +CREATE TABLE qrtz_locks + ( + LOCK_NAME VARCHAR(40) NOT NULL, + PRIMARY KEY (LOCK_NAME) +); + + +INSERT INTO qrtz_locks values('TRIGGER_ACCESS'); +INSERT INTO qrtz_locks values('JOB_ACCESS'); +INSERT INTO qrtz_locks values('CALENDAR_ACCESS'); +INSERT INTO qrtz_locks values('STATE_ACCESS'); +INSERT INTO qrtz_locks values('MISFIRE_ACCESS'); + +create index idx_qrtz_j_req_recovery on qrtz_job_details(REQUESTS_RECOVERY); +create index idx_qrtz_t_next_fire_time on qrtz_triggers(NEXT_FIRE_TIME); +create index idx_qrtz_t_state on qrtz_triggers(TRIGGER_STATE); +create index idx_qrtz_t_nft_st on qrtz_triggers(NEXT_FIRE_TIME,TRIGGER_STATE); +create index idx_qrtz_t_volatile on qrtz_triggers(IS_VOLATILE); +create index idx_qrtz_ft_trig_name on qrtz_fired_triggers(TRIGGER_NAME); +create index idx_qrtz_ft_trig_group on qrtz_fired_triggers(TRIGGER_GROUP); +create index idx_qrtz_ft_trig_nm_gp on qrtz_fired_triggers(TRIGGER_NAME,TRIGGER_GROUP); +create index idx_qrtz_ft_trig_volatile on qrtz_fired_triggers(IS_VOLATILE); +create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(INSTANCE_NAME); +create index idx_qrtz_ft_job_name on qrtz_fired_triggers(JOB_NAME); +create index idx_qrtz_ft_job_group on qrtz_fired_triggers(JOB_GROUP); +create index idx_qrtz_ft_job_stateful on qrtz_fired_triggers(IS_STATEFUL); +create index idx_qrtz_ft_job_req_recovery on qrtz_fired_triggers(REQUESTS_RECOVERY); + +commit; diff --git a/calamus-engine/src/main/resources/jndi.properties b/calamus-engine/src/main/resources/jndi.properties new file mode 100644 index 0000000..ae8a6fb --- /dev/null +++ b/calamus-engine/src/main/resources/jndi.properties @@ -0,0 +1 @@ +java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory diff --git a/calamus-engine/src/test/java/io/trygvis/engine/MyTest.java b/calamus-engine/src/test/java/io/trygvis/engine/MyTest.java new file mode 100644 index 0000000..8c170ea --- /dev/null +++ b/calamus-engine/src/test/java/io/trygvis/engine/MyTest.java @@ -0,0 +1,90 @@ +package io.trygvis.engine; + +import bitronix.tm.TransactionManagerServices; +import bitronix.tm.resource.jdbc.PoolingDataSource; +import org.jbpm.bpmn2.handler.ServiceTaskHandler; +import org.jbpm.process.audit.AuditLoggerFactory; +import org.junit.Before; +import org.junit.Test; +import org.kie.api.KieBase; +import org.kie.api.definition.process.Process; +import org.kie.api.runtime.Environment; +import org.kie.api.runtime.EnvironmentName; +import org.kie.api.runtime.KieSession; +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 javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class MyTest { + + StatefulKnowledgeSession session; + +// @Before +// public void setUp() throws Exception { +// 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(); +// +// EntityManagerFactory 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(); +// +// // create a new knowledge session that uses JPA to store the runtime state +// 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()); +// } + + @Test + public void testDeploy() { +/* + ProcessInstance processInstance = session.startProcess("io.trygvis.bpm.Deploy"); + +// assertProcessInstanceCompleted(processInstance.getId(), session); + + System.out.println("processInstance = " + processInstance); + System.out.println("processInstance.getProcessId() = " + processInstance.getProcessId()); + System.out.println("processInstance.getState() = " + processInstance.getState()); + + Process process = session.getKieBase().getProcess(processInstance.getProcessId()); + System.out.println("process = " + process); + System.out.println("process.getType() = " + process.getType()); +*/ + } + + public static void assertProcessInstanceCompleted(long processInstanceId, KieSession ksession) { + assertNull(ksession.getProcessInstance(processInstanceId)); + } + + public static void assertProcessInstanceAborted(long processInstanceId, KieSession ksession) { + assertNull(ksession.getProcessInstance(processInstanceId)); + } + + public static void assertProcessInstanceActive(long processInstanceId, KieSession ksession) { + assertNotNull(ksession.getProcessInstance(processInstanceId)); + } +} diff --git a/calamus-jenkins-plugin/.gitignore b/calamus-jenkins-plugin/.gitignore new file mode 100644 index 0000000..b8f99f5 --- /dev/null +++ b/calamus-jenkins-plugin/.gitignore @@ -0,0 +1 @@ +work diff --git a/calamus-jenkins-plugin/calamus-jenkins-pipeline.ipr b/calamus-jenkins-plugin/calamus-jenkins-pipeline.ipr new file mode 100644 index 0000000..c47dca1 --- /dev/null +++ b/calamus-jenkins-plugin/calamus-jenkins-pipeline.ipr @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calamus-jenkins-plugin/calamus-jenkins-pipeline.iws b/calamus-jenkins-plugin/calamus-jenkins-pipeline.iws new file mode 100644 index 0000000..b94e12f --- /dev/null +++ b/calamus-jenkins-plugin/calamus-jenkins-pipeline.iws @@ -0,0 +1,418 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calamus-jenkins-plugin/pom.xml b/calamus-jenkins-plugin/pom.xml new file mode 100644 index 0000000..42cc378 --- /dev/null +++ b/calamus-jenkins-plugin/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + + + org.jenkins-ci.plugins + plugin + 1.558 + + calamus-jenkins-pipeline + ${hpi.type} + + + 5.9.1 + hpi + + + + + org.apache.activemq + activemq-client + ${version.activemq} + + + org.apache.activemq + activemq-pool + ${version.activemq} + + + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + + + + maven-compiler-plugin + + 1.7 + 1.7 + + + + + + + + idea + + jar + + + + diff --git a/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/HelloWorldBuilder.java b/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/HelloWorldBuilder.java new file mode 100644 index 0000000..5844a26 --- /dev/null +++ b/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/HelloWorldBuilder.java @@ -0,0 +1,152 @@ +package org.jenkinsci.plugins.calamus; + +import hudson.Launcher; +import hudson.Extension; +import hudson.util.FormValidation; +import hudson.model.AbstractBuild; +import hudson.model.BuildListener; +import hudson.model.AbstractProject; +import hudson.tasks.Builder; +import hudson.tasks.BuildStepDescriptor; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.QueryParameter; + +import javax.servlet.ServletException; +import java.io.IOException; + +/** + * Sample {@link Builder}. + * + *

+ * When the user configures the project and enables this builder, + * {@link DescriptorImpl#newInstance(StaplerRequest)} is invoked + * and a new {@link HelloWorldBuilder} is created. The created + * instance is persisted to the project configuration XML by using + * XStream, so this allows you to use instance fields (like {@link #name}) + * to remember the configuration. + * + *

+ * When a build is performed, the {@link #perform(AbstractBuild, Launcher, BuildListener)} + * method will be invoked. + * + * @author Kohsuke Kawaguchi + */ +public class HelloWorldBuilder extends Builder { + + private final String name; + + // Fields in config.jelly must match the parameter names in the "DataBoundConstructor" + @DataBoundConstructor + public HelloWorldBuilder(String name) { + this.name = name; + } + + /** + * We'll use this from the config.jelly. + */ + public String getName() { + return name; + } + + @Override + public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { + // This is where you 'build' the project. + // Since this is a dummy, we just say 'hello world' and call that a build. + + // This also shows how you can consult the global configuration of the builder + if (getDescriptor().getUseFrench()) + listener.getLogger().println("Bonjour, "+name+"!"); + else + listener.getLogger().println("Hello, "+name+"!"); + return true; + } + + // Overridden for better type safety. + // If your plugin doesn't really define any property on Descriptor, + // you don't have to do this. + @Override + public DescriptorImpl getDescriptor() { + return (DescriptorImpl)super.getDescriptor(); + } + + /** + * Descriptor for {@link HelloWorldBuilder}. Used as a singleton. + * The class is marked as public so that it can be accessed from views. + * + *

+ * See src/main/resources/hudson/plugins/hello_world/HelloWorldBuilder/*.jelly + * for the actual HTML fragment for the configuration screen. + */ + @Extension // This indicates to Jenkins that this is an implementation of an extension point. + public static final class DescriptorImpl extends BuildStepDescriptor { + /** + * To persist global configuration information, + * simply store it in a field and call save(). + * + *

+ * If you don't want fields to be persisted, use transient. + */ + private boolean useFrench; + + /** + * In order to load the persisted global configuration, you have to + * call load() in the constructor. + */ + public DescriptorImpl() { + load(); + } + + /** + * Performs on-the-fly validation of the form field 'name'. + * + * @param value + * This parameter receives the value that the user has typed. + * @return + * Indicates the outcome of the validation. This is sent to the browser. + */ + public FormValidation doCheckName(@QueryParameter String value) + throws IOException, ServletException { + if (value.length() == 0) + return FormValidation.error("Please set a name"); + if (value.length() < 4) + return FormValidation.warning("Isn't the name too short?"); + return FormValidation.ok(); + } + + public boolean isApplicable(Class aClass) { + // Indicates that this builder can be used with all kinds of project types + return true; + } + + /** + * This human readable name is used in the configuration screen. + */ + public String getDisplayName() { + return "Say hello world"; + } + + @Override + public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + // To persist global configuration information, + // set that to properties and call save(). + useFrench = formData.getBoolean("useFrench"); + // ^Can also use req.bindJSON(this, formData); + // (easier when there are many fields; need set* methods for this, like setUseFrench) + save(); + return super.configure(req,formData); + } + + /** + * This method returns true if the global configuration says we should speak French. + * + * The method name is bit awkward because global.jelly calls this method to determine + * the initial state of the checkbox by the naming convention. + */ + public boolean getUseFrench() { + return useFrench; + } + } +} + diff --git a/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/JbpmRunListener.java b/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/JbpmRunListener.java new file mode 100644 index 0000000..2376516 --- /dev/null +++ b/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/JbpmRunListener.java @@ -0,0 +1,42 @@ +package org.jenkinsci.plugins.calamus; + +import hudson.Extension; +import hudson.model.Build; +import hudson.model.TaskListener; +import hudson.model.listeners.RunListener; + +import javax.annotation.Nonnull; + +@Extension +public class JbpmRunListener extends RunListener { + + private final MqClient mqClient; + + public JbpmRunListener() { + super(Build.class); + + System.out.println("JbpmRunListener.JbpmRunListener"); + + mqClient = new MqClient("tcp://localhost:61616"); + } + + @Override + public void onCompleted(Build build, @Nonnull TaskListener listener) { + System.out.println("JbpmRunListener.onCompleted"); + System.out.println("build = " + build); + + System.out.println("build variables"); + for (Object o : build.getBuildVariables().entrySet()) { + System.out.println(o); + } + + mqClient.sendMessage(build.getProject().getName(), build.getNumber(), build.getResult().toString()); + +// Jenkins jenkins = Jenkins.getInstance(); +// List projects = jenkins.getAllItems(AbstractProject.class); +// for (AbstractProject project : projects) { +// System.out.println("project.getPronoun() = " + project.getPronoun()); +// System.out.println("project.getName() = " + project.getName()); +// } + } +} diff --git a/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/MqClient.java b/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/MqClient.java new file mode 100644 index 0000000..6ca4264 --- /dev/null +++ b/calamus-jenkins-plugin/src/main/java/org/jenkinsci/plugins/calamus/MqClient.java @@ -0,0 +1,48 @@ +package org.jenkinsci.plugins.calamus; + +import org.apache.activemq.ActiveMQConnectionFactory; + +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.MessageProducer; +import javax.jms.Session; + +import static javax.jms.Session.AUTO_ACKNOWLEDGE; + +public class MqClient { + + ActiveMQConnectionFactory connectionFactory; + + public MqClient(String brokerUrl) { + this.connectionFactory = new ActiveMQConnectionFactory(brokerUrl); + } + + public void sendMessage(String jobName, int buildNumber, String result) { + try { + Connection connection = connectionFactory.createConnection(); + connection.start(); + + Session session = connection.createSession(false, AUTO_ACKNOWLEDGE); + + Destination destination = session.createQueue("jenkins.build-result"); + + MessageProducer producer = session.createProducer(destination); + producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); + + MapMessage message = session.createMapMessage(); + message.setString("jobName", jobName); + message.setInt("buildNumber", buildNumber); + message.setString("result", result); + + producer.send(message); + + session.close(); + connection.close(); + } catch (JMSException e) { + e.printStackTrace(); + } + } +} diff --git a/calamus-jenkins-plugin/src/main/resources/index.jelly b/calamus-jenkins-plugin/src/main/resources/index.jelly new file mode 100644 index 0000000..538998f --- /dev/null +++ b/calamus-jenkins-plugin/src/main/resources/index.jelly @@ -0,0 +1,6 @@ + +

+ This plugin is a sample to explain how to write a Jenkins plugin. +
diff --git a/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/config.jelly b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/config.jelly new file mode 100644 index 0000000..491280c --- /dev/null +++ b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/config.jelly @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/global.jelly b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/global.jelly new file mode 100644 index 0000000..068b0c0 --- /dev/null +++ b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/global.jelly @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-name.html b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-name.html new file mode 100644 index 0000000..288f214 --- /dev/null +++ b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-name.html @@ -0,0 +1,6 @@ +
+ Help file for fields are discovered through a file name convention. This file is + help for the "name" field. You can have arbitrary HTML here. You can write + this file as a Jelly script if you need a dynamic content (but if you do so, change + the extension to .jelly). +
diff --git a/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-useFrench.html b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-useFrench.html new file mode 100644 index 0000000..df2e815 --- /dev/null +++ b/calamus-jenkins-plugin/src/main/resources/org/jenkinsci/plugins/calamus/HelloWorldBuilder/help-useFrench.html @@ -0,0 +1,6 @@ +
+ This HTML fragment will be injected into the configuration screen + when the user clicks the 'help' icon. See global.jelly for how the + form decides which page to load. + You can have any HTML fragment here. +
diff --git a/calamus-nexus-plugin/pom.xml b/calamus-nexus-plugin/pom.xml new file mode 100644 index 0000000..5060827 --- /dev/null +++ b/calamus-nexus-plugin/pom.xml @@ -0,0 +1,75 @@ + + 4.0.0 + + io.trygvis.calamus + calamus + 1.0-SNAPSHOT + + calamus-nexus-plugin + ${project.groupId}:${project.artifactId} + ${nexus-plugin.type} + + 5.9.1 + 2.8.0-01 + + nexus-plugin + + + + org.apache.activemq + activemq-client + ${version.activemq} + + + org.apache.activemq + activemq-pool + ${version.activemq} + + + org.sonatype.nexus + nexus-plugin-api + ${version.nexus} + provided + + + org.sonatype.nexus.plugins + nexus-restlet1x-plugin + ${version.nexus} + + provided + + + org.sonatype.nexus.plugins + nexus-ui-extjs3-plugin + ${version.nexus} + + provided + + + org.sonatype.nexus + nexus-plugin-testsupport + ${version.nexus} + test + + + + + + org.sonatype.nexus + nexus-plugin-bundle-maven-plugin + 1.2 + true + + + + + + idea + + jar + + + + diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusConfig.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusConfig.java new file mode 100644 index 0000000..a3c09a1 --- /dev/null +++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusConfig.java @@ -0,0 +1,30 @@ +package io.trygvis.calamus.nexus; + +import org.slf4j.Logger; +import org.sonatype.nexus.configuration.application.ApplicationConfiguration; + +import javax.inject.Inject; +import javax.inject.Singleton; +import java.io.File; + +import static org.slf4j.LoggerFactory.getLogger; + +@Singleton +public class CalamusConfig { + + private final Logger log = getLogger(getClass()); + + private final ApplicationConfiguration applicationConfiguration; + + @Inject + public CalamusConfig(ApplicationConfiguration applicationConfiguration) { + this.applicationConfiguration = applicationConfiguration; + log.info("applicationConfiguration = " + applicationConfiguration); + File configurationDirectory = applicationConfiguration.getConfigurationDirectory(); + log.info("configurationDirectory = " + configurationDirectory); + } + + public String getBrokerUrl() { + return "tcp://localhost:61616"; + } +} diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java new file mode 100644 index 0000000..e60fed7 --- /dev/null +++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java @@ -0,0 +1,17 @@ +package io.trygvis.calamus.nexus; + +import org.eclipse.sisu.EagerSingleton; +import org.sonatype.nexus.plugin.PluginIdentity; + +import javax.inject.Inject; +import javax.inject.Named; + +@EagerSingleton +@Named("calamus") +public class CalamusNexusPlugin extends PluginIdentity { + + @Inject + public CalamusNexusPlugin() throws Exception { + super("io.trygvis.calamus", "calamus-nexus-plugin"); + } +} diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java new file mode 100644 index 0000000..ed2f745 --- /dev/null +++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java @@ -0,0 +1,17 @@ +package io.trygvis.calamus.nexus; + +import org.sonatype.nexus.plugins.ui.contribution.UiContributorSupport; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +//@Named +//@Singleton +public class CalamusUiContributor /*extends UiContributorSupport*/ { + +// @Inject +// public CalamusUiContributor(CalamusNexusPlugin plugin) { +// super(plugin); +// } +} diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java new file mode 100644 index 0000000..4770974 --- /dev/null +++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java @@ -0,0 +1,51 @@ +package io.trygvis.calamus.nexus; + +import com.google.common.eventbus.Subscribe; +import org.slf4j.Logger; +import org.sonatype.nexus.events.EventSubscriber; +import org.sonatype.nexus.proxy.events.RepositoryItemEventStoreCreate; +import org.sonatype.nexus.proxy.maven.gav.Gav; +import org.sonatype.nexus.proxy.maven.gav.GavCalculator; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import static org.slf4j.LoggerFactory.getLogger; + +@Singleton +@Named +public class EventListener implements EventSubscriber { + + private final Logger log = getLogger(getClass()); + + private final MqClient mqClient; + private final GavCalculator gavCalculator; + + @Inject + public EventListener(CalamusConfig config, @Named("maven2") GavCalculator gavCalculator) { + log.info("CalamusNexusPlugin.CalamusNexusPlugin"); + log.info("gavCalculator = " + gavCalculator); + + this.mqClient = new MqClient(config.getBrokerUrl()); + this.gavCalculator = gavCalculator; + } + + @Subscribe + public void onRepositoryItemEventStoreCreate(RepositoryItemEventStoreCreate event) { + Gav gav = gavCalculator.pathToGav(event.getItem().getPath()); + + if (gav == null) { + return; + } + + String groupId = gav.getGroupId(); + String artifactId = gav.getArtifactId(); + String version = gav.getVersion(); + String type = gav.getExtension(); + String classifier = gav.getClassifier(); + mqClient.sendMessage(event.getRepository().getId(), groupId, artifactId, version, type, classifier); + + log.info("New artifact: groupId={}, artifactId={}, version={}, type={}, classifier={}", groupId, artifactId, version, type, classifier); + } +} diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java new file mode 100644 index 0000000..51b2b3a --- /dev/null +++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java @@ -0,0 +1,51 @@ +package io.trygvis.calamus.nexus; + +import org.apache.activemq.ActiveMQConnectionFactory; + +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.MessageProducer; +import javax.jms.Session; + +import static javax.jms.Session.AUTO_ACKNOWLEDGE; + +public class MqClient { + + ActiveMQConnectionFactory connectionFactory; + + public MqClient(String brokerUrl) { + this.connectionFactory = new ActiveMQConnectionFactory(brokerUrl); + } + + public void sendMessage(String repository, String groupId, String artifactId, String version, String type, String classifier) { + try { + Connection connection = connectionFactory.createConnection(); + connection.start(); + + Session session = connection.createSession(false, AUTO_ACKNOWLEDGE); + + Destination destination = session.createQueue("nexus.new-artifact"); + + MessageProducer producer = session.createProducer(destination); + producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); + + MapMessage message = session.createMapMessage(); + message.setString("repository", repository); + message.setString("groupId", groupId); + message.setString("artifactId", artifactId); + message.setString("version", version); + message.setString("type", type); + message.setString("classifier", classifier); + + producer.send(message); + + session.close(); + connection.close(); + } catch (JMSException e) { + e.printStackTrace(); + } + } +} diff --git a/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js b/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js new file mode 100644 index 0000000..81a7887 --- /dev/null +++ b/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js @@ -0,0 +1,3 @@ +define('Sonatype/repoServer/LdapConfigPanel', function () { + +}); diff --git a/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js b/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js new file mode 100644 index 0000000..0c454be --- /dev/null +++ b/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js @@ -0,0 +1,3 @@ +define('calamus-nexus-plugin', [ + 'Calamus/CalamusConfigPanel' +]); diff --git a/demo/pom.xml b/demo/pom.xml new file mode 100644 index 0000000..d113356 --- /dev/null +++ b/demo/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + demo + demo + 1.0-SNAPSHOT + + + nexus + http://localhost:8081/nexus/content/repositories/snapshots/ + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..128f850 --- /dev/null +++ b/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + io.trygvis + trygvis-parent + 1 + + io.trygvis.calamus + calamus + 1.0-SNAPSHOT + pom + + 1.8 + 1.8 + UTF-8 + + + + calamus-engine + calamus-jenkins-plugin + calamus-nexus-plugin + + -- cgit v1.2.3