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

We are happy to announce the new Windchill Customization board! Learn more.

How to get/Search AdminDomainRef.

apatil-2
1-Newbie

How to get/Search AdminDomainRef.

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 3
VINO
3-Visitor
(To:apatil-2)

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-2
1-Newbie
(To:VINO)

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.

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;

}

Top Tags