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
5c0cc697
Commit
5c0cc697
authored
Dec 23, 2022
by
hanson.yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert wtPart
parent
9e6ecfe2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
852 additions
and
36 deletions
+852
-36
IBAHelper.java
src/com/yonde/common/IBAHelper.java
+831
-0
PartUtil.java
src/com/yonde/common/PartUtil.java
+8
-17
PartService.java
src/com/yonde/part/service/PartService.java
+13
-8
DxPart.java
src/com/yonde/part/vo/DxPart.java
+0
-11
No files found.
src/com/yonde/common/IBAHelper.java
0 → 100644
View file @
5c0cc697
/* bcwti
*
* Copyright (c) 1998 Windchill Technology. All Rights Reserved.
*
* This software is the confidential and proprietary information of Windchill
* Technology. You shall not disclose such confidential information and
* shall use it only in accordance with the terms of the license agreement
* you entered into with Windchill.
*
* ecwti
*/
package
com
.
yonde
.
common
;
import
com.ptc.core.foundation.type.server.impl.SoftAttributesHelper
;
import
com.ptc.core.meta.common.AttributeIdentifier
;
import
com.ptc.core.meta.common.AttributeTypeIdentifier
;
import
com.ptc.core.meta.common.DefinitionIdentifier
;
import
com.ptc.core.meta.common.TypeInstanceIdentifier
;
import
com.ptc.core.meta.server.TypeIdentifierUtility
;
import
com.ptc.core.meta.type.common.TypeInstance
;
import
org.apache.log4j.Logger
;
import
wt.fc.*
;
import
wt.iba.definition.DefinitionLoader
;
import
wt.iba.definition.litedefinition.*
;
import
wt.iba.definition.service.IBADefinitionHelper
;
import
wt.iba.value.StringValue
;
import
wt.iba.value.*
;
import
wt.iba.value.litevalue.*
;
import
wt.iba.value.service.IBAValueDBService
;
import
wt.iba.value.service.IBAValueDBServiceInterface
;
import
wt.iba.value.service.IBAValueHelper
;
import
wt.iba.value.service.StandardIBAValueService
;
import
wt.log4j.LogR
;
import
wt.method.RemoteAccess
;
import
wt.method.RemoteMethodServer
;
import
wt.query.QuerySpec
;
import
wt.query.SearchCondition
;
import
wt.services.ManagerServiceFactory
;
import
wt.session.SessionServerHelper
;
import
wt.util.WTContext
;
import
wt.util.WTException
;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
IBAHelper
implements
Serializable
,
RemoteAccess
{
private
static
final
String
CLASSNAME
=
IBAHelper
.
class
.
getName
();
private
static
Locale
LOCALE
=
Locale
.
CHINA
;
private
static
final
Logger
log
;
static
{
try
{
log
=
LogR
.
getLogger
(
IBAHelper
.
class
.
getName
());
}
catch
(
Exception
e
)
{
throw
new
ExceptionInInitializerError
(
e
);
}
}
/**
* @param obj Object to be validated
* @return String
* @throws WTException
*/
public
static
Hashtable
getAllIBAValues
(
WTObject
obj
)
throws
WTException
,
InvocationTargetException
,
RemoteException
{
System
.
out
.
println
(
"=================getAllIBAValues======"
);
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
Hashtable
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getAllIBAValues"
,
IBAHelper
.
class
.
getName
(),
null
,
new
Class
[]{
WTObject
.
class
},
new
Object
[]{
obj
});
}
Hashtable
hashtable
=
new
Hashtable
();
if
(
obj
==
null
)
{
return
hashtable
;
}
try
{
if
(
obj
instanceof
IBAHolder
)
{
IBAHolder
ibaholder
=
(
IBAHolder
)
obj
;
DefaultAttributeContainer
dac
=
getContainer
(
ibaholder
);
if
(
dac
!=
null
)
{
AbstractValueView
avv
[]
=
null
;
avv
=
dac
.
getAttributeValues
();
System
.
out
.
println
(
"==========getAllIBAValues=======9"
);
for
(
int
j
=
0
;
j
<
avv
.
length
;
j
++)
{
System
.
out
.
println
(
"==========getAllIBAValues=======10:"
+
j
);
String
thisIBAName
=
avv
[
j
].
getDefinition
().
getName
();
String
thisIBAValue
=
IBAValueUtility
.
getLocalizedIBAValueDisplayString
(
avv
[
j
],
LOCALE
);
String
thisIBAClass
=
(
avv
[
j
].
getDefinition
()).
getAttributeDefinitionClassName
();
System
.
out
.
println
(
"==========getAllIBAValues=======11:"
+
j
);
if
(
thisIBAClass
.
equals
(
"wt.iba.definition.FloatDefinition"
))
{
float
value
=
(
float
)
((
FloatValueDefaultView
)
avv
[
j
]).
getValue
();
hashtable
.
put
(
thisIBAName
,
new
Float
(
value
));
}
else
if
(
thisIBAClass
.
equals
(
"wt.iba.definition.IntegerDefinition"
))
{
long
value
=
((
IntegerValueDefaultView
)
avv
[
j
]).
getValue
();
hashtable
.
put
(
thisIBAName
,
String
.
valueOf
(
value
));
}
else
if
(
thisIBAClass
.
equals
(
"wt.iba.definition.StringDefinition"
))
{
System
.
out
.
println
(
"==========getAllIBAValues=======12:"
+
j
);
String
value
=
((
StringValueDefaultView
)
avv
[
j
]).
getValue
();
hashtable
.
put
(
thisIBAName
,
value
);
}
}
}
}
}
catch
(
RemoteException
rexp
)
{
System
.
out
.
println
(
" ** !!!!! ** ERROR Getting IBAHelper.getAllIBAValues"
);
rexp
.
printStackTrace
();
}
return
hashtable
;
}
/**
* @param obj Object to be validated
* @return String
* @throws WTException
**/
public
static
String
getIBAStringValue
(
WTObject
obj
,
String
ibaName
)
throws
WTException
{
String
value
=
null
;
String
ibaClass
=
"wt.iba.definition.StringDefinition"
;
try
{
if
(
obj
instanceof
IBAHolder
)
{
System
.
out
.
println
(
"================================IBA1============="
);
IBAHolder
ibaholder
=
(
IBAHolder
)
obj
;
DefaultAttributeContainer
defaultattributecontainer
=
getContainer
(
ibaholder
);
if
(
defaultattributecontainer
!=
null
)
{
System
.
out
.
println
(
"================================IBA2============="
);
AbstractValueView
avv
=
getIBAValueView
(
defaultattributecontainer
,
ibaName
,
ibaClass
);
if
(
avv
!=
null
)
{
value
=
((
StringValueDefaultView
)
avv
).
getLocalizedDisplayString
();
System
.
out
.
println
(
ibaName
+
"================================IBA3============="
+
value
);
}
}
}
}
catch
(
RemoteException
rexp
)
{
rexp
.
printStackTrace
();
}
return
value
;
}
public
static
String
getStringIBAValueOfObject
(
IBAHolder
p
,
String
ibaName
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
String
method
=
"getStringIBAValueOfObject"
;
Class
[]
types
=
{
IBAHolder
.
class
,
String
.
class
};
Object
[]
vals
=
{
p
,
ibaName
};
try
{
return
(
String
)
RemoteMethodServer
.
getDefault
().
invoke
(
method
,
CLASSNAME
,
null
,
types
,
vals
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
boolean
access
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
AttributeDefDefaultView
addv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
ibaName
);
if
(
addv
==
null
)
{
return
null
;
}
long
ibaDefId
=
addv
.
getObjectID
().
getId
();
long
prjObid
=
PersistenceHelper
.
getObjectIdentifier
((
Persistable
)
p
).
getId
();
QuerySpec
qs
=
new
QuerySpec
(
StringValue
.
class
);
qs
.
appendWhere
(
new
SearchCondition
(
StringValue
.
class
,
StringValue
.
DEFINITION_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
ibaDefId
),
new
int
[]{
0
});
qs
.
appendAnd
();
qs
.
appendWhere
(
new
SearchCondition
(
StringValue
.
class
,
StringValue
.
IBAHOLDER_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
prjObid
),
new
int
[]{
0
});
qs
.
setAdvancedQueryEnabled
(
true
);
QueryResult
qr
=
PersistenceHelper
.
manager
.
find
(
qs
);
if
(
qr
.
hasMoreElements
())
{
String
value
=
""
;
while
(
qr
.
hasMoreElements
())
{
if
(
value
.
length
()
==
0
)
{
value
=
((
StringValue
)
qr
.
nextElement
()).
getValue
();
}
else
{
value
=
value
+
","
+
((
StringValue
)
qr
.
nextElement
()).
getValue
();
}
}
return
value
;
}
else
return
null
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
access
);
}
return
null
;
}
public
static
Integer
getIntegerIBAValueOfObject
(
IBAHolder
p
,
String
ibaName
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
String
method
=
"getIntegerIBAValueOfObject"
;
Class
[]
types
=
{
IBAHolder
.
class
,
String
.
class
};
Object
[]
vals
=
{
p
,
ibaName
};
try
{
return
(
Integer
)
RemoteMethodServer
.
getDefault
().
invoke
(
method
,
CLASSNAME
,
null
,
types
,
vals
);
}
catch
(
Exception
e
)
{
log
.
info
(
"getIntegerIBAValueOfObject() Exception:"
+
e
.
getMessage
());
e
.
printStackTrace
();
return
null
;
}
}
boolean
access
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
AttributeDefDefaultView
addv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
ibaName
);
if
(
addv
==
null
)
{
return
null
;
}
long
ibaDefId
=
addv
.
getObjectID
().
getId
();
long
objObid
=
PersistenceHelper
.
getObjectIdentifier
((
Persistable
)
p
).
getId
();
QuerySpec
qs
=
new
QuerySpec
(
IntegerValue
.
class
);
qs
.
appendWhere
(
new
SearchCondition
(
IntegerValue
.
class
,
IntegerValue
.
DEFINITION_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
ibaDefId
),
new
int
[]{
0
});
qs
.
appendAnd
();
qs
.
appendWhere
(
new
SearchCondition
(
IntegerValue
.
class
,
IntegerValue
.
IBAHOLDER_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
objObid
),
new
int
[]{
0
});
qs
.
setAdvancedQueryEnabled
(
true
);
QueryResult
qr
=
PersistenceHelper
.
manager
.
find
(
qs
);
if
(
qr
.
hasMoreElements
())
{
return
Integer
.
valueOf
((
int
)
((
IntegerValue
)
qr
.
nextElement
()).
getValue
());
}
else
return
null
;
}
catch
(
Exception
e
)
{
log
.
info
(
"Get IBA Value Exception."
,
e
);
e
.
printStackTrace
();
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
access
);
}
return
null
;
}
public
static
Boolean
getBooleanIBAValueOfObject
(
IBAHolder
p
,
String
ibaName
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
String
method
=
"getBooleanIBAValueOfObject"
;
Class
[]
types
=
{
IBAHolder
.
class
,
String
.
class
};
Object
[]
vals
=
{
p
,
ibaName
};
try
{
return
(
Boolean
)
RemoteMethodServer
.
getDefault
().
invoke
(
method
,
CLASSNAME
,
null
,
types
,
vals
);
}
catch
(
Exception
e
)
{
log
.
info
(
"getBooleanIBAValueOfObject() Exception:"
+
e
.
getMessage
());
e
.
printStackTrace
();
return
null
;
}
}
boolean
access
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
AttributeDefDefaultView
addv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
ibaName
);
if
(
addv
==
null
)
{
return
null
;
}
long
ibaDefId
=
addv
.
getObjectID
().
getId
();
long
objObid
=
PersistenceHelper
.
getObjectIdentifier
((
Persistable
)
p
).
getId
();
QuerySpec
qs
=
new
QuerySpec
(
BooleanValue
.
class
);
qs
.
appendWhere
(
new
SearchCondition
(
BooleanValue
.
class
,
BooleanValue
.
DEFINITION_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
ibaDefId
),
new
int
[]{
0
});
qs
.
appendAnd
();
qs
.
appendWhere
(
new
SearchCondition
(
BooleanValue
.
class
,
BooleanValue
.
IBAHOLDER_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
objObid
),
new
int
[]{
0
});
qs
.
setAdvancedQueryEnabled
(
true
);
QueryResult
qr
=
PersistenceHelper
.
manager
.
find
(
qs
);
if
(
qr
.
hasMoreElements
())
{
Object
obj
=
qr
.
nextElement
();
return
Boolean
.
valueOf
(((
BooleanValue
)
obj
).
isValue
());
}
else
return
null
;
}
catch
(
Exception
e
)
{
log
.
info
(
"Get IBA Value Exception."
,
e
);
e
.
printStackTrace
();
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
access
);
}
return
null
;
}
/**
* Get string or date IBA
*
* @param p
* @param ibaName
* @return
*/
public
static
String
getIBAValueOfObject
(
IBAHolder
p
,
String
ibaName
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
String
method
=
"getIBAValueOfObject"
;
Class
[]
types
=
{
IBAHolder
.
class
,
String
.
class
};
Object
[]
vals
=
{
p
,
ibaName
};
try
{
return
(
String
)
RemoteMethodServer
.
getDefault
().
invoke
(
method
,
CLASSNAME
,
null
,
types
,
vals
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
boolean
access
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
AbstractAttributeDefinizerView
addv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
ibaName
);
if
(
addv
==
null
)
{
return
null
;
}
if
(
addv
instanceof
StringDefView
)
{
return
getStringIBAValueOfObject
(
p
,
ibaName
);
}
else
if
(
addv
instanceof
TimestampDefView
)
{
long
ibaDefId
=
addv
.
getObjectID
().
getId
();
long
prjObid
=
PersistenceHelper
.
getObjectIdentifier
((
Persistable
)
p
).
getId
();
QuerySpec
qs
=
new
QuerySpec
(
TimestampValue
.
class
);
qs
.
appendWhere
(
new
SearchCondition
(
TimestampValue
.
class
,
TimestampValue
.
DEFINITION_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
ibaDefId
),
new
int
[]{
0
});
qs
.
appendAnd
();
qs
.
appendWhere
(
new
SearchCondition
(
TimestampValue
.
class
,
TimestampValue
.
IBAHOLDER_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
,
SearchCondition
.
EQUAL
,
prjObid
),
new
int
[]{
0
});
qs
.
setAdvancedQueryEnabled
(
true
);
QueryResult
qr
=
PersistenceHelper
.
manager
.
find
(
qs
);
if
(
qr
.
hasMoreElements
())
{
TimestampValue
timeValue
=
(
TimestampValue
)
qr
.
nextElement
();
Timestamp
time
=
timeValue
.
getValue
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
value
=
sdf
.
format
(
new
Timestamp
(
time
.
getTime
()
+
8
*
60
*
60
*
1000
));
return
value
;
}
else
return
null
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
access
);
}
return
null
;
}
/**
* Set IBA values
*
* @param ibaholder
* @param ibaValues
* @return
*/
public
static
IBAHolder
setIBAValues
(
IBAHolder
ibaholder
,
Properties
ibaValues
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
String
method
=
"setIBAValues"
;
Class
[]
types
=
{
IBAHolder
.
class
,
Properties
.
class
};
Object
[]
vals
=
{
ibaholder
,
ibaValues
};
IBAHolder
rtn
=
ibaholder
;
try
{
rtn
=
(
IBAHolder
)
RemoteMethodServer
.
getDefault
().
invoke
(
method
,
CLASSNAME
,
null
,
types
,
vals
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
rtn
;
}
boolean
checkFlag
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
for
(
Enumeration
en
=
ibaValues
.
keys
();
en
.
hasMoreElements
();
)
{
String
attrName
=
(
String
)
en
.
nextElement
();
String
attrValue
=
(
String
)
ibaValues
.
get
(
attrName
);
if
(
attrValue
==
null
)
continue
;
AbstractAttributeDefinizerView
aadv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
attrName
);
if
(
aadv
==
null
)
{
log
.
info
(
"Not found IBA="
+
attrName
+
"] Definition."
);
}
else
{
Object
obj
=
null
;
if
(
aadv
instanceof
StringDefView
)
{
obj
=
new
StringValueDefaultView
((
StringDefView
)
aadv
,
String
.
valueOf
(
attrValue
));
}
else
if
(
aadv
instanceof
BooleanDefView
)
{
boolean
flag
=
Boolean
.
valueOf
(
attrValue
).
booleanValue
();
obj
=
new
BooleanValueDefaultView
((
BooleanDefView
)
aadv
,
flag
);
}
else
if
(
aadv
instanceof
IntegerDefView
)
{
long
l
=
Long
.
valueOf
(
attrValue
).
longValue
();
obj
=
new
IntegerValueDefaultView
((
IntegerDefView
)
aadv
,
l
);
}
else
if
(
aadv
instanceof
FloatDefView
)
{
/*int i = attrValue.lastIndexOf(",");
String s4 = i <= 0 ? "2" : attrValue.substring(i + 1);
String s8 = i <= 0 ? attrValue : attrValue.substring(0, i);
if (i<=0) {
int j=s8.lastIndexOf(".");
if (j<=0)
s4="2";
else
s4=String.valueOf(s8.substring(j).length());
}
obj = new FloatValueDefaultView((FloatDefView)aadv, Double.valueOf(s8).doubleValue(), Integer.valueOf(s4).intValue());*/
//���и��������ݵ��������⣬���е���20190823
obj
=
new
FloatValueDefaultView
((
FloatDefView
)
aadv
,
Double
.
valueOf
(
attrValue
).
doubleValue
(),
Integer
.
valueOf
(
0
).
intValue
());
}
else
if
(
aadv
instanceof
TimestampDefView
)
{
try
{
java
.
util
.
Date
dd
=
SoftAttributesHelper
.
parseDate
(
attrValue
,
null
,
null
);
obj
=
new
TimestampValueDefaultView
((
TimestampDefView
)
aadv
,
new
Timestamp
(
dd
.
getTime
()));
}
catch
(
ParseException
parseexception
)
{
parseexception
.
printStackTrace
();
}
}
if
(
obj
!=
null
)
{
ibaholder
=
IBAValueHelper
.
service
.
refreshAttributeContainer
(
ibaholder
,
"CSM"
,
null
,
null
);
DefaultAttributeContainer
defaultattributecontainer
=
(
DefaultAttributeContainer
)
ibaholder
.
getAttributeContainer
();
if
(
defaultattributecontainer
==
null
)
{
defaultattributecontainer
=
new
DefaultAttributeContainer
();
defaultattributecontainer
.
addAttributeValue
(((
AbstractValueView
)
(
obj
)));
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
}
else
{
AbstractValueView
oldavv
[]
=
defaultattributecontainer
.
getAttributeValues
((
AttributeDefDefaultView
)
aadv
);
for
(
int
k
=
0
;
k
<
oldavv
.
length
;
k
++)
defaultattributecontainer
.
deleteAttributeValue
(
oldavv
[
k
]);
defaultattributecontainer
.
addAttributeValue
((
AbstractValueView
)
(
obj
));
IBAValueDBServiceInterface
dbService
=
(
IBAValueDBServiceInterface
)
ManagerServiceFactory
.
getDefault
().
getManager
(
IBAValueDBService
.
class
);
defaultattributecontainer
=
(
DefaultAttributeContainer
)
dbService
.
updateAttributeContainer
(
ibaholder
,
defaultattributecontainer
.
getConstraintParameter
(),
null
,
null
);
}
ibaholder
=
(
IBAHolder
)
IBAValueHelper
.
service
.
refreshAttributeContainer
(
ibaholder
,
"CSM"
,
null
,
null
);
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
checkFlag
);
}
return
ibaholder
;
}
public
static
IBAHolder
setObjectIBAValueNoCheckout
(
IBAHolder
ibaholder
,
String
attrName
,
String
attrValue
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
String
method
=
"setObjectIBAValueNoCheckout"
;
Class
[]
types
=
{
IBAHolder
.
class
,
String
.
class
,
String
.
class
};
Object
[]
vals
=
{
ibaholder
,
attrName
,
attrValue
};
IBAHolder
rtn
=
ibaholder
;
try
{
rtn
=
(
IBAHolder
)
RemoteMethodServer
.
getDefault
().
invoke
(
method
,
CLASSNAME
,
null
,
types
,
vals
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
rtn
;
}
boolean
checkFlag
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
AbstractAttributeDefinizerView
aadv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
attrName
);
if
(
aadv
==
null
)
{
// Debug.I("Not found IBA="+attrName+"] Definition.");
}
else
{
Object
obj
=
null
;
if
(
aadv
instanceof
StringDefView
)
{
obj
=
new
StringValueDefaultView
((
StringDefView
)
aadv
,
String
.
valueOf
(
attrValue
));
}
else
if
(
aadv
instanceof
BooleanDefView
)
{
boolean
flag
=
Boolean
.
valueOf
(
attrValue
).
booleanValue
();
obj
=
new
BooleanValueDefaultView
((
BooleanDefView
)
aadv
,
flag
);
}
else
if
(
aadv
instanceof
IntegerDefView
)
{
long
l
=
Long
.
valueOf
(
attrValue
).
longValue
();
obj
=
new
IntegerValueDefaultView
((
IntegerDefView
)
aadv
,
l
);
}
else
if
(
aadv
instanceof
FloatDefView
)
{
int
i
=
attrValue
.
lastIndexOf
(
","
);
String
s4
=
i
<=
0
?
"2"
:
attrValue
.
substring
(
i
+
1
);
String
s8
=
i
<=
0
?
attrValue
:
attrValue
.
substring
(
0
,
i
);
if
(
i
<=
0
)
{
int
j
=
s8
.
lastIndexOf
(
"."
);
if
(
j
<=
0
)
s4
=
"2"
;
else
s4
=
String
.
valueOf
(
s8
.
substring
(
j
).
length
());
}
obj
=
new
FloatValueDefaultView
((
FloatDefView
)
aadv
,
Double
.
valueOf
(
s8
).
doubleValue
(),
Integer
.
valueOf
(
s4
).
intValue
());
}
else
if
(
aadv
instanceof
TimestampDefView
)
{
try
{
//java.util.Date dd=SoftAttributesHelper.parseDate(attrValue, Locale.SIMPLIFIED_CHINESE, TimeZone.getTimeZone("GMT+8:00"));
java
.
util
.
Date
dd
=
SoftAttributesHelper
.
parseDate
(
attrValue
,
null
,
null
);
obj
=
new
TimestampValueDefaultView
((
TimestampDefView
)
aadv
,
new
Timestamp
(
dd
.
getTime
()));
}
catch
(
ParseException
parseexception
)
{
parseexception
.
printStackTrace
();
}
}
else
if
(
aadv
instanceof
UnitDefView
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
char
c
:
attrValue
.
toCharArray
())
{
if
(
Character
.
isDigit
(
c
)
||
c
==
'.'
)
{
sb
.
append
(
c
);
}
else
{
break
;
}
}
obj
=
new
UnitValueDefaultView
((
UnitDefView
)
aadv
,
Double
.
parseDouble
(
sb
.
toString
()),
-
1
);
}
if
(
obj
!=
null
)
{
ibaholder
=
IBAValueHelper
.
service
.
refreshAttributeContainer
(
ibaholder
,
"CSM"
,
null
,
null
);
DefaultAttributeContainer
defaultattributecontainer
=
(
DefaultAttributeContainer
)
ibaholder
.
getAttributeContainer
();
if
(
defaultattributecontainer
==
null
)
{
defaultattributecontainer
=
new
DefaultAttributeContainer
();
defaultattributecontainer
.
addAttributeValue
(((
AbstractValueView
)
(
obj
)));
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
}
else
{
AbstractValueView
oldavv
[]
=
defaultattributecontainer
.
getAttributeValues
((
AttributeDefDefaultView
)
aadv
);
for
(
int
k
=
0
;
k
<
oldavv
.
length
;
k
++)
defaultattributecontainer
.
deleteAttributeValue
(
oldavv
[
k
]);
defaultattributecontainer
.
addAttributeValue
((
AbstractValueView
)
(
obj
));
IBAValueDBServiceInterface
dbService
=
(
IBAValueDBServiceInterface
)
ManagerServiceFactory
.
getDefault
().
getManager
(
IBAValueDBService
.
class
);
defaultattributecontainer
=
(
DefaultAttributeContainer
)
dbService
.
updateAttributeContainer
(
ibaholder
,
defaultattributecontainer
.
getConstraintParameter
(),
null
,
null
);
}
ibaholder
=
(
IBAHolder
)
IBAValueHelper
.
service
.
refreshAttributeContainer
(
ibaholder
,
"CSM"
,
null
,
null
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
checkFlag
);
}
return
ibaholder
;
}
public
static
String
setIBAStringValue
(
WTObject
obj
,
String
ibaName
,
String
newvalue
)
throws
WTException
{
String
value
=
null
;
String
ibaClass
=
"wt.iba.definition.StringDefinition"
;
try
{
if
(
obj
instanceof
IBAHolder
)
{
IBAHolder
ibaholder
=
(
IBAHolder
)
obj
;
DefaultAttributeContainer
defaultattributecontainer
=
getContainer
(
ibaholder
);
if
(
defaultattributecontainer
!=
null
)
{
StringValueDefaultView
avv
=
(
StringValueDefaultView
)
getIBAValueView
(
defaultattributecontainer
,
ibaName
,
ibaClass
);
if
(
avv
!=
null
)
{
avv
.
setValue
(
newvalue
);
defaultattributecontainer
.
updateAttributeValue
(
avv
);
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
wt
.
iba
.
value
.
service
.
LoadValue
.
applySoftAttributes
(
ibaholder
);
}
else
{
AbstractAttributeDefinizerView
aadv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
ibaName
);
avv
=
new
StringValueDefaultView
((
StringDefView
)
aadv
,
String
.
valueOf
(
newvalue
));
defaultattributecontainer
.
addAttributeValue
(
avv
);
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
wt
.
iba
.
value
.
service
.
LoadValue
.
applySoftAttributes
(
ibaholder
);
}
}
}
}
catch
(
Exception
rexp
)
{
rexp
.
printStackTrace
();
}
return
value
;
}
public
static
String
setIBAStringValue2
(
IBAHolder
obj
,
String
ibaName
,
String
newvalue
)
throws
WTException
{
String
value
=
null
;
String
ibaClass
=
"wt.iba.definition.StringDefinition"
;
try
{
if
(
obj
instanceof
IBAHolder
)
{
IBAHolder
ibaholder
=
(
IBAHolder
)
obj
;
DefaultAttributeContainer
defaultattributecontainer
=
getContainer
(
ibaholder
);
if
(
defaultattributecontainer
!=
null
)
{
StringValueDefaultView
avv
=
(
StringValueDefaultView
)
getIBAValueView
(
defaultattributecontainer
,
ibaName
,
ibaClass
);
if
(
avv
!=
null
)
{
avv
.
setValue
(
newvalue
);
defaultattributecontainer
.
updateAttributeValue
(
avv
);
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
wt
.
iba
.
value
.
service
.
LoadValue
.
applySoftAttributes
(
ibaholder
);
}
else
{
AbstractAttributeDefinizerView
aadv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
ibaName
);
avv
=
new
StringValueDefaultView
((
StringDefView
)
aadv
,
String
.
valueOf
(
newvalue
));
defaultattributecontainer
.
addAttributeValue
(
avv
);
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
wt
.
iba
.
value
.
service
.
LoadValue
.
applySoftAttributes
(
ibaholder
);
}
}
}
}
catch
(
Exception
rexp
)
{
rexp
.
printStackTrace
();
}
return
value
;
}
public
static
String
setIBAStringValue
(
WTObject
obj
,
String
ibaName
,
String
path
,
String
newvalue
)
throws
WTException
{
String
value
=
null
;
String
ibaClass
=
"wt.iba.definition.StringDefinition"
;
try
{
if
(
obj
instanceof
IBAHolder
)
{
IBAHolder
ibaholder
=
(
IBAHolder
)
obj
;
DefaultAttributeContainer
defaultattributecontainer
=
getContainer
(
ibaholder
);
if
(
defaultattributecontainer
!=
null
)
{
StringValueDefaultView
avv
=
(
StringValueDefaultView
)
getIBAValueView
(
defaultattributecontainer
,
ibaName
,
ibaClass
);
if
(
avv
!=
null
)
{
avv
.
setValue
(
newvalue
);
defaultattributecontainer
.
updateAttributeValue
(
avv
);
}
else
{
StringDefView
adv
=
getStringDefViewByPath
(
path
);
avv
=
new
StringValueDefaultView
(
adv
);
avv
.
setValue
(
newvalue
);
defaultattributecontainer
.
addAttributeValue
(
avv
);
}
ibaholder
.
setAttributeContainer
(
defaultattributecontainer
);
wt
.
iba
.
value
.
service
.
LoadValue
.
applySoftAttributes
(
ibaholder
);
}
}
}
catch
(
Exception
rexp
)
{
rexp
.
printStackTrace
();
}
return
value
;
}
public
static
void
copySingleValueAttrs
(
IBAHolder
src
,
IBAHolder
dest
)
throws
RemoteException
,
WTException
,
InvocationTargetException
{
DefaultAttributeContainer
srccont
=
getContainer
(
src
);
DefaultAttributeContainer
destcont
=
getContainer
(
dest
);
AbstractValueView
[]
srcvals
=
srccont
.
getAttributeValues
();
for
(
AbstractValueView
srcval
:
srcvals
)
{
AttributeDefDefaultView
srcdef
=
srcval
.
getDefinition
();
destcont
.
deleteAttributeValues
(
srcdef
);
destcont
.
addAttributeValue
(
srcval
);
}
dest
.
setAttributeContainer
(
destcont
);
IBAValueDBServiceInterface
dbService
=
(
IBAValueDBServiceInterface
)
ManagerServiceFactory
.
getDefault
().
getManager
(
IBAValueDBService
.
class
);
destcont
=
(
DefaultAttributeContainer
)
dbService
.
updateAttributeContainer
(
dest
,
destcont
.
getConstraintParameter
(),
null
,
null
);
}
public
static
DefaultAttributeContainer
getContainer
(
IBAHolder
ibaholder
)
throws
WTException
,
RemoteException
{
ibaholder
=
IBAValueHelper
.
service
.
refreshAttributeContainerWithoutConstraints
(
ibaholder
);
DefaultAttributeContainer
defaultattributecontainer
=
(
DefaultAttributeContainer
)
ibaholder
.
getAttributeContainer
();
return
defaultattributecontainer
;
}
public
static
AbstractValueView
getIBAValueView
(
DefaultAttributeContainer
dac
,
String
ibaName
,
String
ibaClass
)
throws
WTException
{
AbstractValueView
aabstractvalueview
[]
=
null
;
AbstractValueView
avv
=
null
;
aabstractvalueview
=
dac
.
getAttributeValues
();
for
(
int
j
=
0
;
j
<
aabstractvalueview
.
length
;
j
++)
{
String
thisIBAName
=
aabstractvalueview
[
j
].
getDefinition
().
getName
();
String
thisIBAValue
=
IBAValueUtility
.
getLocalizedIBAValueDisplayString
(
aabstractvalueview
[
j
],
LOCALE
);
String
thisIBAClass
=
(
aabstractvalueview
[
j
].
getDefinition
()).
getAttributeDefinitionClassName
();
if
(
thisIBAName
.
equals
(
ibaName
)
&&
thisIBAClass
.
equals
(
ibaClass
))
{
avv
=
aabstractvalueview
[
j
];
break
;
}
}
return
avv
;
}
public
static
StringDefView
getStringDefViewByPath
(
String
path
)
throws
Exception
{
StringTokenizer
stringtokenizer
=
new
StringTokenizer
(
path
,
"/"
);
String
node1
,
node2
,
ibaName
;
node1
=
stringtokenizer
.
nextToken
();
node2
=
stringtokenizer
.
nextToken
();
ibaName
=
stringtokenizer
.
nextToken
();
AttributeOrgNodeView
nodeview1
=
getAttributeOrganizer
(
node1
);
AbstractAttributeDefinizerNodeView
nodeview2
=
getAttributeChildren
(
nodeview1
,
node2
);
AbstractAttributeDefinizerNodeView
ibaDefNode
=
getAttributeChildren
(
nodeview2
,
ibaName
);
AttributeDefDefaultView
adv
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultView
((
AttributeDefNodeView
)
ibaDefNode
);
if
(
adv
instanceof
StringDefView
)
return
(
StringDefView
)
adv
;
else
return
null
;
}
private
static
AttributeOrgNodeView
getAttributeOrganizer
(
String
s
)
{
int
i
;
AttributeOrgNodeView
aattributeorgnodeview
[]
=
null
;
try
{
aattributeorgnodeview
=
IBADefinitionHelper
.
service
.
getAttributeOrganizerRoots
();
for
(
i
=
0
;
i
<
aattributeorgnodeview
.
length
;
i
++)
{
if
(
aattributeorgnodeview
[
i
]
==
null
)
continue
;
if
(
aattributeorgnodeview
[
i
].
getName
().
equalsIgnoreCase
(
s
))
return
aattributeorgnodeview
[
i
];
}
}
catch
(
RemoteException
remoteexception
)
{
remoteexception
.
printStackTrace
();
}
catch
(
WTException
wte
)
{
wte
.
printStackTrace
();
}
return
null
;
}
private
static
AbstractAttributeDefinizerNodeView
getAttributeChildren
(
AbstractAttributeDefinizerNodeView
ibaDefNode
,
String
s
)
{
int
i
;
AbstractAttributeDefinizerNodeView
aattributeorgnodeview
[]
=
null
;
try
{
aattributeorgnodeview
=
IBADefinitionHelper
.
service
.
getAttributeChildren
(
ibaDefNode
);
for
(
i
=
0
;
i
<
aattributeorgnodeview
.
length
;
i
++)
{
if
(
aattributeorgnodeview
[
i
]
==
null
)
continue
;
if
(
aattributeorgnodeview
[
i
].
getName
().
equalsIgnoreCase
(
s
))
return
aattributeorgnodeview
[
i
];
}
}
catch
(
RemoteException
remoteexception
)
{
remoteexception
.
printStackTrace
();
}
catch
(
WTException
wte
)
{
wte
.
printStackTrace
();
}
return
null
;
}
private
static
AttributeDefDefaultView
getDefaultViewObject
(
Object
obj
)
{
AttributeDefDefaultView
attributedefdefaultview
=
null
;
try
{
if
(
obj
instanceof
AttributeDefNodeView
)
attributedefdefaultview
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultView
((
AttributeDefNodeView
)
obj
);
}
catch
(
RemoteException
remoteexception
)
{
remoteexception
.
printStackTrace
();
}
catch
(
WTException
wte
)
{
wte
.
printStackTrace
();
}
return
attributedefdefaultview
;
}
/**
* ����OID��ȡ����IBA�����嵥
*
* @param oid
* @return
*/
public
static
List
getIBAAttNames
(
String
oid
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
try
{
return
(
List
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getIBAAttNames"
,
IBAHelper
.
class
.
getName
(),
null
,
new
Class
[]{
String
.
class
},
new
Object
[]{
oid
});
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
return
new
ArrayList
();
}
else
{
List
list
=
new
ArrayList
();
try
{
Locale
locale
=
WTContext
.
getContext
().
getLocale
();
ReferenceFactory
rf
=
new
ReferenceFactory
();
Object
obj
=
rf
.
getReference
(
oid
).
getObject
();
TypeInstanceIdentifier
tii
=
TypeIdentifierUtility
.
getTypeInstanceIdentifier
(
obj
);
TypeInstance
typeInstance
=
SoftAttributesHelper
.
getSoftSchemaTypeInstance
(
tii
,
null
,
locale
);
AttributeIdentifier
[]
ais
=
typeInstance
.
getAttributeIdentifiers
();
for
(
int
i
=
0
;
ais
!=
null
&&
i
<
ais
.
length
;
i
++)
{
DefinitionIdentifier
di
=
ais
[
i
].
getDefinitionIdentifier
();
AttributeTypeIdentifier
ati
=
(
AttributeTypeIdentifier
)
di
;
String
ibaName
=
ati
.
getAttributeName
();
list
.
add
(
ibaName
);
}
}
catch
(
WTException
e
)
{
e
.
printStackTrace
();
}
Collections
.
sort
(
list
);
return
list
;
}
}
public
static
void
setIBAStringValues
(
WTObject
obj
,
String
ibaName
,
String
[]
newValue
)
throws
WTException
{
String
oneNewValue
=
""
;
try
{
if
(
obj
instanceof
IBAHolder
)
{
for
(
int
i
=
0
;
i
<
newValue
.
length
;
i
++)
{
oneNewValue
=
newValue
[
i
];
IBAHolder
ibaHolder
=
(
IBAHolder
)
obj
;
DefaultAttributeContainer
defaultattributecontainer
=
getContainer
(
ibaHolder
);
if
(
defaultattributecontainer
==
null
)
{
defaultattributecontainer
=
new
DefaultAttributeContainer
();
ibaHolder
.
setAttributeContainer
(
defaultattributecontainer
);
}
AttributeDefDefaultView
attributedefdefaultview
=
getAttributeDefinition
(
ibaName
,
false
);
StringValueDefaultView
abstractvaluedefaultview1
=
new
StringValueDefaultView
(
(
StringDefView
)
attributedefdefaultview
,
oneNewValue
);
defaultattributecontainer
.
addAttributeValue
(
abstractvaluedefaultview1
);
ibaHolder
.
setAttributeContainer
(
defaultattributecontainer
);
StandardIBAValueService
.
theIBAValueDBService
.
updateAttributeContainer
(
ibaHolder
,
null
,
null
,
null
);
ibaHolder
=
IBAValueHelper
.
service
.
refreshAttributeContainer
(
ibaHolder
,
"CSM"
,
null
,
null
);
// wt.iba.value.service.LoadValue.applySoftAttributes(
// ibaHolder);
}
}
System
.
out
.
println
(
"ENTER..."
+
ibaName
+
"..."
+
newValue
.
toString
());
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
}
public
static
AttributeDefDefaultView
getAttributeDefinition
(
String
s
,
boolean
flag
)
{
AttributeDefDefaultView
attributedefdefaultview
=
null
;
try
{
attributedefdefaultview
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultViewByPath
(
s
);
if
(
attributedefdefaultview
==
null
)
{
AbstractAttributeDefinizerView
abstractattributedefinizerview
=
DefinitionLoader
.
getAttributeDefinition
(
s
);
if
(
abstractattributedefinizerview
!=
null
)
attributedefdefaultview
=
IBADefinitionHelper
.
service
.
getAttributeDefDefaultView
((
AttributeDefNodeView
)
abstractattributedefinizerview
);
}
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
attributedefdefaultview
;
}
}
src/com/yonde/common/PartUtil.java
View file @
5c0cc697
...
@@ -30,6 +30,7 @@ import java.lang.reflect.InvocationTargetException;
...
@@ -30,6 +30,7 @@ import java.lang.reflect.InvocationTargetException;
import
java.rmi.RemoteException
;
import
java.rmi.RemoteException
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
public
class
PartUtil
implements
RemoteAccess
{
public
class
PartUtil
implements
RemoteAccess
{
private
static
Logger
logger
=
LogR
.
getLogger
(
PartUtil
.
class
.
getName
());
private
static
Logger
logger
=
LogR
.
getLogger
(
PartUtil
.
class
.
getName
());
...
@@ -70,20 +71,12 @@ public class PartUtil implements RemoteAccess {
...
@@ -70,20 +71,12 @@ public class PartUtil implements RemoteAccess {
if
(
queryResult
.
hasMoreElements
())
{
if
(
queryResult
.
hasMoreElements
())
{
part
=
(
WTPart
)
queryResult
.
nextElement
();
part
=
(
WTPart
)
queryResult
.
nextElement
();
}
}
if
(
part
!=
null
){
System
.
out
.
println
(
"--------Part info-----"
);
System
.
out
.
println
(
"----partNumber-----"
+
part
.
getNumber
());
System
.
out
.
println
(
"----creatorName-----"
+
part
.
getCreatorName
());
System
.
out
.
println
(
"----------------------"
);
}
}
finally
{
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
enforce
);
SessionServerHelper
.
manager
.
setAccessEnforced
(
enforce
);
}
}
}
}
}
catch
(
RemoteException
e
)
{
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -91,7 +84,6 @@ public class PartUtil implements RemoteAccess {
...
@@ -91,7 +84,6 @@ public class PartUtil implements RemoteAccess {
}
}
public
static
WTPart
createPart
(
String
number
,
String
name
,
HashMap
attributes
,
WTContainerRef
containerRef
)
{
public
static
WTPart
createPart
(
String
number
,
String
name
,
HashMap
attributes
,
WTContainerRef
containerRef
)
{
try
{
try
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
...
@@ -314,8 +306,7 @@ public class PartUtil implements RemoteAccess {
...
@@ -314,8 +306,7 @@ public class PartUtil implements RemoteAccess {
return
(
TypeIdentifier
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getWTObjectSubType"
,
PartUtil
.
class
.
getName
(),
null
,
new
Class
[]{
WTObject
.
class
},
new
Object
[]{
obj
});
return
(
TypeIdentifier
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getWTObjectSubType"
,
PartUtil
.
class
.
getName
(),
null
,
new
Class
[]{
WTObject
.
class
},
new
Object
[]{
obj
});
}
else
{
}
else
{
// wt.doc.WTDocument|org.saacc.MEETINGSUGGESTION
// wt.doc.WTDocument|org.saacc.MEETINGSUGGESTION
TypeIdentifier
typeIdentifier
=
TypedUtility
.
getTypeIdentifier
(
obj
);
return
TypedUtility
.
getTypeIdentifier
(
obj
);
return
typeIdentifier
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -323,10 +314,10 @@ public class PartUtil implements RemoteAccess {
...
@@ -323,10 +314,10 @@ public class PartUtil implements RemoteAccess {
return
null
;
return
null
;
}
}
public
static
void
main
(
String
[]
args
)
throws
WTException
,
InvocationTargetException
,
RemoteException
{
public
static
void
main
(
String
[]
args
)
throws
InvocationTargetException
,
RemoteException
{
WTPart
part
=
getPartByNumberAndView
(
args
[
0
],
args
[
1
],
false
);
if
(!
RemoteMethodServer
.
ServerFlag
)
{
System
.
out
.
println
(
"part number====>"
+
part
.
getNumber
());
RemoteMethodServer
.
getDefault
().
invoke
(
"getLatestPartByNumber"
,
PartUtil
.
class
.
getName
(),
null
,
new
Class
[]{
String
.
class
},
new
Object
[]{
args
[
0
]}
);
Hashtable
hashtable
=
IBAHelper
.
getAllIBAValues
(
part
);
}
System
.
out
.
println
(
"hashtable====>"
+
hashtable
);
}
}
}
}
src/com/yonde/part/service/PartService.java
View file @
5c0cc697
package
com
.
yonde
.
part
.
service
;
package
com
.
yonde
.
part
.
service
;
import
com.yonde.common.DateTimeUtil
;
import
com.yonde.common.DateTimeUtil
;
import
com.yonde.common.IBAHelper
;
import
com.yonde.common.PartUtil
;
import
com.yonde.common.PartUtil
;
import
com.yonde.part.vo.DxPart
;
import
com.yonde.part.vo.DxPart
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -13,16 +14,22 @@ import wt.type.ClientTypedUtility;
...
@@ -13,16 +14,22 @@ import wt.type.ClientTypedUtility;
import
wt.util.WTException
;
import
wt.util.WTException
;
import
wt.vc.wip.WorkInProgressHelper
;
import
wt.vc.wip.WorkInProgressHelper
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
import
java.rmi.RemoteException
;
import
java.util.Hashtable
;
import
java.util.Locale
;
import
java.util.Locale
;
@Service
@Service
public
class
PartService
{
public
class
PartService
{
public
static
DxPart
getPartByNumber
(
String
number
,
String
view
)
throws
WTException
,
RemoteException
{
public
static
DxPart
getPartByNumber
(
String
number
,
String
view
)
throws
WTException
,
RemoteException
,
InvocationTargetException
{
System
.
out
.
println
(
"-----getPartByNumber----"
);
boolean
accessControlled
=
false
;
boolean
accessControlled
=
false
;
DxPart
dxPart
=
new
DxPart
();
DxPart
dxPart
=
new
DxPart
();
WTPart
wtPart
=
PartUtil
.
getPartByNumberAndView
(
number
,
view
,
accessControlled
);
WTPart
wtPart
=
PartUtil
.
getPartByNumberAndView
(
number
,
view
,
accessControlled
);
System
.
out
.
println
(
"-----getPartByNumber----a"
);
Hashtable
hashtable
=
IBAHelper
.
getAllIBAValues
(
wtPart
);
System
.
out
.
println
(
"-----getPartByNumber----b"
);
if
(
wtPart
!=
null
)
{
if
(
wtPart
!=
null
)
{
WTUser
creat
=
((
WTUser
)
wtPart
.
getCreator
().
getObject
());
WTUser
creat
=
((
WTUser
)
wtPart
.
getCreator
().
getObject
());
dxPart
.
setCreator
(
String
.
format
(
"%s(%s)"
,
creat
.
getFullName
(),
creat
.
getName
()));
dxPart
.
setCreator
(
String
.
format
(
"%s(%s)"
,
creat
.
getFullName
(),
creat
.
getName
()));
...
@@ -40,10 +47,10 @@ public class PartService {
...
@@ -40,10 +47,10 @@ public class PartService {
System
.
out
.
println
(
"-----getPartByNumber----5"
);
System
.
out
.
println
(
"-----getPartByNumber----5"
);
dxPart
.
setState
(
wtPart
.
getState
().
getState
().
getDisplay
(
Locale
.
SIMPLIFIED_CHINESE
));
dxPart
.
setState
(
wtPart
.
getState
().
getState
().
getDisplay
(
Locale
.
SIMPLIFIED_CHINESE
));
String
wtType
=
ClientTypedUtility
.
getExternalTypeIdentifier
(
wtPart
);
String
wtType
=
ClientTypedUtility
.
getExternalTypeIdentifier
(
wtPart
);
wtType
=
wtType
.
substring
(
wtType
.
lastIndexOf
(
"."
)+
1
,
wtType
.
length
()
);
wtType
=
wtType
.
substring
(
wtType
.
lastIndexOf
(
"|"
)
+
1
);
System
.
out
.
println
(
"--------wtType------"
+
wtType
);
System
.
out
.
println
(
"--------wtType------"
+
wtType
);
// dxPart.setSubTypeName(PartUtil.getWTObjectSubType(wtPart).getTypename());
// dxPart.setSubTypeName(PartUtil.getWTObjectSubType(wtPart).getTypename());
dxPart
.
setDefaultUnit
(
wtPart
.
getDefaultUnit
().
getDisplay
(
Locale
.
SIMPLIFIED_CHINESE
));
dxPart
.
setDefaultUnit
(
wtPart
.
getDefaultUnit
().
getDisplay
(
Locale
.
SIMPLIFIED_CHINESE
));
dxPart
.
setMasterId
(
new
ReferenceFactory
().
getReferenceString
(
ObjectReference
.
newObjectReference
((
wtPart
.
getMaster
().
getPersistInfo
().
getObjectIdentifier
()))));
dxPart
.
setMasterId
(
new
ReferenceFactory
().
getReferenceString
(
ObjectReference
.
newObjectReference
((
wtPart
.
getMaster
().
getPersistInfo
().
getObjectIdentifier
()))));
//dxPart.setSubTypeDisplayName(wtPart.getDisplayIdentity().getDisplayType().getLocalizedMessage(Locale.CHINESE));
//dxPart.setSubTypeDisplayName(wtPart.getDisplayIdentity().getDisplayType().getLocalizedMessage(Locale.CHINESE));
...
@@ -70,9 +77,7 @@ public class PartService {
...
@@ -70,9 +77,7 @@ public class PartService {
}
}
dxPart
.
setVersion
(
wtPart
.
getVersionIdentifier
().
getValue
());
dxPart
.
setVersion
(
wtPart
.
getVersionIdentifier
().
getValue
());
dxPart
.
setIteration
(
wtPart
.
getIterationIdentifier
().
getValue
());
dxPart
.
setIteration
(
wtPart
.
getIterationIdentifier
().
getValue
());
//dxPart.setSubTypeDisplayName(TypedUtility.getTypeIdentifier(wtPart).getTypename());
dxPart
.
setDynamicAttrs
(
hashtable
);
}
}
return
dxPart
;
return
dxPart
;
}
}
...
...
src/com/yonde/part/vo/DxPart.java
View file @
5c0cc697
...
@@ -36,8 +36,6 @@ public class DxPart implements Serializable {
...
@@ -36,8 +36,6 @@ public class DxPart implements Serializable {
//todo dynamicAttrs subTypeDisplayName 无法获取
//todo dynamicAttrs subTypeDisplayName 无法获取
private
Map
<
String
,
Object
>
dynamicAttrs
;
private
Map
<
String
,
Object
>
dynamicAttrs
;
private
String
subTypeDisplayName
;
public
DxPart
()
{
public
DxPart
()
{
}
}
...
@@ -90,14 +88,6 @@ public class DxPart implements Serializable {
...
@@ -90,14 +88,6 @@ public class DxPart implements Serializable {
this
.
subTypeName
=
subTypeName
;
this
.
subTypeName
=
subTypeName
;
}
}
public
String
getSubTypeDisplayName
()
{
return
subTypeDisplayName
;
}
public
void
setSubTypeDisplayName
(
String
subTypeDisplayName
)
{
this
.
subTypeDisplayName
=
subTypeDisplayName
;
}
public
Map
<
String
,
Object
>
getDynamicAttrs
()
{
public
Map
<
String
,
Object
>
getDynamicAttrs
()
{
return
dynamicAttrs
;
return
dynamicAttrs
;
}
}
...
@@ -202,7 +192,6 @@ public class DxPart implements Serializable {
...
@@ -202,7 +192,6 @@ public class DxPart implements Serializable {
this
.
checkOuted
=
checkOuted
;
this
.
checkOuted
=
checkOuted
;
}
}
public
String
getMasterId
()
{
public
String
getMasterId
()
{
return
masterId
;
return
masterId
;
}
}
...
...
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