-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add ability to dynamically search for comments #3028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DavidPLamas
wants to merge
2
commits into
flowable:main
Choose a base branch
from
DavidPLamas:add-comment-query
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
modules/flowable-engine/src/main/java/org/flowable/engine/impl/CommentQueryImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* 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.flowable.engine.impl; | ||
|
||
import java.io.Serializable; | ||
import java.util.Collection; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.flowable.common.engine.api.FlowableIllegalArgumentException; | ||
import org.flowable.common.engine.impl.interceptor.CommandContext; | ||
import org.flowable.common.engine.impl.interceptor.CommandExecutor; | ||
import org.flowable.common.engine.impl.query.AbstractQuery; | ||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; | ||
import org.flowable.engine.task.Comment; | ||
import org.flowable.engine.task.CommentQuery; | ||
|
||
/** | ||
* @author David Lamas | ||
*/ | ||
public class CommentQueryImpl extends AbstractQuery<CommentQuery, Comment> implements CommentQuery, Serializable { | ||
private ProcessEngineConfigurationImpl processEngineConfiguration; | ||
|
||
private String commentId; | ||
private String taskId; | ||
private String processInstanceId; | ||
private String type; | ||
private String createdBy; | ||
private Collection<String> createdByOneOf; | ||
private Date createdBefore; | ||
private Date createdAfter; | ||
private Date createdOn; | ||
|
||
public CommentQueryImpl() { | ||
} | ||
|
||
public CommentQueryImpl(CommandExecutor commandExecutor, ProcessEngineConfigurationImpl processEngineConfiguration) { | ||
super(commandExecutor); | ||
this.processEngineConfiguration = processEngineConfiguration; | ||
} | ||
|
||
public CommentQueryImpl(CommandContext commandContext, ProcessEngineConfigurationImpl processEngineConfiguration) { | ||
super(commandContext); | ||
this.processEngineConfiguration = processEngineConfiguration; | ||
} | ||
|
||
@Override | ||
public CommentQuery commentId(String commentId) { | ||
this.commentId = commentId; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery taskId(String taskId) { | ||
this.taskId = taskId; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery processInstanceId(String processInstanceId) { | ||
this.processInstanceId = processInstanceId; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery type(String type) { | ||
this.type = type; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery createdBy(String userId) { | ||
if (userId != null) { | ||
if (createdByOneOf != null) { | ||
throw new FlowableIllegalArgumentException("Invalid query usage: cannot set both createdBy and createdByOneOf"); | ||
} | ||
} | ||
this.createdBy = userId; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery createdByOneOf(Collection<String> userIds) { | ||
if (userIds != null) { | ||
if (userIds.isEmpty()) { | ||
throw new FlowableIllegalArgumentException("User id list cannot be empty"); | ||
} | ||
|
||
if (createdBy != null) { | ||
throw new FlowableIllegalArgumentException("Invalid query usage: cannot set both createdBy and createdByOneOf"); | ||
} | ||
} | ||
|
||
this.createdByOneOf = userIds; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery createdBefore(Date beforeTime) { | ||
this.createdBefore = beforeTime; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery createdAfter(Date afterTime) { | ||
this.createdAfter = afterTime; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery createdOn(Date createTime) { | ||
this.createdOn = createTime; | ||
return this; | ||
} | ||
|
||
@Override | ||
public CommentQuery orderByCreateTime() { | ||
return orderBy(CommentQueryProperty.TIME); | ||
} | ||
|
||
@Override | ||
public CommentQuery orderByUser() { | ||
return orderBy(CommentQueryProperty.USER_ID); | ||
} | ||
|
||
@Override | ||
public CommentQuery orderByType() { | ||
return orderBy(CommentQueryProperty.TYPE); | ||
} | ||
|
||
@Override | ||
public CommentQuery orderByTaskId() { | ||
return orderBy(CommentQueryProperty.TASK_ID); | ||
} | ||
|
||
@Override | ||
public CommentQuery orderByProcessInstanceId() { | ||
return orderBy(CommentQueryProperty.PROCESS_INSTANCE_ID); | ||
} | ||
|
||
@Override | ||
public long executeCount(CommandContext commandContext) { | ||
return processEngineConfiguration.getCommentEntityManager().findCommentCountByQueryCriteria(this); | ||
} | ||
|
||
@Override | ||
public List<Comment> executeList(CommandContext commandContext) { | ||
return processEngineConfiguration.getCommentEntityManager().findCommentsByQueryCriteria(this); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
modules/flowable-engine/src/main/java/org/flowable/engine/impl/CommentQueryProperty.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* 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.flowable.engine.impl; | ||
DavidPLamas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.flowable.common.engine.api.query.QueryProperty; | ||
|
||
/** | ||
* Contains the possible properties which can be used in a {@link org.flowable.engine.task.CommentQuery}. | ||
* | ||
* @author David Lamas | ||
*/ | ||
public class CommentQueryProperty implements QueryProperty { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private static final Map<String, CommentQueryProperty> properties = new HashMap<>(); | ||
|
||
public static final CommentQueryProperty ID = new CommentQueryProperty("RES.ID_"); | ||
public static final CommentQueryProperty TIME = new CommentQueryProperty("RES.TIME_"); | ||
public static final CommentQueryProperty USER_ID = new CommentQueryProperty("RES.USER_ID_"); | ||
public static final CommentQueryProperty TYPE = new CommentQueryProperty("RES.TYPE_"); | ||
public static final CommentQueryProperty TASK_ID = new CommentQueryProperty("RES.TASK_ID_"); | ||
public static final CommentQueryProperty PROCESS_INSTANCE_ID = new CommentQueryProperty("RES.PROC_INST_ID_"); | ||
|
||
private String name; | ||
|
||
public CommentQueryProperty(String name) { | ||
this.name = name; | ||
properties.put(name, this); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static CommentQueryProperty findByName(String propertyName) { | ||
return properties.get(propertyName); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.