本文整理汇总了Java中org.activiti.engine.impl.persistence.entity.ByteArrayEntity类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayEntity类的具体用法?Java ByteArrayEntity怎么用?Java ByteArrayEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayEntity类属于org.activiti.engine.impl.persistence.entity包,在下文中一共展示了ByteArrayEntity类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
public Attachment execute(CommandContext commandContext) {
verifyParameters(commandContext);
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(attachmentName);
attachment.setDescription(attachmentDescription);
attachment.setType(attachmentType);
attachment.setTaskId(taskId);
attachment.setProcessInstanceId(processInstanceId);
attachment.setUrl(url);
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.insert(attachment);
if (content != null) {
byte[] bytes = IoUtil.readInputStream(content, attachmentName);
ByteArrayEntity byteArray = ByteArrayEntity.createAndInsert(bytes);
attachment.setContentId(byteArray.getId());
}
commandContext.getHistoryManager()
.createAttachmentComment(taskId, processInstanceId, attachmentName, true);
return attachment;
}
示例2: execute
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
@Override
public InputStream execute(CommandContext commandContext) {
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
AttachmentEntity attachment = dbSqlSession.selectById(AttachmentEntity.class, attachmentId);
String contentId = attachment.getContentId();
if (contentId == null) {
return null;
}
ByteArrayEntity byteArray = dbSqlSession.selectById(ByteArrayEntity.class, contentId);
byte[] bytes = byteArray.getBytes();
return new ByteArrayInputStream(bytes);
}
示例3: createTask
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
public void createTask(CommandContext commandContext, DbSqlSession dbSqlSession, MailTransformer mailTransformer) throws MessagingException {
// distill the task description from the mail body content (without the html tags)
String taskDescription = mailTransformer.getHtml();
taskDescription = taskDescription.replaceAll("\\<.*?\\>", "");
taskDescription = taskDescription.replaceAll("\\s", " ");
taskDescription = taskDescription.trim();
if (taskDescription.length()>120) {
taskDescription = taskDescription.substring(0, 117)+"...";
}
// create and insert the task
TaskEntity task = new TaskEntity();
task.setAssignee(userId);
task.setName(mailTransformer.getMessage().getSubject());
task.setDescription(taskDescription);
dbSqlSession.insert(task);
String taskId = task.getId();
// add identity links for all the recipients
for (String recipientEmailAddress: mailTransformer.getRecipients()) {
User recipient = new UserQueryImpl(commandContext)
.userEmail(recipientEmailAddress)
.singleResult();
if (recipient!=null) {
task.addUserIdentityLink(recipient.getId(), "Recipient");
}
}
// attach the mail and other attachments to the task
List<AttachmentEntity> attachments = mailTransformer.getAttachments();
for (AttachmentEntity attachment: attachments) {
// insert the bytes as content
ByteArrayEntity content = attachment.getContent();
dbSqlSession.insert(content);
// insert the attachment
attachment.setContentId(content.getId());
attachment.setTaskId(taskId);
dbSqlSession.insert(attachment);
}
}
示例4: MailTransformer
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
public MailTransformer(Message message) throws Exception {
this.message = message;
processRecipients(message);
processContentPart(0, message);
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(message.getSubject());
attachment.setType("email");
attachments.add(attachment);
JSONObject jsonMail = new JSONObject();
jsonMail.put("recipients", recipients);
jsonMail.put("sentDate", message.getSentDate());
jsonMail.put("receivedDate", message.getReceivedDate());
jsonMail.put("subject", message.getSubject());
jsonMail.put("htmlContent", getHtml());
String jsonMailString = jsonMail.toString(2);
byte[] bytes = jsonMailString.getBytes();
attachment.setContent(new ByteArrayEntity(bytes));
log.fine("=== json ==========================");
log.fine(jsonMailString);
log.fine("=== attachments ==========================");
for (AttachmentEntity attachmentForLogging: attachments) {
log.fine(attachmentForLogging.getName()+" | "+attachmentForLogging.getType()+" | "+attachmentForLogging.getContent().getBytes().length);
}
}
示例5: processContentPart
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
protected void processContentPart(int indent, Part part) throws Exception {
if (part.getContent() instanceof MimeMultipart) {
log(indent, "--- multipart "+getMimeType(part)+" ----------------------------------");
MimeMultipart mimeMultipart = (MimeMultipart) part.getContent();
for (int i=0; i<mimeMultipart.getCount(); i++) {
BodyPart bodyPart = mimeMultipart.getBodyPart(i);
processContentPart(indent+1, bodyPart);
}
} else {
log(indent, "--- part "+getMimeType(part)+" ----------------------------------");
if (part.isMimeType("text/plain")) {
String contentText = (String) part.getContent();
log(indent, "adding plain text: "+contentText);
messageText.append(contentText);
} else if (part.isMimeType("text/html")){
String rawHtml = (String) part.getContent();
log(indent, "raw html: "+rawHtml);
String cleanedUpHtml = htmlExtractBodyContent(rawHtml);
log(indent, "adding cleaned up html: "+cleanedUpHtml);
containsHtml = true;
messageHtml.append(cleanedUpHtml);
} else {
String fileName = part.getFileName();
log(indent, "unknown content part | "+part.getContentType()+" | "+part.getDisposition()+" | "+Arrays.toString(part.getHeader("Content-ID"))+" | "+fileName+" | "+part.getContent().getClass().getName());
if (part.getSize()!=-1 && part.getSize()<ATTACHMENT_SIZE_LIMIT && (part.getContent() instanceof InputStream)) {
String attachmentName = null;
String attachmentType = null;
String[] contentIdArray = part.getHeader("Content-ID");
if (contentIdArray!=null && contentIdArray.length>0) {
attachmentName = contentIdArray[0].trim();
if (attachmentName.startsWith("<") && attachmentName.endsWith(">")) {
attachmentName = attachmentName.substring(1, attachmentName.length()-2).trim();
}
attachmentType = getImageMimeType(attachmentName);
} else if (Part.INLINE.equalsIgnoreCase(part.getDisposition())) {
attachmentName = fileName;
attachmentType = getImageMimeType(attachmentName);
messageText.append("<img id=\"cid:"+fileName+"\" src=\"cid:"+fileName+"\" />");
messageHtml.append("<img id=\"cid:"+fileName+"\" src=\"cid:"+fileName+"\" />");
}
if (attachmentName==null) {
attachmentName = fileName;
attachmentType = "email-attachment";
}
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(attachmentName);
attachment.setType(attachmentType);
attachments.add(attachment);
byte[] bytes = IoUtil.readInputStream((InputStream)part.getContent(), "mail attachment "+attachmentName);
attachment.setContent(new ByteArrayEntity(bytes));
}
}
}
}
示例6: execute
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
public InputStream execute(CommandContext commandContext) {
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
AttachmentEntity attachment = dbSqlSession.selectById(AttachmentEntity.class, attachmentId);
String contentId = attachment.getContentId();
if (contentId==null) {
return null;
}
ByteArrayEntity byteArray = dbSqlSession.selectById(ByteArrayEntity.class, contentId);
byte[] bytes = byteArray.getBytes();
return new ByteArrayInputStream(bytes);
}
示例7: execute
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
public Attachment execute(CommandContext commandContext) {
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(attachmentName);
attachment.setDescription(attachmentDescription);
attachment.setType(attachmentType);
attachment.setTaskId(taskId);
attachment.setProcessInstanceId(processInstanceId);
attachment.setUrl(url);
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.insert(attachment);
if (content!=null) {
byte[] bytes = IoUtil.readInputStream(content, attachmentName);
ByteArrayEntity byteArray = new ByteArrayEntity(bytes);
dbSqlSession.insert(byteArray);
attachment.setContentId(byteArray.getId());
}
CommentManager commentManager = commandContext.getCommentManager();
if (commentManager.isHistoryEnabled()) {
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(ClockUtil.getCurrentTime());
comment.setTaskId(taskId);
comment.setProcessInstanceId(processInstanceId);
comment.setAction(Event.ACTION_ADD_ATTACHMENT);
comment.setMessage(attachmentName);
commentManager.insert(comment);
}
return attachment;
}
示例8: execute
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
@Override
public Attachment execute(CommandContext commandContext) {
verifyParameters(commandContext);
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(attachmentName);
attachment.setDescription(attachmentDescription);
attachment.setType(attachmentType);
attachment.setTaskId(taskId);
attachment.setProcessInstanceId(processInstanceId);
attachment.setUrl(url);
attachment.setUserId(Authentication.getAuthenticatedUserId());
attachment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.insert(attachment);
if (content != null) {
byte[] bytes = IoUtil.readInputStream(content, attachmentName);
ByteArrayEntity byteArray = ByteArrayEntity.createAndInsert(bytes);
attachment.setContentId(byteArray.getId());
attachment.setContent(byteArray);
}
commandContext.getHistoryManager()
.createAttachmentComment(taskId, processInstanceId, attachmentName, true);
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
// Forced to fetch the process-instance to associate the right process definition
String processDefinitionId = null;
if (attachment.getProcessInstanceId() != null) {
ExecutionEntity process = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
if (process != null) {
processDefinitionId = process.getProcessDefinitionId();
}
}
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, attachment, processInstanceId, processInstanceId, processDefinitionId));
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, attachment, processInstanceId, processInstanceId, processDefinitionId));
}
return attachment;
}
示例9: getByteArrayValue
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
/**
* @return the ByteArrayEntity that contains the byte array value, or null if the byte array value is null.
* @deprecated use getBytes.
*/
@Deprecated
ByteArrayEntity getByteArrayValue();
示例10: setByteArrayValue
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
void setByteArrayValue(ByteArrayEntity byteArrayValue);
示例11: getByteArrayValue
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity; //导入依赖的package包/类
ByteArrayEntity getByteArrayValue();