diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 176a458..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 58ba2cc..0000000 --- a/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -.gradle -build/ - -# Ignore Gradle GUI config -gradle-app.setting - -# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) -!gradle-wrapper.jar - -# Cache of project -.gradletasknamecache - -# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 -# gradle/wrapper/gradle-wrapper.properties - -*.class - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -# file produced by the build for the credits check -resources/credits/dependencies.txt -resources/credits/jars.txt diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 8f71f43..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - 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. - diff --git a/README.md b/README.md index 9df1299..a315afe 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# workflow +Module moved to [LabKey/clientModules](https://github.com/LabKey/clientModules) in 25.3 diff --git a/api-src/org/labkey/api/workflow/DataManagerConfig.java b/api-src/org/labkey/api/workflow/DataManagerConfig.java deleted file mode 100644 index 7acc7d3..0000000 --- a/api-src/org/labkey/api/workflow/DataManagerConfig.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.security.User; -import org.labkey.api.security.UserManager; - -import java.util.Map; - -/** - * Created by davebradlee on 7/20/15. - * - */ -public abstract class DataManagerConfig extends WorkflowDelegateActionBase -{ - private final Container _container; - private final User _initiator; - - public DataManagerConfig(Map variables) - { - super(variables); - _container = ContainerManager.getForId((String) _variables.get(WorkflowProcess.CONTAINER_ID)); - _initiator = UserManager.getUser(Integer.valueOf((String) _variables.get(WorkflowProcess.INITIATOR_ID))); - } - - public abstract void doAction() throws Exception; - - @Override - public Container getContainer() - { - return _container; - } - - @Override - public User getInitiator() - { - return _initiator; - } - -} diff --git a/api-src/org/labkey/api/workflow/NotificationConfig.java b/api-src/org/labkey/api/workflow/NotificationConfig.java deleted file mode 100644 index 535d336..0000000 --- a/api-src/org/labkey/api/workflow/NotificationConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -/** - * Class that is used to notify a set of users from a service task within a workflow. - * Created by susanh on 6/9/15. - */ - -import org.jetbrains.annotations.Nullable; -import org.labkey.api.security.User; -import org.labkey.api.util.emailTemplate.EmailTemplate; - -import java.util.List; -import java.util.Map; - -public abstract class NotificationConfig extends WorkflowDelegateActionBase -{ - public NotificationConfig(Map variables) - { - super(variables); - } - - public abstract List getUsers(); - - public abstract EmailTemplate getEmailTemplate(String processInstanceId, Map variables); - - @Nullable - public abstract User getLogUser(); -} diff --git a/api-src/org/labkey/api/workflow/PermissionsHandler.java b/api-src/org/labkey/api/workflow/PermissionsHandler.java deleted file mode 100644 index b1967a7..0000000 --- a/api-src/org/labkey/api/workflow/PermissionsHandler.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.Container; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.query.FieldKey; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.security.permissions.Permission; -import org.labkey.api.security.permissions.ReadPermission; - -import java.util.Map; -import java.util.Set; - -/** - * Created by susanh on 5/27/15. - * - */ -public abstract class PermissionsHandler -{ - protected final User _user; - protected final Container _container; - protected final boolean _hasAdmin; - - public PermissionsHandler(User user, Container container) - { - _user = user; - _container = container; - _hasAdmin = _container.hasPermission(_user, AdminPermission.class); - } - - public boolean canStartProcess(@NotNull String processDefinitionKey) - { - return _container.hasPermission(_user, ReadPermission.class); - } - - public boolean canDeployProcess(@NotNull String processDefinitionKey) { return _hasAdmin; } - - - public boolean canView(@NotNull WorkflowProcess process) - { - return (process.getInitiatorId() == _user.getUserId()) || _hasAdmin; - } - - public boolean canAccessData(@NotNull WorkflowProcess process) - { - return _hasAdmin; - } - - - public boolean canDelete(@NotNull WorkflowProcess process) - { - return _hasAdmin || process.getInitiatorId() == _user.getUserId(); - } - - public boolean canClaim(@NotNull WorkflowTask task) - { - return _hasAdmin || task.isInCandidateGroups(_user); - } - - public boolean canDelegate(@NotNull WorkflowTask task) - { - return _hasAdmin; - } - - public boolean canAssign(@NotNull WorkflowTask task) - { - return _hasAdmin; - } - - public boolean canView(@NotNull WorkflowTask task) - { - return ((task.getAssignee() != null && task.getAssignee().getUserId() == _user.getUserId())) || canClaim(task) || canDelegate(task); - } - - public boolean canAccessData(@Nullable WorkflowTask task) - { - return _hasAdmin; - } - - public boolean canComplete(@NotNull WorkflowTask task) - { - return task.isAssigned(_user); - } - - public boolean canUpdate(@NotNull WorkflowTask task) - { - return _hasAdmin; - } - - public SimpleFilter getProcessListFilter() - { - return new SimpleFilter(); - } - - protected SimpleFilter.FilterClause getInitiatorCondition() - { - SQLFragment sql = new SQLFragment("act_ru_execution.id_ IN (SELECT V.execution_id_ FROM workflow.act_ru_variable V WHERE V.name_ = 'initiatorId' AND V.text_ = ?)"); - sql.add(String.valueOf(_user.getUserId())); - return new SimpleFilter.SQLClause("(" + sql.getSQL() + ")", sql.getParams().toArray(), new FieldKey(null, "id_")); - } - - public SimpleFilter getTaskListFilter() - { - return new SimpleFilter(); - } - - protected SimpleFilter.FilterClause getAssigneeOwnerClause() - { - SQLFragment sql = new SQLFragment("owner_ = ? OR assignee_ = ?"); - sql.add(String.valueOf(_user.getUserId())); - sql.add(String.valueOf(_user.getUserId())); - return new SimpleFilter.SQLClause("(" + sql.getSQL() + ")", sql.getParams().toArray(), new FieldKey(null, "id_")); - } - - /** - * For a particular task, return the set of permissions a user must have in order to perform this task. - * This is used when displaying the list of candidate users to assign a task to. - * @param task the task that is to be assigned - * @return a set of permissions classes - */ - public abstract Set> getCandidateUserPermissions(@NotNull WorkflowTask task); - - @SuppressWarnings("unchecked") - public Object getDataAccessParameter(Map variables, String key) - { - Object dataAccess = variables.get(WorkflowProcess.DATA_ACCESS_KEY); - if (null != dataAccess && dataAccess instanceof Map) - { - Object parameters = ((Map) dataAccess).get(WorkflowProcess.DATA_ACCESS_PARAMETERS_KEY); - if (null != parameters && parameters instanceof Map) - return ((Map)parameters).get(key); - } - return null; - } -} diff --git a/api-src/org/labkey/api/workflow/SystemTaskRunner.java b/api-src/org/labkey/api/workflow/SystemTaskRunner.java deleted file mode 100644 index b9bf665..0000000 --- a/api-src/org/labkey/api/workflow/SystemTaskRunner.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.jetbrains.annotations.NotNull; -import org.labkey.api.security.SecurityManager; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.Permission; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * User: tgaluhn - * Date: 1/25/2016 - */ -public abstract class SystemTaskRunner extends WorkflowDelegateActionBase -{ - public SystemTaskRunner(Map variables) - { - super(variables); - } - - public SystemTaskRunner(WorkflowProcess process) - { - super(process); - } - - public abstract void doAction() throws Exception; - - - @NotNull - protected List getUsers(Set> permissions) - { - return _container != null ? SecurityManager.getUsersWithPermissions(_container, permissions) : Collections.emptyList(); - } - -} diff --git a/api-src/org/labkey/api/workflow/TaskFormField.java b/api-src/org/labkey/api/workflow/TaskFormField.java deleted file mode 100644 index 2c86078..0000000 --- a/api-src/org/labkey/api/workflow/TaskFormField.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.jetbrains.annotations.Nullable; - -/** - * Represents a form field as defined in a BPMN 2.0 XML file with the Activiti extensions - * - * Created by susanh on 6/14/15. - */ -public interface TaskFormField -{ - - /** - * @return id of this form field - */ - String getId(); - - /** - * - * @return name of this form field - */ - String getName(); - - /** - * @return the type of field (one of "string", "enum", "Date", "long", "boolean") - */ - String getType(); - - /** - * @return the extra information used in defining this form field. - * * For an enum, use "value" as the key to return a Map of the choices, mapping from the choice key to the display string - * * For a date, use "datePattern" as the key to return the date display format - */ - @Nullable - Object getInformation(String key); - - /** - * @return the value for the form field - */ - String getValue(); - - /** - * @return indication of whether the field is readable or not - */ - boolean isReadable(); - - /** - * @return indication of whether the field is writable or not - */ - boolean isWritable(); - - /** - * @return indication of whether the field is required or not - */ - boolean isRequired(); -} diff --git a/api-src/org/labkey/api/workflow/WorkflowDelegateActionBase.java b/api-src/org/labkey/api/workflow/WorkflowDelegateActionBase.java deleted file mode 100644 index f9f30fa..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowDelegateActionBase.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.security.User; -import org.labkey.api.security.UserManager; - -import java.util.Map; - -/** - * Created by susanh on 8/2/15. - */ -public class WorkflowDelegateActionBase -{ - protected final Map _variables; - protected WorkflowProcess _process; - protected final Container _container; - protected final User _initiator; - - public WorkflowDelegateActionBase(Map variables) - { - _variables = variables; - _container = ContainerManager.getForId((String) _variables.get(WorkflowProcess.CONTAINER_ID)); - _initiator = UserManager.getUser(Integer.valueOf((String) _variables.get(WorkflowProcess.INITIATOR_ID))); - } - - public WorkflowDelegateActionBase(WorkflowProcess process) - { - this(process.getVariables()); - _process = process; - } - - public WorkflowProcess getProcess() - { - return _process; - } - - public Map getVariables() - { - return _variables; - } - - public Container getContainer() - { - return _container; - } - - public User getInitiator() - { - return _initiator; - } - - public Object getVariable(String key) - { - return _variables.get(key); - } - - public void setVariable(String key, Object value) - { - _variables.put(key, value); - } - - @SuppressWarnings("unchecked") - public Object getDataAccessParameter(String key) - { - Object dataAccess = _variables.get(WorkflowProcess.DATA_ACCESS_KEY); - if (null != dataAccess && dataAccess instanceof Map) - { - Object parameters = ((Map) dataAccess).get(WorkflowProcess.DATA_ACCESS_PARAMETERS_KEY); - if (null != parameters && parameters instanceof Map) - return ((Map)parameters).get(key); - } - return null; - } - - @SuppressWarnings("unchecked") - public void setDataAccessParameter(String key, Object value) - { - Object dataAccess = _variables.get(WorkflowProcess.DATA_ACCESS_KEY); - if (null != dataAccess && dataAccess instanceof Map) - { - Object parameters = ((Map) dataAccess).get(WorkflowProcess.DATA_ACCESS_PARAMETERS_KEY); - if (null != parameters && parameters instanceof Map) - ((Map)parameters).put(key, value); - } - } - - public boolean shouldAddUINotification() - { - return false; - } - - public String getUINotificationType() - { - return null; - } -} diff --git a/api-src/org/labkey/api/workflow/WorkflowJob.java b/api-src/org/labkey/api/workflow/WorkflowJob.java deleted file mode 100644 index 5d3840a..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowJob.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import java.util.Date; - -/** - * Created by susanh on 7/23/15. - */ -public interface WorkflowJob -{ - Date getDueDate(); - - String getId(); - - String getProcessInstanceId(); - - String getExecutionId(); - - String getProcessDefinitionId(); - - int getRetries(); - - String getExceptionMessage(); - - String getContainerId(); -} diff --git a/api-src/org/labkey/api/workflow/WorkflowProcess.java b/api-src/org/labkey/api/workflow/WorkflowProcess.java deleted file mode 100644 index a728a1e..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowProcess.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; - -import java.util.List; -import java.util.Map; - -/** - * Created by susanh on 6/14/15. - * - */ -public interface WorkflowProcess -{ - String INITIATOR_ID = "initiatorId"; - String CONTAINER_ID = "container"; - String CREATED_DATE = "created"; - - String DATA_ACCESS_KEY = "dataAccess"; - String DATA_ACCESS_PARAMETERS_KEY = "parameters"; - - String getId(); - - String getProcessDefinitionKey(); - - void setProcessDefinitionKey(String processKey); - - String getProcessDefinitionName(); - - String getProcessDefinitionModule(); - - @Nullable - Map getProcessVariables(); - - @Nullable - Map getVariables(); - - Integer getInitiatorId(); - - String getProcessInstanceId(); - - String getName(); - - User getInitiator(); - - List getCurrentTasks(); - - List getCurrentJobs(); - - List getCompletedTasks(); - - boolean canAccessData(User user, Container container); - - boolean canView(User user, Container container); - - boolean canDelete(User user, Container container); - - boolean canDeploy(User user, Container conatiner); - - boolean hasDiagram(Container container); - - boolean isActive(); - - boolean isDeployed(Container container); - - @Nullable - Map getStartFormFields(Container container); - - String getProcessExecutionId(); -} diff --git a/api-src/org/labkey/api/workflow/WorkflowProcessEventListener.java b/api-src/org/labkey/api/workflow/WorkflowProcessEventListener.java deleted file mode 100644 index c57e448..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowProcessEventListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.labkey.api.data.Container; -import org.labkey.api.security.User; - -/** - * Created by susanh on 7/22/15. - */ -public abstract class WorkflowProcessEventListener -{ - protected WorkflowProcess _process; - protected User _user; - protected Container _container; - - public WorkflowProcessEventListener(WorkflowProcess process, User user, Container container) - { - _process = process; - _user = user; - _container = container; - } - - /** - * Called when an entity create event is received. - */ - public void onCreate() - { - // NO-OP for now - } - - /** - * Called when an entity initialized event is received. - */ - public void onInitialized() - { - // NO-OP for now - } - - /** - * Called when an entity delete event is received. - */ - public void onDelete() - { - // NO-OP for now - } - - /** - * Called when an entity update event is received. - */ - public void onUpdate() - { - // NO-OP for now - } - -} diff --git a/api-src/org/labkey/api/workflow/WorkflowRegistry.java b/api-src/org/labkey/api/workflow/WorkflowRegistry.java deleted file mode 100644 index deff517..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowRegistry.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.Container; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.module.Module; -import org.labkey.api.security.User; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Class for registering handlers, listeners, etc. for workflow processes. - * - * Created by susanh on 5/27/15. - */ -public class WorkflowRegistry -{ - private static final Logger _log = LogManager.getLogger(WorkflowRegistry.class); - private static String _defaultHandler = null; - private static final WorkflowRegistry _instance = new WorkflowRegistry(); - private static final Map> _permissionsRegistry = new ConcurrentHashMap<>(); - private static final Map> _processListenerRegistry = new ConcurrentHashMap<>(); - - private WorkflowRegistry() - { - // private so there can be only one instance created - } - - public static WorkflowRegistry get() { return _instance; } - - public static void registerPermissionsHandler(Module module, Class handler) - { - registerPermissionsHandler(module, handler, false); - } - - public static void registerPermissionsHandler(Module module, Class handler, Boolean isDefault) - { - _permissionsRegistry.put(module.getName().toLowerCase(), handler); - if (isDefault) - _defaultHandler = module.getName().toLowerCase(); - - } - - @Nullable - public PermissionsHandler getPermissionsHandler(@Nullable String moduleName, User user, Container container) - { - Class handlerClass; - if (null == moduleName) - handlerClass = _permissionsRegistry.get(_defaultHandler); - else - { - handlerClass = _permissionsRegistry.get(moduleName.toLowerCase()); - if (null == handlerClass) - handlerClass = _permissionsRegistry.get(_defaultHandler); - } - return createPermissionsHandler(handlerClass, user, container); - } - - private static PermissionsHandler createPermissionsHandler(Class handlerClass, User user, Container container) - { - try - { - return handlerClass.getDeclaredConstructor(User.class, Container.class).newInstance(user, container); - } - catch (InstantiationException|IllegalAccessException|InvocationTargetException|NoSuchMethodException e) - { - _log.error("Unable to instantiate permissions handler for class " + handlerClass, e); - return null; - } - } - - public static List getProcessListFilters(User user, Container container) - { - List filters = new ArrayList<>(); - for (Class handlerClass : _permissionsRegistry.values()) - { - PermissionsHandler handler = createPermissionsHandler(handlerClass, user, container); - SimpleFilter filter = handler.getProcessListFilter(); - if (!filter.isEmpty()) - filters.add(filter); - } - return filters; - } - - public static List getTaskListFilters(User user, Container container) - { - List filters = new ArrayList<>(); - for (Class handlerClass : _permissionsRegistry.values()) - { - PermissionsHandler handler = createPermissionsHandler(handlerClass, user, container); - SimpleFilter filter = handler.getTaskListFilter(); - if (!filter.isEmpty()) - filters.add(filter); - } - return filters; - } - - private static String getProcessListenerKey(String moduleName, String processDefinitionKey) - { - return moduleName.toLowerCase() + ":" + processDefinitionKey; - } - - public static void registerWorkflowProcessEventListener(Module module, String processDefinitionKey, Class listener) - { - _processListenerRegistry.put(getProcessListenerKey(module.getName(), processDefinitionKey), listener); - } - - @Nullable - public WorkflowProcessEventListener getWorkflowProcessEventListener(@NotNull WorkflowProcess instance, User user, Container container) - { - - Class listener = _processListenerRegistry.get(getProcessListenerKey(instance.getProcessDefinitionModule(), instance.getProcessDefinitionKey())); - if (listener != null) - { - try - { - return listener.getDeclaredConstructor(WorkflowProcess.class, User.class, Container.class).newInstance(instance, user, container); - } - catch (InstantiationException|IllegalAccessException|InvocationTargetException|NoSuchMethodException e) - { - _log.error("Unable to instantiate process instance event listener for process " + instance.getName() + " with id " + instance.getId(), e); - return null; - } - } - return null; - } -} - diff --git a/api-src/org/labkey/api/workflow/WorkflowService.java b/api-src/org/labkey/api/workflow/WorkflowService.java deleted file mode 100644 index 04b1e11..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowService.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (c) 2015-2018 LabKey Corporation - * - * 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.labkey.api.workflow; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.Container; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.data.TableInfo; -import org.labkey.api.query.QueryView; -import org.labkey.api.resource.Resource; -import org.labkey.api.security.User; -import org.labkey.api.services.ServiceRegistry; -import org.labkey.api.view.ViewContext; - -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.List; -import java.util.Map; - -/** - * Service for accessing workflow objects including WorkflowTasks and WorkflowProcesses - * Created by susanh on 11/5/15. - */ -public interface WorkflowService -{ - String TASK_KEY = "taskKey"; // the key/name for the column containing the current task description, also an indicator for filtering on a particular type of task. - - static WorkflowService get() - { - return ServiceRegistry.get().getService(WorkflowService.class); - } - - static void setInstance(WorkflowService impl) - { - ServiceRegistry.get().registerService(WorkflowService.class, impl); - } - - /** - * Gets the list of candidate group ids for a task given its id, or an empty list if there are no candidate groups - * @param taskId id of the task to get groups for - * @return list of candidate group ids. - */ - @NotNull - List getCandidateGroupIds(@NotNull String taskId); - - /** - * Retrieve a task given its id - * @param taskId id of the task to retrieve - * @param container container in which the task is defined - * @return a workflow task of the given Id. If there is no such task, an exception is thrown. - */ - WorkflowTask getTask(@NotNull String taskId, @Nullable Container container); - - /** - * Completes a task in a workflow given the id of the task - * @param taskId the id of an active task - * @param user the user completing the task - * @param container the container in which the task is being completed - * @throws Exception when no task exists with the given id or the tasks is pending delegation - */ - void completeTask(@NotNull String taskId, User user, Container container) throws Exception; - - - /** - * Claim a task that one (or more) of the user's group is currently a candidate group for - * @param taskId id of the task to be claimed - * @param userId id of the user who is claiming the task - * @param container the container in which the task is being handled - * @throws Exception if user - */ - void claimTask(@NotNull String taskId, @NotNull Integer userId, Container container) throws Exception; - - /** - * Assign a particular task to a user given the id of the user - * @param taskId id of the task to be assigned - * @param assigneeId id of the user to whom the task should be assigned - * @param user principal doing the assignment - * @param container container context for this assignment - * @throws Exception - */ - void assignTask(@NotNull String taskId, @NotNull Integer assigneeId, User user, Container container) throws Exception; - - /** - * Delegate a task to a particular task (retaining ownership of the task for later review of results) - * @param taskId id of the task to be delegated - * @param user principal doing the delegation - * @param designateeId id of the user to delegate to - * @param container context in which the delegation is being made - * @throws Exception - */ - void delegateTask(@NotNull String taskId, @NotNull User user, @NotNull Integer designateeId, Container container) throws Exception; - - /** - * Creates a new process instance for the given workflow and returns the id for this new instance. - * @param moduleName - the name of the module in which the process definition key is defined - * @param processDefinitionKey - the unique key for this process definition - * @param name - the human-readable name for the process - * @param processVariables - the set of variables to associate with this process instance (should contain at least the INITIATOR_ID variable) - * @param container the container in which this process is being created - * @return the id of the new process instance for this workflow - */ - String startWorkflow(@NotNull String moduleName, @NotNull String processDefinitionKey, @Nullable String name, @NotNull Map processVariables, @Nullable Container container) throws FileNotFoundException; - - /** - * Creates a new process instance for a given workflow starting at the message start event provided - * @param moduleName - name of the module in which the workflow is defined - * @param processDefinitionKey - the unique key for this process definition (also the prefix of the bpmn.xml file) - * @param processVariables - the set of variables to associate with this process instance (should contain at least the INITIATOR_ID variable) - * @param container - the container in which this process is being created - * @param startMessage - the id of the message element defined for the start event - * @return id of the process instance created - * @throws FileNotFoundException if the bpmn.xml file that defines the process does not exist and it is necessary to deploy a new instance of this model in this container - */ - String startWorkflow(@NotNull String moduleName, @NotNull String processDefinitionKey, @NotNull Map processVariables, @NotNull Container container, @NotNull String startMessage) throws FileNotFoundException; - - - /** - * Sends the message indicated by the message name to the provided executionId - * setting the processVariables as provided. - * @param messageName - name of the message to send - * @param executionId - identifier for the execution receiving the message (the id of the execution to deliver the message to) - * @param processVariables - variables that represent the payload of this message - */ - public void sendMessage(String messageName, String executionId, @Nullable Map processVariables); - - /** - * Find the workflow process corresponding to the given process instance id. It will find either an acitve - * or inactive process instance. - * @param processInstanceId identifier for the process instance to retrieve. - * @return null if no such process instance exists - */ - WorkflowProcess getWorkflowProcess(@NotNull String processInstanceId); - - /** - * Given a key and value that correspond to a process variable for a set of processes within a container, finds the - * workflow process with that process variable value that was started last. This can be used for variables of - * type string as well as integer. - * @param key - the process variable name - * @param value - the string value for the unique identifier for the process instance - * @param container - the container context - * @return the workflow identified by the given key and value - * @throws Exception if the key-value pair does not uniquely identify a single latest workflow process - */ - @Nullable - WorkflowProcess getWorkflowProcessForVariable(String key, String value, Container container) throws Exception; - - /** - * Gets the list of jobs taht are currently active for the given processInstanceId in the given container, - * or in all containers if container is null - * @param processInstanceId instance for which tasks are to be retrieved - * @param container container in which the process instance is active - * @return list of workflow jobs, or an empty list of there are none - */ - List getCurrentProcessJobs(@NotNull String processInstanceId, @Nullable Container container); - - - /** - * Gets the list of tasks that are currently active for the given processInstanceId in the given container, - * or in all containers if container is null - * @param processInstanceId instance for which tasks are to be retrieved - * @param container container in which the process instance is active - * @return list of workflow tasks, or an empty list of there are none - */ - @NotNull - List getCurrentProcessTasks(@NotNull String processInstanceId, @Nullable Container container); - - /** - * Gets the list of completed tasks for the given processInstanceId in the given container, - * or in all containers if container is null - * @param processInstanceId instance for which tasks are to be retrieved - * @param container container in which the process instance is active - * @return list of workflow tasks, or an empty list of there are none - */ - @NotNull - List getCompletedProcessTasks(@NotNull String processInstanceId, @Nullable Container container); - - /** - * Retrieves the count of the tasks associated with a particular processDefinitionKey that are assigned to a particular user - * @param processDefinitionKey identifier for the process definition - * @param filter a filter over the task variables for the assigned tasks - * @param assignee the user the tasks are assigned to - * @param container the container in which the tasks are defined, null for all containers @return count of the workflow tasks - * */ - long getTaskCount(@NotNull String processDefinitionKey, @Nullable SimpleFilter filter, @Nullable User assignee, @Nullable Container container); - - /** - * Creates a column containing the assignee with a given key for a process instance identified by a process variable of a given name - * @param tableInfo the table the column will be attached to - * @param colName name to give the column being created - * @param assigneeKey the name of the process variable that contains the assigneeId (as an integer) - * @param identifierKey the name of the variable that has the identifier for the workflow object in this table - * @param identifierColName - * @param user the current user - * @param container the container context for this table @return column that will display the assignee - */ - ColumnInfo getAssigneeColumn(TableInfo tableInfo, final String colName, String assigneeKey, String identifierKey, String identifierColName, User user, Container container); - - /** - * Creates a column with the current taskType (task definition key) for a given identifier variable. Note that this - * will not work if there is more than one active task for a particular process instance and it currently assumes the - * identifier is a long_ value. - * @param tableInfo the table to which the column will be added - * @param colLabel the name to be given to the column - * @param identifierVarName the name of the process variable that contains the identifier - * @param identifierColumnName the name of the column in the table that contains the identifier - * @return a column with the id of the current task. - */ - ColumnInfo getTaskTypeColumn(TableInfo tableInfo, final String colLabel, String identifierVarName, String identifierColumnName); - - - /** - * Count of the number of process instances in the current container that were initiated by the given user, - * or by any user if this user has administrative permissions. If the container is null, all process instances - * for the given definition key will be returned. - * @param processDefinitionKey identifier for the process definition - * @param user user making the request - * @param container container of context, or null for all containers - * @return number of process instances - */ - @NotNull - Long getProcessInstanceCount(String processDefinitionKey, @NotNull User user, @Nullable Container container); - - /** - * Count of the number of process instances, both active an inactive, but not including deleted ones, in the given container for a given definiiton key - * @param processDefinitionKey identifier of the process definition - * @param container container of context, or null for all containers - * @return number of active and inactive process instances, excluding deleted instances - */ - @NotNull - public Long getProcessInstanceCount(String processDefinitionKey, @Nullable Container container); - - /** - * Returns the set of variables associated with the given historicProcessInstance - * @param processInstanceId id of the historic process instance in question - * @return the set of process instance variables for this historic process instance - */ - Map getHistoricProcessInstanceVariables(@NotNull String processInstanceId); - - /** - * Given the id of a particular task, will update the process instance variables (not the task variables) - * for the instance that contains this task with the given variables. New variables will be added; existing - * variables will be replaced. Task variables are left alone. - * @param taskId - - * id of the task whose process variables should be updated - * @param variables - - * variables that will be merged into the existing set of variables - * - */ - void updateProcessVariables(@NotNull String taskId, @Nullable Map variables); - - /** - * Given the id of a particular task, will update the variables for this task (not the process instance) - * New variables will be added; existing variables will be replaced. Process variables are left alone. - * @param taskId - - * id of the task whose variables should be updated - * @param variables - - * variables that will be merged into the existing set of variables - * - */ - void updateTaskVariables(@NotNull String taskId, @Nullable Map variables); - - /** - * Provides a query view of the task list for a given context - * @param context the context of the query view - * @param filter - * @return a query view or null if one cannot be shown - */ - @Nullable - QueryView getTaskListQueryView(ViewContext context, SimpleFilter filter); - - /** - * Remove the process instance whose id is supplied, logging the reason for the deletion if provided - * @param processInstanceId id of the process instance to be removed - * @param reason reason for deletion (may be null) - */ - void deleteProcessInstance(@NotNull String processInstanceId, @Nullable String reason); - - /** - * Deletes an active process instance given a key and value that uniquely identify it within a particular container. - * Historic process instances with no active counterparts will not be deleted. - * @param key the key for the variable identifier - * @param value the value for the variable identifier - * @param reason (optional) reason for deletion - * @param container the container context - * @throws Exception if there are problems retrieving the process instance using the given variable data - */ - void deleteProcessInstance(String key, String value, @Nullable String reason, @NotNull Container container) throws RuntimeException; - - /** - * Deletes active process instances given a key and set of values value that each uniquely identify a process within a particular container. - * Historic process instances with no active counterparts will not be deleted. - * @param key the key for the variable identifier - * @param values the set of values for the given variable identifier that identify the process instance to be deleted - * @param reason (optional) reason for deletion - * @param container the container context - * @throws Exception if there are problems retrieving the process instance using the given variable data - */ - void deleteProcessInstances(String key, List values, @Nullable String reason, @NotNull Container container) throws RuntimeException; - - - /** - * Returns the set of variables associated with the given processInstance as well as a list of the current active tasks for that instance - * @param processInstanceId id of the process instance in question - * @return the set of process instance variables for this process instance - */ - Map getProcessInstanceVariables(@NotNull String processInstanceId); - - /** - * Returns the set of variables associated with a given task. - * Does not include any variables associated with the corresponding process instance. - * @param taskId id of the task in question - * @return the set of variables associated with this task, or an empty map if there are none - */ - Map getTaskVariables(@NotNull String taskId); - - /** - * @param processDefinitionId unique id of a process definition - * @param container container in which the process is defined - * @return name of the module that this process definition comes from - */ - String getProcessDefinitionModule(@NotNull String processDefinitionId, Container container); - - - Map getProcessDefinitionNames(@Nullable Container container); - - Map getStartFormFields(String processDefinitionKey); - - Map getFormFields(String taskId); - - String getProcessDefinitionKey(@NotNull String processDefinitionId); - - InputStream getProcessDiagram(@NotNull String processInstanceId); - - InputStream getProcessDiagramByKey(@NotNull String processDefinitionKey, @Nullable Container container); - - void deleteDeployments(@NotNull Container container); - - String deployWorkflow(String moduleName, Resource modelResource, @Nullable Container container) throws FileNotFoundException; - - void deleteWorkflow(@NotNull String deploymentId); -} diff --git a/api-src/org/labkey/api/workflow/WorkflowTask.java b/api-src/org/labkey/api/workflow/WorkflowTask.java deleted file mode 100644 index fc2ed7d..0000000 --- a/api-src/org/labkey/api/workflow/WorkflowTask.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.api.workflow; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.Permission; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Represents a single task within a workflow instance. - * - * Created by susanh on 6/14/15. - */ -public interface WorkflowTask -{ - String getId(); - - String getExecutionId(); - - String getName(); - - String getDescription(); - - String getProcessDefinitionKey(Container container); - - String getProcessDefinitionName(Container container); - - @Nullable - @JsonIgnore - User getOwner(); - - @Nullable - Integer getOwnerId(); - - @Nullable - @JsonIgnore - User getAssignee(); - - @Nullable - Integer getAssigneeId(); - - void assign(@NotNull Integer assigneeId, User user, Container container) throws Exception; - - String getProcessInstanceId(); - - String getProcessDefinitionId(); - - Date getCreateTime(); - - String getTaskDefinitionKey(); - - Date getDueDate(); - - Date getEndDate(); - - String getParentTaskId(); - - Map getTaskLocalVariables(); - - Map getProcessVariables(); - - String getContainer(); - - List getGroupIds(); - - boolean isInCandidateGroups(User user); - - boolean hasCandidateGroups(); - - boolean canClaim(User user, Container container); - - boolean canDelegate(User user, Container container); - - boolean canAssign(User user, Container container); - - boolean canView(User user, Container container); - - boolean canAccessData(User user, Container container); - - boolean canComplete(User user, Container container); - - boolean canUpdate(User user, Container container); - - void setName(String name); - - void setDescription(String description); - - /** - * Set the user responsible for full completion of the task, which may include review of results - * if the task has been delegated - * @param owner the owner for this task - */ - void setOwner(User owner); - - /** - * Set the user who is currently assigned to work on this task - * @param assignee the user to assign this task to - */ - void setAssignee(User assignee); - - boolean isAssigned(User user); - - boolean isDelegated(); - - boolean isReadyForReview(); - - void setDueDate(Date dueDate); - - void delegate(User user); - - boolean isSuspended(); - - Set> getReassignPermissions(User user, Container container); - - boolean isActive(); - - @NotNull - Map getFormFields(); - - @Nullable - Map getVariables(); -} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index ad4989a..0000000 --- a/build.gradle +++ /dev/null @@ -1,120 +0,0 @@ -import org.labkey.gradle.util.BuildUtils; -import org.labkey.gradle.util.ExternalDependency - -plugins { - id 'org.labkey.build.module' -} - -configurations.all { - resolutionStrategy { - // Force to get a fix for CVEs - force "org.apache.commons:commons-email:1.5" - } -} - -dependencies { - implementation "org.eclipse.angus:angus-mail:${angusMailVersion}" - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.activiti:activiti-bpmn-model:${activitiVersion}", - "Workflow", - "Activiti", - "http://activiti.org/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "BPMN 2.0 modeling library", - ) - ) - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.activiti:activiti-engine:${activitiVersion}", - "Workflow", - "Activiti", - "http://activiti.org/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "BPMN Engine", - ), - { - // We get mail and activation jars from the api build and include them in the tomcat/lib directory. They've gone - // by various names over the last couple years... exclude them all to prevent version compatibility problems. - exclude group: "com.sun.mail", module:"javax.mail" // Old name - exclude group: "com.sun.mail", module:"jakarta.mail" // New name - exclude group: "javax.activation", module: "activation" // Old name - exclude group: "javax.activation", module: "javax.activation" // Old name - exclude group: "javax.activation", module: "jakarta.activation" // New name - - // we get spring jars from api - exclude group: "org.springframework", module:"spring-beans" - } - ) - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.activiti:activiti-image-generator:${activitiVersion}", - "Workflow", - "Activiti", - "http://activiti.org/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "BPMN 2.0 model image library", - ) - ) - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.activiti:activiti-process-validation:${activitiVersion}", - "Workflow", - "Activiti", - "http://activiti.org/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "BPMN 2.0 model validation", - ) - ) - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "joda-time:joda-time:${jodaTimeVersion}", - "Workflow", - "Joda.org", - "http://www.joda.org/joda-time/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "Dependency of Activiti workflow engine", - ) - ) - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.mybatis:mybatis:${mybatisVersion}", - "Workflow", - "Mybatis", - "https://mybatis.github.io/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "Dependency of Activiti for database interaction", - ) - ) - - BuildUtils.addLabKeyDependency(project: project, config: "implementation", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "core"), depProjectConfig: "apiJarFile") -} - -sourceSets { - main { - resources { - srcDirs = ['src'] // src is included because it contains some configuration files. - exclude '**/*.java' - exclude '**/*.jsp' - } - } -} - diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 24b77b7..0000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -mybatisVersion=3.5.13 -activitiVersion=5.20.0 diff --git a/module.properties b/module.properties deleted file mode 100644 index 4fdde1c..0000000 --- a/module.properties +++ /dev/null @@ -1,11 +0,0 @@ -ModuleClass: org.labkey.workflow.WorkflowModule -Label: Workflow processing engine and services -Description: The LabKey Workflow module provides a \ - centralized workflow system for incorporating general workflows specified \ - using the BPMN 2.0 standard into an application. -URL: https://www.labkey.org/Documentation/wiki-page.view?name=workflow -Organization: LabKey -OrganizationURL: https://www.labkey.com/ -License: Apache 2.0 -LicenseURL: http://www.apache.org/licenses/LICENSE-2.0 -ManageVersion: true diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 2a1c8ac..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,8 +0,0 @@ -#### Rationale - - -#### Related Pull Requests -* - -#### Changes -* diff --git a/resources/schemas/dbscripts/activity_tables.sql b/resources/schemas/dbscripts/activity_tables.sql deleted file mode 100644 index fd6c543..0000000 --- a/resources/schemas/dbscripts/activity_tables.sql +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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. - */ -DROP TABLE IF EXISTS act_evt_log, -act_ge_bytearray, -act_ge_property, -act_hi_attachment, -act_hi_comment, -act_hi_detail, -act_hi_identitylink, -act_hi_taskinst, -act_hi_varinst, -act_id_group, -act_id_info, -act_id_membership, -act_id_user, -act_re_deployment, -act_re_model, -act_re_procdef, -act_ru_event_subscr, -act_ru_execution, -act_ru_identitylink, -act_ru_job, -act_ru_task, -act_ru_variable; diff --git a/resources/schemas/dbscripts/postgresql/workflow-0.00-17.20.sql b/resources/schemas/dbscripts/postgresql/workflow-0.00-17.20.sql deleted file mode 100644 index 39a3f35..0000000 --- a/resources/schemas/dbscripts/postgresql/workflow-0.00-17.20.sql +++ /dev/null @@ -1,651 +0,0 @@ -/* workflow-00.00-15.10.sql */ - -/* - * Activiti BPM Platform - * Copyright 2010-2014 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ --- @SkipLabKeySyntaxCheck --- Create schema, tables, indexes, and constraints used for Workflow module here --- All SQL VIEW definitions should be created in workflow-create.sql and dropped in workflow-drop.sql -CREATE SCHEMA workflow; - -CREATE TABLE workflow.ACT_GE_PROPERTY ( - NAME_ varchar(64), - VALUE_ varchar(300), - REV_ integer, - primary key (NAME_) -); - -INSERT INTO workflow.ACT_GE_PROPERTY -values ('schema.version', '5.17.0.2', 1); - -INSERT INTO workflow.ACT_GE_PROPERTY -values ('schema.history', 'create(5.17.0.2)', 1); - -INSERT INTO workflow.ACT_GE_PROPERTY -values ('next.dbid', '1', 1); - -CREATE TABLE workflow.ACT_GE_BYTEARRAY ( - ID_ varchar(64), - REV_ integer, - NAME_ varchar(255), - DEPLOYMENT_ID_ varchar(64), - BYTES_ bytea, - GENERATED_ boolean, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RE_DEPLOYMENT ( - ID_ varchar(64), - NAME_ varchar(255), - CATEGORY_ varchar(255), - TENANT_ID_ varchar(255) default '', - DEPLOY_TIME_ timestamp, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RE_MODEL ( - ID_ varchar(64) not null, - REV_ integer, - NAME_ varchar(255), - KEY_ varchar(255), - CATEGORY_ varchar(255), - CREATE_TIME_ timestamp, - LAST_UPDATE_TIME_ timestamp, - VERSION_ integer, - META_INFO_ varchar(4000), - DEPLOYMENT_ID_ varchar(64), - EDITOR_SOURCE_VALUE_ID_ varchar(64), - EDITOR_SOURCE_EXTRA_VALUE_ID_ varchar(64), - TENANT_ID_ varchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_EXECUTION ( - ID_ varchar(64), - REV_ integer, - PROC_INST_ID_ varchar(64), - BUSINESS_KEY_ varchar(255), - PARENT_ID_ varchar(64), - PROC_DEF_ID_ varchar(64), - SUPER_EXEC_ varchar(64), - ACT_ID_ varchar(255), - IS_ACTIVE_ boolean, - IS_CONCURRENT_ boolean, - IS_SCOPE_ boolean, - IS_EVENT_SCOPE_ boolean, - SUSPENSION_STATE_ integer, - CACHED_ENT_STATE_ integer, - TENANT_ID_ varchar(255) default '', - NAME_ varchar(255), - LOCK_TIME_ timestamp, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_JOB ( - ID_ varchar(64) NOT NULL, - REV_ integer, - TYPE_ varchar(255) NOT NULL, - LOCK_EXP_TIME_ timestamp, - LOCK_OWNER_ varchar(255), - EXCLUSIVE_ boolean, - EXECUTION_ID_ varchar(64), - PROCESS_INSTANCE_ID_ varchar(64), - PROC_DEF_ID_ varchar(64), - RETRIES_ integer, - EXCEPTION_STACK_ID_ varchar(64), - EXCEPTION_MSG_ varchar(4000), - DUEDATE_ timestamp, - REPEAT_ varchar(255), - HANDLER_TYPE_ varchar(255), - HANDLER_CFG_ varchar(4000), - TENANT_ID_ varchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RE_PROCDEF ( - ID_ varchar(64) NOT NULL, - REV_ integer, - CATEGORY_ varchar(255), - NAME_ varchar(255), - KEY_ varchar(255) NOT NULL, - VERSION_ integer NOT NULL, - DEPLOYMENT_ID_ varchar(64), - RESOURCE_NAME_ varchar(4000), - DGRM_RESOURCE_NAME_ varchar(4000), - DESCRIPTION_ varchar(4000), - HAS_START_FORM_KEY_ boolean, - HAS_GRAPHICAL_NOTATION_ boolean, - SUSPENSION_STATE_ integer, - TENANT_ID_ varchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_TASK ( - ID_ varchar(64), - REV_ integer, - EXECUTION_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - PROC_DEF_ID_ varchar(64), - NAME_ varchar(255), - PARENT_TASK_ID_ varchar(64), - DESCRIPTION_ varchar(4000), - TASK_DEF_KEY_ varchar(255), - OWNER_ varchar(255), - ASSIGNEE_ varchar(255), - DELEGATION_ varchar(64), - PRIORITY_ integer, - CREATE_TIME_ timestamp, - DUE_DATE_ timestamp, - CATEGORY_ varchar(255), - SUSPENSION_STATE_ integer, - TENANT_ID_ varchar(255) default '', - FORM_KEY_ varchar(255), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_IDENTITYLINK ( - ID_ varchar(64), - REV_ integer, - GROUP_ID_ varchar(255), - TYPE_ varchar(255), - USER_ID_ varchar(255), - TASK_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - PROC_DEF_ID_ varchar (64), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_VARIABLE ( - ID_ varchar(64) not null, - REV_ integer, - TYPE_ varchar(255) not null, - NAME_ varchar(255) not null, - EXECUTION_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - TASK_ID_ varchar(64), - BYTEARRAY_ID_ varchar(64), - DOUBLE_ double precision, - LONG_ bigint, - TEXT_ varchar(4000), - TEXT2_ varchar(4000), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_EVENT_SUBSCR ( - ID_ varchar(64) not null, - REV_ integer, - EVENT_TYPE_ varchar(255) not null, - EVENT_NAME_ varchar(255), - EXECUTION_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - ACTIVITY_ID_ varchar(64), - CONFIGURATION_ varchar(255), - CREATED_ timestamp not null, - PROC_DEF_ID_ varchar(64), - TENANT_ID_ varchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_EVT_LOG ( - LOG_NR_ SERIAL PRIMARY KEY, - TYPE_ varchar(64), - PROC_DEF_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - EXECUTION_ID_ varchar(64), - TASK_ID_ varchar(64), - TIME_STAMP_ timestamp not null, - USER_ID_ varchar(255), - DATA_ bytea, - LOCK_OWNER_ varchar(255), - LOCK_TIME_ timestamp null, - IS_PROCESSED_ smallint default 0 -); - -create index ACT_IDX_EXEC_BUSKEY on workflow.ACT_RU_EXECUTION(BUSINESS_KEY_); -create index ACT_IDX_TASK_CREATE on workflow.ACT_RU_TASK(CREATE_TIME_); -create index ACT_IDX_IDENT_LNK_USER on workflow.ACT_RU_IDENTITYLINK(USER_ID_); -create index ACT_IDX_IDENT_LNK_GROUP on workflow.ACT_RU_IDENTITYLINK(GROUP_ID_); -create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on workflow.ACT_RU_EVENT_SUBSCR(CONFIGURATION_); -create index ACT_IDX_VARIABLE_TASK_ID on workflow.ACT_RU_VARIABLE(TASK_ID_); - -create index ACT_IDX_BYTEAR_DEPL on workflow.ACT_GE_BYTEARRAY(DEPLOYMENT_ID_); -ALTER TABLE workflow.ACT_GE_BYTEARRAY - add constraint ACT_FK_BYTEARR_DEPL - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_); - -ALTER TABLE workflow.ACT_RE_PROCDEF - add constraint ACT_UNIQ_PROCDEF - unique (KEY_,VERSION_, TENANT_ID_); - -create index ACT_IDX_EXE_PROCINST on workflow.ACT_RU_EXECUTION(PROC_INST_ID_); -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_EXE_PARENT on workflow.ACT_RU_EXECUTION(PARENT_ID_); -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_PARENT - foreign key (PARENT_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_EXE_SUPER on workflow.ACT_RU_EXECUTION(SUPER_EXEC_); -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_SUPER - foreign key (SUPER_EXEC_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_EXE_PROCDEF on workflow.ACT_RU_EXECUTION(PROC_DEF_ID_); -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_PROCDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - - -create index ACT_IDX_TSKASS_TASK on workflow.ACT_RU_IDENTITYLINK(TASK_ID_); -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_TSKASS_TASK - foreign key (TASK_ID_) - references workflow.ACT_RU_TASK (ID_); - -create index ACT_IDX_ATHRZ_PROCEDEF on workflow.ACT_RU_IDENTITYLINK(PROC_DEF_ID_); -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_ATHRZ_PROCEDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -create index ACT_IDX_IDL_PROCINST on workflow.ACT_RU_IDENTITYLINK(PROC_INST_ID_); -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_IDL_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_TASK_EXEC on workflow.ACT_RU_TASK(EXECUTION_ID_); -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_EXE - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_TASK_PROCINST on workflow.ACT_RU_TASK(PROC_INST_ID_); -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_TASK_PROCDEF on workflow.ACT_RU_TASK(PROC_DEF_ID_); -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_PROCDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -create index ACT_IDX_VAR_EXE on workflow.ACT_RU_VARIABLE(EXECUTION_ID_); -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_EXE - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -create index ACT_IDX_VAR_PROCINST on workflow.ACT_RU_VARIABLE(PROC_INST_ID_); -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION(ID_); - -create index ACT_IDX_VAR_BYTEARRAY on workflow.ACT_RU_VARIABLE(BYTEARRAY_ID_); -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_BYTEARRAY - foreign key (BYTEARRAY_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -create index ACT_IDX_JOB_EXCEPTION on workflow.ACT_RU_JOB(EXCEPTION_STACK_ID_); -ALTER TABLE workflow.ACT_RU_JOB - add constraint ACT_FK_JOB_EXCEPTION - foreign key (EXCEPTION_STACK_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -create index ACT_IDX_EVENT_SUBSCR on workflow.ACT_RU_EVENT_SUBSCR(EXECUTION_ID_); -ALTER TABLE workflow.ACT_RU_EVENT_SUBSCR - add constraint ACT_FK_EVENT_EXEC - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION(ID_); - -create index ACT_IDX_MODEL_SOURCE on workflow.ACT_RE_MODEL(EDITOR_SOURCE_VALUE_ID_); -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_SOURCE - foreign key (EDITOR_SOURCE_VALUE_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -create index ACT_IDX_MODEL_SOURCE_EXTRA on workflow.ACT_RE_MODEL(EDITOR_SOURCE_EXTRA_VALUE_ID_); -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_SOURCE_EXTRA - foreign key (EDITOR_SOURCE_EXTRA_VALUE_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -create index ACT_IDX_MODEL_DEPLOYMENT on workflow.ACT_RE_MODEL(DEPLOYMENT_ID_); -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_DEPLOYMENT - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_); - -CREATE TABLE workflow.ACT_HI_PROCINST ( - ID_ varchar(64) not null, - PROC_INST_ID_ varchar(64) not null, - BUSINESS_KEY_ varchar(255), - PROC_DEF_ID_ varchar(64) not null, - START_TIME_ timestamp not null, - END_TIME_ timestamp, - DURATION_ bigint, - START_USER_ID_ varchar(255), - START_ACT_ID_ varchar(255), - END_ACT_ID_ varchar(255), - SUPER_PROCESS_INSTANCE_ID_ varchar(64), - DELETE_REASON_ varchar(4000), - TENANT_ID_ varchar(255) default '', - NAME_ varchar(255), - primary key (ID_), - unique (PROC_INST_ID_) -); - -CREATE TABLE workflow.ACT_HI_ACTINST ( - ID_ varchar(64) not null, - PROC_DEF_ID_ varchar(64) not null, - PROC_INST_ID_ varchar(64) not null, - EXECUTION_ID_ varchar(64) not null, - ACT_ID_ varchar(255) not null, - TASK_ID_ varchar(64), - CALL_PROC_INST_ID_ varchar(64), - ACT_NAME_ varchar(255), - ACT_TYPE_ varchar(255) not null, - ASSIGNEE_ varchar(255), - START_TIME_ timestamp not null, - END_TIME_ timestamp, - DURATION_ bigint, - TENANT_ID_ varchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_TASKINST ( - ID_ varchar(64) not null, - PROC_DEF_ID_ varchar(64), - TASK_DEF_KEY_ varchar(255), - PROC_INST_ID_ varchar(64), - EXECUTION_ID_ varchar(64), - NAME_ varchar(255), - PARENT_TASK_ID_ varchar(64), - DESCRIPTION_ varchar(4000), - OWNER_ varchar(255), - ASSIGNEE_ varchar(255), - START_TIME_ timestamp not null, - CLAIM_TIME_ timestamp, - END_TIME_ timestamp, - DURATION_ bigint, - DELETE_REASON_ varchar(4000), - PRIORITY_ integer, - DUE_DATE_ timestamp, - FORM_KEY_ varchar(255), - CATEGORY_ varchar(255), - TENANT_ID_ varchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_VARINST ( - ID_ varchar(64) not null, - PROC_INST_ID_ varchar(64), - EXECUTION_ID_ varchar(64), - TASK_ID_ varchar(64), - NAME_ varchar(255) not null, - VAR_TYPE_ varchar(100), - REV_ integer, - BYTEARRAY_ID_ varchar(64), - DOUBLE_ double precision, - LONG_ bigint, - TEXT_ varchar(4000), - TEXT2_ varchar(4000), - CREATE_TIME_ timestamp, - LAST_UPDATED_TIME_ timestamp, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_DETAIL ( - ID_ varchar(64) not null, - TYPE_ varchar(255) not null, - PROC_INST_ID_ varchar(64), - EXECUTION_ID_ varchar(64), - TASK_ID_ varchar(64), - ACT_INST_ID_ varchar(64), - NAME_ varchar(255) not null, - VAR_TYPE_ varchar(64), - REV_ integer, - TIME_ timestamp not null, - BYTEARRAY_ID_ varchar(64), - DOUBLE_ double precision, - LONG_ bigint, - TEXT_ varchar(4000), - TEXT2_ varchar(4000), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_COMMENT ( - ID_ varchar(64) not null, - TYPE_ varchar(255), - TIME_ timestamp not null, - USER_ID_ varchar(255), - TASK_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - ACTION_ varchar(255), - MESSAGE_ varchar(4000), - FULL_MSG_ bytea, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_ATTACHMENT ( - ID_ varchar(64) not null, - REV_ integer, - USER_ID_ varchar(255), - NAME_ varchar(255), - DESCRIPTION_ varchar(4000), - TYPE_ varchar(255), - TASK_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - URL_ varchar(4000), - CONTENT_ID_ varchar(64), - TIME_ timestamp, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_IDENTITYLINK ( - ID_ varchar(64), - GROUP_ID_ varchar(255), - TYPE_ varchar(255), - USER_ID_ varchar(255), - TASK_ID_ varchar(64), - PROC_INST_ID_ varchar(64), - primary key (ID_) -); - - -create index ACT_IDX_HI_PRO_INST_END on workflow.ACT_HI_PROCINST(END_TIME_); -create index ACT_IDX_HI_PRO_I_BUSKEY on workflow.ACT_HI_PROCINST(BUSINESS_KEY_); -create index ACT_IDX_HI_ACT_INST_START on workflow.ACT_HI_ACTINST(START_TIME_); -create index ACT_IDX_HI_ACT_INST_END on workflow.ACT_HI_ACTINST(END_TIME_); -create index ACT_IDX_HI_DETAIL_PROC_INST on workflow.ACT_HI_DETAIL(PROC_INST_ID_); -create index ACT_IDX_HI_DETAIL_ACT_INST on workflow.ACT_HI_DETAIL(ACT_INST_ID_); -create index ACT_IDX_HI_DETAIL_TIME on workflow.ACT_HI_DETAIL(TIME_); -create index ACT_IDX_HI_DETAIL_NAME on workflow.ACT_HI_DETAIL(NAME_); -create index ACT_IDX_HI_DETAIL_TASK_ID on workflow.ACT_HI_DETAIL(TASK_ID_); -create index ACT_IDX_HI_PROCVAR_PROC_INST on workflow.ACT_HI_VARINST(PROC_INST_ID_); -create index ACT_IDX_HI_PROCVAR_NAME_TYPE on workflow.ACT_HI_VARINST(NAME_, VAR_TYPE_); -create index ACT_IDX_HI_PROCVAR_TASK_ID on workflow.ACT_HI_VARINST(TASK_ID_); -create index ACT_IDX_HI_ACT_INST_PROCINST on workflow.ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); -create index ACT_IDX_HI_ACT_INST_EXEC on workflow.ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_); -create index ACT_IDX_HI_IDENT_LNK_USER on workflow.ACT_HI_IDENTITYLINK(USER_ID_); -create index ACT_IDX_HI_IDENT_LNK_TASK on workflow.ACT_HI_IDENTITYLINK(TASK_ID_); -create index ACT_IDX_HI_IDENT_LNK_PROCINST on workflow.ACT_HI_IDENTITYLINK(PROC_INST_ID_); - -/* workflow-15.10-15.20.sql */ - -/* - * Activiti BPM Platform - * Copyright 2010-2015 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ - -ALTER TABLE workflow.ACT_GE_BYTEARRAY - DROP constraint IF EXISTS ACT_FK_BYTEARR_DEPL; -ALTER TABLE workflow.ACT_GE_BYTEARRAY - add constraint ACT_FK_BYTEARR_DEPL - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - DROP constraint IF EXISTS ACT_FK_TSKASS_TASK; -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_TSKASS_TASK - foreign key (TASK_ID_) - references workflow.ACT_RU_TASK (ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - DROP constraint IF EXISTS ACT_FK_ATHRZ_PROCEDEF; -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_ATHRZ_PROCEDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - DROP constraint IF EXISTS ACT_FK_IDL_PROCINST; -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_IDL_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RU_TASK - DROP constraint IF EXISTS ACT_FK_TASK_EXE; -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_EXE - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION (ID_) - ON DELETE NO ACTION; - -ALTER TABLE workflow.ACT_RU_TASK - DROP constraint IF EXISTS ACT_FK_TASK_PROCINST; -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RU_VARIABLE - DROP constraint IF EXISTS ACT_FK_VAR_PROCINST; -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION(ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RU_EVENT_SUBSCR - DROP constraint IF EXISTS ACT_FK_EVENT_EXEC; -ALTER TABLE workflow.ACT_RU_EVENT_SUBSCR - add constraint ACT_FK_EVENT_EXEC - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION(ID_) - ON DELETE CASCADE; - -ALTER TABLE workflow.ACT_RE_MODEL - DROP constraint IF EXISTS ACT_FK_MODEL_DEPLOYMENT; -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_DEPLOYMENT - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_) - ON DELETE CASCADE; - -/* workflow-16.10-16.20.sql */ - -/* - * Activiti BPM Platform - * Copyright 2010-2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ - -DELETE FROM workflow.act_ru_variable WHERE name_ = 'processInstanceUrl'; -DELETE FROM workflow.act_hi_varinst WHERE name_ = 'processInstanceUrl'; -DELETE FROM workflow.act_ge_bytearray WHERE name_ LIKE '%var-processInstanceUrl'; - -DELETE FROM workflow.act_hi_detail WHERE name_ = 'processInstanceUrl'; - -/* - * Activiti BPM Platform - * Copyright 2010-2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ -UPDATE workflow.ACT_GE_PROPERTY SET VALUE_ = '5.20.0.2' WHERE NAME_ = 'schema.version'; - -CREATE INDEX ACT_IDX_HI_TASK_INST_PROCINST ON workflow.ACT_HI_TASKINST(PROC_INST_ID_); - -create table workflow.ACT_PROCDEF_INFO ( - ID_ varchar(64) not null, - PROC_DEF_ID_ varchar(64) not null, - REV_ integer, - INFO_JSON_ID_ varchar(64), - primary key (ID_) -); - -create index ACT_IDX_PROCDEF_INFO_JSON on workflow.ACT_PROCDEF_INFO(INFO_JSON_ID_); -alter table workflow.ACT_PROCDEF_INFO - add constraint ACT_FK_INFO_JSON_BA - foreign key (INFO_JSON_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -create index ACT_IDX_PROCDEF_INFO_PROC on workflow.ACT_PROCDEF_INFO(PROC_DEF_ID_); -alter table workflow.ACT_PROCDEF_INFO - add constraint ACT_FK_INFO_PROCDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -alter table workflow.ACT_PROCDEF_INFO - add constraint ACT_UNIQ_INFO_PROCDEF - unique (PROC_DEF_ID_); - -update workflow.ACT_RU_EVENT_SUBSCR set PROC_DEF_ID_ = CONFIGURATION_ where EVENT_TYPE_ = 'message' and PROC_INST_ID_ is null and EXECUTION_ID_ is null; - -/* workflow-16.20-16.30.sql */ - -CREATE INDEX IDX_ACT_HI_PROCINST_STARTTIME_PROCINST ON workflow.ACT_HI_PROCINST -(START_TIME_, PROC_INST_ID_); - -CREATE INDEX IDX_ACT_HI_VARINST_NAME_LONG ON workflow.ACT_HI_VARINST -(NAME_, LONG_); - -CREATE INDEX IDX_ACT_HI_VARINST_NAME_TEXT ON workflow.ACT_HI_VARINST -(NAME_, TEXT_); - -CREATE INDEX IDX_ACT_HI_VARINST_PROCINST_NAME_LONG ON workflow.ACT_HI_VARINST -(PROC_INST_ID_, NAME_, LONG_); - -CREATE INDEX IDX_ACT_HI_VARINST_PROCINST_NAME_TEXT ON workflow.ACT_HI_VARINST -(PROC_INST_ID_, NAME_, TEXT_); - -CREATE INDEX IDX_ACT_RU_TASK_PROCINST_TASKDEFKEY ON workflow.ACT_RU_TASK -(PROC_INST_ID_, TASK_DEF_KEY_); - -CREATE INDEX IDX_ACT_RU_VARIABLE_PROCINST_NAME_LONG ON workflow.ACT_RU_VARIABLE -(NAME_, PROC_INST_ID_, LONG_); - -/* workflow-17.10-17.20.sql */ - --- Change the resource and diagram resource names from the old form of an absolute filepath to new form of moduleName:filename -update workflow.ACT_RE_PROCDEF -set resource_name_ = right(category_, strpos(reverse(category_), ':') - 1) || ':' || - right(resource_name_, strpos(reverse(replace(resource_name_, '\', '/')), '/') - 1) - , dgrm_resource_name_ = right(category_, strpos(reverse(category_), ':') - 1) || ':' || - right(dgrm_resource_name_, strpos(reverse(replace(dgrm_resource_name_, '\', '/')), '/') - 1) -where strpos(replace(resource_name_, '\', '/'), '/') != 0; \ No newline at end of file diff --git a/resources/schemas/dbscripts/sqlserver/workflow-0.00-17.20.sql b/resources/schemas/dbscripts/sqlserver/workflow-0.00-17.20.sql deleted file mode 100644 index 3fc7123..0000000 --- a/resources/schemas/dbscripts/sqlserver/workflow-0.00-17.20.sql +++ /dev/null @@ -1,623 +0,0 @@ -/* workflow-00.00-15.10.sql */ - -/* - * Activiti BPM Platform - * Copyright 2010-2014 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ --- @SkipLabKeySyntaxCheck --- Create schema, tables, indexes, and constraints used for Workflow module here --- All SQL VIEW definitions should be created in workflow-create.sql and dropped in workflow-drop.sql -CREATE SCHEMA workflow; -GO - -CREATE TABLE workflow.ACT_GE_PROPERTY ( - NAME_ nvarchar(64), - VALUE_ nvarchar(300), - REV_ int, - primary key (NAME_) -); - -INSERT INTO workflow.ACT_GE_PROPERTY -values ('schema.version', '5.17.0.2', 1); - -INSERT INTO workflow.ACT_GE_PROPERTY -values ('schema.history', 'create(5.17.0.2)', 1); - -INSERT INTO workflow.ACT_GE_PROPERTY -values ('next.dbid', '1', 1); - -CREATE TABLE workflow.ACT_GE_BYTEARRAY ( - ID_ nvarchar(64), - REV_ int, - NAME_ nvarchar(255), - DEPLOYMENT_ID_ nvarchar(64), - BYTES_ varbinary(max), - GENERATED_ tinyint, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RE_DEPLOYMENT ( - ID_ nvarchar(64), - NAME_ nvarchar(255), - CATEGORY_ nvarchar(255), - TENANT_ID_ nvarchar(255) default '', - DEPLOY_TIME_ datetime, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RE_MODEL ( - ID_ nvarchar(64) not null, - REV_ int, - NAME_ nvarchar(255), - KEY_ nvarchar(255), - CATEGORY_ nvarchar(255), - CREATE_TIME_ datetime, - LAST_UPDATE_TIME_ datetime, - VERSION_ int, - META_INFO_ nvarchar(4000), - DEPLOYMENT_ID_ nvarchar(64), - EDITOR_SOURCE_VALUE_ID_ nvarchar(64), - EDITOR_SOURCE_EXTRA_VALUE_ID_ nvarchar(64), - TENANT_ID_ nvarchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_EXECUTION ( - ID_ nvarchar(64), - REV_ int, - PROC_INST_ID_ nvarchar(64), - BUSINESS_KEY_ nvarchar(255), - PARENT_ID_ nvarchar(64), - PROC_DEF_ID_ nvarchar(64), - SUPER_EXEC_ nvarchar(64), - ACT_ID_ nvarchar(255), - IS_ACTIVE_ tinyint, - IS_CONCURRENT_ tinyint, - IS_SCOPE_ tinyint, - IS_EVENT_SCOPE_ tinyint, - SUSPENSION_STATE_ tinyint, - CACHED_ENT_STATE_ int, - TENANT_ID_ nvarchar(255) default '', - NAME_ nvarchar(255), - LOCK_TIME_ datetime, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_JOB ( - ID_ nvarchar(64) NOT NULL, - REV_ int, - TYPE_ nvarchar(255) NOT NULL, - LOCK_EXP_TIME_ datetime, - LOCK_OWNER_ nvarchar(255), - EXCLUSIVE_ bit, - EXECUTION_ID_ nvarchar(64), - PROCESS_INSTANCE_ID_ nvarchar(64), - PROC_DEF_ID_ nvarchar(64), - RETRIES_ int, - EXCEPTION_STACK_ID_ nvarchar(64), - EXCEPTION_MSG_ nvarchar(4000), - DUEDATE_ datetime NULL, - REPEAT_ nvarchar(255), - HANDLER_TYPE_ nvarchar(255), - HANDLER_CFG_ nvarchar(4000), - TENANT_ID_ nvarchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RE_PROCDEF ( - ID_ nvarchar(64) not null, - REV_ int, - CATEGORY_ nvarchar(255), - NAME_ nvarchar(255), - KEY_ nvarchar(255) not null, - VERSION_ int not null, - DEPLOYMENT_ID_ nvarchar(64), - RESOURCE_NAME_ nvarchar(4000), - DGRM_RESOURCE_NAME_ nvarchar(4000), - DESCRIPTION_ nvarchar(4000), - HAS_START_FORM_KEY_ tinyint, - HAS_GRAPHICAL_NOTATION_ tinyint, - SUSPENSION_STATE_ tinyint, - TENANT_ID_ nvarchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_TASK ( - ID_ nvarchar(64), - REV_ int, - EXECUTION_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - PROC_DEF_ID_ nvarchar(64), - NAME_ nvarchar(255), - PARENT_TASK_ID_ nvarchar(64), - DESCRIPTION_ nvarchar(4000), - TASK_DEF_KEY_ nvarchar(255), - OWNER_ nvarchar(255), - ASSIGNEE_ nvarchar(255), - DELEGATION_ nvarchar(64), - PRIORITY_ int, - CREATE_TIME_ datetime, - DUE_DATE_ datetime, - CATEGORY_ nvarchar(255), - SUSPENSION_STATE_ int, - TENANT_ID_ nvarchar(255) default '', - FORM_KEY_ nvarchar(255), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_IDENTITYLINK ( - ID_ nvarchar(64), - REV_ int, - GROUP_ID_ nvarchar(255), - TYPE_ nvarchar(255), - USER_ID_ nvarchar(255), - TASK_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - PROC_DEF_ID_ nvarchar(64), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_VARIABLE ( - ID_ nvarchar(64) not null, - REV_ int, - TYPE_ nvarchar(255) not null, - NAME_ nvarchar(255) not null, - EXECUTION_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - TASK_ID_ nvarchar(64), - BYTEARRAY_ID_ nvarchar(64), - DOUBLE_ double precision, - LONG_ numeric(19,0), - TEXT_ nvarchar(4000), - TEXT2_ nvarchar(4000), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_RU_EVENT_SUBSCR ( - ID_ nvarchar(64) not null, - REV_ int, - EVENT_TYPE_ nvarchar(255) not null, - EVENT_NAME_ nvarchar(255), - EXECUTION_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - ACTIVITY_ID_ nvarchar(64), - CONFIGURATION_ nvarchar(255), - CREATED_ datetime not null, - PROC_DEF_ID_ nvarchar(64), - TENANT_ID_ nvarchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_EVT_LOG ( - LOG_NR_ numeric(19,0) IDENTITY(1,1), - TYPE_ nvarchar(64), - PROC_DEF_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - EXECUTION_ID_ nvarchar(64), - TASK_ID_ nvarchar(64), - TIME_STAMP_ datetime not null, - USER_ID_ nvarchar(255), - DATA_ varbinary(max), - LOCK_OWNER_ nvarchar(255), - LOCK_TIME_ datetime null, - IS_PROCESSED_ tinyint default 0, - primary key (LOG_NR_) -); - -create index ACT_IDX_EXEC_BUSKEY on workflow.ACT_RU_EXECUTION(BUSINESS_KEY_); -create index ACT_IDX_TASK_CREATE on workflow.ACT_RU_TASK(CREATE_TIME_); -create index ACT_IDX_IDENT_LNK_USER on workflow.ACT_RU_IDENTITYLINK(USER_ID_); -create index ACT_IDX_IDENT_LNK_GROUP on workflow.ACT_RU_IDENTITYLINK(GROUP_ID_); -create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on workflow.ACT_RU_EVENT_SUBSCR(CONFIGURATION_); -create index ACT_IDX_VARIABLE_TASK_ID on workflow.ACT_RU_VARIABLE(TASK_ID_); -create index ACT_IDX_ATHRZ_PROCEDEF on workflow.ACT_RU_IDENTITYLINK(PROC_DEF_ID_); -create index ACT_IDX_EXECUTION_PROC on workflow.ACT_RU_EXECUTION(PROC_DEF_ID_); -create index ACT_IDX_EXECUTION_PARENT on workflow.ACT_RU_EXECUTION(PARENT_ID_); -create index ACT_IDX_EXECUTION_SUPER on workflow.ACT_RU_EXECUTION(SUPER_EXEC_); -create index ACT_IDX_EXECUTION_IDANDREV on workflow.ACT_RU_EXECUTION(ID_, REV_); -create index ACT_IDX_VARIABLE_BA on workflow.ACT_RU_VARIABLE(BYTEARRAY_ID_); -create index ACT_IDX_VARIABLE_EXEC on workflow.ACT_RU_VARIABLE(EXECUTION_ID_); -create index ACT_IDX_VARIABLE_PROCINST on workflow.ACT_RU_VARIABLE(PROC_INST_ID_); -create index ACT_IDX_IDENT_LNK_TASK on workflow.ACT_RU_IDENTITYLINK(TASK_ID_); -create index ACT_IDX_IDENT_LNK_PROCINST on workflow.ACT_RU_IDENTITYLINK(PROC_INST_ID_); -create index ACT_IDX_TASK_EXEC on workflow.ACT_RU_TASK(EXECUTION_ID_); -create index ACT_IDX_TASK_PROCINST on workflow.ACT_RU_TASK(PROC_INST_ID_); -create index ACT_IDX_EXEC_PROC_INST_ID on workflow.ACT_RU_EXECUTION(PROC_INST_ID_); -create index ACT_IDX_TASK_PROC_DEF_ID on workflow.ACT_RU_TASK(PROC_DEF_ID_); -create index ACT_IDX_EVENT_SUBSCR_EXEC_ID on workflow.ACT_RU_EVENT_SUBSCR(EXECUTION_ID_); -create index ACT_IDX_JOB_EXCEPTION_STACK_ID on workflow.ACT_RU_JOB(EXCEPTION_STACK_ID_); - -ALTER TABLE workflow.ACT_GE_BYTEARRAY - add constraint ACT_FK_BYTEARR_DEPL - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_); - -ALTER TABLE workflow.ACT_RE_PROCDEF - add constraint ACT_UNIQ_PROCDEF - unique (KEY_,VERSION_, TENANT_ID_); - -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_PARENT - foreign key (PARENT_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_SUPER - foreign key (SUPER_EXEC_) - references workflow.ACT_RU_EXECUTION (ID_); - -ALTER TABLE workflow.ACT_RU_EXECUTION - add constraint ACT_FK_EXE_PROCDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_TSKASS_TASK - foreign key (TASK_ID_) - references workflow.ACT_RU_TASK (ID_); - -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_ATHRZ_PROCEDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_IDL_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_EXE - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -ALTER TABLE workflow.ACT_RU_TASK - add constraint ACT_FK_TASK_PROCDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_EXE - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION (ID_); - -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION(ID_); - -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_BYTEARRAY - foreign key (BYTEARRAY_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -ALTER TABLE workflow.ACT_RU_JOB - add constraint ACT_FK_JOB_EXCEPTION - foreign key (EXCEPTION_STACK_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -ALTER TABLE workflow.ACT_RU_EVENT_SUBSCR - add constraint ACT_FK_EVENT_EXEC - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION(ID_); - -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_SOURCE - foreign key (EDITOR_SOURCE_VALUE_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_SOURCE_EXTRA - foreign key (EDITOR_SOURCE_EXTRA_VALUE_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_DEPLOYMENT - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_); - -CREATE TABLE workflow.ACT_HI_PROCINST ( - ID_ nvarchar(64) not null, - PROC_INST_ID_ nvarchar(64) not null, - BUSINESS_KEY_ nvarchar(255), - PROC_DEF_ID_ nvarchar(64) not null, - START_TIME_ datetime not null, - END_TIME_ datetime, - DURATION_ numeric(19,0), - START_USER_ID_ nvarchar(255), - START_ACT_ID_ nvarchar(255), - END_ACT_ID_ nvarchar(255), - SUPER_PROCESS_INSTANCE_ID_ nvarchar(64), - DELETE_REASON_ nvarchar(4000), - TENANT_ID_ nvarchar(255) default '', - NAME_ nvarchar(255), - primary key (ID_), - unique (PROC_INST_ID_) -); - -CREATE TABLE workflow.ACT_HI_ACTINST ( - ID_ nvarchar(64) not null, - PROC_DEF_ID_ nvarchar(64) not null, - PROC_INST_ID_ nvarchar(64) not null, - EXECUTION_ID_ nvarchar(64) not null, - ACT_ID_ nvarchar(255) not null, - TASK_ID_ nvarchar(64), - CALL_PROC_INST_ID_ nvarchar(64), - ACT_NAME_ nvarchar(255), - ACT_TYPE_ nvarchar(255) not null, - ASSIGNEE_ nvarchar(255), - START_TIME_ datetime not null, - END_TIME_ datetime, - DURATION_ numeric(19,0), - TENANT_ID_ nvarchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_TASKINST ( - ID_ nvarchar(64) not null, - PROC_DEF_ID_ nvarchar(64), - TASK_DEF_KEY_ nvarchar(255), - PROC_INST_ID_ nvarchar(64), - EXECUTION_ID_ nvarchar(64), - NAME_ nvarchar(255), - PARENT_TASK_ID_ nvarchar(64), - DESCRIPTION_ nvarchar(4000), - OWNER_ nvarchar(255), - ASSIGNEE_ nvarchar(255), - START_TIME_ datetime not null, - CLAIM_TIME_ datetime, - END_TIME_ datetime, - DURATION_ numeric(19,0), - DELETE_REASON_ nvarchar(4000), - PRIORITY_ int, - DUE_DATE_ datetime, - FORM_KEY_ nvarchar(255), - CATEGORY_ nvarchar(255), - TENANT_ID_ nvarchar(255) default '', - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_VARINST ( - ID_ nvarchar(64) not null, - PROC_INST_ID_ nvarchar(64), - EXECUTION_ID_ nvarchar(64), - TASK_ID_ nvarchar(64), - NAME_ nvarchar(255) not null, - VAR_TYPE_ nvarchar(100), - REV_ int, - BYTEARRAY_ID_ nvarchar(64), - DOUBLE_ double precision, - LONG_ numeric(19,0), - TEXT_ nvarchar(4000), - TEXT2_ nvarchar(4000), - CREATE_TIME_ datetime, - LAST_UPDATED_TIME_ datetime, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_DETAIL ( - ID_ nvarchar(64) not null, - TYPE_ nvarchar(255) not null, - PROC_INST_ID_ nvarchar(64), - EXECUTION_ID_ nvarchar(64), - TASK_ID_ nvarchar(64), - ACT_INST_ID_ nvarchar(64), - NAME_ nvarchar(255) not null, - VAR_TYPE_ nvarchar(255), - REV_ int, - TIME_ datetime not null, - BYTEARRAY_ID_ nvarchar(64), - DOUBLE_ double precision, - LONG_ numeric(19,0), - TEXT_ nvarchar(4000), - TEXT2_ nvarchar(4000), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_COMMENT ( - ID_ nvarchar(64) not null, - TYPE_ nvarchar(255), - TIME_ datetime not null, - USER_ID_ nvarchar(255), - TASK_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - ACTION_ nvarchar(255), - MESSAGE_ nvarchar(4000), - FULL_MSG_ varbinary(max), - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_ATTACHMENT ( - ID_ nvarchar(64) not null, - REV_ integer, - USER_ID_ nvarchar(255), - NAME_ nvarchar(255), - DESCRIPTION_ nvarchar(4000), - TYPE_ nvarchar(255), - TASK_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - URL_ nvarchar(4000), - CONTENT_ID_ nvarchar(64), - TIME_ datetime, - primary key (ID_) -); - -CREATE TABLE workflow.ACT_HI_IDENTITYLINK ( - ID_ nvarchar(64), - GROUP_ID_ nvarchar(255), - TYPE_ nvarchar(255), - USER_ID_ nvarchar(255), - TASK_ID_ nvarchar(64), - PROC_INST_ID_ nvarchar(64), - primary key (ID_) -); - - -create index ACT_IDX_HI_PRO_INST_END on workflow.ACT_HI_PROCINST(END_TIME_); -create index ACT_IDX_HI_PRO_I_BUSKEY on workflow.ACT_HI_PROCINST(BUSINESS_KEY_); -create index ACT_IDX_HI_ACT_INST_START on workflow.ACT_HI_ACTINST(START_TIME_); -create index ACT_IDX_HI_ACT_INST_END on workflow.ACT_HI_ACTINST(END_TIME_); -create index ACT_IDX_HI_DETAIL_PROC_INST on workflow.ACT_HI_DETAIL(PROC_INST_ID_); -create index ACT_IDX_HI_DETAIL_ACT_INST on workflow.ACT_HI_DETAIL(ACT_INST_ID_); -create index ACT_IDX_HI_DETAIL_TIME on workflow.ACT_HI_DETAIL(TIME_); -create index ACT_IDX_HI_DETAIL_NAME on workflow.ACT_HI_DETAIL(NAME_); -create index ACT_IDX_HI_DETAIL_TASK_ID on workflow.ACT_HI_DETAIL(TASK_ID_); -create index ACT_IDX_HI_PROCVAR_PROC_INST on workflow.ACT_HI_VARINST(PROC_INST_ID_); -create index ACT_IDX_HI_PROCVAR_NAME_TYPE on workflow.ACT_HI_VARINST(NAME_, VAR_TYPE_); -create index ACT_IDX_HI_PROCVAR_TASK_ID on workflow.ACT_HI_VARINST(TASK_ID_); -create index ACT_IDX_HI_ACT_INST_PROCINST on workflow.ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); -create index ACT_IDX_HI_ACT_INST_EXEC on workflow.ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_); -create index ACT_IDX_HI_IDENT_LNK_USER on workflow.ACT_HI_IDENTITYLINK(USER_ID_); -create index ACT_IDX_HI_IDENT_LNK_TASK on workflow.ACT_HI_IDENTITYLINK(TASK_ID_); -create index ACT_IDX_HI_IDENT_LNK_PROCINST on workflow.ACT_HI_IDENTITYLINK(PROC_INST_ID_); - -/* workflow-15.10-15.20.sql */ - -/* - * Activiti BPM Platform - * Copyright 2010-2015 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ - -EXEC core.fn_dropifexists 'ACT_GE_BYTEARRAY', 'workflow', 'CONSTRAINT', 'ACT_FK_BYTEARR_DEPL' ; - -ALTER TABLE workflow.ACT_GE_BYTEARRAY - add constraint ACT_FK_BYTEARR_DEPL - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_) - ON DELETE CASCADE; - -EXEC core.fn_dropifexists 'ACT_RU_IDENTITYLINK', 'workflow', 'CONSTRAINT', 'ACT_FK_TSKASS_TASK'; -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_TSKASS_TASK - foreign key (TASK_ID_) - references workflow.ACT_RU_TASK (ID_) - ON DELETE CASCADE; - -EXEC core.fn_dropifexists 'ACT_RU_IDENTITYLINK', 'workflow', 'CONSTRAINT', 'ACT_FK_ATHRZ_PROCEDEF'; -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_ATHRZ_PROCEDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_) - ON DELETE CASCADE; - -EXEC core.fn_dropifexists 'ACT_RU_IDENTITYLINK', 'workflow', 'CONSTRAINT', 'ACT_FK_IDL_PROCINST'; -ALTER TABLE workflow.ACT_RU_IDENTITYLINK - add constraint ACT_FK_IDL_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION (ID_) - ON DELETE CASCADE; - - -EXEC core.fn_dropifexists 'ACT_RU_VARIABLE', 'workflow', 'CONSTRAINT', 'ACT_FK_VAR_PROCINST'; -ALTER TABLE workflow.ACT_RU_VARIABLE - add constraint ACT_FK_VAR_PROCINST - foreign key (PROC_INST_ID_) - references workflow.ACT_RU_EXECUTION(ID_) - ON DELETE CASCADE; - -EXEC core.fn_dropifexists 'ACT_RU_EVENT_SUBSCR', 'workflow', 'CONSTRAINT', 'ACT_FK_EVENT_EXEC'; -ALTER TABLE workflow.ACT_RU_EVENT_SUBSCR - add constraint ACT_FK_EVENT_EXEC - foreign key (EXECUTION_ID_) - references workflow.ACT_RU_EXECUTION(ID_) - ON DELETE CASCADE; - -EXEC core.fn_dropifexists 'ACT_RE_MODEL', 'workflow', 'CONSTRAINT', 'ACT_FK_MODEL_DEPLOYMENT'; -ALTER TABLE workflow.ACT_RE_MODEL - add constraint ACT_FK_MODEL_DEPLOYMENT - foreign key (DEPLOYMENT_ID_) - references workflow.ACT_RE_DEPLOYMENT (ID_) - ON DELETE CASCADE; - -/* workflow-16.10-16.20.sql */ - -/* - * Activiti BPM Platform - * Copyright 2010-2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ - -DELETE FROM workflow.act_ru_variable WHERE name_ = 'processInstanceUrl'; -DELETE FROM workflow.act_hi_varinst WHERE name_ = 'processInstanceUrl'; -DELETE FROM workflow.act_ge_bytearray WHERE name_ LIKE '%var-processInstanceUrl'; - -DELETE FROM workflow.act_hi_detail WHERE name_ = 'processInstanceUrl'; - -/* - * Activiti BPM Platform - * Copyright 2010-2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0- http://www.apache.org/licenses/LICENSE-2.0 - */ -update workflow.ACT_GE_PROPERTY set VALUE_ = '5.20.0.2' where NAME_ = 'schema.version'; - -create index ACT_IDX_HI_TASK_INST_PROCINST on workflow.ACT_HI_TASKINST(PROC_INST_ID_); - -create table workflow.ACT_PROCDEF_INFO ( - ID_ nvarchar(64) not null, - PROC_DEF_ID_ nvarchar(64) not null, - REV_ int, - INFO_JSON_ID_ nvarchar(64), - primary key (ID_) -); - -create index ACT_IDX_INFO_PROCDEF on workflow.ACT_PROCDEF_INFO(PROC_DEF_ID_); - -alter table workflow.ACT_PROCDEF_INFO - add constraint ACT_FK_INFO_JSON_BA - foreign key (INFO_JSON_ID_) - references workflow.ACT_GE_BYTEARRAY (ID_); - -alter table workflow.ACT_PROCDEF_INFO - add constraint ACT_FK_INFO_PROCDEF - foreign key (PROC_DEF_ID_) - references workflow.ACT_RE_PROCDEF (ID_); - -alter table workflow.ACT_PROCDEF_INFO - add constraint ACT_UNIQ_INFO_PROCDEF - unique (PROC_DEF_ID_); - -update workflow.ACT_RU_EVENT_SUBSCR set PROC_DEF_ID_ = CONFIGURATION_ where EVENT_TYPE_ = 'message' and PROC_INST_ID_ is null and EXECUTION_ID_ is null; - -/* workflow-16.20-16.30.sql */ - -CREATE NONCLUSTERED INDEX IDX_ACT_HI_PROCINST_STARTTIME_PROCINST ON workflow.ACT_HI_PROCINST -(START_TIME_, PROC_INST_ID_); - -CREATE NONCLUSTERED INDEX IDX_ACT_HI_VARINST_NAME_LONG ON workflow.ACT_HI_VARINST -(NAME_, LONG_); - -CREATE NONCLUSTERED INDEX IDX_ACT_HI_VARINST_NAME_TEXT ON workflow.ACT_HI_VARINST -(NAME_, TEXT_); - -CREATE NONCLUSTERED INDEX IDX_ACT_HI_VARINST_PROCINST_NAME_LONG ON workflow.ACT_HI_VARINST -(PROC_INST_ID_, NAME_, LONG_); - -CREATE NONCLUSTERED INDEX IDX_ACT_HI_VARINST_PROCINST_NAME_TEXT ON workflow.ACT_HI_VARINST -(PROC_INST_ID_, NAME_, TEXT_); - -CREATE NONCLUSTERED INDEX IDX_ACT_RU_TASK_PROCINST_TASKDEFKEY ON workflow.ACT_RU_TASK -(PROC_INST_ID_, TASK_DEF_KEY_); - -CREATE NONCLUSTERED INDEX IDX_ACT_RU_VARIABLE_PROCINST_NAME_LONG ON workflow.ACT_RU_VARIABLE -(NAME_, PROC_INST_ID_, LONG_); - -/* workflow-17.10-17.20.sql */ - --- Change the resource and diagram resource names from the old form of an absolute filepath to new form of moduleName:filename -update workflow.ACT_RE_PROCDEF -set resource_name_ = right(category_, charindex(':', reverse(category_)) - 1) + ':' + - right(resource_name_, charindex('/', reverse(replace(resource_name_, '\', '/'))) - 1) - , dgrm_resource_name_ = right(category_, charindex(':', reverse(category_)) - 1) + ':' + - right(dgrm_resource_name_, charindex('/', reverse(replace(dgrm_resource_name_, '\', '/'))) - 1) -where charindex('/', replace(resource_name_, '\', '/')) != 0; \ No newline at end of file diff --git a/resources/schemas/workflow.xml b/resources/schemas/workflow.xml deleted file mode 100644 index 5ccb3dc..0000000 --- a/resources/schemas/workflow.xml +++ /dev/null @@ -1,987 +0,0 @@ - - - - - - Id - - - Type - - - Time - - - User Id - - UserId - Users - core - - - - Task Id - - - Process Instance Id - - id_ - ACT_HI_PROCINST - workflow - - - - Action - - - Message - - - Full Message - - -
- - - - Id - - - Process Definition Id - - id_ - ACT_RE_PROCDEF - workflow - key_ - - - - Task Definition Key - - - Process Instance Id - - id_ - ACT_HI_PROCINST - workflow - - - - Execution Id - - - Name - - - Parent Task Id - - - Description - - - - Owner - - UserId - Users - core - - - - Assignee - - UserId - Users - core - - - - Start Time - - - Claim Time - - - End Time - - - Duration - - - Delete Reason - - - Priority - - - Due Date - - - Form Key - - - Category - - - Container - - -
- - - - Id - - - Revision - - - Type - - - Lock Expiration Time - - - Lock Owner - - - Exclusive - - - Execution Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Instance Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Definition Id - - - Retries - - - Exception Stack Id - - - Exception Message - - - Due Date - - - Repeat - - - Handler Type - - - Handler Config - - - Container - - -
- - - - Task Details - - - Revision - - - Execution Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Instance Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Definition Id - - id_ - ACT_RE_PROCDEF - workflow - key_ - - - - Name - - - Parent Task - - - Description - - - Task Definition Key - - - Owner - - UserId - Users - core - - - - Assignee - - UserId - Users - core - - - - Delegation State - - - Priority - - - Created - - - Due Date - - - Category - - - Suspension State - - - Container - - - Form Key - - -
- - - - RowId - - - Name - - - Category - - - Container - - - Deployed - - -
- - - - Name - - - Value - - - Revision - - -
- - - - Id - - - Revision - - - Event Type - - - Event Name - - - Execution Id - - - Process Instance Id - - - Activity Id - - - Configuration - - - Created - - - Process Definition Id - - - Container - - -
- - - - Id - - - Process Definition Id - - - Process Instance Id - - - Execution Id - - - Activity Id - - - Task Id - - - Call Process Instance Id - - - Activity Name - - - Activity Type - - - Assignee - - UserId - Users - core - - - - Start Time - - - End Time - - - Duration - - - Container - - -
- - - - RowId - - - Revision - - - Type - - - Name - - - Execution Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Instance Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Task Id - - id_ - ACT_RU_TASK - workflow - - - - Bytearray Id - - - Double - - - Long - - - Text - - - Text 2 - - -
- - - - RowId - - - Group - - UserId - principals - core - - - - Type - - - User Id - - UserId - Users - core - - - - Task Id - - - Process Instance Id - - -
- - - - RowId - - - Revision - - - Process Instance Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Business Key - - - Parent Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Definition Id - - id_ - ACT_RE_PROCDEF - workflow - key_ - - - - - Activity Id - - - Is Active - - - Is Concurrent - - - Is Scope - - - Is Event Scope - - - Suspension State - - - Cached Entity State - - - Container - - - Name - - - Lock Time - - -
- - - - Id - - - Revision - - - Name - - - Deployment Id - - - Bytes - - - Generated - - -
- - - - Id - - - Revision - - - Name - - - Key - - - Category - - - Create Time - - - Last Update Time - - - Version - - - Meta info - - - Deployment Id - - - Editor Source Value Id - - - Editor Source Extra Value Id - - - Container - - -
- - - - RowId - - - Revision - - - Category - - - Name - - - Key - - - Version - - - Deployment Id - - id_ - act_re_deployment - workflow - deploymentKey_ - - - - Resource Name - - - Diagram Resource Name - - - Description - - - Has Start Form Key - - - Has Graphical Notation - - - Suspension State - - - Container - - -
- - - - Id - - - Process Instance Id - - - Business Key - - - Process Definition Id - - - Start Time - - - End Time - - - Duration - - - Start User - - UserId - Users - core - - - - Start Activity Key - - - End Activity Key - - - Super Process Instance Id - - - Delete Reason - - - Container - - - Name - - -
- - - - Id - - - Revision - - - User - - UserId - Users - core - - - - Name - - - Description - - - Type - - - Task Id - - - Process Instance Id - - - URL - - - Content Id - - - Time - - -
- - - - - Type - - - Process Definition Id - - - Process Instance Id - - - Execution Id - - - Task Id - - - Time Stamp - - - User - - UserId - Users - core - - - - Data - - - Lock Owner - - - Lock Time - - - Is Processed - - -
- - - - Id - - - Process Instance Id - - - Execution Id - - - Task Id - - - Name - - - Variable Type - - - Revision - - - Bytearray Id - - - Double - - - Long - - - Text - - - Text2 - - - Create Time - - - Last Updated Time - - -
- - - - RowId - - - Revision - - - Group - - UserId - Principals - core - - - - Type - - - User - - UserId - Users - core - - - - Task Id - - id_ - act_ru_task - workflow - - - - Process Instance Id - - id_ - ACT_RU_EXECUTION - workflow - - - - Process Definition Id - - id_ - ACT_RE_PROCDEF - workflow - key_ - - - -
- - - - Id - - - Type - - - Process Instance Id - - - Execution Id - - - Task Id - - - Activity Instance Id - - - Name - - - Variable Type - - - Revision - - - Time - - - Bytearray Id - - id_ - act_ge_bytearray - workflow - - - - Double - - - Long - - - Text - - - Text2 - - -
- - - - Id - - - Process Definition Id - - id_ - ACT_RE_PROCDEF - workflow - key_ - - - - Revision - - - Info JSON Id - - -
-
diff --git a/resources/workflow/model/submitForApprovalWithRetry.bpmn20.xml b/resources/workflow/model/submitForApprovalWithRetry.bpmn20.xml deleted file mode 100644 index 5ea58b8..0000000 --- a/resources/workflow/model/submitForApprovalWithRetry.bpmn20.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - User makes a request to an approver, with the ability to resubmit or abort a request after denial. - - - - - - - User makes a request that requires approval - - - - - - - - - - - Review user request and approve or deny - - - ${decision == 'approve'} - - - ${decision != 'approve'} - - - Request revised - - - ${initiatorId} - - - - - - - - User's request is fulfilled - - - ${userId} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/workflow/model/submitForApprovalWithoutRetry.bpmn20.xml b/resources/workflow/model/submitForApprovalWithoutRetry.bpmn20.xml deleted file mode 100644 index 395e453..0000000 --- a/resources/workflow/model/submitForApprovalWithoutRetry.bpmn20.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - User submits a request to a group or user for approval. - - User makes a request requiring approval - - - User makes a request that requires approval - - - - User's request is fulfilled - - - Review user request and approve or deny - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/org/labkey/workflow/PermissionsHandlerImpl.java b/src/org/labkey/workflow/PermissionsHandlerImpl.java deleted file mode 100644 index 3412576..0000000 --- a/src/org/labkey/workflow/PermissionsHandlerImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow; - -import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.Container; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.security.permissions.Permission; -import org.labkey.api.workflow.PermissionsHandler; -import org.labkey.api.workflow.WorkflowTask; - -import java.util.Collections; -import java.util.Set; - -/** - * Created by susanh on 5/27/15. - */ -public class PermissionsHandlerImpl extends PermissionsHandler -{ - - public PermissionsHandlerImpl(@NotNull User user, @NotNull Container container) - { - super (user, container); - } - - - @Override - public SimpleFilter getProcessListFilter() - { - SimpleFilter filter = new SimpleFilter(); - if (!_hasAdmin) // admins can see everything by default - { - filter.addClause(getInitiatorCondition()); - } - return filter; - } - - @Override - public SimpleFilter getTaskListFilter() - { - SimpleFilter filter = new SimpleFilter(); - if (!_hasAdmin) // admins can see everything by default - { - filter.addClause(getAssigneeOwnerClause()); // otherwise you see tasks you are assigned or that you own - } - return filter; - } - - @Override - public Set> getCandidateUserPermissions(@NotNull WorkflowTask task) - { - return Collections.singleton(AdminPermission.class); - } -} diff --git a/src/org/labkey/workflow/ProcessInstanceEventListener.java b/src/org/labkey/workflow/ProcessInstanceEventListener.java deleted file mode 100644 index 1d225fa..0000000 --- a/src/org/labkey/workflow/ProcessInstanceEventListener.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow; - -import org.activiti.engine.delegate.event.ActivitiEvent; -import org.activiti.engine.delegate.event.BaseEntityEventListener; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; -import org.labkey.api.view.HttpView; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.api.workflow.WorkflowProcessEventListener; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.workflow.model.WorkflowProcessImpl; - -/** - * Created by susanh on 7/22/15. - * - * N.B. From the Activiti docs: "there will only be a single instance of [this] class created. Make sure the listener - * implementations do not rely on member-fields or ensure safe usage from multiple threads/contexts." - */ -public class ProcessInstanceEventListener extends BaseEntityEventListener -{ - @Override - protected void onCreate(ActivitiEvent event) - { - WorkflowProcessEventListener listener = getListener(event.getProcessInstanceId()); - if (listener != null) - listener.onCreate(); - } - - @Override - protected void onInitialized(ActivitiEvent event) - { - WorkflowProcessEventListener listener = getListener(event.getProcessInstanceId()); - if (listener != null) - listener.onInitialized(); - } - - @Override - protected void onDelete(ActivitiEvent event) - { - WorkflowProcessEventListener listener = getListener(event.getProcessInstanceId()); - if (listener != null) - listener.onDelete(); - } - - @Override - protected void onUpdate(ActivitiEvent event) - { - - WorkflowProcessEventListener listener = getListener(event.getProcessInstanceId()); - if (listener != null) - listener.onUpdate(); - } - - @Nullable - private WorkflowProcessEventListener getListener(String processInstanceId) - { - Container container = null; - User user = null; - if (HttpView.hasCurrentView()) - { - container = HttpView.currentContext().getContainer(); - user = HttpView.currentContext().getUser(); - } - WorkflowProcess instance = new WorkflowProcessImpl(WorkflowManager.get().getProcessInstance(processInstanceId)); - if (instance != null) - return WorkflowRegistry.get().getWorkflowProcessEventListener(instance, user, container); - return null; - } -} diff --git a/src/org/labkey/workflow/WorkflowContainerListener.java b/src/org/labkey/workflow/WorkflowContainerListener.java deleted file mode 100644 index 7199f2f..0000000 --- a/src/org/labkey/workflow/WorkflowContainerListener.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow; - -import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager.ContainerListener; -import org.labkey.api.security.User; - -import java.beans.PropertyChangeEvent; -import java.util.Collection; -import java.util.Collections; - -public class WorkflowContainerListener implements ContainerListener -{ - @Override - public void containerCreated(Container c, User user) - { - } - - @Override - public void containerDeleted(Container c, User user) - { - WorkflowManager.get().deleteDeployments(c); - } - - @Override - public void propertyChange(PropertyChangeEvent evt) - { - } - - @Override - public void containerMoved(Container c, Container oldParent, User user) - { - } - - @NotNull @Override - public Collection canMove(Container c, Container newParent, User user) - { - return Collections.emptyList(); - } -} \ No newline at end of file diff --git a/src/org/labkey/workflow/WorkflowController.java b/src/org/labkey/workflow/WorkflowController.java deleted file mode 100644 index 0f5791c..0000000 --- a/src/org/labkey/workflow/WorkflowController.java +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow; - -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.repository.ProcessDefinition; -import org.apache.commons.io.IOUtils; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.action.ApiResponse; -import org.labkey.api.action.ApiSimpleResponse; -import org.labkey.api.action.BaseViewAction; -import org.labkey.api.action.Marshal; -import org.labkey.api.action.Marshaller; -import org.labkey.api.action.MutatingApiAction; -import org.labkey.api.action.ReadOnlyApiAction; -import org.labkey.api.action.SimpleErrorView; -import org.labkey.api.action.SimpleResponse; -import org.labkey.api.action.SimpleViewAction; -import org.labkey.api.action.SpringActionController; -import org.labkey.api.data.Container; -import org.labkey.api.query.QueryService; -import org.labkey.api.query.QuerySettings; -import org.labkey.api.query.QueryView; -import org.labkey.api.query.UserSchema; -import org.labkey.api.security.RequiresPermission; -import org.labkey.api.security.SecurityManager; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.security.permissions.Permission; -import org.labkey.api.security.permissions.ReadPermission; -import org.labkey.api.security.permissions.UpdatePermission; -import org.labkey.api.util.Pair; -import org.labkey.api.view.JspView; -import org.labkey.api.view.NavTree; -import org.labkey.api.view.UnauthorizedException; -import org.labkey.api.workflow.PermissionsHandler; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.api.workflow.WorkflowTask; -import org.labkey.workflow.model.WorkflowEngineTaskImpl; -import org.labkey.workflow.model.WorkflowHistoricTaskImpl; -import org.labkey.workflow.model.WorkflowProcessImpl; -import org.labkey.workflow.model.WorkflowSummary; -import org.labkey.workflow.query.WorkflowQuerySchema; -import org.labkey.workflow.view.WorkflowWebPart; -import org.springframework.validation.BindException; -import org.springframework.validation.Errors; -import org.springframework.web.servlet.ModelAndView; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Marshal(Marshaller.Jackson) -public class WorkflowController extends SpringActionController -{ - private static final DefaultActionResolver _actionResolver = new DefaultActionResolver(WorkflowController.class); - public static final String NAME = "workflow"; - - private static final String PROCESS_DEFINITION_KEY_MISSING = "Process definition key is required"; - private static final String TASK_ID_MISSING = "Task id is required"; - private static final String TASK_ID_UNKNOWN = "Task id is unknown"; - private static final String PROCESS_INSTANCE_ID_MISSING = "Process instance id is required"; - private static final String ASSIGNEE_ID_MISSING = "Assignee id is required"; - private static final String MODULE_NAME_MISSING = "Module name is required"; - private static final String NO_SUCH_TASK_ERROR = "No active task with the given id"; - private static final String NO_SUCH_INSTANCE_ERROR = "No active process instance with the given id"; - private static final String NO_SUCH_DEFINITION_ERROR = "No process definition with the given key"; - - - public WorkflowController() - { - setActionResolver(_actionResolver); - } - - /** - * Shows a summary of the workflows for the current container and user - */ - @RequiresPermission(ReadPermission.class) - public class BeginAction extends SimpleViewAction - { - @Override - public ModelAndView getView(Object o, BindException errors) throws Exception - { - setTitle("Workflows"); - WorkflowWebPart wp = new WorkflowWebPart(getContainer()); - return wp; - } - - @Override - public void addNavTrail(NavTree root) - { - root.addChild("Workflow Process List"); - } - } - - public static class AllWorkflowsBean - { - private Map _workflowDefinitions = new HashMap<>(); - - public AllWorkflowsBean() {} - - public AllWorkflowsBean(@Nullable Container container) - { - setWorkflowDefinitions(WorkflowManager.get().getProcessDefinitionNames(container)); - } - - public Map getWorkflowDefinitions() - { - return _workflowDefinitions; - } - - public void setWorkflowDefinitions(Map workflowDefinitions) - { - _workflowDefinitions = workflowDefinitions; - } - } - - /** - * Shows a summary of a given workflow for the current container and user, including the number of tasks - * and number of workflow instances currently active for this user. - */ - @RequiresPermission(ReadPermission.class) - public class SummaryAction extends SimpleViewAction - { - private String _navLabel = "Workflow Summary"; - - @Override - public ModelAndView getView(WorkflowRequestForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - WorkflowSummary bean = new WorkflowSummary(form.getProcessDefinitionKey(), getUser(), getContainer()); - _navLabel = bean.getName(); - - return new JspView<>("/org/labkey/workflow/view/workflowSummary.jsp", bean, errors); - } - - @Override - public void validate(WorkflowRequestForm workflowRequestForm, BindException errors) - { - if (workflowRequestForm.getProcessDefinitionKey() == null) - errors.rejectValue("processDefinitionKey", ERROR_MSG, PROCESS_DEFINITION_KEY_MISSING); - } - - @Override - public void addNavTrail(NavTree root) - { - root.addChild(_navLabel); - } - } - - - /** - * Shows a list of tasks that are associated with a particular workflow. - */ - @RequiresPermission(ReadPermission.class) - public class TaskListAction extends SimpleViewAction - { - private UserSchema _schema; - - @Override - public ModelAndView getView(WorkflowRequestForm bean, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - JspView jsp = new JspView<>("/org/labkey/workflow/view/workflowList.jsp", bean, errors); - - ProcessDefinition definition = WorkflowManager.get().getProcessDefinition(bean.getProcessDefinitionKey(), getContainer()); - if (definition != null) - { - bean.setProcessDefinitionName(definition.getName()); - - jsp.setTitle("Task List for '" + bean.getProcessDefinitionName() + "' workflow instances "); - } - else - { - jsp.setTitle("Task List for workflow instances"); - } - - if (_schema != null) - { - QuerySettings settings = _schema.getSettings(getViewContext(), QueryView.DATAREGIONNAME_DEFAULT, WorkflowQuerySchema.TABLE_TASK); - QueryView queryView = _schema.createView(getViewContext(), settings, errors); - - jsp.setView("workflowListQueryView", queryView); - } - - return jsp; - } - - @Override - public void validate(WorkflowRequestForm workflowRequestForm, BindException errors) - { - if (workflowRequestForm.getProcessDefinitionKey() == null) - errors.rejectValue("processDefinitionKey", ERROR_MSG, PROCESS_DEFINITION_KEY_MISSING); - else - { - _schema = QueryService.get().getUserSchema(getUser(), getContainer(), WorkflowQuerySchema.NAME); - if (_schema == null) - { - errors.reject(ERROR_MSG, WorkflowQuerySchema.SCHEMA_NOT_DEFINED_ERROR); - } - } - } - - @Override - public void addNavTrail(NavTree root) - { - } - } - - /** - * Shows a list of the current workflow instances for a given workflow model key - */ - @RequiresPermission(ReadPermission.class) - public class InstanceListAction extends SimpleViewAction - { - private UserSchema _schema; - - @Override - public ModelAndView getView(WorkflowRequestForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - { - return new SimpleErrorView(errors); - } - - ProcessDefinition processDefinition = WorkflowManager.get().getProcessDefinition(form.getProcessDefinitionKey(), getContainer()); - form.setProcessDefinitionName(processDefinition.getName()); - JspView jsp = new JspView<>("/org/labkey/workflow/view/workflowList.jsp", form); - jsp.setTitle("Active Processes"); - - QuerySettings settings = _schema.getSettings(getViewContext(), QueryView.DATAREGIONNAME_DEFAULT, WorkflowQuerySchema.TABLE_PROCESS_INSTANCE); - QueryView queryView = _schema.createView(getViewContext(), settings, errors); - - jsp.setView("workflowListQueryView", queryView); - - return jsp; - } - - @Override - public void validate(WorkflowRequestForm form, BindException errors) - { - String errorMessage = validateProcessDefinitionKey(form); - if (errorMessage != null) - errors.rejectValue("processDefinitionKey", ERROR_MSG, errorMessage); - - _schema = QueryService.get().getUserSchema(getUser(), getContainer(), WorkflowQuerySchema.NAME); - if (_schema == null) - { - errors.reject(ERROR_MSG, WorkflowQuerySchema.SCHEMA_NOT_DEFINED_ERROR); - } - } - - @Override - public void addNavTrail(NavTree root) - { - } - } - - private String validateProcessDefinitionKey(WorkflowRequestForm form) - { - if (form.getProcessDefinitionKey() == null) - { - return PROCESS_DEFINITION_KEY_MISSING; - } - else - { - ProcessDefinition processDefinition = WorkflowManager.get().getProcessDefinition(form.getProcessDefinitionKey(), getContainer()); - if (processDefinition == null) - return NO_SUCH_DEFINITION_ERROR; - } - - return null; - } - - - /** - * Shows the data about a task if the user has permissions to see this task - */ - @RequiresPermission(ReadPermission.class) - public static class TaskAction extends SimpleViewAction - { - private String _navLabel = "Task details"; - private WorkflowTask _task; - - @Override - public ModelAndView getView(WorkflowTaskForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - if (_task.getName() != null) - _navLabel = "'" + _task.getName() + "' " + (_task.isActive() ? "active" : " inactive ") + " task details"; - - return new JspView<>("/org/labkey/workflow/view/workflowTask.jsp", _task, errors); - } - - @Override - public void validate(WorkflowTaskForm workflowTaskForm, BindException errors) - { - if (workflowTaskForm.getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - _task = new WorkflowEngineTaskImpl(workflowTaskForm.getTaskId(), getContainer()); - if (!_task.isActive()) - _task = new WorkflowHistoricTaskImpl(workflowTaskForm.getTaskId(), getContainer()); - if (_task.getName() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_UNKNOWN); - } - - @Override - public void addNavTrail(NavTree root) - { - root.addChild(_navLabel); - } - } - - /** - * View the details of a process instance. - */ - @RequiresPermission(ReadPermission.class) - public class ProcessInstanceAction extends SimpleViewAction - { - private String _navLabel = "Workflow process instance details"; - - @Override - public void validate(ProcessInstanceDetailsForm form, BindException errors) - { - if (form.getProcessInstanceId() == null) - errors.rejectValue("processInstanceId", ERROR_MSG, PROCESS_INSTANCE_ID_MISSING); - } - - @Override - public ModelAndView getView(ProcessInstanceDetailsForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - WorkflowProcessImpl bean = new WorkflowProcessImpl(form.getProcessInstanceId()); - if (form.getProcessDefinitionKey() != null && bean.getProcessDefinitionKey() == null) - { - bean.setProcessDefinitionKey(form.getProcessDefinitionKey()); - } - if (bean.getProcessDefinitionName() != null) - _navLabel = "'" + bean.getProcessDefinitionName() + "' " + (bean.isActive() ? "active" : "inactive") + " process instance details"; - - return new JspView<>("/org/labkey/workflow/view/workflowProcessInstance.jsp", bean, errors); - } - - @Override - public void addNavTrail(NavTree root) - { - root.addChild(_navLabel); - } - } - - - private static class ProcessInstanceDetailsForm - { - private String _processInstanceId; - private String _processDefinitionKey; - private boolean _includeCompletedTasks; - - public String getProcessInstanceId() - { - return _processInstanceId; - } - - public void setProcessInstanceId(String processInstanceId) - { - _processInstanceId = processInstanceId; - } - - public String getProcessDefinitionKey() - { - return _processDefinitionKey; - } - - public void setProcessDefinitionKey(String processDefinitionKey) - { - _processDefinitionKey = processDefinitionKey; - } - - public boolean includeCompletedTasks() - { - return _includeCompletedTasks; - } - - public void setIncludeCompletedTasks(boolean includeCompletedTasks) - { - _includeCompletedTasks = includeCompletedTasks; - } - } - - /** - * Retrieves the process diagram associated with a particular processInstance or processName as a png. - * If there is no such diagram, a plain text response will be returned indicating that there is no such image. - */ - @RequiresPermission(ReadPermission.class) - public class ProcessDiagramAction extends BaseViewAction - { - @Override - protected String getCommandClassMethodName() - { - return "validate"; - } - - @Override - public ModelAndView handleRequest() throws Exception - { - Pair pair = getInputStream(getViewContext().getRequest()); - - try (InputStream stream = pair.first) - { - byte[] imageBytes = IOUtils.toByteArray(stream); - HttpServletResponse response = getViewContext().getResponse(); - - response.setContentType(pair.second); - response.setContentLength(imageBytes.length); - response.getOutputStream().write(imageBytes); - } - - return null; - } - - private Pair getInputStream(HttpServletRequest request) - { - InputStream stream = null; - String contentType = "image/png"; - if (request.getParameter("processInstanceId") != null) - stream = WorkflowManager.get().getProcessDiagram(request.getParameter("processInstanceId")); - else if (request.getParameter("processDefinitionKey") != null) - stream = WorkflowManager.get().getProcessDiagramByKey(request.getParameter("processDefinitionKey"), getContainer()); - if (stream == null) - { - contentType = "text/plain"; - stream = new ByteArrayInputStream("Unable to retrieve process diagram. Perhaps you need to deploy the process.".getBytes(StandardCharsets.UTF_8)); - } - return Pair.of(stream, contentType); - } - - @Override - public void validate(Object o, Errors errors) - { - HttpServletRequest request = getViewContext().getRequest(); - if (request.getParameter("processInstanceId") == null && request.getParameter("processDefinitionKey") == null) - errors.reject(ERROR_MSG, "Either a process instance id or a process definition key must be provided"); - } - } - - - /** - * Shows the data about a process instance if the user has permissions to see this task - */ - @RequiresPermission(ReadPermission.class) - public class ProcessInstanceDataAction extends ReadOnlyApiAction - { - private WorkflowProcess _processInstance; - - - @Override - public void validateForm(ProcessInstanceDetailsForm form, Errors errors) - { - if (form.getProcessInstanceId() == null) - errors.rejectValue("processInstanceId", ERROR_MSG, PROCESS_INSTANCE_ID_MISSING); - else - { - HistoricProcessInstance historicProcessInstance = WorkflowManager.get().getHistoricProcessInstance(form.getProcessInstanceId()); - if (historicProcessInstance == null) - { - errors.reject(ERROR_MSG, NO_SUCH_INSTANCE_ERROR); - } - else - { - _processInstance = new WorkflowProcessImpl(historicProcessInstance, form.includeCompletedTasks()); - if (!_processInstance.canView(getUser(), getContainer())) - errors.reject(ERROR_MSG, "User does not have permission to view process instance data for this process"); - } - } - } - - @Override - public SimpleResponse execute(ProcessInstanceDetailsForm processInstanceDetailsForm, BindException errors) throws Exception - { - ensureProcessUserAccessData(_processInstance, getUser(), getContainer()); - return success(_processInstance); - } - } - - private void ensureProcessUserAccessData(WorkflowProcess process, User user, Container container) - { - // remove the data access parameters if the user does not have permission to access the data or if it is inactive - if (!process.isActive() || !process.canAccessData(user, container)) - { - Map variables = process.getProcessVariables(); - variables.remove(WorkflowProcess.DATA_ACCESS_KEY); - } - } - - - /** - * Shows the data about the list of process instances the user has permissions to see for a given process definition - */ - @RequiresPermission(ReadPermission.class) - public class ProcessInstanceListDataAction extends ReadOnlyApiAction - { - @Override - public void validateForm(WorkflowRequestForm form, Errors errors) - { - String errorMessage = validateProcessDefinitionKey(form); - if (errorMessage != null) - errors.rejectValue("processDefinitionKey", ERROR_MSG, errorMessage); - } - - @Override - public ApiResponse execute(WorkflowRequestForm form, BindException errors) throws Exception - { - List workflowProcessList = new ArrayList<>(); - - // use the historical process instance query so we get all process instances (active and inactive) - List processInstanceList = WorkflowManager.get().getHistoricProcessInstanceList(form.getProcessDefinitionKey(), getContainer(), false); - for (HistoricProcessInstance historicProcessInstance : processInstanceList) - { - WorkflowProcess workflowProcess = new WorkflowProcessImpl(historicProcessInstance, form.includeCompletedTasks()); - if (workflowProcess.canView(getUser(), getContainer())) - { - ensureProcessUserAccessData(workflowProcess, getUser(), getContainer()); - workflowProcessList.add(workflowProcess); - } - } - - ApiSimpleResponse resp = new ApiSimpleResponse(); - resp.put("processes", workflowProcessList); - resp.put("success", true); - return resp; - - } - } - - - /** - * Shows the data about a task if the user has permissions to see this task - */ - @RequiresPermission(ReadPermission.class) - public class TaskDataAction extends ReadOnlyApiAction - { - private WorkflowTask _task; - - @Override - public Object execute(WorkflowTaskForm workflowTaskForm, BindException errors) throws Exception - { - // remove the data access parameters if the user does not have permission to data access the data - if (!_task.canAccessData(getUser(), getContainer())) - { - Map variables = _task.getProcessVariables(); - variables.remove(WorkflowProcess.DATA_ACCESS_KEY); - } - return success(_task); - } - - @Override - public void validateForm(WorkflowTaskForm form, Errors errors) - { - if (form.getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - else - { - _task = WorkflowManager.get().getTask(form.getTaskId(), getContainer()); - if (!_task.canView(getUser(), getContainer())) - errors.reject(ERROR_MSG, "User does not have permission to view task data for this task"); - } - } - } - - @RequiresPermission(ReadPermission.class) - public class GetReassignPermissionNamesAction extends ReadOnlyApiAction - { - private WorkflowTask _task; - - - @Override - public Object execute(WorkflowTaskForm form, BindException errors) throws Exception - { - ApiSimpleResponse response = new ApiSimpleResponse(); - Set> permissionClasses = _task.getReassignPermissions(getUser(), getContainer()); - List> names = new ArrayList<>(); - for (Class permissionClass : permissionClasses) - { - Map permData = new HashMap<>(); - Permission permission = (Permission) newInstance(permissionClass); - permData.put("name", permission.getName()); - names.add(permData); - } - response.put("permissions", names); - - return success(response); - } - - @Override - public void validateForm(WorkflowTaskForm form, Errors errors) - { - if (form.getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - else - { - _task = WorkflowManager.get().getTask(form.getTaskId(), getContainer()); - if (!_task.isActive()) - errors.reject(ERROR_MSG, NO_SUCH_TASK_ERROR); - } - } - } - - - @RequiresPermission(ReadPermission.class) - public class CandidateUsersAction extends ReadOnlyApiAction - { - protected static final String PROP_USER_ID = "userId"; - protected static final String PROP_USER_NAME = "displayName"; - - private WorkflowTask _task; - - - @Override - public Object execute(WorkflowTaskForm form, BindException errors) throws Exception - { - ApiSimpleResponse response = new ApiSimpleResponse(); - User currentUser = getUser(); - boolean includeEmail = SecurityManager.canSeeUserDetails(getContainer(), currentUser); - List users = SecurityManager.getUsersWithOneOf(getContainer(), _task.getReassignPermissions(getUser(), getContainer())); - List> userResponseList = new ArrayList<>(); - for (User user : users) - { - Map userInfo = new HashMap<>(); - userInfo.put(PROP_USER_ID, user.getUserId()); - - //force sanitize of the display name, even for logged-in users - userInfo.put(PROP_USER_NAME, user.getDisplayName(currentUser)); - //include email address, if user is allowed to see them - if (includeEmail) - userInfo.put("email", user.getEmail()); - userResponseList.add(userInfo); - - } - response.put("users", userResponseList); - return success(response); - } - - @Override - public void validateForm(WorkflowTaskForm form, Errors errors) - { - if (form.getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - else - { - _task = WorkflowManager.get().getTask(form.getTaskId(), getContainer()); - if (!_task.isActive()) - errors.reject(ERROR_MSG, NO_SUCH_TASK_ERROR); - } - } - } - - /** - * Claims a task for a user, making that user the owner and the assignee. - */ - @RequiresPermission(UpdatePermission.class) - public class ClaimTaskAction extends MutatingApiAction - { - @Override - public Object execute(WorkflowTaskForm form, BindException errors) throws Exception - { - WorkflowManager.get().claimTask(form.getTaskId(), form.getAssigneeId(), getContainer()); - return success(); - } - - @Override - public void validateForm(WorkflowTaskForm form, Errors errors) - { - form.validate(errors); - } - } - - /** - * Delegates a task to a particular user. The owner of the task remains unchanged. - */ - @RequiresPermission(UpdatePermission.class) - public class DelegateTaskAction extends MutatingApiAction - { - @Override - public Object execute(WorkflowTaskForm form, BindException errors) throws Exception - { - WorkflowManager.get().delegateTask(form.getTaskId(), getUser(), form.getAssigneeId(), getContainer()); - return success(); - } - - @Override - public void validateForm(WorkflowTaskForm form, Errors errors) - { - form.validate(errors); - } - } - - - public static class WorkflowRequestForm - { - private String _processDefinitionKey; - private String _processDefinitionName; - private boolean _includeCompletedTasks; - - public String getProcessDefinitionKey() - { - return _processDefinitionKey; - } - - public void setProcessDefinitionKey(String processDefinitionKey) - { - _processDefinitionKey = processDefinitionKey; - } - - public String getProcessDefinitionName() - { - return _processDefinitionName; - } - - public void setProcessDefinitionName(String processDefinitionName) - { - _processDefinitionName = processDefinitionName; - } - - public boolean includeCompletedTasks() - { - return _includeCompletedTasks; - } - - public void setIncludeCompletedTasks(boolean includeCompletedTasks) - { - _includeCompletedTasks = includeCompletedTasks; - } - } - - /** - * Assigns a task to a user - */ - @RequiresPermission(UpdatePermission.class) - public class AssignTaskAction extends MutatingApiAction - { - @Override - public Object execute(WorkflowTaskForm form, BindException errors) throws Exception - { - if (form.getProcessVariables() != null) - { - WorkflowManager.get().updateProcessVariables(form.getTaskId(), form.getProcessVariables()); - } - WorkflowManager.get().assignTask(form.getTaskId(), form.getAssigneeId(), getUser(), getContainer()); - return success(); - } - - @Override - public void validateForm(WorkflowTaskForm form, Errors errors) - { - form.validate(errors); - } - } - - private static class WorkflowTaskForm - { - private String _taskId; - private Integer _ownerId; - private Integer _assigneeId; - private Map _processVariables; - - public String getTaskId() - { - return _taskId; - } - - public void setTaskId(String taskId) - { - _taskId = taskId; - } - - public Integer getAssigneeId() - { - return _assigneeId; - } - - public void setAssigneeId(int assigneeId) - { - _assigneeId = assigneeId; - } - - public Integer getOwnerId() - { - return _ownerId; - } - - public void setOwnerId(int ownerId) - { - _ownerId = ownerId; - } - - public Map getProcessVariables() - { - return _processVariables; - } - - public void setProcessVariables(Map processVariables) - { - _processVariables = processVariables; - } - - public void validate(Errors errors) - { - if (getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - if (getAssigneeId() == null) - errors.rejectValue("assigneeId", ERROR_MSG, ASSIGNEE_ID_MISSING); - - } - } - - - /** - * Creates a new instance of a process with a given processKey and returns the id of the new instance on success. - */ - @RequiresPermission(UpdatePermission.class) - public class StartProcessAction extends MutatingApiAction - { - @Override - public Object execute(StartWorkflowProcessForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - form.setInitiatorId(getUser().getUserId()); - form.setContainerId(getContainer().getId()); - String instanceId = WorkflowManager.get().startWorkflow(form.getWorkflowModelModule(), form.getProcessDefinitionKey(), form.getName(), form.getProcessVariables(), getContainer()); - ApiSimpleResponse response = new ApiSimpleResponse(); - response.put("processInstanceId", instanceId); - return success(response); - } - - @Override - public void validateForm(StartWorkflowProcessForm form, Errors errors) - { - if (form != null) - form.validate(getUser(), getContainer(), errors); - } - } - - public static class StartWorkflowProcessForm - { - private String _workflowModelModule; - private String _processDefinitionKey; - private String _name; - private Map _processVariables; - - public String getName() - { - return _name; - } - - public void setName(String name) - { - _name = name; - } - - public String getProcessDefinitionKey() - { - return _processDefinitionKey; - } - - public void setProcessDefinitionKey(String processDefinitionKey) - { - _processDefinitionKey = processDefinitionKey; - } - - public String getWorkflowModelModule() - { - return _workflowModelModule; - } - - public void setWorkflowModelModule(String module) - { - _workflowModelModule = module; - } - - public void setInitiatorId(int userId) - { - if (_processVariables == null) - { - _processVariables = new HashMap<>(); - } - _processVariables.put(WorkflowProcess.INITIATOR_ID, String.valueOf(userId)); - } - - public void setContainerId(String containerId) - { - if (_processVariables == null) - { - _processVariables = new HashMap<>(); - } - _processVariables.put(WorkflowProcess.CONTAINER_ID, containerId); - } - - public Map getProcessVariables() - { - return _processVariables; - } - - public void setProcessVariables(Map processVariables) - { - _processVariables = processVariables; - } - - public void validate(User user, Container container, Errors errors) - { - if (getProcessDefinitionKey() == null) - errors.rejectValue("processDefinitionKey", ERROR_MSG, PROCESS_DEFINITION_KEY_MISSING); - else if (getWorkflowModelModule() == null) - errors.rejectValue("workflowModelModule", ERROR_MSG, MODULE_NAME_MISSING); - else - { - PermissionsHandler handler = WorkflowRegistry.get().getPermissionsHandler(getWorkflowModelModule(), user, container); - if (!handler.canStartProcess(getProcessDefinitionKey())) - throw new UnauthorizedException("User does not have permission to start a process with key " + getProcessDefinitionKey() + " from module " + getWorkflowModelModule()); - } - } - } - - /** - * Deletes a particular process instance. This is allowed for the initiator of the - * process and for administrators. - */ - @RequiresPermission(UpdatePermission.class) - public class RemoveProcessInstanceAction extends MutatingApiAction - { - @Override - public Object execute(RemoveWorkflowProcessForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - String removalMsg = "Removed by user " + getUser() + " on " + (new Date()) + ". "; - if (form.getComment() != null) - removalMsg += "Reason: " + form.getComment(); - form.setComment(removalMsg); - WorkflowProcess process = new WorkflowProcessImpl(WorkflowManager.get().getProcessInstance(form.getProcessInstanceId())); - if (!process.canDelete(getUser(), getContainer())) - { - throw new UnauthorizedException("You do not have permission to delete this process instance"); - } - WorkflowManager.get().deleteProcessInstance(form.getProcessInstanceId(), form.getComment()); - return success(); - } - - @Override - public void validateForm(RemoveWorkflowProcessForm form, Errors errors) - { - form.validate(errors); - } - } - - public static class RemoveWorkflowProcessForm - { - private String _processInstanceId; - private String _comment; - - public String getProcessInstanceId() - { - return _processInstanceId; - } - - public void setProcessInstanceId(String processInstanceId) - { - _processInstanceId = processInstanceId; - } - - public String getComment() - { - return _comment; - } - - public void setComment(String comment) - { - _comment = comment; - } - - public void validate(Errors errors) - { - if (getProcessInstanceId() == null) - errors.rejectValue("processInstanceId", ERROR_MSG, PROCESS_INSTANCE_ID_MISSING); - } - } - - @RequiresPermission(UpdatePermission.class) - public class UpdateVariablesAction extends MutatingApiAction - { - private WorkflowTask _task; - - @Override - public Object execute(ProcessVariablesForm form, BindException errors) throws Exception - { - _task = WorkflowManager.get().getTask(form.getTaskId(), getContainer()); - if (_task.canUpdate(getUser(), getContainer())) - { - WorkflowManager.get().updateProcessVariables(form.getTaskId(), form.getProcessVariables()); - } - ApiSimpleResponse response = new ApiSimpleResponse(); - return success(); - } - - @Override - public void validateForm(ProcessVariablesForm form, Errors errors) - { - form.validate(errors); - if (!errors.hasErrors()) - { - _task = WorkflowManager.get().getTask(form.getTaskId(), getContainer()); - if (_task == null || !_task.isActive()) - errors.reject(ERROR_MSG, NO_SUCH_TASK_ERROR); - if (!_task.canUpdate(getUser(), getContainer())) - throw new UnauthorizedException("User does not have permission to update task " + form.getTaskId()); - - } - } - } - - public static class ProcessVariablesForm - { - private String _taskId; - private Map _processVariables; - - public String getTaskId() - { - return _taskId; - } - - public void setTaskId(String taskId) - { - _taskId = taskId; - } - - public Map getProcessVariables() - { - return _processVariables; - } - - public void setProcessVariables(Map processVariables) - { - _processVariables = processVariables; - } - - public void validate(Errors errors) - { - if (getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - } - } - - /** - * Complete a task in a workflow. If the task is currently unassigned, it will be assigned to the current user. - */ - @RequiresPermission(UpdatePermission.class) - public class CompleteTaskAction extends MutatingApiAction - { - @Override - public Object execute(TaskCompletionForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - ApiSimpleResponse response = new ApiSimpleResponse(); - - WorkflowTask task = WorkflowManager.get().getTask(form.getTaskId(), getContainer()); - if (!task.isActive()) - throw new Exception("No active task with id " + form.getTaskId()); - if (!task.canComplete(getUser(), getContainer())) - { - throw new Exception("User " + getUser() + " does not have permission to complete this task (id: " + form.getTaskId() + ")"); - } - if (!task.isAssigned(getUser())) // if user can complete it but it is not assigned to this user, we should change that. - { - WorkflowManager.get().assignTask(form.getTaskId(), getUser().getUserId(), getUser(), getContainer()); - task.setAssignee(getUser()); - } - WorkflowManager.get().updateProcessVariables(form.getTaskId(), form.getProcessVariables()); - WorkflowManager.get().completeTask(form.getTaskId(), getUser(), getContainer()); - response.put("status", "success"); - - return response; - } - - @Override - public void validateForm(TaskCompletionForm form, Errors errors) - { - if (form.getTaskId() == null) - errors.rejectValue("taskId", ERROR_MSG, TASK_ID_MISSING); - } - } - - public static class TaskCompletionForm - { - private String _taskId; - private String _processInstanceId; - private String _processDefinitionKey; - private Map _processVariables; - - public String getTaskId() - { - return _taskId; - } - - public void setTaskId(String taskId) - { - _taskId = taskId; - } - - public String getProcessInstanceId() - { - return _processInstanceId; - } - - public void setProcessInstanceId(String processInstanceId) - { - _processInstanceId = processInstanceId; - } - - public Map getProcessVariables() - { - return _processVariables; - } - - public void setProcessVariables(Map processVariables) - { - _processVariables = processVariables; - } - - public String getProcessDefinitionKey() - { - return _processDefinitionKey; - } - - public void setProcessDefinitionKey(String processDefinitionKey) - { - _processDefinitionKey = processDefinitionKey; - } - } - - /** - * Creates a new deployment of a process definition - */ - @RequiresPermission(AdminPermission.class) - public class DeployAction extends MutatingApiAction - { - @Override - public Object execute(DeploymentForm form, BindException errors) throws Exception - { - if (errors.hasErrors()) - return new SimpleErrorView(errors); - - ApiSimpleResponse response = new ApiSimpleResponse(); - if (form.getFile() != null) - { - File modelFile = new File(form.getFile()); - response.put("deploymentId", WorkflowManager.get().deployWorkflow(form.getModuleName(), modelFile, getContainer())); - } - else - { - throw new Exception("No process specified for deployment"); - } - return success(response); - } - - @Override - public void validateForm(DeploymentForm form, Errors errors) - { - if (form.getFile() == null) - errors.rejectValue("file", ERROR_MSG, "File name is required"); - } - } - - public static class DeploymentForm - { - private String _file; - private String _moduleName; - - public String getFile() - { - return _file; - } - - public void setFile(String file) - { - _file = file; - } - - public String getModuleName() - { - return _moduleName; - } - - public void setModuleName(String moduleName) - { - _moduleName = moduleName; - } - } - -} diff --git a/src/org/labkey/workflow/WorkflowManager.java b/src/org/labkey/workflow/WorkflowManager.java deleted file mode 100644 index 322044d..0000000 --- a/src/org/labkey/workflow/WorkflowManager.java +++ /dev/null @@ -1,1403 +0,0 @@ -/* - * Copyright (c) 2015-2017 LabKey Corporation - * - * 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.labkey.workflow; - -import org.activiti.engine.ActivitiException; -import org.activiti.engine.ActivitiObjectNotFoundException; -import org.activiti.engine.FormService; -import org.activiti.engine.HistoryService; -import org.activiti.engine.ManagementService; -import org.activiti.engine.ProcessEngine; -import org.activiti.engine.ProcessEngineConfiguration; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.TaskService; -import org.activiti.engine.form.FormProperty; -import org.activiti.engine.form.StartFormData; -import org.activiti.engine.form.TaskFormData; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.history.HistoricProcessInstanceQuery; -import org.activiti.engine.history.HistoricTaskInstance; -import org.activiti.engine.history.HistoricTaskInstanceQuery; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.DeploymentBuilder; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.repository.ProcessDefinitionQuery; -import org.activiti.engine.runtime.Job; -import org.activiti.engine.runtime.JobQuery; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.runtime.ProcessInstanceBuilder; -import org.activiti.engine.runtime.ProcessInstanceQuery; -import org.activiti.engine.task.IdentityLink; -import org.activiti.engine.task.Task; -import org.activiti.engine.task.TaskQuery; -import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.exceptions.PersistenceException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.data.DbSchema; -import org.labkey.api.data.JdbcType; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.data.Table; -import org.labkey.api.data.TableInfo; -import org.labkey.api.data.dialect.SqlDialect; -import org.labkey.api.exp.Lsid; -import org.labkey.api.module.Module; -import org.labkey.api.module.ModuleLoader; -import org.labkey.api.module.ModuleResourceCache; -import org.labkey.api.module.ModuleResourceCacheHandler; -import org.labkey.api.module.ModuleResourceCaches; -import org.labkey.api.module.ResourceRootProvider; -import org.labkey.api.query.ExprColumn; -import org.labkey.api.query.FieldKey; -import org.labkey.api.query.QueryService; -import org.labkey.api.query.QuerySettings; -import org.labkey.api.query.QueryView; -import org.labkey.api.query.UserIdQueryForeignKey; -import org.labkey.api.query.UserSchema; -import org.labkey.api.resource.Resource; -import org.labkey.api.security.User; -import org.labkey.api.security.UserManager; -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.test.TestWhen; -import org.labkey.api.util.ContextListener; -import org.labkey.api.util.Path; -import org.labkey.api.util.ShutdownListener; -import org.labkey.api.util.TestContext; -import org.labkey.api.view.UnauthorizedException; -import org.labkey.api.view.ViewContext; -import org.labkey.api.workflow.TaskFormField; -import org.labkey.api.workflow.WorkflowJob; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.api.workflow.WorkflowService; -import org.labkey.api.workflow.WorkflowTask; -import org.labkey.workflow.model.TaskFormFieldImpl; -import org.labkey.workflow.model.WorkflowEngineTaskImpl; -import org.labkey.workflow.model.WorkflowHistoricTaskImpl; -import org.labkey.workflow.model.WorkflowJobImpl; -import org.labkey.workflow.model.WorkflowProcessImpl; -import org.labkey.workflow.query.WorkflowQuerySchema; - -import javax.sql.DataSource; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -public class WorkflowManager implements WorkflowService -{ - private static final Logger logger = LogManager.getLogger(WorkflowManager.class); - - private static final String ACTIVITI_CONFIG_FILE = "resources/workflow/config/activiti.cfg.xml"; - private static final String WORKFLOW_FILE_NAME_EXTENSION = ".bpmn20.xml"; - private static final Path WORKFLOW_MODEL_PATH = new Path("workflow", "model"); - private static final WorkflowManager _instance = new WorkflowManager(); - - private ProcessEngine _processEngine = null; - - // A cache of the deployments at the global scope. New deployments are created in the database when the workflow model files change. - private static final ModuleResourceCache> DEPLOYMENT_CACHE = ModuleResourceCaches.create("Workflow model definitions", new WorkflowDeploymentCacheHandler(), ResourceRootProvider.getStandard(WORKFLOW_MODEL_PATH)); - - private WorkflowManager() - { - // prevent external construction with a private default constructor - - // Don't leave activiti ProcessEngine running with an invalid data source - ContextListener.addShutdownListener(new ShutdownListener() - { - @Override - public String getName() - { - return "WorkflowManager process engine"; - } - - @Override - public void shutdownPre() - { - if (_processEngine != null) - { - try - { - _processEngine.close(); - } - finally - { - _processEngine = null; - } - } - } - - @Override - public void shutdownStarted() { /* Nothing to do */ } - }); - } - - public static WorkflowManager get() - { - return _instance; - } - - /** - * Gets the list of candidate group ids for a task given its id, or an empty list if there are no candidate groups - * @param taskId id of the task to get groups for - * @return list of candidate group ids. - */ - @Override - @NotNull - public List getCandidateGroupIds(@NotNull String taskId) - { - List groupIds = new ArrayList<>(); - List links = getTaskService().getIdentityLinksForTask(taskId); - for (IdentityLink link : links) - { - if (link.getGroupId() != null) - { - groupIds.add(Integer.valueOf(link.getGroupId())); - } - } - return groupIds; - } - - - /** - * Retrieves the count of the tasks associated with a particular processDefinitionKey that are assigned to a particular user - * @param processDefinitionKey identifier for the process definition - * @param filter a filter over the task variables for the assigned tasks - * @param assignee the user the tasks are assigned to - * @param container the container in which the tasks are defined @return count of the workflow tasks - */ - @Override - public long getTaskCount(@NotNull String processDefinitionKey, @Nullable SimpleFilter filter, @Nullable User assignee, @Nullable Container container) - { - TaskQuery query = getTaskService().createTaskQuery().processDefinitionKey(processDefinitionKey); - if (assignee != null) - query.taskAssignee(String.valueOf(assignee.getUserId())); - if (container != null) - query.taskTenantId(container.getId()); - if (filter != null) - { - for (SimpleFilter.FilterClause clause : filter.getClauses()) - { - List fieldKeys = clause.getFieldKeys(); - for (int i = 0; i < fieldKeys.size(); i++) - { - FieldKey fieldKey = fieldKeys.get(i); - if (fieldKey.getName().equals(WorkflowService.TASK_KEY)) - query.taskDefinitionKey(String.valueOf(clause.getParamVals()[i])); - else - { - // TODO other comparators are also supported - query.taskVariableValueEquals(fieldKey.getName(), clause.getParamVals()[i]); - } - } - } - } - return query.count(); - } - - @Override - @Nullable - public WorkflowProcess getWorkflowProcessForVariable(String key, String value, @NotNull Container container) throws Exception - { - return getWorkflowProcessForVariable(key, "text_", value, container); - } - - /** - * Creates a column containing the assignee with a given key for a process instance identified by a process variable of a given name. - * Note that this assumes the identifier is a long value. - * @param tableInfo the table the column will be attached to - * @param colName name to give the column being created - * @param assigneeVarName the name of the process variable that contains the assigneeId (as an integer) - * @param identifierVarName the name of the variable that has the identifier for the workflow object in this table - * @param identifierColName the name of the column in the current table in which the identifier is located. - *@param user the current user - * @param container the container context for this table @return column that will display the assignee - * TODO this assumes the key is a long_, which may not always be true - */ - @Override - public ColumnInfo getAssigneeColumn(TableInfo tableInfo, final String colName, String assigneeVarName, String identifierVarName, String identifierColName, User user, Container container) - { - SQLFragment sql = new SQLFragment("(SELECT text_ FROM workflow.act_hi_varinst WHERE name_ = ").appendValue(assigneeVarName).append(" AND proc_inst_id_ IN "); - sql.append(" (SELECT pi.proc_inst_id_ FROM workflow.act_hi_procinst pi, (SELECT MAX(start_time_) startTime, v.long_ FROM workflow.act_hi_procinst p "); - sql.append(" JOIN workflow.act_hi_varinst v ON p.proc_inst_id_ = v.proc_inst_id_ "); - sql.append(" WHERE v.name_ = ").appendValue(identifierVarName); - sql.append(" GROUP BY v.long_) AS sub WHERE pi.start_time_ = sub.startTime AND sub.long_ = ").append(identifierColName).append(")"); - sql.append(")"); - ExprColumn ret = new ExprColumn(tableInfo, colName, sql, JdbcType.VARCHAR); - - ret.setFk(new UserIdQueryForeignKey(user, container, true)); - - return ret; - } - - /** - * Creates a column with the current taskId for a given identifier variable. Note that this - * will not work if there is more than one active task for a particular process instance. - * @param tableInfo the table to which the column will be added - * @param colLabel the name to be given to the column - * @param identifierVarName the name of the process variable that contains the identifier - * @param identifierColumnName the name of the column in the table that contains the identifier - * @return a column with the id of the current task. - */ - public ColumnInfo getTaskIdColumn(TableInfo tableInfo, final String colLabel, String identifierVarName, String identifierColumnName) - { - SQLFragment sql = new SQLFragment("(SELECT t.id_ FROM "); - sql.append(" workflow.act_ru_task t "); - sql.append(" LEFT JOIN workflow.act_ru_variable v ON t.proc_inst_id_ = v.proc_inst_id_ "); - sql.append(" WHERE v.name_ = ").appendValue(identifierVarName); - sql.append(" AND v.long_ = ").append(identifierColumnName); - sql.append(")"); - - ExprColumn col = new ExprColumn(tableInfo, WorkflowService.TASK_KEY, sql, JdbcType.VARCHAR); - col.setLabel(colLabel); - return col; - } - - /** - * Creates a column with the current taskType (task definition key) for a given identifier variable. Note that this - * will not work if there is more than one active task for a particular process instance and it currently assumes the - * identifier is a long_ value. - * @param tableInfo the table to which the column will be added - * @param colLabel the name to be given to the column - * @param identifierVarName the name of the process variable that contains the identifier - * @param identifierColumnName the name of the column in the table that contains the identifier - * @return a column with the id of the current task. - */ - @Override - public ColumnInfo getTaskTypeColumn(TableInfo tableInfo, final String colLabel, String identifierVarName, String identifierColumnName) - { - SQLFragment sql = new SQLFragment("(SELECT t.task_def_key_ FROM "); - sql.append(" workflow.act_ru_task t "); - sql.append(" LEFT JOIN workflow.act_ru_variable v ON t.proc_inst_id_ = v.proc_inst_id_ "); - sql.append(" WHERE v.name_ = ").appendValue(identifierVarName); - sql.append(" AND v.long_ = ").append(identifierColumnName); - sql.append(")"); - - ExprColumn col = new ExprColumn(tableInfo, WorkflowService.TASK_KEY, sql, JdbcType.VARCHAR); - col.setLabel(colLabel); - return col; - } - - /** - * Given a key, valueField and sqlValue that correspond to a process variable for a set of processes within a container, - * finds the workflow process with that process variable value that was started last. - * @param key the name of the process variable - * @param valueField the field in the act_hi_varinst table in which the value is stored - * @param value the string representation of the comparison value to be used in the SQL statement (e.g., for a string - * value, this should contain the single quotes ('string'), but for an integer value it should not (123)) - * @param container the container context - * @return the lates workflow instance with a variable with the given name and value - * @throws Exception if the key-value pair does not uniquely identify a single latest workflow process - * CONSIDER: value could be an Object and internally we map to the proper field based on the type of the object - */ - @Nullable - public WorkflowProcess getWorkflowProcessForVariable(String key, String valueField, String value, @NotNull Container container) throws Exception - { - DbSchema schema = WorkflowSchema.getInstance().getSchema(); - SqlDialect dialect = schema.getSqlDialect(); - SQLFragment sql = new SQLFragment("SELECT * FROM workflow.act_hi_procinst pi, "); - sql.append(" (SELECT MAX(start_time_) startTime, v.").append(valueField).append(" FROM workflow.act_hi_procinst p "); - sql.append(" JOIN workflow.act_hi_varinst v ON p.proc_inst_id_ = v.proc_inst_id_ "); - sql.append(" WHERE v.name_ = ").appendStringLiteral(key, dialect); - sql.append(" GROUP BY v.").append(valueField).append(") AS sub "); - sql.append(" WHERE pi.tenant_id_ = ").appendStringLiteral(container.getId(), dialect).append(" AND pi.start_time_ = sub.startTime AND sub.").append(valueField).append(" = ").appendStringLiteral(value, dialect); - try - { - assert(sql.getParams().isEmpty()); - HistoricProcessInstance instance = getHistoryService().createNativeHistoricProcessInstanceQuery().sql(sql.getSQL()).singleResult(); - if (instance == null) - return null; - return new WorkflowProcessImpl(instance); - } - catch (ActivitiException e) - { - throw new Exception("More than one process identified by the given key-value pair: " + key + "= " + value + " in this container"); - } - } - - /** - * Retrieve a task given its id - * @param taskId id of the task to retrieve - * @param container container in which the task is defined - * @return a workflow task of the given Id. If there is no such task, an exception is thrown. - */ - @Override - public WorkflowTask getTask(@NotNull String taskId, @Nullable Container container) - { - Task engineTask = getEngineTask(taskId, container); - if (engineTask != null) - return new WorkflowEngineTaskImpl(engineTask); - - return new WorkflowHistoricTaskImpl(taskId, container); - } - - public Task getEngineTask(@NotNull String taskId, @Nullable Container container) - { - TaskQuery query = getTaskService().createTaskQuery().taskId(taskId).includeTaskLocalVariables().includeProcessVariables(); - if (container != null) - query.taskTenantId(container.getId()); - return query.singleResult(); - } - - public HistoricTaskInstance getHistoricTask(@NotNull String taskId, @Nullable Container container) - { - HistoricTaskInstanceQuery query = getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId).includeTaskLocalVariables().includeProcessVariables(); - if (container != null) - query.taskTenantId(container.getId()); - return query.singleResult(); - } - - @Override - @Nullable - public QueryView getTaskListQueryView(ViewContext context, @Nullable SimpleFilter filter) - { - UserSchema schema = QueryService.get().getUserSchema(context.getUser(), context.getContainer(), WorkflowQuerySchema.NAME); - if (schema == null) - { - return null; - } - else - { - QuerySettings settings = schema.getSettings(context, QueryView.DATAREGIONNAME_DEFAULT, WorkflowQuerySchema.TABLE_TASK); - settings.setMaxRows(Table.ALL_ROWS); - if (filter != null) - settings.setBaseFilter(filter); - return new QueryView(schema, settings, null); - } - } - - /** - * Sends the message indicated by the message name to the provided executionId - * setting the processVariables as provided. - * @param messageName - name of the message to send - * @param executionId - identifier for the execution receiving the message (the id of the execution to deliver the message to) - * @param processVariables - variables that represent the payload of this message - */ - @Override - public void sendMessage(String messageName, String executionId, @Nullable Map processVariables) - { - if (processVariables != null) - getRuntimeService().messageEventReceived(messageName, executionId, processVariables); - else - getRuntimeService().messageEventReceived(messageName, executionId); - } - - /** - * Completes a task in a workflow given the id of the task - * @param taskId the id of an active task - * @param user the user completing the task - * @param container the container in which the task is being completed - * @throws ActivitiObjectNotFoundException when no task exists with the given id. - * @throws ActivitiException when this task is pending delegation. - */ - @Override - public void completeTask(@NotNull String taskId, User user, Container container) throws Exception - { - WorkflowTask task = new WorkflowEngineTaskImpl(getTaskService().createTaskQuery().taskId(taskId).singleResult()); - - if (!task.isActive()) - throw new Exception("No such task (id = " + taskId + ")"); - if (!task.canComplete(user, container)) - throw new UnauthorizedException("User does not have permission to complete this task"); - - if (task.isDelegated()) - getTaskService().resolveTask(taskId); - else - getTaskService().complete(taskId); - } - - /** - * Claim a task that one (or more) of the user's group is currently a candidate group for - * @param taskId id of the task to be claimed - * @param userId id of the user who is claiming the task - * @param container the container in which the task is being handled - * @throws Exception if user - */ - @Override - public void claimTask(@NotNull String taskId, @NotNull Integer userId, Container container) throws Exception - { - User user = UserManager.getUser(userId); - if (user == null) - throw new Exception("No such user: (id = " + userId + ")"); - - WorkflowTask task = getTask(taskId, container); - - if (task == null || !task.isActive()) - throw new Exception("No such task (id = " + taskId + ")"); - if (!task.canClaim(user, container)) - throw new UnauthorizedException("User " + user + " cannot claim task " + taskId); - - getTaskService().setOwner(taskId, String.valueOf(userId)); - getTaskService().claim(taskId, String.valueOf(userId)); - } - - /** - * Assign a particular task to a user given the id of the user - * @param taskId id of the task to be assigned - * @param assigneeId id of the user to whom the task should be assigned - * @param user principal doing the assignment - * @param container container context for this assignment - * @throws Exception if there is no user or task specified - */ - @Override - public void assignTask(@NotNull String taskId, @NotNull Integer assigneeId, User user, Container container) throws Exception - { - if (assigneeId == null) - { - throw new Exception("No user specified"); - } - else if (taskId == null) - { - throw new Exception("No task specified"); - } - else - { - User assignee = UserManager.getUser(assigneeId); - if (assignee == null) - throw new Exception("No such user: (id = " + assigneeId + ")"); - - WorkflowTask task = getTask(taskId, container); - - if (task == null) - throw new Exception("No such task (id = " + taskId + ")"); - if (!task.canAssign(user, container)) - throw new Exception("User " + user + " does not have permission to assign tasks"); - - getTaskService().setOwner(taskId, String.valueOf(assigneeId)); - getTaskService().setAssignee(taskId, String.valueOf(assigneeId)); - } - } - - /** - * Delegate a task to a particular task (retaining ownership of the task for later review of results) - * @param taskId id of the task to be delegated - * @param user principal doing the delegation - * @param designateeId id of the user to delegate to - * @param container context in which the delegation is being made - * @throws Exception if there is no delegate or task specified or if the user cannot delegate the task - */ - @Override - public void delegateTask(@NotNull String taskId, @NotNull User user, @NotNull Integer designateeId, Container container) throws Exception - { - - User designatee = UserManager.getUser(designateeId); - if (designatee == null) - throw new Exception("No such user: (id = " + designateeId + ")"); - WorkflowTask task = getTask(taskId, container); - - if (task == null || !task.isActive()) - throw new Exception("No such task (id = " + taskId + ")"); - if (!task.canDelegate(user, container)) - throw new Exception("User " + user + " does not have permission to delegate tasks"); - getTaskService().delegateTask(taskId, String.valueOf(designateeId)); - getTaskService().setOwner(taskId, String.valueOf(user.getUserId())); - - } - - /** - * Creates a new process instance for a given workflow starting at the message start event provided - * @param moduleName - name of the module in which the workflow is defined - * @param processDefinitionKey - the unique key for this process definition (also the prefix of the bpmn.xml file) - * @param processVariables - the set of variables to associate with this process instance (should contain at least the INITIATOR_ID variable) - * @param container - the container in which this process is being created - * @param startMessage - the id of the message element defined for the start event - * @return id of the process instance created - * @throws FileNotFoundException if the bpmn.xml file that defines the process does not exist and it is necessary to deploy a new instance of this model in this container - */ - @Override - public String startWorkflow(@NotNull String moduleName, @NotNull String processDefinitionKey, @NotNull Map processVariables, @NotNull Container container, @NotNull String startMessage) throws FileNotFoundException - { - makeContainerDeployment(moduleName, processDefinitionKey, container); - - ProcessInstance instance = getRuntimeService().startProcessInstanceByMessageAndTenantId(startMessage, processVariables, container.getId()); - return instance.getId(); - } - - /** - * Creates a new process instance for a given workflow starting at the message start event provided - * @param moduleName - name of the module in which the workflow is defined - * @param processDefinitionKey - the unique key for this process definition (also the prefix of the bpmn.xml file) - * @param processVariables - the set of variables to associate with this process instance (should contain at least the INITIATOR_ID variable) - * @param container - the container in which this process is being created - * @param startMessage - the id of the message element defined for the start event - * @return id of the process instance created - * @throws FileNotFoundException if the bpmn.xml file that defines the process does not exist and it is necessary to deploy a new instance of this model in this container - */ - public String startWorkflow(@NotNull String moduleName, @NotNull String processDefinitionKey, @NotNull Map processVariables, @NotNull User initiator, @NotNull Container container, @NotNull String startMessage) throws FileNotFoundException - { - makeContainerDeployment(moduleName, processDefinitionKey, container); - - processVariables.put(WorkflowProcess.INITIATOR_ID, String.valueOf(initiator.getUserId())); - processVariables.put(WorkflowProcess.CONTAINER_ID, String.valueOf(container.getId())); - ProcessInstance instance = getRuntimeService().startProcessInstanceByMessageAndTenantId(startMessage, processVariables, container.getId()); - return instance.getId(); - } - - /** - * Creates a new process instance for the given workflow and returns the id for this new instance. - * @param moduleName - the name of the module in which the process definition key is defined - * @param processDefinitionKey - the unique key for this process definition - * @param name - the human-readable name for the process - * @param processVariables - the set of variables to associate with this process instance (should contain at least the INITIATOR_ID variable) - * @param container the container in which this process is being created - * @return the id of the new process instance for this workflow - */ - @Override - public String startWorkflow(@NotNull String moduleName, @NotNull String processDefinitionKey, @Nullable String name, @NotNull Map processVariables, @Nullable Container container) throws FileNotFoundException - { - - makeContainerDeployment(moduleName, processDefinitionKey, container); - - ProcessInstanceBuilder builder = getRuntimeService().createProcessInstanceBuilder().processDefinitionKey(processDefinitionKey); - if (name != null) { - builder.processInstanceName(name); - } - if (container != null) - builder.tenantId(container.getId()); - for (Map.Entry variable : processVariables.entrySet()) - { - builder.addVariable(variable.getKey(), variable.getValue()); - } - builder.addVariable(WorkflowProcess.CREATED_DATE, new Date()); // CONSIDER this could be retrieved from the corresponding entry in the History table - ProcessInstance instance = builder.start(); - - return instance.getId(); - } - - /** - * Gets the list of jobs taht are currently active for the given processInstanceId in the given container, - * or in all containers if container is null - * @param processInstanceId instance for which tasks are to be retrieved - * @param container container in which the process instnace is active - * @return list of workflow jobs, or an empty list of there are none - */ - @Override - public List getCurrentProcessJobs(@NotNull String processInstanceId, @Nullable Container container) - { - JobQuery query = getManagementService().createJobQuery().processInstanceId(processInstanceId); - if (container != null) - query.jobTenantId(container.getId()); - List list = new ArrayList<>(); - for (Job job : query.list()) - { - list.add(new WorkflowJobImpl(job)); - } - return list; - } - - /** - * Gets the list of tasks that are currently active for the given processInstanceId in the given container, - * or in all containers if container is null - * @param processInstanceId instance for which tasks are to be retrieved - * @param container container in which the process instance is active - * @return list of workflow tasks, or an empty list if there are none - */ - @Override - @NotNull - public List getCurrentProcessTasks(@NotNull String processInstanceId, @Nullable Container container) - { - TaskQuery query = getTaskService().createTaskQuery().processInstanceId(processInstanceId); - if (container != null) - query.taskTenantId(container.getId()); - - List tasks = new ArrayList<>(); - for (Task engineTask : query.list()) - tasks.add(new WorkflowEngineTaskImpl(engineTask)); - - return tasks; - } - - /** - * Gets the list of completed tasks for the given processInstanceId in the given container, - * or in all containers if container is null - * @param processInstanceId instance for which tasks are to be retrieved - * @param container container in which the process instance is active - * @return list of workflow tasks, or an empty list of there are none - */ - @Override - @NotNull - public List getCompletedProcessTasks(@NotNull String processInstanceId, @Nullable Container container) - { - HistoricTaskInstanceQuery query = getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).finished(); - if (container != null) - query.taskTenantId(container.getId()); - - List tasks = new ArrayList<>(); - for (HistoricTaskInstance historicTask : query.list()) - tasks.add(new WorkflowHistoricTaskImpl(historicTask)); - - return tasks; - } - - /** - * Count of the number of process instances in the current container that were initiated by the given user, - * or by any user if this user has administrative permissions. If the container is null, all process instances - * for the given definition key will be returned. - * @param processDefinitionKey identifier for the process definition - * @param user user making the request - * @param container container of context, or null for all containers - * @return number of process instances - */ - @Override - @NotNull - public Long getProcessInstanceCount(String processDefinitionKey, @NotNull User user, @Nullable Container container) - { - ProcessInstanceQuery query = getRuntimeService().createProcessInstanceQuery() - .processDefinitionKey(processDefinitionKey); - if (container != null && !container.hasPermission(user, AdminPermission.class)) - { - query.variableValueEquals("initiatorId", String.valueOf(user.getUserId())); - } - if (container != null) - query.processInstanceTenantId(container.getId()); - return query.count(); - } - - /** - * Count of the number of process instances, both active an inactive, but not including deleted ones, in the given container for a given definiiton key - * @param processDefinitionKey identifier of the process definition - * @param container container of context, or null for all containers - * @return number of active and inactive process instances, excluding deleted instances - */ - @Override - @NotNull - public Long getProcessInstanceCount(String processDefinitionKey, @Nullable Container container) - { - HistoricProcessInstanceQuery query = getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey(processDefinitionKey); - if (container != null) - query.processInstanceTenantId(container.getId()); - // deleted instances should not be counted - query.notDeleted(); - return query.count(); - } - - /** - * Given the process definition key, returns the corresponding list of process instances in the - * current container - * @param processDefinitionKey identifier for the process definition - * @param container container of context, or null for all containers - * @return the list of ProcessInstance objects - */ - public List getProcessInstanceList(String processDefinitionKey, @NotNull Container container) - { - ProcessInstanceQuery query = getRuntimeService().createProcessInstanceQuery().processDefinitionKey(processDefinitionKey); - query.processInstanceTenantId(container.getId()); - return query.list(); - } - - @Override - public WorkflowProcess getWorkflowProcess(@NotNull String processInstanceId) - { - ProcessInstance instance = getProcessInstance(processInstanceId); - if (instance != null) - return new WorkflowProcessImpl(instance); - else - { - HistoricProcessInstance historicInstance = getHistoricProcessInstance(processInstanceId); - if (historicInstance == null) - return null; - else - return new WorkflowProcessImpl(historicInstance); - } - } - - /** - * Given the id of a process instance, returns the corresponding process instance - * @param processInstanceId id of process instance to retrieve - * @return ProcessInstance corresponding to the given id. - */ - public ProcessInstance getProcessInstance(@NotNull String processInstanceId) - { - return getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - } - - /** - * Given the process definition key, returns the corresponding list of historic process instances in the - * current container - * @param processDefinitionKey identifier for the process definition - * @param container container of context, or null for all containers - * @param finishedOnly include data for only finished process instances - * @return the list of HistoricProcessInstance objects - */ - public List getHistoricProcessInstanceList(String processDefinitionKey, @NotNull Container container, Boolean finishedOnly) - { - HistoricProcessInstanceQuery query = getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey(processDefinitionKey); - query.processInstanceTenantId(container.getId()); - if (finishedOnly) - query.finished(); - return query.list(); - } - - /** - * Given the id of a process instance, returns the corresponding historic process instance - * @param processInstanceId id of process instance to retrieve - * @return HistoricProcessInstance corresponding to the given id. - */ - public HistoricProcessInstance getHistoricProcessInstance(@NotNull String processInstanceId) - { - return getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - } - - /** - * Returns the set of variables associated with the given historicProcessInstance - * @param processInstanceId id of the historic process instance in question - * @return the set of process instance variables for this historic process instance - */ - @Override - public Map getHistoricProcessInstanceVariables(@NotNull String processInstanceId) - { - try - { - HistoricProcessInstance processInstance = getHistoryService().createHistoricProcessInstanceQuery().includeProcessVariables().processInstanceId(processInstanceId).singleResult(); - return processInstance.getProcessVariables(); - } - catch (PersistenceException e) - { - return new HashMap<>(); - } - } - - /** - * Given the id of a particular task, will update the process instance variables (not the task variables) - * for the instance that contains this task with the given variables. New variables will be added; existing - * variables will be replaced. Task variables are left alone. - * @param taskId - - * id of the task whose process variables should be updated - * @param variables - - * variables that will be merged into the existing set of variables - * - */ - @Override - public void updateProcessVariables(@NotNull String taskId, @Nullable Map variables) - { - getTaskService().setVariables(taskId, variables); - } - - /** - * Given the id of a particular task, will update the variables for this task (not the process instance) - * New variables will be added; existing variables will be replaced. Process variables are left alone. - * @param taskId - - * id of the task whose variables should be updated - * @param variables - - * variables that will be merged into the existing set of variables - * - */ - @Override - public void updateTaskVariables(@NotNull String taskId, @Nullable Map variables) - { - getTaskService().setVariablesLocal(taskId, variables); - } - - /** - * Remove the process instance whose id is supplied, logging the reason for the deletion if provided - * @param processInstanceId id of the process instance to be removed - * @param reason reason for deletion (may be null) - */ - @Override - public void deleteProcessInstance(@NotNull String processInstanceId, @Nullable String reason) - { - logger.info("Deleting process instance for processInstanceId " + processInstanceId); - getRuntimeService().deleteProcessInstance(processInstanceId, reason); - } - - /** - * Deletes an active process instance given a key and value that uniquely identify it within a particular container. - * Historic process instances with no active counterparts will not be deleted. - * @param key the key for the variable identifier - * @param value the value for the variable identifier - * @param reason (optional) reason for deletion - * @param container the container context - * @throws RuntimeException if there are problems retrieving the process instance using the given variable data or deleting it - */ - @Override - public void deleteProcessInstance(String key, String value, @Nullable String reason, @NotNull Container container) throws RuntimeException - { - try - { - WorkflowProcess process = getWorkflowProcessForVariable(key, value, container); - if (process != null && process.isActive()) - { - deleteProcessInstance(process.getProcessInstanceId(), reason); - } - } - catch (Exception e) - { - throw new RuntimeException("Unable to delete process instance for key '" + key + "' and value '" + value + "'", e); - } - } - - /** - * Deletes a set of process instances given a key and set of values that each uniquely identify a process within a particular container - * @param key the key for the variable identifier - * @param values the values for the variable identifier - * @param reason (optional) reason for deletion - * @param container the container context - * @throws RuntimeException if there are problems retrieving a process instance using the given variable data or deleting one - */ - @Override - public void deleteProcessInstances(String key, List values, @Nullable String reason, @NotNull Container container) throws RuntimeException - { - for (Object value : values) - { - logger.info("Deleting process instance for key " + key + " and value " + value); - deleteProcessInstance(key, value.toString(), reason, container); - } - } - - /** - * Returns the set of variables associated with the given processInstance as well as a list of the current active tasks for that instance - * @param processInstanceId id of the process instance in question - * @return the set of process instance variables for this process instance - */ - @Override - public Map getProcessInstanceVariables(@NotNull String processInstanceId) - { - try - { - ProcessInstance processInstance = getRuntimeService().createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInstanceId).singleResult(); - if (processInstance != null) - return processInstance.getProcessVariables(); - else - return Collections.emptyMap(); - } - catch (PersistenceException e) - { - return Collections.emptyMap(); - } - } - - /** - * Returns the set of variables associated with the given taskId. - * Does not include the process instance variables for the corresponding process instance. - * @param taskId id of the task in question - * @return the set of task variables for this task - */ - @Override - public Map getTaskVariables(@NotNull String taskId) - { - return getTaskService().getVariablesLocal(taskId); - } - - /** - * Returns the latest version of the process definition corresponding to the provided key - * @param processDefinitionKey key identifying the process definition - * @param container container in which the process is defined - * @return process definition for the given key - */ - public ProcessDefinition getProcessDefinition(@NotNull String processDefinitionKey, @Nullable Container container) - { - ProcessDefinitionQuery query = getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey); - if (container != null) - { - query.processDefinitionTenantId(container.getId()); - } - else - { - query.processDefinitionWithoutTenantId(); - } - return query.latestVersion().singleResult(); - } - - /** - * @param processDefinitionId unique id of a process definition - * @param container container in which the process is defined - * @return name of the module that this process definition comes from - */ - @Override - public String getProcessDefinitionModule(@NotNull String processDefinitionId, Container container) - { - Lsid lsid = new Lsid(WorkflowManager.get().getProcessDefinition(getProcessDefinitionKey(processDefinitionId), container).getCategory()); - return lsid.getObjectId(); - } - - /** - * @param container the container for which this query is being made - * @return the number of process definitions currently deployed in the container, or defined without a container if null - */ - protected long getProcessDefinitionCount(@Nullable Container container) - { - ProcessDefinitionQuery query = getRepositoryService().createProcessDefinitionQuery(); - if (container != null) - query.processDefinitionTenantId(container.getId()); - else - query.processDefinitionWithoutTenantId(); - return query.count(); - } - - public List getProcessDefinitionList(@Nullable Container container) - { - ProcessDefinitionQuery query = getRepositoryService().createProcessDefinitionQuery(); - if (container != null) - { - query.processDefinitionTenantId(container.getId()); - } - return query.latestVersion().list(); - } - - @Override - public Map getProcessDefinitionNames(@Nullable Container container) - { - Map keyToNameMap = new HashMap<>(); - - List definitions = WorkflowManager.get().getProcessDefinitionList(container); - for (ProcessDefinition definition : definitions) - { - keyToNameMap.put(definition.getKey(), definition.getName() == null ? definition.getKey() : definition.getName()); - } - return keyToNameMap; - } - - @Override - public Map getStartFormFields(String processDefinitionKey) - { - StartFormData form = getFormService().getStartFormData(processDefinitionKey); - List properties = form.getFormProperties(); - Map fields = new HashMap<>(); - for (FormProperty property : properties) - { - fields.put(property.getId(), new TaskFormFieldImpl(property)); - } - return fields; - } - - @Override - public Map getFormFields(String taskId) - { - TaskFormData form = getFormService().getTaskFormData(taskId); - List properties = form.getFormProperties(); - Map fields = new HashMap<>(); - for (FormProperty property : properties) - { - fields.put(property.getId(), new TaskFormFieldImpl(property)); - } - return fields; - } - - @Override - public String getProcessDefinitionKey(@NotNull String processDefinitionId) - { - ProcessDefinition definition = getRepositoryService().createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); - if (definition != null) - return definition.getKey(); - else - return null; - } - - @Override - public InputStream getProcessDiagram(@NotNull String processInstanceId) - { - ProcessInstance instance = getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - - return getRepositoryService().getProcessDiagram(instance.getProcessDefinitionId()); - } - - @Override - public InputStream getProcessDiagramByKey(@NotNull String processDefinitionKey, @Nullable Container container) - { - ProcessDefinitionQuery query = getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey); - if (container != null) - { - query.processDefinitionTenantId(container.getId()); - } - ProcessDefinition definition = query.latestVersion().singleResult(); - if (definition != null) - return getRepositoryService().getProcessDiagram(definition.getId()); - else - return null; - } - - public static String getDeploymentResourceNameFromDefinitionKey(String moduleName, String workflowDefinitionKey) - { - return getDeploymentResourceNameFromFilename(moduleName,workflowDefinitionKey + WORKFLOW_FILE_NAME_EXTENSION); - } - - private static String getDeploymentResourceNameFromFilename(String moduleName, String filename) - { - return moduleName + ":" + filename; - } - - private static Path getModelPathFromResourceName(String moduleName, String resourceName) - { - return WORKFLOW_MODEL_PATH.append(Path.parse(StringUtils.substringAfter(resourceName, moduleName + ":"))); - } - - public void makeContainerDeployment(@NotNull String moduleName, @NotNull String processDefinitionKey, @Nullable Container container) throws FileNotFoundException - { - // get the deployment in the global scope, referencing the cache - Deployment globalDeployment = DEPLOYMENT_CACHE.getResourceMap(ModuleLoader.getInstance().getModule(moduleName)).get(processDefinitionKey); - - // find the latest version for this container and compare deployment time to the time for the global version - ProcessDefinition containerDef = getProcessDefinition(processDefinitionKey, container); - if (containerDef != null) - { - Deployment containerDeployment = getDeployment(containerDef.getDeploymentId()); - // if the container version was deployed after the global version, there's nothing more to do - if (containerDeployment != null && containerDeployment.getDeploymentTime().after(globalDeployment.getDeploymentTime())) - return; - } - - - ProcessDefinition globalDefinition = getProcessDefinition(processDefinitionKey, null); - - // deploy a (newer) version in this container - if (globalDefinition != null) - { - Resource modelResource = ModuleLoader.getInstance() - .getResource(moduleName, getModelPathFromResourceName(moduleName, globalDefinition.getResourceName())); - deployWorkflow(moduleName, modelResource, container); - } - else - throw new FileNotFoundException("No process definition for key " + processDefinitionKey); - } - - private Deployment getDeployment(@NotNull String deploymentId) - { - return getRepositoryService().createDeploymentQuery().deploymentId(deploymentId).singleResult(); - } - - private List getDeployments(@NotNull Container container) - { - return getRepositoryService().createDeploymentQuery().deploymentTenantId(container.getId()).list(); - } - - @Override - public void deleteDeployments(@NotNull Container container) - { - for (Deployment deployment : getDeployments(container)) - { - getRepositoryService().deleteDeployment(deployment.getId(), true); - } - } - - public String deployWorkflow(@NotNull String moduleName, @NotNull File modelFile, @Nullable Container container) throws FileNotFoundException - { - return deployWorkflow(moduleName, modelFile.getName(), new FileInputStream(modelFile), container); - } - - @Override - public String deployWorkflow(@NotNull String moduleName, @NotNull Resource modelResource, @Nullable Container container) throws FileNotFoundException - { - try - { - return deployWorkflow(moduleName, modelResource.getName(), modelResource.getInputStream(), container); - } - catch (IOException e) - { - throw new FileNotFoundException(e.getMessage()); - } - } - - private String deployWorkflow(@NotNull String moduleName, @NotNull String filename, @NotNull InputStream stream, @Nullable Container container) - { - DeploymentBuilder builder = getRepositoryService().createDeployment().addInputStream(getDeploymentResourceNameFromFilename(moduleName, filename), stream); - if (container != null) - builder.tenantId(container.getId()); - Deployment deployment = builder.deploy(); - return deployment.getId(); - } - - @Override - public void deleteWorkflow(@NotNull String deploymentId) - { - getRepositoryService().deleteDeployment(deploymentId); - } - - protected RuntimeService getRuntimeService() - { - return getProcessEngine().getRuntimeService(); - } - - protected HistoryService getHistoryService() - { - return getProcessEngine().getHistoryService(); - } - - protected ManagementService getManagementService() - { - return getProcessEngine().getManagementService(); - } - - protected TaskService getTaskService() - { - return getProcessEngine().getTaskService(); - } - - protected RepositoryService getRepositoryService() - { - return getProcessEngine().getRepositoryService(); - } - - protected FormService getFormService() - { - return getProcessEngine().getFormService(); - } - - private synchronized ProcessEngine getProcessEngine() - { - if (_processEngine == null) - { - ProcessEngineConfiguration processConfig; - DataSource dataSource = WorkflowSchema.getInstance().getSchema().getScope().getDataSource(); - - processConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(ACTIVITI_CONFIG_FILE) - .setDataSource(dataSource); - _processEngine = processConfig.buildProcessEngine(); - } - return _processEngine; - } - - - private static class WorkflowDeploymentCacheHandler implements ModuleResourceCacheHandler> - { - @Override - public Map load(Stream resources, Module module) - { - Map map = new HashMap<>(); - - resources - .filter(getFilter(WORKFLOW_FILE_NAME_EXTENSION)) - .forEach(resource -> - { - String filename = resource.getName(); - String processDefinitionKey = filename.indexOf(".") > 0 ? filename.substring(0, filename.indexOf(".")) : filename; - - Deployment deployment = getDeployment(resource, processDefinitionKey, module.getName()); - - if (null != deployment) - map.put(processDefinitionKey, deployment); - }); - - return unmodifiable(map); - } - - private Deployment getDeployment(Resource modelResource, String processDefinitionKey, String moduleName) - { - try - { - // find the latest process definition without a container - ProcessDefinition processDef = WorkflowManager.get().getProcessDefinition(processDefinitionKey, null); - String deploymentId; - if (processDef == null) // no such definition, we'll deploy one - { - deploymentId = WorkflowManager.get().deployWorkflow(moduleName, modelResource, null); - return WorkflowManager.get().getDeployment(deploymentId); - } - else - { - deploymentId = processDef.getDeploymentId(); - Deployment deployment = WorkflowManager.get().getDeployment(deploymentId); - // file is newer than deployment, so we'll deploy a new version - if (deployment.getDeploymentTime().before(new Date(modelResource.getLastModified()))) - { - deploymentId = WorkflowManager.get().deployWorkflow(moduleName, modelResource, null); - deployment = WorkflowManager.get().getDeployment(deploymentId); - } - return deployment; - } - } - catch (FileNotFoundException e) - { - return null; - } - } - } - - // - //JUnit TestCase - // - @TestWhen(TestWhen.When.BVT) - public static class TestCase extends Assert - { - private static final String _testDirName = "/_jUnitWorkflow"; - private static final String PROCESS_DEF_KEY = "submitForApprovalWithoutRetry"; - private static User _user; - private static Container _container; - private static WorkflowManager _manager; - private static Map _processVariables = new HashMap<>(); - - @BeforeClass - public static void setup() - { - _manager = WorkflowManager.get(); - _user = TestContext.get().getUser(); - assertNotNull("Should have access to a user", _user); - _processVariables.put(WorkflowProcess.INITIATOR_ID, _user.getUserId()); - - deleteTestContainer(); - _container = ContainerManager.ensureContainer(_testDirName, _user); - } - - @AfterClass - public static void cleanup() - { - deleteTestContainer(); - } - - @Test - public void testStartWorkflow() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testStartWorkflow", _processVariables, _container); - assertNotNull(processId); - ProcessInstance instance = _manager.getProcessInstance(processId); - assertNotNull("Should have an active process instance", instance); - assertEquals("testStartWorkflow", instance.getName()); - Map instanceVars = _manager.getProcessInstanceVariables(processId); - assertNotNull("Should have added a created date", instanceVars.get(WorkflowProcess.CREATED_DATE)); - assertEquals("Should have retained the initiator id", instanceVars.get(WorkflowProcess.INITIATOR_ID), _processVariables.get(WorkflowProcess.INITIATOR_ID)); - List tasks = _manager.getCurrentProcessTasks(processId, _container); - assertEquals("Number of current tasks not as expected", 1, tasks.size()); - List completedTasks = _manager.getCompletedProcessTasks(processId, _container); - assertEquals("Number of completed tasks not as expected", 0, completedTasks.size()); - } - - @Test - public void testUpdateVariables() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testTaskClaiming", _processVariables, _container); - List tasks = _manager.getCurrentProcessTasks(processId, _container); - WorkflowTask task = tasks.get(0); - Map newVariables = new HashMap<>(); - newVariables.put("adding", "this"); - newVariables.put(WorkflowProcess.DATA_ACCESS_KEY, "updated"); - _manager.updateProcessVariables(task.getId(), newVariables); - WorkflowTask updatedTask = _manager.getTask(task.getId(), _container); - Map updatedVars = updatedTask.getProcessVariables(); - assertEquals("New variable not present in updated variables list", "this", updatedVars.get("adding")); - assertEquals("Updated variable not updated", "updated", updatedVars.get(WorkflowProcess.DATA_ACCESS_KEY)); - } - - @Test - public void testTaskClaiming() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testTaskClaiming", _processVariables, _container); - List tasks = _manager.getCurrentProcessTasks(processId, _container); - assertEquals("Number of current tasks not as expected", 1, tasks.size()); - WorkflowTask task = tasks.get(0); - _manager.claimTask(task.getId(), _user.getUserId(), _container); - WorkflowTask claimedTask = _manager.getTask(task.getId(), _container); - assertEquals("Claimed task should be owned by current user", (Integer) _user.getUserId(), claimedTask.getOwnerId()); - assertEquals("Claimed task should be assigned to current user", (Integer) _user.getUserId(), claimedTask.getAssigneeId()); - } - - @Test - public void testTaskAssignment() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testTaskAssignment", _processVariables, _container); - List tasks = _manager.getCurrentProcessTasks(processId, _container); - assertEquals("Number of current tasks not as expected", 1, tasks.size()); - WorkflowTask task = tasks.get(0); - _manager.assignTask(task.getId(), _user.getUserId(), _user, _container); - WorkflowTask assignedTask = _manager.getTask(task.getId(), _container); - assertEquals("Assigned task should also be owned", _user.getUserId(), (int) assignedTask.getOwnerId()); - assertEquals("Assigned task should be assigned to new user", _user.getUserId(), (int) assignedTask.getAssigneeId()); - } - - @Test - public void testTaskDelegation() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testTaskAssignment", _processVariables, _container); - List tasks = _manager.getCurrentProcessTasks(processId, _container); - assertEquals("Number of current tasks not as expected", 1, tasks.size()); - WorkflowTask task = tasks.get(0); - _manager.delegateTask(task.getId(), _user, _user.getUserId(), _container); - WorkflowTask delegatedTask = _manager.getTask(task.getId(), _container); - assertEquals("Delegated task should be owned by the current user", _user.getUserId(), (int) delegatedTask.getOwnerId()); - assertEquals("Assigned task should be assigned to new user", _user.getUserId(), (int) delegatedTask.getAssigneeId()); - } - - @Test - public void testCompleteTask() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testTaskClaiming", _processVariables, _container); - List tasks = _manager.getCurrentProcessTasks(processId, _container); - assertEquals("Number of current tasks not as expected", 1, tasks.size()); - WorkflowTask task = tasks.get(0); - _manager.claimTask(task.getId(), _user.getUserId(), _container); - Map variables = new HashMap<>(); - variables.put("approved", true); - _manager.updateProcessVariables(task.getId(), variables); - _manager.completeTask(task.getId(), _user, _container); - List completedTasks = _manager.getCompletedProcessTasks(processId, _container); - assertEquals("Number of completed tasks not as expected", 1, completedTasks.size()); - List currentTasks = _manager.getCurrentProcessTasks(processId, _container); - assertEquals("Number of current tasks not as expected", 1, currentTasks.size()); - } - - @Test - public void testDeleteProcessInstance() throws Exception - { - String processId = _manager.startWorkflow(WorkflowModule.NAME, PROCESS_DEF_KEY, "testTaskClaiming", _processVariables, _container); - _manager.deleteProcessInstance(processId, "testDeleteProcessInstance"); - assertNull("Should not be able to retrieve a deleted process instance as an active process", _manager.getProcessInstance(processId)); - HistoricProcessInstance instance = _manager.getHistoricProcessInstance(processId); - assertNotNull(instance); - assertEquals("Delete reason not as expected for historic instance", "testDeleteProcessInstance", instance.getDeleteReason()); - List instances = _manager.getHistoricProcessInstanceList(PROCESS_DEF_KEY, _container, true); - assertEquals("Number of historic process instances not as expected", 1, instances.size()); - } - - @Test - public void testModuleResourceCache() - { - // Load all the module-defined workflow models to ensure no exceptions - int deploymentCount = ModuleLoader.getInstance().getModules().stream() - .map(DEPLOYMENT_CACHE::getResourceMap) - .mapToInt(Map::size) - .sum(); - - logger.info(deploymentCount + " workflow deployments defined in all modules"); - - // Make sure the cache retrieves the expected number of test models in this module - - Module workflow = ModuleLoader.getInstance().getModule(WorkflowModule.NAME); - - assertEquals("Workflow models from workflow module", 2, DEPLOYMENT_CACHE.getResourceMap(workflow).size()); - } - - private static void deleteTestContainer() - { - Container container = ContainerManager.getForPath(_testDirName); - if (null != container) - { - ContainerManager.deleteAll(ContainerManager.getForPath(_testDirName), _user); - List deployments = _manager.getDeployments(_container); - assertEquals("Number of deployments after deletion of container not as expected", 0, deployments.size()); - List active = _manager.getProcessInstanceList(PROCESS_DEF_KEY, _container); - assertEquals("Number of active process instances after deletion of container not as expected", 0, active.size()); - List inactive = _manager.getHistoricProcessInstanceList(PROCESS_DEF_KEY, _container, false); - assertEquals("Number of inactive process instances after deletion of container not as expected", 0, inactive.size()); - } - } - } -} \ No newline at end of file diff --git a/src/org/labkey/workflow/WorkflowModule.java b/src/org/labkey/workflow/WorkflowModule.java deleted file mode 100644 index 12fe7c4..0000000 --- a/src/org/labkey/workflow/WorkflowModule.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.module.DefaultModule; -import org.labkey.api.module.ModuleContext; -import org.labkey.api.view.SimpleWebPartFactory; -import org.labkey.api.view.WebPartFactory; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.api.workflow.WorkflowService; -import org.labkey.workflow.query.WorkflowQuerySchema; -import org.labkey.workflow.view.WorkflowWebPart; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -public class WorkflowModule extends DefaultModule -{ - public static final String NAME = "Workflow"; - - @Override - public String getName() - { - return NAME; - } - - @Override - public @Nullable Double getSchemaVersion() - { - return 25.000; - } - - @Override - public boolean hasScripts() - { - return true; - } - - @Override - protected void init() - { - addController(WorkflowController.NAME, WorkflowController.class); - WorkflowQuerySchema.register(this); - WorkflowRegistry.registerPermissionsHandler(this, PermissionsHandlerImpl.class, true); - WorkflowService.setInstance(WorkflowManager.get()); - } - - @Override - public void doStartup(ModuleContext moduleContext) - { - // add a container listener so we'll know when our container is deleted: - ContainerManager.addContainerListener(new WorkflowContainerListener()); - } - - @Override - @NotNull - public Set getSchemaNames() - { - return Collections.singleton(WorkflowSchema.NAME); - } - - @NotNull - @Override - public Set getUnitTests() - { - return Set.of( - WorkflowManager.TestCase.class - ); - } - - @NotNull - @Override - protected Collection createWebPartFactories() - { - return List.of( - new SimpleWebPartFactory("Workflow List", WebPartFactory.LOCATION_BODY, WorkflowWebPart.class, null) - ); - } -} \ No newline at end of file diff --git a/src/org/labkey/workflow/WorkflowSchema.java b/src/org/labkey/workflow/WorkflowSchema.java deleted file mode 100644 index ccaf4ad..0000000 --- a/src/org/labkey/workflow/WorkflowSchema.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow; - -import org.labkey.api.data.DbSchema; -import org.labkey.api.data.DbSchemaType; - -public class WorkflowSchema -{ - private static final WorkflowSchema _instance = new WorkflowSchema(); - public static final String NAME = "workflow"; - - public static WorkflowSchema getInstance() - { - return _instance; - } - - private WorkflowSchema() - { - // private constructor to prevent instantiation from - // outside this class: this singleton should only be - // accessed via org.labkey.workflow.WorkflowSchema.getInstance() - } - - public DbSchema getSchema() - { - return DbSchema.get(NAME, DbSchemaType.Module); - } - -} diff --git a/src/org/labkey/workflow/delegate/DataManager.java b/src/org/labkey/workflow/delegate/DataManager.java deleted file mode 100644 index 1c5bfaf..0000000 --- a/src/org/labkey/workflow/delegate/DataManager.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.delegate; - -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.delegate.Expression; -import org.activiti.engine.delegate.JavaDelegate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.labkey.api.admin.notification.Notification; -import org.labkey.api.admin.notification.NotificationService; -import org.labkey.api.workflow.DataManagerConfig; - -import java.lang.reflect.InvocationTargetException; -import java.util.Map; - -/** - * Created by davebradlee on 7/20/15. - * - */ -public class DataManager implements JavaDelegate -{ - private static final Logger _log = LogManager.getLogger(DataManager.class); - private Expression _dataManagerClassName; - - public Expression getDataManagerClassName() - { - return _dataManagerClassName; - } - - @SuppressWarnings({"unused"}) - public void setDataManagerClassName(Expression dataManagerClassName) - { - _dataManagerClassName = dataManagerClassName; - } - - @SuppressWarnings({"unchecked"}) - private Class getDataManagerClass(DelegateExecution execution) throws ClassNotFoundException - { - return (Class ) Class.forName((String) getDataManagerClassName().getValue(execution)); - } - - private DataManagerConfig getDataManagerConfig(DelegateExecution execution) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException - { - return getDataManagerClass(execution).getDeclaredConstructor(Map.class).newInstance(execution.getVariables()); - } - - @Override - public void execute(DelegateExecution execution) throws Exception - { - DataManagerConfig dataManagerConfig = getDataManagerConfig(execution); - dataManagerConfig.doAction(); - execution.setVariables(dataManagerConfig.getVariables()); - - // give the config a chance to add a UI notification to the system for this data manager action - if (dataManagerConfig.shouldAddUINotification()) - { - Notification notification = new Notification(); - notification.setUserId(dataManagerConfig.getInitiator().getUserId()); - notification.setObjectId(execution.getProcessInstanceId()); - notification.setType(dataManagerConfig.getUINotificationType()); - - NotificationService.get().addNotification(dataManagerConfig.getContainer(), dataManagerConfig.getInitiator(), notification); - } - } -} diff --git a/src/org/labkey/workflow/delegate/EmailNotifier.java b/src/org/labkey/workflow/delegate/EmailNotifier.java deleted file mode 100644 index abc5500..0000000 --- a/src/org/labkey/workflow/delegate/EmailNotifier.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.delegate; - -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.delegate.Expression; -import org.activiti.engine.delegate.JavaDelegate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.labkey.api.admin.notification.Notification; -import org.labkey.api.admin.notification.NotificationService; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; -import org.labkey.api.settings.LookAndFeelProperties; -import org.labkey.api.util.ConfigurationException; -import org.labkey.api.util.ExceptionUtil; -import org.labkey.api.util.MailHelper; -import org.labkey.api.util.emailTemplate.EmailTemplate; -import org.labkey.api.workflow.NotificationConfig; - -import jakarta.mail.Address; -import jakarta.mail.internet.AddressException; -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import java.util.Map; - -/** - * A Java delegate that can be used within a workflow to send email to a set of users using an email template. - * - * N.B. There is a single instance of this class created for the serviceTask it is defined on. All process instances share - * the same class instance that will be used to all the execute method. - * See http://activiti.org/userguide/index.html#bpmnJavaServiceTaskXML - * - * Created by susanh on 6/8/15. - */ -public class EmailNotifier implements JavaDelegate -{ - private static final Logger _log = LogManager.getLogger(EmailNotifier.class); - private Expression _notificationClassName; - - public Expression getNotificationClassName() - { - return _notificationClassName; - } - - @SuppressWarnings({"unused"}) - public void setNotificationClassName(Expression notificationClassName) - { - _notificationClassName = notificationClassName; - } - - @SuppressWarnings({"unchecked"}) - private Class getNotificationClass(DelegateExecution execution) throws ClassNotFoundException - { - return (Class) Class.forName((String) getNotificationClassName().getValue(execution)); - } - - private NotificationConfig getNotificationConfig(DelegateExecution execution) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException - { - return getNotificationClass(execution).getDeclaredConstructor(Map.class).newInstance(execution.getVariables()); - } - - @Override - public void execute(DelegateExecution execution) throws Exception - { - NotificationConfig notificationConfig = getNotificationConfig(execution); - Container container = notificationConfig.getContainer(); - EmailTemplate template = notificationConfig.getEmailTemplate(execution.getProcessInstanceId(), execution.getVariables()); - if (template != null) - { - final List allAddresses = notificationConfig.getUsers(); - for (User user : allAddresses) - { - // give the config a chance to add a UI notification to the system for this email message - if (notificationConfig.shouldAddUINotification()) - { - Notification notification = new Notification(); - notification.setUserId(user.getUserId()); - notification.setObjectId(execution.getProcessInstanceId()); - notification.setType(notificationConfig.getUINotificationType()); - - NotificationService.get().addNotification(container, notificationConfig.getLogUser(), notification); - } - - String to = user.getEmail(); - try - { - MailHelper.ViewMessage m = MailHelper.createMessage(LookAndFeelProperties.getInstance(container).getSystemEmailAddress(), to); - Address[] addresses = m.getAllRecipients(); - if (addresses != null && addresses.length > 0) - { - m.setSubject(template.renderSubject(container)); - String body = template.renderBody(container); - m.setText(body); - - MailHelper.send(m, notificationConfig.getLogUser(), container); - } - } - catch (ConfigurationException | AddressException e) - { - _log.error("error sending service task notification email to " + to, e); - } - catch (Exception e) - { - _log.error("error sending service task notification email to " + to, e); - ExceptionUtil.logExceptionToMothership(null, e); - } - } - } - } - -} diff --git a/src/org/labkey/workflow/delegate/SystemTaskManager.java b/src/org/labkey/workflow/delegate/SystemTaskManager.java deleted file mode 100644 index 532b077..0000000 --- a/src/org/labkey/workflow/delegate/SystemTaskManager.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016 LabKey Corporation - * - * 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.labkey.workflow.delegate; - -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.delegate.Expression; -import org.activiti.engine.delegate.JavaDelegate; -import org.labkey.api.workflow.SystemTaskRunner; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.workflow.WorkflowManager; - -import java.lang.reflect.InvocationTargetException; -import java.util.Map; - -/** - * - * User: tgaluhn - * Date: 1/22/2016 - */ -public class SystemTaskManager implements JavaDelegate -{ - private Expression _taskRunnerClassName; - - public Expression getTaskRunnerClassName() - { - return _taskRunnerClassName; - } - - @SuppressWarnings({"unused"}) - public void setTaskRunnerClassName(Expression taskRunnerClassName) - { - _taskRunnerClassName = taskRunnerClassName; - } - - @SuppressWarnings({"unchecked"}) - private Class getTaskRunnerClass(DelegateExecution execution) throws ClassNotFoundException - { - return (Class) Class.forName((String) getTaskRunnerClassName().getValue(execution)); - } - - private SystemTaskRunner getTaskRunnerInstance(DelegateExecution execution) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException - { - Class taskRunnerClass = getTaskRunnerClass(execution); - try - { - WorkflowProcess process = WorkflowManager.get().getWorkflowProcess(execution.getProcessInstanceId()); - if (process != null) - { - return taskRunnerClass.getDeclaredConstructor(WorkflowProcess.class).newInstance(process); - } - else - { - return taskRunnerClass.getDeclaredConstructor(Map.class).newInstance(execution.getVariables()); - } - } - catch (NoSuchMethodException e) - { - return taskRunnerClass.getDeclaredConstructor(Map.class).newInstance(execution.getVariables()); - } - } - - @Override - public void execute(DelegateExecution execution) throws Exception - { - SystemTaskRunner runner = getTaskRunnerInstance(execution); - runner.doAction(); - execution.setVariables(runner.getVariables()); - } -} diff --git a/src/org/labkey/workflow/model/TaskFormFieldImpl.java b/src/org/labkey/workflow/model/TaskFormFieldImpl.java deleted file mode 100644 index ad0ef6d..0000000 --- a/src/org/labkey/workflow/model/TaskFormFieldImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - - -import org.activiti.engine.form.FormProperty; -import org.labkey.api.workflow.TaskFormField; - -/** - * Created by susanh on 5/25/15. - */ -public class TaskFormFieldImpl implements TaskFormField -{ - private FormProperty _engineFormProperty; - - public TaskFormFieldImpl(FormProperty engineFormProperty) - { - _engineFormProperty = engineFormProperty; - } - - @Override - public String getId() - { - return _engineFormProperty.getId(); - } - - @Override - public String getName() - { - return _engineFormProperty.getName(); - } - - @Override - public String getType() - { - return _engineFormProperty.getType().getName(); - } - - @Override - public Object getInformation(String key) { return _engineFormProperty.getType().getInformation(key); } - - @Override - public String getValue() - { - return _engineFormProperty.getValue(); - } - - @Override - public boolean isReadable() - { - return _engineFormProperty.isReadable(); - } - - @Override - public boolean isWritable() - { - return _engineFormProperty.isWritable(); - } - - @Override - public boolean isRequired() - { - return _engineFormProperty.isRequired(); - } -} diff --git a/src/org/labkey/workflow/model/WorkflowEngineTaskImpl.java b/src/org/labkey/workflow/model/WorkflowEngineTaskImpl.java deleted file mode 100644 index 47244c4..0000000 --- a/src/org/labkey/workflow/model/WorkflowEngineTaskImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - -import org.activiti.engine.task.DelegationState; -import org.activiti.engine.task.Task; -import org.labkey.api.action.Marshal; -import org.labkey.api.action.Marshaller; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; -import org.labkey.workflow.WorkflowManager; - -import java.util.Date; -import java.util.List; - -/** - * Created by cnathe on 9/25/2015. - */ -@Marshal(Marshaller.Jackson) -public class WorkflowEngineTaskImpl extends WorkflowTaskImpl -{ - private Task _engineTask; - - public WorkflowEngineTaskImpl(String taskId, Container container) - { - this(WorkflowManager.get().getEngineTask(taskId, container)); - _id = taskId; - } - - public WorkflowEngineTaskImpl(Task engineTask) - { - _engineTask = engineTask; - _taskInfo = _engineTask; - } - - - @Override - public void setName(String name) - { - _engineTask.setName(name); - } - - @Override - public void setDescription(String description) - { - _engineTask.setDescription(description); - } - - /** - * Set the user responsible for full completion of the task, which may include review of results - * if the task has been delegated - * @param owner - */ - @Override - public void setOwner(User owner) - { - _engineTask.setOwner(String.valueOf(owner.getUserId())); - } - - /** - * Set the user who is currently assigned to work on this task - * @param assignee - */ - @Override - public void setAssignee(User assignee) - { - _engineTask.setOwner(String.valueOf(assignee.getUserId())); - } - - @Override - public boolean isDelegated() - { - return _engineTask.getDelegationState() == DelegationState.PENDING; - } - - @Override - public boolean isReadyForReview() - { - return _engineTask.getDelegationState() == DelegationState.RESOLVED; - } - - public void setReadyForReview() - { - _engineTask.setDelegationState(DelegationState.RESOLVED); - } - - @Override - public void setDueDate(Date dueDate) - { - _engineTask.setDueDate(dueDate); - } - - @Override - public void delegate(User user) - { - _engineTask.delegate(String.valueOf(user.getUserId())); - } - - public void setParentTaskId(String parentTaskId) - { - _engineTask.setParentTaskId(parentTaskId); - } - - public void setContainer(String containerId) - { - _engineTask.setTenantId(containerId); - } - - @Override - public boolean isSuspended() - { - return _engineTask.isSuspended(); - } - - @Override - public boolean isActive() { return _engineTask != null; } - - @Override - public List getGroupIds() - { - if (_groupIds == null) - _groupIds = WorkflowManager.get().getCandidateGroupIds(getId()); - return _groupIds; - } - - @Override - public Date getEndDate() - { - return null; - } -} diff --git a/src/org/labkey/workflow/model/WorkflowHistoricTaskImpl.java b/src/org/labkey/workflow/model/WorkflowHistoricTaskImpl.java deleted file mode 100644 index e325650..0000000 --- a/src/org/labkey/workflow/model/WorkflowHistoricTaskImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - -import org.activiti.engine.history.HistoricTaskInstance; -import org.labkey.api.action.Marshal; -import org.labkey.api.action.Marshaller; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; -import org.labkey.workflow.WorkflowManager; - -import java.util.Date; -import java.util.List; - -/** - * Created by cnathe on 9/25/2015. - */ -@Marshal(Marshaller.Jackson) -public class WorkflowHistoricTaskImpl extends WorkflowTaskImpl -{ - private HistoricTaskInstance _historicTask; - - public WorkflowHistoricTaskImpl(String taskId, Container container) - { - this(WorkflowManager.get().getHistoricTask(taskId, container)); - _id = taskId; - } - - public WorkflowHistoricTaskImpl(HistoricTaskInstance historicTask) - { - _historicTask = historicTask; - _taskInfo = historicTask; - } - - - // Don't do anything for set methods for a HistoricTaskInstance - @Override - public void setName(String name) - {} - @Override - public void setDescription(String description) - {} - @Override - public void setOwner(User owner) - {} - @Override - public void setAssignee(User assignee) - {} - public void setReadyForReview() - {} - @Override - public void setDueDate(Date dueDate) - {} - public void setParentTaskId(String parentTaskId) - {} - public void setContainer(String containerId) - {} - @Override - public void delegate(User user) - {} - - @Override - public boolean isDelegated() - { - return false; - } - - @Override - public boolean isReadyForReview() - { - return false; - } - - @Override - public boolean isSuspended() - { - return false; - } - - @Override - public boolean isActive() { return false; } - - @Override - public List getGroupIds() - { - return null; - } - - @Override - public Date getEndDate() - { - return _historicTask.getEndTime(); - } -} diff --git a/src/org/labkey/workflow/model/WorkflowJobImpl.java b/src/org/labkey/workflow/model/WorkflowJobImpl.java deleted file mode 100644 index 01b841d..0000000 --- a/src/org/labkey/workflow/model/WorkflowJobImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - -import org.activiti.engine.runtime.Job; -import org.labkey.api.workflow.WorkflowJob; - -import java.util.Date; - -/** - * This class represents a system job (e.g., a timer) within a workflow. - * Created by susanh on 7/23/15. - */ -public class WorkflowJobImpl implements WorkflowJob -{ - private Job _engineJob; - - public WorkflowJobImpl(Job engineJob) - { - _engineJob = engineJob; - } - - @Override - public Date getDueDate() - { - return _engineJob.getDuedate(); - } - - @Override - public String getId() - { - return _engineJob.getId(); - } - - @Override - public String getProcessInstanceId() - { - return _engineJob.getProcessInstanceId(); - } - - @Override - public String getExecutionId() - { - return _engineJob.getExecutionId(); - } - - @Override - public String getProcessDefinitionId() - { - return _engineJob.getProcessDefinitionId(); - } - - @Override - public int getRetries() - { - return _engineJob.getRetries(); - } - - @Override - public String getExceptionMessage() - { - return _engineJob.getExceptionMessage(); - } - - @Override - public String getContainerId() - { - return _engineJob.getTenantId(); - } -} diff --git a/src/org/labkey/workflow/model/WorkflowProcessImpl.java b/src/org/labkey/workflow/model/WorkflowProcessImpl.java deleted file mode 100644 index 0db8545..0000000 --- a/src/org/labkey/workflow/model/WorkflowProcessImpl.java +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.ProcessInstance; -import org.labkey.api.action.HasViewContext; -import org.labkey.api.action.Marshal; -import org.labkey.api.action.Marshaller; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.exp.Lsid; -import org.labkey.api.security.User; -import org.labkey.api.security.UserManager; -import org.labkey.api.view.ViewContext; -import org.labkey.api.workflow.PermissionsHandler; -import org.labkey.api.workflow.TaskFormField; -import org.labkey.api.workflow.WorkflowJob; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.api.workflow.WorkflowTask; -import org.labkey.workflow.WorkflowManager; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by susanh on 5/3/15. - */ -@Marshal(Marshaller.Jackson) -public class WorkflowProcessImpl implements WorkflowProcess, HasViewContext -{ - private ProcessInstance _engineProcessInstance; - private HistoricProcessInstance _historicEngineProcessInstance; - - private String _processDefinitionKey; - private String _id = null; - private Map _processVariables = new HashMap<>(); - private Integer _initiatorId; - private String _processInstanceId; - private ViewContext _viewContext; - private String _name; // the name for this process instance - private List _currentTasks = Collections.EMPTY_LIST; - private List _completedTasks = Collections.EMPTY_LIST; - private Container _container; - private String _moduleName; - private PermissionsHandler _permissionsHandler; - private List _currentJobs = Collections.EMPTY_LIST; - - public WorkflowProcessImpl(String processDefinitionKey, String moduleName) - { - _processDefinitionKey = processDefinitionKey; - _moduleName = moduleName; - } - - public WorkflowProcessImpl(String id) - { - ProcessInstance instance = WorkflowManager.get().getProcessInstance(id); - if (instance != null) - setActiveEngineInstance(instance, true); - else - setHistoricEngineProcessInstance(WorkflowManager.get().getHistoricProcessInstance(id)); - _id = id; - } - - public WorkflowProcessImpl(ProcessInstance engineProcessInstance) - { - setActiveEngineInstance(engineProcessInstance, true); - } - - public WorkflowProcessImpl(HistoricProcessInstance historicProcessInstance) - { - this(historicProcessInstance, false); - } - - public WorkflowProcessImpl(HistoricProcessInstance historicProcessInstance, boolean includeCompletedTasks) - { - ProcessInstance instance = WorkflowManager.get().getProcessInstance(historicProcessInstance.getId()); - if (instance != null) - setActiveEngineInstance(instance, includeCompletedTasks); - else - setHistoricEngineProcessInstance(historicProcessInstance); - } - - private void setActiveEngineInstance(ProcessInstance instance, boolean includeCompletedTasks) - { - _engineProcessInstance = instance; - if (_engineProcessInstance != null) - { - setProcessVariables(WorkflowManager.get().getProcessInstanceVariables(_engineProcessInstance.getProcessInstanceId())); - setCurrentTasks(WorkflowManager.get().getCurrentProcessTasks(_engineProcessInstance.getProcessInstanceId(), _container)); - setCurrentJobs(WorkflowManager.get().getCurrentProcessJobs(_engineProcessInstance.getProcessInstanceId(), _container)); - if (includeCompletedTasks) - setCompletedTasks(WorkflowManager.get().getCompletedProcessTasks(_engineProcessInstance.getId(), _container)); - } - } - - private void setHistoricEngineProcessInstance(HistoricProcessInstance instance) - { - _historicEngineProcessInstance = instance; - - if (_historicEngineProcessInstance != null) - { - setCompletedTasks(WorkflowManager.get().getCompletedProcessTasks(_historicEngineProcessInstance.getId(), _container)); - - Map variables = WorkflowManager.get().getHistoricProcessInstanceVariables(_historicEngineProcessInstance.getId()); - variables.put("endDate", _historicEngineProcessInstance.getEndTime()); - setProcessVariables(variables); - } - } - - @JsonIgnore - public Container getContainer() - { - return _container; - } - - @Override - public String getId() - { - if (_engineProcessInstance != null) - return _engineProcessInstance.getId(); - if (_historicEngineProcessInstance != null) - return _historicEngineProcessInstance.getId(); - return _id; - } - - public void setId(String id) - { - _id = id; - } - - @Override - public String getProcessDefinitionKey() - { - if (_processDefinitionKey == null) - { - if (_engineProcessInstance != null) - { - if (_engineProcessInstance.getProcessDefinitionKey() == null) - _processDefinitionKey = WorkflowManager.get().getProcessDefinitionKey(_engineProcessInstance.getProcessDefinitionId()); - else - return _engineProcessInstance.getProcessDefinitionKey(); - } - else if (_historicEngineProcessInstance != null) - { - _processDefinitionKey = WorkflowManager.get().getProcessDefinitionKey(_historicEngineProcessInstance.getProcessDefinitionId()); - } - } - return _processDefinitionKey; - } - - @Override - public String getProcessDefinitionName() - { - if (getProcessDefinitionKey() == null) - return null; - ProcessDefinition definition = WorkflowManager.get().getProcessDefinition(getProcessDefinitionKey(), null); - if (definition != null) - return definition.getName(); - else - return null; - } - - @Override - public String getProcessDefinitionModule() - { - if (_engineProcessInstance == null && _historicEngineProcessInstance == null) - return _moduleName; - if (_moduleName == null) - { - Lsid lsid = new Lsid(WorkflowManager.get().getProcessDefinition(getProcessDefinitionKey(), _container).getCategory()); - _moduleName = lsid.getObjectId(); - } - return _moduleName; - } - - @Override - public void setProcessDefinitionKey(String processKey) - { - _processDefinitionKey = processKey; - } - - - @Override - public Map getProcessVariables() - { - return _processVariables; - } - - public void setProcessVariables(Map processVariables) - { - _processVariables = processVariables; - if (_processVariables.get(CONTAINER_ID) != null) - _container = ContainerManager.getForId((String) _processVariables.get(CONTAINER_ID)); - if (_processVariables.get(INITIATOR_ID) != null) - if (_processVariables.get(INITIATOR_ID) instanceof Integer) - setInitiatorId((Integer) _processVariables.get(INITIATOR_ID)); - else - setInitiatorId(Integer.valueOf((String) _processVariables.get(INITIATOR_ID))); - } - - @JsonIgnore - @Override - public Map getVariables() - { - return getProcessVariables(); - } - - @Override - public void setViewContext(ViewContext context) - { - _viewContext = context; - } - - @JsonIgnore - @Override - public ViewContext getViewContext() - { - return _viewContext; - } - - @Override - public Integer getInitiatorId() - { - return _initiatorId; - } - - public String getInitiatorName() - { - User initiator = getInitiator(); - if (initiator != null) - return initiator.getDisplayName(null); - return null; - } - - public void setInitiatorId(Integer initiatorId) - { - _initiatorId = initiatorId; - } - - @Override - public String getProcessInstanceId() - { - if (_engineProcessInstance != null) - return _engineProcessInstance.getProcessInstanceId(); - else if (_historicEngineProcessInstance != null) - return _historicEngineProcessInstance.getId(); - return _processInstanceId; - } - - public void setProcessInstanceId(String processInstanceId) - { - _processInstanceId = processInstanceId; - } - - @Override - public String getName() - { - if (_engineProcessInstance != null) - return _engineProcessInstance.getName(); - else if (_historicEngineProcessInstance != null) - return _historicEngineProcessInstance.getName(); - return _name; - } - - public void setName(String name) - { - _name = name; - } - - @Override - @JsonIgnore - public User getInitiator() - { - if (getInitiatorId() != null) - { - return UserManager.getUser(getInitiatorId()); - } - return null; - } - - @Override - public List getCurrentTasks() - { - return _currentTasks; - } - - public void setCurrentTasks(List currentTasks) - { - _currentTasks = currentTasks; - } - - @Override - public List getCompletedTasks() - { - return _completedTasks; - } - - public void setCompletedTasks(List completedTasks) - { - _completedTasks = completedTasks; - } - - @Override - public List getCurrentJobs() - { - return _currentJobs; - } - - public void setCurrentJobs(List currentJobs) - { - _currentJobs = currentJobs; - } - - private PermissionsHandler getPermissionsHandler(User user, Container container) - { - if (_permissionsHandler == null) - { - _permissionsHandler = WorkflowRegistry.get().getPermissionsHandler(getProcessDefinitionModule(), user, container); - } - return _permissionsHandler; - } - - @Override - public boolean canAccessData(User user, Container container) - { - return getPermissionsHandler(user, container).canAccessData(this); - } - - @Override - public boolean canView(User user, Container container) - { - return getPermissionsHandler(user, container).canView(this); - } - - @Override - public boolean canDelete(User user, Container container) - { - return getPermissionsHandler(user, container).canDelete(this); - } - - @Override - public boolean canDeploy(User user, Container container) - { - return getPermissionsHandler(user, container).canDeployProcess(getProcessDefinitionKey()); - } - - @Override - public boolean hasDiagram(Container container) - { - if (_engineProcessInstance == null) - return false; - ProcessDefinition definition = WorkflowManager.get().getProcessDefinition(_engineProcessInstance.getProcessDefinitionKey(), container); - return definition != null && definition.getDiagramResourceName() != null; - } - - @Override - public boolean isActive() - { - return _engineProcessInstance != null; - } - - @Override - public boolean isDeployed(Container container) - { - return WorkflowManager.get().getProcessDefinition(getProcessDefinitionKey(), container) != null; - } - - @Override - public Map getStartFormFields(Container container) - { - ProcessDefinition definition = WorkflowManager.get().getProcessDefinition(getProcessDefinitionKey(), container); - if (definition != null) - return WorkflowManager.get().getStartFormFields(definition.getId()); - else - return Collections.emptyMap(); - } - - @Override - public String getProcessExecutionId() - { - List tasks = getCurrentTasks(); - if (tasks.isEmpty()) - return null; - return tasks.get(0).getExecutionId(); - } -} diff --git a/src/org/labkey/workflow/model/WorkflowSummary.java b/src/org/labkey/workflow/model/WorkflowSummary.java deleted file mode 100644 index 11c0ad8..0000000 --- a/src/org/labkey/workflow/model/WorkflowSummary.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - -import org.activiti.engine.repository.ProcessDefinition; -import org.labkey.api.data.Container; -import org.labkey.api.exp.Lsid; -import org.labkey.api.security.User; -import org.labkey.api.security.UserPrincipal; -import org.labkey.api.workflow.PermissionsHandler; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.workflow.WorkflowManager; - -import java.io.File; -import java.util.Map; - -/** - * Created by susanh on 5/14/15. - */ -public class WorkflowSummary -{ - private ProcessDefinition _engineProcessDefinition; - private String _processDefinitionKey; - private Long _numAssignedTasks; - private Long _numOwnedTasks; - private Map _numGroupTasks; - private Long _numInstances; - private Long _numTotalTasks; - - - public WorkflowSummary() - {} - - public WorkflowSummary(String processDefinitionKey, User user, Container container) - { - _processDefinitionKey = processDefinitionKey; - _engineProcessDefinition = WorkflowManager.get().getProcessDefinition(processDefinitionKey, container); - } - - public String getWorkflowModelModule() - { - if (_engineProcessDefinition == null) - return null; - else - { - Lsid lsid = new Lsid(_engineProcessDefinition.getCategory()); - return lsid.getObjectId(); - } - } - - public boolean canStartProcess(User user, Container container) - { - PermissionsHandler handler = WorkflowRegistry.get().getPermissionsHandler(getWorkflowModelModule(), user, container); - if (handler != null) - return handler.canStartProcess(getProcessDefinitionKey()); - else - return false; - } - - public String getName() - { - if (_engineProcessDefinition == null) - return null; - else if (_engineProcessDefinition.getName() == null) - return "Process Definition " + _engineProcessDefinition.getId(); - else - return _engineProcessDefinition.getName(); - } - - public String getDescription() - { - if (_engineProcessDefinition == null) - return null; - else - return _engineProcessDefinition.getDescription(); - } - - public boolean hasDiagram() - { - return _engineProcessDefinition != null && _engineProcessDefinition.getDiagramResourceName() != null; - } - - public File getModelFile() - { - File file = null; - if (_engineProcessDefinition != null) - { - file = new File(_engineProcessDefinition.getResourceName()); - } - return file; - } - - - public String getProcessDefinitionKey() - { - return _processDefinitionKey; - } - - public void setProcessDefinitionKey(String processDefinitionKey) - { - _processDefinitionKey = processDefinitionKey; - } - - public Long getNumInstances() - { - return _numInstances; - } - - public void setNumInstances(Long numInstances) - { - _numInstances = numInstances; - } - - public Long getNumAssignedTasks() - { - return _numAssignedTasks; - } - - public void setNumAssignedTasks(Long numAssignedTasks) - { - _numAssignedTasks = numAssignedTasks; - } - - public Map getNumGroupTasks() - { - return _numGroupTasks; - } - - public void setNumGroupTasks(Map numGroupTasks) - { - _numGroupTasks = numGroupTasks; - } - - public Long getNumOwnedTasks() - { - return _numOwnedTasks; - } - - public void setNumOwnedTasks(Long numOwnedTasks) - { - _numOwnedTasks = numOwnedTasks; - } - - public Long getNumTotalTasks() - { - return _numTotalTasks; - } - - public void setNumTotalTasks(Long numTotalTasks) - { - _numTotalTasks = numTotalTasks; - } - -} diff --git a/src/org/labkey/workflow/model/WorkflowTaskImpl.java b/src/org/labkey/workflow/model/WorkflowTaskImpl.java deleted file mode 100644 index 55fe311..0000000 --- a/src/org/labkey/workflow/model/WorkflowTaskImpl.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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.labkey.workflow.model; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.activiti.engine.task.TaskInfo; -import org.apache.commons.collections4.CollectionUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.action.Marshal; -import org.labkey.api.action.Marshaller; -import org.labkey.api.data.Container; -import org.labkey.api.security.User; -import org.labkey.api.security.UserManager; -import org.labkey.api.security.permissions.Permission; -import org.labkey.api.workflow.PermissionsHandler; -import org.labkey.api.workflow.TaskFormField; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.api.workflow.WorkflowTask; -import org.labkey.workflow.WorkflowManager; -import org.labkey.workflow.WorkflowModule; - -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -@Marshal(Marshaller.Jackson) -public abstract class WorkflowTaskImpl implements WorkflowTask -{ - protected TaskInfo _taskInfo; - protected String _id; - protected String _executionId; - protected List _groupIds = null; - private WorkflowProcess _processInstance = null; - private PermissionsHandler _permissionsHandler = null; - - protected WorkflowTaskImpl() - {} - - public WorkflowTaskImpl(TaskInfo taskInfo) - { - _taskInfo = taskInfo; - } - - @Override - public String getId() - { - return _taskInfo == null ? _id : _taskInfo.getId(); - } - - @Override - public String getExecutionId() - { - return _taskInfo == null ? _executionId : _taskInfo.getExecutionId(); - } - - @Override - public String getName() - { - return _taskInfo == null ? null : _taskInfo.getName(); - } - - @Override - public String getDescription() - { - return _taskInfo == null ? null : _taskInfo.getDescription(); - } - - @JsonIgnore - private WorkflowProcess getProcessInstance() - { - if (_processInstance == null && _taskInfo != null) - { - _processInstance = new WorkflowProcessImpl(_taskInfo.getProcessInstanceId()); - } - return _processInstance; - } - - @Override - public String getProcessDefinitionKey(Container container) - { - return _taskInfo == null || !isActive() ? null : getProcessInstance().getProcessDefinitionKey(); - } - - @Override - public String getProcessDefinitionName(Container container) - { - String key = getProcessDefinitionKey(container); - return _taskInfo == null || key == null ? null : WorkflowManager.get().getProcessDefinition(key, container).getName(); - } - - public String getProcessDefinitionModule(Container container) - { - if (_taskInfo == null) - return WorkflowModule.NAME; - else - { - return WorkflowManager.get().getProcessDefinitionModule(getProcessDefinitionId(), container); - } - } - - @Override - public boolean isActive() - { - return getProcessInstance().isActive(); - } - - @Override - @Nullable - @JsonIgnore - public User getOwner() - { - Integer id = getOwnerId(); - if (id == null) - return null; - else - return UserManager.getUser(id); - } - - @Override - @Nullable - public Integer getOwnerId() - { - if (_taskInfo == null || _taskInfo.getOwner() == null) - return null; - else - return Integer.valueOf(_taskInfo.getOwner()); - } - - @Nullable - public String getOwnerName() - { - User owner = getOwner(); - if (owner != null) - { - return owner.getDisplayName(null); - } - return null; - } - - @Override - public void assign(@NotNull Integer assigneeId, User user, Container container) throws Exception - { - WorkflowManager.get().assignTask(getId(), assigneeId, user, container); - this.setAssignee(UserManager.getUser(assigneeId)); - } - - @Override - public boolean isAssigned(@NotNull User user) - { - return getAssigneeId() != null && getAssigneeId() == user.getUserId(); - } - - @Override - @Nullable - @JsonIgnore - public User getAssignee() - { - Integer id = getAssigneeId(); - if (id == null) - return null; - else - return UserManager.getUser(id); - } - - @Override - @Nullable - public Integer getAssigneeId() - { - if (_taskInfo == null || _taskInfo.getAssignee() == null) - return null; - else - return Integer.valueOf(_taskInfo.getAssignee()); - } - - @Nullable - public String getAssigneeName() - { - User user = getAssignee(); - if (user != null) - return user.getDisplayName(null); - return null; - } - - @Override - public String getProcessInstanceId() - { - return _taskInfo == null ? null : _taskInfo.getProcessInstanceId(); - } - - @Override - public String getProcessDefinitionId() - { - return _taskInfo == null ? null : _taskInfo.getProcessDefinitionId(); - } - - @Override - public Date getCreateTime() - { - return _taskInfo == null ? null : _taskInfo.getCreateTime(); - } - - @Override - public String getTaskDefinitionKey() - { - return _taskInfo == null ? null : _taskInfo.getTaskDefinitionKey(); - } - - @Override - public Date getDueDate() - { - return _taskInfo == null ? null : _taskInfo.getDueDate(); - } - - @Override - public String getParentTaskId() - { - return _taskInfo == null ? null : _taskInfo.getParentTaskId(); - } - - @Override - public Map getTaskLocalVariables() - { - return _taskInfo == null ? Collections.emptyMap() : _taskInfo.getTaskLocalVariables(); - } - - @Override - public Map getProcessVariables() - { - return _taskInfo == null ? Collections.emptyMap() : _taskInfo.getProcessVariables(); - } - - @Override - @JsonIgnore - @Nullable - public Map getVariables() - { - Map variables = getProcessVariables(); - if (variables == null) - { - variables = getTaskLocalVariables(); - } - else if (getTaskLocalVariables() != null) - { - variables.putAll(getTaskLocalVariables()); - } - return variables; - } - - @Override - @JsonIgnore // for some reason this comes back as the empty string, but it is also available as one of the process variables - public String getContainer() - { - return _taskInfo == null ? null : _taskInfo.getTenantId(); - } - - @Override - public boolean isInCandidateGroups(User user) - { - return hasCandidateGroups() && CollectionUtils.containsAny(getGroupIds(), user.getGroups().stream().collect(Collectors.toSet())); - } - - @Override - public boolean hasCandidateGroups() - { - return getGroupIds() != null && !_groupIds.isEmpty(); - } - - private PermissionsHandler getPermissionsHandler(User user, Container container) - { - if (_permissionsHandler == null) - { - _permissionsHandler = WorkflowRegistry.get().getPermissionsHandler(getProcessDefinitionModule(container), user, container); - } - return _permissionsHandler; - } - - @Override - public boolean canClaim(User user, Container container) - { - return getAssigneeId() == null && isActive() && getPermissionsHandler(user, container).canClaim(this); - } - - @Override - public boolean canDelegate(User user, Container container) - { - return isActive() && getPermissionsHandler(user, container).canDelegate(this); - } - - @Override - public boolean canAssign(User user, Container container) - { - return isActive() && getPermissionsHandler(user, container).canAssign(this); - } - - @Override - public boolean canView(User user, Container container) - { - return getPermissionsHandler(user, container).canView(this); - } - - @Override - public boolean canAccessData(User user, Container container) - { - return isActive() && getPermissionsHandler(user, container).canAccessData(this); - } - - @Override - public boolean canComplete(User user, Container container) - { - return isActive() && getPermissionsHandler(user, container).canComplete(this); - } - - @Override - public boolean canUpdate(User user, Container container) - { - return isActive() && getPermissionsHandler(user, container).canUpdate(this); - } - - @Override - public Set> getReassignPermissions(User user, Container container) - { - return getPermissionsHandler(user, container).getCandidateUserPermissions(this); - } - - @Override - @JsonIgnore - @NotNull - public Map getFormFields() - { - return WorkflowManager.get().getFormFields(getId()); - } -} diff --git a/src/org/labkey/workflow/query/WorkflowIdentityLinkTable.java b/src/org/labkey/workflow/query/WorkflowIdentityLinkTable.java deleted file mode 100644 index d2937fe..0000000 --- a/src/org/labkey/workflow/query/WorkflowIdentityLinkTable.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.query.FieldKey; -import org.labkey.api.query.SimpleUserSchema; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; - -/** - * Created by susanh on 5/28/15. - */ -public class WorkflowIdentityLinkTable extends SimpleUserSchema.SimpleTable -{ - public WorkflowIdentityLinkTable(WorkflowQuerySchema userSchema, ContainerFilter containerFilter, User user, Container container) - { - super(userSchema, userSchema.getDbSchema().getTable(WorkflowQuerySchema.TABLE_IDENTITY_LINK), containerFilter); - wrapAllColumns(); - - if (!container.hasPermission(user, AdminPermission.class)) - { - String userId = String.valueOf(user.getUserId()); - SQLFragment sql = new SQLFragment("(act_ru_identityLink.proc_inst_id_ IN (SELECT V.execution_id_ FROM workflow.act_ru_variable V WHERE V.name_ = 'initiatorId' AND V.text_ = ?))"); - sql.add(userId); - sql.append(" OR (act_ru_identityLink.task_id_ IN (SELECT T.id_ FROM workflow.act_ru_task T WHERE T.owner_ = ? OR T.assignee_ = ?))"); - sql.add(userId); - sql.add(userId); - addCondition(sql, new FieldKey(null, "id_")); - - } - } -} diff --git a/src/org/labkey/workflow/query/WorkflowProcessDefinitionTable.java b/src/org/labkey/workflow/query/WorkflowProcessDefinitionTable.java deleted file mode 100644 index 03ab40b..0000000 --- a/src/org/labkey/workflow/query/WorkflowProcessDefinitionTable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.util.PageFlowUtil; - -import java.util.Set; - -/** - * Created by susanh on 5/11/15. - */ -public class WorkflowProcessDefinitionTable extends WorkflowTenantTable -{ - private static final Set _columnsToIgnore = PageFlowUtil.set("has_start_form_key_", "category_"); - - public WorkflowProcessDefinitionTable(WorkflowQuerySchema userSchema, ContainerFilter containerFilter) - { - super(userSchema, WorkflowQuerySchema.TABLE_PROCESS_DEFINITION, containerFilter); - } - - @Override - public boolean acceptColumn(ColumnInfo columnInfo) - { - return !_columnsToIgnore.contains(columnInfo.getName().toLowerCase()); - } - -} diff --git a/src/org/labkey/workflow/query/WorkflowProcessInstanceTable.java b/src/org/labkey/workflow/query/WorkflowProcessInstanceTable.java deleted file mode 100644 index e92d341..0000000 --- a/src/org/labkey/workflow/query/WorkflowProcessInstanceTable.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.DatabaseTableType; -import org.labkey.api.data.JdbcType; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.data.TableInfo; -import org.labkey.api.query.DefaultQueryUpdateService; -import org.labkey.api.query.DetailsURL; -import org.labkey.api.query.ExprColumn; -import org.labkey.api.query.InvalidKeyException; -import org.labkey.api.query.QueryUpdateService; -import org.labkey.api.query.QueryUpdateServiceException; -import org.labkey.api.query.UserIdForeignKey; -import org.labkey.api.security.User; -import org.labkey.api.view.ActionURL; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.workflow.WorkflowController; -import org.labkey.workflow.WorkflowManager; - -import java.sql.SQLException; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Created by susanh on 5/11/15. - */ -public class WorkflowProcessInstanceTable extends WorkflowTenantTable -{ - - private static Set _columnsToIgnore = new HashSet<>(); - static - { - _columnsToIgnore.add("business_key_"); - _columnsToIgnore.add("super_exec_"); - _columnsToIgnore.add("act_id_"); - _columnsToIgnore.add("is_concurrent_"); - _columnsToIgnore.add("is_scope_"); - _columnsToIgnore.add("is_event_scope_"); - _columnsToIgnore.add("suspension_state_"); - _columnsToIgnore.add("cached_ent_state_"); - _columnsToIgnore.add("lock_time_"); - } - - public WorkflowProcessInstanceTable(WorkflowQuerySchema userSchema, ContainerFilter containerFilter, User user, Container container) - { - super(userSchema, WorkflowQuerySchema.TABLE_PROCESS_INSTANCE, containerFilter); - - var idColumn = getMutableColumn("id_"); - ActionURL base = new ActionURL(WorkflowController.ProcessInstanceAction.class, getContainer()); - DetailsURL detailsURL = new DetailsURL(base, Collections.singletonMap("processInstanceId", "proc_inst_id_")); - - idColumn.setURL(detailsURL); - setDetailsURL(detailsURL); - - addInitiatorColumn(); - - addWorkflowListFilter(WorkflowRegistry.getProcessListFilters(user, container)); - } - - private ColumnInfo addInitiatorColumn() - { - SQLFragment sql = new SQLFragment("(SELECT V.text_ FROM workflow.act_ru_variable V WHERE V.name_ = 'initiatorId' AND V.execution_id_ = act_ru_execution.id_)"); - - ExprColumn ret = new ExprColumn(this, "Initiator", sql, JdbcType.VARCHAR); - ret.setFk(new UserIdForeignKey(this.getUserSchema())); - - this.addColumn(ret); - - return ret; - } - - - @Override - public boolean acceptColumn(ColumnInfo columnInfo) - { - return !_columnsToIgnore.contains(columnInfo.getName().toLowerCase()); - } - - @Override - public QueryUpdateService getUpdateService() - { - TableInfo table = getRealTable(); - if (table != null && table.getTableType() == DatabaseTableType.TABLE) - { - return new DefaultQueryUpdateService(this, table) - { - @Override - protected Map deleteRow(User user, Container container, Map oldRowMap) throws QueryUpdateServiceException, SQLException, InvalidKeyException - { - // FIXME this doesn't quite work - WorkflowManager.get().deleteProcessInstance((String) oldRowMap.get("PROC_INST_ID_"), null); - return oldRowMap; - - } - }; - } - return null; - } - - -} diff --git a/src/org/labkey/workflow/query/WorkflowQuerySchema.java b/src/org/labkey/workflow/query/WorkflowQuerySchema.java deleted file mode 100644 index f088782..0000000 --- a/src/org/labkey/workflow/query/WorkflowQuerySchema.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.CompareType; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.DbSchema; -import org.labkey.api.data.DbSchemaType; -import org.labkey.api.data.DetailsColumn; -import org.labkey.api.data.DisplayColumn; -import org.labkey.api.data.DisplayColumnFactory; -import org.labkey.api.data.JavaScriptDisplayColumn; -import org.labkey.api.data.RenderContext; -import org.labkey.api.data.SchemaTableInfo; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.data.TableInfo; -import org.labkey.api.module.Module; -import org.labkey.api.query.AliasedColumn; -import org.labkey.api.query.DefaultSchema; -import org.labkey.api.query.DetailsURL; -import org.labkey.api.query.FieldKey; -import org.labkey.api.query.FilteredTable; -import org.labkey.api.query.QuerySchema; -import org.labkey.api.query.QuerySettings; -import org.labkey.api.query.QueryView; -import org.labkey.api.query.UserSchema; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.util.HtmlString; -import org.labkey.api.view.ActionURL; -import org.labkey.api.view.ViewContext; -import org.labkey.workflow.WorkflowController; -import org.labkey.workflow.WorkflowModule; -import org.springframework.validation.BindException; - -import java.io.IOException; -import java.io.Writer; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Created by susanh on 5/11/15. - */ -public class WorkflowQuerySchema extends UserSchema -{ - public static final String NAME = "workflow"; - public static final String DESCRIPTION = "Provides information on workflow models, processes and tasks"; - - public static final String TABLE_TASK = "act_ru_task"; - public static final String TABLE_PROCESS_DEFINITION = "act_re_procdef"; - public static final String TABLE_PROCESS_INSTANCE = "act_ru_execution"; - public static final String TABLE_DEPLOYMENT = "act_re_deployment"; - public static final String TABLE_VARIABLE = "act_ru_variable"; - public static final String TABLE_IDENTITY_LINK = "act_ru_identitylink"; - public static final String TABLE_RUNTIME_JOB = "act_ru_job"; - public static final String TABLE_HISTORY_ACTIVITY_INSTANCE = "act_hi_actinst"; - public static final String TABLE_HISTORY_COMMENT = "act_hi_comment"; - public static final String TABLE_HISTORY_DETAIL = "act_hi_detail"; - public static final String TABLE_HISTORY_IDENTITY_LINK = "act_hi_identitylink"; - public static final String TABLE_HISTORY_PROCESS_INSTANCE = "act_hi_procinst"; - public static final String TABLE_HISTORY_TASK_INSTANCE = "act_hi_taskinst"; - public static final String TABLE_HISTORY_VARIABLE_INSTANCE = "act_hi_varinst"; - - public static final String SCHEMA_NOT_DEFINED_ERROR = "No schema defined for this view. Check that the Workflow module is available in this container"; - - - public WorkflowQuerySchema(User user, Container container) - { - super(NAME, DESCRIPTION, user, container, DbSchema.get(NAME, DbSchemaType.Module)); - } - - public static void register(final WorkflowModule module) - { - DefaultSchema.registerProvider(NAME, new DefaultSchema.SchemaProvider(module) - { - @Override - public QuerySchema createSchema(DefaultSchema schema, Module module) - { - return new WorkflowQuerySchema(schema.getUser(), schema.getContainer()); - } - }); - } - - @Override - public Set getTableNames() - { - Set names = new HashSet<>(); - names.add(TABLE_DEPLOYMENT); - names.add(TABLE_TASK); - names.add(TABLE_PROCESS_DEFINITION); - names.add(TABLE_PROCESS_INSTANCE); - names.add(TABLE_VARIABLE); - names.add(TABLE_IDENTITY_LINK); - names.add(TABLE_RUNTIME_JOB); - names.add(TABLE_HISTORY_ACTIVITY_INSTANCE); - names.add(TABLE_HISTORY_COMMENT); - names.add(TABLE_HISTORY_IDENTITY_LINK); - names.add(TABLE_HISTORY_DETAIL); - names.add(TABLE_HISTORY_PROCESS_INSTANCE); - names.add(TABLE_HISTORY_TASK_INSTANCE); - names.add(TABLE_HISTORY_VARIABLE_INSTANCE); - return names; - } - - @Nullable - @Override - public TableInfo createTable(String name, ContainerFilter containerFilter) - { - switch (name) - { - case TABLE_TASK: - return new WorkflowTaskTable(this, containerFilter, getUser(), getContainer()); - case TABLE_PROCESS_DEFINITION: - return new WorkflowProcessDefinitionTable(this, containerFilter); - case TABLE_PROCESS_INSTANCE: - return new WorkflowProcessInstanceTable(this, containerFilter, getUser(), getContainer()); - case TABLE_IDENTITY_LINK: - return new WorkflowIdentityLinkTable(this, containerFilter, getUser(), getContainer()); - case TABLE_VARIABLE: - return new WorkflowVariableTable(this, containerFilter, getUser(), getContainer()); - case TABLE_DEPLOYMENT: - case TABLE_HISTORY_PROCESS_INSTANCE: - case TABLE_HISTORY_ACTIVITY_INSTANCE: - case TABLE_HISTORY_TASK_INSTANCE: - return new WorkflowTenantTable(this, name, containerFilter); - } - - //just return a filtered table over the db table if it exists - SchemaTableInfo tableInfo = getDbSchema().getTable(name); - if (null == tableInfo) - return null; - - FilteredTable filteredTable = new FilteredTable<>(tableInfo, this); - filteredTable.wrapAllColumns(true); - return filteredTable; - } - - @Override - public QueryView createView(ViewContext context, @NotNull QuerySettings settings, BindException errors) - { - QueryView queryView = null; - - String processDefinitionKey = context.getRequest().getParameter("processDefinitionKey"); - if (StringUtils.isNotBlank(processDefinitionKey)) - { - SimpleFilter filter = settings.getBaseFilter(); - FieldKey definitionKeyField = new FieldKey(null, "proc_def_id_"); - // These keys have the form :revision:id, so we add the ":" to distinguish keys with the same prefix. - SimpleFilter processFilter = new SimpleFilter(definitionKeyField, processDefinitionKey + ":", CompareType.CONTAINS); - filter.addAllClauses(processFilter); - } - - - if (settings.getQueryName() != null && settings.getQueryName().equalsIgnoreCase(TABLE_TASK)) - { - String assigneeId = context.getRequest().getParameter("assignee"); - SimpleFilter baseFilter = settings.getBaseFilter(); - if (StringUtils.isNotBlank(assigneeId)) - { - FieldKey field = new FieldKey(null, "assignee_"); - SimpleFilter assigneeFilter; - if (assigneeId.equals("_blank")) - { - assigneeFilter = new SimpleFilter(field, assigneeId, CompareType.ISBLANK); - } - else - { - assigneeFilter = new SimpleFilter(field, assigneeId, CompareType.EQUAL); - } - baseFilter.addAllClauses(assigneeFilter); - } - - String ownerId = context.getRequest().getParameter("owner"); - if (StringUtils.isNotBlank(ownerId)) - { - FieldKey field = new FieldKey(null, "owner_"); - SimpleFilter ownerFilter; - if (ownerId.equals("_blank")) - { - ownerFilter = new SimpleFilter(field, ownerId, CompareType.ISBLANK); - } - else - { - ownerFilter = new SimpleFilter(field, ownerId, CompareType.EQUAL); - } - baseFilter.addAllClauses(ownerFilter); - } - - queryView = new QueryView(this, settings, errors) - { - @Override - protected void addDetailsAndUpdateColumns(List ret, TableInfo table) - { - ActionURL base = new ActionURL(WorkflowController.TaskAction.class, getContainer()); - DetailsURL detailsURL = new DetailsURL(base, Collections.singletonMap("taskId", "id_")); - setDetailsURL(detailsURL.toString()); - DetailsColumn column = new DetailsColumn(detailsURL, table); - column.setDisplayHtml("Task Details"); - ret.add(column); - ret.add(getReassignmentColumn(table, "Reassign", null)); - } - }; - } - else - { - queryView = new QueryView(this, settings, errors); - } -// queryView.setShowDeleteButton(settings.getQueryName().equalsIgnoreCase(TABLE_PROCESS_INSTANCE)); - queryView.setShowDeleteButton(false); - queryView.setShowUpdateColumn(false); - queryView.setShowInsertNewButton(false); - queryView.setShowImportDataButton(false); - return queryView; - } - - private DisplayColumn getReassignmentColumn(@NotNull TableInfo table, @NotNull String linkText, @Nullable String title) - { - AliasedColumn reassignmentColumn = new AliasedColumn(linkText, table.getColumn("id_")); - reassignmentColumn.setDisplayColumnFactory(new ReassignmentDisplayColumnFactory(HtmlString.of(linkText))); - return reassignmentColumn.getRenderer(); - } - - private class ReassignmentDisplayColumnFactory implements DisplayColumnFactory - { - private final HtmlString _assignmentType; - - public ReassignmentDisplayColumnFactory(HtmlString assignmentType) - { - _assignmentType = assignmentType; - } - - @Override - public DisplayColumn createRenderer(ColumnInfo colInfo) - { - Collection dependencies = Collections.singletonList("workflow/view/reassignTask.js"); - String onClickJavaScript = "createReassignTaskWindow(${id_:jsString}, ${assignee_:jsString});"; - return new JavaScriptDisplayColumn(colInfo, dependencies, onClickJavaScript, "labkey-text-link") - { - @NotNull - @Override - public HtmlString getFormattedHtml(RenderContext ctx) - { - return _assignmentType; - } - - @Override - public void renderTitle(RenderContext ctx, Writer out) throws IOException - { - // no title for these columns - } - - @Override - public boolean isSortable() - { - return false; - } - - @Override - public boolean isFilterable() - { - return false; - } - - @Override - public void renderGridCellContents(RenderContext ctx, Writer out) throws IOException - { - // TODO add in the proper permissions check here, passed in as part of the constructor - String group = (String) ctx.get("_Group"); - if (group == null) - return; - Integer groupId = Integer.valueOf(group); - if (getUser().isInGroup(groupId) || getContainer().hasPermission(getUser(), AdminPermission.class)) - { - super.renderGridCellContents(ctx, out); - } - } - }; - } - } -} diff --git a/src/org/labkey/workflow/query/WorkflowTaskTable.java b/src/org/labkey/workflow/query/WorkflowTaskTable.java deleted file mode 100644 index 32b74a2..0000000 --- a/src/org/labkey/workflow/query/WorkflowTaskTable.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.data.CoreSchema; -import org.labkey.api.data.DataColumn; -import org.labkey.api.data.DisplayColumn; -import org.labkey.api.data.DisplayColumnFactory; -import org.labkey.api.data.JdbcType; -import org.labkey.api.data.RenderContext; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.data.TableInfo; -import org.labkey.api.query.DetailsURL; -import org.labkey.api.query.ExprColumn; -import org.labkey.api.query.FieldKey; -import org.labkey.api.query.FilteredTable; -import org.labkey.api.query.LookupForeignKey; -import org.labkey.api.query.UserSchema; -import org.labkey.api.security.Group; -import org.labkey.api.security.SecurityManager; -import org.labkey.api.security.SecurityUrls; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; -import org.labkey.api.util.PageFlowUtil; -import org.labkey.api.view.ActionURL; -import org.labkey.api.workflow.WorkflowRegistry; -import org.labkey.workflow.WorkflowController; - -import java.io.IOException; -import java.io.Writer; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Created by susanh on 5/11/15. - */ -public class WorkflowTaskTable extends WorkflowTenantTable -{ - private static Set _columnsToIgnore = new HashSet<>(); - static - { - _columnsToIgnore.add("form_key_"); - _columnsToIgnore.add("category_"); - _columnsToIgnore.add("suspension_state_"); - } - - public WorkflowTaskTable(@NotNull WorkflowQuerySchema userSchema, ContainerFilter containerFilter, User user, Container container) - { - super(userSchema, WorkflowQuerySchema.TABLE_TASK, containerFilter); - - var idColumn = getMutableColumn("id_"); - ActionURL base = new ActionURL(WorkflowController.TaskAction.class, getContainer()); - DetailsURL detailsURL = new DetailsURL(base, Collections.singletonMap("taskId", "id_")); - idColumn.setURL(detailsURL); - setDetailsURL(detailsURL); - - addCandidateGroupColumn(user, container); - - addWorkflowListFilter(WorkflowRegistry.getTaskListFilters(user, container)); - } - - private ColumnInfo addCandidateGroupColumn(User user, Container container) - { - SQLFragment sql = new SQLFragment("(SELECT I.group_id_ FROM workflow.act_ru_identitylink I WHERE I.task_id_ = act_ru_task.id_"); - if (!container.hasPermission(user, AdminPermission.class)) - { - sql.append(" AND (I.group_id_ IS NULL OR "); - SimpleFilter.InClause clause = new SimpleFilter.InClause(FieldKey.fromParts("I","group_id_"), - SecurityManager.getGroups(container, user).stream().map(g -> String.valueOf(g.getUserId())).collect(Collectors.toList())); - sql.append(clause.toSQLFragment(Collections.emptyMap(), _schema.getSqlDialect())); - sql.append(")"); - } - sql.append(")"); - ExprColumn ret = new ExprColumn(this, "Group", sql, JdbcType.VARCHAR); - - ret.setFk(new GroupForeignKey(this.getUserSchema())); - ret.setDisplayColumnFactory(new DisplayColumnFactory() - { - @Override - public DisplayColumn createRenderer(ColumnInfo colInfo) - { - return new GroupDisplayColumn(colInfo); - } - }); - this.addColumn(ret); - - return ret; - } - - public static class GroupDisplayColumn extends DataColumn - { - private ColumnInfo _groupId; - - public GroupDisplayColumn(ColumnInfo groupId) - { - super(groupId); - _groupId = groupId; - } - - @Override - public String getName() - { - return "group"; - } - - @Override - public void renderGridCellContents(RenderContext ctx, Writer out) throws IOException - { - String id = (String)getBoundColumn().getValue(ctx); - if (id != null) - { - Group g = org.labkey.api.security.SecurityManager.getGroup(Integer.valueOf(id)); - if (g != null) - { - Container groupContainer = g.isAdministrators() ? ContainerManager.getRoot() : ContainerManager.getForId(g.getContainer()); - if (g.isAdministrators() || g.isProjectGroup()) - { - String groupName = g.isProjectGroup() ? groupContainer.getPath() + "/" + g.getName() : g.getName(); - ActionURL url = PageFlowUtil.urlProvider(SecurityUrls.class).getManageGroupURL(groupContainer, groupName); - - out.write(""); - out.write(PageFlowUtil.filter(g.getName())); - out.write(""); - return; - } - } - } - out.write(" "); - } - - @Override - public void addQueryColumns(Set set) - { - set.add(_groupId); - } - } - - public static class GroupForeignKey extends LookupForeignKey - { - private final UserSchema _userSchema; - - public GroupForeignKey(UserSchema userSchema) - { - super("UserId", "Name"); - _userSchema = userSchema; - } - - @Override - public TableInfo getLookupTableInfo() - { - TableInfo tinfoUsers = CoreSchema.getInstance().getTableInfoPrincipals(); - FilteredTable ret = new FilteredTable<>(tinfoUsers, _userSchema); - ret.addWrapColumn(tinfoUsers.getColumn("UserId")); - ret.addColumn(ret.wrapColumn("Name", tinfoUsers.getColumn("Name"))); - ret.setTitleColumn("Name"); - return ret; - } - } - - @Override - public boolean acceptColumn(ColumnInfo columnInfo) - { - return !_columnsToIgnore.contains(columnInfo.getName().toLowerCase()); - } -} diff --git a/src/org/labkey/workflow/query/WorkflowTenantTable.java b/src/org/labkey/workflow/query/WorkflowTenantTable.java deleted file mode 100644 index a52f52f..0000000 --- a/src/org/labkey/workflow/query/WorkflowTenantTable.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.ContainerForeignKey; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.query.SimpleUserSchema; - -import java.util.List; - -/** - * Created by susanh on 5/11/15. - */ -public class WorkflowTenantTable extends SimpleUserSchema.SimpleTable -{ - - public WorkflowTenantTable(WorkflowQuerySchema userSchema, String tableName, ContainerFilter containerFilter) - { - super(userSchema, userSchema.getDbSchema().getTable(tableName), containerFilter); - wrapAllColumns(); - } - - @Override - protected String getContainerFilterColumn() - { - return "tenant_id_"; - } - - @Override - public void wrapAllColumns() - { - super.wrapAllColumns(); - var containerColumn = getMutableColumn("tenant_id_"); - containerColumn.setFk(new ContainerForeignKey(getUserSchema())); - containerColumn.setUserEditable(false); - containerColumn.setShownInInsertView(false); - containerColumn.setShownInUpdateView(false); - containerColumn.setLabel("Container"); - } - - protected void addWorkflowListFilter(List filters) - { - if (filters.size() > 0) - { - SimpleFilter.OrClause or = new SimpleFilter.OrClause(); - for (SimpleFilter filter : filters) - { - List clauses = filter.getClauses(); - for (SimpleFilter.FilterClause clause : clauses) - { - or.addClause(clause); - } - } - SimpleFilter filter = new SimpleFilter(); - filter.addClause(or); - addCondition(filter); - } - } - - -} diff --git a/src/org/labkey/workflow/query/WorkflowVariableTable.java b/src/org/labkey/workflow/query/WorkflowVariableTable.java deleted file mode 100644 index 342fd5d..0000000 --- a/src/org/labkey/workflow/query/WorkflowVariableTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.query; - -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.query.FieldKey; -import org.labkey.api.query.SimpleUserSchema; -import org.labkey.api.security.User; -import org.labkey.api.security.permissions.AdminPermission; - -/** - * Created by susanh on 5/28/15. - */ -public class WorkflowVariableTable extends SimpleUserSchema.SimpleTable -{ - public WorkflowVariableTable(WorkflowQuerySchema userSchema, ContainerFilter containerFilter, User user, Container container) - { - super(userSchema, userSchema.getDbSchema().getTable(WorkflowQuerySchema.TABLE_VARIABLE), containerFilter); - wrapAllColumns(); - - if (!container.hasPermission(user, AdminPermission.class)) - { - String userId = String.valueOf(user.getUserId()); - SQLFragment sql = new SQLFragment("(act_ru_variable.proc_inst_id_ IN (SELECT V.execution_id_ FROM workflow.act_ru_variable V WHERE V.name_ = 'initiatorId' AND V.text_ = ?))"); - sql.add(userId); - sql.append(" OR (act_ru_variable.task_id_ IN (SELECT T.id_ FROM workflow.act_ru_task T WHERE T.owner_ = ? OR T.assignee_ = ?))"); - sql.add(userId); - sql.add(userId); - addCondition(sql, new FieldKey(null, "id_")); - - } - - } -} - diff --git a/src/org/labkey/workflow/view/WorkflowViewBase.java b/src/org/labkey/workflow/view/WorkflowViewBase.java deleted file mode 100644 index 6e2ff2a..0000000 --- a/src/org/labkey/workflow/view/WorkflowViewBase.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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.labkey.workflow.view; - -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.json.JSONObject; -import org.labkey.api.data.Container; -import org.labkey.api.jsp.JspBase; -import org.labkey.api.util.DateUtil; -import org.labkey.api.util.HtmlString; -import org.labkey.api.util.HtmlStringBuilder; -import org.labkey.api.util.PageFlowUtil; -import org.labkey.api.util.StringUtilsLabKey; -import org.labkey.api.view.ActionURL; -import org.labkey.api.workflow.WorkflowProcess; -import org.labkey.workflow.WorkflowController; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by susanh on 6/14/15. - * - */ -public abstract class WorkflowViewBase extends JspBase -{ - protected String rowClass = "labkey-row"; - - public String nextRowClass() - { - rowClass = rowClass.equals("labkey-row")? "labkey-alternate-row" : "labkey-row"; - return rowClass; - } - - public String variablesTableRows(Map variables) - { - StringBuilder builder = new StringBuilder(); - if (variables != null && !variables.isEmpty()) - { - Map displayVariables = getDisplayVariables(getContainer(), variables); - - for (Map.Entry variable : displayVariables.entrySet()) - { - if (variable.getKey().equalsIgnoreCase("Data Access")) - continue; - builder.append("\n"); - builder.append("").append(h(variable.getKey())).append("\n"); - builder.append("").append(h(variable.getValue())).append("\n"); - builder.append("\n"); - } - } - return builder.toString(); - } - - @SuppressWarnings("unchecked") - public String dataAccessTable(Map variables, boolean canAccessData) - { - StringBuilder builder = new StringBuilder(); - if (variables != null && variables.containsKey(WorkflowProcess.DATA_ACCESS_KEY)) - { - builder.append("Data Parameters

\n"); - builder.append("\n"); - Map dataAccess = (Map) variables.get(WorkflowProcess.DATA_ACCESS_KEY); - HashMap parameters = (HashMap) dataAccess.get(WorkflowProcess.DATA_ACCESS_PARAMETERS_KEY); - - for (Map.Entry parameter : parameters.entrySet()) - { - builder.append("\n"); - builder.append("\n"); - builder.append("\n"); - builder.append("\n"); - } - if (canAccessData) - { - builder.append(""); - builder.append("\n"); - builder.append(""); - } - builder.append("
").append(h(parameter.getKey())).append("").append(h(getParameterValue(parameter.getKey(), parameter.getValue()))).append("

").append(PageFlowUtil.button("Download Data").id("downloadDataBtn").onClick(" downloadWorkflowTaskData(" + q((String) dataAccess.get("url")) + ", " + new JSONObject(parameters).toString() + "); return false;")).append("

\n"); - } - return builder.toString(); - } - - private Object getParameterValue(String key, Object value) - { - return value; - } - - - @Nullable - public Map getDisplayVariables(Container container, Map variables) - { - String displayKey; - Object displayValue; - Map _displayVariables = new HashMap<>(); - for (String key : variables.keySet()) - { - if (WorkflowProcess.CONTAINER_ID.equalsIgnoreCase(key) || WorkflowProcess.INITIATOR_ID.equalsIgnoreCase(key)) - continue; - else if (key.endsWith("GroupId")) - { - displayKey = key.substring(0, key.length() - 2); - try - { - displayValue = org.labkey.api.security.SecurityManager.getGroup(Integer.valueOf((String) variables.get(key))); - } - catch (NumberFormatException e) - { - displayValue = variables.get(key); - } - } - else if (variables.get(key) instanceof Date) - { - displayKey = key; - displayValue = DateUtil.formatDateTime(container, (Date) variables.get(key)); - } - else - { - displayKey = key; - displayValue = variables.get(key); - } - displayKey = StringUtilsLabKey.splitCamelCase(StringUtils.capitalize(displayKey)); - - _displayVariables.put(displayKey, displayValue); - } - - return _displayVariables; - - } - - public HtmlString navigationLinks(@Nullable String processDefinitionName, @NotNull String processDefinitionKey, @Nullable String processInstanceId) - { - HtmlStringBuilder builder = HtmlStringBuilder.of(); - - builder.append(PageFlowUtil.link("All workflows").href(new ActionURL(WorkflowController.BeginAction.class, getContainer()))); - builder.append(HtmlString.NBSP).append(HtmlString.NBSP); - if (processDefinitionName != null) - { - builder.append(PageFlowUtil.link(processDefinitionName).href(new ActionURL(WorkflowController.SummaryAction.class, getContainer()).addParameter("processDefinitionKey", processDefinitionKey))); - builder.append(HtmlString.NBSP).append(HtmlString.NBSP); - - } - builder.append(PageFlowUtil.link("Process instance list").href(new ActionURL(WorkflowController.InstanceListAction.class, getContainer()).addParameter("processDefinitionKey", processDefinitionKey))); - builder.append(HtmlString.NBSP).append(HtmlString.NBSP); - - if (processInstanceId != null) - { - builder.append(PageFlowUtil.link("This Process Instance").href(new ActionURL(WorkflowController.ProcessInstanceAction.class, getContainer()).addParameter("processInstanceId", processInstanceId))); - builder.append(HtmlString.NBSP).append(HtmlString.NBSP); - } - builder.append(PageFlowUtil.link("My tasks").href(new ActionURL(WorkflowController.TaskListAction.class, getContainer()).addParameter("processDefinitionKey", processDefinitionKey).addParameter("assignee", getUser().getUserId()))); - - return builder.getHtmlString(); - } -} diff --git a/src/org/labkey/workflow/view/WorkflowWebPart.java b/src/org/labkey/workflow/view/WorkflowWebPart.java deleted file mode 100644 index 99bcd37..0000000 --- a/src/org/labkey/workflow/view/WorkflowWebPart.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016 LabKey Corporation - * - * 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.labkey.workflow.view; - -import org.labkey.api.data.Container; -import org.labkey.api.view.JspView; -import org.labkey.api.view.ViewContext; -import org.labkey.workflow.WorkflowController; - -/** - * Created by susanh on 9/30/16. - */ -public class WorkflowWebPart extends JspView -{ - public WorkflowWebPart(Container container) - { - super("/org/labkey/workflow/view/allWorkflows.jsp"); - this.setModelBean( new WorkflowController.AllWorkflowsBean(container)); - setTitle("Workflow List"); - } - - public WorkflowWebPart(ViewContext v) - { - this(v.getContainer()); - } -} - diff --git a/src/org/labkey/workflow/view/allWorkflows.jsp b/src/org/labkey/workflow/view/allWorkflows.jsp deleted file mode 100644 index 980be4e..0000000 --- a/src/org/labkey/workflow/view/allWorkflows.jsp +++ /dev/null @@ -1,55 +0,0 @@ -<% -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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. - */ -%> -<%@ page import="org.labkey.api.view.HttpView" %> -<%@ page import="org.labkey.workflow.WorkflowController" %> -<%@ page import="java.util.Map" %> -<%@ page extends="org.labkey.api.jsp.JspBase" %> -<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> -<% - HttpView me = HttpView.currentView(); - - WorkflowController.AllWorkflowsBean bean = (WorkflowController.AllWorkflowsBean) me.getModelBean(); - Map processDefinitions = bean.getWorkflowDefinitions(); -%> - -<% - if (processDefinitions.isEmpty()) - { -%> -There are currently no workflows deployed in this container. -<% - } - else - { -%> -The following workflows are currently deployed in this container: - -<% - for (Map.Entry entry : processDefinitions.entrySet()) - { -%> -
    -
  • - <%=link(entry.getValue(), urlFor(WorkflowController.SummaryAction.class).addParameter("processDefinitionKey", entry.getKey()))%> -
  • -
-<% - } - } - -%> diff --git a/src/org/labkey/workflow/view/workflowList.jsp b/src/org/labkey/workflow/view/workflowList.jsp deleted file mode 100644 index 664cc60..0000000 --- a/src/org/labkey/workflow/view/workflowList.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<% -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * 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. - */ -%> -<%@ page import="org.labkey.api.view.HttpView" %> -<%@ page import="org.labkey.api.view.template.ClientDependencies" %> -<%@ page import="org.labkey.workflow.WorkflowController" %> -<%@ page extends="org.labkey.workflow.view.WorkflowViewBase" %> -<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> -<%! - @Override - public void addClientDependencies(ClientDependencies dependencies) - { - dependencies.add("Ext4"); - dependencies.add("workflow/view/reassignTask.js"); - } -%> -<% - HttpView me = HttpView.currentView(); - WorkflowController.WorkflowRequestForm bean = (WorkflowController.WorkflowRequestForm) me.getModelBean(); -%> - - -<%= navigationLinks(bean.getProcessDefinitionName(), bean.getProcessDefinitionKey(), null) %> -
-
- -<% - if (me.getView("workflowListQueryView") != null) - { -%> -
- <% me.include(me.getView("workflowListQueryView"),out); %> -
-

-<% - } -%> -<%= navigationLinks(bean.getProcessDefinitionName(), bean.getProcessDefinitionKey(), null) %> - diff --git a/src/org/labkey/workflow/view/workflowProcessInstance.jsp b/src/org/labkey/workflow/view/workflowProcessInstance.jsp deleted file mode 100644 index db985f6..0000000 --- a/src/org/labkey/workflow/view/workflowProcessInstance.jsp +++ /dev/null @@ -1,238 +0,0 @@ -<% -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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. - */ -%> -<%@ page import="org.labkey.api.view.HttpView" %> -<%@ page import="org.labkey.api.view.template.ClientDependencies" %> -<%@ page import="org.labkey.api.workflow.WorkflowJob" %> -<%@ page import="org.labkey.api.workflow.WorkflowProcess" %> -<%@ page import="org.labkey.api.workflow.WorkflowTask" %> -<%@ page import="org.labkey.workflow.WorkflowController" %> -<%@ page extends="org.labkey.workflow.view.WorkflowViewBase" %> -<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> -<%! - @Override - public void addClientDependencies(ClientDependencies dependencies) - { - dependencies.add("Ext4"); - dependencies.add("workflow/view/workflow.css"); - dependencies.add("workflow/view/reassignTask.js"); - dependencies.add("workflow/view/completeTask.js"); - dependencies.add("workflow/view/deleteProcessInstance.js"); - } -%> -<% - HttpView me = HttpView.currentView(); - WorkflowProcess bean = (WorkflowProcess) me.getModelBean(); -%> - -<% - if (bean.getProcessInstanceId() == null) - { -%> -There is no active process with id <%= h(bean.getId()) %> -

-<%=link("All workflows", WorkflowController.BeginAction.class)%> -<% - } - else if (!bean.canView(getUser(), getContainer())) - { -%> -<%= h(getUser().getDisplayName(getUser())) %> does not have permission to view this process instance. -<% - } - else - { -%> -<%= navigationLinks(bean.getProcessDefinitionName(), bean.getProcessDefinitionKey(), null) %> - -
-
-<% - if (bean.getName() == null) - { -%> -Process <%= h(bean.getId()) %> -<% - } - else - { -%> -<%= h(bean.getName()) %> -<% - } -%> -<% - if (bean.canDelete(getUser(), getContainer())) - { -%> -  <%= button("Delete").onClick(" createDeleteProcessInstanceConfirmationWindow(" + q(bean.getProcessInstanceId()) + ", " + q(bean.getProcessDefinitionKey()) + ", " + q(bean.getName()) + ")") %> -<% - } -%> -
-
-Process Instance Details -

- - - - - - <% - if (bean.getInitiator() != null) - { - %> - - - - - - <% - } - %> - -<%= unsafe(variablesTableRows(bean.getVariables())) %> - - - - <% - if (bean.getCurrentJobs().isEmpty()) - { - out.println(unsafe("")); - } - else - { - out.println(unsafe("")); - } - %> - - -<% - if (bean.getCurrentTasks().isEmpty()) - { - out.println(unsafe("")); - } - else - { - - out.println(unsafe("")); - } -%> - - -<% - if (bean.getCompletedTasks().isEmpty()) - { - out.println(unsafe("")); - } - else - { - out.println(unsafe("")); - %> - -<% - } -%> -
Status<%= unsafe(bean.isActive() ? "Active" : "Inactive")%>
Initiator<%= h(bean.getInitiator().getDisplayName(getUser())) %>
Current Job(s)None
")); - for (WorkflowJob job: bean.getCurrentJobs()) - { - %> - <%= h(job.getId()) %>: Due date <%= formatDateTime(job.getDueDate()) %> -
- <% - } - out.println(unsafe("
Current Task(s)None
")); - for (WorkflowTask task: bean.getCurrentTasks()) - { -%> - <% - if (task.canView(getUser(), getContainer())) - { - %> - <%=link(task.getName(), urlFor(WorkflowController.TaskAction.class).addParameter("taskId", task.getId())) %> - <% - } - else - { - %> - <%= h(task.getName()) %> - <% - } - if (task.getAssignee() != null) - { - %> - (assigned to <%= h(task.getAssignee().getDisplayName(getUser())) %>) - <% - } - else - { - %> - (currently unassigned) - <% - } - %> -
-<% - } - out.println(unsafe("
Completed Task(s)None
")); - for (WorkflowTask completedTask: bean.getCompletedTasks()) - { -%> - <% - if (completedTask.canView(getUser(), getContainer())) - { - %> - <%=link(completedTask.getName(), urlFor(WorkflowController.TaskAction.class).addParameter("taskId", completedTask.getId())) %> - <% - } - else - { - %> - <%= h(completedTask.getName()) %> - <% - } - if (completedTask.getAssignee() != null) - { - %> - (completed by <%= h(completedTask.getAssignee().getDisplayName(getUser())) %>) - <% - } - else - { - %> - (unassigned) - <% - } - %> -
- <% - } - out.println(unsafe("
-<%= unsafe(dataAccessTable(bean.getVariables(), bean.canAccessData(getUser(), getContainer()))) %> -<% - if (bean.hasDiagram(getContainer())) - { -%> -
-Process Diagram -

-"> -<% - - } - } -%> diff --git a/src/org/labkey/workflow/view/workflowSummary.jsp b/src/org/labkey/workflow/view/workflowSummary.jsp deleted file mode 100644 index 7f67c66..0000000 --- a/src/org/labkey/workflow/view/workflowSummary.jsp +++ /dev/null @@ -1,102 +0,0 @@ -<% -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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. - */ -%> -<%@ page import="org.labkey.api.security.permissions.AdminPermission" %> -<%@ page import="org.labkey.api.view.ActionURL" %> -<%@ page import="org.labkey.api.view.HttpView" %> -<%@ page import="org.labkey.workflow.WorkflowController" %> -<%@ page import="org.labkey.workflow.model.WorkflowSummary" %> -<%@ page extends="org.labkey.api.jsp.JspBase" %> -<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> -<% - HttpView me = HttpView.currentView(); - WorkflowSummary bean = (WorkflowSummary) me.getModelBean(); -%> - -<% - if (getContainer().hasPermission(getUser(), AdminPermission.class)) - { -%> -<%=link("All workflows", WorkflowController.BeginAction.class)%> -
-
-<% - } -%> -<% - if (bean.getDescription() != null) - { -%> -
-<%= h(bean.getDescription()) %> -<% - } -%> -
    -
  • - <%=link("Active processes", urlFor(WorkflowController.InstanceListAction.class).addParameter("processDefinitionKey", bean.getProcessDefinitionKey())) %> -
  • - -
  • Tasks
  • -
      -
    • - <%=link("All tasks", urlFor(WorkflowController.TaskListAction.class).addParameter("processDefinitionKey", bean.getProcessDefinitionKey()))%> -
    • - -
    • - <%=link("Assigned tasks", urlFor(WorkflowController.TaskListAction.class).addParameter("processDefinitionKey", bean.getProcessDefinitionKey()).addParameter("assignee", getUser().getUserId()))%> -
    • -
    • - <%=link("Owned tasks", urlFor(WorkflowController.TaskListAction.class).addParameter("processDefinitionKey", bean.getProcessDefinitionKey()).addParameter("owner", getUser().getUserId())) %> -
    • -
    • - <%=link("Unassigned tasks", urlFor(WorkflowController.TaskListAction.class).addParameter("processDefinitionKey", bean.getProcessDefinitionKey()).addParameter("assignee", "_blank")) %> -
    • -
    - -
- -
-Current Process Diagram -
-<%= h(bean.getModelFile()) %> -
-<% - if (bean.hasDiagram()) - { -%> -"> -<% - } - else - { -%> -No process diagram available. -<% - - } -%> -
-
-<% - if (getContainer().hasPermission(getUser(), AdminPermission.class)) - { -%> -<%=link("All workflows", WorkflowController.BeginAction.class)%> -<% - } -%> \ No newline at end of file diff --git a/src/org/labkey/workflow/view/workflowTask.jsp b/src/org/labkey/workflow/view/workflowTask.jsp deleted file mode 100644 index 315104b..0000000 --- a/src/org/labkey/workflow/view/workflowTask.jsp +++ /dev/null @@ -1,155 +0,0 @@ -<% -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * 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. - */ -%> -<%@ page import="org.labkey.api.util.DateUtil" %> -<%@ page import="org.labkey.api.view.HttpView" %> -<%@ page import="org.labkey.api.view.template.ClientDependencies" %> -<%@ page import="org.labkey.api.workflow.TaskFormField" %> -<%@ page import="org.labkey.api.workflow.WorkflowTask" %> -<%@ page import="java.util.Map" %> -<%@ page extends="org.labkey.workflow.view.WorkflowViewBase" %> -<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> -<%! - @Override - public void addClientDependencies(ClientDependencies dependencies) - { - dependencies.add("Ext4"); - dependencies.add("workflow/view/reassignTask.js"); - dependencies.add("workflow/view/completeTask.js"); - } -%> - -<% - HttpView me = HttpView.currentView(); - WorkflowTask bean = (WorkflowTask) me.getModelBean(); - if (!bean.canView(getUser(), getContainer())) - { -%> -<%= h(getUser().getDisplayName(getUser())) %> does not have permission to view this task. -<% - } - else - { - String assigneeLabel = bean.isDelegated() ? "Delegated to" : "Assigned to"; - String changeAssigneeLabel = bean.getAssigneeId() == null ? "Assign" : "Reassign"; - boolean canChangeAssignee = bean.canClaim(getUser(), getContainer()) || (bean.isDelegated() && bean.canDelegate(getUser(), getContainer())) || bean.canAssign(getUser(), getContainer()); -%> -<%= navigationLinks(bean.getProcessDefinitionName(getContainer()), bean.getProcessDefinitionKey(getContainer()), bean.getProcessInstanceId()) %> -
-
- - - - - - <% - if (bean.getDescription() != null) - { - %> - - - - <% - } - %> - - - <% - if (bean.getDueDate() != null) - { - %> - - <% - } - %> - -
- <%= h(bean.getName()) %> -
<%= h(bean.getDescription()) %>
Created: <%= h(DateUtil.formatDateTime(getContainer(), bean.getCreateTime())) %> Due: <%= h(DateUtil.formatDateTime(getContainer(), bean.getDueDate())) %>
- - -Task Details -<% - if (canChangeAssignee) - { -%> - - <%= button(changeAssigneeLabel).onClick("createReassignTaskWindow(" + q(bean.getId()) + ", " + bean.getAssigneeId() + "); return false;") %> -<% - } -%> -

- - - - - - <% - if (bean.getOwner() != null) - { - %> - - - - - <% - } - %> - <% - if (bean.getAssignee() != null) - { - %> - - - - - <% - } - %> - -<%= unsafe(variablesTableRows(bean.getVariables())) %> -
Status<%= unsafe(bean.isActive() ? "Active" : "Inactive") %>
Owned by<%= h(bean.getOwner().getDisplayName(getUser())) %>
<%= h(assigneeLabel) %><%= h(bean.getAssignee().getDisplayName(getUser())) %>
-<%= unsafe(dataAccessTable(bean.getVariables(), bean.canAccessData(getUser(), getContainer()))) %> - -
-<% - if (bean.canComplete(getUser(), getContainer())) - { - Map fields = bean.getFormFields(); - if (fields.isEmpty()) - { - if (bean.getTaskDefinitionKey().equals("downloadDataSet")) - { -%> -<%= button("Complete Task").onClick("completeWorkflowTask(" + q(bean.getId()) + "," + qh(bean.getTaskDefinitionKey()) + ", [], " + q(bean.getProcessInstanceId()) + "," + qh(bean.getProcessDefinitionKey(getContainer())) + ")")%> -<% - } - else - { -%> -<%= button(bean.getName()).onClick("completeWorkflowTask(" + q(bean.getId()) + "," + qh(bean.getTaskDefinitionKey()) + ", [], " + q(bean.getProcessInstanceId()) + "," + qh(bean.getProcessDefinitionKey(getContainer())) + ")")%> -<% - } - } - else { -%> -
Unsupported in UI
-<% - } - } - } -%> diff --git a/src/resources/workflow/config/activiti.cfg.xml b/src/resources/workflow/config/activiti.cfg.xml deleted file mode 100644 index 4e90a12..0000000 --- a/src/resources/workflow/config/activiti.cfg.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/webapp/workflow/view/completeTask.js b/webapp/workflow/view/completeTask.js deleted file mode 100644 index 84834af..0000000 --- a/webapp/workflow/view/completeTask.js +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ -/** - * The Ext component is currently not used in the application. We would need to pass in the - * form fields to do something more than just a generic "comment" form, and then write the - * logic to display the different fields with Ext components. - * - * Created by susanh on 5/20/15. - */ -Ext4.define("Workflow.view.dialog.CompleteTask", { - extend: 'Ext.window.Window', - title: 'Complete Task', - modal: true, - completeTaskEvent: "submitclick", - taskId: null, - name: null, - parameters: null, - processInstanceId: null, - processDefinitionKey: null, - - constructor : function(config) { - this.callParent([config]); - this.addEvents([this.completeTaskEvent]); - }, - - initComponent : function() - { - this.border = false; - - this.items = [ - { - itemId: 'taskDescription', - xtype: 'box', - width: 400, - padding: '15px 15px', - html: this.name - }, - { - xtype : 'textareafield', - width : 325, - height : 50, - padding: '15px 15px', - itemId : 'TaskComment', - fieldLabel : 'Comment ', - labelWidth : 75, - listeners : { - scope: this, - change: function (cmp, newValue) - { - var trimmedVal = newValue ? newValue.trim() : ""; - this.down('button#SubmitButton').setDisabled(trimmedVal.length == 0); - } - } - }, - { - xtype : 'combobox', - itemId:'decisionCombo', - width : 250, - name : 'decision', - fieldLabel : 'Decision', - labelWidth : 75, - labelSeparator : '', - store : Ext4.create('Ext.data.Store', { - fields: ['name', 'description'], - data : [ - {'name':'approve', 'description':'Approve'}, - {'name':'deny', 'description':'Deny'} - ] - }), - queryMode : 'local', - value : {}, - valueField : 'name', - displayField : 'description', - forceSelection : true, - editable : false, - scope: this, - listConfig : { - getInnerTpl : function() { - return '
{description}
'; - } - }, - listeners : { - select : function(combo, records) { - this.up().parameters.decision = combo.value; - } - } - } - ] - this.buttons = [{ - itemId: 'CancelButton', - disabled: false, - text: 'Cancel', - scope: this, - handler : function() { - this.close(); - } - },{ - text: 'Submit', - itemId: 'SubmitButton', - disabled: false, - scope: this, - handler : function() { - this.fireEvent(this.completeTaskEvent, this.taskId, this.parameters); - this.close(); - } - } - ] - - this.callParent(); - - this.on(this.completeTaskEvent, this.makeTaskCompletionRequest, this); - }, - - - makeTaskCompletionRequest: function(taskId, parameters) - { - parameters.comment = this.down('textfield#TaskComment').getValue(); - var returnURLParams = { - processInstanceId: this.processInstanceId, - processDefinitionKey: this.processDefinitionKey - }; - LABKEY.Ajax.request({ - url: LABKEY.ActionURL.buildURL('workflow', 'completeTask'), - method: 'POST', - jsonData: { - taskId: taskId, - processVariables: parameters - }, - returnUrl: LABKEY.ActionURL.buildURL('workflow', 'processInstance', null, returnURLParams), - scope: this, - success: function(response) { - window.location = LABKEY.ActionURL.buildURL('workflow', 'processInstance', null, returnURLParams) - }, - failure: this.taskActionFailure - }); - }, - - taskActionFailure : function(response){ - var jsonResp = LABKEY.Utils.decode(response.responseText); - if (jsonResp && jsonResp.errors) - { - var errorHTML = jsonResp.errors[0].message; - Ext4.Msg.alert('Error', errorHTML); - } - } - -}); - -// TODO move out of global scope once there's an object to attach it to. -function downloadWorkflowTaskData(url, parameters) { - var newForm = document.createElement('form'); - document.body.appendChild(newForm); - Ext4.Ajax.request({ - url: url, - method: 'POST', - form: newForm, - isUpload: true, - params: parameters, - failure: function(response) - { - var jsonResp = LABKEY.Utils.decode(response.responseText); - if (jsonResp && jsonResp.errors) - { - var errorHTML = jsonResp.errors[0].message; - Ext4.Msg.alert('Error', errorHTML); - } - }, - scope: this - }); -} - -// TODO remove from global scope once there's an object to attach it to. -// The one above is currently not used in the application. -function completeWorkflowTask(taskId, formName, fields, processInstanceId, processDefinitionKey) -{ - var form = document.forms[formName]; - var parameters = {}; - for (i = 0, len = fields.length; i < len; i++) - { - parameters[fields[i]] = form[fields[i]].value; - } - var returnURLParams = { - processInstanceId: processInstanceId, - processDefinitionKey: processDefinitionKey - }; - Ext4.Ajax.request({ - url: LABKEY.ActionURL.buildURL('workflow', 'completeTask'), - method: 'POST', - jsonData: { - taskId: taskId, - processVariables: parameters - }, - returnUrl: LABKEY.ActionURL.buildURL('workflow', 'processInstance', null, returnURLParams), - scope: this, - success: function(response) { - window.location = LABKEY.ActionURL.buildURL('workflow', 'processInstance', null, returnURLParams); - }, - failure: function(response) - { - var jsonResp = LABKEY.Utils.decode(response.responseText); - if (jsonResp && jsonResp.errors) - { - var errorHTML = jsonResp.errors[0].message; - Ext4.Msg.alert('Error', errorHTML); - } - } - }); -} diff --git a/webapp/workflow/view/deleteProcessInstance.js b/webapp/workflow/view/deleteProcessInstance.js deleted file mode 100644 index f2832c6..0000000 --- a/webapp/workflow/view/deleteProcessInstance.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ -/** - * Created by susanh on 5/29/15. - */ -Ext4.define("Workflow.view.dialog.DeleteProcessInstance", { - extend: 'Ext.window.Window', - title: 'Remove Process Instance', - modal: true, - deleteProcessEvent: "confirmclick", - processInstanceId: null, - processDefinitionKey: null, - name: null, - - constructor : function(config) { - this.callParent([config]); - this.addEvents([this.deleteProcessEvent]); - }, - - initComponent : function() - { - this.border = false; - - this.items = [ - { - itemId: 'confirmationMessage', - xtype: 'box', - width: 400, - padding: '15px 15px', - html: 'Are you sure you want to permanently remove this process instance?

' + this.name - }, - { - xtype : 'textareafield', - width : 325, - height : 50, - padding: '15px 15px', - itemId : 'DeletionComment', - fieldLabel : 'Comment (optional)', - labelWidth : 75 - } - ] - this.buttons = [{ - itemId: 'CancelButton', - disabled: false, - text: 'Cancel', - scope: this, - handler : function() { - this.close(); - } - },{ - text: 'Confirm', - itemId: 'ConfirmButton', - disabled: false, - scope: this, - handler : function() { - this.fireEvent(this.deleteProcessEvent, this.processInstanceId, this.processDefinitionKey); - this.close(); - } - } - ] - - this.callParent(); - - this.on(this.deleteProcessEvent, this.makeDeleteProcessInstanceRequest, this); - }, - - makeDeleteProcessInstanceRequest: function(processInstanceId, processDefinitionKey) - { - var parameters = { - processDefinitionKey: processDefinitionKey - } - LABKEY.Ajax.request({ - url: LABKEY.ActionURL.buildURL('workflow', 'removeProcessInstance.api'), - method: 'POST', - jsonData: { - processInstanceId: processInstanceId, - comment: this.down('textfield#DeletionComment').getValue() - }, - returnUrl: window.location, - scope: this, - success: function(response) { - window.location = LABKEY.ActionURL.buildURL('workflow', 'instanceList', LABKEY.containerPath, parameters) - }, - failure: this.actionFailure - }); - }, - - actionFailure : function(response){ - var jsonResp = LABKEY.Utils.decode(response.responseText); - if (jsonResp && jsonResp.errors) - { - var errorHTML = jsonResp.errors[0].message; - Ext4.Msg.alert('Error', errorHTML); - } - } - -}); - -function createDeleteProcessInstanceConfirmationWindow(processInstanceId, processDefinitionKey, name) -{ - Ext4.create("Workflow.view.dialog.DeleteProcessInstance", { - processInstanceId: processInstanceId, - processDefinitionKey: processDefinitionKey, - name: name - }).show(); -} diff --git a/webapp/workflow/view/reassignTask.js b/webapp/workflow/view/reassignTask.js deleted file mode 100644 index 2bdb611..0000000 --- a/webapp/workflow/view/reassignTask.js +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2015-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ -/** - * Created by susanh on 5/19/15. - */ - -Ext4.define("Workflow.view.dialog.ReassignTask", { - extend: 'Ext.window.Window', - title: 'Reassign Task', - modal: true, - reassignEvent : "reassignclick", - - constructor : function(config) { - this.callParent([config]); - this.addEvents([this.reassignEvent]); - this.taskId = config['taskId']; - this.assgineeId = config['assigneeId']; - }, - - initComponent : function() - { - this.border = false; - - this.userCombo = Ext4.create('Ext.form.field.ComboBox', { - store: this.getUserStore(), - name: 'reassign', - itemId: 'reassign', - allowBlank: true, - valueField: 'userId', - displayField: 'displayName', - padding: '15px 15px', - fieldLabel: 'User', - triggerAction: 'all', - labelWidth: 75, - typeAhead: true, - forceSelection: true, - tpl: Ext4.create('Ext.XTemplate', - '', - '
{displayName:htmlEncode}
', - '
'), - listeners : { - scope: this, - 'select': function (field, value) - { - this.down('button#DelegateButton').setDisabled(value.length == 0); - this.down('button#AssignButton').setDisabled(value.length == 0); - } - } - }); - - this.instructions = Ext4.create('Ext.view.View', { - itemId: 'instructions', - xtype: 'box', - width: 400, - padding: '15px 15px', - store : this.getPermissionsStore(), - tpl: new Ext4.XTemplate ( - 'You can reassign a task to any user with one of the following permissions within this folder: ', - '
    ', - '', - '
  • {name:htmlEncode}', - '', - '
', - 'When delegating, you will retain ownership of the task for further review after the task is completed.' - ) - }); - - this.items = [ - this.instructions, - this.userCombo - ]; - - this.buttons = [{ - itemId: 'CancelButton', - disabled: false, - text: 'Cancel', - scope: this, - handler : function() { - this.close(); - } - },{ - text: 'Claim', - itemId: 'ClaimButton', - disabled: this.assigneeId != "" && this.assigneeId != null, - scope: this, - handler : function() { - this.fireEvent(this.reassignEvent, this.taskId, "Claim"); - this.close(); - } - },{ - text: 'Delegate', - itemId: 'DelegateButton', - disabled: true, - scope: this, - handler : function() { - this.fireEvent(this.reassignEvent, this.taskId, "Delegate"); - this.close(); - } - },{ - text: 'Assign', - itemId: 'AssignButton', - disabled: true, - scope: this, - handler : function() { - this.fireEvent(this.reassignEvent, this.taskId, 'Assign'); - this.close(); - } - } - ]; - - this.callParent(); - - this.on(this.reassignEvent, this.makeReassignmentRequest, this); - }, - - makeReassignmentRequest: function(taskId, reassignmentType) - { - LABKEY.Ajax.request({ - url: LABKEY.ActionURL.buildURL('workflow', reassignmentType + 'Task'), - method: 'POST', - params: { - taskId: taskId, - ownerId: LABKEY.user.id, - assigneeId: reassignmentType == 'Claim' ? LABKEY.user.id : this.userCombo.getValue(), - returnUrl: window.location - }, - scope: this, - success: function(response) { - window.location.reload(); - }, - failure: function(response){ - var jsonResp = LABKEY.Utils.decode(response.responseText); - if (jsonResp && jsonResp.errors) - { - var errorHTML = jsonResp.errors[0].message; - Ext4.Msg.alert('Error', errorHTML); - } - } - }); - }, - - getPermissionsStore : function() { - // define data models - if (!Ext4.ModelManager.isRegistered('LABKEY.Workflow.ReassignmentPermissions')) { - Ext4.define('LABKEY.Workflow.ReassignmentPermissions', { - extend: 'Ext.data.Model', - fields: [ - {name: 'name', type: 'string'} - ] - }); - } - - return Ext4.create('Ext.data.Store', { - model: 'LABKEY.Workflow.ReassignmentPermissions', - autoLoad: true, - proxy: { - type: 'ajax', - url: LABKEY.ActionURL.buildURL('workflow', 'getReassignPermissionNames.api', LABKEY.container.path, {taskId: this.taskId}), - reader: { - type: 'json', - root: 'data.permissions' - } - } - }); - }, - - getUserStore: function(){ - // define data models - if (!Ext4.ModelManager.isRegistered('LABKEY.Workflow.ReassignmentUsers')) { - Ext4.define('LABKEY.Workflow.ReassignmentUsers', { - extend: 'Ext.data.Model', - fields: [ - {name: 'userId', type: 'integer'}, - {name: 'displayName', type: 'string'} - ] - }); - } - - return Ext4.create('Ext.data.Store', { - model: 'LABKEY.Workflow.ReassignmentUsers', - autoLoad: true, - proxy: { - type: 'ajax', - url: LABKEY.ActionURL.buildURL('workflow', 'candidateUsers.api', LABKEY.container.path, {taskId: this.taskId}), - reader: { - type: 'json', - root: 'data.users' - } - } - }); - } - -} -); - -// helper used in display column -function createReassignTaskWindow(taskId, assigneeId) { - Ext4.create("Workflow.view.dialog.ReassignTask", { - taskId: taskId, - assigneeId: assigneeId, - }).show(); -} \ No newline at end of file diff --git a/webapp/workflow/view/workflow.css b/webapp/workflow/view/workflow.css deleted file mode 100644 index b68169a..0000000 --- a/webapp/workflow/view/workflow.css +++ /dev/null @@ -1,3 +0,0 @@ -.labkey-workflow-detail-label { - vertical-align: top; -} \ No newline at end of file