Community Tip - You can change your system assigned username to something more personal in your community settings. X
Hi All,
In Windchill 12.1 Vesion below API is not supported and any alternative API?
SearchCondition sc = TypedUtility.getSearchCondition("WTYPE|WTDocument|my.softType", true);
My requirement is to get wtdocument softype as searchcondition then add to QuerySpec.
Thanks,
Vishvanatha
Solved! Go to Solution.
Hello @VR_10417596
Does the API exists? use it. Not supported means nothing.
Also you can try alternate one or write own method to crete it.
WCTypeIdentifier typeID = CreateAndEditWizBean.newWCTypeIdentifier("WTYPE|WTDocument|my.softType");
this one is from the mentioned class CreateAndEditWizBean
public static final WCTypeIdentifier newWCTypeIdentifier(String typeInput) {
WCTypeIdentifier var1 = null;
if (typeInput != null && !"".equals(typeInput)) {
try {
var1 = (WCTypeIdentifier)IDENTIFIER_FACTORY.newWCTypeIdentifier(typeInput);
Class.forName(var1.getClassnameFromTypename());
} catch (Exception var3) {
if (log.isDebugEnabled()) {
log.debug(" in getTypeIdentifier() trying to create WCTypeIdentifier from type: " + typeInput);
}
var1 = null;
}
}
return var1;
}
PS> here is example how to create SearchCondition
ModeledTypeModel atmodel = new ModeledTypeModel();
WCTypeIdentifier typeID = CreateAndEditWizBean.newWCTypeIdentifier("WTYPE|WTDocument|my.softType");
try
{
SearchCondition sc = atmodel.getSearchCondition(typeID,true);
} catch (WTException e)
{
throw new RuntimeException(e);
}
PetrH
Hello @VR_10417596
Does the API exists? use it. Not supported means nothing.
Also you can try alternate one or write own method to crete it.
WCTypeIdentifier typeID = CreateAndEditWizBean.newWCTypeIdentifier("WTYPE|WTDocument|my.softType");
this one is from the mentioned class CreateAndEditWizBean
public static final WCTypeIdentifier newWCTypeIdentifier(String typeInput) {
WCTypeIdentifier var1 = null;
if (typeInput != null && !"".equals(typeInput)) {
try {
var1 = (WCTypeIdentifier)IDENTIFIER_FACTORY.newWCTypeIdentifier(typeInput);
Class.forName(var1.getClassnameFromTypename());
} catch (Exception var3) {
if (log.isDebugEnabled()) {
log.debug(" in getTypeIdentifier() trying to create WCTypeIdentifier from type: " + typeInput);
}
var1 = null;
}
}
return var1;
}
PS> here is example how to create SearchCondition
ModeledTypeModel atmodel = new ModeledTypeModel();
WCTypeIdentifier typeID = CreateAndEditWizBean.newWCTypeIdentifier("WTYPE|WTDocument|my.softType");
try
{
SearchCondition sc = atmodel.getSearchCondition(typeID,true);
} catch (WTException e)
{
throw new RuntimeException(e);
}
PetrH
Hi Helesic,
I have tried this and its returning the soft type model type.
Thanks,
Vishvanatha
Hi @VR_10417596
And can you share a example how it looks like ?
What are real data returned and what do you really expect ?
PetrH
Hi,
I'm search custom document soft type with custom IBA value based on this I need these document soft type object.
Hi @VR_10417596
BTW I checked the Windchill version library 12.1.2.0 and I have not found any deprecated method. that you use
TypedUtility.getSearchCondition(mysofttype, true);
so what version library do you use?
PS: My IDE informs me if the method is Deprecated
also check if you have correct library dependencies in your IDE because the class is not in jar files but it is directly in
...\Windchill\codebase\wt\type\TypedUtility.class
for example my library def looks like this:
PetrH
this is deprecated so I have tried getTypeName() also not working
Class.forName(var1.getClassnameFromTypename());
Hi @VR_10417596
Where is the problem if the ptc method is Deprecated?
The problem would be somewhere else. Not in this method.
PetrH
Hi @VR_10417596
Following code works. and query returns just documents of Agenda type.
Windchill 12.1.2.0
QuerySpec querySpec = new QuerySpec();
int idDocObject = querySpec.appendClassList(WTDocument.class, true);
try
{
TypeIdentifier tiCheck = ClientTypedUtility.getTypeIdentifier("wt.doc.WTDocument|cz.in.Agenda");
SearchCondition sc2 = TypedUtility.getSearchCondition(tiCheck, true);
querySpec.appendWhere(sc2, idDocObject);
QueryResult find = PersistenceHelper.manager.find((StatementSpec) querySpec);
while (find.hasMoreElements())
{
Persistable[] nextobj = (Persistable[]) find.nextElement();
WTDocument nextDoc = (WTDocument) nextobj[0];
}
} catch (WTException e)
{
throw new RuntimeException(e);
}
PS: you used wrong string type definition. You need to use only internal names of type example: "wt.doc.WTDocument|cz.in.Agenda"
PetrH
Hi
Below API is deprecated so I need alternative API
Class.forName(var1.getClassnameFromTypename());
Thanks,
Vishvanatha
Hi @VR_10417596
This method is part of the Java base, so it depends what version of Java you use.
I use Correto 11+ so the method is not deprecated in my case.
You need to find alternate in a Java documentation on some where else where the base java is discussed it is out of scope of PTC.
PetrH
Hi PetrH,
Thanks for your examples but there is an OOTB Deprecated method getClassnameFromTypeName() in WCTypeIdentifier.java. even I had tried for getName(); its not working.
Thanks,
Vishvanatha