Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
fbb28d43
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fbb28d43
编写于
7月 15, 2021
作者:
O
o2null
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
snap增加福建
上级
b32d8927
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
385 addition
and
98 deletion
+385
-98
assets/O2OA-logo.jpg
assets/O2OA-logo.jpg
+0
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/ActionDownload.java
...splatform/assemble/surface/jaxrs/snap/ActionDownload.java
+51
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/ActionUpload.java
...essplatform/assemble/surface/jaxrs/snap/ActionUpload.java
+63
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/ExceptionContentConfusion.java
...ssemble/surface/jaxrs/snap/ExceptionContentConfusion.java
+12
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/SnapAction.java
...ocessplatform/assemble/surface/jaxrs/snap/SnapAction.java
+41
-0
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/SnapProperties.java
...x/processplatform/core/entity/content/SnapProperties.java
+12
-0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionDelete.java
...splatform/service/processing/jaxrs/snap/ActionDelete.java
+20
-26
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionRestore.java
...platform/service/processing/jaxrs/snap/ActionRestore.java
+78
-72
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionTypeSnap.java
...latform/service/processing/jaxrs/snap/ActionTypeSnap.java
+1
-0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionUpload.java
...splatform/service/processing/jaxrs/snap/ActionUpload.java
+65
-0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/BaseAction.java
...essplatform/service/processing/jaxrs/snap/BaseAction.java
+22
-0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/SnapAction.java
...essplatform/service/processing/jaxrs/snap/SnapAction.java
+20
-0
未找到文件。
assets/O2OA-logo.jpg
已删除
100644 → 0
浏览文件 @
b32d8927
32.2 KB
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/ActionDownload.java
0 → 100644
浏览文件 @
fbb28d43
package
com.x.processplatform.assemble.surface.jaxrs.snap
;
import
java.nio.charset.StandardCharsets
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoFile
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.processplatform.assemble.surface.Business
;
import
com.x.processplatform.core.entity.content.Snap
;
class
ActionDownload
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionDownload
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
id
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
Snap
snap
=
emc
.
find
(
id
,
Snap
.
class
);
if
(!
allow
(
effectivePerson
,
business
,
snap
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
,
snap
);
}
String
text
=
gson
.
toJson
(
snap
);
Wo
wo
=
new
Wo
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
),
this
.
contentType
(
false
,
id
),
this
.
contentDisposition
(
false
,
id
));
result
.
setData
(
wo
);
}
return
result
;
}
private
boolean
allow
(
EffectivePerson
effectivePerson
,
Business
business
,
Snap
snap
)
throws
Exception
{
return
(
business
.
canManageApplicationOrProcess
(
effectivePerson
,
snap
.
getApplication
(),
snap
.
getProcess
())
||
effectivePerson
.
isNotPerson
(
snap
.
getPerson
()));
}
public
static
class
Wo
extends
WoFile
{
private
static
final
long
serialVersionUID
=
-
2577413577740827608L
;
public
Wo
(
byte
[]
bytes
,
String
contentType
,
String
contentDisposition
)
{
super
(
bytes
,
contentType
,
contentDisposition
);
}
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/ActionUpload.java
0 → 100644
浏览文件 @
fbb28d43
package
com.x.processplatform.assemble.surface.jaxrs.snap
;
import
java.nio.charset.StandardCharsets
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.Applications
;
import
com.x.base.core.project.x_processplatform_service_processing
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapString
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.processplatform.assemble.surface.Business
;
import
com.x.processplatform.assemble.surface.ThisApplication
;
import
com.x.processplatform.core.entity.content.Snap
;
class
ActionUpload
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionUpload
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
byte
[]
bytes
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
String
text
=
new
String
(
bytes
,
StandardCharsets
.
UTF_8
);
Snap
snap
=
gson
.
fromJson
(
text
,
Snap
.
class
);
if
(!
allow
(
effectivePerson
,
business
,
snap
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
if
(!
check
(
snap
))
{
throw
new
ExceptionContentConfusion
();
}
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
ThisApplication
.
context
().
applications
()
.
postQuery
(
effectivePerson
.
getDebugger
(),
x_processplatform_service_processing
.
class
,
Applications
.
joinQueryUri
(
"snap"
,
"upload"
),
text
,
snap
.
getJob
())
.
getData
(
Wo
.
class
);
result
.
setData
(
wo
);
return
result
;
}
}
private
boolean
check
(
Snap
snap
)
{
if
(
StringUtils
.
isBlank
(
snap
.
getId
()))
{
return
false
;
}
if
(
StringUtils
.
isBlank
(
snap
.
getJob
()))
{
return
false
;
}
return
!((
null
==
snap
.
getProperties
().
getWorkCompleted
())
&&
snap
.
getProperties
().
getWorkList
().
isEmpty
());
}
private
boolean
allow
(
EffectivePerson
effectivePerson
,
Business
business
,
Snap
snap
)
throws
Exception
{
return
(
business
.
canManageApplicationOrProcess
(
effectivePerson
,
snap
.
getApplication
(),
snap
.
getProcess
()));
}
public
static
class
Wo
extends
WrapString
{
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/ExceptionContentConfusion.java
0 → 100644
浏览文件 @
fbb28d43
package
com.x.processplatform.assemble.surface.jaxrs.snap
;
import
com.x.base.core.project.exception.LanguagePromptException
;
class
ExceptionContentConfusion
extends
LanguagePromptException
{
private
static
final
long
serialVersionUID
=
1040883405179987063L
;
ExceptionContentConfusion
()
{
super
(
"snap content confusion."
);
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/snap/SnapAction.java
浏览文件 @
fbb28d43
...
...
@@ -7,6 +7,7 @@ import javax.ws.rs.Consumes;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.PUT
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
...
...
@@ -15,6 +16,9 @@ import javax.ws.rs.container.Suspended;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
org.glassfish.jersey.media.multipart.FormDataContentDisposition
;
import
org.glassfish.jersey.media.multipart.FormDataParam
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.annotation.JaxrsDescribe
;
import
com.x.base.core.project.annotation.JaxrsMethodDescribe
;
...
...
@@ -331,6 +335,43 @@ public class SnapAction extends StandardJaxrsAction {
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"导出快照."
,
action
=
ActionDownload
.
class
)
@GET
@Path
(
"{id}/download"
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
download
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"标识"
)
@PathParam
(
"id"
)
String
id
)
{
ActionResult
<
ActionDownload
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionDownload
().
execute
(
effectivePerson
,
id
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"导入快照."
,
action
=
ActionUpload
.
class
)
@POST
@Path
(
"upload"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
public
void
upload
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@FormDataParam
(
FILE_FIELD
)
byte
[]
bytes
,
@FormDataParam
(
FILE_FIELD
)
final
FormDataContentDisposition
disposition
)
{
ActionResult
<
ActionUpload
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionUpload
().
execute
(
effectivePerson
,
bytes
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
...
...
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/SnapProperties.java
浏览文件 @
fbb28d43
package
com.x.processplatform.core.entity.content
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.x.base.core.entity.JsonProperties
;
import
com.x.base.core.project.annotation.FieldDescribe
;
...
...
@@ -52,6 +54,8 @@ public class SnapProperties extends JsonProperties {
@FieldDescribe
(
"版式文件版本"
)
private
List
<
DocumentVersion
>
documentVersionList
=
new
ArrayList
<
DocumentVersion
>();
private
Map
<
String
,
String
>
attachmentContentMap
=
new
HashMap
<>();
public
Data
getData
()
{
return
data
;
}
...
...
@@ -194,4 +198,12 @@ public class SnapProperties extends JsonProperties {
this
.
workCompleted
=
workCompleted
;
}
public
Map
<
String
,
String
>
getAttachmentContentMap
()
{
return
attachmentContentMap
;
}
public
void
setAttachmentContentMap
(
Map
<
String
,
String
>
attachmentContentMap
)
{
this
.
attachmentContentMap
=
attachmentContentMap
;
}
}
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionDelete.java
浏览文件 @
fbb28d43
...
...
@@ -5,9 +5,7 @@ import java.util.concurrent.TimeUnit;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.annotation.CheckRemoveType
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.executor.ProcessPlatformExecutorFactory
;
import
com.x.base.core.project.http.ActionResult
;
...
...
@@ -16,11 +14,7 @@ import com.x.base.core.project.jaxrs.WoId;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.processplatform.core.entity.content.Attachment
;
import
com.x.processplatform.core.entity.content.Snap
;
import
com.x.processplatform.core.entity.content.Work
;
import
com.x.processplatform.core.entity.content.WorkCompleted
;
import
com.x.processplatform.service.processing.ThisApplication
;
class
ActionDelete
extends
BaseAction
{
...
...
@@ -53,26 +47,26 @@ class ActionDelete extends BaseAction {
if
(
null
==
snap
)
{
throw
new
ExceptionEntityNotExist
(
id
,
Snap
.
class
);
}
// 已经没有work,workCompleted以及snap所以附件可以删除了
if
((
emc
.
countEqual
(
Work
.
class
,
Work
.
job_FIELDNAME
,
snap
.
getJob
())
==
0
)
&&
(
emc
.
countEqual
(
WorkCompleted
.
class
,
WorkCompleted
.
job_FIELDNAME
,
snap
.
getJob
())
==
0
)
&&
(
emc
.
countEqualAndNotEqual
(
Snap
.
class
,
Snap
.
job_FIELDNAME
,
snap
.
getJob
(),
JpaObject
.
id_FIELDNAME
,
snap
.
getId
())
==
0
))
{
emc
.
beginTransaction
(
Attachment
.
class
);
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
job_FIELDNAME
,
snap
.
getJob
()).
forEach
(
o
->
{
try
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
o
.
getStorage
());
if
(
null
!=
mapping
)
{
o
.
deleteContent
(
mapping
);
}
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
emc
.
commit
();
}
//
// 已经没有work,workCompleted以及snap所以附件可以删除了
//
if ((emc.countEqual(Work.class, Work.job_FIELDNAME, snap.getJob()) == 0)
//
&& (emc.countEqual(WorkCompleted.class, WorkCompleted.job_FIELDNAME, snap.getJob()) == 0)
//
&& (emc.countEqualAndNotEqual(Snap.class, Snap.job_FIELDNAME, snap.getJob(),
//
JpaObject.id_FIELDNAME, snap.getId()) == 0)) {
//
emc.beginTransaction(Attachment.class);
//
emc.listEqual(Attachment.class, Attachment.job_FIELDNAME, snap.getJob()).forEach(o -> {
//
try {
//
StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
//
o.getStorage());
//
if (null != mapping) {
//
o.deleteContent(mapping);
//
}
//
emc.remove(o, CheckRemoveType.all);
//
} catch (Exception e) {
//
logger.error(e);
//
}
//
});
//
emc.commit();
//
}
emc
.
beginTransaction
(
Snap
.
class
);
emc
.
remove
(
snap
,
CheckRemoveType
.
all
);
emc
.
commit
();
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionRestore.java
浏览文件 @
fbb28d43
package
com.x.processplatform.service.processing.jaxrs.snap
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
...
...
@@ -104,30 +105,6 @@ class ActionRestore extends BaseAction {
}
}
private
void
attachment
(
Business
business
,
Snap
snap
)
throws
Exception
{
EntityManagerContainer
emc
=
business
.
entityManagerContainer
();
List
<
Attachment
>
attachments
=
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
job_FIELDNAME
,
snap
.
getJob
());
attachments
.
stream
().
filter
(
o
->
!
snap
.
getProperties
().
getAttachmentList
().
contains
(
o
)).
forEach
(
o
->
{
try
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
o
.
getStorage
());
if
(
null
!=
mapping
)
{
o
.
deleteContent
(
mapping
);
}
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
attachments
.
stream
().
filter
(
o
->
snap
.
getProperties
().
getAttachmentList
().
contains
(
o
)).
forEach
(
o
->
{
try
{
emc
.
remove
(
o
,
CheckRemoveType
.
all
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
private
void
restore
(
Business
business
,
Snap
snap
)
throws
Exception
{
EntityManagerContainer
emc
=
business
.
entityManagerContainer
();
emc
.
beginTransaction
(
Work
.
class
);
...
...
@@ -141,38 +118,15 @@ class ActionRestore extends BaseAction {
emc
.
beginTransaction
(
DocumentVersion
.
class
);
emc
.
beginTransaction
(
Item
.
class
);
emc
.
beginTransaction
(
Attachment
.
class
);
for
(
Task
o
:
snap
.
getProperties
().
getTaskList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
task_create
(
o
);
}
for
(
TaskCompleted
o
:
snap
.
getProperties
().
getTaskCompletedList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
taskCompleted_create
(
o
);
}
for
(
Read
o
:
snap
.
getProperties
().
getReadList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
read_create
(
o
);
}
for
(
ReadCompleted
o
:
snap
.
getProperties
().
getReadCompletedList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
readCompleted_create
(
o
);
}
for
(
Review
o
:
snap
.
getProperties
().
getReviewList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
review_create
(
o
);
}
for
(
WorkLog
o
:
snap
.
getProperties
().
getWorkLogList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
for
(
Record
o
:
snap
.
getProperties
().
getRecordList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
for
(
DocumentVersion
o
:
snap
.
getProperties
().
getDocumentVersionList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
for
(
Attachment
o
:
snap
.
getProperties
().
getAttachmentList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
restoreTask
(
emc
,
snap
);
restoreTaskCompleted
(
emc
,
snap
);
restoreRead
(
emc
,
snap
);
restoreReadCompleted
(
emc
,
snap
);
restoreReview
(
emc
,
snap
);
restoreWorkLog
(
emc
,
snap
);
restoreRecord
(
emc
,
snap
);
restoreDocumentVersion
(
emc
,
snap
);
restoreAttachment
(
emc
,
snap
);
if
(
ListTools
.
isNotEmpty
(
snap
.
getProperties
().
getWorkList
()))
{
WorkDataHelper
workDataHelper
=
new
WorkDataHelper
(
emc
,
snap
.
getProperties
().
getWorkList
().
get
(
0
));
for
(
Work
o
:
snap
.
getProperties
().
getWorkList
())
{
...
...
@@ -180,7 +134,6 @@ class ActionRestore extends BaseAction {
}
workDataHelper
.
update
(
snap
.
getProperties
().
getData
());
}
attachment
(
business
,
snap
);
emc
.
commit
();
}
...
...
@@ -195,37 +148,90 @@ class ActionRestore extends BaseAction {
emc
.
beginTransaction
(
Record
.
class
);
emc
.
beginTransaction
(
Item
.
class
);
emc
.
beginTransaction
(
Attachment
.
class
);
for
(
TaskCompleted
o
:
snap
.
getProperties
().
getTaskCompletedList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
taskCompleted_create
(
o
);
restoreTaskCompleted
(
emc
,
snap
);
restoreRead
(
emc
,
snap
);
restoreReadCompleted
(
emc
,
snap
);
restoreReview
(
emc
,
snap
);
restoreWorkLog
(
emc
,
snap
);
restoreRecord
(
emc
,
snap
);
restoreAttachment
(
emc
,
snap
);
emc
.
persist
(
snap
.
getProperties
().
getWorkCompleted
(),
CheckPersistType
.
all
);
if
(
BooleanUtils
.
isNotTrue
(
snap
.
getProperties
().
getWorkCompleted
().
getMerged
()))
{
WorkDataHelper
workDataHelper
=
new
WorkDataHelper
(
emc
,
snap
.
getProperties
().
getWorkCompleted
());
workDataHelper
.
update
(
snap
.
getProperties
().
getData
());
}
emc
.
commit
();
}
private
void
restoreRead
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
Read
o
:
snap
.
getProperties
().
getReadList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
read_create
(
o
);
}
for
(
ReadCompleted
o
:
snap
.
getProperties
().
getReadCompletedList
())
{
}
private
void
restoreAttachment
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
Attachment
o
:
snap
.
getProperties
().
getAttachmentList
())
{
String
content
=
snap
.
getProperties
().
getAttachmentContentMap
().
get
(
o
.
getId
());
if
(
StringUtils
.
isNotEmpty
(
content
))
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
o
.
getStorage
());
if
(
null
==
mapping
)
{
mapping
=
ThisApplication
.
context
().
storageMappings
().
random
(
Attachment
.
class
);
}
if
(
null
!=
mapping
)
{
byte
[]
bytes
=
Base64
.
decodeBase64
(
content
);
o
.
updateContent
(
mapping
,
bytes
);
}
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
readCompleted_create
(
o
);
}
for
(
Review
o
:
snap
.
getProperties
().
getReviewList
())
{
}
}
private
void
restoreDocumentVersion
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
DocumentVersion
o
:
snap
.
getProperties
().
getDocumentVersionList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
}
private
void
restoreRecord
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
Record
o
:
snap
.
getProperties
().
getRecordList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
review_create
(
o
);
}
}
private
void
restoreWorkLog
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
WorkLog
o
:
snap
.
getProperties
().
getWorkLogList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
}
for
(
Record
o
:
snap
.
getProperties
().
getRecordList
())
{
}
private
void
restoreReview
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
Review
o
:
snap
.
getProperties
().
getReviewList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
review_create
(
o
);
}
for
(
Attachment
o
:
snap
.
getProperties
().
getAttachmentList
())
{
}
private
void
restoreTask
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
Task
o
:
snap
.
getProperties
().
getTaskList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
task_create
(
o
);
}
emc
.
persist
(
snap
.
getProperties
().
getWorkCompleted
(),
CheckPersistType
.
all
);
if
(
BooleanUtils
.
isNotTrue
(
snap
.
getProperties
().
getWorkCompleted
().
getMerged
()))
{
WorkDataHelper
workDataHelper
=
new
WorkDataHelper
(
emc
,
snap
.
getProperties
().
getWorkCompleted
());
workDataHelper
.
update
(
snap
.
getProperties
().
getData
());
}
emc
.
commit
();
private
void
restoreTaskCompleted
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
TaskCompleted
o
:
snap
.
getProperties
().
getTaskCompletedList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
taskCompleted_create
(
o
);
}
}
private
void
restoreReadCompleted
(
EntityManagerContainer
emc
,
Snap
snap
)
throws
Exception
{
for
(
ReadCompleted
o
:
snap
.
getProperties
().
getReadCompletedList
())
{
emc
.
persist
(
o
,
CheckPersistType
.
all
);
MessageFactory
.
readCompleted_create
(
o
);
}
}
}
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionTypeSnap.java
浏览文件 @
fbb28d43
...
...
@@ -76,6 +76,7 @@ class ActionTypeSnap extends BaseAction {
Snap
snap
=
new
Snap
(
work
);
snap
.
setProperties
(
snap
(
business
,
work
.
getJob
(),
items
,
works
,
tasks
,
taskCompleteds
,
reads
,
readCompleteds
,
reviews
,
workLogs
,
records
,
attachments
,
documentVersions
));
snap
.
setType
(
Snap
.
TYPE_SNAP
);
emc
.
beginTransaction
(
Snap
.
class
);
emc
.
persist
(
snap
,
CheckPersistType
.
all
);
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/ActionUpload.java
0 → 100644
浏览文件 @
fbb28d43
package
com.x.processplatform.service.processing.jaxrs.snap
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.entity.annotation.CheckRemoveType
;
import
com.x.base.core.project.executor.ProcessPlatformExecutorFactory
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapString
;
import
com.x.processplatform.core.entity.content.Snap
;
class
ActionUpload
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
Snap
snap
=
this
.
convertToWrapIn
(
jsonElement
,
Snap
.
class
);
check
(
snap
);
Callable
<
ActionResult
<
Wo
>>
callable
=
new
Callable
<
ActionResult
<
Wo
>>()
{
public
ActionResult
<
Wo
>
call
()
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Snap
exist
=
emc
.
find
(
snap
.
getId
(),
Snap
.
class
);
if
(
null
!=
exist
)
{
emc
.
beginTransaction
(
Snap
.
class
);
emc
.
remove
(
exist
,
CheckRemoveType
.
all
);
emc
.
commit
();
}
emc
.
beginTransaction
(
Snap
.
class
);
emc
.
persist
(
snap
,
CheckPersistType
.
all
);
emc
.
commit
();
Wo
wo
=
new
Wo
();
wo
.
setValue
(
snap
.
getId
());
result
.
setData
(
wo
);
return
result
;
}
}
};
return
ProcessPlatformExecutorFactory
.
get
(
snap
.
getJob
()).
submit
(
callable
).
get
(
300
,
TimeUnit
.
SECONDS
);
}
private
boolean
check
(
Snap
snap
)
{
if
(
StringUtils
.
isBlank
(
snap
.
getId
()))
{
return
false
;
}
if
(
StringUtils
.
isBlank
(
snap
.
getJob
()))
{
return
false
;
}
return
!((
null
==
snap
.
getProperties
().
getWorkCompleted
())
&&
snap
.
getProperties
().
getWorkList
().
isEmpty
());
}
public
static
class
Wo
extends
WrapString
{
}
}
\ No newline at end of file
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/BaseAction.java
浏览文件 @
fbb28d43
...
...
@@ -8,12 +8,14 @@ import java.util.concurrent.CompletableFuture;
import
java.util.concurrent.ExecutionException
;
import
java.util.stream.Collectors
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.BooleanUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.entity.dataitem.DataItem
;
import
com.x.base.core.entity.dataitem.DataItemConverter
;
import
com.x.base.core.entity.dataitem.ItemCategory
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
...
...
@@ -33,6 +35,7 @@ import com.x.processplatform.core.entity.content.WorkCompleted;
import
com.x.processplatform.core.entity.content.WorkLog
;
import
com.x.processplatform.service.processing.Business
;
import
com.x.processplatform.service.processing.MessageFactory
;
import
com.x.processplatform.service.processing.ThisApplication
;
import
com.x.query.core.entity.Item
;
abstract
class
BaseAction
extends
StandardJaxrsAction
{
...
...
@@ -261,6 +264,15 @@ abstract class BaseAction extends StandardJaxrsAction {
.
collect
(
Collectors
.
toList
());
snapProperties
.
setAttachmentList
(
os
);
attachments
.
addAll
(
os
);
for
(
Attachment
attachment
:
os
)
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
attachment
.
getStorage
());
if
(
null
!=
mapping
)
{
byte
[]
bytes
=
attachment
.
readContent
(
mapping
);
snapProperties
.
getAttachmentContentMap
().
put
(
attachment
.
getId
(),
Base64
.
encodeBase64URLSafeString
(
bytes
));
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
...
...
@@ -423,6 +435,11 @@ abstract class BaseAction extends StandardJaxrsAction {
try
{
business
.
entityManagerContainer
().
beginTransaction
(
Attachment
.
class
);
for
(
Attachment
o
:
attachments
)
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
o
.
getStorage
());
if
(
null
!=
mapping
)
{
o
.
deleteContent
(
mapping
);
}
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -591,6 +608,11 @@ abstract class BaseAction extends StandardJaxrsAction {
business
.
entityManagerContainer
().
beginTransaction
(
Attachment
.
class
);
for
(
Attachment
o
:
business
.
entityManagerContainer
().
listEqual
(
Attachment
.
class
,
Attachment
.
job_FIELDNAME
,
job
))
{
StorageMapping
mapping
=
ThisApplication
.
context
().
storageMappings
().
get
(
Attachment
.
class
,
o
.
getStorage
());
if
(
null
!=
mapping
)
{
o
.
deleteContent
(
mapping
);
}
business
.
entityManagerContainer
().
remove
(
o
);
}
}
catch
(
Exception
e
)
{
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/snap/SnapAction.java
浏览文件 @
fbb28d43
...
...
@@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
...
...
@@ -12,6 +13,7 @@ import javax.ws.rs.container.Suspended;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.annotation.JaxrsDescribe
;
import
com.x.base.core.project.annotation.JaxrsMethodDescribe
;
import
com.x.base.core.project.annotation.JaxrsParameterDescribe
;
...
...
@@ -138,4 +140,22 @@ public class SnapAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"导入快照"
,
action
=
ActionUpload
.
class
)
@POST
@Path
(
"upload"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
upload
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionUpload
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionUpload
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录