Skip to content

Commit

Permalink
Adding aps-attach-task-form-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciju committed Apr 20, 2018
1 parent 47315f1 commit 88f98c6
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 0 deletions.
28 changes: 28 additions & 0 deletions aps-attach-task-form-extension/.gitignore
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 not shown.
Binary file not shown.
56 changes: 56 additions & 0 deletions aps-attach-task-form-extension/pom.xml
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>
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());

}

}

0 comments on commit 88f98c6

Please sign in to comment.