Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BasicAPI
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杜科
BasicAPI
Commits
524c07dd
Commit
524c07dd
authored
Feb 21, 2023
by
shyWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PDM前端改造
添加删除对象公共方法
parent
780369c0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
7 deletions
+64
-7
CommonUtil.java
src/com/yonde/common/CommonUtil.java
+64
-7
No files found.
src/com/yonde/common/CommonUtil.java
View file @
524c07dd
...
...
@@ -34,6 +34,7 @@ import wt.org.WTUser;
import
wt.part.WTPart
;
import
wt.part.WTPartMaster
;
import
wt.part.WTPartMasterIdentity
;
import
wt.pom.Transaction
;
import
wt.query.QuerySpec
;
import
wt.query.SearchCondition
;
import
wt.query.WhereExpression
;
...
...
@@ -46,10 +47,10 @@ import wt.util.WTContext;
import
wt.util.WTException
;
import
wt.util.WTProperties
;
import
wt.util.WTRuntimeException
;
import
wt.vc.
Iterated
;
import
wt.vc.
OneOffVersioned
;
import
wt.vc.
VersionControlHelper
;
import
wt.vc.
Versioned
;
import
wt.vc.
*
;
import
wt.vc.
struct.IteratedDescribeLink
;
import
wt.vc.
struct.IteratedReferenceLink
;
import
wt.vc.
struct.IteratedUsageLink
;
import
wt.vc.wip.CheckoutLink
;
import
wt.vc.wip.WorkInProgressException
;
import
wt.vc.wip.WorkInProgressHelper
;
...
...
@@ -61,9 +62,7 @@ import java.lang.reflect.Method;
import
java.rmi.RemoteException
;
import
java.text.MessageFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.TimeZone
;
import
java.util.*
;
public
class
CommonUtil
implements
RemoteAccess
{
private
static
final
Logger
log
=
LogR
.
getLogger
(
CommonUtil
.
class
.
getName
());
...
...
@@ -629,6 +628,64 @@ public class CommonUtil implements RemoteAccess {
return
result
;
}
private
static
void
deleteBizObj
(
RevisionControlled
obj
,
boolean
deleteAllVersion
)
throws
Exception
{
Transaction
tx
=
new
Transaction
();
tx
.
start
();
try
{
// 先删除与指定对象每个Iteration的关联关系: IteratedDescribeLink
List
<
Persistable
>
objList
=
new
ArrayList
<
Persistable
>();
Set
linkSet
=
new
HashSet
();
QueryResult
qrIter
;
if
(
deleteAllVersion
)
qrIter
=
VersionControlHelper
.
service
.
allIterationsOf
(
obj
.
getMaster
());
else
qrIter
=
VersionControlHelper
.
service
.
iterationsOf
(
obj
);
while
(
qrIter
.
hasMoreElements
())
{
Iterated
iterated
=
(
Iterated
)
qrIter
.
nextElement
();
objList
.
add
(
iterated
);
linkSet
.
addAll
((
PersistenceServerHelper
.
manager
.
expand
(
iterated
,
IteratedDescribeLink
.
DESCRIBES_ROLE
,
IteratedDescribeLink
.
class
,
false
)).
getObjectVectorIfc
().
getVector
());
}
// 如果只有一个版本,则Master也将被自动删除,需要准备将Master的关联删除
// IteratedUsageLink, IteratedReferenceLink
if
(
deleteAllVersion
||
VersionControlHelper
.
service
.
allVersionsOf
(
obj
).
size
()
==
1
)
{
linkSet
.
addAll
((
PersistenceServerHelper
.
manager
.
expand
(
obj
.
getMaster
(),
IteratedUsageLink
.
USED_BY_ROLE
,
IteratedUsageLink
.
class
,
false
)).
getObjectVectorIfc
().
getVector
());
linkSet
.
addAll
((
PersistenceServerHelper
.
manager
.
expand
(
obj
.
getMaster
(),
IteratedReferenceLink
.
REFERENCED_BY_ROLE
,
IteratedReferenceLink
.
class
,
false
)).
getObjectVectorIfc
().
getVector
());
}
// 删除关联Link
for
(
Iterator
it
=
linkSet
.
iterator
();
it
.
hasNext
();)
{
BinaryLink
link
=
(
BinaryLink
)
it
.
next
();
PersistenceServerHelper
.
manager
.
remove
(
link
);
}
// 删除对象本身
for
(
Iterator
it
=
objList
.
iterator
();
it
.
hasNext
();)
{
Iterated
iterated
=
(
Iterated
)
it
.
next
();
// 如果一个版本有多个小版本的话,需要将状态设置为非控制状态,才可删除
iterated
.
getIterationInfo
().
setState
(
IterationState
.
toIterationState
(
"unctrld"
));
PersistenceHelper
.
manager
.
delete
(
iterated
);
}
tx
.
commit
();
tx
=
null
;
// 删除对象本身
// removeObjectsBackground(objSet);
}
catch
(
Exception
e
)
{
if
(
tx
!=
null
)
tx
.
rollback
();
throw
e
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment