cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Based on IBA value how to get the document soft type using QuerySpec

VR_10417596
5-Regular Member

Based on IBA value how to get the document soft type using QuerySpec

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 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

13 REPLIES 13

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

VR_10417596
5-Regular Member
(To:HelesicPetr)

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

VR_10417596
5-Regular Member
(To:HelesicPetr)

Hi,

I'm search custom document soft type with custom IBA value based on this I need these document soft type object.

  • TypeIdentifier tiCheck =ClientTypedUtility.getTypeIdentifier(ext.ptc.softDocument);
    SearchCondition sc = TypedUtility.getSearchCondition(mysofttype, true);
    querySpec.appendWhere(sc, new int[] { 0 });
    querySpec.appendAnd();
    QueryResult find = PersistenceHelper.manager.find((StatementSpec)querySpec);
    while (find.hasMoreElements()) {
    Persistable[] nextobj = (Persistable[]) find.nextElement();
            WTDocument nextDoc = (WTDocument) nextobj[0];
    }
  • TypedUtility.getSearchCondition(mysofttype, true);  -- its not available in Windhcill-12.1

@VR_10417596 

And I wrote how you can achieve it. 

PetrH

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

HelesicPetr_0-1684411090162.png

TypedUtility.getSearchCondition(mysofttype, true);

 

so what version library do you use?

 

PS: My IDE informs me if the method is Deprecated

HelesicPetr_1-1684411465731.png

 

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:

HelesicPetr_2-1684411707290.png

 

PetrH

VR_10417596
5-Regular Member
(To:HelesicPetr)

VR_10417596_0-1684417565645.pngthis 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"

HelesicPetr_0-1684483028002.png

 

PetrH

VR_10417596
5-Regular Member
(To:VR_10417596)

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

VR_10417596
5-Regular Member
(To:HelesicPetr)

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

Hi @VR_10417596 

In my case it works perfectly. For all my applications. 

PetrH

Top Tags