|
| 1 | +/* |
| 2 | + * Copyright (C) 2025 eXo Platform SAS |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU Affero General Public License as published by |
| 6 | + * the Free Software Foundation, either version 3 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU Affero General Public License |
| 15 | + * along with this program. If not, see <gnu.org/licenses>. |
| 16 | + */ |
| 17 | +package org.exoplatform.processes.service; |
| 18 | + |
| 19 | +import java.util.List; |
| 20 | + |
| 21 | +import org.exoplatform.commons.exception.ObjectNotFoundException; |
| 22 | +import org.exoplatform.processes.model.IllustrativeAttachment; |
| 23 | +import org.exoplatform.processes.model.ProcessesFilter; |
| 24 | +import org.exoplatform.processes.model.WorkFlow; |
| 25 | +import org.exoplatform.processes.model.WorkStatus; |
| 26 | + |
| 27 | +public interface ProcessService { |
| 28 | + |
| 29 | + /** |
| 30 | + * Retrieves a list of accessible Processes, for a selected user, by applying |
| 31 | + * the designated filter. The returned results will be of type {@link WorkFlow} |
| 32 | + * only. The ownerId of filter object will be used to select the list of |
| 33 | + * accessible processes to retrieve. |
| 34 | + * |
| 35 | + * @param filter {@link ProcessesFilter} that contains filtering criteria |
| 36 | + * @param offset Offset of the result list |
| 37 | + * @param limit Limit of the result list |
| 38 | + * @param userName name of the user accessing files |
| 39 | + * @return {@link List} of {@link WorkFlow} |
| 40 | + */ |
| 41 | + List<WorkFlow> getWorkFlows(ProcessesFilter filter, int offset, int limit, String userName); |
| 42 | + |
| 43 | + /** |
| 44 | + * Return the number of proceses after applying a given filter |
| 45 | + * |
| 46 | + * @param filter: process filter to apply |
| 47 | + * @return Filtered processes count |
| 48 | + */ |
| 49 | + int countWorkFlows(ProcessesFilter filter, String userName); |
| 50 | + |
| 51 | + /** |
| 52 | + * get a process by its given id |
| 53 | + * |
| 54 | + * @param id process id |
| 55 | + * @param userName user name |
| 56 | + * @return {@link WorkFlow} object |
| 57 | + * @throws IllegalAccessException if the user does not have access to the |
| 58 | + * process |
| 59 | + * @throws ObjectNotFoundException if the process with the given id does not |
| 60 | + * exist |
| 61 | + */ |
| 62 | + WorkFlow getWorkFlow(long id, String userName) throws IllegalAccessException, ObjectNotFoundException; |
| 63 | + |
| 64 | + /** |
| 65 | + * get a process by its given id |
| 66 | + * |
| 67 | + * @param id process id |
| 68 | + * @return {@link WorkFlow} object |
| 69 | + * @throws ObjectNotFoundException if the process with the given id does not |
| 70 | + * exist |
| 71 | + */ |
| 72 | + WorkFlow getWorkFlow(long id) throws ObjectNotFoundException; |
| 73 | + |
| 74 | + /** |
| 75 | + * Create a process |
| 76 | + * |
| 77 | + * @param workFlow process object |
| 78 | + * @param userName user name |
| 79 | + * @return {@link WorkFlow} object |
| 80 | + * @throws IllegalAccessException if the user does not have the rights to create |
| 81 | + * a process |
| 82 | + */ |
| 83 | + WorkFlow createWorkFlow(WorkFlow workFlow, String userName) throws IllegalAccessException; |
| 84 | + |
| 85 | + /** |
| 86 | + * Update a process |
| 87 | + * |
| 88 | + * @param workFlow process object |
| 89 | + * @param userName user name |
| 90 | + * @return {@link WorkFlow} object |
| 91 | + * @throws IllegalAccessException if the user does not have the rights to update |
| 92 | + * the process |
| 93 | + * @throws IllegalArgumentException if the process is null or its id is 0 |
| 94 | + * @throws ObjectNotFoundException if the process does not exist |
| 95 | + */ |
| 96 | + WorkFlow updateWorkFlow(WorkFlow workFlow, |
| 97 | + String userName) throws IllegalArgumentException, ObjectNotFoundException, IllegalAccessException; |
| 98 | + |
| 99 | + /** |
| 100 | + * get process by its project id |
| 101 | + * |
| 102 | + * @param projectId process(s project id |
| 103 | + * @param userName user name |
| 104 | + * @return {@link WorkFlow} object |
| 105 | + * @throws IllegalAccessException if the user does not have access to the |
| 106 | + * process |
| 107 | + * @throws ObjectNotFoundException if the project with the given id does not |
| 108 | + * exist |
| 109 | + */ |
| 110 | + WorkFlow getWorkFlowByProjectId(long projectId, String userName) throws IllegalAccessException, ObjectNotFoundException; |
| 111 | + |
| 112 | + /** |
| 113 | + * get process by its project id |
| 114 | + * |
| 115 | + * @param projectId process(s project id |
| 116 | + * @return {@link WorkFlow} object |
| 117 | + * @throws ObjectNotFoundException if the project with the given id does not |
| 118 | + * exist |
| 119 | + */ |
| 120 | + WorkFlow getWorkFlowByProjectId(long projectId) throws ObjectNotFoundException; |
| 121 | + |
| 122 | + /** |
| 123 | + * Delete a workflow by its given id. |
| 124 | + * |
| 125 | + * @param workflowId : workflow id |
| 126 | + * @param userName user name |
| 127 | + * @throws ObjectNotFoundException if the project with the given id does not |
| 128 | + * exist |
| 129 | + * @throws IllegalAccessException if the user does not have access to the |
| 130 | + * process |
| 131 | + */ |
| 132 | + void deleteWorkflowById(Long workflowId, String userName) throws IllegalAccessException, ObjectNotFoundException; |
| 133 | + |
| 134 | + /** |
| 135 | + * @param projectId: Tasks project id |
| 136 | + * @param isCompleted: filter by completed and uncompleted tasks |
| 137 | + * @param userName user name |
| 138 | + * @return Filtered tasks count |
| 139 | + * @throws ObjectNotFoundException if the project with the given id does not |
| 140 | + * exist |
| 141 | + * @throws IllegalAccessException if the user does not have access to the |
| 142 | + * process |
| 143 | + */ |
| 144 | + int countWorksByWorkflow(Long projectId, String userName, Boolean isCompleted) throws ObjectNotFoundException, |
| 145 | + IllegalAccessException; |
| 146 | + |
| 147 | + /** |
| 148 | + * Retrieves the list of available statuses in all workflows |
| 149 | + * |
| 150 | + * @return {@link List} of {@link WorkStatus} |
| 151 | + */ |
| 152 | + List<WorkStatus> getAvailableWorkStatuses(); |
| 153 | + |
| 154 | + /** |
| 155 | + * Retrieves an illustration image by its given id |
| 156 | + * |
| 157 | + * @param illustrationId illustration file id |
| 158 | + * @param userName user name |
| 159 | + * @return {@link IllustrativeAttachment} |
| 160 | + */ |
| 161 | + IllustrativeAttachment getIllustrationImageById(Long illustrationId, String userName); |
| 162 | + |
| 163 | + boolean canAccessProcess(WorkFlow workFlow, org.exoplatform.services.security.Identity identity); |
| 164 | + |
| 165 | + boolean canAddProcess(org.exoplatform.services.security.Identity identity); |
| 166 | + |
| 167 | + boolean canEditProcess(WorkFlow workFlow, org.exoplatform.services.security.Identity identity); |
| 168 | + |
| 169 | + boolean canDeleteProcess(WorkFlow workFlow, org.exoplatform.services.security.Identity identity); |
| 170 | +} |
0 commit comments