public class AttachmentFactory {
private static AttachmentDO create(Attachment attachment) {
return AttachmentDO
.builder()
.id(attachment.getId())
.name(attachment.getName())
.description(attachment.getDescription())
.taskId(attachment.getTaskId())
.type(attachment.getType())
.url(attachment.getUrl())
.createTime(DateUtils.toLocalDateTime(attachment.getCreateTime()))
.removalTime(DateUtils.toLocalDateTime(attachment.getRemovalTime()))
.rootProcessInstanceId(attachment.getRootProcessInstanceId())
.processInstanceId(attachment.getProcessInstanceId())
.build();
}
}
》》》》》》》》》》》》》》》》
package yssWork.domin;
import org.camunda.bpm.engine.TaskService;
import java.util.Date;
public interface Attachment {
/** unique id for this attachment */
String getId();
/** free user defined short (max 255 chars) name for this attachment */
String getName();
/** free user defined short (max 255 chars) name for this attachment */
void setName(String name);
/** long (max 255 chars) explanation what this attachment is about in context of the task and/or process instance it's linked to. */
String getDescription();
/** long (max 255 chars) explanation what this attachment is about in context of the task and/or process instance it's linked to. */
void setDescription(String description);
/** indication of the type of content that this attachment refers to. Can be mime type or any other indication. */
String getType();
/** reference to the task to which this attachment is associated. */
String getTaskId();
/** reference to the process instance to which this attachment is associated. */
String getProcessInstanceId();
/** the remote URL in case this is remote content. If the attachment content was
* {@link TaskService#createAttachment(String, String, String, String, String, java.io.InputStream) uploaded with an input stream},
* then this method returns null and the content can be fetched with {@link TaskService#getAttachmentContent(String)}. */
String getUrl();
/** The time when the attachment was created. */
Date getCreateTime();
/** reference to the root process instance id of the process instance on which this attachment was made */
String getRootProcessInstanceId();
/** The time the historic attachment will be removed. */
Date getRemovalTime();
}
》》》》》》》》》》》》》》》》》》
package yssWork.domin;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AttachmentDO {
/**
* 附件Id
*/
private String id;
/**
* 附件名
*/
private String name;
/**
* 附件描述
*/
private String description;
/**
* 任务Id
*/
private String taskId;
/**
* 附件类型
*/
private String type;
/**
* 附件URL
*/
private String url;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 清除时间
*/
private LocalDateTime removalTime;
/**
* 根流程实例Id
*/
private String rootProcessInstanceId;
/**
* 流程实例Id
*/
private String processInstanceId;
}
》》》》》》》》》》》》》》》》》
根据AttchmentId获取附件
@Override
public Optional findById(String attachmentId) {
Attachment attachment = taskService.getAttachment(attachmentId);
return AttachmentFactory.createByAttachment(attachment);
}