Skip to main content
12-Amethyst
December 22, 2014
Question

How to get/Search AdminDomainRef.

  • December 22, 2014
  • 3 replies
  • 1937 views

I want to set/assign the domain to a folder, And the API requires AdminDomainRef.

I want to Query and get this. But QuerySpech throws error saying it's not persistable object.

Can anyone sugest me how to get this....

Or How to set the domain to Folder Using API.

Thanks,

3 replies

12-Amethyst
December 22, 2014

You can try the following way for getting the AdminDomainRef .

For eg.,

ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.projmgmt.admin.Project2:xxxxxx");

Project2 project = (Project2) PersistenceHelper.manager.refresh(oid);

WTContainerRef project_ref = WTContainerRef.newWTContainerRef(oid);

AdminDomainRef domain_ref = project.getDefaultDomainReference();


apatil-212-AmethystAuthor
12-Amethyst
December 23, 2014

Hi,

Thx for the reply .I want to query and get the Domains(AdminDomainRef) from windchill for Containrers. Bcz we have multiple domains for a container which I want to set for folder.

FolderHelper.service.updateSubFolder(arg0, arg1, arg2, arg3)

where arg2 is AdminDomainRef.

1-Visitor
March 30, 2016

Query the AdministrativeDomain then get the AdminDomainRef from that.

public QueryResult queryDomain(String name)

{

QueryResult qr = null;

try

{

QuerySpec qs = new QuerySpec(AdministratvieDomain.class);

qs.appendWhere( new SearchCondition(AdministratvieDomain.class,

                        AdministratvieDomain.NAME, SearchCondition.EQUAL, name), null);

StatementSpec statementSpec = (StatementSpec) qs;

qr = PersistenceHelper.manager.find(statementSpec);

}

catch(WTException e)

{

   e.printStackTrace();

}

}

public AdministrativeDomain getDomain(String name)

{

QueryResult qr = queryDomain(name);

if(qr != null)

{

       //Our system is guaranteed to have unique names otherwise use the OID for the query.

while(qr.hasMoreElements())

{

    return (AdministrativeDomain)qr.nextElement();

}

}

return null;

}

public AdminDomainRef getDomainRef(String name)

{

AdministrativeDomain ad = getDomain(name);

AdminDomainRef domainRef = null;

if(ad != null)

{

ReferenceFactory rf = new ReferenceFactory();

domainRef = (AdminDomainRef)rf.getReference(ad);

}

return domainRef;

}