Skip to content

Commit

Permalink
JBPM-6174: Add error count column to the task admin list (kiegroup#965)…
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianonicolai committed Mar 6, 2018
1 parent 6d48772 commit 0e1126b
Show file tree
Hide file tree
Showing 33 changed files with 562 additions and 246 deletions.
@@ -0,0 +1,89 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates.
*
* 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.jbpm.workbench.common.model;

public abstract class GenericErrorSummary<T> extends GenericSummary<T>{

private Integer errorCount;

public GenericErrorSummary() {

}

public GenericErrorSummary(Integer errorCount, T id, String name) {
super(id,name);
this.errorCount = errorCount;
}

public Integer getErrorCount() {
return errorCount;
}

public void setErrorCount(Integer errorCount) {
this.errorCount = errorCount;
}

@Override
@SuppressWarnings("PMD.AvoidMultipleUnaryOperators")
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = ~~result;
result = prime * result + ((errorCount == null) ? 0 : errorCount.hashCode());
result = ~~result;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
GenericErrorSummary other = (GenericErrorSummary) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (errorCount == null) {
if (other.errorCount != null) {
return false;
}
} else if (!errorCount.equals(other.errorCount)) {
return false;
}
return true;
}

@Override
public String toString() {
return "GenericErrorSummary{" +
"id=" + id +
", errorCount=" + errorCount +
'}';
}

}
Expand Up @@ -22,6 +22,7 @@ public interface PerspectiveIds extends org.kie.workbench.common.workbench.clien
String SEARCH_PARAMETER_PROCESS_DEFINITION_ID = "processDefinitionId";
String SEARCH_PARAMETER_TASK_ID = "taskId";
String SEARCH_PARAMETER_JOB_ID = "jobId";
String SEARCH_PARAMETER_ERROR_TYPE = "errorType";
String SEARCH_PARAMETER_IS_ERROR_ACK = "isErrorAck";

String PROCESS_INSTANCE_DETAILS_SCREEN = "ProcessInstanceDetailsScreen";
Expand Down
Expand Up @@ -17,6 +17,8 @@
package org.jbpm.workbench.common.client.list;

import java.util.Optional;
import java.util.function.Predicate;

import javax.inject.Inject;

import org.dashbuilder.dataset.filter.ColumnFilter;
Expand Down Expand Up @@ -145,4 +147,10 @@ public boolean isUserAuthorizedForPerspective(final String perspectiveId) {
return authorizationManager.authorize(resourceRef,
identity);
}

public void openErrorView(final String parameterId) {}

public Predicate<T> getViewErrorsActionCondition(){
return null;
}
}
Expand Up @@ -18,6 +18,7 @@

import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.Messages;
import com.google.gwt.i18n.client.Messages.PluralCount;

/**
* This uses GWT to provide client side compile time resolving of locales. See:
Expand Down Expand Up @@ -140,4 +141,6 @@ String DataSetError(String dataSet,
String RemoveSavedFilterMessage(String filterName);

String Remove();

String ErrorCountNumberView(@PluralCount int errCount);
}
@@ -0,0 +1,12 @@
.data-error-count {
margin-left: 0px;
cursor: initial !important;
}

.data-error-count.error-present {
background-color: #c00;
}

.data-error-count.link-available {
cursor: pointer !important;
}
@@ -0,0 +1,3 @@
<a data-field="pisepc-tooltip" href="#" class="badge data-error-count"
data-toggle="tooltip" data-placement="right">
</a>
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*/

package org.jbpm.workbench.pr.client.editors.instance.list;
package org.jbpm.workbench.common.client.util;

import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
Expand All @@ -27,32 +26,31 @@
import org.jboss.errai.ui.client.local.api.IsElement;
import org.jboss.errai.ui.shared.api.annotations.DataField;
import org.jboss.errai.ui.shared.api.annotations.Templated;
import org.jbpm.workbench.pr.client.resources.i18n.Constants;
import org.jbpm.workbench.pr.model.ProcessInstanceSummary;
import org.jbpm.workbench.common.client.list.AbstractMultiGridPresenter;
import org.jbpm.workbench.common.model.GenericErrorSummary;
import org.jbpm.workbench.common.client.resources.i18n.Constants;

@Dependent
@Templated(value = "ProcessInstanceSummaryErrorCountCell.html", stylesheet = "ProcessInstanceSummaryErrorCountCell.css")
public class ProcessInstanceSummaryErrorCountCell extends AbstractCell<ProcessInstanceSummary> implements IsElement {
@Templated(value = "GenericErrorSummaryCountCell.html", stylesheet = "GenericErrorSummaryCountCell.css")
public class GenericErrorSummaryCountCell<C extends GenericErrorSummary> extends AbstractCell<C> implements IsElement {

private static final String TOOLTIP_NAME = "pisepc-tooltip";
private static final String PROCESS_INSTANCE_ATTRIBUTE = "data-jbpm-processInstanceId";
private static final String DATA_INSTANCE_ATTRIBUTE = "data-jbpm-id";
private static final String ERROR_PRESENT_STYLE = "error-present";
private static final String LINK_AVAILABLE_STYLE = "link-available";

@Inject
@DataField(TOOLTIP_NAME)
private Anchor tooltip;

private ProcessInstanceListPresenter viewPresenter;

public ProcessInstanceSummaryErrorCountCell init(final ProcessInstanceListPresenter viewPresenter) {
private AbstractMultiGridPresenter viewPresenter;

public GenericErrorSummaryCountCell init(final AbstractMultiGridPresenter viewPresenter) {
this.viewPresenter = viewPresenter;
return this;
}

@Override
public void render(Context context,
ProcessInstanceSummary value,
C value,
SafeHtmlBuilder sb) {
Integer errCount = (value != null && value.getErrorCount() != null ? value.getErrorCount() : 0);

Expand All @@ -67,34 +65,34 @@ public void render(Context context,

if (viewPresenter.getViewErrorsActionCondition().test(value)) {
tooltip.setTitle(Constants.INSTANCE.ErrorCountNumberView(errCount));
tooltip.setAttribute(PROCESS_INSTANCE_ATTRIBUTE,
Long.toString(value.getProcessInstanceId()));
tooltip.setAttribute(DATA_INSTANCE_ATTRIBUTE,
value.getId().toString());
tooltipClasses.add(LINK_AVAILABLE_STYLE);

initTooltipsAsync();

} else {
tooltip.removeAttribute("title");
tooltip.removeAttribute(PROCESS_INSTANCE_ATTRIBUTE);
tooltip.removeAttribute(DATA_INSTANCE_ATTRIBUTE);
tooltipClasses.remove(LINK_AVAILABLE_STYLE);
}

sb.appendHtmlConstant(tooltip.getOuterHTML());
}

public void openErrorView(final String pid) {
viewPresenter.openErrorView(pid);
public void openErrorView(final String id){
viewPresenter.openErrorView(id);
}

private void initTooltipsAsync(){
Scheduler.get().scheduleDeferred(() -> initTooltips(TOOLTIP_NAME,
LINK_AVAILABLE_STYLE,
PROCESS_INSTANCE_ATTRIBUTE));
DATA_INSTANCE_ATTRIBUTE));
}

private native void initTooltips(String dataAttrVal,
String linkClassName,
String procIdAttrName) /*-{
String IdAttrName) /*-{
var thisCellRef = this;
$wnd.jQuery(document).ready(function () {
$wnd.jQuery("[data-field='" + dataAttrVal + "']")
Expand All @@ -103,8 +101,8 @@ private native void initTooltips(String dataAttrVal,
.filter("." + linkClassName)
.tooltip()
.on("click", function () {
var processInstId = $wnd.jQuery(this).attr(procIdAttrName);
thisCellRef.@org.jbpm.workbench.pr.client.editors.instance.list.ProcessInstanceSummaryErrorCountCell::openErrorView(Ljava/lang/String;)(processInstId);
var id = $wnd.jQuery(this).attr(IdAttrName);
thisCellRef.@org.jbpm.workbench.common.client.util.GenericErrorSummaryCountCell::openErrorView(Ljava/lang/String;)(id);
});
});
}-*/;
Expand Down
Expand Up @@ -51,4 +51,6 @@ FilterBy=Filter By
SavedFilters=Saved Filters
RemoveSavedFilterTitle=Remove Saved Filter
RemoveSavedFilterMessage=Are you sure you want to remove saved filter: {0}?
Remove=Remove
Remove=Remove
ErrorCountNumberView=Click to view {0} errors
ErrorCountNumberView[\=1]=Click to view {0} error
Expand Up @@ -348,6 +348,36 @@ public void setupActiveSearchFilters() {
isDefaultFilters = false;
}

final Optional<String> taskIdSearch = getSearchParameter(PerspectiveIds.SEARCH_PARAMETER_TASK_ID);
if (taskIdSearch.isPresent()) {
final String taskId = taskIdSearch.get();
view.addActiveFilter(constants.Task(),
taskId,
taskId,
v -> removeAdvancedSearchFilter(equalsTo(COLUMN_ACTIVITY_ID,
v))
);

addAdvancedSearchFilter(equalsTo(COLUMN_ACTIVITY_ID,
taskId));
isDefaultFilters = false;
}

final Optional<String> errorTypeSearch = getSearchParameter(PerspectiveIds.SEARCH_PARAMETER_ERROR_TYPE);
if (errorTypeSearch.isPresent()) {
final String errorType = errorTypeSearch.get();
view.addActiveFilter(constants.Type(),
errorType,
errorType,
v -> removeAdvancedSearchFilter(equalsTo(COLUMN_ERROR_TYPE,
v))
);

addAdvancedSearchFilter(equalsTo(COLUMN_ERROR_TYPE,
errorType));
isDefaultFilters = false;
}

final Optional<String> isErrorAckSearch = getSearchParameter(PerspectiveIds.SEARCH_PARAMETER_IS_ERROR_ACK);
if (isErrorAckSearch.isPresent()) {
final boolean isErrorAck = isErrorAckSearch.get().equalsIgnoreCase(Boolean.toString(true));
Expand Down
Expand Up @@ -49,6 +49,7 @@ public final class TaskDataSetConstants {
public static final String COLUMN_TASK_VARIABLE_NAME = "name";
public static final String COLUMN_TASK_VARIABLE_VALUE = "value";

private TaskDataSetConstants() {
}
public static final String COLUMN_ERROR_COUNT = "errorCount";

private TaskDataSetConstants() {}
}
Expand Up @@ -21,10 +21,10 @@

import org.jboss.errai.common.client.api.annotations.NonPortable;
import org.jboss.errai.common.client.api.annotations.Portable;
import org.jbpm.workbench.common.model.GenericSummary;
import org.jbpm.workbench.common.model.GenericErrorSummary;

@Portable
public class TaskSummary extends GenericSummary<Long> {
public class TaskSummary extends GenericErrorSummary<Long> {

private String description;
private String status;
Expand Down Expand Up @@ -215,34 +215,33 @@ public void setProcessSessionId(Long processSessionId) {
@Override
public String toString() {
return "TaskSummary{" +
"description='" + description + '\'' +
", status='" + status + '\'' +
", priority=" + priority +
", actualOwner='" + actualOwner + '\'' +
", createdBy='" + createdBy + '\'' +
", createdOn=" + createdOn +
", activationTime=" + activationTime +
", expirationTime=" + expirationTime +
", lastModificationDate=" + lastModificationDate +
", processInstanceId=" + processInstanceId +
", processInstanceCorrelationKey='" + processInstanceCorrelationKey + '\'' +
", processInstanceDescription='" + processInstanceDescription + '\'' +
", processId='" + processId + '\'' +
", deploymentId='" + deploymentId + '\'' +
", isForAdmin=" + isForAdmin +
", isLogOnly=" + isLogOnly +
", parentId=" + parentId +
", domainData=" + domainData +
"} " + super.toString();
"description='" + description + '\'' +
", status='" + status + '\'' +
", priority=" + priority +
", actualOwner='" + actualOwner + '\'' +
", createdBy='" + createdBy + '\'' +
", createdOn=" + createdOn +
", activationTime=" + activationTime +
", expirationTime=" + expirationTime +
", lastModificationDate=" + lastModificationDate +
", processInstanceId=" + processInstanceId +
", processInstanceCorrelationKey='" + processInstanceCorrelationKey + '\'' +
", processInstanceDescription='" + processInstanceDescription + '\'' +
", processId='" + processId + '\'' +
", deploymentId='" + deploymentId + '\'' +
", isForAdmin=" + isForAdmin +
", isLogOnly=" + isLogOnly +
", parentId=" + parentId +
", domainData=" + domainData +
"} " + super.toString();
}

@NonPortable
public static final class Builder {

private TaskSummary taskSummary = new TaskSummary();

private Builder() {
}
private Builder() {}

public TaskSummary build() {
return taskSummary;
Expand Down Expand Up @@ -352,5 +351,10 @@ public Builder processSessionId(Long processSessionId) {
this.taskSummary.setProcessSessionId(processSessionId);
return this;
}

public Builder errorCount(Integer errorCount) {
this.taskSummary.setErrorCount(errorCount);
return this;
}
}
}

0 comments on commit 0e1126b

Please sign in to comment.