Hi All,
I want to find the available Attribute List and its respective Values for WTDocument.
I am able to find System and General Attributes and its Respective values by below code,
I got code to fetch Attributes and its values on PTC portal, but when i use this in my code, i got below error.
Here in my case, "OI_BUSINESS_TYPE" is soft type Attribute of String data type.
Here is my code,
public static void main(String[] args) throws WTException, RemoteException{
RemoteMethodServer rms = RemoteMethodServer.getDefault();
GatewayAuthenticator auth = new GatewayAuthenticator();
auth.setRemoteUser("wcadmin");
rms.setAuthenticator(auth);
String docnumber="0000000264";
WTDocument wtdoc=null;
// search condition
QuerySpec qs = new QuerySpec(WTDocument.class);
SearchCondition sc = new SearchCondition(WTDocument.class,WTDocument.NUMBER,SearchCondition.EQUAL,docnumber,true);
qs.appendSearchCondition(sc);
QueryResult qr = PersistenceHelper.manager.find(qs);
System.out.println(">> Qr size == "+qr.size());
while(qr.hasMoreElements()){
wtdoc=(WTDocument)qr.nextElement();
//System and General Attribute values like created by, Name , version , Lifecycle State etc are simple to get its values as like below.
System.out.println(">>> Name "+wtdoc.getName());
System.out.println(">>>>Number "+wtdoc.getNumber());
System.out.println(">>>> Creator "+wtdoc.getCreatorName());
System.out.println("***** "+wtdoc.BUSINESS_TYPE.toString());
System.out.println(">>>>> "+wtdoc.getIdentity());
System.out.println(">>>Life Cycle State "+wtdoc.getState());
System.out.println(">>> description "+wtdoc.getDescription());
// Code /Api need to Find Attribute and its values found on PTC portal .
com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(wtdoc,null, java.util.Locale.US, new com.ptc.core.meta.common.DisplayOperationIdentifier());
/* Get value of IBAName soft attribute */
obj.load("OI_BUSINESS_TYPE");
java.lang.String string_value = (java.lang.String) obj.get("OI_BUSINESS_TYPE");
System.out.println("Soft attibute value : " + string_value);
}
System.out.println("Done..");
}
-------------------------------------------------------
Error as follows,
--------------
WARNING: The ManagerService is not initialized! This can be caused by:
1) Attempting to invoke a server only method from a remote client
2) Attempting to invoke a method on a service from the constructor or static initializer of another service
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.ptc.core.meta.type.mgmt.server.impl.service.WTTypeManagementDBService.getWTTypeDefinition(WTTypeManagementDBService.java:1210)
at com.ptc.core.meta.type.mgmt.server.impl.service.WTTypeManagementDBService.refreshOriginalTypeDefinition(WTTypeManagementDBService.java:399)
at com.ptc.core.meta.type.mgmt.server.impl.StandardTypeDefinitionCacheManager.getNodeFromService(StandardTypeDefinitionCacheManager.java:63)
at com.ptc.core.meta.type.mgmt.server.impl.AbstractTypeDefinitionCacheManager.load(AbstractTypeDefinitionCacheManager.java:841)
at com.ptc.core.meta.type.mgmt.server.impl.AbstractTypeDefinitionCacheManager.getNode(AbstractTypeDefinitionCacheManager.java:529)
at com.ptc.core.meta.type.mgmt.server.impl.AbstractTypeDefinitionCache.getCurrentTypeIdentifier(AbstractTypeDefinitionCache.java:554)
at com.ptc.core.meta.type.mgmt.server.impl.AbstractTypeDefinitionCache.getTypeIdentifierFromPersistedType(AbstractTypeDefinitionCache.java:444)
at com.ptc.core.meta.server.impl.TypeIdentifierUtilityImplementation.getTypeIdentifierFromPersistedType(TypeIdentifierUtilityImplementation.java:508)
at com.ptc.core.meta.server.impl.TypeIdentifierUtilityImplementation.getTypeIdentifierFromPersistedType(TypeIdentifierUtilityImplementation.java:440)
at com.ptc.core.meta.server.impl.TypeIdentifierUtilityImplementation.getTypeIdentifier(TypeIdentifierUtilityImplementation.java:140)
at com.ptc.core.meta.server.impl.TypeIdentifierUtilityImplementation.getTypeInstanceIdentifier(TypeIdentifierUtilityImplementation.java:219)
at com.ptc.core.meta.server.TypeIdentifierUtility.getTypeInstanceIdentifier(TypeIdentifierUtility.java:212)
at com.ptc.core.meta.type.runtime.server.impl.TypeInstanceUtilityImplementation.getIBAValues(TypeInstanceUtilityImplementation.java:460)
at com.ptc.core.meta.type.server.TypeInstanceUtility.getIBAValues(TypeInstanceUtility.java:254)
at com.ptc.core.lwc.server.LWCNormalizedObject.load(LWCNormalizedObject.java:319)
at com.ptc.core.lwc.server.LWCNormalizedObject.load(LWCNormalizedObject.java:256)
at ext.mbm.PtcAttributeValues.main(PtcAttributeValues.java:60)
Caused by: java.lang.NullPointerException
at wt.session.SessionServerHelper.<clinit>(SessionServerHelper.java:40)
... 17 more
Please guide me to tackle this error.
Regards,
Vivek