标签:
public void recordProcessInstanceStart(ExecutionEntity processInstance) {
if(isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance);
// Insert historic process-instance
getDbSqlSession().insert(historicProcessInstance);
....
}
public boolean isHistoryLevelAtLeast(HistoryLevel level) {
if(log.isDebugEnabled()) {
log.debug("Current history level: {}, level required: {}", historyLevel, level);
}
// Comparing enums actually compares the location of values declared in the enum
return historyLevel.isAtLeast(level);
}
/**
* Enum that contains all possible history-levels.
*
* @author Frederik Heremans
*/
public enum HistoryLevel {
NONE("none"),
ACTIVITY("activity"),
AUDIT("audit"),
FULL("full");
private String key;
private HistoryLevel(String key) {
this.key = key;
}
/**
* @param key string representation of level
* @return {@link HistoryLevel} for the given key
* @throws ActivitiException when passed in key doesn‘t correspond to existing level
*/
public static HistoryLevel getHistoryLevelForKey(String key) {
for(HistoryLevel level : values()) {
if(level.key.equals(key)) {
return level;
}
}
throw new ActivitiIllegalArgumentException("Illegal value for history-level: " + key);
}
/**
* String representation of this history-level.
*/
public String getKey() {
return key;
}
/**
* Checks if the given level is the same as, or higher in order than the
* level this method is executed on.
*/
public boolean isAtLeast(HistoryLevel level) {
// Comparing enums actually compares the location of values declared in the enum
return this.compareTo(level) >= 0;
}
}
Activiti系列:是否可以让某些流程的信息写到历史表,而另外一些不写?
标签:
原文地址:http://www.cnblogs.com/strinkbug/p/4977012.html