org.camunda.bpm.engine.impl.persistence.entity.CommentManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camunda-engine Show documentation
Show all versions of camunda-engine Show documentation
The Camunda BPMN engine + configurable support for GraalVM and support for CockroachDB.
The newest version!
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; 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.camunda.bpm.engine.impl.persistence.entity;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.camunda.bpm.engine.impl.Direction;
import org.camunda.bpm.engine.impl.QueryOrderingProperty;
import org.camunda.bpm.engine.impl.QueryPropertyImpl;
import org.camunda.bpm.engine.impl.db.ListQueryParameterObject;
import org.camunda.bpm.engine.impl.db.DbEntity;
import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation;
import org.camunda.bpm.engine.impl.persistence.AbstractHistoricManager;
import org.camunda.bpm.engine.task.Comment;
import org.camunda.bpm.engine.task.Event;
/**
* @author Tom Baeyens
*/
public class CommentManager extends AbstractHistoricManager {
public void delete(DbEntity dbEntity) {
checkHistoryEnabled();
super.delete(dbEntity);
}
public void insert(DbEntity dbEntity) {
checkHistoryEnabled();
super.insert(dbEntity);
}
@SuppressWarnings("unchecked")
public List findCommentsByTaskId(String taskId) {
checkHistoryEnabled();
return getDbEntityManager().selectList("selectCommentsByTaskId", taskId);
}
@SuppressWarnings("unchecked")
public List findEventsByTaskId(String taskId) {
checkHistoryEnabled();
ListQueryParameterObject query = new ListQueryParameterObject();
query.setParameter(taskId);
query.getOrderingProperties().add(new QueryOrderingProperty(new QueryPropertyImpl("TIME_"), Direction.DESCENDING));
return getDbEntityManager().selectList("selectEventsByTaskId", query);
}
public void deleteCommentsByTaskId(String taskId) {
checkHistoryEnabled();
getDbEntityManager().delete(CommentEntity.class, "deleteCommentsByTaskId", taskId);
}
public void deleteCommentsByProcessInstanceIds(List processInstanceIds) {
Map parameters = new HashMap();
parameters.put("processInstanceIds", processInstanceIds);
deleteComments(parameters);
}
public void deleteCommentsByTaskProcessInstanceIds(List processInstanceIds) {
Map parameters = new HashMap();
parameters.put("taskProcessInstanceIds", processInstanceIds);
deleteComments(parameters);
}
public void deleteCommentsByTaskCaseInstanceIds(List caseInstanceIds) {
Map parameters = new HashMap();
parameters.put("taskCaseInstanceIds", caseInstanceIds);
deleteComments(parameters);
}
protected void deleteComments(Map parameters) {
getDbEntityManager().deletePreserveOrder(CommentEntity.class, "deleteCommentsByIds", parameters);
}
@SuppressWarnings("unchecked")
public List findCommentsByProcessInstanceId(String processInstanceId) {
checkHistoryEnabled();
return getDbEntityManager().selectList("selectCommentsByProcessInstanceId", processInstanceId);
}
public CommentEntity findCommentByTaskIdAndCommentId(String taskId, String commentId) {
checkHistoryEnabled();
Map parameters = new HashMap();
parameters.put("taskId", taskId);
parameters.put("id", commentId);
return (CommentEntity) getDbEntityManager().selectOne("selectCommentByTaskIdAndCommentId", parameters);
}
public void addRemovalTimeToCommentsByRootProcessInstanceId(String rootProcessInstanceId, Date removalTime) {
Map parameters = new HashMap<>();
parameters.put("rootProcessInstanceId", rootProcessInstanceId);
parameters.put("removalTime", removalTime);
getDbEntityManager()
.updatePreserveOrder(CommentEntity.class, "updateCommentsByRootProcessInstanceId", parameters);
}
public void addRemovalTimeToCommentsByProcessInstanceId(String processInstanceId, Date removalTime) {
Map parameters = new HashMap<>();
parameters.put("processInstanceId", processInstanceId);
parameters.put("removalTime", removalTime);
getDbEntityManager()
.updatePreserveOrder(CommentEntity.class, "updateCommentsByProcessInstanceId", parameters);
}
public DbOperation deleteCommentsByRemovalTime(Date removalTime, int minuteFrom, int minuteTo, int batchSize) {
Map parameters = new HashMap<>();
parameters.put("removalTime", removalTime);
if (minuteTo - minuteFrom + 1 < 60) {
parameters.put("minuteFrom", minuteFrom);
parameters.put("minuteTo", minuteTo);
}
parameters.put("batchSize", batchSize);
return getDbEntityManager()
.deletePreserveOrder(CommentEntity.class, "deleteCommentsByRemovalTime",
new ListQueryParameterObject(parameters, 0, batchSize));
}
}