提交 d3ed5574 编写于 作者: T tijsrademakers

Merge branch 'master' of https://github.com/Activiti/Activiti

......@@ -47,6 +47,8 @@ import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.ErrorEventDefinition;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.ExtensionAttribute;
import org.activiti.bpmn.model.ExtensionElement;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.FormProperty;
import org.activiti.bpmn.model.FormValue;
......@@ -201,6 +203,18 @@ public abstract class BaseBpmnXMLConverter implements BpmnXMLConstants {
writeExtensionChildElements(baseElement, xtw);
didWriteExtensionStartElement = writeListeners(baseElement, xtw);
if (baseElement.getExtensionElements().size() > 0) {
if (didWriteExtensionStartElement == false) {
xtw.writeStartElement(ELEMENT_EXTENSIONS);
didWriteExtensionStartElement = true;
}
Map<String, String> namespaceMap = new HashMap<String, String>();
for (ExtensionElement extensionElement : baseElement.getExtensionElements().values()) {
writeExtensionElement(extensionElement, namespaceMap, xtw);
}
}
if (didWriteExtensionStartElement) {
xtw.writeEndElement();
}
......@@ -234,21 +248,69 @@ public abstract class BaseBpmnXMLConverter implements BpmnXMLConstants {
childParsers.putAll(childElementParsers);
}
boolean inExtensionElements = false;
boolean readyWithChildElements = false;
while (readyWithChildElements == false && xtr.hasNext()) {
xtr.next();
if (xtr.isStartElement()) {
if (childParsers.containsKey(xtr.getLocalName())) {
if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
inExtensionElements = true;
} else if (childParsers.containsKey(xtr.getLocalName())) {
childParsers.get(xtr.getLocalName()).parseChildElement(xtr, parentElement, model);
} else if (inExtensionElements) {
ExtensionElement extensionElement = parseExtensionElement(xtr);
parentElement.addExtensionElement(extensionElement);
}
} else if (xtr.isEndElement() && elementName.equalsIgnoreCase(xtr.getLocalName())) {
readyWithChildElements = true;
} else if (xtr.isEndElement()) {
if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
inExtensionElements = false;
} else if (elementName.equalsIgnoreCase(xtr.getLocalName())) {
readyWithChildElements = true;
}
}
}
}
private boolean parseAsync(XMLStreamReader xtr) {
protected ExtensionElement parseExtensionElement(XMLStreamReader xtr) throws Exception {
ExtensionElement extensionElement = new ExtensionElement();
extensionElement.setName(xtr.getLocalName());
if (StringUtils.isNotEmpty(xtr.getNamespaceURI())) {
extensionElement.setNamespace(xtr.getNamespaceURI());
}
if (StringUtils.isNotEmpty(xtr.getPrefix())) {
extensionElement.setNamespacePrefix(xtr.getPrefix());
}
for (int i = 0; i < xtr.getAttributeCount(); i++) {
ExtensionAttribute extensionAttribute = new ExtensionAttribute();
extensionAttribute.setName(xtr.getAttributeLocalName(i));
extensionAttribute.setValue(xtr.getAttributeValue(i));
extensionAttribute.setNamespace(xtr.getAttributeNamespace(i));
if (StringUtils.isNotEmpty(xtr.getAttributePrefix(i))) {
extensionAttribute.setNamespacePrefix(xtr.getAttributePrefix(i));
}
extensionElement.addAttribute(extensionAttribute);
}
boolean readyWithExtensionElement = false;
while (readyWithExtensionElement == false && xtr.hasNext()) {
xtr.next();
if (xtr.isCharacters()) {
if (StringUtils.isNotEmpty(xtr.getText().trim())) {
extensionElement.setElementText(xtr.getText().trim());
}
} else if (xtr.isStartElement()) {
ExtensionElement childExtensionElement = parseExtensionElement(xtr);
extensionElement.addChildElement(childExtensionElement);
} else if (xtr.isEndElement() && extensionElement.getName().equalsIgnoreCase(xtr.getLocalName())) {
readyWithExtensionElement = true;
}
}
return extensionElement;
}
protected boolean parseAsync(XMLStreamReader xtr) {
boolean async = false;
String asyncString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS);
if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(asyncString)) {
......@@ -257,7 +319,7 @@ public abstract class BaseBpmnXMLConverter implements BpmnXMLConstants {
return async;
}
private boolean parseNotExclusive(XMLStreamReader xtr) {
protected boolean parseNotExclusive(XMLStreamReader xtr) {
boolean notExclusive = false;
String exclusiveString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_EXCLUSIVE);
if (ATTRIBUTE_VALUE_FALSE.equalsIgnoreCase(exclusiveString)) {
......@@ -266,7 +328,7 @@ public abstract class BaseBpmnXMLConverter implements BpmnXMLConstants {
return notExclusive;
}
private boolean parseForCompensation(XMLStreamReader xtr) {
protected boolean parseForCompensation(XMLStreamReader xtr) {
boolean isForCompensation = false;
String compensationString = xtr.getAttributeValue(null, ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION);
if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(compensationString)) {
......@@ -289,6 +351,59 @@ public abstract class BaseBpmnXMLConverter implements BpmnXMLConstants {
// To XML converter convenience methods
protected void writeExtensionElement(ExtensionElement extensionElement, Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception {
if (StringUtils.isNotEmpty(extensionElement.getName())) {
if (StringUtils.isNotEmpty(extensionElement.getNamespace())) {
if (StringUtils.isNotEmpty(extensionElement.getNamespacePrefix())) {
xtw.writeStartElement(extensionElement.getNamespacePrefix(), extensionElement.getName(), extensionElement.getNamespace());
if (namespaceMap.containsKey(extensionElement.getNamespacePrefix()) == false ||
namespaceMap.get(extensionElement.getNamespacePrefix()).equals(extensionElement.getNamespace()) == false) {
xtw.writeNamespace(extensionElement.getNamespacePrefix(), extensionElement.getNamespace());
namespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace());
}
} else {
xtw.writeStartElement(extensionElement.getNamespace(), extensionElement.getName());
}
} else {
xtw.writeStartElement(extensionElement.getName());
}
for (ExtensionAttribute attribute : extensionElement.getAttributes().values()) {
if (StringUtils.isNotEmpty(attribute.getName()) && attribute.getValue() != null) {
if (StringUtils.isNotEmpty(attribute.getNamespace())) {
if (StringUtils.isNotEmpty(attribute.getNamespacePrefix())) {
if (namespaceMap.containsKey(attribute.getNamespacePrefix()) == false ||
namespaceMap.get(attribute.getNamespacePrefix()).equals(attribute.getNamespace()) == false) {
xtw.writeNamespace(attribute.getNamespacePrefix(), attribute.getNamespace());
namespaceMap.put(attribute.getNamespacePrefix(), attribute.getNamespace());
}
xtw.writeAttribute(attribute.getNamespacePrefix(), attribute.getNamespace(), attribute.getName(), attribute.getValue());
} else {
xtw.writeAttribute(attribute.getNamespace(), attribute.getName(), attribute.getValue());
}
} else {
xtw.writeAttribute(attribute.getName(), attribute.getValue());
}
}
}
if (extensionElement.getElementText() != null) {
xtw.writeCharacters(extensionElement.getElementText());
} else {
for (ExtensionElement childElement : extensionElement.getChildElements().values()) {
writeExtensionElement(childElement, namespaceMap, xtw);
}
}
xtw.writeEndElement();
}
}
protected String convertToDelimitedString(List<String> stringList) {
return BpmnXMLUtil.convertToDelimitedString(stringList);
}
......
......@@ -364,7 +364,7 @@ public class BpmnXMLConverter implements BpmnXMLConstants {
new MultiInstanceParser().parseChildElement(xtr, activeSubProcessList.get(activeSubProcessList.size() - 1), model);
} else if (convertersToBpmnMap.containsKey(xtr.getLocalName())) {
if (activeProcess.isExecutable()) {
if (activeProcess != null && activeProcess.isExecutable()) {
Class<? extends BaseBpmnXMLConverter> converterClass = convertersToBpmnMap.get(xtr.getLocalName());
BaseBpmnXMLConverter converter = converterClass.newInstance();
if (userTaskFormTypes != null && ELEMENT_TASK_USER.equals(xtr.getLocalName())) {
......
......@@ -38,7 +38,6 @@ public class CompleteConverterTest extends AbstractConverterTest {
assertNotNull(flowElement);
assertTrue(flowElement instanceof UserTask);
assertEquals("userTask1", flowElement.getId());
UserTask userTask = (UserTask) flowElement;
flowElement = model.getMainProcess().getFlowElement("catchsignal");
assertNotNull(flowElement);
......
package org.activiti.editor.language.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import org.activiti.bpmn.model.ActivitiListener;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.ExtensionAttribute;
import org.activiti.bpmn.model.ExtensionElement;
import org.activiti.bpmn.model.FieldExtension;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.ImplementationType;
import org.activiti.bpmn.model.ServiceTask;
import org.junit.Test;
public class CustomExtensionsConverterTest extends AbstractConverterTest {
@Test
public void connvertXMLToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
@Test
public void convertModelToXML() throws Exception {
BpmnModel bpmnModel = readXMLFile();
BpmnModel parsedModel = exportAndReadXMLFile(bpmnModel);
validateModel(parsedModel);
deployProcess(parsedModel);
}
protected String getResource() {
return "customextensionsmodel.bpmn";
}
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
assertNotNull(flowElement);
assertTrue(flowElement instanceof ServiceTask);
assertEquals("servicetask", flowElement.getId());
ServiceTask serviceTask = (ServiceTask) flowElement;
assertEquals("servicetask", serviceTask.getId());
assertEquals("Service task", serviceTask.getName());
List<FieldExtension> fields = serviceTask.getFieldExtensions();
assertEquals(2, fields.size());
FieldExtension field = (FieldExtension) fields.get(0);
assertEquals("testField", field.getFieldName());
assertEquals("test", field.getStringValue());
field = (FieldExtension) fields.get(1);
assertEquals("testField2", field.getFieldName());
assertEquals("${test}", field.getExpression());
List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
assertEquals(3, listeners.size());
ActivitiListener listener = (ActivitiListener) listeners.get(0);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
assertEquals("org.test.TestClass", listener.getImplementation());
assertEquals("start", listener.getEvent());
listener = (ActivitiListener) listeners.get(1);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
assertEquals("${testExpression}", listener.getImplementation());
assertEquals("end", listener.getEvent());
listener = (ActivitiListener) listeners.get(2);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
assertEquals("${delegateExpression}", listener.getImplementation());
assertEquals("start", listener.getEvent());
Map<String, ExtensionElement> extensionElementMap = serviceTask.getExtensionElements();
assertEquals(1, extensionElementMap.size());
ExtensionElement extensionElement = extensionElementMap.get("test");
assertNotNull(extensionElement);
assertEquals("test", extensionElement.getName());
assertEquals("custom", extensionElement.getNamespacePrefix());
assertEquals("http://custom.org/bpmn", extensionElement.getNamespace());
assertEquals(2, extensionElement.getAttributes().size());
ExtensionAttribute attribute = extensionElement.getAttributes().get("id");
assertNotNull(attribute);
assertEquals("id", attribute.getName());
assertEquals("test", attribute.getValue());
assertNull(attribute.getNamespace());
assertNull(attribute.getNamespacePrefix());
attribute = extensionElement.getAttributes().get("name");
assertNotNull(attribute);
assertEquals("name", attribute.getName());
assertEquals("test", attribute.getValue());
assertEquals(2, extensionElement.getChildElements().size());
ExtensionElement childExtension = extensionElement.getChildElements().get("name");
assertNotNull(childExtension);
assertEquals("name", childExtension.getName());
assertEquals("custom", childExtension.getNamespacePrefix());
assertEquals("http://custom.org/bpmn", childExtension.getNamespace());
assertEquals(0, childExtension.getAttributes().size());
assertEquals(1, childExtension.getChildElements().size());
childExtension = childExtension.getChildElements().get("test");
assertNotNull(childExtension);
assertEquals("test", childExtension.getName());
assertEquals("custom", childExtension.getNamespacePrefix());
assertEquals("http://custom.org/bpmn", childExtension.getNamespace());
assertEquals(0, childExtension.getAttributes().size());
assertEquals(0, childExtension.getChildElements().size());
assertEquals("test", childExtension.getElementText());
childExtension = extensionElement.getChildElements().get("description");
assertNotNull(childExtension);
assertEquals("description", childExtension.getName());
assertEquals(1, childExtension.getAttributes().size());
attribute = childExtension.getAttributes().get("id");
assertNotNull(attribute);
assertEquals("id", attribute.getName());
assertEquals("test", attribute.getValue());
assertEquals("custom2", attribute.getNamespacePrefix());
assertEquals("http://custom2.org/bpmn", attribute.getNamespace());
}
}
package org.activiti.editor.language.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.UserTask;
import org.junit.Test;
public class EncodingConverterTest extends AbstractConverterTest {
@Test
public void connvertXMLToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
@Test
public void convertModelToXML() throws Exception {
BpmnModel bpmnModel = readXMLFile();
BpmnModel parsedModel = exportAndReadXMLFile(bpmnModel);
validateModel(parsedModel);
}
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("writeReportTask");
assertNotNull(flowElement);
assertTrue(flowElement instanceof UserTask);
assertEquals("writeReportTask", flowElement.getId());
UserTask userTask = (UserTask) flowElement;
assertEquals("writeReportTask", userTask.getId());
assertEquals("Fazer relatório", userTask.getName());
}
protected String getResource() {
return "encoding.bpmn";
}
}
......@@ -56,7 +56,7 @@ public class UserTaskConverterTest extends AbstractConverterTest {
assertTrue(userTask.getCandidateGroups().contains("sales"));
List<FormProperty> formProperties = userTask.getFormProperties();
assertEquals(2, formProperties.size());
assertEquals(3, formProperties.size());
FormProperty formProperty = formProperties.get(0);
assertEquals("formId", formProperty.getId());
assertEquals("formName", formProperty.getName());
......@@ -69,6 +69,13 @@ public class UserTaskConverterTest extends AbstractConverterTest {
assertEquals("long", formProperty.getType());
assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
formProperty = formProperties.get(2);
assertEquals("formId3", formProperty.getId());
assertEquals("enumName", formProperty.getName());
assertEquals("enum", formProperty.getType());
assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
assertEquals(2, formProperty.getFormValues().size());
List<ActivitiListener> listeners = userTask.getTaskListeners();
assertEquals(3, listeners.size());
......
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://www.activiti.org/test">
<process id="process" name="process1" isExecutable="true">
<endEvent id="sid-F7795B38-72CD-41A4-9549-6CFB7D3E5FB5"></endEvent>
<sequenceFlow id="sid-C6C56AC3-9561-49E0-A58A-624F6CB8BB82" sourceRef="sid-F62B554B-FF4F-475E-94FF-A3F44EDA6A6A" targetRef="servicetask"></sequenceFlow>
<serviceTask id="servicetask" name="Service task" activiti:async="true" activiti:exclusive="false" activiti:class="org.test.TestClass">
<extensionElements>
<activiti:field name="testField" stringValue="test"></activiti:field>
<activiti:field name="testField2" expression="${test}"></activiti:field>
<activiti:executionListener event="start" class="org.test.TestClass"></activiti:executionListener>
<activiti:executionListener event="end" expression="${testExpression}"></activiti:executionListener>
<activiti:executionListener event="start" delegateExpression="${delegateExpression}"></activiti:executionListener>
<custom:test xmlns:custom="http://custom.org/bpmn" id="test" name="test">
<custom:name>
<custom:test>test</custom:test>
</custom:name>
<custom:description xmlns:custom2="http://custom2.org/bpmn" custom2:id="test" />
</custom:test>
</extensionElements>
</serviceTask>
<startEvent id="sid-F62B554B-FF4F-475E-94FF-A3F44EDA6A6A"></startEvent>
<sequenceFlow id="sid-91C0F3A0-649F-462E-A1C1-1CE499FEDE3E" sourceRef="servicetask" targetRef="sid-F7795B38-72CD-41A4-9549-6CFB7D3E5FB5"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_process">
<bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process">
<bpmndi:BPMNShape bpmnElement="sid-F7795B38-72CD-41A4-9549-6CFB7D3E5FB5" id="BPMNShape_sid-F7795B38-72CD-41A4-9549-6CFB7D3E5FB5">
<omgdc:Bounds height="28.0" width="28.0" x="324.5" y="137.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask" id="BPMNShape_servicetask">
<omgdc:Bounds height="80.0" width="100.0" x="179.5" y="111.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-F62B554B-FF4F-475E-94FF-A3F44EDA6A6A" id="BPMNShape_sid-F62B554B-FF4F-475E-94FF-A3F44EDA6A6A">
<omgdc:Bounds height="30.0" width="30.0" x="104.5" y="136.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-C6C56AC3-9561-49E0-A58A-624F6CB8BB82" id="BPMNEdge_sid-C6C56AC3-9561-49E0-A58A-624F6CB8BB82">
<omgdi:waypoint x="134.5" y="151.0"></omgdi:waypoint>
<omgdi:waypoint x="179.5" y="151.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-91C0F3A0-649F-462E-A1C1-1CE499FEDE3E" id="BPMNEdge_sid-91C0F3A0-649F-462E-A1C1-1CE499FEDE3E">
<omgdi:waypoint x="279.5" y="151.0"></omgdi:waypoint>
<omgdi:waypoint x="324.5" y="151.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples"
xmlns:tns="Examples"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<message id="writeReport" name="newWriteReport" />
<process id="process01" isExecutable="true">
<startEvent id="theStart">
<messageEventDefinition messageRef="tns:writeReport" />
</startEvent>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="writeReportTask" />
<userTask id="writeReportTask" name="Fazer relatório" >
</userTask>
<sequenceFlow id="flow2" sourceRef="writeReportTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="process" name="process1" isExecutable="true">
<endEvent id="sid-7C003C2A-266E-4C30-9309-06BA6F9DD527"></endEvent>
<endEvent id="endEvent"></endEvent>
<sequenceFlow id="sid-10FF0337-D8FC-495E-92C4-82C2FD5F44F8" sourceRef="sid-12DAA756-C12D-42B6-9AB7-D08C7C8283C1" targetRef="usertask"></sequenceFlow>
<startEvent id="sid-12DAA756-C12D-42B6-9AB7-D08C7C8283C1"></startEvent>
<sequenceFlow id="sid-AA1205FD-63BD-47BA-9FB3-AA9F7C1E31F0" sourceRef="usertask" targetRef="sid-7C003C2A-266E-4C30-9309-06BA6F9DD527"></sequenceFlow>
<sequenceFlow id="sid-AA1205FD-63BD-47BA-9FB3-AA9F7C1E31F0" sourceRef="usertask" targetRef="endEvent"></sequenceFlow>
<userTask id="usertask" name="User task" activiti:async="true" activiti:exclusive="false" activiti:assignee="kermit" activiti:candidateUsers="kermit,fozzie" activiti:candidateGroups="management,sales" activiti:dueDate="2012-11-01" activiti:formKey="testKey" activiti:priority="40">
<extensionElements>
<activiti:formProperty id="formId" name="formName" type="string" expression="${expression}" variable="variable"></activiti:formProperty>
<activiti:formProperty id="formId2" name="anotherName" type="long"></activiti:formProperty>
<activiti:formProperty id="formId3" name="enumName" type="enum">
<activiti:value id="test" name="Test" />
<activiti:value id="test2" name="Test2" />
</activiti:formProperty>
<activiti:taskListener event="create" class="org.test.TestClass"></activiti:taskListener>
<activiti:taskListener event="assignment" expression="${someExpression}"></activiti:taskListener>
<activiti:taskListener event="complete" delegateExpression="${someDelegateExpression}"></activiti:taskListener>
<activiti:executionListener expression="${someExpression}" event="end" />
</extensionElements>
</userTask>
<boundaryEvent id="escalationTimer" cancelActivity="true" attachedToRef="usertask">
<timerEventDefinition>
<timeCycle>${cronExpression}</timeCycle>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="flow5" sourceRef="escalationTimer" targetRef="endEvent"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_process">
<bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process">
......
......@@ -12,6 +12,11 @@
*/
package org.activiti.bpmn.model;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
/**
* @author Tijs Rademakers
*/
......@@ -20,6 +25,7 @@ public class BaseElement {
protected String id;
protected int xmlRowNumber;
protected int xmlColumnNumber;
protected Map<String, ExtensionElement> extensionElements = new LinkedHashMap<String, ExtensionElement>();
public String getId() {
return id;
......@@ -44,4 +50,18 @@ public class BaseElement {
public void setXmlColumnNumber(int xmlColumnNumber) {
this.xmlColumnNumber = xmlColumnNumber;
}
public Map<String, ExtensionElement> getExtensionElements() {
return extensionElements;
}
public void addExtensionElement(ExtensionElement extensionElement) {
if (extensionElement != null && StringUtils.isNotEmpty(extensionElement.getName())) {
this.extensionElements.put(extensionElement.getName(), extensionElement);
}
}
public void setExtensionElements(Map<String, ExtensionElement> extensionElements) {
this.extensionElements = extensionElements;
}
}
package org.activiti.bpmn.model;
public class ExtensionAttribute {
protected String name;
protected String value;
protected String namespacePrefix;
protected String namespace;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getNamespacePrefix() {
return namespacePrefix;
}
public void setNamespacePrefix(String namespacePrefix) {
this.namespacePrefix = namespacePrefix;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
}
package org.activiti.bpmn.model;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
public class ExtensionElement {
protected String name;
protected String namespacePrefix;
protected String namespace;
protected String elementText;
protected Map<String, ExtensionElement> childElements = new LinkedHashMap<String, ExtensionElement>();
protected Map<String, ExtensionAttribute> attributes = new LinkedHashMap<String, ExtensionAttribute>();
public String getElementText() {
return elementText;
}
public void setElementText(String elementText) {
this.elementText = elementText;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNamespacePrefix() {
return namespacePrefix;
}
public void setNamespacePrefix(String namespacePrefix) {
this.namespacePrefix = namespacePrefix;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public Map<String, ExtensionElement> getChildElements() {
return childElements;
}
public void addChildElement(ExtensionElement childElement) {
if (childElement != null && StringUtils.isNotEmpty(childElement.getName())) {
this.childElements.put(childElement.getName(), childElement);
}
}
public void setChildElements(Map<String, ExtensionElement> childElements) {
this.childElements = childElements;
}
public Map<String, ExtensionAttribute> getAttributes() {
return attributes;
}
public void addAttribute(ExtensionAttribute attribute) {
if (attribute != null && StringUtils.isNotEmpty(attribute.getName())) {
this.attributes.put(attribute.getName(), attribute);
}
}
public void setAttributes(Map<String, ExtensionAttribute> attributes) {
this.attributes = attributes;
}
}
......@@ -60,7 +60,6 @@
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -120,7 +119,6 @@
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.0.0.CR7</version>
<scope>test</scope>
</dependency>
<dependency>
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api;
/**
* Used for creating a response that represent an error that occurred.
*
* @author Frederik Heremans
*/
public class RestError {
private String errorMessage;
private Integer statusCode;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public Integer getStatusCode() {
return statusCode;
}
public void setStatusCode(Integer statusCode) {
this.statusCode = statusCode;
}
}
......@@ -145,6 +145,8 @@ public class SecuredResource extends ServerResource {
result = isoFormatter.parse(stringValue);
} catch (ParseException e) {
throw new ActivitiIllegalArgumentException("The given value for query-parameter '" + name + "' is not a valid date: " + stringValue, e);
} catch (IllegalArgumentException e) {
throw new ActivitiIllegalArgumentException("The given value for query-parameter '" + name + "' is not a valid date: " + stringValue, e);
}
}
return result;
......
......@@ -33,6 +33,7 @@ public abstract class ActivitiRestApplication extends Application {
public ActivitiRestApplication() {
activitiStatusService = new ActivitiStatusService();
setStatusService(activitiStatusService);
}
public MediaTypeResolver getMediaTypeResolver() {
......@@ -79,9 +80,4 @@ public abstract class ActivitiRestApplication extends Application {
}
return request.getClientInfo().getUser().getIdentifier();
}
@Override
public StatusService getStatusService() {
return activitiStatusService;
}
}
......@@ -17,10 +17,14 @@ import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.ActivitiOptimisticLockingException;
import org.activiti.engine.ActivitiTaskAlreadyClaimedException;
import org.activiti.rest.api.RestError;
import org.codehaus.jackson.map.JsonMappingException;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.data.Status;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.ResourceException;
import org.restlet.service.StatusService;
......@@ -32,6 +36,22 @@ import org.restlet.service.StatusService;
* @author Frederik Heremans
*/
public class ActivitiStatusService extends StatusService {
/**
* Overriding this method to return a JSON-object representing the error that occurred instead of
* the default HTML body Restlet provides.
*/
@Override
public Representation getRepresentation(Status status, Request request, Response response) {
if(status != null && status.isError()) {
RestError error = new RestError();
error.setStatusCode(status.getCode());
error.setErrorMessage(status.getName());
return new JacksonRepresentation<RestError>(error);
} else {
return super.getRepresentation(status, request, response);
}
}
@Override
public Status getStatus(Throwable throwable, Request request, Response response) {
......@@ -57,12 +77,14 @@ public class ActivitiStatusService extends StatusService {
} else if(throwable instanceof ActivitiIllegalArgumentException) {
// 400 - Bad Request
status = new Status(Status.CLIENT_ERROR_BAD_REQUEST.getCode(), throwable.getMessage(), null, null);
} else if (throwable instanceof ActivitiOptimisticLockingException) {
} else if (throwable instanceof ActivitiOptimisticLockingException || throwable instanceof ActivitiTaskAlreadyClaimedException) {
// 409 - Conflict
status = new Status(Status.CLIENT_ERROR_CONFLICT.getCode(), throwable.getMessage(), null, null);
} else if (throwable instanceof ResourceException) {
ResourceException re = (ResourceException) throwable;
status = re.getStatus();
} else if(throwable instanceof ActivitiException) {
status = new Status(Status.SERVER_ERROR_INTERNAL.getCode(), throwable.getMessage(), null, null);;
} else {
status = null;
}
......
......@@ -14,10 +14,13 @@
package org.activiti.engine;
import java.util.List;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.history.HistoricDetailQuery;
import org.activiti.engine.history.HistoricIdentityLink;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
import org.activiti.engine.history.HistoricTaskInstance;
......@@ -27,6 +30,7 @@ import org.activiti.engine.history.HistoricVariableInstanceQuery;
import org.activiti.engine.history.NativeHistoricActivityInstanceQuery;
import org.activiti.engine.history.NativeHistoricProcessInstanceQuery;
import org.activiti.engine.history.NativeHistoricTaskInstanceQuery;
import org.activiti.engine.task.IdentityLink;
/**
* Service exposing information about ongoing and past process instances. This is different
......@@ -82,5 +86,22 @@ public interface HistoryService {
* creates a native query to search for {@link HistoricActivityInstance}s via SQL
*/
NativeHistoricActivityInstanceQuery createNativeHistoricActivityInstanceQuery();
/**
* Retrieves the {@link HistoricIdentityLink}s associated with the given task.
* Such an {@link IdentityLink} informs how a certain identity (eg. group or user)
* is associated with a certain task (eg. as candidate, assignee, etc.), even if the
* task is completed as opposed to {@link IdentityLink}s which only exist for active
* tasks.
*/
List<HistoricIdentityLink> getHistoricIdentityLinksForTask(String taskId);
/**
* Retrieves the {@link HistoricIdentityLink}s associated with the given process instance.
* Such an {@link IdentityLink} informs how a certain identity (eg. group or user)
* is associated with a certain process instance, even if the instance is completed as
* opposed to {@link IdentityLink}s which only exist for active instances.
*/
List<HistoricIdentityLink> getHistoricIdentityLinksForProcessInstance(String processInstanceId);
}
......@@ -12,14 +12,16 @@
*/
package org.activiti.engine;
import java.util.List;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.identity.NativeGroupQuery;
import org.activiti.engine.identity.NativeUserQuery;
import org.activiti.engine.identity.Picture;
import org.activiti.engine.identity.User;
import org.activiti.engine.identity.UserQuery;
import java.util.List;
/**
* Service to manage {@link User}s and {@link Group}s.
......@@ -46,6 +48,11 @@ public interface IdentityService {
* Creates a {@link UserQuery} that allows to programmatically query the users.
*/
UserQuery createUserQuery();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for tasks.
*/
NativeUserQuery createNativeUserQuery();
/**
* @param userId id of user to delete, cannot be null. When an id is passed
......@@ -64,6 +71,11 @@ public interface IdentityService {
* Creates a {@link GroupQuery} thats allows to programmatically query the groups.
*/
GroupQuery createGroupQuery();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for tasks.
*/
NativeGroupQuery createNativeGroupQuery();
/**
* Saves the group. If the group already existed, the group is updated.
......
......@@ -19,7 +19,6 @@ import org.activiti.engine.management.TableMetaData;
import org.activiti.engine.management.TablePage;
import org.activiti.engine.management.TablePageQuery;
import org.activiti.engine.runtime.JobQuery;
import org.activiti.engine.task.Task;
......
......@@ -129,6 +129,7 @@ public abstract class ProcessEngineConfiguration implements EngineServices {
protected String defaultCamelContext = "camelContext";
protected String activityFontName = "Arial";
protected String labelFontName = "Arial";
protected ClassLoader classLoader;
protected ProcessEngineLifecycleListener processEngineLifecycleListener;
......@@ -540,4 +541,12 @@ public abstract class ProcessEngineConfiguration implements EngineServices {
public ProcessEngineLifecycleListener getProcessEngineLifecycleListener() {
return processEngineLifecycleListener;
}
public String getLabelFontName() {
return labelFontName;
}
public void setLabelFontName(String labelFontName) {
this.labelFontName = labelFontName;
}
}
......@@ -13,20 +13,23 @@
package org.activiti.engine;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.DeploymentQuery;
import org.activiti.engine.repository.DiagramLayout;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ModelQuery;
import org.activiti.engine.repository.NativeDeploymentQuery;
import org.activiti.engine.repository.NativeModelQuery;
import org.activiti.engine.repository.NativeProcessDefinitionQuery;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.engine.task.IdentityLink;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
/** Service providing access to the repository of process definitions and deployments.
*
......@@ -34,6 +37,7 @@ import org.activiti.engine.task.IdentityLink;
* @author Falko Menge
* @author Tijs Rademakers
* @author Joram Barrez
* @author Henry Yan
*/
public interface RepositoryService {
......@@ -80,9 +84,19 @@ public interface RepositoryService {
/** Query process definitions. */
ProcessDefinitionQuery createProcessDefinitionQuery();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for process definitions.
*/
NativeProcessDefinitionQuery createNativeProcessDefinitionQuery();
/** Query process definitions. */
/** Query deployment. */
DeploymentQuery createDeploymentQuery();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for deployment.
*/
NativeDeploymentQuery createNativeDeploymentQuery();
/**
* Suspends the process definition with the given id.
......@@ -155,9 +169,7 @@ public interface RepositoryService {
/**
* Activates the process definition with the given id.
*
* @param suspendProcessInstances If true, all the process instances of the provided process definition
* will be activated too.
* @param activationDate The date on which the process definition will be activated. If null, the
* @param activationDate The date on which the process definition will be activated. If null, the
* process definition is suspended immediately.
* Note: The job executor needs to be active to use this!
*
......@@ -177,9 +189,7 @@ public interface RepositoryService {
/**
* Activates the process definition with the given key (=id in the bpmn20.xml file).
*
* @param suspendProcessInstances If true, all the process instances of the provided process definition
* will be activated too.
* @param activationDate The date on which the process definition will be activated. If null, the
* @param activationDate The date on which the process definition will be activated. If null, the
* process definition is suspended immediately.
* Note: The job executor needs to be active to use this!
*
......@@ -187,6 +197,14 @@ public interface RepositoryService {
* @throws ActivitiException if the process definition is already in state active.
*/
void activateProcessDefinitionByKey(String processDefinitionKey, boolean activateProcessInstances, Date activationDate);
/**
* Sets the category of the process definition.
* Process definitions can be queried by category: see {@link ProcessDefinitionQuery#processDefinitionCategory(String)}.
*
* @throws ActivitiObjectNotFoundException if no process defintion with the provided id can be found.
*/
void setProcessDefinitionCategory(String processDefinitionId, String category);
/**
* Gives access to a deployed process model, e.g., a BPMN 2.0 XML file,
......@@ -272,6 +290,11 @@ public interface RepositoryService {
/** Query models. */
public ModelQuery createModelQuery();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for process definitions.
*/
NativeModelQuery createNativeModelQuery();
/**
* Returns the {@link Model}
......
......@@ -322,10 +322,16 @@ public interface RuntimeService {
* @return the variable value or null if the variable is undefined or the value of the variable is null.
* @throws ActivitiObjectNotFoundException when no execution is found for the given executionId. */
Object getVariable(String executionId, String variableName);
/** Check whether or not this execution has variable set with the given name, Searching for the variable is done in all scopes that are visible to the given execution (including parent scopes). */
boolean hasVariable(String executionId, String variableName);
/** The variable value for an execution. Returns the value when the variable is set
* for the execution (and not searching parent scopes). Returns null when no variable value is found with the given name or when the value is set to null. */
Object getVariableLocal(String executionId, String variableName);
/** Check whether or not this execution has a local variable set with the given name. */
boolean hasVariableLocal(String executionId, String variableName);
/** Update or create a variable for an execution. If the variable is not already existing somewhere in the execution hierarchy,
* it will be created in the process instance (which is the root execution).
......
......@@ -160,6 +160,19 @@ public interface TaskService {
* @throws ActivitiObjectNotFoundException when no task exists with the given id.
*/
void resolveTask(String taskId);
/**
* Marks that the assignee is done with this task providing the required
* variables and that it can be sent back to the owner. Can only be called
* when this task is {@link DelegationState#PENDING} delegation. After this
* method returns, the {@link Task#getDelegationState() delegationState} is
* set to {@link DelegationState#RESOLVED}.
*
* @param taskId
* @param variables
* @throws ProcessEngineException When no task exists with the given id.
*/
void resolveTask(String taskId, Map<String, Object> variables);
/**
* Called when the task is successfully executed,
......@@ -315,9 +328,15 @@ public interface TaskService {
/** get a variables and search in the task scope and if available also the execution scopes. */
Object getVariable(String taskId, String variableName);
/** checks whether or not the task has a variable defined with the given name, in the task scope and if available also the execution scopes. */
boolean hasVariable(String taskId, String variableName);
/** get a variables and only search in the task scope. */
/** checks whether or not the task has a variable defined with the given name. */
Object getVariableLocal(String taskId, String variableName);
/** checks whether or not the task has a variable defined with the given name, local task scope only. */
boolean hasVariableLocal(String taskId, String variableName);
/** get all variables and search in the task scope and if available also the execution scopes.
* If you have many variables and you only need a few, consider using {@link #getVariables(String, Collection)}
......@@ -360,16 +379,30 @@ public interface TaskService {
void removeVariablesLocal(String taskId, Collection<String> variableNames);
/** Add a comment to a task and/or process instance. */
void addComment(String taskId, String processInstanceId, String message);
Comment addComment(String taskId, String processInstanceId, String message);
/**
* Returns an individual comment with the given id. Returns null if no comment exists with the given id.
*/
Comment getComment(String commentId);
/** Removes all comments from the provided task and/or process instance*/
void deleteComments(String taskId, String processInstanceId);
/**
* Removes an individual comment with the given id.
* @throws ActivitiObjectNotFoundException when no comment exists with the given id.
*/
void deleteComment(String commentId);
/** The comments related to the given task. */
List<Comment> getTaskComments(String taskId);
/** The all events related to the given task. */
List<Event> getTaskEvents(String taskId);
/** Returns an individual event with the given id. Returns null if no event exists with the given id. */
Event getEvent(String eventId);
/** The comments related to the given process instance. */
List<Comment> getProcessInstanceComments(String processInstanceId);
......
......@@ -23,6 +23,9 @@ import org.activiti.engine.runtime.Execution;
* @author Tom Baeyens
*/
public interface HistoricDetailQuery extends Query<HistoricDetailQuery, HistoricDetail> {
/** Only select historic info with the given id. */
HistoricDetailQuery id(String id);
/** Only select historic variable updates with the given process instance.
* {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. */
......@@ -33,10 +36,6 @@ public interface HistoricDetailQuery extends Query<HistoricDetailQuery, Historic
* only process instances are.*/
HistoricDetailQuery executionId(String executionId);
/** Only select historic variable updates associated to the given {@link HistoricActivityInstance activity instance}.
* @deprecated since 5.2, use {@link #activityInstanceId(String)} instead */
HistoricDetailQuery activityId(String activityId);
/** Only select historic variable updates associated to the given {@link HistoricActivityInstance activity instance}. */
HistoricDetailQuery activityInstanceId(String activityInstanceId);
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.history;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.identity.UserQuery;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.IdentityLinkType;
/**
* Historic counterpart of {@link IdentityLink} that represents the current state
* if any runtime link. Will be preserved when the runtime process instance or task
* is finished.
*
* @author Frederik Heremans
*/
public interface HistoricIdentityLink {
/**
* Returns the type of link.
* See {@link IdentityLinkType} for the native supported types by Activiti.
*/
String getType();
/**
* If the identity link involves a user, then this will be a non-null id of a user.
* That userId can be used to query for user information through the {@link UserQuery} API.
*/
String getUserId();
/**
* If the identity link involves a group, then this will be a non-null id of a group.
* That groupId can be used to query for user information through the {@link GroupQuery} API.
*/
String getGroupId();
/**
* The id of the task associated with this identity link.
*/
String getTaskId();
/**
* The id of the process instance associated with this identity link.
*/
String getProcessInstanceId();
}
......@@ -58,6 +58,9 @@ public interface HistoricProcessInstanceQuery extends Query<HistoricProcessInsta
/** Only select historic process instance that are not yet finished. */
HistoricProcessInstanceQuery unfinished();
/** Only select the historic process instances with which the user with the given id is involved. */
HistoricProcessInstanceQuery involvedUser(String userId);
/** Only select process instances which had a global variable with the given value
* when they ended. The type only applies to already ended
* process instances, otherwise use a {@link ProcessInstanceQuery} instead! of
......
......@@ -32,6 +32,9 @@ public interface HistoricTaskInstanceQuery extends Query<HistoricTaskInstanceQu
/** Only select historic task instances for the given process instance. */
HistoricTaskInstanceQuery processInstanceId(String processInstanceId);
/** Only select historic process instances with the given business key */
HistoricTaskInstanceQuery processInstanceBusinessKey(String processInstanceBusinessKey);
/** Only select historic task instances for the given execution. */
HistoricTaskInstanceQuery executionId(String executionId);
......@@ -114,6 +117,10 @@ public interface HistoricTaskInstanceQuery extends Query<HistoricTaskInstanceQu
*/
HistoricTaskInstanceQuery taskOwnerLike(String taskOwnerLike);
/** Only select historic task for which there exist an {@link HistoricIdentityLink} with the given user, including tasks
* which have been assigned to the given user (assignee) or owned by the given user (owner). */
HistoricTaskInstanceQuery taskInvolvedUser(String involvedUser);
/**
* Only select historic task instances with the given priority.
*/
......@@ -175,6 +182,11 @@ public interface HistoricTaskInstanceQuery extends Query<HistoricTaskInstanceQu
*/
HistoricTaskInstanceQuery taskDueAfter(Date dueDate);
/**
* Only select select historic task instances which are created on the given date
*/
HistoricTaskInstanceQuery taskCreatedOn(Date startDate);
/** Order by task id (needs to be followed by {@link #asc()} or {@link #desc()}). */
HistoricTaskInstanceQuery orderByTaskId();
......
package org.activiti.engine.identity;
import org.activiti.engine.query.NativeQuery;
/**
* Allows querying of {@link org.activiti.engine.identity.Group}s via native (SQL) queries
* @author Henry Yan(http://www.kafeitu.me)
*/
public interface NativeGroupQuery extends NativeQuery<NativeGroupQuery, Group> {
}
\ No newline at end of file
package org.activiti.engine.identity;
import org.activiti.engine.query.NativeQuery;
/**
* Allows querying of {@link org.activiti.engine.identity.User}s via native (SQL) queries
* @author Henry Yan(http://www.kafeitu.me)
*/
public interface NativeUserQuery extends NativeQuery<NativeUserQuery, User> {
}
\ No newline at end of file
......@@ -23,6 +23,8 @@ import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.query.NativeQuery;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
/**
* Abstract superclass for all native query types.
......@@ -35,12 +37,14 @@ public abstract class AbstractNativeQuery<T extends NativeQuery< ? , ? >, U> imp
private static final long serialVersionUID = 1L;
private static enum ResultType {
LIST, SINGLE_RESULT, COUNT
LIST, LIST_PAGE, SINGLE_RESULT, COUNT
}
protected transient CommandExecutor commandExecutor;
protected transient CommandContext commandContext;
protected int maxResults = Integer.MAX_VALUE;
protected int firstResult = 0;
protected ResultType resultType;
private Map<String, Object> parameters = new HashMap<String, Object>();
......@@ -88,6 +92,17 @@ public abstract class AbstractNativeQuery<T extends NativeQuery< ? , ? >, U> imp
}
return executeList(Context.getCommandContext(), getParameterMap(), 0, Integer.MAX_VALUE);
}
@SuppressWarnings("unchecked")
public List<U> listPage(int firstResult, int maxResults) {
this.firstResult =firstResult;
this.maxResults = maxResults;
this.resultType = ResultType.LIST_PAGE;
if (commandExecutor!=null) {
return (List<U>) commandExecutor.execute(this);
}
return executeList(Context.getCommandContext(), getParameterMap(), firstResult, maxResults);
}
public long count() {
this.resultType = ResultType.COUNT;
......@@ -100,6 +115,26 @@ public abstract class AbstractNativeQuery<T extends NativeQuery< ? , ? >, U> imp
public Object execute(CommandContext commandContext) {
if (resultType == ResultType.LIST) {
return executeList(commandContext, getParameterMap(), 0, Integer.MAX_VALUE);
} else if (resultType == ResultType.LIST_PAGE) {
Map<String, Object> parameterMap = getParameterMap();
parameterMap.put("resultType", "LIST_PAGE");
parameterMap.put("firstResult", firstResult);
parameterMap.put("maxResults", maxResults);
if (StringUtils.isNotBlank(ObjectUtils.toString(parameterMap.get("orderBy")))) {
parameterMap.put("orderBy", "RES." + parameterMap.get("orderBy"));
} else {
parameterMap.put("orderBy", "RES.ID_ asc");
}
int firstRow = firstResult + 1;
parameterMap.put("firstRow", firstRow);
int lastRow = 0;
if(maxResults == Integer.MAX_VALUE) {
lastRow = maxResults;
}
lastRow = firstResult + maxResults + 1;
parameterMap.put("lastRow", lastRow);
return executeList(commandContext, parameterMap, firstResult, maxResults);
} else if (resultType == ResultType.SINGLE_RESULT) {
return executeSingleResult(commandContext);
} else {
......
......@@ -15,7 +15,6 @@ package org.activiti.engine.impl;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
......@@ -37,6 +36,7 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
protected String processDefinitionKey;
protected String activityId;
protected String executionId;
protected String parentId;
protected String processInstanceId;
protected List<EventSubscriptionQueryValue> eventSubscriptions;
......@@ -45,6 +45,7 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
protected String subProcessInstanceId;
protected SuspensionState suspensionState;
protected String businessKey;
protected boolean includeChildExecutionsWithBusinessKeyQuery;
protected boolean isActive;
protected String involvedUser;
......@@ -96,6 +97,19 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
return this;
}
public ExecutionQuery processInstanceBusinessKey(String processInstanceBusinessKey, boolean includeChildExecutions) {
if (!includeChildExecutions) {
return processInstanceBusinessKey(processInstanceBusinessKey);
} else {
if (processInstanceBusinessKey == null) {
throw new ActivitiIllegalArgumentException("Business key is null");
}
this.businessKey = processInstanceBusinessKey;
this.includeChildExecutionsWithBusinessKeyQuery = includeChildExecutions;
return this;
}
}
public ExecutionQueryImpl executionId(String executionId) {
if (executionId == null) {
throw new ActivitiIllegalArgumentException("Execution id is null");
......@@ -113,6 +127,14 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
return this;
}
public ExecutionQueryImpl parentId(String parentId) {
if (parentId == null) {
throw new ActivitiIllegalArgumentException("Parent id is null");
}
this.parentId = parentId;
return this;
}
public ExecutionQuery signalEventSubscription(String signalName) {
return eventSubscription("signal", signalName);
}
......@@ -213,11 +235,13 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
public void setSuspensionState(SuspensionState suspensionState) {
this.suspensionState = suspensionState;
}
public List<EventSubscriptionQueryValue> getEventSubscriptions() {
return eventSubscriptions;
}
public boolean isIncludeChildExecutionsWithBusinessKeyQuery() {
return includeChildExecutionsWithBusinessKeyQuery;
}
public void setEventSubscriptions(List<EventSubscriptionQueryValue> eventSubscriptions) {
this.eventSubscriptions = eventSubscriptions;
}
......@@ -230,5 +254,8 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
public void setInvolvedUser(String involvedUser) {
this.involvedUser = involvedUser;
}
public String getParentId() {
return parentId;
}
}
......@@ -116,14 +116,14 @@ public class GroupQueryImpl extends AbstractQuery<GroupQuery, Group> implements
public long executeCount(CommandContext commandContext) {
checkQueryOk();
return commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.findGroupCountByQueryCriteria(this);
}
public List<Group> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
return commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.findGroupByQueryCriteria(this, page);
}
......
......@@ -30,6 +30,7 @@ import org.activiti.engine.impl.variable.JPAEntityVariableType;
public class HistoricDetailQueryImpl extends AbstractQuery<HistoricDetailQuery, HistoricDetail> implements HistoricDetailQuery {
private static final long serialVersionUID = 1L;
protected String id;
protected String taskId;
protected String processInstanceId;
protected String executionId;
......@@ -49,6 +50,11 @@ public class HistoricDetailQueryImpl extends AbstractQuery<HistoricDetailQuery,
super(commandExecutor);
}
public HistoricDetailQuery id(String id) {
this.id = id;
return this;
}
public HistoricDetailQuery processInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
return this;
......
......@@ -18,7 +18,6 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
......@@ -48,6 +47,7 @@ public class HistoricProcessInstanceQueryImpl extends AbstractVariableQueryImpl<
protected Date finishedAfter;
protected String processDefinitionKey;
protected Set<String> processInstanceIds;
protected String involvedUser;
public HistoricProcessInstanceQueryImpl() {
}
......@@ -134,11 +134,17 @@ public class HistoricProcessInstanceQueryImpl extends AbstractVariableQueryImpl<
}
public HistoricProcessInstanceQuery superProcessInstanceId(String superProcessInstanceId) {
this.superProcessInstanceId = superProcessInstanceId;
return this;
this.superProcessInstanceId = superProcessInstanceId;
return this;
}
public HistoricProcessInstanceQuery orderByProcessInstanceBusinessKey() {
@Override
public HistoricProcessInstanceQuery involvedUser(String userId) {
this.involvedUser = userId;
return this;
}
public HistoricProcessInstanceQuery orderByProcessInstanceBusinessKey() {
return orderBy(HistoricProcessInstanceQueryProperty.BUSINESS_KEY);
}
......@@ -224,6 +230,9 @@ public class HistoricProcessInstanceQueryImpl extends AbstractVariableQueryImpl<
public Date getFinishedBefore() {
return finishedBefore;
}
public String getInvolvedUser() {
return involvedUser;
}
// below is deprecated and to be removed in 5.12
......
......@@ -35,6 +35,7 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
protected String processDefinitionKey;
protected String processDefinitionName;
protected String processInstanceId;
protected String processInstanceBusinessKey;
protected String executionId;
protected String taskId;
protected String taskName;
......@@ -49,6 +50,7 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
protected String taskAssignee;
protected String taskAssigneeLike;
protected String taskDefinitionKey;
protected String involvedUser;
protected Integer taskPriority;
protected boolean finished;
protected boolean unfinished;
......@@ -58,6 +60,7 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
protected Date dueDate;
protected Date dueAfter;
protected Date dueBefore;
protected Date creationDate;
public HistoricTaskInstanceQueryImpl() {
}
......@@ -89,6 +92,11 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
this.processInstanceId = processInstanceId;
return this;
}
public HistoricTaskInstanceQueryImpl processInstanceBusinessKey(String processInstanceBusinessKey) {
this.processInstanceBusinessKey = processInstanceBusinessKey;
return this;
}
public HistoricTaskInstanceQueryImpl executionId(String executionId) {
this.executionId = executionId;
......@@ -230,6 +238,17 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
this.dueBefore = dueBefore;
return this;
}
public HistoricTaskInstanceQuery taskCreatedOn(Date creationDate) {
this.creationDate = creationDate;
return this;
}
@Override
public HistoricTaskInstanceQuery taskInvolvedUser(String involvedUser) {
this.involvedUser = involvedUser;
return this;
}
// ordering /////////////////////////////////////////////////////////////////
......@@ -324,6 +343,9 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
public String getProcessInstanceId() {
return processInstanceId;
}
public String getProcessInstanceBusinessKey() {
return processInstanceBusinessKey;
}
public String getExecutionId() {
return executionId;
}
......@@ -378,4 +400,10 @@ public class HistoricTaskInstanceQueryImpl extends AbstractQuery<HistoricTaskIns
public String getTaskParentTaskId() {
return taskParentTaskId;
}
public Date getCreationDate() {
return creationDate;
}
public String getInvolvedUser() {
return involvedUser;
}
}
......@@ -14,9 +14,12 @@
package org.activiti.engine.impl;
import java.util.List;
import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.history.HistoricDetailQuery;
import org.activiti.engine.history.HistoricIdentityLink;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
import org.activiti.engine.history.HistoricTaskInstanceQuery;
import org.activiti.engine.history.HistoricVariableInstanceQuery;
......@@ -25,6 +28,7 @@ import org.activiti.engine.history.NativeHistoricProcessInstanceQuery;
import org.activiti.engine.history.NativeHistoricTaskInstanceQuery;
import org.activiti.engine.impl.cmd.DeleteHistoricProcessInstanceCmd;
import org.activiti.engine.impl.cmd.DeleteHistoricTaskInstanceCmd;
import org.activiti.engine.impl.cmd.GetHistoricIdentityLinksForTaskCmd;
/**
* @author Tom Baeyens
......@@ -72,4 +76,14 @@ public class HistoryServiceImpl extends ServiceImpl implements HistoryService {
public NativeHistoricActivityInstanceQuery createNativeHistoricActivityInstanceQuery() {
return new NativeHistoricActivityInstanceQueryImpl(commandExecutor);
}
@Override
public List<HistoricIdentityLink> getHistoricIdentityLinksForProcessInstance(String processInstanceId) {
return commandExecutor.execute(new GetHistoricIdentityLinksForTaskCmd(null, processInstanceId));
}
@Override
public List<HistoricIdentityLink> getHistoricIdentityLinksForTask(String taskId) {
return commandExecutor.execute(new GetHistoricIdentityLinksForTaskCmd(taskId, null));
}
}
......@@ -12,11 +12,11 @@
*/
package org.activiti.engine.impl;
import java.util.List;
import org.activiti.engine.IdentityService;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.identity.NativeGroupQuery;
import org.activiti.engine.identity.NativeUserQuery;
import org.activiti.engine.identity.Picture;
import org.activiti.engine.identity.User;
import org.activiti.engine.identity.UserQuery;
......@@ -41,6 +41,8 @@ import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.persistence.entity.GroupEntity;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity;
import java.util.List;
/**
* @author Tom Baeyens
......@@ -66,11 +68,21 @@ public class IdentityServiceImpl extends ServiceImpl implements IdentityService
public UserQuery createUserQuery() {
return commandExecutor.execute(new CreateUserQueryCmd());
}
@Override
public NativeUserQuery createNativeUserQuery() {
return new NativeUserQueryImpl(commandExecutor);
}
public GroupQuery createGroupQuery() {
return commandExecutor.execute(new CreateGroupQueryCmd());
}
@Override
public NativeGroupQuery createNativeGroupQuery() {
return new NativeGroupQueryImpl(commandExecutor);
}
public void createMembership(String userId, String groupId) {
commandExecutor.execute(new CreateMembershipCmd(userId, groupId));
}
......
package org.activiti.engine.impl;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.repository.NativeDeploymentQuery;
import org.activiti.engine.repository.Deployment;
import java.util.List;
import java.util.Map;
public class NativeDeploymentQueryImpl extends AbstractNativeQuery<NativeDeploymentQuery, Deployment> implements NativeDeploymentQuery {
private static final long serialVersionUID = 1L;
public NativeDeploymentQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public NativeDeploymentQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
//results ////////////////////////////////////////////////////////////////
public List<Deployment> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
return commandContext
.getDeploymentEntityManager()
.findDeploymentsByNativeQuery(parameterMap, firstResult, maxResults);
}
public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
return commandContext
.getDeploymentEntityManager()
.findDeploymentCountByNativeQuery(parameterMap);
}
}
package org.activiti.engine.impl;
import org.activiti.engine.identity.NativeGroupQuery;
import org.activiti.engine.identity.Group;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import java.util.List;
import java.util.Map;
public class NativeGroupQueryImpl extends AbstractNativeQuery<NativeGroupQuery, Group> implements NativeGroupQuery {
private static final long serialVersionUID = 1L;
public NativeGroupQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public NativeGroupQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
//results ////////////////////////////////////////////////////////////////
public List<Group> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
return commandContext
.getGroupIdentityManager()
.findGroupsByNativeQuery(parameterMap, firstResult, maxResults);
}
public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
return commandContext
.getGroupIdentityManager()
.findGroupCountByNativeQuery(parameterMap);
}
}
\ No newline at end of file
package org.activiti.engine.impl;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.repository.NativeModelQuery;
import org.activiti.engine.repository.Model;
import java.util.List;
import java.util.Map;
public class NativeModelQueryImpl extends AbstractNativeQuery<NativeModelQuery, Model> implements NativeModelQuery {
private static final long serialVersionUID = 1L;
public NativeModelQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public NativeModelQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
//results ////////////////////////////////////////////////////////////////
public List<Model> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
return commandContext
.getModelEntityManager()
.findModelsByNativeQuery(parameterMap, firstResult, maxResults);
}
public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
return commandContext
.getModelEntityManager()
.findModelCountByNativeQuery(parameterMap);
}
}
package org.activiti.engine.impl;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.repository.NativeProcessDefinitionQuery;
import org.activiti.engine.repository.ProcessDefinition;
import java.util.List;
import java.util.Map;
public class NativeProcessDefinitionQueryImpl extends AbstractNativeQuery<NativeProcessDefinitionQuery, ProcessDefinition> implements NativeProcessDefinitionQuery {
private static final long serialVersionUID = 1L;
public NativeProcessDefinitionQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public NativeProcessDefinitionQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
//results ////////////////////////////////////////////////////////////////
public List<ProcessDefinition> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
return commandContext
.getProcessDefinitionEntityManager()
.findProcessDefinitionsByNativeQuery(parameterMap, firstResult, maxResults);
}
public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
return commandContext
.getProcessDefinitionEntityManager()
.findProcessDefinitionCountByNativeQuery(parameterMap);
}
}
package org.activiti.engine.impl;
import org.activiti.engine.identity.NativeUserQuery;
import org.activiti.engine.identity.User;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import java.util.List;
import java.util.Map;
public class NativeUserQueryImpl extends AbstractNativeQuery<NativeUserQuery, User> implements NativeUserQuery {
private static final long serialVersionUID = 1L;
public NativeUserQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public NativeUserQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
//results ////////////////////////////////////////////////////////////////
public List<User> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
return commandContext
.getUserIdentityManager()
.findUsersByNativeQuery(parameterMap, firstResult, maxResults);
}
public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
return commandContext
.getUserIdentityManager()
.findUserCountByNativeQuery(parameterMap);
}
}
\ No newline at end of file
......@@ -209,7 +209,7 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
if(authorizationUserId != null) {
List<Group> groups = Context
.getCommandContext()
.getGroupEntityManager()
.getGroupIdentityManager()
.findGroupsByUser(authorizationUserId);
List<String> groupIds = new ArrayList<String>();
for (Group group : groups) {
......
......@@ -17,7 +17,6 @@ import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
......@@ -38,6 +37,7 @@ public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl<ProcessI
private static final long serialVersionUID = 1L;
protected String executionId;
protected String businessKey;
protected boolean includeChildExecutionsWithBusinessKeyQuery;
protected String processDefinitionId;
protected Set<String> processInstanceIds;
protected String processDefinitionKey;
......@@ -188,6 +188,9 @@ public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl<ProcessI
public String getBusinessKey() {
return businessKey;
}
public boolean isIncludeChildExecutionsWithBusinessKeyQuery() {
return includeChildExecutionsWithBusinessKeyQuery;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
......@@ -220,4 +223,12 @@ public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl<ProcessI
public void setEventSubscriptions(List<EventSubscriptionQueryValue> eventSubscriptions) {
this.eventSubscriptions = eventSubscriptions;
}
/**
* Method needed for ibatis because of re-use of query-xml for executions. ExecutionQuery contains
* a parentId property.
*/
public String getParentId() {
return null;
}
}
......@@ -13,10 +13,6 @@
package org.activiti.engine.impl;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.cmd.ActivateProcessDefinitionCmd;
......@@ -40,6 +36,7 @@ import org.activiti.engine.impl.cmd.GetModelCmd;
import org.activiti.engine.impl.cmd.GetModelEditorSourceCmd;
import org.activiti.engine.impl.cmd.GetModelEditorSourceExtraCmd;
import org.activiti.engine.impl.cmd.SaveModelCmd;
import org.activiti.engine.impl.cmd.SetProcessDefinitionCategoryCmd;
import org.activiti.engine.impl.cmd.SuspendProcessDefinitionCmd;
import org.activiti.engine.impl.persistence.entity.ModelEntity;
import org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition;
......@@ -50,10 +47,17 @@ import org.activiti.engine.repository.DeploymentQuery;
import org.activiti.engine.repository.DiagramLayout;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ModelQuery;
import org.activiti.engine.repository.NativeDeploymentQuery;
import org.activiti.engine.repository.NativeModelQuery;
import org.activiti.engine.repository.NativeProcessDefinitionQuery;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.engine.task.IdentityLink;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
/**
* @author Tom Baeyens
......@@ -86,6 +90,11 @@ public class RepositoryServiceImpl extends ServiceImpl implements RepositoryServ
return new ProcessDefinitionQueryImpl(commandExecutor);
}
@Override
public NativeProcessDefinitionQuery createNativeProcessDefinitionQuery() {
return new NativeProcessDefinitionQueryImpl(commandExecutor);
}
@SuppressWarnings("unchecked")
public List<String> getDeploymentResourceNames(String deploymentId) {
return commandExecutor.execute(new GetDeploymentResourceNamesCmd(deploymentId));
......@@ -99,6 +108,11 @@ public class RepositoryServiceImpl extends ServiceImpl implements RepositoryServ
return new DeploymentQueryImpl(commandExecutor);
}
@Override
public NativeDeploymentQuery createNativeDeploymentQuery() {
return new NativeDeploymentQueryImpl(commandExecutor);
}
public ProcessDefinition getProcessDefinition(String processDefinitionId) {
return commandExecutor.execute(new GetDeploymentProcessDefinitionCmd(processDefinitionId));
}
......@@ -142,6 +156,10 @@ public class RepositoryServiceImpl extends ServiceImpl implements RepositoryServ
public void activateProcessDefinitionByKey(String processDefinitionKey, boolean activateProcessInstances, Date activationDate) {
commandExecutor.execute(new ActivateProcessDefinitionCmd(null, processDefinitionKey, activateProcessInstances, activationDate));
}
public void setProcessDefinitionCategory(String processDefinitionId, String category) {
commandExecutor.execute(new SetProcessDefinitionCategoryCmd(processDefinitionId, category));
}
public InputStream getProcessModel(String processDefinitionId) {
return commandExecutor.execute(new GetDeploymentProcessModelCmd(processDefinitionId));
......@@ -178,7 +196,12 @@ public class RepositoryServiceImpl extends ServiceImpl implements RepositoryServ
public ModelQuery createModelQuery() {
return new ModelQueryImpl(commandExecutor);
}
@Override
public NativeModelQuery createNativeModelQuery() {
return new NativeModelQueryImpl(commandExecutor);
}
public Model getModel(String modelId) {
return commandExecutor.execute(new GetModelCmd(modelId));
}
......
......@@ -29,6 +29,7 @@ import org.activiti.engine.impl.cmd.GetExecutionVariableCmd;
import org.activiti.engine.impl.cmd.GetExecutionVariablesCmd;
import org.activiti.engine.impl.cmd.GetIdentityLinksForProcessInstanceCmd;
import org.activiti.engine.impl.cmd.GetStartFormCmd;
import org.activiti.engine.impl.cmd.HasExecutionVariableCmd;
import org.activiti.engine.impl.cmd.MessageEventReceivedCmd;
import org.activiti.engine.impl.cmd.RemoveExecutionVariablesCmd;
import org.activiti.engine.impl.cmd.SetExecutionVariablesCmd;
......@@ -118,10 +119,20 @@ public class RuntimeServiceImpl extends ServiceImpl implements RuntimeService {
return commandExecutor.execute(new GetExecutionVariableCmd(executionId, variableName, false));
}
@Override
public boolean hasVariable(String executionId, String variableName) {
return commandExecutor.execute(new HasExecutionVariableCmd(executionId, variableName, false));
}
public Object getVariableLocal(String executionId, String variableName) {
return commandExecutor.execute(new GetExecutionVariableCmd(executionId, variableName, true));
}
@Override
public boolean hasVariableLocal(String executionId, String variableName) {
return commandExecutor.execute(new HasExecutionVariableCmd(executionId, variableName, true));
}
public void setVariable(String executionId, String variableName, Object value) {
if(variableName == null) {
throw new ActivitiIllegalArgumentException("variableName is null");
......
......@@ -31,6 +31,7 @@ import org.activiti.engine.task.TaskQuery;
* @author Joram Barrez
* @author Tom Baeyens
* @author Falko Menge
* @author Tijs Rademakers
*/
public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements TaskQuery {
......@@ -69,6 +70,8 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas
protected Date dueAfter;
protected SuspensionState suspensionState;
protected boolean excludeSubtasks = false;
protected boolean includeTaskLocalVariables = false;
protected boolean includeProcessVariables = false;
public TaskQueryImpl() {
}
......@@ -382,6 +385,16 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas
this.suspensionState = SuspensionState.ACTIVE;
return this;
}
public TaskQuery includeTaskLocalVariables() {
this.includeTaskLocalVariables = true;
return this;
}
public TaskQuery includeProcessVariables() {
this.includeProcessVariables = true;
return this;
}
public List<String> getCandidateGroups() {
if (candidateGroup!=null) {
......@@ -401,7 +414,7 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas
// and explain alternatives
List<Group> groups = Context
.getCommandContext()
.getGroupEntityManager()
.getGroupIdentityManager()
.findGroupsByUser(candidateUser);
List<String> groupIds = new ArrayList<String>();
for (Group group : groups) {
......@@ -460,9 +473,15 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas
public List<Task> executeList(CommandContext commandContext, Page page) {
ensureVariablesInitialized();
checkQueryOk();
return commandContext
.getTaskEntityManager()
.findTasksByQueryCriteria(this);
if (includeTaskLocalVariables || includeProcessVariables) {
return commandContext
.getTaskEntityManager()
.findTasksAndVariablesByQueryCriteria(this);
} else {
return commandContext
.getTaskEntityManager()
.findTasksByQueryCriteria(this);
}
}
public long executeCount(CommandContext commandContext) {
......
......@@ -34,15 +34,18 @@ import org.activiti.engine.impl.cmd.DeleteIdentityLinkCmd;
import org.activiti.engine.impl.cmd.DeleteTaskCmd;
import org.activiti.engine.impl.cmd.GetAttachmentCmd;
import org.activiti.engine.impl.cmd.GetAttachmentContentCmd;
import org.activiti.engine.impl.cmd.GetCommentCmd;
import org.activiti.engine.impl.cmd.GetIdentityLinksForTaskCmd;
import org.activiti.engine.impl.cmd.GetProcessInstanceAttachmentsCmd;
import org.activiti.engine.impl.cmd.GetProcessInstanceCommentsCmd;
import org.activiti.engine.impl.cmd.GetSubTasksCmd;
import org.activiti.engine.impl.cmd.GetTaskAttachmentsCmd;
import org.activiti.engine.impl.cmd.GetTaskCommentsCmd;
import org.activiti.engine.impl.cmd.GetTaskEventCmd;
import org.activiti.engine.impl.cmd.GetTaskEventsCmd;
import org.activiti.engine.impl.cmd.GetTaskVariableCmd;
import org.activiti.engine.impl.cmd.GetTaskVariablesCmd;
import org.activiti.engine.impl.cmd.HasTaskVariableCmd;
import org.activiti.engine.impl.cmd.RemoveTaskVariablesCmd;
import org.activiti.engine.impl.cmd.ResolveTaskCmd;
import org.activiti.engine.impl.cmd.SaveAttachmentCmd;
......@@ -172,7 +175,7 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
commandExecutor.execute(new ResolveTaskCmd(taskId, null));
}
public void resolve(String taskId, Map<String, Object> variables) {
public void resolveTask(String taskId, Map<String, Object> variables) {
commandExecutor.execute(new ResolveTaskCmd(taskId, variables));
}
......@@ -212,10 +215,18 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
return commandExecutor.execute(new GetTaskVariableCmd(executionId, variableName, false));
}
public boolean hasVariable(String taskId, String variableName) {
return commandExecutor.execute(new HasTaskVariableCmd(taskId, variableName, false));
}
public Object getVariableLocal(String executionId, String variableName) {
return commandExecutor.execute(new GetTaskVariableCmd(executionId, variableName, true));
}
public boolean hasVariableLocal(String taskId, String variableName) {
return commandExecutor.execute(new HasTaskVariableCmd(taskId, variableName, true));
}
public void setVariable(String executionId, String variableName, Object value) {
if(variableName == null) {
throw new ActivitiIllegalArgumentException("variableName is null");
......@@ -262,8 +273,18 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
commandExecutor.execute(new RemoveTaskVariablesCmd(taskId, variableNames, true));
}
public void addComment(String taskId, String processInstance, String message) {
commandExecutor.execute(new AddCommentCmd(taskId, processInstance, message));
public Comment addComment(String taskId, String processInstance, String message) {
return commandExecutor.execute(new AddCommentCmd(taskId, processInstance, message));
}
@Override
public Comment getComment(String commentId) {
return commandExecutor.execute(new GetCommentCmd(commentId));
}
@Override
public Event getEvent(String eventId) {
return commandExecutor.execute(new GetTaskEventCmd(eventId));
}
public List<Comment> getTaskComments(String taskId) {
......@@ -295,7 +316,12 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
}
public void deleteComments(String taskId, String processInstanceId) {
commandExecutor.execute(new DeleteCommentCmd(taskId, processInstanceId));
commandExecutor.execute(new DeleteCommentCmd(taskId, processInstanceId, null));
}
@Override
public void deleteComment(String commentId) {
commandExecutor.execute(new DeleteCommentCmd(null, null, commentId));
}
public Attachment getAttachment(String attachmentId) {
......
......@@ -145,14 +145,14 @@ public class UserQueryImpl extends AbstractQuery<UserQuery, User> implements Use
public long executeCount(CommandContext commandContext) {
checkQueryOk();
return commandContext
.getUserEntityManager()
.getUserIdentityManager()
.findUserCountByQueryCriteria(this);
}
public List<User> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
return commandContext
.getUserEntityManager()
.getUserIdentityManager()
.findUserByQueryCriteria(this, page);
}
......
......@@ -84,7 +84,7 @@ public abstract class MultiInstanceActivityBehavior extends FlowNodeActivityBeha
}
public void execute(ActivityExecution execution) throws Exception {
if (getLoopVariable(execution, LOOP_COUNTER) == null) {
if (getLocalLoopVariable(execution, LOOP_COUNTER) == null) {
try {
createInstances(execution);
} catch (BpmnError error) {
......@@ -227,6 +227,10 @@ public abstract class MultiInstanceActivityBehavior extends FlowNodeActivityBeha
}
return (Integer) value;
}
protected Integer getLocalLoopVariable(ActivityExecution execution, String variableName) {
return (Integer) execution.getVariableLocal(variableName);
}
/**
* Since no transitions are followed when leaving the inner activity,
......
......@@ -187,6 +187,7 @@ public class BpmnDeployer implements Deployer {
if (timerDeclarations!=null) {
for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
TimerEntity timer = timerDeclaration.prepareTimerEntity(null);
timer.setProcessDefinitionId(processDefinition.getId());
Context
.getCommandContext()
.getJobEntityManager()
......@@ -269,7 +270,6 @@ public class BpmnDeployer implements Deployer {
}
private void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
CommandContext commandContext = Context.getCommandContext();
if (exprSet != null) {
Iterator<Expression> iterator = exprSet.iterator();
while (iterator.hasNext()) {
......@@ -282,7 +282,7 @@ public class BpmnDeployer implements Deployer {
identityLink.setGroupId(expr.toString());
}
identityLink.setType(IdentityLinkType.CANDIDATE);
commandContext.getDbSqlSession().insert(identityLink);
identityLink.insert();
}
}
}
......
......@@ -84,7 +84,7 @@ public class ProcessDiagramCanvas {
protected static Color LABEL_COLOR = new Color(112, 146, 190);
// Fonts
protected static Font LABEL_FONT = new Font("Arial", Font.ITALIC, 10);
protected static Font LABEL_FONT = null;
// Strokes
protected static Stroke THICK_TASK_BORDER_STROKE = new BasicStroke(3.0f);
......@@ -140,6 +140,7 @@ public class ProcessDiagramCanvas {
protected FontMetrics fontMetrics;
protected boolean closed;
protected String activityFontName = "Arial";
protected String labelFontName = "Arial";
/**
* Creates an empty canvas with given width and height.
......@@ -151,6 +152,10 @@ public class ProcessDiagramCanvas {
if (Context.getProcessEngineConfiguration() != null) {
this.activityFontName = Context.getProcessEngineConfiguration().getActivityFontName();
}
if (Context.getProcessEngineConfiguration() != null) {
this.labelFontName = Context.getProcessEngineConfiguration().getLabelFontName();
}
this.processDiagram = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
this.g = processDiagram.createGraphics();
......@@ -160,6 +165,8 @@ public class ProcessDiagramCanvas {
Font font = new Font(activityFontName, Font.BOLD, FONT_SIZE);
g.setFont(font);
this.fontMetrics = g.getFontMetrics();
LABEL_FONT = new Font(labelFontName, Font.ITALIC, 10);
}
/**
......
......@@ -408,6 +408,7 @@ public class ProcessDiagramGenerator {
// Outgoing transitions of activity
for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId());
boolean drawedLabel = false;
for (int i=1; i<graphicInfoList.size(); i++) {
GraphicInfo graphicInfo = graphicInfoList.get(i);
......@@ -422,6 +423,17 @@ public class ProcessDiagramGenerator {
} else {
processDiagramCanvas.drawSequenceflow((int) previousGraphicInfo.getX(), (int) previousGraphicInfo.getY(),
(int) graphicInfo.getX(), (int) graphicInfo.getY(), drawConditionalIndicator, highLighted);
if (!drawedLabel) {
GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId());
if (labelGraphicInfo != null) {
int middleX = (int) (((previousGraphicInfo.getX() + labelGraphicInfo.getX()) + (graphicInfo.getX()+ labelGraphicInfo.getX())) / 2);
int middleY = (int) (((previousGraphicInfo.getY() + labelGraphicInfo.getY()) + (graphicInfo.getY()+ labelGraphicInfo.getY())) / 2);
middleX += 15;
processDiagramCanvas.drawLabel(sequenceFlow.getName(), middleX, middleY,
(int) labelGraphicInfo.getWidth(), (int) labelGraphicInfo.getHeight());
drawedLabel = true;
}
}
}
}
}
......
......@@ -32,6 +32,8 @@ public class ScriptTaskListener implements TaskListener {
protected Expression language = null;
protected Expression resultVariable = null;
protected boolean autoStoreVariables;
public void notify(DelegateTask delegateTask) {
if (script == null) {
......@@ -44,7 +46,7 @@ public class ScriptTaskListener implements TaskListener {
ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
Object result = scriptingEngines.evaluate(script.getExpressionText(), language.getExpressionText(), delegateTask);
Object result = scriptingEngines.evaluate(script.getExpressionText(), language.getExpressionText(), delegateTask, autoStoreVariables);
if (resultVariable != null) {
delegateTask.setVariable(resultVariable.getExpressionText(), result);
......@@ -62,5 +64,10 @@ public class ScriptTaskListener implements TaskListener {
public void setResultVariable(Expression resultVariable) {
this.resultVariable = resultVariable;
}
public void setAutoStoreVariables(boolean autoStoreVariables) {
this.autoStoreVariables = autoStoreVariables;
}
}
......@@ -136,6 +136,9 @@ import org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler
import org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler;
import org.activiti.engine.impl.jobexecutor.TimerSuspendProcessDefinitionHandler;
import org.activiti.engine.impl.persistence.GenericManagerFactory;
import org.activiti.engine.impl.persistence.GroupEntityManagerFactory;
import org.activiti.engine.impl.persistence.MembershipEntityManagerFactory;
import org.activiti.engine.impl.persistence.UserEntityManagerFactory;
import org.activiti.engine.impl.persistence.deploy.DefaultDeploymentCache;
import org.activiti.engine.impl.persistence.deploy.Deployer;
import org.activiti.engine.impl.persistence.deploy.DeploymentCache;
......@@ -146,9 +149,9 @@ import org.activiti.engine.impl.persistence.entity.CommentEntityManager;
import org.activiti.engine.impl.persistence.entity.DeploymentEntityManager;
import org.activiti.engine.impl.persistence.entity.EventSubscriptionEntityManager;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricDetailEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntityManager;
......@@ -163,7 +166,6 @@ import org.activiti.engine.impl.persistence.entity.PropertyEntityManager;
import org.activiti.engine.impl.persistence.entity.ResourceEntityManager;
import org.activiti.engine.impl.persistence.entity.TableDataManager;
import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityManager;
import org.activiti.engine.impl.scripting.BeansResolverFactory;
import org.activiti.engine.impl.scripting.ResolverFactory;
......@@ -190,6 +192,7 @@ import org.activiti.engine.impl.variable.StringType;
import org.activiti.engine.impl.variable.VariableType;
import org.activiti.engine.impl.variable.VariableTypes;
import org.activiti.engine.parse.BpmnParseHandler;
import org.apache.commons.lang.ObjectUtils;
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.apache.ibatis.mapping.Environment;
......@@ -206,6 +209,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfiguration {
......@@ -255,6 +259,10 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
protected DbSqlSessionFactory dbSqlSessionFactory;
protected Map<Class<?>, SessionFactory> sessionFactories;
// Configurators ////////////////////////////////////////////////////////////
protected List<ProcessEngineConfigurator> configurators;
// DEPLOYERS ////////////////////////////////////////////////////////////////
protected BpmnDeployer bpmnDeployer;
......@@ -400,6 +408,7 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
initDelegateInterceptor();
initEventHandlers();
initFailedJobCommandFactory();
initConfigurators();
}
// failedJobCommandFactory ////////////////////////////////////////////////////////
......@@ -639,6 +648,7 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
properties.put("limitAfter" , DbSqlSessionFactory.databaseSpecificLimitAfterStatements.get(databaseType));
properties.put("limitBetween" , DbSqlSessionFactory.databaseSpecificLimitBetweenStatements.get(databaseType));
properties.put("orderBy" , DbSqlSessionFactory.databaseSpecificOrderByStatements.get(databaseType));
properties.put("limitBeforeNativeQuery" , ObjectUtils.toString(DbSqlSessionFactory.databaseSpecificLimitBeforeNativeQueryStatements.get(databaseType)));
}
XMLConfigBuilder parser = new XMLConfigBuilder(reader,"", properties);
Configuration configuration = parser.getConfiguration();
......@@ -686,22 +696,25 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
addSessionFactory(new GenericManagerFactory(HistoricProcessInstanceEntityManager.class));
addSessionFactory(new GenericManagerFactory(HistoricVariableInstanceEntityManager.class));
addSessionFactory(new GenericManagerFactory(HistoricTaskInstanceEntityManager.class));
addSessionFactory(new GenericManagerFactory(HistoricIdentityLinkEntityManager.class));
addSessionFactory(new GenericManagerFactory(IdentityInfoEntityManager.class));
addSessionFactory(new GenericManagerFactory(IdentityLinkEntityManager.class));
addSessionFactory(new GenericManagerFactory(JobEntityManager.class));
addSessionFactory(new GenericManagerFactory(GroupEntityManager.class));
addSessionFactory(new GenericManagerFactory(MembershipEntityManager.class));
addSessionFactory(new GenericManagerFactory(ProcessDefinitionEntityManager.class));
addSessionFactory(new GenericManagerFactory(PropertyEntityManager.class));
addSessionFactory(new GenericManagerFactory(ResourceEntityManager.class));
addSessionFactory(new GenericManagerFactory(ByteArrayEntityManager.class));
addSessionFactory(new GenericManagerFactory(TableDataManager.class));
addSessionFactory(new GenericManagerFactory(TaskEntityManager.class));
addSessionFactory(new GenericManagerFactory(UserEntityManager.class));
addSessionFactory(new GenericManagerFactory(VariableInstanceEntityManager.class));
addSessionFactory(new GenericManagerFactory(EventSubscriptionEntityManager.class));
addSessionFactory(new GenericManagerFactory(HistoryManager.class));
addSessionFactory(new UserEntityManagerFactory());
addSessionFactory(new GroupEntityManagerFactory());
addSessionFactory(new MembershipEntityManagerFactory());
}
if (customSessionFactories!=null) {
for (SessionFactory sessionFactory: customSessionFactories) {
addSessionFactory(sessionFactory);
......@@ -713,6 +726,14 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
sessionFactories.put(sessionFactory.getSessionType(), sessionFactory);
}
protected void initConfigurators() {
if (configurators != null) {
for (ProcessEngineConfigurator configurator : configurators) {
configurator.configure(this);
}
}
}
// deployers ////////////////////////////////////////////////////////////////
protected void initDeployers() {
......@@ -1290,6 +1311,14 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
return this;
}
public List<ProcessEngineConfigurator> getConfigurators() {
return configurators;
}
public void setConfigurators(List<ProcessEngineConfigurator> configurators) {
this.configurators = configurators;
}
public BpmnDeployer getBpmnDeployer() {
return bpmnDeployer;
}
......@@ -1976,4 +2005,4 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
this.enableSafeBpmnXml = enableSafeBpmnXml;
}
}
\ No newline at end of file
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cfg;
/**
* @author Joram Barrez
*/
public interface ProcessEngineConfigurator {
void configure(ProcessEngineConfigurationImpl processEngineConfiguration);
}
......@@ -24,6 +24,7 @@ import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.util.ClockUtil;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Event;
import org.activiti.engine.task.Task;
......@@ -31,7 +32,7 @@ import org.activiti.engine.task.Task;
/**
* @author Tom Baeyens
*/
public class AddCommentCmd implements Command<Object>{
public class AddCommentCmd implements Command<Comment>{
protected String taskId;
protected String processInstanceId;
......@@ -43,7 +44,7 @@ public class AddCommentCmd implements Command<Object>{
this.message = message;
}
public Object execute(CommandContext commandContext) {
public Comment execute(CommandContext commandContext) {
// Validate task
if (taskId != null) {
......@@ -91,7 +92,7 @@ public class AddCommentCmd implements Command<Object>{
.getCommentEntityManager()
.insert(comment);
return null;
return comment;
}
protected String getSuspendedTaskException() {
......
......@@ -34,7 +34,7 @@ public class CheckPassword implements Command<Boolean>, Serializable {
}
public Boolean execute(CommandContext commandContext) {
return commandContext.getUserEntityManager().checkPassword(userId, password);
return commandContext.getUserIdentityManager().checkPassword(userId, password);
}
}
......@@ -39,7 +39,7 @@ public class CreateGroupCmd implements Command<Group>, Serializable {
public Group execute(CommandContext commandContext) {
return commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.createNewGroup(groupId);
}
......
......@@ -29,7 +29,7 @@ public class CreateGroupQueryCmd implements Command<GroupQuery>, Serializable {
public GroupQuery execute(CommandContext commandContext) {
return commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.createNewGroupQuery();
}
......
......@@ -42,7 +42,7 @@ public class CreateMembershipCmd implements Command<Object>, Serializable {
throw new ActivitiIllegalArgumentException("groupId is null");
}
commandContext
.getMembershipEntityManager()
.getMembershipIdentityManager()
.createMembership(userId, groupId);
return null;
}
......
......@@ -39,7 +39,7 @@ public class CreateUserCmd implements Command<User>, Serializable {
public User execute(CommandContext commandContext) {
return commandContext
.getUserEntityManager()
.getUserIdentityManager()
.createNewUser(userId);
}
}
......@@ -29,7 +29,7 @@ public class CreateUserQueryCmd implements Command<UserQuery>, Serializable {
public UserQuery execute(CommandContext commandContext) {
return commandContext
.getUserEntityManager()
.getUserIdentityManager()
.createNewUserQuery();
}
......
......@@ -15,6 +15,7 @@ package org.activiti.engine.impl.cmd;
import java.io.Serializable;
import java.util.ArrayList;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.CommentEntity;
......@@ -29,27 +30,39 @@ public class DeleteCommentCmd implements Command<Void>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
protected String processInstanceId;
protected String commentId;
public DeleteCommentCmd(String taskId, String processInstanceId) {
public DeleteCommentCmd(String taskId, String processInstanceId, String commentId) {
this.taskId = taskId;
this.processInstanceId = processInstanceId;
this.commentId = commentId;
}
public Void execute(CommandContext commandContext) {
CommentEntityManager commentManager = commandContext.getCommentEntityManager();
ArrayList<Comment> comments = new ArrayList<Comment>();
if (processInstanceId != null) {
comments.addAll(commentManager.findCommentsByProcessInstanceId(processInstanceId));
}
if (taskId != null) {
comments.addAll(commentManager.findCommentsByTaskId(taskId));
}
if(commentId != null) {
// Delete for an individual comment
Comment comment = commentManager.findComment(commentId);
if(comment == null) {
throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", Comment.class);
}
commentManager.delete((CommentEntity) comment);
} else {
// Delete all comments on a task of process
ArrayList<Comment> comments = new ArrayList<Comment>();
if (processInstanceId != null) {
comments.addAll(commentManager.findCommentsByProcessInstanceId(processInstanceId));
}
if (taskId != null) {
comments.addAll(commentManager.findCommentsByTaskId(taskId));
}
for (Comment comment : comments) {
commentManager.delete((CommentEntity)comment);
for (Comment comment : comments) {
commentManager.delete((CommentEntity)comment);
}
}
return null;
}
}
......@@ -36,7 +36,7 @@ public class DeleteGroupCmd implements Command<Void>, Serializable {
throw new ActivitiIllegalArgumentException("groupId is null");
}
commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.deleteGroup(groupId);
return null;
......
......@@ -42,7 +42,7 @@ public class DeleteMembershipCmd implements Command<Void>, Serializable {
}
commandContext
.getMembershipEntityManager()
.getMembershipIdentityManager()
.deleteMembership(userId, groupId);
return null;
......
......@@ -36,7 +36,7 @@ public class DeleteUserCmd implements Command<Void>, Serializable {
throw new ActivitiIllegalArgumentException("userId is null");
}
commandContext
.getUserEntityManager()
.getUserIdentityManager()
.deleteUser(userId);
return null;
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cmd;
import java.io.Serializable;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.task.Comment;
/**
* @author Frederik Heremans
*/
public class GetCommentCmd implements Command<Comment>, Serializable {
private static final long serialVersionUID = 1L;
protected String commentId;
public GetCommentCmd(String commentId) {
this.commentId = commentId;
if(commentId == null) {
throw new ActivitiIllegalArgumentException("commentId is null");
}
}
public Comment execute(CommandContext commandContext) {
return commandContext
.getCommentEntityManager().findComment(commentId);
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cmd;
import java.io.Serializable;
import java.util.List;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.history.HistoricIdentityLink;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.activiti.engine.task.IdentityLinkType;
/**
* @author Frederik Heremans
*/
public class GetHistoricIdentityLinksForTaskCmd implements Command<List<HistoricIdentityLink>>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
protected String processInstanceId;
public GetHistoricIdentityLinksForTaskCmd(String taskId, String processInstanceId) {
if(taskId == null && processInstanceId == null) {
throw new ActivitiIllegalArgumentException("taskId or processInstanceId is required");
}
this.taskId = taskId;
this.processInstanceId = processInstanceId;
}
public List<HistoricIdentityLink> execute(CommandContext commandContext) {
if(taskId != null) {
return getLinksForTask();
} else {
return getLinksForProcessInstance();
}
}
@SuppressWarnings({"unchecked", "rawtypes" })
protected List<HistoricIdentityLink> getLinksForTask() {
HistoricTaskInstanceEntity task = Context
.getCommandContext()
.getHistoricTaskInstanceEntityManager()
.findHistoricTaskInstanceById(taskId);
if(task == null) {
throw new ActivitiObjectNotFoundException("No historic task exists with the given id: " + taskId, HistoricTaskInstance.class);
}
List<HistoricIdentityLink> identityLinks = (List) Context.getCommandContext().
getHistoricIdentityLinkEntityManager()
.findHistoricIdentityLinksByTaskId(taskId);
// Similar to GetIdentityLinksForTask, return assignee and owner as identity link
if (task.getAssignee() != null) {
HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
identityLink.setUserId(task.getAssignee());
identityLink.setTaskId(task.getId());
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
identityLink.setTaskId(task.getId());
identityLink.setUserId(task.getOwner());
identityLink.setType(IdentityLinkType.OWNER);
identityLinks.add(identityLink);
}
return identityLinks;
}
@SuppressWarnings({"unchecked", "rawtypes" })
protected List<HistoricIdentityLink> getLinksForProcessInstance() {
return (List) Context.getCommandContext().
getHistoricIdentityLinkEntityManager()
.findHistoricIdentityLinksByProcessInstanceId(processInstanceId);
}
}
......@@ -58,11 +58,13 @@ public class GetIdentityLinksForTaskCmd implements Command<List<IdentityLink>>,
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setUserId(task.getAssignee());
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLink.setTaskId(task.getId());
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setUserId(task.getOwner());
identityLink.setTaskId(task.getId());
identityLink.setType(IdentityLinkType.OWNER);
identityLinks.add(identityLink);
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cmd;
import java.io.Serializable;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.task.Event;
/**
* @author Frederik Heremans
*/
public class GetTaskEventCmd implements Command<Event>, Serializable {
private static final long serialVersionUID = 1L;
protected String eventId;
public GetTaskEventCmd(String eventId) {
this.eventId = eventId;
if(eventId == null) {
throw new ActivitiIllegalArgumentException("eventId is null");
}
}
public Event execute(CommandContext commandContext) {
return commandContext
.getCommentEntityManager().findEvent(eventId);
}
}
......@@ -41,7 +41,7 @@ public class GetUserPictureCmd implements Command<Picture>, Serializable {
throw new ActivitiIllegalArgumentException("userId is null");
}
UserEntity user = (UserEntity) commandContext
.getUserEntityManager()
.getUserIdentityManager()
.findUserById(userId);
if(user == null) {
throw new ActivitiObjectNotFoundException("user "+userId+" doesn't exist", User.class);
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cmd;
import java.io.Serializable;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.runtime.Execution;
/**
* @author Frederik Heremans
*/
public class HasExecutionVariableCmd implements Command<Boolean>, Serializable {
private static final long serialVersionUID = 1L;
protected String executionId;
protected String variableName;
protected boolean isLocal;
public HasExecutionVariableCmd(String executionId, String variableName, boolean isLocal) {
this.executionId = executionId;
this.variableName = variableName;
this.isLocal = isLocal;
}
public Boolean execute(CommandContext commandContext) {
if(executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
if(variableName == null) {
throw new ActivitiIllegalArgumentException("variableName is null");
}
ExecutionEntity execution = commandContext
.getExecutionEntityManager()
.findExecutionById(executionId);
if (execution==null) {
throw new ActivitiObjectNotFoundException("execution "+executionId+" doesn't exist", Execution.class);
}
boolean hasVariable = false;
if (isLocal) {
hasVariable = execution.hasVariableLocal(variableName);
} else {
hasVariable = execution.hasVariable(variableName);
}
return hasVariable;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cmd;
import java.io.Serializable;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.task.Task;
/**
* @author Frederik Heremans
*/
public class HasTaskVariableCmd implements Command<Boolean>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
protected String variableName;
protected boolean isLocal;
public HasTaskVariableCmd(String taskId, String variableName, boolean isLocal) {
this.taskId = taskId;
this.variableName = variableName;
this.isLocal = isLocal;
}
public Boolean execute(CommandContext commandContext) {
if(taskId == null) {
throw new ActivitiIllegalArgumentException("taskId is null");
}
if(variableName == null) {
throw new ActivitiIllegalArgumentException("variableName is null");
}
TaskEntity task = Context
.getCommandContext()
.getTaskEntityManager()
.findTaskById(taskId);
if (task==null) {
throw new ActivitiObjectNotFoundException("task "+taskId+" doesn't exist", Task.class);
}
boolean hasVariable = false;
if (isLocal) {
hasVariable = task.hasVariableLocal(variableName);
} else {
hasVariable = task.hasVariable(variableName);
}
return hasVariable;
}
}
......@@ -34,6 +34,9 @@ public class ResolveTaskCmd extends NeedsActiveTaskCmd<Void> {
}
protected Void execute(CommandContext commandContext, TaskEntity task) {
if (variables != null) {
task.setVariables(variables);
}
task.resolve();
return null;
}
......
......@@ -38,11 +38,11 @@ public class SaveGroupCmd implements Command<Void>, Serializable {
}
if (group.getRevision()==0) {
commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.insertGroup(group);
} else {
commandContext
.getGroupEntityManager()
.getGroupIdentityManager()
.updateGroup(group);
}
......
......@@ -39,11 +39,11 @@ public class SaveUserCmd implements Command<Void>, Serializable {
}
if (user.getRevision()==0) {
commandContext
.getUserEntityManager()
.getUserIdentityManager()
.insertUser(user);
} else {
commandContext
.getUserEntityManager()
.getUserIdentityManager()
.updateUser(user);
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.cmd;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.deploy.DeploymentCache;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.repository.ProcessDefinition;
/**
* @author Joram Barrez
*/
public class SetProcessDefinitionCategoryCmd implements Command<Void> {
protected String processDefinitionId;
protected String category;
public SetProcessDefinitionCategoryCmd(String processDefinitionId, String category) {
this.processDefinitionId = processDefinitionId;
this.category = category;
}
public Void execute(CommandContext commandContext) {
if (processDefinitionId == null) {
throw new ActivitiIllegalArgumentException("Process definition id is null");
}
ProcessDefinitionEntity processDefinition = Context
.getCommandContext()
.getProcessDefinitionEntityManager()
.findProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for id = '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Update category
processDefinition.setCategory(category);
// Remove process definition from cache, it will be refetched later
DeploymentCache<ProcessDefinitionEntity> processDefinitionCache =
Context.getProcessEngineConfiguration().getProcessDefinitionCache();
if (processDefinitionCache != null) {
processDefinitionCache.remove(processDefinitionId);
}
return null;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
}
......@@ -44,7 +44,7 @@ public class SetUserPictureCmd implements Command<Object>, Serializable {
throw new ActivitiIllegalArgumentException("userId is null");
}
UserEntity user = (UserEntity) commandContext
.getUserEntityManager()
.getUserIdentityManager()
.findUserById(userId);
if(user == null) {
throw new ActivitiObjectNotFoundException("user "+userId+" doesn't exist", User.class);
......
......@@ -55,7 +55,7 @@ public class StartProcessInstanceByMessageCmd implements Command<ProcessInstance
.findMessageStartEventSubscriptionByName(messageName);
if(messageEventSubscription == null) {
throw new ActivitiException("Cannot start process instance by message: no subscription to message with name '"+messageName+"' found.");
throw new ActivitiObjectNotFoundException("Cannot start process instance by message: no subscription to message with name '"+messageName+"' found.", MessageEventSubscriptionEntity.class);
}
String processDefinitionId = messageEventSubscription.getConfiguration();
......
......@@ -191,7 +191,7 @@ public class DbSqlSession implements Session {
sqlSession.delete(statement, parameter);
}
public String toString() {
return "bulk delete: "+statement;
return "bulk delete: " + statement + "(" + parameter + ")";
}
}
......@@ -202,6 +202,7 @@ public class DbSqlSession implements Session {
DeletePersistentObjectOperation deletePersistentObjectOperation = (DeletePersistentObjectOperation) deleteOperation;
if (persistentObject.getId().equals(deletePersistentObjectOperation.getPersistentObject().getId())
&& persistentObject.getClass().equals(deletePersistentObjectOperation.getPersistentObject().getClass())) {
log.debug("skipping redundant delete: {}", persistentObject);
return; // Skip this delete. It was already added.
}
}
......@@ -227,16 +228,12 @@ public class DbSqlSession implements Session {
if (deleteStatement == null) {
throw new ActivitiException("no delete statement for " + persistentObject.getClass() + " in the ibatis mapping files");
}
if(log.isDebugEnabled()) {
log.debug("deleting: {}[{}]", persistentObject.getClass().getSimpleName(), persistentObject.getId());
}
// It only makes sense to check for optimistic locking exceptions for objects that actually have a revision
if (persistentObject instanceof HasRevision) {
int nrOfRowsDeleted = sqlSession.delete(deleteStatement, persistentObject);
if (nrOfRowsDeleted == 0) {
throw new ActivitiOptimisticLockingException(DbSqlSession.this.toString(persistentObject) + " was updated by another transaction concurrently");
throw new ActivitiOptimisticLockingException(persistentObject + " was updated by another transaction concurrently");
}
} else {
sqlSession.delete(deleteStatement, persistentObject);
......@@ -252,7 +249,7 @@ public class DbSqlSession implements Session {
}
public String toString() {
return "Delete operation for " + persistentObject.getClass() + " [" + persistentObject.getId() + "]";
return "delete " + persistentObject;
}
}
......@@ -444,14 +441,14 @@ public class DbSqlSession implements Session {
List<PersistentObject> updatedObjects = getUpdatedObjects();
if (log.isDebugEnabled()) {
log.debug("flush summary:");
log.debug("flush summary: {} insert, {} update, {} delete.", insertedObjects.size(), updatedObjects.size(), deleteOperations.size());
for (PersistentObject insertedObject: insertedObjects) {
log.debug(" insert {}", toString(insertedObject));
log.debug(" insert {}", insertedObject);
}
for (PersistentObject updatedObject: updatedObjects) {
log.debug(" update {}", toString(updatedObject));
log.debug(" update {}", updatedObject);
}
for (Object deleteOperation: deleteOperations) {
for (DeleteOperation deleteOperation: deleteOperations) {
log.debug(" {}", deleteOperation);
}
log.debug("now executing flush...");
......@@ -491,9 +488,8 @@ public class DbSqlSession implements Session {
for (DeleteOperation deleteOperation: deletedObjectsCopy) {
if (deleteOperation instanceof DeletePersistentObjectOperation) {
DeletePersistentObjectOperation deletePersistentObjectOperation = (DeletePersistentObjectOperation) deleteOperation;
PersistentObject insertedObject = findInsertedObject(deletePersistentObjectOperation.getPersistentObject().getClass(),
deletePersistentObjectOperation.getPersistentObject().getId());
PersistentObject deletedObject = ((DeletePersistentObjectOperation) deleteOperation).getPersistentObject();
PersistentObject insertedObject = findInsertedObject(deletedObject.getClass(), deletedObject.getId());
// if the deleted object is inserted,
if (insertedObject != null) {
......@@ -503,10 +499,9 @@ public class DbSqlSession implements Session {
}
// in any case, remove the deleted object from the cache
cacheRemove(deletePersistentObjectOperation.getPersistentObject().getClass(),
deletePersistentObjectOperation.getPersistentObject().getId());
cacheRemove(deletedObject.getClass(), deletedObject.getId());
}
}
}
for (PersistentObject insertedObject: insertedObjects) {
......@@ -603,7 +598,7 @@ public class DbSqlSession implements Session {
// }
public <T extends PersistentObject> List<T> pruneDeletedEntities(List<T> listToPrune) {
ArrayList<T> prunedList = new ArrayList<T>(listToPrune);
List<T> prunedList = new ArrayList<T>(listToPrune);
for (T potentiallyDeleted : listToPrune) {
for (DeleteOperation deleteOperation: deleteOperations) {
if (deleteOperation instanceof DeletePersistentObjectOperation) {
......@@ -629,7 +624,7 @@ public class DbSqlSession implements Session {
throw new ActivitiException("no insert statement for "+insertedObject.getClass()+" in the ibatis mapping files");
}
log.debug("inserting: {}", toString(insertedObject));
log.debug("inserting: {}", insertedObject);
sqlSession.insert(insertStatement, insertedObject);
// See http://jira.codehaus.org/browse/ACT-1290
......@@ -647,10 +642,10 @@ public class DbSqlSession implements Session {
if (updateStatement==null) {
throw new ActivitiException("no update statement for "+updatedObject.getClass()+" in the ibatis mapping files");
}
log.debug("updating: ", toString(updatedObject));
log.debug("updating: {}", updatedObject);
int updatedRecords = sqlSession.update(updateStatement, updatedObject);
if (updatedRecords!=1) {
throw new ActivitiOptimisticLockingException(toString(updatedObject)+" was updated by another transaction concurrently");
throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently");
}
// See http://jira.codehaus.org/browse/ACT-1290
......@@ -681,13 +676,6 @@ public class DbSqlSession implements Session {
public void rollback() {
sqlSession.rollback();
}
protected String toString(PersistentObject persistentObject) {
if (persistentObject==null) {
return "null";
}
return persistentObject.getClass().getSimpleName() +"["+persistentObject.getId()+"]";
}
// schema operations ////////////////////////////////////////////////////////
......
......@@ -13,15 +13,15 @@
package org.activiti.engine.impl.db;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.activiti.engine.impl.cfg.IdGenerator;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.apache.ibatis.session.SqlSessionFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Tom Baeyens
......@@ -34,6 +34,7 @@ public class DbSqlSessionFactory implements SessionFactory {
public static final Map<String, String> databaseSpecificLimitAfterStatements = new HashMap<String, String>();
public static final Map<String, String> databaseSpecificLimitBetweenStatements = new HashMap<String, String>();
public static final Map<String, String> databaseSpecificOrderByStatements = new HashMap<String, String>();
public static final Map<String, String> databaseSpecificLimitBeforeNativeQueryStatements = new HashMap<String, String>();
static {
......@@ -91,14 +92,27 @@ public class DbSqlSessionFactory implements SessionFactory {
databaseSpecificLimitAfterStatements.put("db2", ")RES ) SUB WHERE SUB.rnk >= #{firstRow} AND SUB.rnk < #{lastRow}");
databaseSpecificLimitBetweenStatements.put("db2", ", row_number() over (ORDER BY ${orderBy}) rnk FROM ( select distinct RES.* ");
databaseSpecificOrderByStatements.put("db2", "");
databaseSpecificLimitBeforeNativeQueryStatements.put("db2", "SELECT SUB.* FROM ( select RES.* , row_number() over (ORDER BY ${orderBy}) rnk FROM (");
addDatabaseSpecificStatement("db2", "selectExclusiveJobsToExecute", "selectExclusiveJobsToExecute_integerBoolean");
addDatabaseSpecificStatement("db2", "selectExecutionByNativeQuery", "selectExecutionByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("db2", "selectHistoricActivityInstanceByNativeQuery", "selectHistoricActivityInstanceByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("db2", "selectHistoricProcessInstanceByNativeQuery", "selectHistoricProcessInstanceByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("db2", "selectHistoricTaskInstanceByNativeQuery", "selectHistoricTaskInstanceByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("db2", "selectTaskByNativeQuery", "selectTaskByNativeQuery_mssql_or_db2");
// mssql
databaseSpecificLimitBeforeStatements.put("mssql", "SELECT SUB.* FROM (");
databaseSpecificLimitAfterStatements.put("mssql", ")RES ) SUB WHERE SUB.rnk >= #{firstRow} AND SUB.rnk < #{lastRow}");
databaseSpecificLimitBetweenStatements.put("mssql", ", row_number() over (ORDER BY ${orderBy}) rnk FROM ( select distinct RES.* ");
databaseSpecificOrderByStatements.put("mssql", "");
databaseSpecificLimitBeforeNativeQueryStatements.put("mssql", "SELECT SUB.* FROM ( select RES.* , row_number() over (ORDER BY ${orderBy}) rnk FROM (");
addDatabaseSpecificStatement("mssql", "selectExclusiveJobsToExecute", "selectExclusiveJobsToExecute_integerBoolean");
addDatabaseSpecificStatement("mssql", "selectExecutionByNativeQuery", "selectExecutionByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("mssql", "selectHistoricActivityInstanceByNativeQuery", "selectHistoricActivityInstanceByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("mssql", "selectHistoricProcessInstanceByNativeQuery", "selectHistoricProcessInstanceByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("mssql", "selectHistoricTaskInstanceByNativeQuery", "selectHistoricTaskInstanceByNativeQuery_mssql_or_db2");
addDatabaseSpecificStatement("mssql", "selectTaskByNativeQuery", "selectTaskByNativeQuery_mssql_or_db2");
}
protected String databaseType;
......
......@@ -36,7 +36,7 @@ public class IbatisVariableTypeHandler implements TypeHandler<VariableType> {
public VariableType getResult(ResultSet rs, String columnName) throws SQLException {
String typeName = rs.getString(columnName);
VariableType type = getVariableTypes().getVariableType(typeName);
if (type == null) {
if (type == null && typeName != null) {
throw new ActivitiException("unknown variable type name " + typeName);
}
return type;
......
......@@ -31,9 +31,11 @@ import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity;
import org.activiti.engine.impl.persistence.entity.HistoricFormPropertyEntity;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntity;
import org.activiti.engine.impl.pvm.runtime.InterpretableExecution;
......@@ -613,4 +615,23 @@ public class HistoryManager extends AbstractManager {
}
}
}
// Identity link related history
/**
* Record the creation of a new {@link IdentityLink}, if audit history is enabled.
*/
public void recordIdentityLinkCreated(IdentityLinkEntity identityLink) {
// It makes no sense storing historic counterpart for an identity-link that is related
// to a process-definition only as this is never kept in history
if (isHistoryLevelAtLeast(HistoryLevel.AUDIT) && (identityLink.getProcessInstanceId() != null || identityLink.getTaskId() != null)) {
HistoricIdentityLinkEntity historicIdentityLinkEntity = new HistoricIdentityLinkEntity(identityLink);
getDbSqlSession().insert(historicIdentityLinkEntity);
}
}
public void deleteHistoricIdentityLink(String id) {
if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
getHistoricIdentityLinkEntityManager().deleteHistoricIdentityLink(id);
}
}
}
......@@ -32,23 +32,24 @@ import org.activiti.engine.impl.persistence.entity.CommentEntityManager;
import org.activiti.engine.impl.persistence.entity.DeploymentEntityManager;
import org.activiti.engine.impl.persistence.entity.EventSubscriptionEntityManager;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupIdentityManager;
import org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricDetailEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntityManager;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntityManager;
import org.activiti.engine.impl.persistence.entity.JobEntityManager;
import org.activiti.engine.impl.persistence.entity.MembershipEntityManager;
import org.activiti.engine.impl.persistence.entity.MembershipIdentityManager;
import org.activiti.engine.impl.persistence.entity.ModelEntityManager;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager;
import org.activiti.engine.impl.persistence.entity.PropertyEntityManager;
import org.activiti.engine.impl.persistence.entity.ResourceEntityManager;
import org.activiti.engine.impl.persistence.entity.TableDataManager;
import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.activiti.engine.impl.persistence.entity.UserIdentityManager;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityManager;
import org.activiti.engine.impl.pvm.runtime.AtomicOperation;
import org.activiti.engine.impl.pvm.runtime.InterpretableExecution;
......@@ -133,9 +134,9 @@ public class CommandContext {
log.info("Error while closing command context", exception);
} else if (exception instanceof ActivitiOptimisticLockingException) {
// reduce log level, as normally we're not interested in logging this exception
log.debug("Optimistic locking exception : " + exception);
}else {
log.error("Error while closing command context", exception);
log.debug("Optimistic locking exception : " + exception);
} else {
log.debug("Error while closing command context", exception);
}
transactionContext.rollback();
......@@ -262,24 +263,28 @@ public class CommandContext {
return getSession(HistoricTaskInstanceEntityManager.class);
}
public HistoricIdentityLinkEntityManager getHistoricIdentityLinkEntityManager() {
return getSession(HistoricIdentityLinkEntityManager.class);
}
public JobEntityManager getJobEntityManager() {
return getSession(JobEntityManager.class);
}
public UserEntityManager getUserEntityManager() {
return getSession(UserEntityManager.class);
public UserIdentityManager getUserIdentityManager() {
return getSession(UserIdentityManager.class);
}
public GroupEntityManager getGroupEntityManager() {
return getSession(GroupEntityManager.class);
public GroupIdentityManager getGroupIdentityManager() {
return getSession(GroupIdentityManager.class);
}
public IdentityInfoEntityManager getIdentityInfoEntityManager() {
return getSession(IdentityInfoEntityManager.class);
}
public MembershipEntityManager getMembershipEntityManager() {
return getSession(MembershipEntityManager.class);
public MembershipIdentityManager getMembershipIdentityManager() {
return getSession(MembershipIdentityManager.class);
}
public AttachmentEntityManager getAttachmentEntityManager() {
......
......@@ -24,6 +24,9 @@ import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.util.Properties;
import org.activiti.engine.ActivitiClassLoadingException;
import org.activiti.engine.impl.util.ReflectUtil;
/**
* Parses a String into a {@link ValueExpression} or {@link MethodExpression} instance for later
* evaluation. Classes that implement the EL expression language expose their functionality via this
......@@ -117,7 +120,7 @@ public abstract class ExpressionFactory {
String className = null;
String serviceId = "META-INF/services/" + ExpressionFactory.class.getName();
InputStream input = classLoader.getResourceAsStream(serviceId);
InputStream input = ReflectUtil.getResourceAsStream(serviceId);
try {
if (input != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
......@@ -180,7 +183,7 @@ public abstract class ExpressionFactory {
className = "org.activiti.engine.impl.juel.ExpressionFactoryImpl";
}
return newInstance(properties, className, classLoader);
return newInstance(properties, className);
}
/**
......@@ -198,14 +201,14 @@ public abstract class ExpressionFactory {
* if the class could not be found or if it is not a subclass of ExpressionFactory
* or if the class could not be instantiated.
*/
private static ExpressionFactory newInstance(Properties properties, String className, ClassLoader classLoader) {
private static ExpressionFactory newInstance(Properties properties, String className) {
Class<?> clazz = null;
try {
clazz = classLoader.loadClass(className.trim());
clazz = ReflectUtil.loadClass(className.trim());
if (!ExpressionFactory.class.isAssignableFrom(clazz)) {
throw new ELException("Invalid expression factory class: " + clazz.getName());
}
} catch (ClassNotFoundException e) {
} catch (ActivitiClassLoadingException e) {
throw new ELException("Could not find expression factory class", e);
}
try {
......
......@@ -138,6 +138,7 @@ public class TimerDeclarationImpl implements Serializable {
timer.setDuedate(duedate);
if (executionEntity != null) {
timer.setExecution(executionEntity);
timer.setProcessDefinitionId(executionEntity.getProcessDefinitionId());
}
if (type == TimerDeclarationType.CYCLE) {
......
......@@ -22,20 +22,21 @@ import org.activiti.engine.impl.persistence.entity.AttachmentEntityManager;
import org.activiti.engine.impl.persistence.entity.ByteArrayEntityManager;
import org.activiti.engine.impl.persistence.entity.DeploymentEntityManager;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupIdentityManager;
import org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricDetailEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntityManager;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntityManager;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntityManager;
import org.activiti.engine.impl.persistence.entity.MembershipEntityManager;
import org.activiti.engine.impl.persistence.entity.MembershipIdentityManager;
import org.activiti.engine.impl.persistence.entity.ModelEntityManager;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager;
import org.activiti.engine.impl.persistence.entity.ResourceEntityManager;
import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.activiti.engine.impl.persistence.entity.UserIdentityManager;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityManager;
......@@ -117,20 +118,24 @@ public abstract class AbstractManager implements Session {
return getSession(HistoricTaskInstanceEntityManager.class);
}
protected UserEntityManager getUserManager() {
return getSession(UserEntityManager.class);
protected HistoricIdentityLinkEntityManager getHistoricIdentityLinkEntityManager() {
return getSession(HistoricIdentityLinkEntityManager.class);
}
protected UserIdentityManager getUserIdentityManager() {
return getSession(UserIdentityManager.class);
}
protected GroupEntityManager getGroupManager() {
return getSession(GroupEntityManager.class);
protected GroupIdentityManager getGroupIdentityManager() {
return getSession(GroupIdentityManager.class);
}
protected IdentityInfoEntityManager getIdentityInfoManager() {
return getSession(IdentityInfoEntityManager.class);
}
protected MembershipEntityManager getMembershipManager() {
return getSession(MembershipEntityManager.class);
protected MembershipIdentityManager getMembershipIdentityManager() {
return getSession(MembershipIdentityManager.class);
}
protected AttachmentEntityManager getAttachmentManager() {
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupIdentityManager;
/**
* @author Joram Barrez
*/
public class GroupEntityManagerFactory implements SessionFactory {
public Class< ? > getSessionType() {
return GroupIdentityManager.class;
}
public Session openSession() {
return new GroupEntityManager();
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.MembershipEntityManager;
import org.activiti.engine.impl.persistence.entity.MembershipIdentityManager;
/**
* @author Joram Barrez
*/
public class MembershipEntityManagerFactory implements SessionFactory {
public Class< ? > getSessionType() {
return MembershipIdentityManager.class;
}
public Session openSession() {
return new MembershipEntityManager();
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.activiti.engine.impl.persistence.entity.UserIdentityManager;
/**
* @author Joram Barrez
*/
public class UserEntityManagerFactory implements SessionFactory {
public Class< ? > getSessionType() {
return UserIdentityManager.class;
}
public Session openSession() {
return new UserEntityManager();
}
}
......@@ -84,6 +84,11 @@ public class ByteArrayEntity implements Serializable, PersistentObject, HasRevis
this.revision = revision;
}
@Override
public String toString() {
return "ByteArrayEntity[id=" + id + ", name=" + name + ", size=" + (bytes != null ? bytes.length : 0) + "]";
}
// Wrapper for a byte array, needed to do byte array comparisons
// See http://jira.codehaus.org/browse/ACT-1524
public static class ByteArray {
......
......@@ -60,6 +60,14 @@ public class CommentEntityManager extends AbstractManager {
return getDbSqlSession().selectList("selectCommentsByProcessInstanceId", processInstanceId);
}
public Comment findComment(String commentId) {
return getDbSqlSession().selectById(CommentEntity.class, commentId);
}
public Event findEvent(String commentId) {
return getDbSqlSession().selectById(CommentEntity.class, commentId);
}
protected void checkHistoryEnabled() {
if(!getHistoryManager().isHistoryEnabled()) {
throw new ActivitiException("In order to use comments, history should be enabled");
......
......@@ -13,8 +13,6 @@
package org.activiti.engine.impl.persistence.entity;
import java.util.List;
import org.activiti.engine.impl.DeploymentQueryImpl;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.ProcessDefinitionQueryImpl;
......@@ -27,6 +25,9 @@ import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.Job;
import java.util.List;
import java.util.Map;
/**
* @author Tom Baeyens
......@@ -155,6 +156,15 @@ public class DeploymentEntityManager extends AbstractManager {
return getDbSqlSession().getSqlSession().selectList("selectResourceNamesByDeploymentId", deploymentId);
}
@SuppressWarnings("unchecked")
public List<Deployment> findDeploymentsByNativeQuery(Map<String, Object> parameterMap, int firstResult, int maxResults) {
return getDbSqlSession().selectListWithRawParameter("selectDeploymentByNativeQuery", parameterMap, firstResult, maxResults);
}
public long findDeploymentCountByNativeQuery(Map<String, Object> parameterMap) {
return (Long) getDbSqlSession().selectOne("selectDeploymentCountByNativeQuery", parameterMap);
}
public void close() {
}
......
......@@ -1198,11 +1198,12 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
}
public IdentityLinkEntity addIdentityLink(String userId, String type) {
IdentityLinkEntity identityLinkEntity = IdentityLinkEntity.createAndInsert();
IdentityLinkEntity identityLinkEntity = new IdentityLinkEntity();
getIdentityLinks().add(identityLinkEntity);
identityLinkEntity.setProcessInstance(this);
identityLinkEntity.setUserId(userId);
identityLinkEntity.setType(type);
identityLinkEntity.insert();
return identityLinkEntity;
}
......
......@@ -13,10 +13,6 @@
package org.activiti.engine.impl.persistence.entity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.impl.GroupQueryImpl;
......@@ -27,13 +23,17 @@ import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.AbstractManager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Tom Baeyens
* @author Saeid Mirzaei
* @author Joram Barrez
*/
public class GroupEntityManager extends AbstractManager {
public class GroupEntityManager extends AbstractManager implements GroupIdentityManager {
public Group createNewGroup(String groupId) {
return new GroupEntity(groupId);
......@@ -68,21 +68,18 @@ public class GroupEntityManager extends AbstractManager {
return (Long) getDbSqlSession().selectOne("selectGroupCountByQueryCriteria", query);
}
public GroupEntity findGroupById(String groupId) {
return (GroupEntity) getDbSqlSession().selectOne("selectGroupById", groupId);
}
@SuppressWarnings("unchecked")
public List<Group> findGroupsByUser(String userId) {
return getDbSqlSession().selectList("selectGroupsByUserId", userId);
}
@SuppressWarnings("unchecked")
public List<Group> findPotentialStarterUsers(String proceDefId) {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("procDefId", proceDefId);
return (List<Group>) getDbSqlSession().selectOne("selectGroupByQueryCriteria", parameters);
public List<Group> findGroupsByNativeQuery(Map<String, Object> parameterMap, int firstResult, int maxResults) {
return getDbSqlSession().selectListWithRawParameter("selectGroupByNativeQuery", parameterMap, firstResult, maxResults);
}
public long findGroupCountByNativeQuery(Map<String, Object> parameterMap) {
return (Long) getDbSqlSession().selectOne("selectGroupCountByNativeQuery", parameterMap);
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence.entity;
import java.util.List;
import java.util.Map;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.impl.GroupQueryImpl;
import org.activiti.engine.impl.Page;
/**
* @author Joram Barrez
*/
public interface GroupIdentityManager {
Group createNewGroup(String groupId);
void insertGroup(Group group);
void updateGroup(GroupEntity updatedGroup);
void deleteGroup(String groupId);
GroupQuery createNewGroupQuery();
List<Group> findGroupByQueryCriteria(GroupQueryImpl query, Page page);
long findGroupCountByQueryCriteria(GroupQueryImpl query);
List<Group> findGroupsByUser(String userId);
List<Group> findGroupsByNativeQuery(Map<String, Object> parameterMap, int firstResult, int maxResults);
long findGroupCountByNativeQuery(Map<String, Object> parameterMap);
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.history.HistoricIdentityLink;
import org.activiti.engine.impl.db.PersistentObject;
/**
* @author Frederik Heremans
*/
public class HistoricIdentityLinkEntity implements Serializable, HistoricIdentityLink, PersistentObject {
private static final long serialVersionUID = 1L;
protected String id;
protected String type;
protected String userId;
protected String groupId;
protected String taskId;
protected String processInstanceId;
public HistoricIdentityLinkEntity(IdentityLinkEntity identityLink) {
this.id = identityLink.getId();
this.groupId = identityLink.getGroupId();
this.processInstanceId = identityLink.getProcessInstanceId();
this.taskId = identityLink.getTaskId();
this.type = identityLink.getType();
this.userId = identityLink.getUserId();
}
public HistoricIdentityLinkEntity() {
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("id", this.id);
persistentState.put("type", this.type);
if (this.userId != null) {
persistentState.put("userId", this.userId);
}
if (this.groupId != null) {
persistentState.put("groupId", this.groupId);
}
if (this.taskId != null) {
persistentState.put("taskId", this.taskId);
}
if (this.processInstanceId != null) {
persistentState.put("processInstanceId", this.processInstanceId);
}
return persistentState;
}
public boolean isUser() {
return userId != null;
}
public boolean isGroup() {
return groupId != null;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
if (this.groupId != null && userId != null) {
throw new ActivitiException("Cannot assign a userId to a task assignment that already has a groupId");
}
this.userId = userId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
if (this.userId != null && groupId != null) {
throw new ActivitiException("Cannot assign a groupId to a task assignment that already has a userId");
}
this.groupId = groupId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence.entity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.AbstractManager;
/**
* @author Frederik Heremans
*/
public class HistoricIdentityLinkEntityManager extends AbstractManager {
public void deleteHistoricIdentityLink(HistoricIdentityLinkEntity identityLink) {
getDbSqlSession().delete(identityLink);
}
public void deleteHistoricIdentityLink(String id) {
getDbSqlSession().delete("deleteHistoricIdentityLink", id);
}
@SuppressWarnings("unchecked")
public List<HistoricIdentityLinkEntity> findHistoricIdentityLinksByTaskId(String taskId) {
return getDbSqlSession().selectList("selectHistoricIdentityLinksByTask", taskId);
}
@SuppressWarnings("unchecked")
public List<HistoricIdentityLinkEntity> findHistoricIdentityLinksByProcessInstanceId(String processInstanceId) {
return getDbSqlSession().selectList("selectHistoricIdentityLinksByProcessInstance", processInstanceId);
}
@SuppressWarnings("unchecked")
public List<HistoricIdentityLinkEntity> findHistoricIdentityLinksByProcessDefinitionId(String processDefinitionId) {
return getDbSqlSession().selectList("selectHistoricIdentityLinksByProcessDefinition", processDefinitionId);
}
@SuppressWarnings("unchecked")
public List<HistoricIdentityLinkEntity> findHistoricIdentityLinks() {
return getDbSqlSession().selectList("selectHistoricIdentityLinks");
}
@SuppressWarnings("unchecked")
public List<HistoricIdentityLinkEntity> findHistoricIdentityLinkByTaskUserGroupAndType(String taskId, String userId, String groupId, String type) {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("taskId", taskId);
parameters.put("userId", userId);
parameters.put("groupId", groupId);
parameters.put("type", type);
return getDbSqlSession().selectList("selectHistoricIdentityLinkByTaskUserGroupAndType", parameters);
}
@SuppressWarnings("unchecked")
public List<HistoricIdentityLinkEntity> findHistoricIdentityLinkByProcessDefinitionUserAndGroup(String processDefinitionId, String userId, String groupId) {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("processDefinitionId", processDefinitionId);
parameters.put("userId", userId);
parameters.put("groupId", groupId);
return getDbSqlSession().selectList("selectHistoricIdentityLinkByProcessDefinitionUserAndGroup", parameters);
}
public void deleteHistoricIdentityLinksByTaskId(String taskId) {
List<HistoricIdentityLinkEntity> identityLinks = findHistoricIdentityLinksByTaskId(taskId);
for (HistoricIdentityLinkEntity identityLink: identityLinks) {
deleteHistoricIdentityLink(identityLink);
}
}
public void deleteHistoricIdentityLinksByProcInstance(String processInstanceId) {
// Identity links from db
List<HistoricIdentityLinkEntity> identityLinks = findHistoricIdentityLinksByProcessInstanceId(processInstanceId);
// Delete
for (HistoricIdentityLinkEntity identityLink: identityLinks) {
deleteHistoricIdentityLink(identityLink);
}
// Identity links from cache
List<HistoricIdentityLinkEntity> identityLinksFromCache = Context.getCommandContext().getDbSqlSession().findInCache(HistoricIdentityLinkEntity.class);
for (HistoricIdentityLinkEntity identityLinkEntity : identityLinksFromCache) {
if (processInstanceId.equals(identityLinkEntity.getProcessInstanceId())) {
deleteHistoricIdentityLink(identityLinkEntity);
}
}
}
public void deleteHistoricIdentityLinksByProcDef(String processDefId) {
getDbSqlSession().delete("deleteHistoricIdentityLinkByProcDef", processDefId);
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册