Agile Product Lifecycle Management Web Services Guide Release 9.3.6 E71166-01 |
|
![]() Previous |
![]() Next |
A Query is a feature which helps you search for Agile PLM data. It defines a search similar to the searches in Agile Web Client. The search can have multiple search criteria (similar to the Advanced Search in Agile Web Client), or a simple search that specifies a single criterion.
To create and execute a query, first create a Query object. As with other Agile API objects, create the object using the createQuery operation.
In its simplest form, the parameters that pass with the createQuery operation to create a query are the Query object type and the query class used in the search.
Example: Creating a Query
CreateQueryRequestType createQueryRequestType = new CreateQueryRequestType(); AgileCreateQueryRequestType[] agileCreateQueryRequestType = new AgileCreateQueryRequestType[1]; agileCreateQueryRequestType[0] = new AgileCreateQueryRequestType(); QueryObjectIdentifierType queryObjectIdentifierType = new QueryObjectIdentifierType(); queryObjectIdentifierType.setName("Personal Searches/Submitted Changes"); QueryObjectType queryObjectType = new QueryObjectType(); queryObjectType.setOwner("badriv"); agileCreateQueryRequestType[0].setQueryParams(queryObjectType); createQueryRequestType.setRequests(agileCreateQueryRequestType);
The query class you specify with the createQuery operation also includes objects from all of its subclasses. For example, when you search for objects in the Item class, the results include Parts and Documents. When you search for objects in the Change class, the results include objects from all Change subclasses (Deviation, ECO, ECR, MCO, PCO, SCO, and Stop Ship). To search for a specific subclass, you must explicitly specify the class.
You can use the saveAsQuery operation to create a new query from an existing query object.
Example: Using IQuery.saveAs() to save a query to a folder
SaveAsQueryRequestType saveAsQueryRequestType = new SaveAsQueryRequestType(); AgileSaveAsQueryRequestType[] agileSaveAsQueryRequestType = new AgileSaveAsQueryRequestType[1]; agileSaveAsQueryRequestType[0] = new AgileSaveAsQueryRequestType(); QueryObjectIdentifierType queryObjectIdentifierType = new QueryObjectIdentifierType(); queryObjectIdentifierType.setName("Personal Searches/Submitted Changes"); agileSaveAsQueryRequestType[0].setQueryIdentifier(queryObjectIdentifierType); agileSaveAsQueryRequestType[0].setNewQueryIdentifier("Personal Searches/My Submitted Changes"); saveAsQueryRequestType.setRequests(agileSaveAsQueryRequestType);
Used to load a query.
Example: Loading a query
LoadQueryRequestType loadQueryRequestType = new LoadQueryRequestType(); AgileLoadQueryRequestType[] agileLoadQueryRequestType = new AgileLoadQueryRequestType[1]; agileLoadQueryRequestType[0] = new AgileLoadQueryRequestType(); QueryObjectIdentifierType queryObjectIdentifierType = new QueryObjectIdentifierType(); queryObjectIdentifierType.setName("Recycle Bin Searches/Deleted Changes"); agileLoadQueryRequestType[0].setQueryIdentifier(queryObjectIdentifierType); loadQueryRequestType.setRequests(agileLoadQueryRequestType);
Used to execute a saved query existing in the system.
Example: Executing an existing Query saved in the Agile system
ExecuteSavedQueryRequestType executeSavedQueryRequestType = new ExecuteSavedQueryRequestType(); AgileExecuteSavedQueryRequestType[] agileExecuteSavedQueryRequestType = new AgileExecuteSavedQueryRequestType[1]; agileExecuteSavedQueryRequestType[0] = new AgileExecuteSavedQueryRequestType(); QueryObjectIdentifierType queryObjectIdentifierType = new QueryObjectIdentifierType(); queryObjectIdentifierType.setName("Recycle Bin Searches/Deleted Changes"); agileExecuteSavedQueryRequestType[0].setQueryIdentifier(queryObjectIdentifierType); executeSavedQueryRequestType.setRequests(agileExecuteSavedQueryRequestType);
Used to update an existing query.
Example: Updating an existing query
UpdateQueryRequestType updateQueryRequestType = new UpdateQueryRequestType(); AgileUpdateQueryRequestType[] agileUpdateQueryRequestType = new AgileUpdateQueryRequestType[1]; agileUpdateQueryRequestType[0] = new AgileUpdateQueryRequestType(); QueryObjectIdentifierType queryObjectIdentifierType = new QueryObjectIdentifierType(); queryObjectIdentifierType.setName("Personal Searches/Submitted Changes"); agileUpdateQueryRequestType[0].setQueryIdentifier(queryObjectIdentifierType); QueryObjectType queryObjectType = new QueryObjectType(); queryObjectType.setOwner("badriv"); agileUpdateQueryRequestType[0].setNewQueryParams(queryObjectType); updateQueryRequestType.setRequests(agileUpdateQueryRequestType);
To delete a query that you have saved, use the "deleteQuery" operation.
Queries which are created but not saved to a folder after the user session is closed are temporary queries. Ensure to delete the temporary queries, especially after you run lengthy sessions.
Example: Deleting a query
DeleteQueryRequestType deleteQueryRequestType = new DeleteQueryRequestType(); AgileDeleteQueryRequestType[] agileDeleteQueryRequestType = new AgileDeleteQueryRequestType[1]; agileDeleteQueryRequestType[0] = new AgileDeleteQueryRequestType(); QueryObjectIdentifierType queryObjectIdentifierType = new QueryObjectIdentifierType(); queryObjectIdentifierType.setName("Personal Searches/MySubmittedChanges"); agileDeleteQueryRequestType[0].setQueryIdentifier(queryObjectIdentifierType); deleteQueryRequestType.setRequests(agileDeleteQueryRequestType);