From a521a2d74c480c53c1004e7e5e2addd28a0578f4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 12 Apr 2014 20:37:55 +0200 Subject: wip --- .gitignore | 3 - calamus-engine/pom.xml | 40 +- .../main/java/io/trygvis/engine/CalamusJbpm.java | 50 +- .../engine/JenkinsBuildResultMessageListener.java | 53 ++ .../src/main/java/io/trygvis/engine/Main.java | 19 +- .../src/main/java/io/trygvis/engine/MqClient.java | 41 +- .../engine/NexusNewArtifactMessageListener.java | 58 ++ .../io/trygvis/engine/domain/AbstractEntity.java | 19 + .../java/io/trygvis/engine/domain/Artifact.java | 48 ++ .../src/main/resources/META-INF/persistence.xml | 4 +- .../main/resources/db/postgresql-jbpm-schema.sql | 633 -------------------- .../main/resources/db/public/V001_000__jbpm.sql | 636 +++++++++++++++++++++ .../resources/db/public/V001_001__baseline.sql | 14 + calamus-engine/src/main/resources/logback.xml | 11 + .../org/jenkinsci/plugins/calamus/MqClient.java | 19 +- calamus-nexus-plugin/pom.xml | 45 +- .../calamus/nexus/CalamusEventListener.java | 52 ++ .../trygvis/calamus/nexus/CalamusNexusPlugin.java | 14 +- .../calamus/nexus/CalamusUiContributor.java | 2 + .../io/trygvis/calamus/nexus/EventListener.java | 51 -- .../java/io/trygvis/calamus/nexus/MqClient.java | 35 +- .../static/js/Calamus/CalamusConfigPanel.js | 3 - .../static/js/calamus-nexus-plugin-boot.js | 3 - pom.xml | 11 + 24 files changed, 1063 insertions(+), 801 deletions(-) create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java create mode 100644 calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java delete mode 100644 calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql create mode 100644 calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql create mode 100644 calamus-engine/src/main/resources/db/public/V001_001__baseline.sql create mode 100644 calamus-engine/src/main/resources/logback.xml create mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java delete mode 100644 calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java delete mode 100644 calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js delete mode 100644 calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js diff --git a/.gitignore b/.gitignore index b64e034..2725f23 100755 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,4 @@ target .project .settings -etc/config.properties - *tmp* - diff --git a/calamus-engine/pom.xml b/calamus-engine/pom.xml index 4923295..98ad6bf 100755 --- a/calamus-engine/pom.xml +++ b/calamus-engine/pom.xml @@ -13,6 +13,7 @@ UTF-8 5.9.1 + 2.2.1 4.2.11.Final 1.7.4 @@ -143,6 +144,11 @@ test --> + + com.googlecode.flyway + flyway-core + ${version.flyway} + org.apache.activemq @@ -340,23 +346,23 @@ - + 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 0a7be62..cc2ff41 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java @@ -2,6 +2,9 @@ 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; @@ -13,11 +16,21 @@ 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 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 EntityManagerFactory emf; + private final StatefulKnowledgeSession session; public static enum CalamusProcess { @@ -42,7 +55,9 @@ public class CalamusJbpm { ds.getDriverProperties().put("driverClassName", org.postgresql.Driver.class.getCanonicalName()); ds.init(); - EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); + 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()); @@ -63,7 +78,40 @@ public class CalamusJbpm { return session; } + 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(); + } + + private static String trimToEmpty(String string) { + if (string == null) { + return ""; + } + + return string.trim(); + } } diff --git a/calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java b/calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java new file mode 100644 index 0000000..08b5e5b --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java @@ -0,0 +1,53 @@ +package io.trygvis.engine; + +import org.kie.internal.runtime.StatefulKnowledgeSession; +import org.slf4j.Logger; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; +import java.io.IOException; +import java.io.StringReader; +import java.util.Properties; + +import static java.lang.Integer.parseInt; +import static org.slf4j.LoggerFactory.getLogger; + +public class JenkinsBuildResultMessageListener implements MessageListener { + private final Logger log = getLogger(getClass()); + + private StatefulKnowledgeSession session; + + public JenkinsBuildResultMessageListener(StatefulKnowledgeSession session) { + this.session = session; + } + + @Override + public void onMessage(Message message) { + if (!(message instanceof TextMessage)) { + return; + } + + try { + TextMessage m = (TextMessage) message; + Properties p = new Properties(); + p.load(new StringReader(m.getText())); + + String jobName = p.getProperty("jobName"); + int buildNumber = parseInt(p.getProperty("buildNumber")); + String result = p.getProperty("result"); + + log.info("New build: jobName={}, buildNumber={}, result={}", jobName, buildNumber, result); + + /* + String type; + Object event; + long processInstanceId; + jbpm.signalEvent(type, event, processInstanceId); + */ + } catch (JMSException | IOException e) { + e.printStackTrace(); + } + } +} 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 bc322e8..f5bfb8a 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/Main.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/Main.java @@ -1,13 +1,22 @@ package io.trygvis.engine; -import static io.trygvis.engine.CalamusJbpm.CalamusProcess.DEPLOY; +import org.kie.internal.runtime.StatefulKnowledgeSession; public class Main { - public static void main(String[] args) { - CalamusJbpm jbpm = new CalamusJbpm(); + public static void main(String[] args) throws Exception { - MqClient mqClient = new MqClient(jbpm.getSession(), "tcp://localhost:61616"); + CalamusJbpm calamus = new CalamusJbpm(); - jbpm.startProcess(DEPLOY); + String brokerUrl = "tcp://localhost:61616"; + + StatefulKnowledgeSession session = calamus.getSession(); + + try (MqClient buildResultClient = new MqClient(brokerUrl, "jenkins.build-result", new JenkinsBuildResultMessageListener(session)); + MqClient newDeployClient = new MqClient(brokerUrl, "nexus.new-artifact", new NexusNewArtifactMessageListener(session))) { + + while (true) { + Thread.sleep(1000); + } + } } } diff --git a/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java b/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java index b609c9f..91eec37 100644 --- a/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java +++ b/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java @@ -6,23 +6,24 @@ 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 javax.jms.TextMessage; +import java.io.IOException; +import java.io.StringReader; +import java.util.Properties; +import static java.lang.Integer.parseInt; 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); + public MqClient(String brokerUrl, String queueName, MessageListener messageListener) { + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrl); try { connection = connectionFactory.createConnection(); @@ -30,34 +31,10 @@ public class MqClient implements AutoCloseable { Session session = connection.createSession(false, AUTO_ACKNOWLEDGE); - Destination destination = session.createQueue("jenkins.build-result"); + Destination destination = session.createQueue(queueName); 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(); - } - } - }); + consumer.setMessageListener(messageListener); } catch (JMSException e) { e.printStackTrace(); } diff --git a/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java b/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java new file mode 100644 index 0000000..f3f9f05 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java @@ -0,0 +1,58 @@ +package io.trygvis.engine; + +import org.kie.internal.runtime.StatefulKnowledgeSession; +import org.slf4j.Logger; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; +import java.io.IOException; +import java.io.StringReader; +import java.util.Properties; + +import static org.slf4j.LoggerFactory.getLogger; + +public class NexusNewArtifactMessageListener implements MessageListener { + private final Logger log = getLogger(getClass()); + + private final StatefulKnowledgeSession session; + + public NexusNewArtifactMessageListener(StatefulKnowledgeSession session) { + this.session = session; + } + + @Override + public void onMessage(Message message) { + System.out.println("NexusNewArtifactMessageListener.onMessage"); + + System.out.println("message.getClass() = " + message.getClass()); + if (!(message instanceof TextMessage)) { + return; + } + + try { + TextMessage m = (TextMessage) message; + Properties p = new Properties(); + p.load(new StringReader(m.getText())); + + String repository = p.getProperty("repository"); + String groupId = p.getProperty("groupId"); + String artifactId = p.getProperty("artifactId"); + String version = p.getProperty("version"); + String classifier = p.getProperty("classifier"); + String extension = p.getProperty("extension"); + + log.info("New artifact: groupId={}, artifactId={}, version={}, classifier={}, extension={}", groupId, artifactId, version, classifier, extension); + + /* + String type; + Object event; + long processInstanceId; + jbpm.signalEvent(type, event, processInstanceId); + */ + } catch (JMSException | IOException e) { + e.printStackTrace(); + } + } +} 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 new file mode 100644 index 0000000..f1357b4 --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java @@ -0,0 +1,19 @@ +package io.trygvis.engine.domain; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.SequenceGenerator; + +@Entity +@SequenceGenerator(name = "calamusSeq", sequenceName = "calamus_seq") +public abstract class AbstractEntity { + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "calamusSeq") + private Long id; + + public Long getId() { + return id; + } +} 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 new file mode 100644 index 0000000..922376b --- /dev/null +++ b/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java @@ -0,0 +1,48 @@ +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 java.util.Optional.ofNullable; + +@Entity +public class Artifact extends AbstractEntity { + @Column(length = 100, nullable = false) + private String groupId; + + @Column(length = 100, nullable = false) + private String artifactId; + + @Column(length = 100, nullable = false) + private String version; + + @Column(length = 100) + private String classifier; + + @Column(length = 100, nullable = false) + private String extension; + + public String getGroupId() { + return groupId; + } + + public String getArtifactId() { + return artifactId; + } + + public String getVersion() { + return version; + } + + public Optional getClassifier() { + return ofNullable(classifier); + } + + public String getExtension() { + return extension; + } +} diff --git a/calamus-engine/src/main/resources/META-INF/persistence.xml b/calamus-engine/src/main/resources/META-INF/persistence.xml index a8a11af..5591390 100644 --- a/calamus-engine/src/main/resources/META-INF/persistence.xml +++ b/calamus-engine/src/main/resources/META-INF/persistence.xml @@ -16,14 +16,12 @@ org.jbpm.process.audit.NodeInstanceLog org.jbpm.process.audit.VariableInstanceLog org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo + io.trygvis.engine.domain.Artifact - diff --git a/calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql b/calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql deleted file mode 100644 index e13e6fb..0000000 --- a/calamus-engine/src/main/resources/db/postgresql-jbpm-schema.sql +++ /dev/null @@ -1,633 +0,0 @@ -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/public/V001_000__jbpm.sql b/calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql new file mode 100644 index 0000000..4d2a194 --- /dev/null +++ b/calamus-engine/src/main/resources/db/public/V001_000__jbpm.sql @@ -0,0 +1,636 @@ +DROP SCHEMA public CASCADE; +CREATE SCHEMA public; + +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/public/V001_001__baseline.sql b/calamus-engine/src/main/resources/db/public/V001_001__baseline.sql new file mode 100644 index 0000000..b1e7a02 --- /dev/null +++ b/calamus-engine/src/main/resources/db/public/V001_001__baseline.sql @@ -0,0 +1,14 @@ +DROP SEQUENCE IF EXISTS calamus_seq; +CREATE SEQUENCE calamus_seq; + +DROP TABLE IF EXISTS artifact; +CREATE TABLE artifact ( + id BIGINT NOT NULL PRIMARY KEY, + group_id VARCHAR(100) NOT NULL, + artifact_id VARCHAR(100) NOT NULL, + version VARCHAR(100) NOT NULL, + classifier VARCHAR(100), + extension VARCHAR(100) NOT NULL, + git_hash CHAR(40) NOT NULL, + level VARCHAR(100) NOT NULL +); diff --git a/calamus-engine/src/main/resources/logback.xml b/calamus-engine/src/main/resources/logback.xml new file mode 100644 index 0000000..d054893 --- /dev/null +++ b/calamus-engine/src/main/resources/logback.xml @@ -0,0 +1,11 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + 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 index 6ca4264..01e4176 100644 --- 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 @@ -6,10 +6,13 @@ 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 java.io.CharArrayWriter; +import java.io.IOException; +import java.util.Properties; +import static java.lang.String.valueOf; import static javax.jms.Session.AUTO_ACKNOWLEDGE; public class MqClient { @@ -32,16 +35,18 @@ public class MqClient { 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); + Properties properties = new Properties(); + properties.setProperty("jobName", jobName); + properties.setProperty("buildNumber", valueOf(buildNumber)); + properties.setProperty("result", result); - producer.send(message); + CharArrayWriter buf = new CharArrayWriter(); + properties.store(buf, null); + producer.send(session.createTextMessage(buf.toString())); session.close(); connection.close(); - } catch (JMSException e) { + } catch (JMSException | IOException e) { e.printStackTrace(); } } diff --git a/calamus-nexus-plugin/pom.xml b/calamus-nexus-plugin/pom.xml index 5060827..464daa6 100644 --- a/calamus-nexus-plugin/pom.xml +++ b/calamus-nexus-plugin/pom.xml @@ -1,21 +1,26 @@ - + + + 4.0.0 + - io.trygvis.calamus - calamus + org.sonatype.nexus.examples + nexus-examples 1.0-SNAPSHOT + + io.trygvis.calamus calamus-nexus-plugin + 1.0-SNAPSHOT + ${project.groupId}:${project.artifactId} - ${nexus-plugin.type} + nexus-plugin 5.9.1 2.8.0-01 - - nexus-plugin + org.apache.activemq @@ -27,24 +32,18 @@ activemq-pool ${version.activemq} - - org.sonatype.nexus - nexus-plugin-api - ${version.nexus} - provided - + provided + --> - org.sonatype.nexus.plugins - nexus-ui-extjs3-plugin + org.sonatype.nexus + nexus-plugin-api ${version.nexus} - provided @@ -64,12 +63,4 @@ - - - idea - - jar - - - diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java new file mode 100644 index 0000000..ddfd171 --- /dev/null +++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java @@ -0,0 +1,52 @@ +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("CalamusEventListener") +public class CalamusEventListener implements EventSubscriber { + + private final Logger log = getLogger(getClass()); + + private final MqClient mqClient; + private final GavCalculator gavCalculator; + + @Inject + public CalamusEventListener(CalamusConfig config, @Named("maven2") GavCalculator gavCalculator) { + log.info("CalamusEventListener.CalamusEventListener"); + log.info("gavCalculator = " + gavCalculator); + + this.mqClient = new MqClient(config.getBrokerUrl()); + this.gavCalculator = gavCalculator; + } + + @Subscribe + public void onRepositoryItemEventStoreCreate(RepositoryItemEventStoreCreate event) { + log.info("EventListener.onRepositoryItemEventStoreCreate"); + + Gav gav = gavCalculator.pathToGav(event.getItem().getPath()); + + if (gav == null || gav.isHash() || gav.isSignature()) { + return; + } + + String groupId = gav.getGroupId(); + String artifactId = gav.getArtifactId(); + String version = gav.getVersion(); + String extension = gav.getExtension(); + String classifier = gav.getClassifier(); + log.info("New artifact: groupId={}, artifactId={}, version={}, classifier={}, extension={}", groupId, artifactId, version, classifier, extension); + mqClient.sendMessage(event.getRepository().getId(), groupId, artifactId, version, classifier, extension); + } +} 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 index e60fed7..96d2c1d 100644 --- 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 @@ -1,17 +1,25 @@ package io.trygvis.calamus.nexus; -import org.eclipse.sisu.EagerSingleton; +//import org.eclipse.sisu.EagerSingleton; + +import org.slf4j.Logger; import org.sonatype.nexus.plugin.PluginIdentity; import javax.inject.Inject; import javax.inject.Named; -@EagerSingleton -@Named("calamus") +import static org.slf4j.LoggerFactory.getLogger; + +@Named +//@EagerSingleton public class CalamusNexusPlugin extends PluginIdentity { + private final Logger log = getLogger(getClass()); + @Inject public CalamusNexusPlugin() throws Exception { super("io.trygvis.calamus", "calamus-nexus-plugin"); + + System.out.println("CalamusNexusPlugin.CalamusNexusPlugin"); } } 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 index ed2f745..18e1c68 100644 --- 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 @@ -1,10 +1,12 @@ 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 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 deleted file mode 100644 index 4770974..0000000 --- a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java +++ /dev/null @@ -1,51 +0,0 @@ -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 index 51b2b3a..2564ed9 100644 --- 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 @@ -1,26 +1,33 @@ package io.trygvis.calamus.nexus; import org.apache.activemq.ActiveMQConnectionFactory; +import org.slf4j.Logger; 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 java.io.CharArrayWriter; +import java.io.IOException; +import java.util.Properties; import static javax.jms.Session.AUTO_ACKNOWLEDGE; +import static org.apache.commons.lang.StringUtils.trimToEmpty; +import static org.slf4j.LoggerFactory.getLogger; public class MqClient { - ActiveMQConnectionFactory connectionFactory; + private final Logger log = getLogger(getClass()); + + private final 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) { + public void sendMessage(String repository, String groupId, String artifactId, String version, String classifier, String extension) { try { Connection connection = connectionFactory.createConnection(); connection.start(); @@ -32,20 +39,22 @@ public class MqClient { 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); + Properties p = new Properties(); + p.setProperty("repository", repository); + p.setProperty("groupId", groupId); + p.setProperty("artifactId", artifactId); + p.setProperty("version", version); + p.setProperty("classifier", trimToEmpty(classifier)); + p.setProperty("extension", extension); - producer.send(message); + CharArrayWriter buf = new CharArrayWriter(); + p.store(buf, null); + producer.send(session.createTextMessage(buf.toString())); session.close(); connection.close(); - } catch (JMSException e) { - e.printStackTrace(); + } catch (JMSException | IOException e) { + log.warn("Unable to send message to broker", e); } } } 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 deleted file mode 100644 index 81a7887..0000000 --- a/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 0c454be..0000000 --- a/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js +++ /dev/null @@ -1,3 +0,0 @@ -define('calamus-nexus-plugin', [ - 'Calamus/CalamusConfigPanel' -]); diff --git a/pom.xml b/pom.xml index 128f850..d8cad9e 100644 --- a/pom.xml +++ b/pom.xml @@ -20,4 +20,15 @@ calamus-jenkins-plugin calamus-nexus-plugin + + + + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + -- cgit v1.2.3