Skip to content

Commit

Permalink
Merge pull request #1176 from axonivy-market/IVYPORTAL-17822-LTS-Test…
Browse files Browse the repository at this point in the history
…ing-Buffer-Story-Reduce-warning

IVYPORTAL-17822-LTS-Testing-Buffer-Story-Reduce-warning
  • Loading branch information
chnam-axonivy authored Nov 12, 2024
2 parents 2eea1f7 + 013c207 commit acb3c4d
Show file tree
Hide file tree
Showing 71 changed files with 259 additions and 1,210 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"namespace" : "portalKit_test",
"isBusinessCaseData" : false,
"fields" : [ {
"name" : "iTask",
"type" : "ch.ivyteam.ivy.workflow.ITask",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "taskId",
"type" : "Number",
"modifiers" : [ "PERSISTENT" ]
Expand All @@ -33,15 +29,13 @@
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "cases",
"type" : "List<ch.ivyteam.ivy.workflow.ICase>",
"modifiers" : [ "PERSISTENT" ]
"type" : "List<ch.ivyteam.ivy.workflow.ICase>"
}, {
"name" : "count",
"type" : "Integer",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "workingCase",
"type" : "ch.ivyteam.ivy.workflow.ICase",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.workflow.ICase"
} ]
}
Original file line number Diff line number Diff line change
@@ -1,105 +1,54 @@
package ch.ivy.addon.portalkit.test.util;

import java.util.ArrayList;
import java.util.List;

import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.persistence.IQueryResult;
import ch.ivyteam.ivy.security.exec.Sudo;
import ch.ivyteam.ivy.workflow.CaseProperty;
import ch.ivyteam.ivy.workflow.CaseState;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.IPropertyFilter;
import ch.ivyteam.ivy.workflow.ITask;
import ch.ivyteam.ivy.workflow.TaskProperty;
import ch.ivyteam.ivy.workflow.TaskState;
import ch.ivyteam.ivy.workflow.query.CaseQuery;
import ch.ivyteam.ivy.workflow.query.TaskQuery;

public class TaskUtils {

public static List<ICase> destroyAllCase() {
try {
return Sudo.call(() -> {
try {
IPropertyFilter<CaseProperty> noFilter = null;
IQueryResult<ICase> qr = Ivy.wf().findCases(noFilter, null, 0, -1, true);
List<ICase> names = new ArrayList<ICase>();
for (ICase ivyCase : qr.getResultList()) {
try {
if (ivyCase.getState().intValue() != TaskState.DESTROYED.intValue()
&& ivyCase.getState().intValue() != TaskState.DONE.intValue()) {
ivyCase.destroy();
}
} catch (Exception e1) {
Ivy.log().error(e1);
}
}
return names;
} catch (Exception e2) {
Ivy.log().error(e2);
return null;
}
});
} catch (Exception e) {
Ivy.log().error(e);
public static void destroyAllCase() throws Exception {
Sudo.call(() -> {
List<ICase> result = Ivy.wf().getCaseQueryExecutor()
.getResults(CaseQuery.create().where().state().isNotIn(CaseState.DESTROYED, CaseState.DONE));
for (ICase iCaze : result) {
iCaze.destroy();
}
return null;
}
}

public static boolean resumeFirstTask() {
try {
Sudo.call(() -> {
try {
IPropertyFilter<TaskProperty> filter = null;
IQueryResult<ITask> result = Ivy.wf().findTasks(filter, null, 0, -1, true);
List<ITask> tasks = result.getResultList();
for (ITask task : tasks) {
if (TaskState.SUSPENDED == task.getState()) {
Ivy.session().resumeTask(task.getId());
break;
}
}
return true;
} catch (Exception e) {
return false;
}
});
} catch (Exception e) {
return false;
}
return false;
});
}

public static void deleteCompletedCases() throws Exception {
Sudo.call(() -> {
IPropertyFilter<CaseProperty> noFilter = null;
IQueryResult<ICase> qr = Ivy.wf().findCases(noFilter, null, 0, -1, true);
for (ICase ivyCase : qr.getResultList()) {
if (ivyCase.getState() == CaseState.DESTROYED || ivyCase.getState() == CaseState.DONE) {
Ivy.wf().deleteCompletedCase(ivyCase);
}
List<ICase> result = Ivy.wf().getCaseQueryExecutor()
.getResults(CaseQuery.create().where().state().isIn(CaseState.DESTROYED, CaseState.DONE));
for (ICase iCaze : result) {
Ivy.wf().deleteCompletedCase(iCaze);
}
return null;
});
}

public static void deleteDestroyedCases() throws Exception {
Sudo.call(() -> {
IPropertyFilter<CaseProperty> noFilter = null;
IQueryResult<ICase> qr = Ivy.wf().findCases(noFilter, null, 0, -1, true);
for (ICase ivyCase : qr.getResultList()) {
if (ivyCase.getState() == CaseState.DESTROYED) {
Ivy.wf().deleteCompletedCase(ivyCase);
}
List<ICase> result = Ivy.wf().getCaseQueryExecutor()
.getResults(CaseQuery.create().where().state().isEqual(CaseState.DESTROYED));
for (ICase iCaze : result) {
Ivy.wf().deleteCompletedCase(iCaze);
}
return null;
});
}

public static void destroyTaskByCustomField(String customFieldName) throws Exception {
Sudo.call(() -> {
ITask selectedTask = TaskQuery.create().where().customField()
.stringField(customFieldName).isNotNull().executor().firstResult();
ITask selectedTask =
TaskQuery.create().where().customField().stringField(customFieldName).isNotNull().executor().firstResult();
if (selectedTask != null) {
selectedTask.destroy();
selectedTask.customFields().stringField(customFieldName).delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ProcessViewerBean implements Serializable {

private static final long serialVersionUID = 3619473738758338192L;

public static String getProcessTypeDisplayName(String processType) {
public String getProcessTypeDisplayName(String processType) {
ProcessType type = ProcessType.typeOf(processType);
return type != null ? type.getLabel() : processType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
"isBusinessCaseData" : false,
"fields" : [ {
"name" : "documents",
"type" : "java.util.List<com.axonivy.portal.components.ivydata.bo.IvyDocument>",
"modifiers" : [ "PERSISTENT" ]
"type" : "java.util.List<com.axonivy.portal.components.ivydata.bo.IvyDocument>"
}, {
"name" : "event",
"type" : "org.primefaces.event.FileUploadEvent",
"modifiers" : [ "PERSISTENT" ]
"type" : "org.primefaces.event.FileUploadEvent"
}, {
"name" : "fileLimit",
"type" : "Integer",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "ivyCase",
"type" : "ch.ivyteam.ivy.workflow.ICase",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.workflow.ICase"
}, {
"name" : "message",
"type" : "String",
Expand All @@ -29,28 +26,23 @@
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "selectedDocument",
"type" : "com.axonivy.portal.components.ivydata.bo.IvyDocument",
"modifiers" : [ "PERSISTENT" ]
"type" : "com.axonivy.portal.components.ivydata.bo.IvyDocument"
}, {
"name" : "streamedContent",
"type" : "org.primefaces.model.StreamedContent",
"modifiers" : [ "PERSISTENT" ]
"type" : "org.primefaces.model.StreamedContent"
}, {
"name" : "typeColumnRendered",
"type" : "Boolean",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "typeSelection",
"type" : "com.axonivy.portal.components.enums.DocumentType",
"modifiers" : [ "PERSISTENT" ]
"type" : "com.axonivy.portal.components.enums.DocumentType"
}, {
"name" : "uploadDocumentCheckStatus",
"type" : "com.axonivy.portal.components.enums.UploadDocumentCheckStatus",
"modifiers" : [ "PERSISTENT" ]
"type" : "com.axonivy.portal.components.enums.UploadDocumentCheckStatus"
}, {
"name" : "uploadedDocument",
"type" : "ch.ivyteam.ivy.workflow.document.IDocument",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.workflow.document.IDocument"
}, {
"name" : "enableVirusScannerForUploadedDocument",
"type" : "Boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "caze",
"type" : "ch.ivyteam.ivy.workflow.ICase",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.workflow.ICase"
}, {
"name" : "isOpenInFrame",
"type" : "Boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "webStartable",
"type" : "ch.ivyteam.ivy.workflow.start.IWebStartable",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.workflow.start.IWebStartable"
}, {
"name" : "webLink",
"type" : "ch.ivyteam.ivy.model.value.WebLink",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.model.value.WebLink"
}, {
"name" : "activatorName",
"type" : "String",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "activator",
"type" : "ch.ivyteam.ivy.security.ISecurityMember",
"modifiers" : [ "PERSISTENT" ]
"type" : "ch.ivyteam.ivy.security.ISecurityMember"
}, {
"name" : "category",
"type" : "String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ public void onResizeColumn(ColumnResizeEvent event) {
* Then, the result should be 1
*
* @param columnKey
* @return
* @return column index
*/
private Integer getColumnIndexFromColumnKey(String columnKey) {
List<String> idParts = Arrays.asList(columnKey.split("\\:"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import ch.ivy.addon.portalkit.util.SortFieldUtil;
import ch.ivyteam.ivy.security.IPermission;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.INoteable;
import ch.ivyteam.ivy.workflow.ITask;
import ch.ivyteam.ivy.workflow.caze.CaseBusinessState;

Expand All @@ -33,33 +32,31 @@ public boolean isShowMoreDocument() {
return PermissionUtils.hasPermission(IPermission.DOCUMENT_READ);
}

public boolean canWriteDocument(INoteable iNoteable) {
ICase currentCase = getCurrentBusinessCase(iNoteable);
if (currentCase == null) {
public boolean canWriteDocument(ICase caze) {
if (caze == null) {
return false;
}
var isHideUploadDocForDoneCase = GlobalSettingService.getInstance()
.findGlobalSettingValueAsBoolean(GlobalVariable.HIDE_UPLOAD_DOCUMENT_FOR_DONE_CASE);
return !(currentCase.getBusinessState() == CaseBusinessState.DONE && isHideUploadDocForDoneCase) && hasPermissionWriteDocument(iNoteable);
return !(caze.getBusinessState() == CaseBusinessState.DONE && isHideUploadDocForDoneCase) && hasPermissionWriteDocument(caze);
}

private ICase getCurrentBusinessCase(INoteable iNoteable) {
if (iNoteable instanceof ICase) {
return (ICase) iNoteable;
}
if (iNoteable instanceof ITask) {
var task = (ITask) iNoteable;
return task.getCase().getBusinessCase();

public boolean canWriteDocument(ITask task) {
ICase currentCase = task.getCase().getBusinessCase();
if (currentCase == null) {
return false;
}
return null;
var isHideUploadDocForDoneCase = GlobalSettingService.getInstance()
.findGlobalSettingValueAsBoolean(GlobalVariable.HIDE_UPLOAD_DOCUMENT_FOR_DONE_CASE);
return !(currentCase.getBusinessState() == CaseBusinessState.DONE && isHideUploadDocForDoneCase) && hasPermissionWriteDocument(task);
}

public boolean hasPermissionWriteDocument(INoteable iNoteable) {
private boolean hasPermissionWriteDocument(Object iNoteable) {
return hasPermission(iNoteable, IPermission.DOCUMENT_WRITE)
|| hasPermission(iNoteable, IPermission.DOCUMENT_OF_INVOLVED_CASE_WRITE);
}

private boolean hasPermission(INoteable iNoteable, IPermission permission) {
private boolean hasPermission(Object iNoteable, IPermission permission) {
if (iNoteable == null || permission == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import ch.ivy.addon.portalkit.util.SortFieldUtil;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.INote;
import ch.ivyteam.ivy.workflow.ITask;
import ch.ivyteam.ivy.workflow.note.Note;

@ManagedBean(name = "caseTaskNoteHistoryBean")
public class CaseTaskNoteHistoryBean implements Serializable {
Expand Down Expand Up @@ -73,7 +73,7 @@ private String createContentWithTaskState(String taskStateCmsUrl, String content
return String.format("%s: %s", Ivy.cms().co(taskStateCmsUrl), content);
}

public StreamedContent getExportedFileOfTaskNoteHistory(List<INote> taskNoteHistory, String fileName) {
public StreamedContent getExportedFileOfTaskNoteHistory(List<Note> taskNoteHistory, String fileName) {
NoteHistoryExporter exporter = new NoteHistoryExporter();
return exporter.getStreamedContentOfTaskNoteHistory(taskNoteHistory, fileName + ".xlsx");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class DocumentIconBean implements Serializable {
* @param documentName is a name of file
* @return return CSS class for icon
*/
public static String getIconCssClass(String documentName) {
public String getIconCssClass(String documentName) {
String iconClass = StringUtils.EMPTY;
if (StringUtils.isNotEmpty(documentName)) {
String fileExtension = getExtensionByFileName(documentName);
Expand Down Expand Up @@ -84,7 +84,7 @@ public static String getIconCssClass(String documentName) {
return iconClass;
}

private static String getExtensionByFileName(String documentName) {
private String getExtensionByFileName(String documentName) {
String fileName = StringUtils.trimToEmpty(documentName);
fileName = RegExUtils.removeAll(fileName, FILE_NAME_REGEX);
return FilenameUtils.getExtension(StringUtils.lowerCase(fileName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public TaskActionBean() {
isShowReadWorkflowEvent = PermissionUtils.hasPortalPermission(PortalPermission.TASK_DISPLAY_WORKFLOW_EVENT_ACTION);
}

public static boolean canReset(ITask task) {
public boolean canReset(ITask task) {
if (task == null) {
return false;
}
Expand Down Expand Up @@ -104,7 +104,7 @@ private boolean userCanOnlyDelegateAssignedTask(ITask task) {
return hasPermission(task, permission) && !hasPermission(task, IPermission.TASK_WRITE_ACTIVATOR);
}

public static boolean canResume(ITask task) {
public boolean canResume(ITask task) {
return TaskUtils.canResume(task);
}

Expand Down
Loading

0 comments on commit acb3c4d

Please sign in to comment.