-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding aps-attach-task-form-extension
- Loading branch information
Ciju
committed
Apr 20, 2018
1 parent
47315f1
commit 88f98c6
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
#*.jar | ||
*.war | ||
*.ear | ||
#*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
.xml/ | ||
/target/ | ||
.classpath | ||
.project | ||
.settings/ | ||
|
Empty file.
Binary file added
BIN
+4.06 KB
aps-attach-task-form-extension/aps-attach-task-form-extension-1.0-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.alfresco.aps</groupId> | ||
<artifactId>aps-attach-task-form-extension</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>aps-attach-task-form-extension</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.activiti</groupId> | ||
<artifactId>activiti-app-dependencies</artifactId> | ||
<version>1.8.0</version> | ||
<type>pom</type> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.alfresco.cmis.client</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.aspose</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.alfresco.officeservices</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>alfresco-artifacts-repository</id> | ||
<name>Alfresco EE releases</name> | ||
<url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-enterprise-releases</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
</project> |
62 changes: 62 additions & 0 deletions
62
aps-attach-task-form-extension/src/main/java/com/activiti/extension/bean/AttachTaskForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.activiti.extension.bean; | ||
|
||
import java.util.List; | ||
import org.activiti.engine.delegate.DelegateTask; | ||
import org.activiti.engine.delegate.TaskListener; | ||
import org.activiti.engine.runtime.Clock; | ||
import org.apache.commons.collections.CollectionUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.activiti.domain.editor.Model; | ||
import com.activiti.domain.editor.StencilSetHistory; | ||
import com.activiti.domain.runtime.Form; | ||
import com.activiti.repository.editor.StencilSetHistoryRepository; | ||
import com.activiti.repository.runtime.FormRepository; | ||
import com.activiti.service.editor.AlfrescoFormService; | ||
|
||
@Component("attachTaskForm") | ||
public class AttachTaskForm implements TaskListener { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Autowired | ||
protected FormRepository formRepository; | ||
|
||
@Autowired | ||
protected AlfrescoFormService formService; | ||
|
||
@Autowired | ||
protected Clock clock; | ||
|
||
@Autowired | ||
protected StencilSetHistoryRepository stencilSetHistoryRepository; | ||
|
||
@Override | ||
public void notify(DelegateTask task) { | ||
//Get the formId using the formKey set on Task | ||
Long formId = Long.parseLong((String) task.getVariable(task.getFormKey())); | ||
Model model = formService.getFormModel(formId); | ||
|
||
Form form = new Form(); | ||
form.setName(model.getName()); | ||
form.setDescription(model.getDescription()); | ||
form.setCreated(clock.getCurrentTime()); | ||
form.setModelId(formId); | ||
form.setDefinition(model.getModelEditorJson()); | ||
form.setTenantId(model.getTenantId()); | ||
if (model.getStencilSetId() != null && model.getStencilSetId() > 0) { | ||
List<StencilSetHistory> stencilHistoryList = stencilSetHistoryRepository | ||
.findByStencilSetIdOrderByIdDesc(model.getStencilSetId()); | ||
if (CollectionUtils.isNotEmpty(stencilHistoryList)) { | ||
form.setStencilSetId(stencilHistoryList.get(0).getId()); | ||
} | ||
|
||
} | ||
formRepository.save(form); | ||
// Overwrite the formKey with the new deployed formId | ||
task.setFormKey(form.getId().toString()); | ||
|
||
} | ||
|
||
} |