Previous Topic: Usage GuidelinesNext Topic: GEL Scripting


XOG Services

This section contains the following topics:

Object API

InvokeAction API

Query API

Object API

The structure for each object is defined in its corresponding schema (XSD). There is one general schema definition for all read object requests; however, the schema definition for each read object response and each write object request varies based on the object that is accessed. This is because the structure for each object is defined in its own corresponding schema.

See Appendix A, XOG Object Reference for a complete list of available XOG objects.

More information:

XOG Object Types

ActionObject Element

Read Standard Stock Objects

Write Standard Stock Objects

XOG Object Types

The Object API includes the following group of XOG objects:

Standard stock objects

Refers to actual objects in the XOG. You can communicate with these standard stock objects by reading and writing data using a valid interface.

Custom objects and add-ins

These objects have unique schemas that differ from the standard stock object schema. You must first create custom objects in Studio before you can are invoke them through the XOG. Add-in schemas allow you to read and write Studio components. For example, objects, pages, and portlets.

For more information, see the Studio Developer’s Guide.

ActionObject Element

All read and write XOG objects use an <ActionObject> element to define the action to be taken and the object to take it on. An action can be either a read or write. An object can be any XOG object that is available under the Objects API category such as department and companies.

For example, the <ReadProject> element indicates read as the action to take, and Project is the XOG object against which the action is taken. The <ActionObject> element is the parent element that wraps around the NikuDataBus header attributes.

The following example shows the structure used for requesting a read action on the Project object:

<obj:ReadProject xmlns:obj="http://www.niku.com/xog/Object">
   <NikuDataBus>
      <Header/>
      <Query/>
   </NikuDataBus>
</obj:ReadProject>

The namespace http://www.niku.com/xog/Object must be localized in your request file to the <ActionObject> element. This localization is accomplished with the obj prefix. Failure to include this prefix results in an error during the processing of the request.

Read Standard Stock Objects

Example XML Read Request

Read object requests are used to extract specific object records from CA Clarity. The read object request services reference the nikuxog_read.xsd schema (shown in bold) in the following example.

<obj:ReadUser xmlns:obj="http://www.niku.com/xog/Object">
   <NikuDataBus 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
      <Header version="12.0.0.5028" externalSource="NIKU"/>
         <Query>
            <Filter name="userName" criteria="EQUALS">admin</Filter>
         </Query>
   </NikuDataBus>
</obj:ReadUser>

Example XML Read Response

In the following example, the nikuxog_user.xsd defines the NikuDataBus read response element.

<ReadUserResponse xmlns="http://www.niku.com/xog/Object">
   <NikuDataBus 
      xsi:noNamespaceSchemaLocation="../xsd/nikuxog_user.xsd" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Header externalSource="NIKU" version="12.0.0.5028"/>
         <Users>
            <User externalId=" " userLanguage="English" 		
               userLocale="en_US" userName="admin" 
               userStatus="ACTIVE" userTimezone="Europe/London" 
               userType="INTERNAL">
               <PersonalInformation emailAddress="test@ca.com"
                  firstName="ca" lastName="Administrator"/>
                  <Resource resourceId="admin"/>
                     <Company/>
                        <General addedBy="admin" addedDate="2005-03-12"/>
                           <OBSAssocs>
                              <OBSAssoc id="loc" name="Location" unitPath="/	USA"/>
                           </OBSAssocs>
                              <Groups>
                                 <Group id="ApplAdminRl"/>
                              </Groups>
                              <GlobalRights/>
                              <InstanceRights/>
                              <InstanceOBSRights>
             </User>
         </Users>
      <XOGOutput>
         <Status state="SUCCESS"/>
         <Statistics failureRecords="0"insertedRecords="0" totalNumberOfRecords="1" updatedRecords="0"/>
         <Records/>'
      </XOGOutput>
   </NikuDataBus>
</ReadUserResponse>

Write Standard Stock Objects

Write object requests are used to insert and update records into another system.

<obj:WriteUser xmlns:obj="http://www.niku.com/xog/Object">
   <NikuDataBus xsi:noNamespaceSchemaLocation="../xsd/nikuxog_user.xsd" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">	
         <Header externalSource="NIKU" version="12.0.0.5028"/>
		...

Example XML Write Request

In XML write requests, the unique record identifier varies based on the object. In the following example, the identifier is the userName attribute. This example is an update, and it includes only a subset of the information exported in the read request example. The nikuxog_user.xsd defines the NikuDataBus write request element.

<obj:WriteUser xmlns:obj="http://www.niku.com/xog/Object">
   <NikuDataBus
      xsi:noNamespaceSchemaLocation="../xsd/nikuxog_user.xsd" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Header externalSource="NIKU" version="12.0.0.5028"/>
            <Users>
               <User externalId=" " userLanguage="English" 		
                  userLocale="en_US" userName="admin"
                  userStatus="ACTIVE" userTimezone="Europe/London">
                     <PersonalInformation emailAddress="admin@ca.com"/>
               </User>
           </Users>
   </NikuDataBus>
</obj:WriteUser>

Example XML Write Response

The following is the result from the example write request.

<WriteUserResponse xmlns="http://www.niku.com/xog/Object">
   <XOGOutput xsi:noNamespaceSchemaLocation="../xsd/status.xsd" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Object type="user"/>
            <Status state="SUCCESS"/>
               <Statistics failureRecords="0" insertedRecords="0" totalNumberOfRecords="1" updatedRecords="1"/>
                  <Records>
                     <Record>
                        <KeyInformation>
                           <column name="ALL">ALL RECORDS</column>
                        </KeyInformation>
                           <ErrorInformation>
                              <Severity>WARNING</Severity>
                                 <Description>New Users Password will be Defaulted to Value ca2000</Description>
                           </ErrorInformation>
                    </Record>
                 </Records>
   </XOGOutput>
</WriteUserResponse>

More information

XOG Object Types

ActionObject Element

Read Standard Stock Objects

Partitioning and Standard Stock Objects

Read and Write Custom Object Instances

ContentPack Service

Autonumbering and Custom Attributes

Import and Export Custom Fiscal Time-Varying Attributes

Import and Export UI Themes

Include New and Delete Buttons

About Passing XDM Custom Fields

Partitioning and Standard Stock Objects

The read object response services provide partition view information for each object instance. Similarly, you can write a partition view to each write object instance request.

If you do not specify a partition view in your write request, all the instances you create are automatically assigned to the default system partition value NIKU.ROOT.

To specify a new partition, replace NIKU.ROOT with your actual partition code. Before you can specify a partition view, you must create a partition model and associate it with your objects in Studio.

For more information, see the Studio Developer’s Guide.

Example Partition XML

The following example shows how partition information is specified for each object instance (that is for each "Project") using the <CustomInformation> element.

<obj:WriteProject xmlns:obj="http://www.niku.com/xog/Object">
   <NikuDataBus xsi:noNamespaceSchemaLocation="../xsd/nikuxog_user.xsd" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Header externalSource="NIKU" version="8.0"/>
            <Projects>
               <Project> 
                  .
                  .
                  .
                  .
                     <CustomInformation>
                             <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                          </CustomInformation>
                  .
                  .
                  .
                  .        
            </Project>
         </Projectss>
   </NikuDataBus>
</obj:WriteProject>

Read and Write Custom Object Instances

The CustomObjectInstances service is an entry point to enable XOG communication with instances of custom objects. Instances represent data held within custom objects, not the definition of the objects.

For more information, see the Studio Developer’s Guide.

More information:

Read CustomObjectInstances

Write CustomObjectInstances

Read CustomObjectInstances

A CustomObjectInstances read request requires the namespace niku_xog_read.xsd and then the <CustomObjectInstanceQuery> element.

The CustomObjectInstanceQuery element allows you to filter on instances of one or more custom objects using the following filter attributes:

objectCode

Refers to the custom object ID as defined in Studio.

instanceCode

Refers to the custom object instance ID as defined in Studio.

For more information, see the Studio Developer’s Guide.

Example XML Read Request

The following XML shows an example read CustomObjectInstance request and how it uses the <CustomObjectInstanceQuery> element.

<obj:ReadCustomObjectInstance xmlns:obj="http://www.niku.com/xog/Object">
   <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
      <Header version="12.0.0.5028" externalSource="NIKU"/>
         <CustomObjectInstanceQuery>
            <Filter name="objectCode" criteria="EQUALS">training_modules</Filter>
               <Filter name="instanceCode" criteria="EQUALS">Business Ethics </Filter>
         </CustomObjectInstanceQuery>
   </NikuDataBus>
</obj:ReadCustomObjectInstance>

More information:

Write CustomObjectInstances

Write CustomObjectInstances

The write CustomObjectInstances request services are defined by the nikuxog_customObjectInstance.xsd schema.

Example Write XML

The following example shows an XML write request:

<obj:WriteCustomObjectInstance xmlns:obj="http://www.niku.com/ xog/Object">
   <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:noNamespaceSchemaLocation="../xsd/ nikuxog_customObjectInstance.xsd">
         <Header externalSource="NIKU" version="12.0.0.5028"/>
            <customObjectInstances objectCode="movies">
               <instance instanceCode="Star Wars" objectCode="movies11">
                  <CustomInformation>
                     <ColumnValue name="category">Science Fiction</ ColumnValue>
                     <ColumnValue name="code">Star Wars</ColumnValue>
                     <ColumnValue name="cost">20000000</ColumnValue>
                     <ColumnValue name="cost_currency">USD</ ColumnValue>
                     <ColumnValue name="name">Star Wars</ColumnValue>
                     <ColumnValue name="page_layout">odf.moviesFrame</ColumnValue>
                     <ColumnValue name="partition_code">US</ ColumnValue>
                     <ColumnValue name="us_rating">PG-13</ ColumnValue>
                  </CustomInformation>
                     <OBSAssocs/>
             </instance>
          </customObjectInstances>
   </NikuDataBus>
</obj: WriteCustomObjectInstance>
Partitioning

Like standard stock objects, the read CustomObjectInstances response service provides partition view information for each custom object instance. You can write a partition view to each write CustomObjectInstances instance. In the previous XML write request example, the partition view of US is specified for the Star Wars movie instance definition.

More information:

Read CustomObjectInstances

ContentPack Service

The ContentPack service is an entry point to enable XOG communication with Studio components, such as objects, object views, NSQL queries, portlets, process definitions, report definitions, lookups, and portlet pages.

For more information, see the Studio Developer’s Guide.

More information:

Read Content Pack Objects

Read Content Pack Objects with Partitioning

Export Content Types Without Dependencies

Export Portlet Data from Studio to an XML File

Read Content Pack Objects

Like standard stock objects, the read ContentPack request service is also defined by the nikuxog_read.xsd schema as shown in the following example. However, for the ContentPack service, this schema is unique because it includes the <ViewQuery> element. This element allows you to read Studio components.

Example XML Read Request

The following example shows the ViewQuery for reading the property and list components of the custom object myObject_v1.

<obj:ReadContentPack xmlns:obj="http://www.niku.com/xog/Object">
  <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
      <Header version="12.0.0.5028" externalSource="NIKU"/>
      <ViewQuery>
        <Filter name="code" criteria="EQUALS">property</Filter>
        <Filter name="object_code" criteria="EQUALS">myObject_v1</Filter>
      </ViewQuery>
      <ViewQuery>
        <Filter name="code" criteria="EQUALS">list</Filter>
        <Filter name="object_code" criteria="EQUALS">myObject_v1</Filter>
      </ViewQuery>
  </NikuDataBus>
</obj:ReadContentPack>

More information:

Read Content Pack Objects with Partitioning

Export Content Types Without Dependencies

Export Portlet Data from Studio to an XML File

Read Content Pack Objects with Partitioning

You can filter on partition views from a ContentPack read request by including the <ViewQuery> filter condition attribute.

To read specific partitioned views using the ContentPack XOG, you must explicitly request these partitions in a ViewQuery by including the partition_code.

In the file, specify the following:

object_code

Indicates the CA Clarity identifier for the object.

partition_code

Indicates the CA Clarity identifier for the partition. If the partition_code is not specified, views for all partitions are exported.

Example XML Read Request with Partitioning

The following read ContentPack request specifies the ABC partition for the custom object myObject_v1 as shown in bold.

<obj:ReadContentPack xmlns:obj="http://www.niku.com/xog/Object">
  <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
      <Header version="12.0.0.5028" externalSource="NIKU">
      <!-- the contentType is used to determine which filter goes where -->
        <args contentType="job_definition" name="order_by_1" value="code"/>
        <args contentType="menu" name="order_by_1" value="code"/>
        <args contentType="view" name="order_by_1" value="code"/>
        <args contentType="process" name="order_by_1" value="code"/>
        <args contentType="object" name="order_by_1" value="code"/>
      </Header>
      <ViewQuery>
        <Filter name="code" criteria="EQUALS">property</Filter>
        <Filter name="object_code" criteria="EQUALS">myObject_v1</Filter>
        <Filter name="partition_code" criteria="EQUALS">ABC</Filter>
      </ViewQuery>
      <ViewQuery>
        <Filter name="code" criteria="EQUALS">list</Filter>
        <Filter name="object_code" criteria="EQUALS">myObject_v1</Filter>
        <Filter name="partition_code" criteria="EQUALS">ABC</Filter>
      </ViewQuery>
      <ObjectQuery>
        <Filter name="object_code" criteria="EQUALS">myObject_v1</Filter>
      </ObjectQuery>
  </NikuDataBus>
</obj:ReadContentPack>

More information:

Read Content Pack Objects

Export Content Types Without Dependencies

Export Portlet Data from Studio to an XML File

Export Content Types Without Dependencies

You can use two arguments, singleContentType and no_dependencies, to export individual content types and to limit the amount of data exported for each type. These arguments should be used only for small, incremental updates to content.

Important! Use care when applying these arguments. The user performing the export must have a thorough understanding of content data on the source and target systems.

singleContentType

Exports a specific content type. You must specify the singleContentType argument in the XML read file. The format for the argument in the XML read file is as follows:

<args name="singleContentType" value="content type">

where content type can be any of the following supported content types:

No_dependencies

Limits the amount of data exported for a specific content type. The format for the argument in the XML read file is as follows:

<args name=“no_dependencies” value=“true/false”/>

where true exports incremental changes for a content type without dependencies. By default, the no_dependencies flag is false, which means any dependencies that exist for the value specified in the singleContentType argument are exported if the value is not specified.

The following table shows the content types that are exported when the no_dependencies argument is set to true.

Content Type

Attributes

job_definition

active, executable, isHidden, jobDefinitionCode, jobType, logEnabled, outputEnabled, runConcurrent, source, description, name, attributes related to parameter like code, dataType, defaultValue, order, readOnly, required, widgetType., attributes related to OBSAssocs like completed, Security

lookup

code, hiddenAttributename, sortStype, source, status, description, name, sortorder, attributes related to partition

menu

code, source, description, name, link, section

object

code, source, description, name, displayMapping, parentObjectCode

page [portlet page]

tabbedPage, code, customizable, layout, linkable, objectypes, personalizable, source, space, template, description, name, tab, OBSAssocs, Parameter, dataref, dataSource, paramCode

portlet

allowConfigure, allowConfigureLabel, category, code, colorItem, dataProviderId, dataProvideerPartitionId, dataProviderType, datapointLabels,

firstSliceAngle, forceFilter, link, mouseoverLbels, objectType, seriesDimension, showLegend, showTitle, size, source, type, name, decimalPlaces

Note: Attributes can vary depending on type of portlet.

process

code, endStep, allowOneRunningInstance, source, startOption, startStep, description, name, rightCode, username, manualStart, objectType, partitionCode, partitionModeCode, type, isMileStone, sequenceNo, attributes related to Notifications, Operations, TransactionRestrictions

query

category, code, description, name, attributes related to nsql like dbId, dbVendor, attributes for link like action, code

Example: XML Read File for Exporting a Portlet Without Dependencies

The following example shows an XML read file where portlet data without any dependency data is requested. The arguments are shown in bold.

  <?xml version="1.0" encoding="UTF-8" ?> 
- <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
- <Header version="12.0.0.5028" action="read" objectType="contentPack" externalSource="NIKU">
<!-- Provide following argument with singlecontenttype to retrieve only portlet. --> 
<args name="singleContentType" value="portlet" /> 
<!-- May specify following OPTIONAL argument no_dependencies to exclude dependent content. --> 
<args name="no_dependencies" value="true" /> 
  </Header>
- <PortletQuery>
<Filter name="code" criteria="EQUALS">balance</Filter> 
  </PortletQuery>
</NikuDataBus>

More information:

Read Content Pack Objects

Read Content Pack Objects with Partitioning

Export Portlet Data from Studio to an XML File

Export Portlet Data from Studio to an XML File

To facilitate the export of portlets, you can export this content type from Studio. The Portlets list page has an Export button that lets you export basic data on the portlets as individual XML files. The output XML files, which are packaged into a zip file, contain basic information with no dependencies.

More information:

Read Content Pack Objects

Read Content Pack Objects with Partitioning

Export Content Types Without Dependencies

Autonumbering and Custom Attributes

The flag overrideAutoNumbering is an argument defined in the XOG header that determines whether source XOG content overrides autonumbering in the target content. The flag is available for the custom attributes of custom objects.

The following rules apply:

By default, OverrideAutoNumbering=TRUE.

The following example shows the overrideAutoNumbering argument in the header:

  <Header action="write" externalSource="NIKU" objectType="customObjectInstance" version="13.0.0">
    <args name="overrideAutoNumbering" value="false"/>
  </Header>

Import and Export Custom Fiscal Time-Varying Attributes

You can export or import custom fiscal time-varying attributes as part of the import or export of a standard or custom subobject with which the attributes are associated.

When a subobject is exported, the XOG export file includes the following elements:

If a subobject includes custom fiscal time-varying attributes, the master object export file includes the following additional elements:

More information:

XOG Object Types

ActionObject Element

Read Standard Stock Objects

Write Standard Stock Objects

Partitioning and Standard Stock Objects

Read and Write Custom Object Instances

ContentPack Service

Autonumbering and Custom Attributes

Import and Export UI Themes

Include New and Delete Buttons

About Passing XDM Custom Fields

Import and Export UI Themes

You can import and export UI themes through the XML Open Gateway. The XOG client provides sample UI theme XML files. The import file for UI themes is cmn_ui_themes_write.xml.

The default attribute on the UITheme element determines whether a UI theme being imported is the default theme for the system. If the default attribute is set to true, the theme becomes the system default theme. If you are importing multiple UI themes in one import file, only one UI theme is expected to have the default attribute set to true. If multiple themes in a single import have the default attribute set to true, the last theme processed with the attribute set to true becomes the default theme.

Sample Import File cmn_UI_themes_write.xml

The following section of the cmn_ui_themes_write.xml shows the default attribute set to false. In this case, the UI theme being imported is not the default CA Clarity UI theme.


<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2011, CA Inc.  All rights reserved. -->
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_uitheme.xsd">
    <Header action="write" externalSource="NIKU" objectType="uitheme" version="13.0"/>
    <UIThemes>
        <UITheme active="true" default="false" id="sample_ui_theme">
          <nls description="A sample UI Theme" languageCode="en" name="Sample UI Theme"/>
          <css><![CDATA[

Include New and Delete Buttons

When you are importing a new custom object, the New and Delete buttons are deselected by default. This means it is not possible to immediately create a new instance of the object. To make the New and Delete buttons available immediately for the new object, include the following two lines in the script:

<action code="odf.@objectCode@Create"/>
<action code="odf.deleteObjectInstancesConfirm"/>

Example:

<list>
....

<action code="odf.testCreate"/>
<action code="odf.deleteObjectInstancesConfirm"/>
....

</list>

About Passing XDM Custom Fields

XDM configuration changes are automatically handled by the Object API. The following rules apply:

Example

<CustomInformation>
  <ColumnValue name=”CEO_NAME”>ceo2</ColumnValue>
  <ColumnValue name=”DEFAULTWEBSITE”>http://www1</ColumnValue>
  <ColumnValue name=”NUM_OF_EMPLOYEES”>100</ColumnValue>
  <ColumnValue name=”OPPORTUNITY”>1</ColumnValue>
</CustomInformation>

InvokeAction API

The InvokeAction API is a general-purpose area for administrative actions that fall outside the categories of data import and export. There is no corresponding schema (XSD) for this API and accordingly there is no XSD validation.

More information:

InvokeAction API Root Elements

FlushCache Elements

Process Elements

InvokeAction API Root Elements

The following are the root elements of the InvokeAction API:

FlushCache

This action is used to flush a cache within a running Application.

Process

This action is used to schedule integration processes or initiate them in realtime.

FlushCache Elements

The following describes the FlushCache root elements:

group

Optional. Identifies the cache group to be flushed.

Type: String

id

Optional. Identifies the cache ID to be flushed.

Type: String

Example: XML Flush Cache

In the following example, the xmlns= attribute is using the InvokeAction API. There is no reference to a schema or XSD.

<FlushCache xmlns=”http://www.niku.com/xog/InvokeAction”>	
   <group>Resources</group>
   <id>ConfigurationProperties</id>
</FlushCache>

Process Elements

The following describes the Process root elements:

code

Required. Identifies the process ID.

Type: String

request

Optional. Identifies the root element of the process input document.

Type: Any

Example: Process Request

In the following sample, remedy_writeIncident is the process ID required to invoke the process action. Note that a process may or may not include a request. An action can be invoked by specifying the process ID. The following example includes a request.

<Process xmlns="http://www.niku.com/xog/InvokeAction">>
  <code>remedy_writeIncident</code>
    <request>
      <incidents>
        <incident assignedTo="jstewart" 
          categoryCode="telcom" 
          estimatedEffort="240" 
          estimatedEffortUnit="MINUTES"
          externalId="tc421" 
          impactCode="High" 
          incidentCode="RMD-TC421" 
          priorityCode="Medium"
          reportedBy="rcordry" 
          resolutionDate="2005-03-03T12:30:00" 
          sourceCode="REMEDY" startDate="2005-03-01T08:00:00" 
          statusCode="Closed" 
          subject="Phone system down" typeCode="incident" 
          urgencyCode="High">
            <description>
              Tried making call, no dial tone.
            </description> 
              <notes/>
                <efforts enterOnce="true">
                  <effort quantity="3.5" quantityUnit="HOURS" 
                    resourceCode="jstewart" 
                    transactionDate="2005-03-03"/>
                </efforts>
                  <contacts/>
      </incident>
    </incidents>
  </request>
</Process>

Query API

It is often not sufficient to read data only as predefined objects. For example, full object instance data including dependencies may be too much detail. Or, you may need data from multiple objects or from database tables that have no defined objects.

You can use the Query API to execute Studio NSQL-based queries from the XOG. The Studio Query is referenced by its code. The response is formatted as record elements.

Note: The Query API requires a valid license for Studio.

Example: Studio Query

code: sample.getresources

NSQL:

SELECT 
@SELECT:DIM:USER_DEF:IMPLIED:RESOURCE:R.FULL_NAME:RSRC@,
@SELECT:DIM_PROP:USER_DEF:IMPLIED:RESOURCE:MR.FULL_NAME:MGR@,
@SELECT:METRIC:USER_DEF:IMPLIED:COUNT(*):PROJECT_COUNT:AGG@
FROM 			SRM_PROJECTS P,
			SRM_RESOURCES R,
			SRM_RESOURCES MR,
			CMN_SEC_USERS U
WHERE    P.CREATED_BY = U.ID
AND      U.ID = R.USER_ID
AND      R.MANAGER_ID = MR.USER_ID
AND      @FILTER@
GROUP BY R.FULL_NAME,
MR.FULL_NAME
HAVING   @HAVING_FILTER@

Example: XML Query

<Query xmlns="http://www.niku.com/xog/Query">
  <Code>sample.getresources</Code>
</Query>

Example: Result

<QueryResult xmlns="http://www.niku.com/xog/Query">
  <Code>sample.getresources</Code>
  <Records>
    <Record>
      <rsrc>Administrator, Niku</rsrc>
      <project_count>178</project_count>
      <manager>Administrator, Niku</manager>
    </Record>
  </Records>
</QueryResult>

Query API Root Elements

The following describes the Query API root elements:

Code

Required. Identifies the NSQL unique identifier defined in Studio.

Type: String

Filter

Optional. Identifies the NSQL filter columns defined in Studio.

Type: User-defined

The Query Filter

The WSDL for queries defines filter parameters in addition to the code identifier. This allows ad-hoc queries based on a Studio Query using the XOG. For every column selected in the query, you are given multiple filter possibilities.

More information:

Exact Match

Wildcard Query Example

Capture Bounded and Unbounded Ranges

Exact Match

To filter on a specific value for a column, use the column name directly and pass the value in which you are interested.

The following example retrieves a single row for resource CorpApp Administrator. Any deviation in the rsrc value of 'Administrator, CorpApp' returns nothing.

Example

<Query xmlns="http://www.niku.com/xog/Query">
  <Code>sample.getresources</Code>
    <Filter>
      <rsrc>Administrator, CorpApp</rsrc>
    </Filter>
</Query>

Wildcard Query Example

The wildcard filter behaves like any grid filter field. It automatically appends a wildcard asterisk (*) to the end of a value. You can also insert your own asterisk anywhere in the filter string including at the beginning. The latter is not recommended when filtering very large data sets, as performance is severely degraded.

The wildcard filter is available only on columns of type String.

From the sample.getresources Example

<Query xmlns="http://www.niku.com/xog/Query">
   <Code>sample.getresources</Code>
   <Filter>
      <rsrc_wildcard>Admin</rsrc_wildcard>
   </Filter>
</Query>

Another Example

<Query xmlns="http://www.niku.com/xog/Query">
   <Code>sample.getresources</Code>
   <Filter>
      <rsrc_wildcard>Admin*CorpApp</rsrc_wildcard>
   </Filter>
</Query>

Capture Bounded and Unbounded Ranges

The from and to filters perform a "greater than or equal to” and “less than or equal to” operation on a given value. Use these filters to capture a bounded range or separately for an unbounded range.

Example: From Filter

The following unbounded example returns all records with project_count greater than or equal to 1:

<Query xmlns="http://www.niku.com/xog/Query">
  <Code>sample.getresources</Code>
  <Filter>
    <project_count_from>1</project_count_from>
  </Filter>
</Query>

Example: To Filter

The following bounded example returns all records with rsrc values that start with the letters A through E:

<Query xmlns="http://www.niku.com/xog/Query">
  <Code>sample.getresources</Code>
    <Filter>
      <rsrc_from>A</rsrc_from>
      <rsrc_to>E</rsrc_to>
    </Filter>
</Query>

Example: Exporting Query Results to a Tab-Delimited Text File

The following example uses GEL to execute the NSQL query "xog_query_test", which is the default NSQL query. The example shows how to retrieve the query results and export them to a tab-delimited text file.

For more information on using GEL with the XOG, see the chapter named "GEL Scripting."

Example

<gel:script
  xmlns:core="jelly:core"
  xmlns:xog="http://www.niku.com/xog"
  xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
  xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:f="jelly:com.niku.union.gel.FileTagLibrary"
  xmlns:nikuq="http://www.niku.com/xog/Query"
  xmlns:util="jelly:util">

  <!-- Construct the Query API request for the NSQL query "xog_query_test" -->
  <gel:parse var="xoginput">
    <Query xmlns="http://www.niku.com/xog/Query">
        <Code>xog_query_test</Code>
    </Query>
  </gel:parse>

  <soap:invoke endpoint="http://localhost/niku/xog" var="xogresponse">
    <soap:message>
      <soapenv:Envelope>
      <soapenv:Header>
        <Auth>
        <Username>admin</Username>
        <Password>niku2000</Password>
        </Auth>
      </soapenv:Header>
      <soapenv:Body>
        <gel:include select="$xoginput"/>
      </soapenv:Body>
      </soapenv:Envelope>
    </soap:message>
  </soap:invoke>

  <!-- Extract the sessionID so we may logout later -->
  <gel:set asString="true" select="$xogresponse/soapenv:Envelope/soapenv:Body/xog:SessionID/text()" var="sessionID"/>
  <gel:out>SessionID = ${sessionID}</gel:out>

  <!-- Extract the records -->
  <gel:set select="$xogresponse/soapenv:Envelope/soapenv:Body/nikuq:QueryResult/nikuq:Records" var="records"/>
  <gel:set asString="true" select="$records" var="recordstext"/>
  <gel:out>${recordstext}</gel:out>

  <!-- Create a tab-delimited file from the results -->
  <f:writeFile fileName="projectData.txt" delimiter="&#x9;" embedded="true">
  <gel:forEach select="$records//nikuq:Record" var="xog_record">
    <f:line>
    <gel:forEach select="$xog_record/*" var="xog_data">
      <gel:set var="xog_data" select="$xog_data/text()" asString="true"/>
      <f:column value="${xog_data}"/>
    </gel:forEach>
    </f:line>
  </gel:forEach>
  </f:writeFile>

  <!-- Now log out -->
  <soap:invoke endpoint="http://localhost/niku/xog" var="logout">
    <soap:message>
      <soapenv:Envelope>
      <soapenv:Header>
        <Auth>
          <xog:SessionID>${sessionID}</xog:SessionID>
        </Auth>
      </soapenv:Header>
      <soapenv:Body>
        <xog:Logout/>
      </soapenv:Body>
      </soapenv:Envelope>
    </soap:message>
  </soap:invoke>	

</gel:script>