summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntje Fuhrmann2013-01-25 08:06:18 (EST)
committerSven Rottstock2013-01-25 08:06:18 (EST)
commit2cb705e4ca3a975859a5c8702b3296fdee48c95d (patch)
tree091bc196937f5fe29f538bbd89b1e86a3d065b0b
parent79ff7b326064e08ef0283b50456d08fca192ce0f (diff)
downloadorg.eclipse.stardust.engine-2cb705e4ca3a975859a5c8702b3296fdee48c95d.zip
org.eclipse.stardust.engine-2cb705e4ca3a975859a5c8702b3296fdee48c95d.tar.gz
org.eclipse.stardust.engine-2cb705e4ca3a975859a5c8702b3296fdee48c95d.tar.bz2
Jira-ID: CRNT-27308
ActivityInstanceQuery with ExcludeUserPolicy.EXCLUDE_USER applied does perform many extra SQL fetches for ProcessInstances and DataValues if fetched AI have ExcludeUser-OnAssignement actions modeled git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/engine@62383 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/DataPrefetchHint.java23
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/InlinedDataFilterSqlBuilder.java4
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/extensions/data/DefaultDataFilterExtension.java1
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/persistence/jdbc/ManagedResultSet.java13
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java137
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/ActivityInstanceAuthorization2Predicate.java30
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/WorkItemAuthorization2Predicate.java23
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/struct/spi/StructuredDataFilterExtension.java1
8 files changed, 186 insertions, 46 deletions
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/DataPrefetchHint.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/DataPrefetchHint.java
index 98e1898..08878f3 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/DataPrefetchHint.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/DataPrefetchHint.java
@@ -10,9 +10,15 @@
*******************************************************************************/
package org.eclipse.stardust.engine.api.query;
+import java.util.List;
+
+import org.eclipse.stardust.engine.core.persistence.FieldRef;
+import org.eclipse.stardust.engine.core.runtime.beans.DataValueBean;
+
public class DataPrefetchHint extends AbstractDataFilter
{
private static final long serialVersionUID = 1L;
+ private String prefetchNumberValueColumnName;
public DataPrefetchHint(String dataId)
{
@@ -76,4 +82,21 @@ public class DataPrefetchHint extends AbstractDataFilter
return false;
return true;
}
+
+ public void setPrefetchSelectExtension(List<FieldRef> prefetchSelectExtension)
+ {
+ for (FieldRef fieldRef : prefetchSelectExtension)
+ {
+ String columnName = fieldRef.toString();
+ if (columnName.contains(DataValueBean.FIELD__NUMBER_VALUE))
+ {
+ prefetchNumberValueColumnName = columnName;
+ }
+ }
+ }
+
+ public String getPrefetchNumberValueColumnName()
+ {
+ return prefetchNumberValueColumnName;
+ }
}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/InlinedDataFilterSqlBuilder.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/InlinedDataFilterSqlBuilder.java
index 02d2c9b..e6d62de 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/InlinedDataFilterSqlBuilder.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/api/query/InlinedDataFilterSqlBuilder.java
@@ -131,7 +131,9 @@ public class InlinedDataFilterSqlBuilder extends SqlBuilderBase
if (isPrefetchHint)
{
final List<FieldRef> selectExtension = context.getSelectExtension();
- selectExtension.addAll(dataFilterExtension.getPrefetchSelectExtension(dvJoin));
+ List<FieldRef> prefetchSelectExtension = dataFilterExtension.getPrefetchSelectExtension(dvJoin);
+ selectExtension.addAll(prefetchSelectExtension);
+ ((DataPrefetchHint) filter).setPrefetchSelectExtension(prefetchSelectExtension);
return NOTHING;
}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/extensions/data/DefaultDataFilterExtension.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/extensions/data/DefaultDataFilterExtension.java
index 9585553..7fa3205 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/extensions/data/DefaultDataFilterExtension.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/extensions/data/DefaultDataFilterExtension.java
@@ -142,6 +142,7 @@ public class DefaultDataFilterExtension implements DataFilterExtension
cols.add(descriptor.fieldRef(DataValueBean.FIELD__TYPE_KEY));
cols.add(descriptor.fieldRef(DataValueBean.FIELD__STRING_VALUE));
+ cols.add(descriptor.fieldRef(DataValueBean.FIELD__NUMBER_VALUE));
return cols;
}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/persistence/jdbc/ManagedResultSet.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/persistence/jdbc/ManagedResultSet.java
index f08f306..418bbf2 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/persistence/jdbc/ManagedResultSet.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/persistence/jdbc/ManagedResultSet.java
@@ -11,6 +11,7 @@
package org.eclipse.stardust.engine.core.persistence.jdbc;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.ResultSet;
@@ -56,6 +57,18 @@ public final class ManagedResultSet
{
return method.invoke(resultSet, args);
}
+ catch (InvocationTargetException e)
+ {
+ Throwable targetException = e.getTargetException();
+ if (targetException != null)
+ {
+ throw targetException;
+ }
+ else
+ {
+ throw e;
+ }
+ }
finally
{
if (method.equals(closeMethod))
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java
index a242d86..77c58f8 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/AbstractAuthorization2Predicate.java
@@ -14,7 +14,13 @@ import static org.eclipse.stardust.engine.core.runtime.beans.removethis.KernelTw
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.Pair;
@@ -23,17 +29,46 @@ import org.eclipse.stardust.common.error.AccessForbiddenException;
import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
import org.eclipse.stardust.common.reflect.Reflect;
-import org.eclipse.stardust.engine.api.model.*;
-import org.eclipse.stardust.engine.api.query.*;
+import org.eclipse.stardust.engine.api.model.EventType;
+import org.eclipse.stardust.engine.api.model.IActivity;
+import org.eclipse.stardust.engine.api.model.IData;
+import org.eclipse.stardust.engine.api.model.IEventAction;
+import org.eclipse.stardust.engine.api.model.IEventConditionType;
+import org.eclipse.stardust.engine.api.model.IEventHandler;
+import org.eclipse.stardust.engine.api.model.IModel;
+import org.eclipse.stardust.engine.api.model.IOrganization;
+import org.eclipse.stardust.engine.api.model.IProcessDefinition;
+import org.eclipse.stardust.engine.api.model.PluggableType;
+import org.eclipse.stardust.engine.api.model.PredefinedConstants;
+import org.eclipse.stardust.engine.api.query.ActivityInstanceQuery;
+import org.eclipse.stardust.engine.api.query.ActivityInstanceQueryEvaluator;
+import org.eclipse.stardust.engine.api.query.DataPrefetchHint;
+import org.eclipse.stardust.engine.api.query.EvaluationContext;
+import org.eclipse.stardust.engine.api.query.ExcludeUserPolicy;
+import org.eclipse.stardust.engine.api.query.FilterAndTerm;
+import org.eclipse.stardust.engine.api.query.Query;
+import org.eclipse.stardust.engine.api.query.QueryServiceUtils;
+import org.eclipse.stardust.engine.api.query.RuntimeInstanceQueryEvaluator;
import org.eclipse.stardust.engine.api.query.SqlBuilder.ParsedQuery;
import org.eclipse.stardust.engine.api.runtime.BpmRuntimeError;
import org.eclipse.stardust.engine.api.runtime.UserPK;
import org.eclipse.stardust.engine.core.model.utils.ModelUtils;
-import org.eclipse.stardust.engine.core.persistence.*;
+import org.eclipse.stardust.engine.core.persistence.AndTerm;
+import org.eclipse.stardust.engine.core.persistence.Column;
+import org.eclipse.stardust.engine.core.persistence.ComparisonTerm;
+import org.eclipse.stardust.engine.core.persistence.FetchPredicate;
+import org.eclipse.stardust.engine.core.persistence.FieldRef;
+import org.eclipse.stardust.engine.core.persistence.Join;
+import org.eclipse.stardust.engine.core.persistence.JoinElement;
+import org.eclipse.stardust.engine.core.persistence.MultiPartPredicateTerm;
import org.eclipse.stardust.engine.core.persistence.Operator.Binary;
import org.eclipse.stardust.engine.core.persistence.Operator.Ternary;
import org.eclipse.stardust.engine.core.persistence.Operator.Unary;
+import org.eclipse.stardust.engine.core.persistence.OrTerm;
+import org.eclipse.stardust.engine.core.persistence.PredicateTerm;
+import org.eclipse.stardust.engine.core.persistence.QueryDescriptor;
import org.eclipse.stardust.engine.core.persistence.jdbc.ITableDescriptor;
+import org.eclipse.stardust.engine.core.runtime.beans.ActivityInstanceBean;
import org.eclipse.stardust.engine.core.runtime.beans.BigData;
import org.eclipse.stardust.engine.core.runtime.beans.IDataValue;
import org.eclipse.stardust.engine.core.runtime.beans.IProcessInstance;
@@ -70,6 +105,8 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
private ModelManager modelManager;
+ Map<String, DataPrefetchHint> dataPrefetchHintFilter = Collections.EMPTY_MAP;
+
public AbstractAuthorization2Predicate(AuthorizationContext context)
{
this.context = context;
@@ -132,6 +169,7 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
{
Set<Pair<String, String>> distinctData = CollectionUtils.newHashSet();
this.orderedPrefetchData = CollectionUtils.newArrayList();
+ this.dataPrefetchHintFilter = CollectionUtils.newMap();
FilterAndTerm queryFilter = query.getFilter();
if(query instanceof ActivityInstanceQuery)
@@ -496,6 +534,7 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
if (!queryFilter.getParts().contains(filter))
{
queryFilter.and(filter);
+ dataPrefetchHintFilter.put(dataId, filter);
}
}
}
@@ -537,13 +576,14 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
return false;
}
- public boolean isExcludedUser(long activityRtOid, long processInstanceOID, long modelOid)
+ public boolean isExcludedUser(long activityRtOid, long processInstanceOID, long modelOid, Map<String, Long> dataValueOids)
{
if(processInstanceOID == 0)
{
return false;
}
+ long dataValueOid = 0;
IUser currentUser = SecurityProperties.getUser();
long currentPerformer = currentUser.getOID();
@@ -561,62 +601,83 @@ public abstract class AbstractAuthorization2Predicate implements Authorization2P
{
IEventAction action = (IEventAction) l.next();
PluggableType type = action.getType();
- String instanceName = type.getStringAttribute(PredefinedConstants.ACTION_CLASS_ATT);
+ String instanceName = type
+ .getStringAttribute(PredefinedConstants.ACTION_CLASS_ATT);
String excludeUserAction = PredefinedConstants.EXCLUDE_USER_ACTION_CLASS;
- Class classFromClassName = Reflect.getClassFromClassName(excludeUserAction, false);
- if(classFromClassName != null)
+ Class classFromClassName = Reflect.getClassFromClassName(
+ excludeUserAction, false);
+ if (classFromClassName != null)
{
excludeUserAction = classFromClassName.getName();
}
-
+
if (instanceName.equals(excludeUserAction))
{
- IProcessDefinition processDefinition = activity.getProcessDefinition();
- IProcessInstance processInstance = ProcessInstanceBean.findByOID(processInstanceOID);
-
Map<String, Object> attributes = action.getAllAttributes();
- String dataId = (String) attributes.get(PredefinedConstants.EXCLUDED_PERFORMER_DATA);
+ String dataId = (String) attributes
+ .get(PredefinedConstants.EXCLUDED_PERFORMER_DATA);
String dataPath = (String) attributes
.get(PredefinedConstants.EXCLUDED_PERFORMER_DATAPATH);
- IData data = ModelUtils.getData(processDefinition, dataId);
- IDataValue dataValue = processInstance.getDataValue(data);
-
- Object value = dataValue.getValue();
- if(!StringUtils.isEmpty(dataPath))
+ IData data = ModelUtils.getData(activity.getProcessDefinition(),
+ dataId);
+ if (dataValueOids.containsKey(dataId))
{
- ExtendedAccessPathEvaluator evaluator = SpiUtils
- .createExtendedAccessPathEvaluator(data, dataPath);
- AccessPathEvaluationContext evaluationContext = new AccessPathEvaluationContext(
- processInstance, null, null, null);
- value = evaluator.evaluate(data, dataValue.getValue(), dataPath, evaluationContext);
+ dataValueOid = dataValueOids.get(dataId);
}
-
- Long longValue = null;
- if(value instanceof Long)
+ else if (PredefinedConstants.LAST_ACTIVITY_PERFORMER.equals(data.getId()))
{
- longValue = (Long) value;
+ IUser lastActivityPerformer = ActivityInstanceBean
+ .getLastActivityPerformer(processInstanceOID);
+ Object value = lastActivityPerformer != null
+ ? lastActivityPerformer.getPrimaryKey()
+ : null;
+ if (value instanceof UserPK)
+ {
+ try
+ {
+ dataValueOid = Long.parseLong(value.toString());
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
}
- else if(value instanceof UserPK)
+ if (!StringUtils.isEmpty(dataPath))
{
- try
+ IProcessInstance processInstance = ProcessInstanceBean
+ .findByOID(processInstanceOID);
+ IDataValue dataValue = processInstance.getDataValue(data);
+ ExtendedAccessPathEvaluator evaluator = SpiUtils
+ .createExtendedAccessPathEvaluator(data, dataPath);
+ AccessPathEvaluationContext evaluationContext = new AccessPathEvaluationContext(
+ processInstance, null, null, null);
+ Object value = evaluator.evaluate(data, dataValue.getValue(),
+ dataPath, evaluationContext);
+ if (value instanceof Long)
{
- longValue = Long.parseLong(value.toString());
+ dataValueOid = (Long) value;
}
- catch (NumberFormatException e)
+ else if (value instanceof UserPK)
{
- }
+ try
+ {
+ dataValueOid = Long.parseLong(value.toString());
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
}
-
- if(longValue != null && currentPerformer == longValue)
+
+ if (currentPerformer == dataValueOid)
{
return true;
- }
+ }
}
}
}
}
}
-
- return false;
- }
+ return false;
+ }
} \ No newline at end of file
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/ActivityInstanceAuthorization2Predicate.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/ActivityInstanceAuthorization2Predicate.java
index 2cea138..27c9c68 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/ActivityInstanceAuthorization2Predicate.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/ActivityInstanceAuthorization2Predicate.java
@@ -12,9 +12,12 @@ package org.eclipse.stardust.engine.core.runtime.utils;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
+import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
+import org.eclipse.stardust.engine.api.query.DataPrefetchHint;
import org.eclipse.stardust.engine.api.query.ExcludeUserPolicy;
import org.eclipse.stardust.engine.api.query.Query;
import org.eclipse.stardust.engine.core.persistence.FieldRef;
@@ -82,10 +85,31 @@ public class ActivityInstanceAuthorization2Predicate extends AbstractAuthorizati
long processInstanceOid = rs.getLong(ActivityInstanceBean.FIELD__PROCESS_INSTANCE);
long departmentOid = rs.getLong(ActivityInstanceBean.FIELD__CURRENT_DEPARTMENT);
- if(excludeUserPolicy && isExcludedUser(activityRtOid, processInstanceOid, modelOid))
+ if (excludeUserPolicy)
{
- return false;
- }
+ Map<String, Long> dataValueOids = CollectionUtils.newMap();
+ try
+ {
+ for (String dataId : dataPrefetchHintFilter.keySet())
+ {
+ DataPrefetchHint dataPrefetchHint = dataPrefetchHintFilter
+ .get(dataId);
+ String columnName = dataPrefetchHint
+ .getPrefetchNumberValueColumnName();
+ long dataValueOid = rs.getLong(columnName);
+ dataValueOids.put(dataId, dataValueOid);
+ }
+ }
+ catch (SQLException x)
+ {
+ // leave it to 0 if column cannot be found
+ }
+ if (isExcludedUser(activityRtOid, processInstanceOid, modelOid,
+ dataValueOids))
+ {
+ return false;
+ }
+ }
context.setActivityData(processInstanceOid, activityRtOid, modelOid, currentPerformer,
currentUserPerformer, departmentOid);
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/WorkItemAuthorization2Predicate.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/WorkItemAuthorization2Predicate.java
index 868d225..75d4c29 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/WorkItemAuthorization2Predicate.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/utils/WorkItemAuthorization2Predicate.java
@@ -12,9 +12,12 @@ package org.eclipse.stardust.engine.core.runtime.utils;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
+import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
+import org.eclipse.stardust.engine.api.query.DataPrefetchHint;
import org.eclipse.stardust.engine.api.query.FilterAndTerm;
import org.eclipse.stardust.engine.api.query.Query;
import org.eclipse.stardust.engine.api.runtime.PerformerType;
@@ -33,7 +36,7 @@ import org.eclipse.stardust.engine.core.runtime.beans.WorkItemBean;
public class WorkItemAuthorization2Predicate extends AbstractAuthorization2Predicate
{
private static final Logger trace = LogManager.getLogger(WorkItemAuthorization2Predicate.class);
-
+
public boolean addPrefetchDataHints(Query query)
{
boolean returnValue = super.addPrefetchDataHints(query);
@@ -81,16 +84,27 @@ public class WorkItemAuthorization2Predicate extends AbstractAuthorization2Predi
int performerKind = rs.getInt(WorkItemBean.FIELD__PERFORMER_KIND);
long performer = rs.getLong(WorkItemBean.FIELD__PERFORMER);
+ Map<String, Long> dataValueOids = CollectionUtils.newMap();
long scopeProcessInstanceOid = 0;
try
{
- scopeProcessInstanceOid = rs.getLong(WorkItemBean.FIELD__SCOPE_PROCESS_INSTANCE);
+ scopeProcessInstanceOid = rs
+ .getLong(WorkItemBean.FIELD__SCOPE_PROCESS_INSTANCE);
+ for (String dataId : dataPrefetchHintFilter.keySet())
+ {
+ DataPrefetchHint dataPrefetchHint = dataPrefetchHintFilter
+ .get(dataId);
+ String columnName = dataPrefetchHint
+ .getPrefetchNumberValueColumnName();
+ long dataValueOid = rs.getLong(columnName);
+ dataValueOids.put(dataId, dataValueOid);
+ }
}
catch (SQLException x)
{
// leave it to 0 if column cannot be found
}
-
+
long departmentOid = rs.getLong(WorkItemBean.FIELD__DEPARTMENT);
long currentUserPerformer;
@@ -118,7 +132,8 @@ public class WorkItemAuthorization2Predicate extends AbstractAuthorization2Predi
return false;
}
- if(isExcludedUser(activityRtOid, scopeProcessInstanceOid, modelOid))
+ if (isExcludedUser(activityRtOid, scopeProcessInstanceOid, modelOid,
+ dataValueOids))
{
return false;
}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/struct/spi/StructuredDataFilterExtension.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/struct/spi/StructuredDataFilterExtension.java
index 16db49c..d4e2cec 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/struct/spi/StructuredDataFilterExtension.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/struct/spi/StructuredDataFilterExtension.java
@@ -666,6 +666,7 @@ public class StructuredDataFilterExtension implements DataFilterExtension, State
cols.add(descriptor.fieldRef(StructuredDataValueBean.FIELD__TYPE_KEY));
cols.add(descriptor.fieldRef(StructuredDataValueBean.FIELD__STRING_VALUE));
+ cols.add(descriptor.fieldRef(StructuredDataValueBean.FIELD__NUMBER_VALUE));
return cols;
}