Agile PLM Programming Deck
Agile PLM Programming Deck
Agile PLM Programming Deck
February 2015
Agile Product Lifecycle Management, Release 9.3.4
E52162-02
Copyright © 2010, 2015, Oracle and/or its affiliates. All rights reserved.
Contributor:
This software and related documentation are provided under a license agreement containing restrictions on
use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your
license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license,
transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse
engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is
prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If
you find any errors, please report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it
on behalf of the U.S. Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,
any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users
are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and
agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and
adaptation of the programs, including any operating system, integrated software, any programs installed on
the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to
the programs. No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management
applications. It is not developed or intended for use in any inherently dangerous applications, including
applications that may create a risk of personal injury. If you use this software or hardware in dangerous
applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other
measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages
caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of
their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks
are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD,
Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced
Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content,
products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and
expressly disclaim all warranties of any kind with respect to third-party content, products, and services
unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its
affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of
third-party content, products, or services, except as set forth in an applicable agreement between you and
Oracle.
Contents
1 Introduction
About this Guide...................................................................................................................................... 1-1
Agile PLM Extensions Framework.................................................................................................. 1-2
SDK Components..................................................................................................................................... 1-2
Client-Side Components ................................................................................................................. 1-2
Documentation ............................................................................................................................ 1-2
Installation ................................................................................................................................... 1-2
Server-Side Components ................................................................................................................. 1-3
SDK Architecture ..................................................................................................................................... 1-3
System Requirements.............................................................................................................................. 1-4
Java Requirements ................................................................................................................................... 1-4
JVM Parameters for Preventing Out of Memory Exceptions ................................................... 1-4
Agile SDK Installation Folders ............................................................................................................. 1-5
Checking Your Agile PLM System ....................................................................................................... 1-6
Agile PLM Business Objects.................................................................................................................. 1-6
iii
Creating a Session in a Cluster Environment.............................................................................. 2-7
Loading and Creating Agile PLM Objects .......................................................................................... 2-7
Loading Objects................................................................................................................................. 2-8
Specifying Object Types............................................................................................................. 2-8
Specifying Object Parameters........................................................................................................ 2-9
Loading Different Types of Objects.......................................................................................... 2-9
Creating Objects ............................................................................................................................. 2-11
Working with Agile PLM Classes ......................................................................................... 2-12
Creating Objects of User-Defined Subclasses ............................................................................ 2-12
Using AutoNumbers .................................................................................................................. 2-13
Setting the Required Fields......................................................................................................... 2-14
Creating Different Types of Objects ........................................................................................... 2-15
Checking the State of Agile PLM Objects................................................................................. 2-19
Propagating Values to Related Objects ..................................................................................... 2-19
Saving an Object to a New Object.............................................................................................. 2-19
Sharing an Object........................................................................................................................... 2-20
Deleting and Undeleting Objects ............................................................................................... 2-21
Closing a Session ........................................................................................................................... 2-22
iv
Sorting Query Results Using SQL Syntax ................................................................................ 3-19
Setting Result Attributes for a Query ............................................................................................... 3-20
Specifying Result Attributes ....................................................................................................... 3-23
Retrieving the CTO Originator Name ....................................................................................... 3-24
Duplicate Results for Site-Related Objects and AMLs .......................................................... 3-24
Working with Query Results ............................................................................................................. 3-24
Sorting Query Results ................................................................................................................... 3-25
Query Result Datatypes................................................................................................................ 3-25
Using Admin Preferences Attributes to Manage Queries and Reports .............................. 3-25
Setting the Maximum Query Results Displayed ....................................................................... 3-25
Setting Maximum BOM Report Results ................................................................................... 3-26
Selecting Search Results Based on Table or Row ....................................................................... 3-26
Query Performance ........................................................................................................................ 3-27
Creating a Where-Used Query............................................................................................................ 3-27
Loading a Query .................................................................................................................................... 3-28
Deleting Saved Queries ....................................................................................................................... 3-29
Simple Query Examples....................................................................................................................... 3-29
v
Updating Objects in Query Results with Multiple Page Tables .......................................... 4-14
Sorting Table Rows............................................................................................................................... 4-15
Removing Table Rows ......................................................................................................................... 4-16
Retrieving the Referenced Object for a Row ................................................................................... 4-17
Checking the Status Flags of a Row .................................................................................................. 4-20
Working with Page 1, Page 2, and Page 3 ........................................................................................ 4-21
Working with Revisions and Relationships .................................................................................... 4-21
Setting and Getting Flags for Revision Controlled Relationship Rows .................................. 4-21
Getting Flags on Relationships Tab when Adding Revision Controlled Object Revisions ....
4-22
Setting Different Relationships and Revisions for Items ................................................... 4-23
Redlining ................................................................................................................................................ 4-23
Redlining BOMs, Manufacturers, and Price Lines Tables ........................................................ 4-23
Redlining the Manufacturers table of an item ..................................................................... 4-24
Redlining the Title Block of an Item ............................................................................................. 4-25
Removing Redline Changes................................................................................................................ 4-25
Removing Redline Changes in Bulk Mode .............................................................................. 4-25
Identifying Redlined Rows and Redlined Cells............................................................................. 4-26
Using ICell.getOldValue .............................................................................................................. 4-26
vi
7 Working with Items, BOMs, and AMLs
Working with Items ................................................................................................................................. 7-1
Supported Page 2 Item Attributes ................................................................................................... 7-1
Getting and Setting the Revision of an Item ............................................................................... 7-1
Failing to get a of an Item using the Title Block.Rev field .................................................... 7-3
Changing the Incorporated Status of a Revision ........................................................................ 7-4
Working with BOMs ............................................................................................................................... 7-4
Adding an Item to a BOM .............................................................................................................. 7-4
Expanding a BOM ............................................................................................................................. 7-5
Copying one BOM into another BOM .......................................................................................... 7-6
Creating BOM-Related Product Reports ...................................................................................... 7-6
Redlining a BOM .............................................................................................................................. 7-8
Getting a Released Assembly Item................................................................................................. 7-8
Creating a Change Order .............................................................................................................. 7-9
Adding Items to the Affected Items tab of a Change Order........................................................... 7-9
Modifying the Redline BOM Table ....................................................................................... 7-10
Working with AMLs ............................................................................................................................. 7-11
Adding an Approved Manufacturer to the Manufacturers Table ........................................ 7-11
Updating AML Split Percentages in Sourcing Projects.......................................................... 7-12
Retrieving AML Data from the Item Master ............................................................................ 7-13
Redlining an AML ......................................................................................................................... 7-14
vii
10 Managing Manufacturing Sites
About Manufacturing Sites ................................................................................................................. 10-1
Controlling Access to Sites.................................................................................................................. 10-1
Creating a Manufacturing Site ........................................................................................................... 10-2
Loading a Manufacturing Site ............................................................................................................ 10-2
Retrieving the Sites Table for an Item .............................................................................................. 10-3
Adding a Manufacturing Site to the Sites Table............................................................................. 10-3
Selecting the Current Manufacturing Site of an Item.................................................................... 10-4
Disabling a Site...................................................................................................................................... 10-5
viii
Deleting a List............................................................................................................................... 12-19
Printing Contents of IAgileList Objects ......................................................................................... 12-19
ix
Validating MSP Import Data ......................................................................................................... 14-5
Importing MSP Data................................................................................................................ 14-6
Create Mode ...................................................................................................................... 14-6
Update Mode..................................................................................................................... 14-7
Exporting MSP Data ................................................................................................................ 14-7
API Signature .................................................................................................................... 14-7
15 Managing Workflow
About Workflow ................................................................................................................................... 15-1
The Change Control Process ............................................................................................................... 15-1
Dynamics of Workflow Functionality............................................................................................... 15-2
How the Status of a Change Affects Workflow Functionality.............................................. 15-2
How User Privileges Affect Workflow Functionality............................................................. 15-3
Selecting a Workflow ........................................................................................................................... 15-3
Adding and Removing Approvers..................................................................................................... 15-4
Approving or Rejecting Change.................................................................................................. 15-6
Approving or Rejecting a Change Without Password............................................................ 15-8
Commenting a Change.................................................................................................................. 15-8
Auditing a Change ......................................................................................................................... 15-8
Changing the Workflow Status of an Object .......................................................................... 15-9
Sending an Agile Object to Selected Users............................................................................. 15-12
Sending an Agile Object to User Groups ................................................................................ 15-13
Managing Functional Teams............................................................................................................. 15-13
Job Functions, Functional Teams, and Workflow Actions .................................................. 15-14
Creating a Functional Team ....................................................................................................... 15-14
Managing Timesheets ................................................................................................................. 15-15
Retrieving Tasks Users Can Log Time Against ....................................................................... 15-15
Logging or Modifying the Reported Time for a User on a Task............................................... 15-16
Retrieving Hours for a Given User or Activity........................................................................ 15-16
Creating a Job Functions Table ................................................................................................. 15-16
Adding a Discussion to a Functional Team ............................................................................ 15-17
Assigning Actions Items to Functional Teams ........................................................................ 15-17
Updating a Functional Team's News Table............................................................................. 15-18
x
Assigning a Product Service Request to a Quality Analyst................................................... 16-4
Adding Affected Items to a Product Service Request............................................................. 16-5
Adding Related PSRs to a Product Service Request ............................................................... 16-5
Working with Quality Change Requests.......................................................................................... 16-6
Creating a Quality Change Request ........................................................................................... 16-7
Assigning a Quality Change Request to a Quality Administrator....................................... 16-7
Saving a Quality Change Request as a Change ....................................................................... 16-7
Using Workflow Features with PSRs and QCRs ............................................................................ 16-8
Selecting Workflows for PSRs and QCRs ................................................................................ 16-8
xi
Setting Values in the Calculated Compliance Field for Item Objects ...................................... 17-25
Setting Values in the Calculated Compliance Field for Declaration Objects........................... 17-25
Setting Values in Calculated Overall Compliance Fields of Item and Manufacturer Part Objects .....
17-26
Modifying the Calculated Compliance Field in Specification Table of Part, Manufacturer Part, and
Part Group Objects 17-27
Modifying Settings in the Scheduled Rollups of Declarations................................................. 17-28
Performing External Compliance Rollups on Specification Objects........................................ 17-28
Updating Values of Calculated Compliance Attributes Against External Specifications........
17-29
Creating External or Internal Specifications............................................................................ 17-29
Using the IDeclaration Interface ............................................................................................... 17-30
Modifying value of the Calculated Compliance field of Declarations ...................................... 17-30
xii
Working with Discussions ................................................................................................................ 19-17
Creating a Discussion.................................................................................................................. 19-17
Replying to a Discussion ............................................................................................................ 19-19
Joining a Discussion .................................................................................................................... 19-21
Creating an Action Item.............................................................................................................. 19-22
20 Handling Exceptions
About Exceptions................................................................................................................................... 20-1
Exception Constants ...................................................................................................................... 20-2
Getting Error Codes .............................................................................................................................. 20-2
Disabling and Enabling Error Codes with Bulk APIs ................................................................... 20-2
Getting Error Messages ........................................................................................................................ 20-3
Disabling and Enabling Warning Messages.................................................................................... 20-4
Checking if APIException is Warning and not Error ..................................................................... 20-5
Saving and Restoring State Enabled and Disabled Warnings ..................................................... 20-5
Warnings on Deleting Objects Disabled Automatically by Agile API ...................................... 20-6
xiii
Updating PLM content from the Item Master ......................................................................... 21-16
Updating Selected Attributes on Item Table of Sourcing Projects from Item Master ......
21-17
Performing Quantity Rollups in Sourcing Projects ................................................................ 21-17
Performing Cost Rollup in Sourcing Projects.......................................................................... 21-18
Performing Price Lookup in Sourcing Projects ........................................................................ 21-18
Price Lookup API and Price Options ....................................................................................... 21-19
Parameters specific to price lookups from price history.................................................. 21-20
Parameters specific to price lookups from Sourcing Projects.......................................... 21-21
Required parameters for price lookups from price history ............................................. 21-21
Setting the price lookup from Sourcing Projects .............................................................. 21-21
Setting the price lookup from History or Sourcing Projects............................................ 21-21
Settings for Quantity Breaks in price lookups.......................................................................... 21-21
Impact of improper parameter settings..................................................................................... 21-22
Settings for RFQ lookup........................................................................................................ 21-22
Settings for RFQ lookup........................................................................................................ 21-22
Generating the Assembly Cost Report for Sourcing Projects.......................................... 21-23
Understanding Assembly Cost Report Parameters.................................................................. 21-24
Modifying the Target Price for Items in Sourcing Projects ..................................................... 21-25
Setting the Best Response for Items in Sourcing Projects........................................................ 21-26
Setting Partners in Sourcing Projects...................................................................................... 21-26
Managing Sourcing Project Attachments for Items and AMLs .......................................... 21-28
Adding Sourcing Project Attachments by File Type................................................................ 21-28
Deleting Sourcing Project Table Rows for Items ..................................................................... 21-28
Importing Data for Sourcing Projects...................................................................................... 21-29
Validating Items on the AML Tab of Sourcing Projects.......................................................... 21-29
Working with RFQs..................................................................................................................... 21-30
Supported API Methods ........................................................................................................... 21-30
Creating RFQs for Sourcing Projects....................................................................................... 21-31
Loading RFQs from Sourcing Project's RFQ Table ............................................................... 21-31
Supported RFQ Tables.............................................................................................................. 21-32
Accessing and Modifying RFQ Objects, Tables, Nested Tables, and Attributes..................... 21-32
RFQ Parent Table and Nested Child Table Constants............................................................. 21-32
Performing Price Lookup in RFQs ........................................................................................... 21-33
Working with RFQ Responses ................................................................................................. 21-34
Locking and Unlocking RFQ Responses .................................................................................. 21-35
Editing RFQ Responses Submitted by Suppliers .................................................................... 21-35
xiv
Concrete and Abstract Classes .................................................................................................. 22-11
Referencing Classes ..................................................................................................................... 22-12
Identifying the Target Type of a Class .................................................................................... 22-12
Working with Attributes.................................................................................................................... 22-13
Referencing Attributes................................................................................................................ 22-13
Retrieving Attributes................................................................................................................... 22-14
Retrieving Individual Attributes .............................................................................................. 22-15
Editing the Property of an Attribute ........................................................................................ 22-15
Working with User-Defined Attributes .................................................................................. 22-16
Working with Properties of Administrative Nodes ..................................................................... 22-16
Managing Users ................................................................................................................................... 22-17
Getting all Users........................................................................................................................... 22-17
Creating a User ............................................................................................................................. 22-17
Creating a User Group ................................................................................................................ 22-18
Creating Users and Requiring Password Modification at Login........................................ 22-19
Creating a Supplier User ............................................................................................................ 22-20
Saving a User as a New User...................................................................................................... 22-20
Configuring User Settings.......................................................................................................... 22-21
Resetting User Passwords........................................................................................................... 22-22
Deleting a User ............................................................................................................................. 22-22
Managing User Groups ...................................................................................................................... 22-22
Getting All User Groups............................................................................................................. 22-23
Creating a User Group ................................................................................................................ 22-23
Adding a User Group to the User Group Table of the User ................................................ 22-24
Listing Users in a User Group ................................................................................................... 22-25
xv
xvi
Preface
Agile PLM is a comprehensive enterprise PLM solution for managing your product
value chain.
Audience
This document is intended for administrators and users of the Agile PLM products.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle
Accessibility Program website at
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.
Related Documents
Oracle's Agile PLM documentation set includes Adobe® Acrobat PDF files. The Oracle
Technology Network (OTN) website at:
http://www.oracle.com/technetwork/documentation/agile-085940.html contains
the latest versions of the Agile PLM PDF files. You can view or download these
manuals from the Web site, or you can ask your Agile administrator if there is an Agile
PLM Documentation folder available on your network from which you can access the
Agile PLM documentation (PDF) files.
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface elements associated
with an action, or terms defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or placeholder variables for
which you supply particular values.
xvii
Convention Meaning
monospace Monospace type indicates commands within a paragraph, URLs, code
in examples, text that appears on the screen, or text that you enter.
xviii
1
Introduction
1
Introduction 1-1
SDK Components
SDK Components
The Agile SDK has the following Client-side and Sever-side components:
Client-Side Components
The contents of the Agile SDK Client-side components are:
Documentation
■ SDK Developer Guide (this manual)
■ API Reference files (these are the Javadoc generated HTML files that document the
API methods)
■ Sample applications
Note: The API HTML reference files and Sample applications are in the
SDK_samples.zip folder. You can find this folder at
http://www.oracle.com/technetwork/indexes/samplecode/agileplm-
sample-520945.html. For more information and procedures to access its
contents, contact your system administrator, or refer to your PLM
installation guide.
Installation
■ Agile API library (AgileAPI.jar)
■ Java Process Extensions API library (pxapi.jar)
■ Apache Axis library (axis.jar)
1-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
SDK Architecture
Server-Side Components
Oracle's Agile Application Server contains the following SDK server-side components:
■ Agile API implementation classes
■ Java and Scripting process extensions framework
■ Web service extensions frameworks
SDK Architecture
The SDK facilitates developing different types of programs to connect to the Agile
Application Server. If you are using only the Agile APIs, these programs connect
directly to the server. For information to develop these types of programs, refer to SDK
Developer Guide - Using Agile APIs.
If you are using WSX to develop Web service extensions, you can deploy the Web
services inside the Agile Application Server container. The Web server used for WSX is
accessible from inside or outside the company's demilitarized computing zone (DMZ)
or perimeter network. Information for developing Web service extensions is provided
in this document.
When the Agile PLM Client initiates a custom action, it either runs a program that is
deployed on the server, or connects to an external resource such as a URL. WSX, Java
PX and Script PX extensions can also use the Agile APIs. You can develop extensions
using APIs that are not provided by Agile. This information is also provided in this
document.
Introduction 1-3
System Requirements
System Requirements
For Agile SDK system requirements, refer to PLM Capacity Planning and Deployment
Guide.
Java Requirements
The Agile API must be compatible with the version of Java that the application server
supports. To avoid problems, an Agile API Client must use the same version of Java
that the connecting application server is using. Oracle Application Server 10g must use
Sun Java Runtime Environment (JRE) 1.5.0_06 and Oracle WebLogic Server 10.3 must
use Sun Java Runtime Environment (JRE) 1.6 for interoperability and 2007 Daylight
Saving Time compliance.
The following table lists the recommended Java Runtime Environment (JRE) to use
with Agile API Clients on different application servers that Agile PLM supports.
1-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Agile SDK Installation Folders
■ If the Client is a PX and out of memory occurs in Agile Server, add the JVM option
in <OAS_HOME>/opmn/conf/opmn.xml.
<category id="start-parameters">
<data id="java-options" value="-Xrs -server -XX:MaxPermSize=256M -ms1280M
-mx1280M -XX:NewSize=256M -XX:MaxNewSize=256M -XX:AppendRatio=3
-Doracle.xdkjava.compatibility.version=10.1.0 -Djava.security.policy=$ORACLE_
HOME/j2ee/home/config/java2.policy -Dagile.log.dir=$ORACLE_HOME/j2ee/home/log
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9899
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false -Djava.awt.headless=true
-Dhttp.webdir.enable=false -Duser.timezone=GMT
-Ddisable.agile.sessionID.generation=true"/>
<data id="oc4j-options" value="-verbosity 10 -userThreads"/>
</category>
■ If the Client is a URL PX, add the following JVM option in the Server Start up
(This is similar to catalina.bat in Tomcat.)
-Ddisable.agile.sessionID.generation=true
Note: Do not include the axis.jar file and AgileAPI.jar file in the
same classpath. The SDK classpath does not support this setting and
the SDK will not function properly.
■ AgileAPI.jar - Agile API library. This file contains Agile API classes and
interfaces.
■ axis.jar - An Oracle-modified version of the Apache Axis library. This is required
for Web service Clients.
■ pxapi.jar - PX API library.This file contains interfaces used to develop custom
autonumber sources and custom actions.
Introduction 1-5
Checking Your Agile PLM System
4. When the login window appears, type the username and password.
You can log in with the built-in Administrator account by typing admin for the
user and the password you supplied as the password for the admin user in the
password management screen during installation.
The first time you log in to the application, it may take a while to load the
information. For more information, refer to the Agile PLM Installation Guide.
1-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Agile PLM Business Objects
* Agile does not support the API interfaces in the current release of the software.
The business objects that you can view and actions that you can perform on these
objects are determined by the server components installed on your Agile Application
Server and the assigned privilege roles to that are assigned to your user account.
Privilege levels can vary from field to field. In addition to Users and User Groups,
Agile PLM administrators work with administrative objects, such as administrative
nodes and Agile PLM classes.
Note: Not all Agile PLM business objects are exposed in the Agile
API. For example, some Report objects are not accessible via the Agile
API.
Introduction 1-7
Agile PLM Business Objects
1-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
2
Getting Started with Agile API
2
Network class loading provides many benefits, including the ability to update client
implementation classes by automatically downloading them from a server. Any Agile
API classes that are downloaded from the server are automatically cached to a local
disk. When an Agile API program needs to load a particular class, it retrieves it from
the cache rather than downloading it again from the network. The cache results in
faster loading of classes and reduced network load.
If the network class loader detects that its cache is stale, that is, its classes are older
than the classes on the server, it invalidates the cache and reloads the necessary classes
from the server. This allows you to update Agile SDK Clients to use the latest
implementation classes without redeploying applications throughout the enterprise.
2-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Starting an Agile API Program
Sample Programs
The Agile SDK provides several sample programs that demonstrate how to use its
APIs. These sample programs are in the api, dx, px, and wsx folders. You can find them
in the SDK_samples (ZIP file). To access this file, see the Note in "Client-Side
Components" on page 1-2.
Each sample program has its own Readme.txt file. Be sure to review the Readme.txt
document before trying to run a sample program.
4. Complete one or more business processes. This is where most of your program
code goes.
5. Close the Agile session.
Rather than importing the com.agile.api package, you can also refer to Agile API
classes by their full package name, for example:
com.agile.api.IItem source =
(com.agile.api.IItem)m_session.getObject(com.agile.api.IItem.OBJECT_TYPE,
"1000-02");
As you can see, if you do not import the com.agile.api package, it is cumbersome to
type the full package name whenever you refer to one of its classes. Also, when you
don't import the com.agile.api package, or reference the Agile API classes by full
package name, the Java compiler will return an error when you try to build your
program.
2-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Starting an Agile API Program
To start an Agile API program, you must complete the following two tasks:
1. Get an instance of the Agile Application Server.
factory = AgileSessionFactory.getInstance(URL);
HashMap params = new HashMap();
params.put(AgileSessionFactory.USERNAME, USERNAME);
params.put(AgileSessionFactory.PASSWORD, PASSWORD);
session = factory.createSession(params);
Your Oracle Agile PLM agreement determines the maximum number of concurrent
open sessions to the Agile Application Server per user account. If you exceed this
maximum number, the server prevents you from logging in. Therefore, it is important
to use the IAgileSession.close() method to properly log out and close a session
when your program is finished running. If the Agile PLM system is hosted on Oracle
Application Servers, you are limited to only one session per thread.
The createSessionEx()method also works for URLs that are not password-protected
and you can use it instead of createSessionEx() if you prefer.
If you pass a null value for the params parameter of createSession(), the user
authentication that took place when the Agile PLM server intercepted the web service
request is reused for the Agile API session. You don't need to log in again. Do not
attempt to close the session using IAgileSession.close(); the authorization handler
will automatically close the session.
Specifying a null parameter for the createSession() method creates an
IAgileSession corresponding to the session created by the authorization handler. If
your web service doesn't use the authorization handler, or if you want to create a
session for a different user than the one used for the authorization handler, you can
still use createSession(params) to create a session. For the params parameter, specify
a Map object containing the login parameters (username and password). If you don't
2-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
use the authorization handler to create a session, you are responsible for closing it. Call
the IAgileSession.close() method to close the session.
To load and create these Agile PLM objects, you must first get an instance of the
AgileSessionFactory object and then create an Agile PLM session. Then use
IAgileSession.getObject() to load Agile PLM objects
andIAgileSession.createObject() to create objects.
For more information about creating queries and folders, see Chapter 3, "Creating and
Loading Queries" and Working with Folders.
Loading Objects
To load an Agile PLM object, use one of the IAgileSession.getObject()methods.
■ IAgileObject getObject(Object objectType, Object params)
■ IAgileObject getObject(int objectType, Object params)
Note: If not specified by the user, objects will always load according
to their base class which are derived from the subclass or class. Objects
will also load correctly when the object's derived base class is correct.
However, the SDK will load an object even if an invalid subclass is
passed for that object when the derived base class of the invalid class
and that of the object are both the same.
Note: When you use the getObject() method to load an object, you
can specify abstract or concrete Agile PLM classes. For more
information, see "Concrete and Abstract Classes" on page 22-9.
2-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
If the object you're loading has a single attribute that serves as a unique identifier, you
can enter the String value for that attribute as the params parameter. For example, the
unique identifier for a part is a part number. Therefore, you can enter the part number
as the parameter to load the object.
Note: Not all objects have one attribute that serves as a unique
identifier. For example, a manufacturer part is identified by both its
manufacturer name and manufacturer part number. Therefore, to load
a manufacturer part you must specify values for at least those two
attributes.
This example shows how to load part 1000-02 by specifying a unique String identifier.
Example 2–7 Loading Agile PLM Item, Manufacturer, and Manufacturer Parts objects
///Load an item
IItem item = (IItem)m_session.getObject(IItem.OBJECT_TYPE, "1000-02");
System.out.println("Item : " + item.getName());
//Load a manufacturer
IManufacturer mfr = (IManufacturer)m_session.getObject(IManufacturer.OBJECT_TYPE);
params.put(ManufacturerPartConstants.ATT_GENERAL_INFO_MANUFACTURER_PART_NUMBER,
"WE10023-45");
IManufacturerPart mfrPart =
(IManufacturerPart)m_session.getObject(IManufacturerPart.OBJECT_TYPE, params);
System.out.println("ManufacturerPart : " + mfrPart.getName());
//Load a declaration
IDeclaration dec = (IDeclaration)m_session.getObject(IDeclaration.OBJECT_TYPE,
"MD00001");
System.out.println("Declaration : " + dec.getName());
Example 2–9 Loading Agile PLM Discussion, File Folder and Folder objects
//Load a discussion
IDiscussion discussion = (IDiscussion)m_session.getObject(IDiscussion.OBJECT_TYPE,
"D00002");
System.out.println("Discussion : " + discussion.getName());
//Load a folder
IFolder folder = (IFolder)m_session.getObject(IFolder.OBJECT_TYPE, "/Personal
Searches/MyTemporaryQueries");
System.out.println("Folder : " + folder.getName());
Example 2–10 Loading Agile PLM Package, Price, Program, PSR, and QCR objects
//Load a package
IPackage pkg = (IPackage)m_session.getObject(PackageConstants.CLASS_PACKAGE,
"PKG00010");
System.out.println("Package : " + pkg.getName());
//Load a price
IPrice price =
(IPrice)m_session.getObject(IPrice.OBJECT_TYPE, "PRICE10008");
System.out.println("Price : " + price.getName());
//Load a program
IProgram program =
(IProgram)m_session.getObject(IProgram.OBJECT_TYPE, "PGM10008");
System.out.println("Program : " + program.getName());
//Load a PSR
IServiceRequest psr = (IServiceRequest)m_session.getObject(IServiceRequest.OBJECT_
TYPE, "NCR01562");
System.out.println("PSR : " + psr.getName());
2-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
//Load a QCR
IQualityChangeRequest qcr =
(IQualityChangeRequest)m_session.getObject(IQualityChangeRequest.OBJECT_TYPE,
"CAPA02021");
System.out.println("QCR : " + qcr.getName());
Example 2–11 Loading Agile PLM Change, Commodity, and Supplier objects
//Load a change
IChange change = (IChange)m_session.getObject(IChange.OBJECT_TYPE, "C00002");
System.out.println("Change : " + change.getName());
//Load a commodity
ICommodity comm =
(ICommodity)m_session.getObject(ICommodity.OBJECT_TYPE, "Res");
System.out.println("Commodity : " + comm.getName());
//Load a supplier
ISupplier supplier =
(ISupplier)m_session.getObject(ISupplier.OBJECT_TYPE, "SUP20013");
System.out.println("Supplier : " + supplier.getName());
Creating Objects
You can use one of the following IAgileSession.createObject() methods create an Agile
PLM object.
■ IAgileObject createObject(Object objectType, Object params)
■ IAgileObject createObject(int objectType, Object params)
Note: The SDK does not support setting the Lifecycle Phase
(LCP)/Workflow status attribute of an object while you are creating
that object. The reason is that the necessary settings for LCP are not
available until after the object is created. The same is also applicable in
the UI. For example, IChange will not get Workflow status values until
a Workflow is selected. However, you can use the SDK to create
objects, and then set and modify the LCP/Workflow status attribute.
Also, you cannot get a list of values for this field, until the object is
created, and the relevant actions are performed on the object.
The objectType and params parameters are identical to those used in the
IAgileSession.getObject() methods; for more information, see "Loading Objects" on
page 2-8. Except for IFolder and IQuery objects, you must specify a concrete class for
the objectType parameter. For example, if you are creating a part, you cannot specify
ItemConstants.CLASS_PARTS_CLASS because that class is an abstract class that can't be
instantiated. However, you can specify the class ID of any predefined or user-defined
concrete class, such as ItemConstants.CLASS_PART.
If you are creating an object of a user-defined subclass, the objectType parameter of
createObject()should be an Integer object corresponding to the subclass ID.
In addition to a Map or String type, the params parameter for
IAgileSession.createObject() can also be an INode object representing an
autonumber source for the particular object class. The Agile Application Server queries
the autonumber source for the next number in its sequence, and that number is used
as the unique identifier.
Note: You cannot specify an INode object for the params parameter
for objects that don't have their autonumber sources available.
The following example shows how to create part 1000-02 using a Map parameter that
specifies an attribute (ItemConstants.ATT_TITLE_BLOCK_NUMBER) and a value.
The following example shows how to create part 1000-02 by specifying a unique String
identifier.
2-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
m_admin.getAgileClasses(IAdmin.CONCRETE);
for (int i = 0; i < classes.length; i++) {
if (classes[i].getName().equals("Resistor")) {
classResistor = (Integer)classes[i].getId();
break;
}
}
//Create a Resistor object
if (classResistor != null) {
IItem resistor =
(IItem)m_session.createObject(classResistor, "R10245");
}
Of course, you can also reference a user-defined subclass by name, as in the following
example. However, class names are not necessarily unique. If there are two subclasses
with the same name, the Agile API matches the first one found, which may not be the
one you intended.
Using AutoNumbers
An Agile PLM class can have one or more AutoNumber sources. An AutoNumber source
is a predefined sequence of numbers that automatically number an object. AutoNumber
sources are defined in the administrative functionality of Agile Java Client.
You must configure your Agile Application to use AutoNumber when you create an
object of a particular class. However, the Agile API does not enforce automatic
numbering of objects, even when it is required for a particular class. If your
environment requires this capability, you must develop the necessary routine. Thus, if
you develop a GUI program that allows users to create Agile PLM objects, make sure
the user interface enforces automatic numbering when it is required. For an example of
how a client program enforces automatic numbering, create a few objects using Agile
Web Client and note how the user interface works.
if (numSources[i].getName().equals("Part Number")) {
String nextAutoNumber = numSources[i].getNextNumber();
IItem part = (IItem)session.createObject(ItemConstants.CLASS_PART,
nextAutoNumber);
System.out.println("Item: " + part.getName() + " created");
}
}
return null; \\Only needed if not in main method
2-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
Example 2–19 Getting the required Page 1, 2, and 3 Attributes for the Class
public IAttribute[] getRequiredAttributes(IAgileClass cls) throws APIException {
//Create an array list for the results
ArrayList result = new ArrayList();
Note: Primary key fields that are used to create an object are
required regardless of the setting for the Required property. For
example, for items the [Title Block.Number] field must be specified to
create a new item regardless whether the field is required.
Example 2–20 Creating Change, Commodity, Customer, Declaration, File Folder, Folder,
Item, and Discussion
//Create a change
IChange eco =
(IChange)m_session.createObject(ChangeConstants.CLASS_ECO, "C00002");
System.out.println("Change : " + eco.getName());
//Create a commodity
ICommodity comm =
(ICommodity)m_session.createObject(CommodityConstants.CLASS_COMMODITY,"RES");
System.out.println("Commodity : " + comm.getName());
//Create a customer
Map params = new HashMap();
params.put(CustomerConstants.ATT_GENERAL_INFO_CUSTOMER_NUMBER, "CUST00006");
params.put(CustomerConstants.ATT_GENERAL_INFO_CUSTOMER_NAME, "Western Widgets");
ICustomer customer =
(ICustomer)m_session.createObject(CustomerConstants.CLASS_CUSTOMER, params);
System.out.println("Customer : " + customer.getName());
//Create a declaration
Map params = new HashMap();
ISupplier supplier =
(ISupplier)m_session.getObject(ISupplier.OBJECT_TYPE, "SUP20013");
params.put(DeclarationConstants.ATT_COVER_PAGE_NAME, "MD00001");
params.put(DeclarationConstants.ATT_COVER_PAGE_SUPPLIER, supplier);
IDeclaration dec = (IDeclaration)
m_session.createObject(DeclarationConstants.CLASS_SUBSTANCE_DECLARATION, params);
System.out.println("Declaration : " + dec.getName());
//Create a discussion
Map params = new HashMap();
params.put(DiscussionConstants.ATT_COVER_PAGE_NUMBER, "D000201");
params.put(DiscussionConstants.ATT_COVER_PAGE_SUBJECT, "Packaging issues");
IDiscussion discussion =
(IDiscussion)m_session.createObject(DiscussionConstants.CLASS_DISCUSSION, params);
System.out.println("Discussion : " + discussion.getName());
//Create a folder
Map params = new HashMap();
IFolder parentFolder =
(IFolder)m_session.getObject(IFolder.OBJECT_TYPE, "/Personal Searches");
params.put(FolderConstants.ATT_FOLDER_NAME, "MyTemporaryQueries");
params.put(FolderConstants.ATT_PARENT_FOLDER, parentFolder);
IFolder folder = (IFolder)m_session.createObject(IFolder.OBJECT_TYPE, params);
System.out.println("Folder : " + folder.getName());
2-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
//Create a manufacturer
IManufacturer mfr =
(IManufacturer)m_session.createObject(ManufacturerConstants.CLASS_MANUFACTURER);
System.out.println("Manufacturer : " + mfr.getName());
//Create a price
Map params = new HashMap();
params.put(PriceConstants.ATT_GENERAL_INFORMATION_NUMBER, "PRICE10008");
params.put(PriceConstants.ATT_GENERAL_INFORMATION_CUSTOMER, "CUST00006");
params.put(PriceConstants.ATT_GENERAL_INFORMATION_ITEM_NUMBER, "1000-02");
params.put(PriceConstants.ATT_GENERAL_INFORMATION_ITEM_REV, "B");
params.put(PriceConstants.ATT_GENERAL_INFORMATION_PROGRAM, "PROGRAM0023");
params.put(PriceConstants.ATT_GENERAL_INFORMATION_MANUFACTURING_SITE, "San Jose");
params.put(PriceConstants.ATT_GENERAL_INFORMATION_SUPPLIER, "SUP20013");
IPrice price =
(IPrice)m_session.createObject(PriceConstants.CLASS_PUBLISHED_PRICE, params);
System.out.println("Price : " + price.getName());
//Create a program
DateFormat df =
new SimpleDateFormat("MM/dd/yy");
IAttribute attr =
//Create a QCR
IAgileList list = attr.getAvailableValues();
list.setSelection(new Object[] {"Fixed"});
params.clear();
params.put(ProgramConstants.ATT_GENERAL_INFO_NAME, "Wingspan Program");
params.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_START_DATE,
df.parse("06/01/05"));
params.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_END_DATE,
df.parse("06/30/05"));
params.put(ProgramConstants.ATT_GENERAL_INFO_DURATION_TYPE, list);
IProgram program = (IProgram)m_session.createObject(ProgramConstants.CLASS_
PROGRAM, params);
System.out.println("Program : " + program.getName());
//Create a PSR
IServiceRequest psr =
(IServiceRequest)m_session.createObject(ServiceRequestConstants.CLASS_NCR,
"NCR01562");
System.out.println("PSR : " + psr.getName());
IQualityChangeRequest qcr = (IQualityChangeRequest)m_session.createObject(
QualityChangeRequestConstants.CLASS_CAPA, "CAPA02021");
System.out.println("QCR : " + qcr.getName());
}
Example 2–22 Creating a Query, Specification, Substance, Transfer Order, User, and
User Group
//Create a query
params.clear();
IFolder parent =
(IFolder)m_session.getObject(IFolder.OBJECT_TYPE, "/Personal Searches");
String condition =
//Create a specification
params.put(QueryConstants.ATT_CRITERIA_CLASS, ItemConstants.CLASS_ITEM_BASE_
CLASS);
params.put(QueryConstants.ATT_CRITERIA_STRING, condition);
params.put(QueryConstants.ATT_PARENT_FOLDER, parent);
params.put(QueryConstants.ATT_QUERY_NAME, "Part Numbers Starting with P");
IQuery query =
"[Title Block.Number] starts with 'P'";
(IQuery)m_session.createObject(IQuery.OBJECT_TYPE, params);
System.out.println("Query : " + query.getName());
ISpecification spec = (ISpecification)
m_session.createObject(SpecificationConstants.CLASS_SPECIFICATION, "WEEE");
System.out.println("Specification : " + spec.getName());
//Create a substance
ISubstance sub =
(ISubstance)m_session.createObject(SubstanceConstants.CLASS_SUBSTANCE, "Cadmium");
System.out.println("Substance : " + spec.getName());
//Create a user
params.clear();
params.put(UserConstants.ATT_GENERAL_INFO_USER_ID, "OWELLES");
params.put(UserConstants.ATT_LOGIN_PASSWORD, "agile");
IUser user =
(IUser)m_session.createObject(UserConstants.CLASS_USER, params);
System.out.println("User : " + user.getName());
2-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
Example 2–23 Getting the array that defines the different states of an object
IChange change =
(IChange)session.getObject(ChangeConstants.CLASS_ECO, "ECO-1000-01");
IWorkflow assignedWorkflow = change.getWorkflow();
IStatus[] allStates = assignedWorkflow.getStates();
for (int i = 0; i < allStates.length; i++) {
System.out.println(i + ", " + allStates[i].getName());
must specify the subclass that you are using to save the object and the object number.
If the subclass supports it, you can use an AutoNumber.
This example shows how to save the current object to a new object using the next
AutoNumber for the specified subclass.
Sharing an Object
The IShareable interface is implemented by every Agile PLM business object that is
exposed by Agile APIs. Therefore, every business object sharable. Sharing enables you
to grant one or more of your roles to another Agile PLM user or an Agile PLM user
group for a specific object. The roles you can assign when you share an object include
your assigned or permanent roles and any roles assigned to you from membership in a
user group.
Users that have shared an object, can perform actions permitted by the roles for that
object only. They do not acquire the roles in a global fashion.
The IShareable interface has only two methods, getUsersAndRoles() and
setUsersAndRoles(). The getUsersAndRoles() method returns a Map object. Each user
in the Map has an associated array of roles. The setUsersAndRoles()method has one
parameter, a Map object which similar to the Map returned by getUsersAndRoles()
which maps each user to an array of roles. Each user can be assigned a different
selection of roles.
There are two method, getDataForSharing() and shareItem() for this sample.
Corrected the method name getDataForSharing() and added comment for each
method in the guide
//Get item
IItem item = (IItem)m_session.getObject(ItemConstants.CLASS_ITEM_BASE_CLASS,
"P10011");
//Get users
IUser user1 = (IUser)m_session.getObject(UserConstants.CLASS_USER, "albertl");
IUser user2 = (IUser)m_session.getObject(UserConstants.CLASS_USER, "peterl");
IUser[] users = new IUser[]{user1, user2};
2-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Loading and Creating Agile PLM Objects
//Get roles
INode nodeRoles = (INode)m_session.getAdminInstance().getNode(NodeConstants.NODE_
ROLES);
IRole role1 = (IRole)nodeRoles.getChildNode("Component Engineer");
IRole role2 = (IRole)nodeRoles.getChildNode("Incorporator");
IRole[] roles = new IRole[]{role1, role2};
/**
* Share the specified Item for specified users with specified roles
*/
private void shareItem(IItem item,IUser[] users, IRole[] roles) throws Exception {
Map map = new HashMap();
for (int i = 0; i < users.length; i++) {
map.put(users[i], roles);
}
IShareable shareObj = (IShareable)item;
shareObj.setUsersAndRoles(map);
}
Note: Each user and user group has a Share table that lists objects
that have been shared and which roles have been granted for those
objects.
To restore an object that has been soft-deleted, use the IDataObject.undelete() method.
Once again, to undelete an object, the user must have Undelete privileges for that
object type. However, soft-deleted changes that have items on the Affected Items tab
cannot be restored, regardless of the user's privileges. The following example shows
how to undelete an object that has been deleted.
Closing a Session
Each Agile PLM user can open up to three concurrent sessions. Therefore, each session
that you open using the Agile API should be closed properly. If you fail to close a
session properly, you may not be able to log in with a new session until one of the
concurrent sessions time out.
2-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
3
Creating and Loading Queries
3
About Queries
An IQuery is an object that defines how to search for Agile PLM data. It defines a
search similar to the searches that you can use in Agile Web Client. The search can
have multiple search criteria (like an Advanced Search in Agile Web Client), or it can
be a simple search that specifies only one criterion.
Creating a Query
To create and execute a query, you must first create an IQuery object. Similar to other
Agile API objects, you create the object with the IAgileSession.createObject()
method.
In its simplest form, parameters that you pass with the createObject()method to
create a query, are the IQuery object type and the query class used in the search, and
the IQuery.Object_Type defines that the next parameter is the query class.
In Example 3–1, the query class is the Item class.
The query class you specify with the createObject() method also includes objects
from all of its subclasses. For example, if you search for objects in the Item class, the
results include parts and documents. If 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). If you want to search only a specific subclass, you should
explicitly specify that class.
The following example shows how to create a query that searches for objects in a
subclass named Foobar:
You can also use the IQuery.saveAs() method to name a query and save it to a folder.
3-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Query Attributes when Creating a Query
Note: To sort query results by other than the default order, see
"Sorting Query Results" on page 3-25.
■ IQuery.execute(boolean skipOrdering)
■ IQuery.execute(Object[] params, boolean skipOrdering)
To skip ordering, or perform ordering, set the boolean skipOrdering to true or false as
shown in the following example.
The following example shows how to set the query class, search condition, parent
folder, and query name when you create the query.
Search Conditions
The Agile API provides a simple yet powerful query language for specifying search
criteria. The query language defines the proper syntax for filters, conditions, attribute
references, relational operators, logical operators, and other elements.
Search criteria consist of one or more search conditions. Each search condition contains
the following elements:
1. Left operand - The left operand is always an attribute enclosed in brackets, such as
[Title Block.Number]. You can specify the attribute as an attribute name (fully
qualified name or short name) or attribute ID number. The attribute specifies
which characteristic of the object to use in the search.
3-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Search Criteria
2. Relational operator - The relational operator defines the relationship that the
attribute has to the specified value, for example, “equal to” or “not equal to.”
3. Right operand - The matching value for the specified attribute in the left operand.
The right operand can be a constant expression or a set of constant expressions. A
set of constant expressions is needed if the relational operator is “between,” “not
between,” “in,” or “not in.”
Following are two search condition examples.
Example 3–8 Search condition where the right operand is a set of constant expressions
[Page Two.Numeric01] between ('1000', '2000')
Query language keywords are not localized. You must use English keywords,
regardless of locale. You can use the keywords in lower case or upper case. In addition
to keywords, you can use Agile PLM variables such as $USER (for current user) and
$TODAY (for today's date) in Agile API queries.
Attribute names, whether you use the long or short form, are case-insensitive. For
example, [Title Block.Number] and [TITLE BLOCK.NUMBER] are both allowed.
Attribute names are also localized. The names of Agile PLM attributes vary based on
the locale of your Agile Application Server. If you are creating a query that is going to
be used on servers in different locales, you should reference attributes by ID number
(or the equivalent constant) instead of by name.
If the attribute name contains special characters, such as quotes or back slashes, you
can type these characters using the backslash (\) as an escape character. For example,
to include a quote character in your string, type \'. If you want to write a backslash,
type two of them together (\\). If the attribute name contains square brackets, enclose
the entire name in quotes:
['Page Two.Unit of Measure [g or oz]']
query.setCriteria("[%0] == 'Computer'", new Object[] { attr });
There are other less intuitive ways to specify an attribute. For example, you can pass in
an IAttribute reference using a parameter of the setCriteria() method. In
Example 3–16, '%0' references the attribute in the Object array parameter.
Also, as shown below you can use String concatenation to reference an attribute
constant:
query.setCriteria("[" + ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION + "] ==
'Computer'");
3-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Search Criteria
If a tab is not configured in Java Client to be visible, you can still search for an attribute
on that tab in the Agile SDK. However, you must search for the Table name that
corresponds to the Tab name.
Note: Because you use the table name to setup IQuery, it does not
matter if an Agile administrator changes a Tab name from the name
specified in Agile Java Client. Tab name changes do not affect SDK
table names.
3-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Search Criteria
As shown in the preceding table, when you use the 'between', 'not between', 'in', and
'not in' relational operators, each value in the set of values must be enclosed in quotes
and delimited by commas. These are additional examples that use 'between' and 'in'
relational operators:
[Title Block.Number] in ('1000-02', '1234-01', '4567-89')
[Title Block.Effectivity Date] between ('01/01/2001', '01/01/2002')
[Page Two.Numeric01] between ('1000', '2000')
Note: The relational operators any, all, none of, and not all are
not supported in the SDK.
The following criteria find a user with the first name Christopher OR the last name
Nolan.
[Page Two.Create User] in ([General Info.First Name] == 'Christopher',
[General Info.Last Name] == 'Nolan')
The following criteria find a user with the first name Christopher AND the last name
Nolan.
[Page Two.Create User] in ([General Info.First Name] == 'Christopher' &&
[General Info.Last Name] == 'Nolan')
If Part.Page Three.List01 is enabled and is set to Part Families list, the following
criteria finds a Part Family with the name PartFamily_01.
[Page Three.List01] in ([General Info.Name] == 'PartFamily_01')
The parameter query is not supported in nested queries and multiple values for one
placeholder in query parameters must be specified in two dimensional arrays as
shown in the following correct and incorrect examples of parameter query in nested
query criteria:
■ The parameter query specified in the following nested query criteria will fail to
execute:
[Page Two.User1] in ([General Info.First Name] == %0)
3-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Search Criteria
The following example gets a Criteria node from the Criteria library and loads and sets
it as the SDK query criteria.
Example 3–11 Using criteria from the Criteria Library in SDK queries
IQuery query = (IQuery) session.createObject(IQuery.OBJECT_TYPE,
ItemConstants.CLASS_ITEM_BASE_CLASS);
IAdmin admin = session.getAdminInstance();
// Get the Criteria Library node
INode criteriaLibrary = admin.getNode(NodeConstants.NODE_CRITERIA_LIBRARY);
// Load the Criteria relevant to the query class (For example it is Items base
class)
ICriteria criteria = (ICriteria) criteriaLibrary.getChild("All Released Items");
// Set the ICriteria in SDK Query Criteria
query.setCriteria(criteria);
Example 3–14 Using a Transfer Orders object's Selected Content as the query criteria
IQuery query1 = (IQuery) session.createObject(IQuery.OBJECT_TYPE,
TransferOrderConstants.CLASS_CTO);
query1.setSearchType(QueryConstants.TRANSFER_ORDER_SELECTED_CONTENT);
query1.setRelatedContentClass("ECR"); // ID or API Name
query1.setCriteria("[Selected Content.ECR.Cover Page.Number] equal to 'C0001'");
3-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Search Criteria
//query.setCriteria("[2000025272] is null");
ITable results = query.execute();
System.out.println("result size:"+results.size());
Indexes for query parameters are 0-based. Parameters are numbered 0, 1, 2, and so on.
Always enumerate the parameters in ascending order. The following example shows a
query with three parameters whose values are specified using the
IQuery.execute(Object[]) method.
Do not use quote characters around parameterized queries because they will create a
set of values (more than one element) for the query when parameters can only refer to
a given value. The following examples show the proper use of quote characters when
creating parameterized queries:
3-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Specifying Search Criteria
Note: The Agile API provides three where-used set operators. For
more information, see "Creating a Where-Used Query" on page 3-27.
Logical operators, including the where-used set operators, are not
localized. You must use English keywords, regardless of locale.
Priority Operator(s)
1 union
intersection
minus
2 and
or
3-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Using SQL Syntax for Search Criteria
Example 3–21 Query using the standard Agile API query syntax
try {
IQuery query = (IQuery)m_session.createObject(IQuery.OBJECT_TYPE, "Items");
query.setCriteria("[Page Two.Nummeric01] between (1000, 2000)");
//Set result attributes
String[] attrs = { "Title Block.Number", "Title Block.Description",
query.setResultAttributes(attrs);
//Run the query
ITable results = query.execute();
} catch (APIException ex) {
System.out.println(ex);
}
This example shows the same query rewritten in SQL syntax. Although, the example
does not contain fewer lines of code, it is more readable than Agile API query syntax.
This is particularly true, if ones is familiar with SQL.
The following example shows a query written with SQL syntax that specifies the
search criteria using the ATT_CRITERIA_STRING query attribute. For more information
about how to use query attributes, see Specifying Query Attributes when Creating a
Query.
Note: Recall, the FROM part of the search condition specifies the query
class. If you use the ATT_CRITERIA_CLASS attribute to also specify a
query class, the query class specified in the SQL search condition takes
precedence.
3-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Using SQL Syntax for Search Criteria
Although you can use the IQuery.setCriteria() method to specify a search condition
in SQL syntax, the IQuery.getCriteria()method always returns the search condition
in the standard Agile API query syntax.
Example Description
ORDER BY 1 Sort by the first SELECT attribute in ascending order (the default)
ORDER BY 2 desc Sort by the second SELECT attribute in descending order
ORDER BY 1 asc, 3 desc Sort by the first SELECT attribute in ascending order and the third
SELECT attribute in descending order
Attributes not specified in the SELECT statement cannot be used to sort query results.
Also, if you use “SELECT *” to select all available result attributes, the results cannot
be sorted because the attribute order is undefined.
The following example sorts results in ascending order by [Title Block.Number] and
[Title Block.Number], the first and third attributes in the SELECT statement.
3-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Setting Result Attributes for a Query
3-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Setting Result Attributes for a Query
When you use the setResultAttributes() method, make sure you specify valid
result attributes. Otherwise, the setResultAttributes() method will fail. To get an
array of available result attributes that can be used for a query, use
getResultAttributes() , as shown in the following example.
3-24 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Query Results
The ITwoWayIterator interface enables you to traverse the list of rows in either
direction, using the next() and previous() methods.
■ ITwoWayIterator it = query.execute().getTableIterator();
■ ITwoWayIterator it = query.execute().getReferentIterator();
For more information about using ITwoWayIterator, see "Iterating Over Table Rows"
on page 4-13.
Important: In Agile 9.0 SDK, all values in a query results table were
strings, but in post Agile 9.2, these values were converted to integers.
Note: Searches that you run from other Agile PLM Clients, such as
Agile Web Client, adhere to the limit set in the Maximum Query
Results Displayed preference.
Note: Users with the FSD privilege see all results of reports; also, all
privilege checking is bypassed on users with this privilege when they
view report results. Users without the FSD privilege see the maximum
number of reports specified in this property.
3-26 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating a Where-Used Query
Query Performance
The response time for running queries can be the biggest bottleneck in your Agile API
program. To improve performance, you should try to construct queries that return no
more than a few hundred results. A query that returns more than a 1000 results can
take several minutes to finish processing. Such queries also eat up valuable processing
on the Agile Application Server, potentially slowing down your server for all users.
To define a where-used query, use the IQuery.setSearchType() method. You can also
use the following logical operators, also called where-used set operators, to further
define the relationships between grouped sets of search conditions. Only one logical
operator can be used for each search condition.
Loading a Query
There are two ways to load a query:
■ Using the IAgileSession.getObject() method to specify the full path of a query.
■ Using the IFolder.getChild() method to specify the location of a query relative
to a folder.
The following example shows how to load a query by specifying its full path.
IQuery query =
(IQuery) session.getObject(IQuery.OBJECT_TYPE, new Integer(1002));
3-28 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Simple Query Examples
The Simple Query dialog box enables the user to specify an item number as the search
criteria. When you click the Find button, the program constructs a query to find all
items that contain the specified text in the Item# (Item number) field. This example
shows the code that runs the query when the user clicks the Find button.
3-30 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
4
Working with Tables
4
■ About Tables
■ Retrieving a Table
■ Accessing the New and Merged Relationships Tables
■ Retrieving the Metadata of a Table
■ Adding Table Rows
■ Adding and Updating Multiple Table Rows
■ Managing PSR Affected Items Tables with Bulk Edit APIs
■ Iterating Over Table Rows
■ Sorting Table Rows
■ Removing Table Rows
■ Retrieving the Referenced Object for a Row
■ Checking the Status Flags of a Row
■ Working with Page 1, Page 2, and Page 3
■ Getting and Setting Revisions and Flags
■ Redlining
■ Removing Redline Changes
■ Identifying Redlined Rows and Redlined Cells
About Tables
Whenever you work with an Agile PLM object in your program, you inevitably need
to get and display the object's data. The data is contained in one or more tables. In
Agile Web Client, these tables are equivalent to the separate tabs in a window, such as
the Manufacturers and BOM tabs.
Figure 4–1 The BOM tab for an item in Agile Web Client.
In some cases, a tab in Agile Web Client contains multiple tables. For example, the
Changes tab for an item contains the Pending Changes table and the Change History
table. The tabs and the tables that they contain is not always the same for different
Agile products. Also, they are not the same for each Agile PLM Dataobject. For
example, tables for Parts objects are different from tables for Manufacturers objects.
See “Retrieving a Table” on page 4-3.
To work with data in an Agile PLM table, follow these basic steps:
1. Create or get an object (for example, an item or a change order).
2. Retrieve a table (for example, the BOM table).
3. Iterate through the table rows to retrieve a row.
4. Get or set one or more attribute values for the selected row.
ITable, like IFolder, extends java.util.Collection and supports all methods
provided by that superinterface. This means that you can work with an ITable object
as you would with any Java Collection.
4-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accessing the New and Merged Relationships Tables
Retrieving a Table
After you create or get an object, you can use the IDataObject.getTable() method to
retrieve a particular Agile PLM table. IDataObject is a general-purpose object that
represents any Agile PLM object that contains tables of data. It is a superinterface of
several other objects, including IItem, IChange, and IUser.
Tables vary for each Agile PLM dataobject. Tables for change objects are different from
tables for items. Each table for a particular dataobject is identified by a constant in the
constants class for that dataobject. Item constants are contained in the ItemConstants
class, change constants are contained in the ChangeConstants class, and so on.
For information to use these tables, refer to the following Agile product administration
documents:
■ Getting Started with Agile PLM
■ Agile PLM Administrator Guide
■ Agile PLM Product Governance & Compliance User Guide
■ Agile PLM Product Portfolio Management User Guide
Note: For a complete list of table constants that are merged and
mapped into a single constant, or mapped into a new constant, see
Appendix B, "Migrating Table Constants to Release 9.2.2."
For information to use these tables, refer to the following Agile documents:
■ To use these tables in Agile PLM products, refer to Getting Started with Agile PLM
and Agile PLM Administrator Guide
■ To use these tables in Agile PPM products, refer to Agile PLM Product Portfolio
Management User Guide
4-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Table Rows
You can also use the API Name field to identify a table's name or ID. For information
to use this field, see Chapter 8, "Accessing PLM Metadata with APIName Field." For
information to use the Agile API to work with metadata, see Chapter 22, "Performing
Administrative Tasks."
You can add table rows in a batch format with ITable.createRow(). See “Adding and
Updating Multiple Table Rows” on page 4-9.
4-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Table Rows
Depending on your installation, the three possible locations for this file are:
■ <Agile_Home>\agileDomain\applications\application.ear\APP-INF\
classes\
■ <Agile_Home>\agileDomain\config
■ <Agile_Home>\agileDomain\servers\BEJ301388-AgileServer\tmp\_WL_ user
\AgilePLM\eokg58\APP-INF\classes
Note: This path is generated after starting the server. You can delete
it, but will regenerate as part the WebLogic Server startup process. The
directory eokg58 is generated randomly.
info.put(ManufacturerPartConstants.ATT_GENERAL_INFO_MANUFACTURER_PART_NUMBER,
"TPS100-256");
info.put(ManufacturerPartConstants.ATT_GENERAL_INFO_MANUFACTURER_NAME,
"TPS_POWER");
ManufacturerPart mfrPart =
(IManufacturerPart)(ManufacturerPartConstants.
CLASS_MANUFACTURER_PART, info);
IItem item =
(IItem)m_session.getObject(ItemConstants.CLASS_PART, number);
item.setManufacturingSite(ManufacturingSiteConstants.COMMON_SITE);
ITable table = item.getTable(ItemConstants.TABLE_MANUFACTURERS);
IRow row = table.createRow(mfrPart);
}
4-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding and Updating Multiple Table Rows
Example 4–8 Adding Multiple Team members to a Program with Bulk API
private static void createTeamRows(String[] addTeamMembers) throws APIException {
//Get the Project
IProgram program =
(IProgram)session.getObject(IProgram.OBJECT_TYPE, programNumber);
//Get the Team Table
ITable teamTable =
program.getTable(ProgramConstants.TABLE_TEAM);
IAgileList attrRolesValues =
teamTable.getAvailableValues(ProgramConstants.ATT_TEAM_ROLES);
attrRolesValues.setSelection(new Object[]{"Change Analyst",
"Program Team Member"});
//Collect team members already on Team Table
Set presentMembers = new HashSet();
Iterator it = teamTable.iterator();
while(it.hasNext()) {
IRow row = (IRow)it.next();
IUser user = (IUser)row.getReferent();
presentMembers.add(user);
}
//Validate new team members and filter out existing members to and to Team Table
IUser user = null;
IUser[] newUsers= new IUser[addTeamMembers.length];
int usrCount = 0;
for(int i =0; i<addTeamMembers.length; i++ ) {
user = (IUser)session.getObject(IUser.OBJECT_TYPE, addTeamMembers[i]);
if(!presentMembers.contains(user) || user==null) {
newUsers[usrCount++]=user;
}
}
//Using createRows() API to add all Team members at onece
//In this bulk approach, make sure each map in array is complete by it self to
//create a new row in Team Table.
List<Map> newTeam=new ArrayList<Map>();
for (int i=0; i<usrCount; i++) {
Map teamMap = new HashMap();
teamMap.put(ProgramConstants.ATT_TEAM_NAME, newUsers[i]);
teamMap.put(ProgramConstants.ATT_TEAM_ROLES, attrRolesValues);
teamMap.put(ProgramConstants.ATT_TEAM_ALLOCATION, 0); newTeam.add(teamMap);
}
teamTable.createRows(newTeam.toArray(new Object[0]));
}
4-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing PSR Affected Items Tables Using Bulk Edit APIs
1
See Metadata Interface under "Types of Agile API Classes and Interfaces" on page 2-1.
This bulk operation creates multiple rows with a single remote call. Rather than calling
ITable.createRow(...) to create multiple rows, this API can improve performance
and reduce unnecessary event invocations. However, if an error/warning occurred, all
operations are rolled back. This method accepts an array of objects and returns an
array of IRow corresponding objects. See createRow(Object) for more information on
the possible makeup of each element in the rows array.
boolean bulkRemoveAll ( Collection c ) throws APIException
This operation removes all of this collection's elements from this table in a single
remote call. This API can improve the performance and reduce unnecessary event
Invocations. This collection's elements must be IRow. If an error/warning occurred, all
operations are rolled back.
void bulkUpdateRows ( Map rows ) throws APIException
This bulk operation updates multiple rows with a single remote call. Rather than call
IRow.setValues(...) for multiple rows in a table, this API can potentially improve
the performance and reduce unnecessary event Invocation. If an error/warning
occurred, all operations are rolled back.
//Bulk Update
Map retmap = new HashMap();
Iterator it = aiTable.iterator();
while (it.hasNext()) {
IRow row = (IRow) it.next();
Map map = new HashMap();
4-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Iterating Over Table Rows
map.put(ServiceRequestConstants.ATT_AFFECTED_ITEMS_TEXT01, "AI.Text01");
retmap.put(row, map);
}
aiTable.bulkUpdateRows(retmap);
//Bulk Remove
List list = new ArrayList();
Iterator it = aiTable.iterator();
while (it.hasNext()) {
IRow row = (IRow) it.next();
list.add(row);
}
aiTable.bulkRemoveAll(list);
The ITwoWayIterator object allows a user interface to display table rows on multiple
pages, which is perhaps more practical than the use of ITwoWayIterator shown in the
preceding example. For example, instead of displaying a single scrolling page of
several hundred BOM items, you can break the table into pages displaying 20 BOM
items per page. To navigate from page to page, your program should provide
navigation controls such as those displayed in Figure 4–2 below.
4-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Sorting Table Rows
Note: The Agile API allows you to sort a table by only one attribute.
Therefore, the ISortBy array that you specify for the ISortBy
parameter of getTableIterator() must contain only one ISortBy
object.
The following example sorts the BOM table by the BOM | Item Number attribute.
The following Product Sourcing and Projects Execution objects load tables a bit
differently and therefore cannot be sorted using the
getTableIterator(ITable.ISortBy[]) method. For any tables of these objects, create
an unsorted iterator using either the iterator() or getTableIterator() methods.
■ IDiscussion
■ IPrice
■ IProgram
■ IProject
■ IRequestForQuote
■ ISupplier
■ ISupplierResponse
The ITable.ISortBy interface is not supported for query result tables. To sort query
results, use SQL syntax and specify an ORDER BY statement with the search criteria.
For more information, see "Using SQL Syntax for Search Criteria" on page 3-17.
// Find bom component 6642-01 and remove it from the table row
while (i.hasNext()) {
IRow row = (IRow)i.next();
String bomitem = (String)row.getValue(ItemConstants.ATT_BOM_ITEM_NUMBER);
if (bomitem.equals("6642-01")) {
bom.removeRow(row);
break;
}
}
} catch (APIException ex) {
System.out.println(ex);
}
Because ITable implements the Collection interface, you can use the Collection
methods to remove table rows. To remove all rows in a table, use Collection.clear().
4-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Retrieving the Referenced Object for a Row
4-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Retrieving the Referenced Object for a Row
The following example shows how to retrieve the referenced IChange object from the
Pending Changes table for an item.
The following example shows how to simplify the code in the previous example by
using the ITable.getReferentIterator() method to iterate through the table's
referenced objects.
4-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Revisions and Relationships
}
// Edit Page Two cells by calling IDataObject.getCell()
private static void editPageTwoCells2(IItem item) throws Exception {
ICell cell = null;
DateFormat df = new SimpleDateFormat("MM/dd/yy");
cell = item.getCell(ItemConstants.ATT_PAGE_TWO_TEXT01);
cell.setValue("Aluminum clips");
cell = item.getCell(ItemConstants.ATT_PAGE_TWO_MONEY01);
cell.setValue(new Money(new Double(9.95), "USD"));
cell = item.getCell(ItemConstants.ATT_PAGE_TWO_DATE01);
cell.setValue(df.parse("12/01/03"));
}
■ Track Impact
Note: Because the impacted flag is set by releasing the change, SDK
does not need to support setting the impacted flag.
To enable this feature, the following attributes are added in SDK’s CommonConstants
class:
public static final Integer ATT_RELATIONSHIPS_REVISION = new Integer(2000025267);
public static final Integer ATT_RELATIONSHIPS_IMPACTED = new
Integer(2000025266);
public static final Integer ATT_RELATIONSHIPS_TRACK_IMPACT = new
Integer(2000025268);
public static final Integer ATT_RELATIONSHIPS_CHANGE = new Integer(2000025422);
The following example uses these attributes to set a revision change and track flags.
Example 4–22 Using attributes that set Revisions and track Flags
IItem item =
(IItem) session.getObject(ItemConstants.CLASS_PART,"P00001");
IChange change =
(IChange) session.getObject(ChangeConstants.CLASS_ECO,"C00001");
item.setRevision(change);
IRelationshipTable table = (IRelationshipTable) change.getRelationship();
Iterator it = table.iterator();
while (it.hasNext()) {
IRow row = (IRow) it.next();
Object revision = row.getValue(ItemConstants.ATT_RELATIONSHIPS_REVISION);
Object impacted = row.getValue(ItemConstants.ATT_RELATIONSHIPS_IMPACTED);
Object trackImpact = row.getValue(ItemConstants.ATT_RELATIONSHIPS_TRACK_IMPACT);
Object rchange = row.getValue(ItemConstants.ATT_RELATIONSHIPS_CHANGE);
row.setValue(ItemConstants.ATT_RELATIONSHIPS_TRACK_IMPACT, "Yes");
}
4-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Redlining
item.setRevision('B C00002');
// Add Part "P00002" with Rev "B" into Change "C00002"'s relationship
table.addRevSpecificRelationship(item, null);
Redlining
When you issue a change for a released item or a price agreement, the Agile API lets
you redline certain tables affected by the change. In the Agile PLM Clients, redline
tables visually identify values that have been modified from the previous revision. Red
underlined text-thus the term “redline”-indicates values that have been added, and
red strikeout text indicates values that have been deleted. People responsible for
approving the change can review the redline data.
The Agile PLM system provides the following redline tables:
■ Redline BOM
■ Redline Manufacturers (AML)
■ Redline Price Lines
■ Redline Title Block
Note: The Web Client supports redlining the Item's Cover Page, Page
Two, and Page Three tables together. However, in the SDK, these
operations are performed separately, using different tables for each
page.
// Create an MCO
IChange change = (IChange)m_session.createObject(ChangeConstants.CLASS_MCO,
"M000024");
4-24 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Removing Redline Changes
if(((IRedlined)row).isRedlineModified())
rows.add(row);
}
Using ICell.getOldValue
With the introduction of the IRedlined interface, the ICell.getOldValue() method is
no longer defined for redline added and redline removed rows. The
ICell.getOldValue() method has a meaningful result only when FLAG_IS_REDLINE_
MODIFIED is true for the row.
Note: Do not call this method for redline added or redlined removed
rows.
4-26 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
5
Working with Data Cells
5
Data Types
The type of objects associated with the getValue() and setValue() methods depends on
the cell's data type. The table below lists the object types of cell values for getValue()
and setValue() methods.
Getting Values
The following table lists Agile API methods for getting values for cells.
Method Description
ICell.getValue() Gets a cell value
IRow.getValue() Gets a cell value contained within a row
IRow.getValues() Gets all cell values contained within a row
IDataObject.getValue() Gets a cell value on Page One, Page Two, or Page Three
5-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Getting Values
Before working with a cell's value, you must select the cell. Agile PLM cells are
instances of attributes. To specify the attribute for a cell, specify either the attribute's
ID constant, it's fully qualified name (such as "Title Block.Description"), or an
IAttribute object. For more information about referencing attributes, refer to
"Referencing Attributes" in SDK Developer Guide - Developing PLM Extensions.
Note: You can use ICell getAPIName() to access Data Cell attribute
values. For information to use this field, see Chapter 8, "Accessing
PLM Metadata with APIName Field."
The following example shows how to reference a cell by the fully qualified attribute
name.
The method that you use to get a cell value depends on the current object in use by
your program. Use the ICell.getValue() method if you have already retrieved an ICell
object and want to retrieve a value.
Quite often, your program will first retrieve an object, such as an item, and then use
the IDataObject.getValue(java.lang.Object cellId) method to retrieve values for
it.
The object returned by the getValue() method is of the same data type as the Agile
PLM attribute. For more information about data types, see "Data Types" on page 5-1.
If you are iterating over rows in an Agile PLM table, you can use the IRow.getValues()
method to retrieve a Map object containing all cell values for a particular row in the
table. The returned Map object maps attribute ID keys to cell values.
Important: End users must use the GMT date format for PPM dates.
For more information, refer to the Agile PLM Product Portfolio
Management User Guide.
Setting Values
The following table lists Agile API methods for setting values for cells.
Method Description
ICell.setValue() Sets a cell value
IRow.setValue() Sets a cell value contained within a row
IRow.setValues() Sets multiple cell values contained within a row
IDataObject.setValue() Sets a cell value on Page One, Page Two, or Page Three
IDataObject.setValues() Sets multiple cell values on Page One, Page Two, or Page Three
The method that you use to set a value, depends on the current object that is use by
your program.
5-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Setting Values
Use the ICell.setValue() method if you've already retrieved an ICell object and
want to set its value.
If your program has already retrieved an object, such as a part, you can use the
IDataObject.setValue() method to set its values.
If you are iterating over rows in an Agile PLM table, you can use the IRow.setValues()
method to set the cell values for an entire row. You can also use the
IDataObject.setValues() method to set multiple cell values on Page One, Page Two, or
Page Three of an object. The Map parameter you specify with setValues() maps
attributes to cell values.
When you set an Agile PLM value, you must know the cell's data type. If you try to set
a cell's value using an object of the wrong data type, the method fails. You may need to
cast the object to another class before using it to set a value.
The typical exception message that Agile PLM returns for a locked object is "Someone
is working on this object. Please try again later."
For more information on handling exceptions, see Chapter 20, "Handling Exceptions."
Example 5–9 Getting and setting the value for a SingleList cell
private static String getPartCatValue(IItem item) throws APIException {
// Get the Part Category cell
ICell cell = item.getCell(ItemConstants.ATT_TITLE_BLOCK_PART_CATEGORY);
5-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Getting and Setting List Values
Example 5–10 Getting and setting the value for a MultiList cell
private static String getProdLinesValue(IItem item) throws APIException {
String prodLines;
Example 5–11
private String getCascadeValue(IItem item) throws APIException {
return value;
}
private void setCascadeValue(IItem item) throws APIException {
String value = null;
Although the previous example shows one way to set the value for a cascading list,
there is another longer form you that can use which illustrates the tree structure of the
list. Instead of specifying a single String to represent a cascading list value, you can set
the selection for each level in the list. The following example selects a value for a
cascading list with three levels: continent, country, and city.
Example 5–12 Setting the value for a cascading list (long form)
private void setCascadeValue(IItem item) throws APIException{
// Get the Page Two List01 cell
ICell cell = item.getCell(CommonConstants.ATT_PAGE_TWO_LIST01);
5-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Using Reference Designator Cells
The following table lists Agile API methods for retrieving reference designator values
for cells.
Method Description
IReferenceDesignatorCell. Gets a collapsed representation of the
reference designators. For example,
getCollapsedValue()
"A1,A2,A3" would be represented as
"A1-A3". Note that the range separator, ("-")
is defined as part of the system preferences.
IReferenceDesignatorCell. Gets an expanded value of a reference
designator. For example, for "A1-A3" the
.getExpandedValue()
string, "A1, A2, A3" would be returned.
IReferenceDesignatorCell. Gets the individual reference designators as
an array of strings. For example, for "A1-A3"
getReferenceDesignators()
an array of these three strings, ["A1", "A2",
"A3"] would be returned.
5-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
6
Working with Folders
6
About Folders
An IFolder is a general purpose container used to hold IQuery and IFolder objects as
well as any of the main Agile PLM objects (IChange, IItem, IManufacturer,
IManufacturerPart, and IPackage). Folders are used to organize queries, or searches.
Note: A file folder is different from a folder. It has its own interface
called the IFileFolder. Files in a file folder holds can be referenced
from the Attachments table of other objects. For more information
about file folders, see Chapter 13, "Working with Attachments and File
Folder Objects."
■ Report - A folder containing reports. Although you cannot use the Agile API to
create, modify, or delete report folders, you can create, modify, or delete them in
Agile PLM Clients.
Each user's selection of folders may vary. However, every user has a Home folder. From
each user's Home folder, you can construct various subfolders and browse public and
private queries. To retrieve the Home folder for a user, use the
IUser.getFolder(FolderConstants.TYPE_HOME) method.
Folders are subject to the same transactional model as other Agile API objects. If you
do not set a transaction boundary for a folder, it is automatically updated as soon as
you add anything to, or remove anything from the folder.
IFolder extends java.util.Collection and ITreeNode support all the methods that
are provided by those Superinterfaces. That is, you can work with an IFolder object
as you would any Java Collection. Methods of ITreeNode allow you to deal with the
hierarchical structure of a folder by adding and removing children, getting children,
and getting the parent folder.
6-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating a Folder
Loading a Folder
There are two ways to load a folder:
■ Use the IAgileSession.getObject() method to specify the full path of a folder.
■ Use the IFolder.getChild() method to specify the relative path of a subfolder.
Folder and query names are not case-sensitive. Therefore, you can specify a folder path
using upper or lower case. For example, to load the Personal Searches folder, you can
specify /Personal Searches or /PERSONAL SEARCHES.
The following example shows how to load a folder by specifying the full path to the
folder.
The following example loads a folder by specifying its path relative to another folder.
In this case, the user's Home Folder.
Creating a Folder
To create a folder, use the IAgileSession.createObject() method. When you create a
folder, you must specify the folder's name and its parent folder. The following example
shows how to create a folder named "MyTemporaryQueries" in the Personal Searches
folder.
6-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Getting Folder Elements
Another option to get a folder's children is to iterate over the folder elements, moving
from one end of the folder to the other. To create an iterator for an IFolder object, use
the java.util.Collection.iterator() method.
Deleting a Folder
To delete a folder, use the IFolder.delete() method. You can delete folders that are
empty and that are not predefined Agile PLM system folders (such as the Global
Searches and My Inbox folders).
Unlike other dataobjects, folders are not "soft-deleted" the first time you delete them.
When you delete a folder, it is removed permanently from the system.
void deleteFolder(IFolder folder) throws APIException {
folder.delete();
}
6-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
7
Working with Items, BOMs, and AMLs
7
7-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Items
// Get the revision for this BOM item where bomRev = revID + 8 spaces +
changeNumber)
String bomRev = (String)row.getValue(ItemConstants.ATT_BOM_ITEM_REV);
Example 7–3 Failing to get a revision using the Title Block.Rev field
(IItem)m_session.getObject(IItem.OBJECT_TYPE, "1000-02");
IAgileList listRevValue =
(IAgileList)item.getValue(ItemConstants.ATT_TITLE_BLOCK_REV);
String revValue = listRevValue.toString();
if (revValue==null) {
System.out.println("Failed to get the revision.");
For an example to retrieve a BOM table, see "Retrieving a Table" on page 4-3.
7-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with BOMs
Note: You can't add rows to a BOM if the parent item is currently set
to display all sites. Before adding a row to a BOM, make sure the
item's site is not set to ManufacturingSiteConstants.ALL_SITES.
Otherwise, the API throws an exception.
//Add a site-specific item to the BOM using the user’s default site
public void addSiteBOMItem(IItem item, String bomnumber) throws APIException {
HashMap map = new HashMap();
map.put(ItemConstants.ATT_BOM_ITEM_NUMBER, bomnumber);
item.setManufacturingSite(((IAgileList)m_session.getCurrentUser().getValue()
UserConstants.ATT_GENERAL_INFO_DEFAULT_SITE)).getSelection()[0].getValue();
item.getTable(ItemConstants.TABLE_BOM).createRow(map);
}
For more information about manufacturing sites, see Chapter 10, "Managing
Manufacturing Sites."
Expanding a BOM
The BOM table can be viewed as a table containing multiple levels even though the
API doesn't present it that way. By default, the BOM table contains only top-level
items. To expand a BOM to show its hierarchy, you need to recursively load each BOM
item and its subassemblies. The following example shows how to print multiple levels
of a BOM.
Note: If you copy a BOM from one item to another, the target item
must have the same associated manufacturing sites as the source item.
// Add all rows from the source BOM to the target BOM
targetBOM.addAll(sourceBOM);
}
Another way to copy a BOM is to iterate through the rows of a source BOM and copy
each row to a target BOM.
7-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with BOMs
For example, when a base BOM compared with the target BOM, the comparison will
show:
■ d shown in BOM node - indicates only base assembly has the BOM
■ a shown in BOM node - indicates only target assembly has the BOM
■ u shown in BOM node - indicates both root assemblies have the same BOM
■ m shown in BOM node - indicates both root assemblies have the BOM but with
some differences
All first level BOMs of both base and target assembly are categorized into another
node BOMs. BOM nodes under BOMs are first sorted by FindNum and then by
ItemNumber.
There are several use cases for these reports. For example, archiving or comparative
analysis with outputs of ERP systems.
To create a product report, you must use the IAgileSession object. The following
examples show how to use IAgileSession and ProductReportConstants to prepare
BOM Explosion and BOM Comparison reports.
Redlining a BOM
Note: You can remove redlines from a row of the BOM table. See
"Removing Redline Changes" on page 4-25.
7-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with BOMs
Example 7–12
private static IChange createChange(IAgileSession myServer, Integer ECO_NUMBER)
throws APIException {
IChange change =
IChange)myServer.createObject(ChangeConstants.CLASS_ECO, ECO_NUMBER);
Example 7–13 Adding an item to the Affected Items table of a change order
private static void addAffectedItems(IAgileSession myServer,
IItem item, IChange change) throws APIException {
// Set the value of the item number by specifying the item object
params.put(ChangeConstants.ATT_AFFECTED_ITEMS_ITEM_NUMBER, item);
7-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with AMLs
Note: You can't add rows to an AML if the parent item is currently
set to display all sites. Before adding a row to an AML, make sure the
item's site is not set to ManufacturingSiteConstants.ALL_SITES.
Otherwise, the API throws an exception.
// Add a site-specific MfrPart to the AML using the user’s default site
public void addSiteApprMfr(IItem item, String mfrName, String mfrPartNum)
throws APIException {
HashMap map = new HashMap();
map.put(ManufacturerPartConstants.
ATT_GENERAL_INFO_MANUFACTURER_PART_NUMBER, mfrPartNum);
map.put(ManufacturerPartConstants.
ATT_GENERAL_INFO_MANUFACTURER_NAME, mfrName);
IManufacturerPart mfrPart = (IManufacturerPart)m_session.getObject(
ManufacturerPartConstants.CLASS_MANUFACTURER_PART, map);
item.setManufacturingSite(((IAgileList)m_session.getCurrentUser().
getValue(UserConstants.ATT_GENERAL_INFO_DEFAULT_SITE)).getSelection()[0]);
item.getTable(ItemConstants.TABLE_MANUFACTURERS).createRow(mfrPart);
}
For more information about manufacturing sites, see Chapter 10, "Managing
Manufacturing Sites."
7-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with AMLs
params.put(ProjectConstants.ATT_ITEMS_NUMBER, itmCMObjIdLst);
prj.updateAMLfromIM(params);
disconnect();
}
private static IAgileSession session = null;
}
Redlining an AML
Once an item is released, you can change the Manufacturers table only by issuing a
new change order. The change order allows you to redline the Manufacturers table.
7-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
8
Accessing PLM Metadata with APIName Field
8
The following paragraphs describe the rules that assign a name to APIName fields and
SDK interfaces that you can use in your SDK applications to access internal data with
the APIName field.
8-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accessing Metadata Using the APIName Field
API Example
IAdmin
getAgileClass(Object id) getAgileClass("Parts")
getNode(Object id) getNode ("Part.TitleBlock")
IAgileClass
getAttribute (Object key) getAttribute("TitleBlock.number")
or, getAttribute("number")
getTableAttributes(Object tableId) getTableAttributes("TitleBlock")
getTableDescriptor (Object id) getTableDescriptor("TitleBlock")
isSubclassOf(Object cls) isSubclassOf("Parts")
IAgileList
getChild(Object child) getChild("UNITED_STATES")
UNITED_STATES is the APIName for entry
'United States' in 'Country' list
getChildNode(Object child) getChildNode("UNITED_STATES")
setSelection (Object[] childNodes) setSelection(new Object[]
{"UNITED_STATES" , "INDIA"})
IAgileSession
createObject(Object objectType, Object Map map = new HashMap();
params)
String partNumber = "P00001"
map.put("TitleBlock.number",
partNumber);
IDataObject dObj = (IDataObject) (m_
session.createObject("Part", map));
createObject(int objectType, Object Map map = new HashMap();
params)
String partNumber = "P00001"
map.put("number", partNumber);
IDataObject dObj = (IDataObject) (m_
session.createObject("Part", map));
API Example
getObject(Object objectType, Object Map map = new HashMap();
params)
map.put("TitleBlock.number",
"1000-01");
IDataObject dObj = (IDataObject) (m_
session.getObject("Part", map));
getObject(int objectType, Object Map map = new HashMap();
params)
map.put("TitleBlock.number",
"1000-01");
IDataObject dObj = (IDataObject)(m_
session.getObject(IItem.OBJECT_TYPE,
map));
IDataObject
getCell(Object key) getCell("PageTwo.list11") or
getCell("list11")
getTable(Object tableId) getTable("AffectedItems")
getValue(Object attribute) getValue ("PageTwo.list11") or
getValue ("list11")
setValue(Object key,Object value) setValue("PageTwo.text01","test")
saveAs(Object type,Object params) Map params = new HashMap();
params.put("number", number);
IItem part2 = (IItem)
part.saveAs("Document", params);
setValues(Map map) Map map = new HashMap();
map.put("TitleBlock.number",
"1000-01");
part.setValues(map);
ILibrary
getAdminList(Object listId) getAdminList("ActionStatus")
createAdminList(Map map) map.put(IAdminList.ATT_NAME,"My
List");
map.put(IAdminList.ATT_APINAME,
"MyList");
map.put(IAdminList.ATT_DESCRIPTION,
"My desc");
map.put(IAdminList.ATT_ENABLED, new
Boolean(false));
map.put(IAdminList.ATT_CASCADED, new
Boolean(false));
IAdmin admin = m_
session.getAdminInstance();
IListLibrary listLibrary =
admin.getListLibrary();
IAdminList newList =
listLibrary.createAdminList(map);
INode
8-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accessing Metadata Using the APIName Field
API Example
getChild(Object child) IAdmin admin = m_
session.getAdminInstance();
INode node =
admin.getNode(NodeConstants.NODE_
AGILE_CLASSES);
INode partsClass =
node.getChild("Parts");
getChildNode(Object child) IAdmin admin = m_
session.getAdminInstance();
INode node =
admin.getNode("AgileClasses");
INode partsClass =
node.getChildNode("Parts");
IProgram
saveAs (Object type, Object[] HashMap map = new HashMap();
tablesToCopy, Object params)
map.put("name", new_number);
map.put("scheduleStartDate", new
Date());
Object[] objects = new
Object[]{"PageTwo", "PageThree",
"Team"};
IProgram program2 =
(IProgram)program.saveAs("Program",
objects, map);
saveAs(Object type, HashMap map = new HashMap();
Object[]tablesToCopy, Object params,
map.put("name", new_number);
boolean applyToChildren)
map.put("scheduleStartDate", new
Date());
Object[] objects = new
Object[]{"PageTwo", "PageThree",
"Team"};
IProgram program2 =
(IProgram)program.saveAs("Program",
objects, map, true);
IProject
assignSupplier(Object supplierParams) HashMap map = new HashMap();
map.put("Responses.itemNumber",
item.getName());
map.put("Responses.supplier",
supplier.getName());
rfq.assignSupplier(map);
IQuery
setResultAttributes (Object[] attrs) String[] attrs = new String[3];
attrs[0] = "TitleBlock.number";
attrs[1] = "TitleBlock.description";
attrs[2] =
"TitleBlock.lifecyclePhase";
query.setResultAttributes(attrs);
API Example
IRequestForQuote
assignSupplier (Object supplierParams) HashMap map = new HashMap();
map.put("Responses.itemNumber",
item.getName());
map.put("Responses.supplier",
supplier.getName());
rfq.assignSupplier(map);
ITable
createRow(Object param) HashMap params = new HashMap();
params.put("itemNumber", "P0001");
params.put("newRev", "A");
ITable affectedItems =
change.getTable("AffectedItems");
IRow affectedItemRow =
affectedItems.createRow(params);
createRows(Object[] rows)
getAvailableValues(Object attr) getAvailableValues("PageTwo.list01")
updateRows (Map rows) HashMap[] mapx = new HashMap[5];
Map rows = new HashMap();
mapx[0] = new HashMap();
mapx[0].put("newRev", "A");
mapx[0].put("text01", "sdk test1");
rows.put(rowArray[0], mapx[0]);
mapx[1] = new HashMap();
mapx[1].put("newRev", "A");
mapx[1].put("text01", "sdk test2");
rows.put(rowArray[1], mapx[1]);
tab.updateRows(rows);
ITableDesc
getAttribute (Object key) getAttribute("number")
Interface Method
IAdminList getAPIName()
IAgileClass getAPIName()
IAgileList getAPIName()
addChild(Object child, String apiName)
IAttribute getAPIName()
ICell getAPIName()
INode getAPIName()
8-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accessing Metadata Using the APIName Field
IProperty getAPIName()
ITableDesc getAPIName()
/**
* This sample code shows how to use the API name.
* It uses some of the SDK APIs with the API name.
* For a list of API names for attributes and classes,
* refer to Agile Java Client.
* Some API names in Agile Java Client may differ from the ones
* in this example. This is because a duplicate conflict
* was detected in the API name in the same context.
* If you detect this conflict, be sure to change the API name
* in this sample before compiling and executing the code.
*/
8-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accessing Metadata Using the APIName Field
// Add the child part to the BOM table of the parent part
addBOM(itemParent, itemChild);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
session.close();
}
}
/**
* @throws APIException
*/
private static void createAdminList() throws APIException {
Map listParams = new HashMap();
listParams.put(IAdminList.ATT_APINAME, "MY_LIST");
// Specify the API name of the List
listParams.put(IAdminList.ATT_NAME, "My List");
listParams.put(IAdminList.ATT_ENABLED, new Boolean(true));
IAdminList myList = listLibrary.createAdminList(listParams);
IAgileList values = myList.getValues();
values.addChild("Value A", "VAL_A");
// Specify the API name along with the value
values.addChild("Value B", "VAL_B");
values.addChild("Value C", "VAL_C");
myList.setValues(values);
System.out.println("Created Admin List " + myList.getName());
}
/**
* @throws APIException
*/
8-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accessing Metadata Using the APIName Field
/**
* <p> Create an IAgileSession instance </p>
* @param session
* @return IAgileSession
* @throws APIException
*/
8-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
9
Subscribing to Agile PLM Objects
9
Subscription Events
Subscription events vary per object class. The full set of events you can subscribe to are
listed in the following table.
Although most routable and nonroutable objects support the subscription events listed
in the table above, there are some exceptions:
■ User objects do not support the Lifecycle Change subscription event.
■ File Folder objects do not support the Add File and Cancel Checkout File
subscription events.
The Field Change subscription event is related to any attribute whose Available To
Subscribe property has been set to "Yes." Consequently, each class and subclass can
have a different set of subscribable attributes.
Subscribe Privilege
To subscribe to an object, you must have the Subscribe privilege for that class. Many
predefined Agile PLM roles, such as Creator, already have the Subscribe privilege for
several object classes. To change your roles and privileges, see your Agile PLM system
administrator.
Subscription Notifications
Subscription events trigger two types of Agile PLM Notifications:
■ Email - Email Notifications are sent only if the Receive Email Notification
preference of the recipient is set to Yes. For information on user and system
preferences, refer to Agile PLM Administrator Guide.
■ Inbox - Inbox Notifications occur automatically regardless of user preferences
A user with Administrator privileges can create and configure these Notifications in
Java Client which provides two very similar dialogs for this purpose. The reason for
the two dialogs is due to the fact that there are two sets of Email and Inbox
Notifications:
■ Those that the "To" field is grayed out
■ Those that the administrator user can select recipients who are notified when the
subscription event is triggered
9-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Getting Subscriptions for an Object
}
else if
(subs[i].getId().equals(SubscriptionConstants.EVENT_CANCELCHECKOUT_FILE)) {
if (subs[i].isEnabled()) {
System.out.println("Cancel Checkout File subscription is enabled");
}
}
else if (subs[i].getId().equals(SubscriptionConstants.EVENT_CHECKIN_FILE)) {
if (subs[i].isEnabled()) {
System.out.println("Checkin File subscription is enabled");
}
}
else if (subs[i].getId().equals(SubscriptionConstants.EVENT_CHECKOUT_FILE)) {
if (subs[i].isEnabled()) {
System.out.println("Checkout File subscription is enabled");
}
}
else if (subs[i].getId().equals(SubscriptionConstants.EVENT_DELETE_FILE)) {
if (subs[i].isEnabled()) {
System.out.println("Delete File subscription is enabled");
}
}
else if (subs[i].getId().equals(SubscriptionConstants.EVENT_FIELD_CHANGE)) {
if (subs[i].isEnabled()) {
IAttribute attr = subs[i].getAttribute();
if (attr != null) {
String attrName = attr.getFullName();
System.out.println("Field Change subscription
is enabled for " + attrName);
}
}
}
else if
(subs[i].getId().equals(SubscriptionConstants.EVENT_LIFECYCLE_CHANGE)) {
if (subs[i].isEnabled())
System.out.println("Lifecycle Change subscription is enabled");
}
else if (subs[i].getId().equals(SubscriptionConstants.EVENT_STATUS_CHANGE)) {
if (subs[i].isEnabled())
System.out.println("Status Change subscription is enabled");
}
else
System.out.println("Unrecognized subscription event: " + subs[i].getId());
}
}
9-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Modifying Subscriptions for an Object
9-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Subscription Tables
In addition to removing individual rows from the Subscription table, you can also use
the Collection.clear() method to clear the table.
The Subscription table doesn't list the events you've subscribed to for each object. To
find that information, you need to open each referenced object. The following example
shows how to use ITable.getReferentIterator() to iterate through the referenced
objects in the table.
9-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
10
Managing Manufacturing Sites
10
unlimited number of manufacturing sites, however a user will not have access to every
site unless all sites are specified in his user profile Sites property. Your organization
may have implemented the Agile PLM system in such a way that users can access only
the information pertaining to certain sites, as determined by their user profile Sites
property.
To create a site-specific BOM for an item, the item's subclass must have the
Site-specific BOM property set to Allow. Otherwise, items of that subclass have BOMs
that are common to all sites. For information on Sites and enabling sites, refer to the
Agile PLM Administrator Guide.
Note: When you create a manufacturing site, its Lifecycle Phase is set
to Disabled by default. To use the site, make sure you enable it.
10-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding a Manufacturing Site to the Sites Table
Example 10–5 Getting the currently selected manufacturing site for an item
private static IManufacturingSite getCurrentSite(IItem item)
throws APIException {
IManufacturingSite site = item.getManufacturingSite();
return site;
}
// Load sites
IManufacturingSite siteSF =
(IManufacturingSite)m_session.getObject("Site", "San Francisco");
IManufacturingSite siteHK =
(IManufacturingSite)m_session.getObject("Site", "Hong Kong");
// Load an item
IItem item =
10-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Disabling a Site
(IItem)m_session.getObject("Part", "1000-02");
Disabling a Site
A manufacturing site can have one of two lifecycle phases, enabled or disabled. If a
site is disabled, it can no longer be used to create site-specific BOMs, AMLs, and
changes.
To disable a manufacturing site, set the value for the Lifecycle Phase attribute to
Disabled.
10-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
11
Managing Reference Objects
11
■ PLM Clients support an absolute URL and the SDK supports the absolute and
relative URLs. For example, /jde/servlet/1234 (relative URL) and
https://servlet:port/jde/servlet/1234 (absolute URL).
■ The Relative and Absolute URL types support the following three SDK calls:
– getURL (relative URL)
– setURL (relative URL)
– getAbsoluteURL
■ You can:
– Search for an object in an external application and add a reference to that
object in Agile PLM Relationships table.
– Search, add, and remove Reference Objects from the Agile PLM Relationships
table.
– Create a new object in an external application and add a reference to that
object in the Agile PLM Relationships table.
■ Advanced search does not support case sensitive or other Agile search FTS
features. This limitation on the server side is due to the reference object query
results are from the external system and our reference object WS schema does not
have more search syntax definitions. So Agile core cannot guarantee the external
search criteria.
■ In Advanced Search:
– The only supported search criteria column is TitleBlock.Name/Number/Desc.
– The only supported search operator is “Contains.” For example,
query.setCriteria("[TitleBlock.Name/Number/Desc] contains the phrase
'*’“); If the SDK client passes other criteria columns or operators, the Search
server will throw an error stating the search condition syntax was invalid and
use only one row with criteria column
11-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Updating a Reference Object
//The only allowed Sub Class is Name/APIName of the Reference Object from Agile
//Java Client
paramsMap.put(ReferenceObjectConstants.ATT_GENERAL_INFO_OBJECT_TYPE,
referenceObjectSubClass); //Note: Should be a valid Sub Class
paramsMap.put(ReferenceObjectConstants.ATT_GENERAL_INFO_NUMBER, "REFOBJ01");
paramsMap.put(ReferenceObjectConstants.ATT_GENERAL_INFO_PUBLIC_KEY_STRING,
"UniqueKeyOnRemoteApplication");
IReferenceObject refObject = (IReferenceObject)m_session.createObject(
IReferenceObject.OBJECT_TYPE,paramsMap);
Note: Web Client users can directly create a Reference Object. They
cannot do this by using search, and then adding the search result, or
the object in the remote system. When the required parameters are
known, SDK also supports the direct creation of Reference Objects as
in other Agile object types. This is designed to align Reference Objects
with other object types in the SDK framework.
paramsMap.put(ReferenceObjectConstants.ATT_GENERAL_INFO_PUBLIC_KEY_STRING,
"UniqueKeyOnRemoteApplication");
ICell desc =
refObject.getCell(ReferenceObjectConstants.ATT_GENERAL_INFO_DESCRIPTION);
ICell url =
refObject.getCell(ReferenceObjectConstants.ATT_GENERAL_INFO_URL);
ICell sts =
refObject.getCell(ReferenceObjectConstants.ATT_GENERAL_INFO_STATUS);
11-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Searching for Reference Objects
Example 11–3 Adding a Reference Object to the Relationships Table in Web Client
IAdmin m_admin = m_session.getAdminInstance();
paramsMap.put(ReferenceObjectConstants.
ATT_GENERAL_INFO_OBJECT_TYPE, referenceObjectSubClass);
paramsMap.put(ReferenceObjectConstants.
ATT_GENERAL_INFO_NUMBER, "REFOBJ01");
paramsMap.put(ReferenceObjectConstants.
ATT_GENERAL_INFO_PUBLIC_KEY_STRING, "UniqueKeyOnRemoteApplication");
//Get Relationship Table of an Object that the Reference Object will be added to:
IDataObject parentObj = (IDataObject) m_
session.getObject(QualityChangeRequestConstants.CLASS_CAPA, "CAPA0001");
ITable relTbl = parentObj.
getTable(QualityChangeRequestConstants.TABLE_RELATIONSHIPS);
// Search the external system and retrieve the referenced objects in Tablular
// format:
private static ITable doSearch(String subClassName, String srchStr) throws
APIException {
ITable results = null;
try {
String qry =
"["+ReferenceObjectConstants.SEARCH_KEY+"]"+ " contains '"+srchStr+"'";
IQuery query =
(IQuery)session.createObject(IQuery.OBJECT_TYPE, RefObjSubClassName);
query.setCaseSensitive(false);
query.setCriteria(qry);
results = query.execute();
}
11-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
12
Working with Lists
12
About Lists
Many attributes in the Agile PLM system are configured as lists. Agile provides two
datatypes to support list fields:
■ SingleList - a list in which only one value can be selected.
■ MultiList - a list in which multiple values can be selected.
Attributes, properties, and cells can all be lists. The Agile API provides methods for
working with lists in the IAgileList interface, a generalized data structure used for all
Agile lists. Because IAgileList represents a tree structure of available list values, it
extends the ITreeNode interface.
You can use ITreeNode.addChild() to add values to a list. All list values must be
unique. After adding a list value, you can prevent its selection by making it obsolete.
List Library
In Agile Java Client, administrators can define custom lists that can be used for Page
Two and Page Three list attributes. You can also use the Agile API to define custom
lists. The IListLibrary interface provides functionality equivalent to the list library in
Agile Java Client. You can use the IAdminList interface to modify the values or
properties of a list.
To retrieve the list library, use the IAdmin.getListLibrary() method. You can then
use the IAdminList interface to create new custom lists and work with existing lists.
AdminListConstants provide IDs for each list in the list library.
Note: The Agile API provides support for several internal Agile lists
that are not exposed in the list library in Agile Java Client.
SingleList Lists
A SingleList attribute or cell presents a list from which only one value can be selected.
The following figure shows a SingleList cell for Part Types in Agile Web Client.
Cascading Lists
In Agile Java Client, you can configure a SingleList attribute to have multiple
hierarchical levels. A list with multiple hierarchical levels is called a cascading list. The
following figure shows the Location list, a cascading list, being configured in Agile
Java Client. The list has separate levels for continent, country, and city.
12-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
MultiList Lists
Note: The Location list is the only cascading list that ships with
Agile PLM. However, you can define your own cascading lists.
MultiList Lists
A MultiList attribute or cell presents a list from which multiple values can be selected.
In Agile Web Client, you can select values for a MultiList cell using the Multiple Value
Selection dialog, shown in the following figure.
Figure 12–4 Multiple Value Selection window in the Agile Web Client
12-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Selecting a List Value
The following example shows how to change the value of the Visible property of an
attribute. The Visible property is a SingleList property with two possible values, No
and Yes (or 0 and 1).
When you use the IAgileList.setSelection() method, you can specify String[],
Integer[], or IAgileList[] values for the childNodes parameter. When you select a
value from the IAgileList object, you can use its String representation or its Integer
ID.
To get the currently selected value for a list, use the IAgileList.getSelection()
method. For a SingleList cell or property, IAgileList returns an array containing one
IAgileList object. For a MultiList cell or property, getSelection() returns an array
containing one or more IAgileList objects.
Example 12–2 Getting the current list value for the Visible property
try {
// Get the Admin instance
IAdmin admin = m_session.getAdminInstance();
Lists can be reused for several attributes, even for attributes of different classes. The
following example reuses the list of available values for a Page Two attribute to set the
list of available values for a Page Three list attribute.
// Set the available values for the list, using values from "Page Two.List01"
attr2.setAvailableValues(attr1.getAvailableValues());
} catch (APIException ex) {
System.out.println(ex);
}
12-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Selecting a List Value
}
}
private void setPageTwoMultilistValue(IItem item) throws APIException {
// Get the "Page Two.Multilist01" cell
This method determines if the contents of the IAgileList are enumerable and is a
convenient alternative to using IAgileList.getChildren() which requires accessing
all child values of the list. This method returns a Boolean true if the list is enumerable.
That is, it has an accessible child list, and a Boolean false if otherwise.
12-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Selecting a List from the List Library
maximum value set in the Preferences, instead of displaying the integer 250 as was
done in prior releases.
With the new PropertyConstants PROP_MAXIMUM_LIST_VALUES_DISPLAYED, you can
get/set preference "Max List Values Displayed" value using this property constant.
For example:
INode preferences =
session.getAdminInstance().getNode(NodeConstants.NODE_PREFERENCES);
IProperty prop =
preferences.getProperty(PropertyConstants.PROP_MAXIMUM_LIST_VALUES_DISPLAYED);
System.out.println("Current Value: " + prop.getValue());
prop.setValue("666");
System.out.println("New Value: " + prop.getValue());
if (users != null ) {
if (users.isEnabled()) {
propList.setValue(users);
} else {
System.out.println("Users list is not enabled.");
}
}
When you select a user-defined list using IListLibrary.getAdminList(), you can specify
the list by name or ID. All list names must be unique. The following example shows
how to select an Agile list called Colors.
12-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating Custom Lists
■ ATT_DESCRIPTION - the String description of the list. This is an optional field; the
default value is an empty string.
■ ATT_ENABLED - a Boolean value specifying whether the list is enabled. This is an
optional field; the default value is false.
■ ATT_CASCADED - a Boolean value specifying whether the list contains multiple
levels. This is an optional field; the default value is false. The ATT_CASCADED value
cannot be changed after the list is created.
Once the list is created, you can use the IAdminList interface to enable or disable the
list and set values for it.
The following example shows how to create a new list called Colors. This list is a
simple list with only one level.
Lists that contain String values are case-sensitive. This means that a list can contain
uppercase, lowercase, and mixed-case variations of the same value, which may not be
desirable. For example, the following code snippet adds three variations of each color
value to the Colors list.
list.addChild("green");
list.addChild("Purple");
list.addChild("PURPLE");
list.addChild("purple");
list.addChild("Red");
list.addChild("RED");
list.addChild("red");
list.addChild("White");
list.addChild("WHITE");
list.addChild("white");
Note: Lists that are created automatically by the Agile API have a
prefix "SDK" followed by a random number. You can rename such
lists, if you prefer.
The following example shows how to create a new cascading list called "Field Office."
The list has two levels.
12-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating Custom Lists
Important: When setting level names for cascading lists, always start
with the index 0 for the first level and increment the index subsequent
levels as shown in the following two examples below.
In cascading lists, level names used by the list must be unique and you cannot share
them between lists. The level names are stored internally, but Agile Java Client and
Web Client currently don't display them. The level names are needed only if you want
to show them in a cascading list UI that you created.
After you call the IAdminList.setValues() method, a valid ID is assigned to each list
value. Only leaf nodes, that is, nodes on the lowest level of a cascading list, have valid
IDs. In the previous example, the city nodes are leaf nodes. All other nodes have a null
ID. You can use the ID to set the selection of the IAgileList object.
You can add a list value and its parent nodes in one statement instead of adding the
parent node and then its subnodes. Use the | character to separate nodes, which
represent levels, in the string. The following example replaces a portion of the code in
the previous example; it shows how to add the same list values as in the previous
example, but using fewer lines of code.
Agile SDK supports creating, loading, and modifying Criteria-based lists by exposing
the necessary APIs to:
1. Get the Criteria
2. Create the Criteria-based list
3. Load the Criteria-based list
4. Replace the Criteria-based list
12-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Checking the Data Type of a List
The following examples use the respective APIs to perform these tasks.
Example 12–13 Getting the Criteria from the Agile Criteria library
IListLibrary library = m_admin.getListLibrary();
INode lib = m_admin.getNode(NodeConstants.NODE_CRITERIA_LIBRARY);
ICriteria criteria = (ICriteria)lib.getChild("All Change Orders");
case DataTypeConstants.TYPE_OBJECT:
//Add code here to handle Object values
break;
case DataTypeConstants.TYPE_STRING:
//Add code here to handle String values
break;
default:
//Add code here to handle other datatypes
}
}
Note: This method only applies to String values. You can only use
this method to modify String entries and not object entries.
12-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Renaming and Removing List Values
// Clean up
newList.delete();
}
Note: Level names for cascading lists are not displayed in Agile Java
Client or Web Client. However, you can choose to display them in
Clients you create with the Agile SDK.
12-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Printing Contents of IAgileList Objects
Deleting a List
If a list is not read-only and is not currently being used by an Agile dataobject, you can
delete it. Otherwise, the IAdminList.delete() method throws an exception. Once you
delete a list, it is removed permanently. You cannot undo the deletion.
The following example shows how to delete a list.
12-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
13
Working with Attachments and File Folder
31
Objects
Figure 13–1 File Folder objects referenced from Item and Change Attachments
The Agile API does not provide support for viewing or printing an attachment.
However, after you download a file, you can use another application to view, edit, or
print the attachment.
A File Folder is a business object that specifies one or more files or URLs that are
stored in the file server vault. In addition, a file folder has its own set of tables. This
means that you can create and load an independent file folder and add one or more
files to its Files table. You can also search for a file folder, just as you would search for
an Item or Change.
13-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with File Folders
For information about routing these objects, see "Checking the State of Agile PLM
Objects" on page 2-19.
Note: Note When you add a file or a URL to the row of the
Attachments table of a business object, you will automatically create x
a new file folder object that contains the associated file or URL. See
"Creating File Folder Objects by Adding Rows to Attachments Table"
on page 13-6.
The File Folders Design class is similar to the File folder class with the additional
Structures table (Tab in the Java Client UI) for CAD objects. The following examples
show how to create a Design object, adding a Design object to a the Structure tree, and
loading a structure table.
// add row
Object[] vers = childObj1.getVersions();
IRow row = table.createRow(childObj1);
row.setValue(FileFolderConstants.
ATT_STRUCTURE_LABEL,"label modified by creating row 1");
row = table.createRow(childObj2);
row.setValue(FileFolderConstants.ATT_STRUCTURE_LABEL,
"label modified by creating row 2");
obj.checkIn();
13-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with File Folders
Example 13–6 Creating a file folder by adding a row to the Attachments table
public IFileFolder addRowToItemAttachments
(IItem item, File file) throws Exception {
ITable attTable = item.getTable(ItemConstants.TABLE_ATTACHMENTS);
IRow row = attTable.createRow(file);
IFileFolder ff = (IFileFolder)row.getReferent();
return ff;}
Example 13–7 Adding files and URLs to the Files table of a file folder
public void addFiles(IFileFolder ff, File[] files, URL[] urls) throws Exception {
// Check out the file folder
ff.checkOutEx();
// Get the Files table
ITable filesTable = ff.getTable(FileFolderConstants.TABLE_FILES);
// Add files to the Files table
for (int i = 0; i < files.length; ++i) {
filesTable.createRow(files[i]);
}
// Add URLs to the Files table
for (int i = 0; i < urls.length; ++i) {
filesTable.createRow(urls[i]);
}
// Check in the file folder
ff.checkIn();
}
13-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Attachments Table of an Object
■ isSecure()
Results returned by IAttachmentFile methods vary depending on the object that you
are working with. See Table 13–3 below.
Create an iterator for the table, and then select a particular row. You can use the
ITable.getTableIterator() method to get a bidirectional iterator for the table.
The following example below shows how to retrieve an item, get the Attachments
table for the item, and then select the first attachment.
Example 13–9
try {
// Get Item P1000
Map params = new HashMap();
params.put(ItemConstants.ATT_TITLE_BLOCK_NUMBER, "P1000");
IItem item =
(IItem)m_session.getObject(IItem.OBJECT_TYPE, params);
// Get the attachment table for file attachments
ITable attTable = item.getAttachments();
// Get a table iterator
ITwoWayIterator it = attTable.getTableIterator();
// Get the first attachment in the table
if (it.hasNext()) {
IRow row = (IRow)it.next();
// Read the contents of the stream
InputSteam stream = ((IAttachmentFile)row).getFile();
}
else {
JOptionPane.showMessageDialog(null, "There are no files listed.",
"Error", JOptionPane.ERROR_MESSAGE);
}
} catch (APIException ex) {
System.out.println(ex);
}
Example 13–10
public InputStream checkOutRow(IRow row) throws APIException {
// Check out the attachment
((ICheckoutable)row).checkOutEx();
// Read the contents of the stream
InputStream stream = ((IAttachmentFile)row).getFile();
return stream;
}
13-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Attachments Table of an Object
if (row.isCheckedOut()) {
// Set the new file
((IAttachmentFile)row).setFile(new File(filePath));
// Check in the file
((ICheckoutable)row).checkIn();
}
else {
JOptionPane.showMessageDialog(null,
"The attachment is not checked out.","Error", JOptionPane.ERROR_MESSAGE);
}
}
Note: Only the user who checked out a file folder can cancel the
checkout.
13-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Files and URLs to the Attachments Table
When you add a file or a URL to the Attachments table of a business object, the server
automatically creates a new file folder containing the associated file or URL. The new
row on the Attachments table references the new file folder.
When you add a URL attachment, the server stores a reference to the Internet location
but does not upload a file. Therefore, you cannot download a URL attachment. The
Agile API validates URL strings that you attempt to check in as an attachment. If a
URL is invalid, the Agile API considers the string a filename instead of a URL.
You cannot add a file or URL to the Attachments table of an item if
■ The current revision has a pending or released MCO.
■ The current revision is incorporated.
When you use the ITable.createRow(java.lang.Object) method to add a row to the
Attachments table, the param method can be any of the following object types:
■ String - adds one file attachment specified by a local path.
■ String[] - adds multiple file attachments specified by an array of local paths.
■ File - adds one file attachment.
■ File[]- adds multiple file attachments.
■ InputStream - adds one file attachment.
■ InputStream[]- adds multiple file attachments.
■ URL - adds one URL attachment.
■ URL[] - adds multiple URL attachments.
■ IRow (of the Attachments or Files tables) - adds a file or URL attachment.
■ IFileFolder - adds all files and URLs for the specified file folder.
■ Map - adds one or more files specified by a hash table containing Attachment
parameters.
Note: The File object type performs best when adding attachments.
When you add a file or a URL to the row of the Attachments table of a business object,
you automatically create a new file folder that contains the associated file or URL. You
can load the referenced file folder using the IRow.getReferent() method, as shown in
the following example.
Example 13–15 Creating a file folder by adding a row to the Attachments table
public IFileFolder addRowToItemAttachments
(IItem item, File file) throws Exception; {
ITable attTable = item.getTable(ItemConstants.TABLE_ATTACHMENTS);
IRow row = attTable.createRow(file);
IFileFolder ff = (IFileFolder)row.getReferent();
return ff;
}
This example uses several instances of the addAttachment() methods to illustrate the
different ways you can add rows to an Attachments table.
// Add a file folder to the Attachments table & specify versions for all files
public static IRow addAttachmentWithVersion
(ITable attTable, IFileFolder ff) throws APIException {
ff.setCurrentVersion(new Integer(1));
IRow row = attTable.createRow(ff);
return row;
}
13-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Files and URLs to the Attachments Table
Example 13–18 Deep cloning the Files table row of a File Folder
// Clone a Files table row and its file from one File Folder to another
public static cloneFilesRow
(IFileFolder folder1, IFileFolder folder2, File file) throws APIException {
Example 13–19 Specifying the file folder subclass when adding attachments
IAgileClass ffclass = m_admin.getAgileClass("MyFileFolder");
// init item
IItem item = (IItem)session.createObject(ItemConstants.CLASS_PART, "P0001");
// prepare map
HashMap map = new HashMap();
map.put(CommonConstants.ATT_ATTACHMENTS_CONTENT, new File("files/file.txt"));
map.put(CommonConstants.ATT_ATTACHMENTS_FOLDERCLASS, ffclass);
// add file
IRow row = tab_attachment.createRow(map);
13-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Files and URLs to the Attachments Table
If you use IFileFolder.getFile() to return a zipped file stream for all files contained in a
file folder, you can extract files from the zipped InputStream file using methods of the
java.util.zip.ZipInputStream class, as shown in the following example.
The Agile API provides no direct method for opening an attachment file. However,
you can retrieve a file and then have your program open it in a separate application or
display it in a browser window.
To delete a row from the Attachments table of a business object, use the
ITable.removeRow() method. For more information, see "Removing Table Rows" on
page 4-16. Removing a row from the Attachments table does not delete the associated
file folder. You cannot delete a row from the Attachments table in the following
situations:
Accessing Thumbnails
Agile SDK provides the IThumbnailContainer interface for generalized access to
thumbnail-related operations for file folder and business objects. This interface is
supported by the following API objects:
■ IFileFolder object
■ IItem object
■ IManufacturerPart object
For IFileFolder objects, set the applicable version using
IFileFolder.setCurrentVersion before calling the above APIs. The default version is
LATEST_VERSION. For IItem or IManufacturerPart objects, use the revision that is
already set on these objects.
The following example gets thumbnail details from TitleBlock of an IItem or
IFileFolder object.
Example 13–22 Getting thumbnail details from TitleBlock of IItem or IFileFolder objects
IItem dataObj = (IItem)session.getObject(IItem.OBJECT_TYPE, "P00015");
ITable titleBlockTable = dataObj.getTable(TableTypeConstants.TYPE_PAGE_ONE);
Iterator i = titleBlockTable.getTableIterator();
while (i.hasNext()) {
IRow row = (IRow)i.next();
Object thumbnailIDDetails =
row.getValue(ThumbnailConstants.ATT_THUMBNAIL_ATTACHMENT_TAB);
IAgileList[] nodes =((IAgileList)thumbnailIDDetails).getSelection();
for(int ii=0; ii<nodes.length; ii++) {
IAgileList childNode = nodes[ii];
IThumbnailID thumbnailID = (IThumbnailID)childNode.getValue();
}
}
13-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Files and URLs to the Attachments Table
Regenerating Thumbnails
Regenerating a thumbnail means generating a thumbnail for an existing (generated)
thumbnail for file folder and item objects. This feature is of particular interest in
assembly structures where a change in the child of the assembly structure is reflected
in the thumbnail after the thumbnail is regenerated.
Agile SDK provides the IThumbnailContainer.generateThumbnail(IThumbnailID)
API for this purpose. When invoked, it will generate and return a new thumbnail. In
case of IFileFolder objects, API will use the current version of the object. For IItem or
IManufacturerPart objects, it will use the current revision of the object. An
APIException is thrown when the API fails to regenerate the thumbnail for the
specified thumbnailID parameter.
Replacing Thumbnails
You can replace an Agile PLM generated thumbnail with a user provided image for
file folder and item objects. The SDK provides the following API for this purpose.
IThumbnailID replaceThumbnail (IThumbnailID oldThumbnailID, byte[] bytes)
throws APIException
This API will replace the thumbnail referred to in oldThumbnailID with the image file
referred to in the input stream. That is, it will return the ThumbnailID of the replaced
thumbnail.
For IFileFolder objects, the API will use the version that is already set on the object. For
IItem or IManufacturerPart objects, it will use the revision that is already set on the
object. An APIException is thrown if it fails to replace the thumbnail specified in the
oldThumbnailID parameter.
Sequencing Thumbnails
When Web Client users add attachment files to business objects, they can also set the
order (sequence) of their appearance in the Thumbnail Navigator. Agile PLM provides
the setThumbnailSequence API to enable this feature in the SDK. For IItem or
IManufacturerPart objects, the API will use the revision that is already set on the
object. The API will sort (sequence) the order of appearance using the thumbnailID
parameter. An exception is thrown if the function fails to set the master thumbnail.
13-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Files and URLs to the Attachments Table
m_session.createObject(FileFolderConstants.CLASS_DESIGN, "DESIGN00133");
13-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Files and URLs to the Attachments Table
13-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
14
Importing and Exporting Data with SDK
14
For more information about importing data, refer to Agile Integration Services Developer
Guide and Agile Import and Export Guide.
The following example uses these methods to validate the imported data for
compliance and import it into the PLM system upon validation.
try {
String _url="http://localhost/Agile";
String _user="admin";
String _pwd="agile";
String srcFilePath="bom.txt";
/* The value used by operations and options are the same as the value of "-t"
parameter in the import AIS sample command.
*/
String [] operations=new String[]{"items", "items.bom","items.aml"};
*/
List options=new ArrayList();
options.add("BusinessRuleOptions|ChangeMode=Authoring");
options.add("BusinessRuleOptions|BehaviorUponNonExistingObjects=Accept");
String _output="log.xml";
FileOutputStream fop=new FileOutputStream(_output);
14-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Validating Import Data and Importing Data
while((n=logStream.read(buf))!=-1){
fop.write(buf, 0, n);
}
fop.close();
}
catch (Exception e) {e.printStackTrace();
}
finally {session.close();
}
}
/*
* <p> Create an IAgileSession instance </p>
* @return IAgileSession
* @throws APIException
*/
14-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Importing and Exporting Microsoft Project 2010 Files
...
■ Validate API is also exposed in IProgram. This API enables validating the data in
the document that was retrieved from an existing Program in PPM.
Validate APIs of session and program uses the validateMSPXML API of the Activity to
validate do the XML data. It returns the MspSyncActivityVO object which provides the
validation results. The MspSyncActivityVO object is passed to the validateXML method
of PCUtil which processes the validation information. The validateXML method
returns true if the validation is successful and there were no errors. In case of any
validation errors, the exceptions are added to a batch exception file that is thrown.
Create Mode
For Create mode, the Import API is exposed in IAgileSession and enables publishing
the data which was newly created in the XML format from MSP to PPM.
■ API Signature
Object publishXML(Object documentObject, Object resNameToUserIdObject, Object
resNameToRolesObject, Integer templateType, boolean setScheduleEditorToPPM)
throws APIException
■ API Parameters
– documentObject - This parameter is a Document Object retrieved from the
MSP XML.
– resNameToUserIdObject - This parameter is a Map<String, Long/IUser> of
User Name to Agile User ID. User ID can be passed as a Long object or an
IUser object.
– resNameToRolesObject - This parameter is a Map<String, String/IRole[]>
of User Name to array of Roles. Roles can be a String array of Role IDs or an
array of IRole Objects.
– templateType - This parameter specifies the template type for the new project.
Values of template type are defined in ProgramConstants.java as ACTIVE_
STATE, TEMPLATE_STATE and PROPOSED_STATE.
– setScheduleEditorToPPM - This parameter determine whether the Schedule
Editor for the new Program is set to PPM or not.
14-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Importing and Exporting Microsoft Project 2010 Files
Update Mode
The import API for Update mode is exposed in IProgram and enables users to publish
the data that was retrieved from PPM and modified in MSP
■ API Signature - This API takes only three parameters explained above.
Object publishXML(Object xmlDocument, Object resNameToUserIdObject,Object
resNameToRolesObject) throws APIException
■ Code sample
IProgram program = (IProgram)program.publishXML(document, resNameToUserId,
resNameToRoles);
The Import API for session and program publishes the XML data to PPM only if data
validation is successful. It will then call the validate API to ensure the data designated
for publication is correct. Once validation is successful without any errors,
SyncMspToPE API of Activity is used to publish the XML data to PPM. Data in
resNameToUserIdObject and resNameToRolesObject is prepared by
prepareUsersForMSP of PCUtil in the required format for SyncMspToPE.
API Signature
Object saveAsXML(Integer saveAsXMLMode) throws APIException;
The saveAsXMLMode is the only parameter that is supplied to the API. It defines the
mode in which the data is exported. The values of saveAsXMLMode are defined in
ProgramConstants.java as SAVE_AS_XML_READ and SAVE_AS_XML_EDIT. If the mode
type is Read, then the data exported to MSP is available for read-only purposes and
cannot be published back to PPM. If the mode type is Edit, then the exported data can
be modified in MSP and can be published back to PPM.
document =
(org.jdom.Document)program.saveAsXML(ProgramConstants.SAVE_AS_XML_EDIT);
The export API uses the SyncPEToMSP API of Activity to return the program data in the
form of org.jdom.Document object.
14-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
15
Managing Workflow
15
About Workflow
■ Route changes automatically to the users who need to approve or observe the
change.
■ Send mail alerts automatically to approvers and observers to notify them that a
change has been routed to them.
■ Approve or reject changes online.
■ Attach comments to changes.
Agile has electronic routing, Notification, and signoff capabilities, thus automating the
change control process and providing a simplified but powerful Workflow
mechanism. With these Workflow features, you can
Example 15–2 Getting status of a change object and comparing it to a status type
private static boolean isReleased(IChange change) throws APIException {
return (change.getStatus().getStatusType().
equals(StatusConstants.TYPE_RELEASED);
}
15-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Selecting a Workflow
To determine at run time whether a user has the appropriate privileges to perform an
action, use the IUser.hasPrivilege() method. You can adjust your program's UI
based on the user's privileges. The following example shows how to check whether a
user has the privilege to change the status of a change before calling the
IRoutable.changeStatus() method.
Example 15–3 Checking the privileges of a user before changing the status of a change
private void goToNextStatus(IChange change, IUser user) throws APIException {
Selecting a Workflow
When you create a new change, package, product service request, or quality change
order, you must select a Workflow. Otherwise, the object is in an unassigned state and
cannot progress through a Workflow process. Your Agile system can have multiple
Workflows defined for each type of routable object. To retrieve the valid Workflows for
an object, use the IRoutable.getWorkflows() method. If a routable object has not been
assigned a Workflow yet, you can use the IRoutable.getWorkflows() method to select
a Workflow.
As long as a change is in the Pending status, you can select a different Workflow. Once
a change moves beyond the Pending status, you can't change the Workflow.
return workflow;
}
If a change is still in the Pending status type, you can deselect a Workflow to make the
change “unassigned.” To make a change unassigned, use IRoutable.setWorkflow()
and specify null for the Workflow parameter.
If a user that you select as an approver or observer, do not have appropriate privileges
to view a change, your program throws an APIException. To avoid the possible
exception, check the privileges of each user before adding him to the approvers or
observers list.
15-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding and Removing Approvers
The following example shows how to add and remove approvers for a change.
If you want to modify only the list of approvers or the list of observers for a change,
you can pass a null value for the parameter you don’t want to change. The following
example shows how to add the current user to the approvers list without changing the
list of observers.
// Add the current user to the approvers list for the change
IUser[] approvers = new IUser[]{user};
change.addApprovers(change.getStatus(), approvers, null, true,
"Adding current user to approvers list");
} catch (APIException ex) {
System.out.println(ex);
}
If you want to modify only the list of approvers or the list of observers for a change,
you can pass a null value for the parameter you don't want to change. Example 15–7
adds current users to the list of approvers without changing this list.
When you use the IRoutable.approve() method, specify the user's approval
password and an optional comment. The approve() methods enable you to specify a
Notification list and a collection of user groups for which you are approving.
After installing the Agile SDK, API Reference files, shown in Figure 15–1, "API
reference files" are available and accessible from the Oracle® E-Cloud Web site at
http://edelivery.oracle.com. You can locate and download the void approve
(String, Collection) throws APIException method from this site.
Following paragraphs document approving or rejecting a given routable object. APIs
that support approving or rejecting a change object when a second signature is
required are described in detail in Setting the “Signoff User Dual Identification”
Preference.
Example 15–8
public void approveChange(IChange change){
try {
change.approve("agile","", "Looks good to me",
null, null, null, null, false, false, false, false, false);
} catch (APIException ex) {
System.out.println(ex);
}
To download SDK’s approve and reject methods, locate the IRoutable Interface
Reference from http://edelivery.oracle.com and then look for these methods
under "Public Member Functions." See "IRoutable Approve and Reject methods."
15-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding and Removing Approvers
If a change has a fundamental flaw, users listed on the Workflow table may reject it.
When you reject a change, the system records the rejection on the Workflow tab for the
change and sends an email Notification to the change analyst or component engineer.
The change analyst or component engineer may decide to return the rejected change to
the originator, thus reverting its status to Pending.
When you use the IRoutable.reject() method, you must specify the
userNotifications approval password and optional comments. An overloaded
reject() method enables specifying a Notification list and a collection of user groups for
which you're approving. For more information and additional examples similar to
Figure 15–9, refer to the API Reference files at Oracle® E-Cloud Web site
(http://edelivery.oracle.com/).
The following example shows how to reject a change.
Commenting a Change
When you comment a change, you send a comment to other CCB reviewers during the
online approval process. In addition to the comment, you can specify whether to notify
the originator, the change analyst, and the change control board. An overloaded
comment() method allows you to specify a Notification list. For more information,
similar to refer to the API Reference files at Oracle® E-Cloud Web site
(http://edelivery.oracle.com/).
The following example shows how to comment a change.
Auditing a Change
At any point in a change's workflow, you can audit it to determine if any required
entry cells are not completed or if the change violates any Agile Smart Rules. When
you use the IRoutable.audit() method, the method returns a Map object containing
ICell objects as keys and a List of APIException objects as values. The ICell key can
be null if there are no problems with the change. The APIException object describes a
problem with the associated entry cell.
The Map object returned by the audit() method may also contain null objects as keys.
The APIException object associated with a null object describes a problem unrelated to
data cells.
15-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding and Removing Approvers
// Iterate through the cells and print each cell name and exception
while (it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
ICell cell = (ICell)entry.getKey();
if(cell != null) {
System.out.println("Cell : " + cell.getName());
}
else {
System.out.println("Cell : No associated data cell");
}
false);
} catch (APIException ae) {
try {
if
(ae.getErrorCode().equals
(ExceptionConstants.API_SEE_MULTIPLE_ROOT_CAUSES)){
Throwable[] causes = ae.getRootCauses();
for (int i = 0; i < causes.length; i++) {
m_session.disableWarning(
(Integer)((APIException)causes[i]).getErrorCode());
}
} else {
m_session.disableWarning((Integer)ae.getErrorCode());
}
} catch (Exception e) {
throw ae;
}
continue;
}
break;
}
In general, you release a change after it is signed off by CCB members. In addition to
modifying the status of a change, you can also use changeStatus() to specify a
Notification list, optional comments, and whether to notify the originator and change
control board.
Note: To use the default Notification list for the Workflow status,
specify a null value. To indicate that no users should be notified,
specify an empty array.
15-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding and Removing Approvers
For both the approvers and observers parameters of the changeStatus() method, you
must explicitly pass an array of users or user groups. If you pass null, no approvers or
observers are used. To get the default approvers and observers for a particular
Workflow status, use getApproversEx() and getObserversEx(), respectively.
The following example shows how to check the Workflow status of a change.
The following example shows how to use the default approvers and observers when
you change the status of a routable object.
Example 15–15 Changing the status and routing to the default approvers and observers
public void changeToDefaultNextStatus(IChange change) throws APIException {
// Get the next status of the change
IStatus nextStatus = change.getDefaultNextStatus();
15-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Functional Teams
Note: Users can have more than one Reviewer role, but they cannot
be Acknowledgers, Observers and/or Approvers.
– Observers - A workflow action that requires the notified users to signoff when
notified. Observers can be Users, User Groups or Functional Teams.
– Acknowledgers - A workflow action that requires the notified users to signoff
the change they have approved. This is different from an approval signoff.
Acknowledgers can be Users, User Groups or Functional Teams.
– Approvers - An approvers can sign -off for multiple job functions. Approvers
can be Users, User Groups or Functional Teams.
15-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Functional Teams
Functional Teams is a class under User Group Base Class having out of the box sub
class 'Functional Team'. Creating Functional Team object is similar to creating any
Agile object as detailed below:
Managing Timesheets
PPM has the capability to manage the following Timesheet-related functions from the
Web Client. The SDK enables performing the functions programmatically, by exposing
the ITimesheetManager.
■ Retrieving tasks a user can report time against - This feature enables retrieving
the Web Client's Timesheet view and the list of tasks the user can report time
against programmatically.
■ Logging or modifying time reported for a user on a task - Similar to the Web
Client, this feature supports logging or modifying time by day or activity for the
user.
■ Retrieving hours for a user or activity - This feature enables searching and
retrieving hours for a user, an activity, a project, the date in between, and
Canceled and Soft-Deleted activities. Results are provided as CSV or XLS similar
to the UI
15-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Functional Teams
15-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
16
Managing and Tracking Quality
16
About Customers
The QualityChangeRequest object stores contact information about a customer. What
role does a customer have in the Agile PLM system? Customers provide feedback on
your company's products, alerting you to quality issues or problems they encounter.
This object can originate in another system, such as a CRM system. You can use the
Agile API to import customer data and problem reports from CRM systems into the
Agile PLM system.
Creating a Customer
To create a customer, use the IAgileSession.createObject() method. At a minimum,
you should specify values for the General Info.Customer Name and General
Info.Customer Number attributes.
Loading a Customer
To load a customer, use the IAgileSession.getObject() method. To uniquely
identify a customer, specify the value for the General Info | Customer Number
attribute.
16-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Product Service Requests
For the params parameter, specify the General Info | Customer Name and General
Info | Customer Number attributes.
Problem reports can be routed for investigation. The investigating team, consisting of
Quality Analysts, determines the root cause of the problem and decides whether to
escalate the problem into an issue.
16-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Product Service Requests
//Attribute variable
IAttribute attr = null;
16-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Quality Change Requests
fulfilled. Audits can be initiated against items for which no problems have been
reported.
Example 16–10
public IChange saveQCRasECO(IAgileSession session, IQualityChangeRequest qcr)
throws APIException {
// Add code here to copy affected items from the QCR to the ECO
return eco;
}
16-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Using Workflow Features with PSRs and QCRs
*/
* Get the current Workflow which is a null object
* because the Workflow has not been set yet)
/*
IWorkflow wf = pr.getWorkflow();
You can also set the Workflow for a Product Service Request or a Quality Change
Request by selecting a value for the Cover Page.Workflow field, as shown in the
following example.
16-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
17
Managing Product Governance & Compliance
17
Items, Manufacturer Parts, and Part Groups are objects that are also related to Agile
PG&C. They have Specifications, Compositions, and Substances tables that are
populated with data when declarations are released. For Manufacturer Parts, you can
edit the Compositions and Substances tables directly without submitting a declaration.
Also, other common Agile API interfaces, such as ITable, IDataObject, and ICell, are
also used to work with Agile PG&C objects.
17-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating Declarations, Specifications, and Substances
Creating Declarations
A Declaration object is the main record of Agile PG&C. It tracks the substances and
materials that are used for items, manufacturer parts, and part groups. When you
release a declaration, the information gathered from it is published to the product
record, thereby updating the Composition data contained within the items,
manufacturer parts, and part groups listed by the declaration.
There are seven declaration subclasses provided with Agile PLM:
■ Homogeneous Material Declaration - A homogeneous material composition
declaration that uses material-level specifications.
■ IPC 1752-1 Declaration - A material composition declaration for electronic
products that conforms to IPC standards and uses only one part-level
specification.
■ IPC 1752-2 Declaration - A homogeneous material composition declaration for
electronic products that conforms to IPC standards and uses only one
material-level specification.
■ JGPSSI Declaration - A material composition declaration that follows the Japanese
Green Procurement (JGP) standard and uses part-level specifications.
■ Part Declaration - A material composition declaration that uses part-level or
material-level specifications.
■ Substance Declaration - A material composition declaration for each substance
within part-level specifications.
■ Supplier Declaration of Conformance - A questionnaire to assess supplier
compliance with specifications from customers and government agencies. The
survey addresses compliance at a general company level. Can be used for CSR
type declarations.
The procedure for creating a declaration is the same for all declaration subclasses. You
must specify the declaration subclass as well as values for the Cover Page.Name and
Cover Page.Supplier attributes. Other declaration attributes are optional.
By default, the Cover Page.Name field uses an Autonumber format with the prefix
“MD” (for “Material Declaration”). Although the Autonumber format is not required,
it is a good practice to use the same prefix for all declarations to make it easier to
search for them.
Note: The case required for the Cover Page.Name field depends on
the selected character set for the field. For more information about
defining and modifying character sets, Refer to the Agile PLM
Administrator Guide.
Supplier users with the (Restricted) Material Provider role can also create declarations.
However, in this case, only the Cover Page.Name attribute is required to create the
object. The CoverPage.Supplier attribute is filled in automatically with the user's
supplier organization.
The following example shows how to create a Substance declaration.
Creating Specifications
Specifications are used to state the criteria that a product is expected to meet or exceed.
They are generally used to limit the amount of restricted substances contained in a
product. Specifications can be internal documents issued by a company or industry, or,
more commonly, they are regulations issued by a governing body. Here are some
examples of government regulations:
■ Restrictions on the Use of Certain Hazardous Substances in Electrical and
Electronic Equipment (RoHS) Directive, issued by the European Union
■ Waste Electrical and Electronic Equipment (WEEE) Directive, issued by the
European Union
■ Food Allergen Labeling and Consumer Protection Act (FALCPA), issued by the
U.S.A. Food and Drug Administration (FDA)
A specification defines a list of substances, the parts-per-million (PPM) threshold for
each substance, and whether a particular substance is restricted. Compliance
Managers can use specifications to pre-populate material declarations with
appropriate substances to ensure compliance.
The only required attribute you must specify when you create a specification is
General Info.Name. The name must be unique. The name is case-insensitive, which
means “ROHS” is treated the same as "Rohs".
17-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating Substances
Creating Substances
There are four substance subclasses provided with Agile PLM:
■ Subpart - a subunit of a component manufacturer part. The Composition table of a
subpart can have other subparts, materials, substance groups, and substances.
■ Material - a compound consisting of several substances. The Composition table of
a material can have substance groups or substances.
■ Substance Group - a group of substances. The Composition table of a substance
group can have only substances.
■ Substance - a single element, such as lead, chromium, or cadmium. Substances do
not have a Composition table.
These substance subclasses comprise the hierarchy of objects that can appear on a
Composition table, also known as the Bill of Substances.
Creating a Substance
Like material objects, the only attribute you need to specify to create a substance is the
General Info.Name attribute, which is equivalent to the substance number. You can
also specify other optional attributes, such as General Info.CAS Number.
// Create a Map object to store parameters and initlize the params object.
Map params = new HashMap();
params.put(SubstanceConstants.ATT_GENERAL_INFO_NAME, num);
params.put(SubstanceConstants.ATT_GENERAL_INFO_CAS_NUMBER, casNumber);
Creating a Material
When you create a material object, the only attribute you need to specify is the General
Info.Name attribute, which is equivalent to the substance number. After you create a
material object, you can add substances to its Composition table.
Example 17–5 Creating a material object and adding substances to the new object
17-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Items, Manufacturer Parts, and Part Groups to Declarations
Creating a Subpart
A subpart object is a subunit of a component that is tracked in Agile PLM. Subparts
are parts without a part number that are used to create a bill of material of
manufacturer parts or parts within a composition.
Example 17–7 Adding items, manufacturer parts, and part groups to a declaration
public void addDecObjects(IDeclaration dec) throws APIException {
try {
HashMap params = new HashMap();
17-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Substances to Declarations
When you create a row in the Composition tables, you pass a Map object containing
attribute-value pairs. The following table lists the attributes the Map object must
contain:
Figure 17–1 Hierarchy for a Bill of Substances (Composition) with four child levels
try {
HashMap params = new HashMap();
ITable tblMfrPartComp =
dec.getTable(DeclarationConstants.TABLE_MANUFACTURERPARTCOMPOSITION);
params.put(DeclarationConstants.
ATT_PARENT_ROW, parentRow);
params.put(DeclarationConstants.
ATT_MANUFACTURER_PART_COMPOSITION_SUBSTANCE_NAME, dummyName);
params.put(DeclarationConstants.
ATT_MANUFACTURER_PART_COMPOSITION_SUBSTANCE_TYPE, subtype);
17-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Substances to Declarations
try {
HashMap params = new HashMap();
// Create a Declaration
String num = "MDTEST001";
ISupplier supplier =
(ISupplier)m_session.getObject(ISupplier.OBJECT_TYPE, "DISTRIBUTOR00007");
params.put(DeclarationConstants.ATT_COVER_PAGE_NAME, num);
params.put(DeclarationConstants.ATT_COVER_PAGE_SUPPLIER, supplier);
IAgileClass declClass =
m_session.getAdminInstance().getAgileClass(DeclarationConstants.
CLASS_HOMOGENEOUS_MATERIAL_DECLARATION);
IDeclaration dec = (IDeclaration)m_session.createObject(declClass, params);
ISubstance subpart =
(ISubstance)m_session.getObject(SubstanceConstants.
CLASS_SUBPART, "Steel Casing");
params.clear();
params.put(DeclarationConstants.
ATT_PARENT_ROW, rowMfrParts);
params.put(DeclarationConstants.
ATT_MANUFACTURER_PART_COMPOSITION_SUBSTANCE_NAME, subpart);
IRow rowSubpart = tblMfrPartComp.createRow(params);
// Add a material
ISubstance material =
(ISubstance)m_session.getObject(SubstanceConstants.
CLASS_MATERIAL, "Steel");
params.clear();
params.put(DeclarationConstants.ATT_PARENT_ROW, rowSubpart);
params.put(DeclarationConstants.
ATT_MANUFACTURER_PART_COMPOSITION_SUBSTANCE_NAME, material);
IRow rowMaterial = tblMfrPartComp.createRow(params);
ISubstance sub =
(ISubstance)m_session.getObject(SubstanceConstants.CLASS_SUBSTANCE,"Lead");
params.clear();
params.put(DeclarationConstants.ATT_PARENT_ROW, rowSubGroup);
params.put(DeclarationConstants.
ATT_MANUFACTURER_PART_COMPOSITION_SUBSTANCE_NAME, sub);
IRow rowSubs = tblMfrPartComp.createRow(params);
Example 17–10 Adding Part Level substances to Manufacturer Part Composition table
public void addSubstanceComp(IAgileSession m_session)
throws APIException {
try {
HashMap params = new HashMap();
//Create a Declaration
17-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Substances to Declarations
// Part Level
ISpecification spec =
(ISpecification)m_session.
getObject(ISpecification.OBJECT_TYPE, "Lead Part Level");
IRow rowSpec = tblSpec.createRow(spec);
//Add a substance
ISubstance sub =
(ISubstance)m_session.getObject(SubstanceConstants.CLASS_SUBSTANCE,"Lead");
params.clear();
params.put(DeclarationConstants.
ATT_PARENT_ROW, rowSubGroup);
params.put(DeclarationConstants.
ATT_MANUFACTURER_PART_COMPOSITION_SUBSTANCE_NAME, sub);
IRow rowSubs = tblMfrPartComp.createRow(params);
} catch (APIException ex) {
System.out.println(ex);
}
}
17-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Routing Declarations
Specifications may concern many substances, including those not used by the parts
contained in the declaration. When the declaration is opened to the supplier, any
relevant substances from the specifications are automatically added to the Item
Composition, Manufacturer Part Composition, and Part Group Composition tables.
This ensures that you are properly tracking any restricted substances contained in
parts listed in the declaration.
Routing Declarations
The Default Declarations Workflow follows a straightforward process flow, as shown
in Figure 17–2.
The following table describes each status in the Default Declarations workflow.
Before you can route a declaration, you should set values for the following three Cover
Page fields:
■ Cover Page.Compliance Manager
■ Cover Page.Workflow
■ Cover Page.Due Date
Technically, only the Compliance Manager and Workflow fields are required to route
the declaration. The Due Date field is optional but should be specified for tracking
purposes. The following example shows how to set values for these three fields.
Example 17–13 Setting values for Compliance Manager, Workflow, and Due Date fields
public void setFieldsNeededForRouting(IDeclaration dec) throws Exception {
17-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Completing Declarations
For more information about Agile APIs that support Workflow processes, see
Chapter 15, "Managing Workflow."
Completing Declarations
When a declaration is opened to a supplier, the supplier is responsible for completing
the declaration and disclosing if any restricted substances are contained in the
components and subassemblies it provides and whether those substances comply with
specifications. To complete and sign off on declarations, one or more contact users for
the supplier must be assigned the (Restricted) Material Provider role.
The Material Provider user should do the following to complete a declaration:
■ Fill in the Mass and Declared PPM fields or the Declared Compliance field for
every substance listed on the Item Composition, Manufacturer Part Composition,
and Part Group Composition tables, particularly for substances that are restricted
by specifications.
■ Complete other flex fields on the Composition tables as necessary.
■ Add or remove substances from the declaration.
When the declaration is complete, the Material Provider user can sign off and submit
the declaration to the Compliance Manager, described below.
The following example shows how the supplier can sign off and submit the
declaration to the Compliance Manager.
Publishing a Declaration
The Agile API does not provide a method to publish a material declaration to the
product record. Instead, a declaration is automatically published when it is released.
Therefore, as far as the API is concerned, the substances table for an item,
manufacturer part, or part group always reflects the last released declarations.
However, Agile Web Client allows you to select an later declaration and publish it,
thereby updating the substances information in the product record.
17-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Getting and Setting Weight Values
Note: This example converts the unit of measure in the source object
from 1234.21 Kilograms to its equivalent weight in Grams. Thus,
convert From is the source number you want to convert, Kilogram is
source unit of measure, and Gram is that target unit of measure which
are all randomly selected for this example.
Although the Agile PLM administrator can define new measures from the UOM node
in Agile Java Client, the Agile API supports only the Weight measure for Agile PG&C
objects. You cannot use the Agile API to define new measures.
Note: In Agile 9.2.1, the Title Block.Weight field for items was
changed to Title Block.Mass. However, the Agile API constant for the
field is still ItemConstants.TITLE_BLOCK_WEIGHT.
The following example shows how to get and set values for the Title Title Block.Mass
field of an item.
Example 17–17 Getting and setting the mass (weight) value for an item
private IUnitOfMeasure getMassValue(IItem item) throws APIException {
IUnitOfMeasure uom =
(IUnitOfMeasure)item.getValue(ItemConstants.ATT_TITLE_BLOCK_WEIGHT);
System.out.println("Value: " + uom.getValue());
System.out.println("Unit: " + uom.getUnit().toString());
return uom;
}
private void setMassValue(IItem item, double value, String unit)
throws APIException {
IUnitOfMeasure uom = null;
IUnitOfMeasureManager uomm =
(IUnitOfMeasureManager)m_session.getManager(IUnitOfMeasureManager.class);
uom = uomm.createUOM(value, unit);
item.setValue(ItemConstants.ATT_TITLE_BLOCK_WEIGHT, uom);
System.out.println("Value: " + uom.getValue());
System.out.println("Unit: " + uom.getUnit().toString());
}
If you create a query to search for items by mass, only the numeric value is searched,
not the unit. The server converts mass values to the standard unit before returning
query results. For example, the following query returns all items whose mass value is
between1.0 and 2.0 grams (the default standard unit). Items with a mass between 1000
and 2000 milligrams would also be included in the search results.
The procedure for adding rows to the Substances table of a Manufacturer Part is
similar to the way you add rows to the composition tables for a declaration. Follow
these steps to add substance compositions into a manufacturer part:
2. Add a row to the Compositions table. You must specify a value for the
ManufacturerPartConstants.ATT_COMPOSITIONS_COMPOSITION_TYPE attribute.
3. Add one or more rows to the Substances table. Each row must reference the parent
row from the Compositions table. Use the virtual attribute
ManufacturerPartConstants.ATT_PARENT_ROW to specify the parent row. When
you add a substance, specify the substance name and substance type.
For additional rules about adding substances to the Substances table, see "Rules for
Adding Substances" on page 17-10..
The Composition Type attribute for the parent row determines the types of substances
you can add to the Substances table. There are three possible Composition Type
values:
17-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Substance Compositions for Manufacturer Parts
// Add Spec
IRow rowSpec = tblSpec.createRow(spec);
// Add a subpart
ISubstance subpart = (ISubstance)m_session.
// Add a material
ISubstance material = (ISubstance)m_session.getObject
(SubstanceConstants.CLASS_MATERIAL, "Steel");
params.clear();
params.put(ManufacturerPartConstants.ATT_PARENT_ROW, rowSubpart);
params.put(ManufacturerPartConstants.
ATT_SUBSTANCES_SUBSTANCE_NAME, material);
IRow rowMaterial = tblSubs.createRow(params);
// Add a substance
ISubstance sub = (ISubstance)m_session.
getObject(SubstanceConstants.CLASS_SUBSTANCE,"Lead");
params.clear();
params.put(ManufacturerPartConstants.ATT_PARENT_ROW, rowSubGroup);
params.put(ManufacturerPartConstants.ATT_SUBSTANCES_SUBSTANCE_NAME, sub);
IRow rowSubs = tblSubs.createRow(params);
} catch (APIException ex) {
System.out.println(ex);
}
}
17-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Rolling Up Compliance Data
Assembly 2
Item1
Item3
//
query.setCriteria("["+SDKWrapper.getString("TITLE_BLOCK") +"."+SDKWrapper
.getString("IQuery_Number")+"] Equal To '"+item.getName()+"'");
ITable results=query.execute();
if (results.size() > 0) {
Iterator it = results.getReferentIterator();
if (it.hasNext()) {
IItem obj = (IItem)it.next();
IItem tlaItem = (IItem)m_session.getObject
(IItem.OBJECT_TYPE, obj.getName());
tlaItem.rollup();
}
}
else {
item.rollup();
}
} catch (APIException e) {
throw e;
}
return;
}
17-24 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Rolling Up Compliance Data
try {
itemRollup(itemStr);
} catch (APIException e) {
int error =((Integer)e.getErrorCode()).intValue();
}
}
return;
}
Example 17–23 Setting the value of the Calculated Compliance field for Item objects
// COMPLIANT is the actual value of the Calculated Compliance field which shows
// the Specification is compliant or not, based on the customized calculated
// compliance result.
String COMPLIANT = "Compliant";
Similar to the previous API, when this value is set by the SDK Client, it is never
overwritten during the Rollup within the declaration. This API allows users to set the
calculated compliance value based on their own defined logic, instead of using the
system's default logic.
Example 17–24 Setting values for Calculated Compliance field of Declaration objects
// complianceValue -- This is the customized calculated compliance
value and shows if the part is compliant to a Spec
String ComplianceValue = "Compliant";
Example 17–25 Setting values for Calculated Overall Compliance field of an Item object
Private static void test_OverallComplianceofItem (IAgileSession session) {
Try {
17-26 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Rolling Up Compliance Data
Example 17–26 Setting values for Calculated Overall Compliance field of Manufacture
Part objects
private static void OverallComplianceOfMfrpart(IAgileSession session) {
HashMap params = new HashMap();
params.put(ManufacturerPartConstants.
ATT_GENERAL_INFO_MANUFACTURER_PART_NUMBER, "mfrpart001");
params.put(ManufacturerPartConstants.
ATT_GENERAL_INFO_MANUFACTURER_NAME, "ACT");
try {
IManufacturerPart mfrPart = (IManufacturerPart) session.getObject
(ManufacturerPartConstants.CLASS_MANUFACTURER_PART, params);
mfrPart.setCalculateOverallCompliance();
} catch (APIException e) {
e.printStackTrace();
}
}
17-28 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Rolling Up Compliance Data
ISpecification sp = regulation.createRegulationwithNumberRollupEngine
("Specification", "sina", true);
17-30 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
18
Managing Agile PPM Calendars
18
ICalendarManager manager =
(ICalendarManager)session.getManager(ICalendarManager.class);
Map<Integer, Object> param = new HashMap<Integer, Object>();
param.put(WorkCalendarConstants.ID_CALENDAR_NAME,"SDK1");
param.put(WorkCalendarConstants.ID_CALENDAR_ENABLED, "Yes");
// create calendar
ICalendar calendar = manager.createCalendar(param);
System.out.println(calendar);
The following code sample is an example of creating a PPM calendar:
18-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Performing Calendar-related Tasks using Agile SDK
The following code sample shows how to get and set an existing a PPM calendar’s
workweek settings:
ICalendarManager manager =
(ICalendarManager) session.getManager(ICalendarManager.class);
The following code sample shows how to add and update working and non-working
days in PPM Calendars:
ICalendarManager manager =
(ICalendarManager)session.getManager(ICalendarManager.class);
// get the calendar
ICalendar calendar = manager.getCalendar("SDK1");
The following code samples get and print a PPM Calendar’s exception days as well as
exception days for a specific calendar year:
ICalendarManager manager =
(ICalendarManager)session.getManager(ICalendarManager.class);
// get the calendar
ICalendar calendar = manager.getCalendar("SDK1");
System.out.println(calendar);
Agile SDK exposes the following interface to delete existing PPM Calendar’s
ICalendarManager manager =
(ICalendarManager)session.getManager(ICalendarManager.class);
// remove calendar
manager.removeCalendar("SDK1");
Examples
The following code samples show accepting changes to a PPM Calendar and changing
the Status of a PPM Calendar to Cancel, or Not Started.
Accepting Changes
IProgram program = (IProgram) session.getObject(IProgram.OBJECT_TYPE, "PGM00011");
program.acceptCalendarChange();
} else {
cancelTask(proposedTask,getCancelStatusForWorkflow(proposedTask));
System.out.println("task changed to canceled");
18-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Accepting Changes and Changing the Status of Calendar
}
private static IStatus getCancelStatusForWorkflow(IProgram obj){
IWorkflow workflow = null;
IStatus status = null;
IStatus[] statuses = null;
try{
workflow = obj.getWorkflow();
status = null;
if(workflow!= null){
statuses = workflow.getStates();
int noOfStatuses = statuses.length;
for (int i = 0; i < noOfStatuses; i++) {
status = statuses[i];
if(status.getStatusType()
.equals(StatusConstants.TYPE_CANCEL))break;
}
}
}catch(APIException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
return status;
}
try{
workflow = obj.getWorkflow();
status = null;
if(workflow!= null){
statuses = workflow.getStates();
int noOfStatuses = statuses.length;
for (int i = 0; i < noOfStatuses; i++) {
status = statuses[i];
if(status.getStatusType().equals
(StatusConstants.TYPE_PENDING))break;
}
}
}catch(APIException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
return status;
}
18-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
19
Creating and Managing Projects
19
Note: In Release 9.3, the name of the Program Base Class was
changed to Projects and Projects to Sourcing Projects. However the
interface for the Projects Base Class is still called IProgram in the SDK
Guide and in Javadoc references.
and roles, and history and content of related activities. For management visibility, data
is rolled up to higher levels by rules and parent-child relationships.
The Agile API provides support for creating, loading, and working with Projects. The
IProgram interface represents all Project objects, including programs, phases, tasks,
and gates.
Similar to other Agile PLM business objects, the IProgram interface implements
IRoutable, which means it uses the same IRoutable.changeStatus() method to
change a Projects' Workflow status and to route it to other users. For more information,
"Changing the Workflow Status of an Object" on page 15-9.
Creating Projects
Use the IAgileSession.createObject() method to create Projects. When you specify
the Project's parameters, you must specify the Project subclass (for example, Program,
phase, task, or gate). For Programs, phases, and tasks, you must also specify following
required Project attributes:
■ General Info.Name
■ General Info.Schedule Start Date
■ General Info.Schedule End Date
■ General Info.Duration Type
For gates, only two attributes are required, General Info.Name and General
Info.Schedule End Date.
The following example shows how to create new Projects and specify the required
attributes.
19-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Creating Projects
// Create Projects
IProgram program =
(IProgram)m_session.createObject(ProgramConstants.CLASSPROGRAM, params);
} catch (APIException ex) {
System.out.println(ex);
}
Projects contain other types of activities, such as phases, tasks, and gates. A gate is a
special milestone-a task with an end date but no duration-that denotes the completion
of a set of related phases, tasks, or Projects. The following figure shows the hierarchy
of Project objects.
You can use the IAgileSession.createObject() method to create phases, tasks, and
gates in the same way that you create other Project objects. Once you create these
different types of activities, you can add them to the Schedule table of a Projects object.
For more information, see "Scheduling Projects" on page 19-9.
//Add Rule
HashMap map = new HashMap();
map.put(CommonConstants.ATT_RELATIONSHIPS_RULE_CONTROLOBJECT, pgm);
map.put(CommonConstants.ATT_RELATIONSHIPS_RULE_AFFECTEDOBJECT, eco);
map.put(CommonConstants.ATT_RELATIONSHIPS_RULE_CONTROLOBJECTSTATUS,
ctl_status);
map.put(CommonConstants.
ATT_RELATIONSHIPS_RULE_AFFECTEDOBJECTSTATUS, aff_status);
row.setValue(CommonConstants.ATT_RELATIONSHIPS_RULE, map);
19-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Using Project Templates
System.out.println(row.getCell
(CommonConstants.ATT_RELATIONSHIPS_RULE));
}catch (APIException ex) {
System.out.println(ex);
}
Loading Projects
To load Projects, use the IAgileSession.getObject() method. To uniquely identify a
Project object, specify the value for the General Info.Number attribute. You can also
load a Project object by searching for it by name, and then selecting it from the search
results.
Note: The News table for Projects is disabled by default. To enable it,
log in to the Java Client as an Administrator and make the News tab
visible.
■ Create a new Project from a template and specify the tables that you want copied
over
■ Change the owner of the Project and the owner of the children
■ Create a new Project template by saving a Project as a template
// Available values for Template attribute are Active, Proposed, and Template
templateList.setSelection(new Object[] {"Active"});
map.put(ProgramConstants.ATT_GENERAL_INFO_NAME, name);
map.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_START_DATE, new Date());
map.put(ProgramConstants.ATT_GENERAL_INFO_TEMPLATE, templateList);
// Define the tables to copy to the new program from the template
Integer pagetwo = ProgramConstants.TABLE_PAGETWO;
Integer pagethree = ProgramConstants.TABLE_PAGETHREE;
Integer team = ProgramConstants.TABLE_TEAM;
Object[] tables = new Object[]{pagetwo, pagethree, team};
19-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Using Project Templates
This is done by specifying a value for both the ProgramConstants and the OWNER
attribute. The value for the OWNER attribute is required in order to change the
Project's ownership. Set the Boolean applyToChildren to true if you want to apply the
OWNER value to all children.
In the UI, when you create a Project from a template, you have the option to change
ownership of the Project and apply the change to the children. In this situation, the
SDK mirrors the UI. However, the original Project must be a Template to create a Project
from a template via SDK's saveAs() API.
Example 19–6 Creating Projects from a template, change owner, and propagate change
public IProgram saveTemplateAndSetOwner (IProgram template, String userID, boolean
applyToChildren) throws APIException {
if (program != null) {
// Create a hash map of program attributes for the new program
HashMap map = new HashMap();
String name = "Rapid Development");
IAttribute att =
m_admin.getAgileClass(ProgramConstants.CLASPROGRAM).getAttribute
(ProgramConstants.ATT_GENERAL_INFO_TEMPLATE);
IAgileList templateList =
att.getAvailableValues();
// Available values for Template attribute are Active, Proposed, and Template
templateList.setSelection(new Object[] {"Template"});
map.put(ProgramConstants.ATT_GENERAL_INFO_NAME, name);
map.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_START_DATE, new Date());
map.put(ProgramConstants.ATT_GENERAL_INFO_TEMPLATE, templateList);
19-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Scheduling Projects
Scheduling Projects
To schedule Projects, edit the Schedule table, which lets you add, edit, and remove
schedule items. To add a new row to the Schedule table, use the ITable.createRow()
method and specify an IProgram object for the parameter.
// Get a Project
IProgram program =
(IProgram)m_session.getObject(ProgramConstants.CLASS_PROGRAM, "PGM00012");
if (program != null) {
// Get the Schedule table
ITable schedule = program.getTable(ProgramConstants.TABLE_SCHEDULE);
Iterator i = schedule.iterator();
// Add a phase
HashMap info = new HashMap();
info.put(ProgramConstants.ATT_GENERAL_INFO_NAME, "Specifications phase");
info.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_START_DATE,
df.parse("06/01/15"));
info.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_END_DATE,
df.parse("06/10/15"));
IAttribute attr = m_admin.getAgileClass(ProgramConstants.CLASS_PHASE).
getAttribute(ProgramConstants.ATT_GENERAL_INFO_DURATION_TYPE);
IAgileList list = attr.getAvailableValues();
list.setSelection(new Object[] {"Fixed"});
info.put(ProgramConstants.ATT_GENERAL_INFO_DURATION_TYPE, list);
IProgram phase =
(IProgram)m_session.createObject(ProgramConstants.CLASS_PHASE, info);
row = schedule.createRow(phase);
// Add a task
info = null;
list = null;
info.put(ProgramConstants.ATT_GENERAL_INFO_NAME, "Write specifications");
info.put(ProgramConstants.ATT_GENERAL_INFO_NUMBER, "T000533");
info.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_START_DATE,
df.parse("06/01/15"));
info.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_END_DATE,
df.parse("06/05/15"));
attr = m_admin.getAgileClass(ProgramConstants.CLASS_TASK).
getAttribute(ProgramConstants.ATT_GENERAL_INFO_DURATION_TYPE);
list = attr.getAvailableValues();
list.setSelection(new Object[] {"Fixed"});
info.put(ProgramConstants.ATT_GENERAL_INFO_DURATION_TYPE, list);
IProgram task =
(IProgram)m_session.createObject(ProgramConstants.CLASS_TASK, info);
row = schedule.createRow(task);
// Add a gate
info = null;
info.put(ProgramConstants.ATT_GENERAL_INFO_NAME, "Specifications complete");
info.put(ProgramConstants.ATT_GENERAL_INFO_SCHEDULE_END_DATE,
df.parse("06/10/15"));
IProgram gate =
(IProgram)m_session.createObject(ProgramConstants.CLASS_GATE, info);
row = schedule.createRow(gate);
}
} catch (APIException ex) {
System.out.println(ex);
}
Once a Project's schedule is defined, you can reschedule the project with the
IProgram.reschedule() method. The reschedule() method takes a couple of
parameters, the IProgram.RESCHEDULE constant and the new value for that schedule
option. Here are the list of IProgram.RESCHEDULE constants you can use:
■ STARTDATE - This moves the scheduled start date to the specified date.
■ ENDDATE - This moves the scheduled end date to the specified date.
■ BACKWARDDAYS - This moves the schedule backward by the specified number
of days.
■ FORWARDDAYS - This moves the schedule forward by the specified number of
days.
19-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Setting Start and End Timestamps for PPM Date Attributes
Note: If the specified time for the above Date attributes is not within
the Start and End values set in agile.properties, PPM will not complete
the end operation of the user. For example, if the Start and End values
in agile.properties are 8:00 AM and 6:00 PM and those specified by the
user are different, PPM will not complete the applicable operation.
Note: This is a global setting and the setting will apply to all SDK
programs that are running on the given platform.
// Create a baseline
Object baseline = program.createBaseline("august 8 baseline");
19-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Resources to a Project Team
// Get a user
IUser user1 =
(IUser)m_session.getObject(UserConstants.CLASS_USER, "kkieslowski");
if (user1 != null) {
// Delegate the task to the user
task.delegateOwnership(user1, false);
}
}
} catch (APIException ex) {
System.out.println(ex);
}
When you add a resource to the Team table, you specify what roles the user or user
group has for that Project object. The roles available are not the complete set of Agile
PLM roles; they are roles specifically related to Project functionality. Here is the list of
roles you can assign to team members:
■ Executive
■ Change Analyst
■ Program Team Member
■ Program Manager
■ Resource Pool Owner
■ Program Administrator
For a description of each of these roles, refer to the Agile PLM Administrator Guide.
The Team table has two attributes that require special mention:
■ ProgramConstants.ATT_TEAM_NAME
■ ProgramConstants.ATT_TEAM_ROLES.
These are SingleList and MultiList attributes, respectively. To get the available
values for these attributes, use ITable.getAvailableValues() instead of
IAttribute.getAvailableValues(). Otherwise, the IAgileList object returned by the
method can contain invalid list values.
// Get a Project
IProgram program =
(IProgram)session.getObject(IProgram.OBJECT_TYPE, "PGM02423");
if (program != null) {
// Get the Team table of the program
ITable teamTable = program.getTable(ProgramConstants.TABLE_TEAM);
// Get Roles attribute values (use ITable.getAvailableValues)
IAgileList attrRolesValues =
teamTable.getAvailableValues(ProgramConstants.ATT_TEAM_ROLES);
19-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Adding Resources to a Project Team
In Agile Web Client, when you add a resource pool to the Team table, you can replace
the pool with one or more resources contained within it. In other words, instead of
assigning the entire resource pool, you can assign select users from the pool. The
IProgram.assignUsersFromPool() method reproduces this functionality. To use
assignUsersFromPool(), you must specify a user group that has already been added
to the Project's Team table.
// Find a user group and replace it with one of its members, kwong
while(it.hasNext()){
IRow row = (IRow)it.next();
IDataObject object = row.getReferent();
if(object instanceof IUserGroup){
IUserGroup ug = (IUserGroup)object;
ITable users = ug.getTable(UserGroupConstants.TABLE_USERS);
Iterator ref_it = users.getReferentIterator();
while(ref_it.hasNext()){
IUser user = (IUser)ref_it.next();
if(user.getName().equals("kwong")) {
program.assignUsersFromPool(new IUser[]{user}, ug, true);
break;
}
}
}
}
}
Note: Projects are automatically locked when you use the Gantt
Chart or the Microsoft Project integration functionality in Agile Web
Client.
19-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Discussions
Note: The Action Items, Cover Page, and Replies tables appear on
the Discussion tab in Agile PLM clients. The Page Two table appears
on the Details tab in Agile PLM clients. The Where Used table is not
supported, its functionality is replaced by General Info.Related To
field.
Creating a Discussion
To create a discussion, use the IAgileSession.createObject() method. When you
specify discussion parameters, you must specify the discussion subclass and the
following required discussion attributes:
■ Cover Page.Number
■ Cover Page.Subject
In addition, you must also specify data for the Cover Page.Notify List and Cover
Page.Message attributes. Otherwise, the discussion does not have a Notification list, or
a message that users can respond to.
The following example shows how to create a new discussion and add it to the
Discussion table of a Project.
m_session.getAdminInstance().getAgileClass
( DiscussionConstants.CLASS_DISCUSSION);
String number =
discussionClass.getAutoNumberSources()[0].getNextNumber();
// Get a Projects
IProgram program =
(IProgram)m_session.getObject(IProgram.OBJECT_TYPE, "PGM00012");
if (program != null) {
19-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Discussions
Replying to a Discussion
Team members or notified users-that is, users listed in the Cover Page.Notified List
field of a discussion-can reply to discussions. When you reply to a discussion, you
create another nested table in the Replies table.
// Get a Project
IProgram program =
(IProgram)m_session.getObject(IProgram.OBJECT_TYPE, "PGM00012");
// Iterate to the only row of the Replies table and send a reply
it = repliesTable.iterator();
if (it.hasNext()) {
IRow row = (IRow)it.next();
IMessage message = (IMessage)row;
HashMap response = new HashMap();
// Set the Subject field (use the same Subject as the parent)
response.put(MessageConstants.ATT_COVERPAGE_SUBJECT,row.getValue
(DiscussionConstants.ATT_REPLIES_SUBJECT));
// Send a reply
message.reply(response);
}
}
}
The previous example showed how to reply to the root discussion. But what if a
discussion has several replies and you want to reply to the latest one? That is a little
more complicated, and requires further understanding of the Replies table.
The Replies table of a discussion is different from other Agile PLM tables. It contains
only one row, even if there are multiple replies. If the discussion has multiple replies,
they are contained within a series of nested tables. To select the latest reply, expand the
Replies table to its last nested table. The following figure shows an expanded Replies
table in Agile Web Client.
You can use a recursive method (one that calls itself) to expand all levels of the Replies
table, as shown in the following example. Subsequent levels of the Replies table are
obtained by getting the value of the Child Table attribute (DiscussionConstants.ATT_
REPLIES_CHILD_TABLE).
19-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Discussions
// Indent text
private String indent(int level) {
if (level <= 0) {
return "";
}
char c[] = new char[level*2];
Arrays.fill(c, ' ');
return new String(c);
}
Joining a Discussion
Agile Web Client allows users to join a discussion by clicking the Discussion tab of a
Project, and then clicking the Join button. When you join a discussion, your username
is added to the Notify List field of the Discussion object. To join a discussion using the
Agile API, simply add yourself to the Notify List field. You can join a discussion only
if you are a team member of the Project.
Note: If you are not on the Notify List of a Discussion object, you
cannot read the replies. However, anyone listed on the Team table of a
Projects can join a discussion associated with that Project.
// Get a Project
IProgram program =
(IProgram)m_session.getObject(IProgram.OBJECT_TYPE, "PGM00012");
if (program != null) {
19-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
20
Handling Exceptions
02
About Exceptions
Errors that cause a problem in a Java program are called exceptions. When Java throws
an exception that is not caught, your program may quit, or errors may appear on
screen. To handle an exception gracefully, your program must:
■ Protect code that contains a method that might throw an exception by putting it in
a try block.
■ Test for and handle any exceptions that are thrown inside a catch block.
The Agile API provides a subclass of Exception called APIException. This is a
general-purpose exception class that is used throughout the Agile API to handle Agile
PLM runtime errors. In the Agile API HTML reference, each method indicates the
types of exceptions it throws. Generally, any Agile API method that requires
interaction with the Agile Application Server throws APIException. The table below
lists the APIException class methods for handling exceptions:
Exception Constants
The ExceptionConstants class contains String constants for all Agile Application
Server and Agile API runtime error and warning codes. For a description of each of
these constants, refer to the API Reference files at http://edelivery.oracle.com/.
Several ExceptionConstants are for exceptions that are used to display an Agile PLM
warning message before completing an action. All constants for warning messages end
with the suffix WARNING. If you don't want to use Agile PLM warning messages in
your code, you can disable them. For more information, see "Disabling and Enabling
Error Codes with Bulk APIs" on page 20-2.
Example 20–2 Disabling and enabling error codes in the bulk mode
public static void releseECO(IAgileSession session, IChange change)
throws Exception {
// Set workflow
IWorkflow workflow = change.getWorkflows()[0];
20-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Getting Error Messages
change.setWorkflow(workflow);
IStatus submit = getStatus(workflow, StatusConstants.TYPE_SUBMIT);
IStatus ccb = getStatus(workflow, StatusConstants.TYPE_REVIEW);
IStatus released = getStatus(workflow, StatusConstants.TYPE_RELEASED);
session.disableWarnings(new Integer[] {
ExceptionConstants.APDM_WFL_ATLEASTONECHGANALYST_WARNING,
ExceptionConstants.APDM_MISSINGFIELDS_WARNING });
// instead you can use session.disableAllWarnings()
// route to SUBMIT
change.changeStatus(submit, false, null,
false, false, new Object[]{}, new Object[]{}, new Object[] {}, false);
For a list of Agile PLM error messages, refer to the API Reference files (at
http://edelivery.oracle.com/) under ExceptionConstants. TOHERE
20-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Saving and Restoring State Enabled and Disabled Warnings
20-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
21
Working with Product Cost Management
21
Except for the ISupplierResponse object, Agile API enables you to read and modify
all Product Sourcing objects. The following table lists the create, read, and modify
rights for Product Sourcing objects.
Table 21–1 Create, Read, and Modify privileges for Product Sourcing objects
Object Create Read Modify
IChange (including PCO) Yes Yes Yes
IPrice Yes Yes Yes
IProject Yes Yes Yes
IRequestForQuote Yes Yes Yes
ISupplier Yes Yes Yes
21-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Price Objects
For a list of Price object tables, refer to the Javadoc generated HTML files that
document the SDK code. You can find them in the HTML folder in SDK_samples.zip.
To access this file, see the Note in "Client-Side Components" on page 1-2.
ATT_PRICE_LINES_PRICE_EFFECTIVE_TO_DATE, df.parse("10/31/03"));
21-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Price Objects
After you create a Price object, you can further define it by setting values for Cover
Page, Page Two, and Page Three fields. To define prices and terms for items and
manufacturer parts, add rows to the Price Lines table. If there are files or documents to
attach, add them to the Attachments table.
Defaults
To create a price with Program==All and Customer==All, you do not need to pass
values for PriceConstants.ATT_GENERAL_INFORMATION_CUSTOMER and
PriceConstants.ATT_GENERAL_INFORMATION_Program during price creation. By
default, the price is created with Program==All and Customer==All.
Loading a Supplier
To load a supplier, use the IAgileSession.getObject() method. To uniquely identify the
supplier, specify the General Info | Number attribute.
ISupplier supplier =
(ISupplier)m_session.
getObject(ISupplier.OBJECT_TYPE, "SUP20013");
return supplier;
}
Note: The Agile API does not support adding new rows to Supplier
tables.
21-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
21-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
■ IRow.setValue(Object, Object)
■ ITable.iterator()
■ ITable.getName()
■ ITable.getTableDescriptor()
■ ITable.size()
■ ITable.createRow(Object)
Caution: Do not pass numbers that are greater than two digits to the
QUANTITY_BREAK attribute.
Example 21–10 Creating a Sourcing Project by quantity breaks and price periods
IAgileClass agClass =
m_admin.getAgileClass(ProjectConstants.CLASS_SOURCING_PROJECT);
IAutoNumber number = agClass.getAutoNumberSources()[0];
HashMap map = new HashMap();
map.put(ProjectConstants.ATT_GENERAL_INFORMATION_NUMBER, number);
map.put(ProjectConstants.
ATT_GENERAL_INFORMATION_NUMBER_OF_QTY_BREAKS, new Integer(4));
map.put(ProjectConstants.
ATT_GENERAL_INFORMATION_NUMBER_OF_PERIODS, new Integer(4));
IAgileList list =
agClass.getAttribute(PERIODTYPE).getAvailableValues();
String TYPE = "Monthly";
list.setSelection(new Object[]{TYPE});
map.put(ProjectConstants.ATT_GENERAL_INFORMATION_PERIOD_TYPE, list);
map.put(ProjectConstants.ATT_GENERAL_INFORMATION_PERIOD_START_DATE,
(new GregorianCalendar()).getTime());
IProject prj =
(IProject) m_session.createObject(agClass, map);
21-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
options.add("BusinessRuleOptions|ChangeMode=Authoring");
options.add("BusinessRuleOptions|BehaviorUponNonExistingObjects=Accept");
String _output = ".//Log//Ass_BOM_AML_PC_log.xml";options.add
("Template|TemplateType=com.agile.imp.template.TemplateParentChildFilter");
FileOutputStream fop = new FileOutputStream(_output);
IImportManager imgr =
(IImportManager)session.getManager(IImportManager.class);
byte[] logData = null;
logData = imgr.importDataForSourcingProject(projectNumber,
stream2byte(new FileInputStream(srcFilePath)), srcFileType,
convertFiletoStream(mappingPath),
convertFiletoStream(transformPath), operations, options);
Table 21–2 Parent Sourcing Projects Table Constants and Nested Child Table Constant
Parent Table Constant Nested Child Table Constant Read/Write Mode
TABLE_ITEMS ATT_ITEMS_AML Read/Write
TABLE_ITEMS ATT_ITEMS_PRICING Read/Write
TABLE_AML ATT_AML_PRICETABLE Read/Write
TABLE_ITEM ATT_ITEM_PRICE_TABLE Read/Write
TABLE_ITEM ATT_ITEM_BOM_TABLE Read
TABLE_ANALYSIS ATT_ANALYSIS_AML Read
TABLE_ANALYSIS ATT_ANALYSIS_PRICING Read
Note: The Money type attribute in nested PCM Pricing tables always
uses “USD” as the default currency unit. This applies even if the buyer
specifies a different currency unit. In this case, the “United State
Dollar” is the default and only supported currency.
Example 21–13 Setting values for Sourcing Project's Cover Page and Open and then
Close the Project
// add Ship To //
String sj = "San Jose";
IAgileList ship2List =
(IAgileList)prj.getValue(ProjectConstants.ATT_GENERAL_INFORMATION_SHIP_TO_
LOCATION);
ship2List.setSelection(new Object[]{sj});
prj.setValue(ProjectConstants.ATT_GENERAL_INFORMATION_SHIP_TO_LOCATION,
ship2List);
// open Sourcing Project //
prj.changeStatusToOpen();
// close Sourcing Project //
prj.changeStatusToClose();
21-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
Note: The Sourcing Project Start date that you specify is converted to
the GMT format for storage in the PLM database. Due to this
conversion, the date value returned by
IProject.getValue(ProjectConstants.ATT_GENERAL_INFORMATION_
PERIOD_START_DATE)
is not guaranteed to be the same that the user may expect.
Note: For items, quantity is only set at the root level. Thus, if an item
is not a root, the exception ExceptionConstants.PCM_PROJECT_ITEM_
IS_NOT_ROOT is thrown.
In addition, because priceTable is a nested table, you must reload the table to get the
updated value of Quantity. This is shown in the following example.
Example 21–16 Applying BOM filter operators located in the OperatorConstants class
IProject prj =
(IProject)m_session.getObject(IProject.OBJECT_TYPE, "PRJ00001");
IItem assembly =
(IItem)m_session.getObject(IItem.OBJECT_TYPE, "P00001");
21-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
Example 21–17 Updating the QPA Attribute on the Item Table of Sourcing Projects
public static void main(String[] args) {
try {
Example 21–18 Updating Selected Attributes on Item Table of Sourcing Projects from
Item Master File
public static void updateContentFromItemMaster() throws Exception {
IProject prj =
(IProject)session.getObject(IProject.OBJECT_TYPE, "PRJ00011);
Map params = new HashMap();
params.put(ProjectConstants.FLAG_CONTENT_UPDATE_MODE_OPTION_ALL, false);
params.put(ProjectConstants.FLAG_CONTENT_UPDATE_MAINTAIN_AML_CHANGES, false);
params.put(ProjectConstants.
FLAG_CONTENT_UPDATE_SELECTED_CONTENT_OPTION_BOM_AND_AML, true);
params.put(ProjectConstants.
FLAG_CONTENT_UPDATE_SELECTED_CONTENT_OPTION_ITEM, true);
params.put(ProjectConstants.
FLAG_CONTENT_UPDATE_SELECTED_CONTENT_OPTION_MANUFACTURER_PART, true);
List itemAttributes = new ArrayList();
itemAttributes.add(ProjectConstants.ATT_ITEM_QPA);
params.put(ProjectConstants.
FIELD_CONTENT_UPDATE_ITEM_ATTRIBUTES, itemAttributes);
List mfrPartAttributes = new ArrayList();
mfrPartAttributes.add("description");
mfrPartAttributes.add("attachments");
params.put(ProjectConstants.FIELD_CONTENT_UPDATE_MFR_PART_ATTRIBUTES,
mfrPartAttributes)
prj.updateContentFromItemMaster(params);
21-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
Updating Selected Attributes on Item Table of Sourcing Projects from Item Master
Use public static void updateContentFromItemMaster API as shown in the following
example.
Example 21–20 Updating Item Table of Sourcing Project’s attributes from Item Master
public static void updateContentFromItemMaster() throws Exception {
IProject prj = (IProject)session.getObject(IProject.OBJECT_TYPE, "PRJ00011");
Map params = new HashMap();
params.put(ProjectConstants.FLAG_CONTENT_UPDATE_MODE_OPTION_ALL, false);
params.put(ProjectConstants.FLAG_CONTENT_UPDATE_MAINTAIN_AML_CHANGES, false);
params.put(ProjectConstants.
FLAG_CONTENT_UPDATE_SELECTED_CONTENT_OPTION_BOM_AND_AML, true);
params.put(ProjectConstants.
FLAG_CONTENT_UPDATE_SELECTED_CONTENT_OPTION_ITEM, true);
params.put(ProjectConstants.
FLAG_CONTENT_UPDATE_SELECTED_CONTENT_OPTION_MANUFACTURER_PART, true);
List itemAttributes = new ArrayList();
itemAttributes.add(ProjectConstants.ATT_ITEM_QPA);
The PCM SDK supports the Cost Rollup function with the following API.
public void costRollup()
throws APIException, RemoteException, Exception;
21-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
The following examples show price lookups from the Sourcing Project History and
from another Sourcing Project. In addition, applicable parameters are grouped and
listed as those that are specific to the price lookup type and necessary in the price
lookup type.
This example shows a price lookup from Sourcing Project History and from another
Sourcing Projects. It provides a list of specific and required parameters for the two
price lookups.
Example 21–23 Price lookup from History and another Sourcing Projects
ArrayList priceTypes = new ArayList();
priceTypes.add(PriceConstants.CLASS_PUBLISHED_PRICE);
priceTypes.add(PriceConstants.CLASS_QUOTE_HISTORY);
priceTypes.add(PriceConstants.CLASS_CONTRACT);
m_session.getObject(ProjectConstants.CLASS_SOURCING_PROJECT, "PRJ_SRC");
Boolean isLookupFromPrice = new Boolean(false);
String priceScenario = null;
Map priceScenarios = new HashMap();
21-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
Note: Parameters that are not required in one of the price lookups,
for example, History, may be optional in price lookup from another
Sourcing Project. Comparing the list of required parameters above, the
LookupConstants.FLAG_ALL_PRICE_SCENARIOS parameter is optional
when performing a price lookup from History. You can either omit the
optional parameters, or set them to null.
21-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
map.put(LookupConstants.FIELD_PRICE_SCENARIO,priceScenario);
map.put(LookupConstants.FLAG_IGNORE_QUANTITY,ignoreQtyRange);
map.put(LookupConstants.FIELD_QUANTITY_RANGE,qtyPercentRange);
map.put(LookupConstants.FLAG_IGNORE_DATE_RANGE,ignoreDateRange);
map.put(LookupConstants.FIELD_DATE_RANGE,dateRange);
map.put(LookupConstants.
FELD_SELECT_RESPONSE_BY,LookupConstants.OPTION_LOWEST_PRICE);
map.put(LookupConstants.FLAG_EXCLUDE_AUTH_SUPPLIER,excludeAuthSupplier);
rfq.lookupPrices(map);
21-24 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
If you want to generate a report for all assemblies, all suppliers/partners, or all price
scenarios without specifying their names, you must provide the following
corresponding parameters:
■ String[] items = new String[1];
items[0] = "all";
■ String[] suppliers = new String[2];
suppliers[0] = "101";
suppliers[1] = "all"
■ String[] priceScenarios = new String[0];
priceScenarios[0] = "all";
Target Price is set at the Item level only. You cannot set a Target Price the AML level.
The end user specifies a Pricepoint using the name displayed for the Pricepoint. In the
following example, QuantityBreak2 is the Pricepoint.
Because priceTable is a nested table, you must reload this table to get the updated
value of the Target price as shown in the following example. This is similar to the
example in "Setting Quantity for Items in Sourcing Projects" on page 21-13.
Example 21–26 Reloading the priceTable to get the updated value of the target price
priceTable = row.getValue(ProjectConstants. ATT_ITEMS_PRICING);
for (Iterator iterator = priceTable.iterator(); iterator.hasNext();) {
IRow iRow = (IRow) iterator.next();
String name = iRow.getName();
if(name.equals("QuantityBreak2")){
Object qty = row.getValue(ProjectConstants.ATT_PRICEDETAILS_TARGET_COST));
}
}
Note: Because you can only set the Best Response to Yes, if you pass
any value other than Yes, the ExceptionConstants.API_INVALID_
PARAM exception is thrown.
Example 21–29 Getting the Best Response for an IPN and an MPN
String bResp =
row.getValue(ProjectConstants.ATT_ANALYSIS_BEST_RESPONSE).toString();
21-26 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
In the SDK, the following API is used to set partners for an item in a Sourcing Project
and split the percentage among the partners.
The behavior of this API and its use cases are similar to those of
IRequestForQuote.assignSupplier(). However, when you add new partners for an
item with this API, you will override the existing ones. Thus, to avoid removing
existing partners, it is necessary to once again add the existing partners and set the
split (Percentage for each) level for each one. This only occurs in the SDK, the GUI
does not require adding the existing partners when you add new partners. You cannot
remove a partner for an item, but assigning a split = 0, (Percentage of
ownership/participation) will remove the partner. For more information on the GUI
behavior, refer to the latest release of Agile Product Lifecycle Management - Product Cost
Management Supplier Guide.
The following code sample sets partners and splits the percentages among the
assigned partners.
Or,
ITable tab_item =
prj.getTable(ProjectConstants.TABLE_ITEM);
IRow row =
(IRow) tab_item.iterator().next();
ITable partnerTable =
(ITable) row.getValue(ProjectConstants.ATT_ITEM_PARTNER_TABLE);
for (Iterator iterator =
partnerTable.iterator(); iterator.hasNext();) {
IRow iRow =
(IRow) iterator.next();
String partner =
iRow.getValue(ProjectConstants.ATT_PARTNERS_PARTNER).toString();
String split =
iRow.getValue(ProjectConstants.ATT_PARTNERS_PARTNER_SPLIT).toString();
}
}
21-28 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
{
ITable tableAML = (ITable)row.getValue(ProjectConstants.ATT_ITEMS_AML);
Iterator itrAML = tableAML.getTableIterator();
while (itrAML.hasNext()) {
IRow amlRow = (IRow)itrAML.next();
amlRows.add(amlRow);
}
}
itemRows.add(row);
}
prj.validateItems(itemRows, amlRows);
Note: The PCM SDK RFQ objects do not have a Page three, and no
Page three RFQ constant is supported. Do not invoke these constants
because the RFQ will not produce the expected result.
21-30 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
- ITable.size()
- ITable.createRow(Object)
- IRow.getValue(Object)
- IRow.setValue(Object, Object)
Example 21–40 Loading an RFQ from the Sourcing Project RFQ table
ITable table = prj.getTable(ProjectConstants.TABLE_RFQS);
Iterator it = table.iterator();
IRow row1 = (IRow) it.next();
IDataObject obj1 = (IDataObject)
m_session.getObject(IRequestForQuote.OBJECT_TYPE,row1.getValue
(ProjectConstants.ATT_RFQS_RFQ_NUMBER));
Note: The getReferent() method does not support the PCM SDK,
including the RFQ tables. A list of supported RFQ tables appears in
the table below.
Note: The Agile API does not support adding new rows to RFQ
tables. However, you can add new rows to the RFQ response table.
Accessing and Modifying RFQ Objects, Tables, Nested Tables, and Attributes
You can access RFQ objects, tables, and attributes using the generic IAgileSession
and IDataObject methods and standard calls such as getObject, getValue,
setValue. Information about these classes, tables, and attributes is provided in the
com.agile.api.RequestForQuoteConstants.java file in the API HTML reference
files. To access these files, see "Client-Side Components" on page 1-2.
Table 21–4 RFQ Parent Table and Nested Child Table Constants
Parent Table Constant Nested Child Table Constant Read/Write Mode
TABLE_RESPONSES ATT_RESPONSES_AML Read/Write
TABLE_RESPONSES ATT_RESPONSES_PRICING Read/Write
Similar to Sourcing Projects, nested RFQ tables are accessed by treating their cell value
as a table. See "Understanding Nested Tables of PCM Sourcing Projects" on page 21-11.
The following example updates a nested table.
21-32 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
Example 21–42 Price lookup from history and from another Sourcing Project
HashMap map = new HashMap();
map.put(PriceConstants.ATT_GENERAL_INFORMATION_PRICE_TYPE,priceTypes);
map.put(ProjectConstants.ATT_ANALYSIS_SUPPLIER,suppliers);
map.put(ProjectConstants.ATT_GENERAL_INFORMATION_CUSTOMER,customers);
map.put(ProjectConstants.ATT_GENERAL_INFORMATION_PROGRAM,programs);
map.put(ProjectConstants.
ATT_GENERAL_INFORMATION_SHIP_TO_LOCATION,shipTo);
map.put(ProjectConstants.ATT_ITEMS_NUMBER,itemMap);
map.put(ProjectConstants.ATT_ITEMS_AML,mpnMap);
map.put(LookupConstants.FLAG_ALL_PRICE_SCENARIOS,allPriceScenarios);
map.put(LookupConstants.FIELD_PRICE_SCENARIO,priceScenario);
map.put(LookupConstants.FLAG_IGNORE_QUANTITY,ignoreQtyRange);
map.put(LookupConstants.FIELD_QUANTITY_RANGE,qtyPercentRange);
map.put(LookupConstants.FLAG_IGNORE_DATE_RANGE,ignoreDateRange);
map.put(LookupConstants.FIELD_DATE_RANGE,dateRange);
map.put(LookupConstants.
FIELD_SELECT_RESPONSE_BY,LookupConstants.OPTION_LOWEST_PRICE);
map.put(LookupConstants.FLAG_EXCLUDE_AUTH_SUPPLIER,excludeAuthSupplier);
rfq.lookupPrices(map);
Example 21–43 Using the required parameters to perform RFQ price lookups
PriceConstants.ATT_GENERAL_INFORMATION_PRICE_TYPE
ProjectConstants.ATT_ANALYSIS_SUPPLIER,suppliers
ProjectConstants.ATT_ITEMS_NUMBER or ProjectConstants.ATT_ITEMS_AML
LookupConstants.FIELD_QUANTITY_RANGE
if LookupConstants.FLAG_IGNORE_QUANTITY is ‘false’
LookupConstants.FIELD_DATE_RANGE
if LookupConstants.FLAG_IGNORE_DATE_RANGE is ‘false’
LookupConstants.FIELD_PRICE_SCENARIO
if LookupConstants.FLAG_ALL_PRICE_SCENARIOS is ‘false’
You can assign supplier data such as Manufacturer Part Number (mpn) or supplier
name as a String or an Object to the RFQ response shown in the following example.
If you are assigning a supplier to an mpn, you must specify the mpn as an
IManufacturerPart Object, or as a pair of Objects. One for the mpn name and one for
mfr name.
mp.put(RequestForQuoteConstants.ATT_RESPONSES_NUMBER, mpnObject);
Or,
mp.put(RequestForQuoteConstants.ATT_RESPONSES_NUMBER, mpnName);
mp.put(RequestForQuoteConstants.ATT_RESPONSES_MANUFACTURER, mfrName);
21-34 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
//Bid Decision
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_BID_DECISION, "Bid");
//Lead-Time
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_LEADTIME, new Integer(3));
//Inventory Available
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_INVENTORY_AVAILABLE, new
Integer(222));
//Min
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_MIN, 1);
//Mult
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_MULT, 10);
//Transportation Terms
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_TRANSPORTATION_TERMS, "EXW
- EX WORKS");
//Country of Origin
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_COUNTRY_OF_ORIGIN,
"Canada");
//EOL Date
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_EOL_DATE, eolDate);
//NCNR
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_NCNR, "Yes");
//Valid From
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_VALID_FROM, validFrom);
//resp Money 1
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_MONEY_1, new
Money(value, "INR"));
//resp Date 1
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_DATE_1,
df.parse("12/29/2010"));
//resp Text 1
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_TEXT_1, new
String("EMS1 Supplier Edited from SDK - Text1"));
21-36 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Sourcing Projects
//resp Number1
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_NUMBER_1, 11);
//resp list 1
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_LIST_1, "USD");
//resp MultiText 1
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_MULTITEXT_1, new
String("EMS1 Supplier Edited from SDK - MultiText1"));
//resp MultiList 1
responseMap.put(SupplierResponseConstants.ATT_RESPONSES_RESP_MULTILIST_1, "USD");
ISupplierResponse rfq =
(ISupplierResponse)agileSession.getObject(ISupplierResponse.OBJECT_TYPE, params);
ITable tableResp = rfq.getTable(SupplierResponseConstants.TABLE_RESPONSES);
for (Iterator rowIter = tableResp.iterator(); rowIter.hasNext(); ) {
IRow rowResp = (IRow)rowIter.next();
rowResp.setValues(responseMap);
}
ISupplierResponse rfq =
(ISupplierResponse)agileSession.getObject(ISupplierResponse.OBJECT_TYPE, params);
ITable tableResp =
rfq.getTable(SupplierResponseConstants.TABLE_RESPONSES);
for (Iterator rowIter = tableResp.iterator(); rowIter.hasNext(); ) {
IRow rowResp =
(IRow)rowIter.next();
ITable pricing_table =
(ITable)rowResp.getValue(SupplierResponseConstants.ATT_RESPONSES_PRICING);
Iterator priceIter = pricing_table.iterator();
while (priceIter.hasNext()) {
IRow priceRow =
(IRow)priceIter.next();
priceRow.setValues(responsePriceMap);
}
}
21-38 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
22
Performing Administrative Tasks
22
Administrative Interfaces
The following table lists interfaces related to Agile PLM's administrative functionality.
22-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Nodes
try {
HashMap params =
new HashMap();
params.put(AgileSessionFactory.USERNAME, "jdassin");
params.put(AgileSessionFactory.PASSWORD, "agile");
m_factory =
AgileSessionFactory.getInstance("http://agileserver/virtualPath");
m_session = m_factory.createSession(params);
m_admin = m_session.getAdminInstance();
} catch (APIException ex) {
System.out.println(ex);
}
22-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Nodes
Agile Web Client allows you to view and edit system and user settings by choosing
Admin and Settings from the menu, respectively. The following table identifies how
Agile Web Client administrative functionality maps to the Agile API.
Admin nodes in Agile PLM Clients do not have names that match up identically to
their respective NodeConstants. For example, the Notifications node in Agile Java
Client is equivalent to NodeConstants.NODE_NOTIFICATION_TEMPLATES. Similarly, the
hierarchy of nodes that are represented in the Agile PLM database does not exactly
match Agile Java Client node hierarchy.
If your Agile API program provides a tree view of the Agile PLM administrative
nodes, you can use the view to interactively retrieve INode objects. From each INode
object you can get the child nodes. If you continue to traverse the administrative node
hierarchy, you can reach all node levels.
The following example shows how to retrieve the root node and its children, thus
displaying the top-level nodes on the Agile Application Server.
for (Iterator it =
childNodes.iterator();it.hasNext();) {
INode node =
(INode)it.next();
System.out.println(node.getName() + ", " + node.getId());
}
}
}
Note: When you call getChildNodes() on the root node, the results
include several undocumented Agile PLM nodes. Any undocumented
nodes are not supported by the Agile API.
For faster access, you can also retrieve a node by specifying its node ID constant. The
NodeConstants class lists all administrative nodes that are directly accessible. The
following example shows how to retrieve the SmartRules node and its properties.
Another way to get a node is to locate a parent node and then get one of its children
using the ITreeNode.getChildNode() method. The getChildNode()method supports
22-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Agile PLM Classes
specifying a node by name or ID. You can also specify the path to a subnode,
separating each node level with a slash character (/). The following example shows
how to use the getChildNode() method to retrieve a node.
22-8 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Agile PLM Classes
When you create a new object using the IAgileSession.createObject() method, you
must specify a concrete Agile PLM class, that is, one of the user-defined subclasses.
Remember, abstract classes cannot be instantiated. The following example shows how
to create an object of the Part subclass.
Referencing Classes
You can reference Agile PLM classes in the following ways:
■ by object (an IAgileClass)
■ by class ID constant, such as ItemConstants.CLASS_PART or
ChangeConstants.CLASS_ECO. All Agile API constants are contained in classes that
have a suffix name Constants. For example, ItemConstants contains all constants
related to IItem objects.
■ by class name, such as “Part” or “ECO”.
In general, avoid referencing classes by name for the following reasons:
■ Class names can be modified.
■ Class names are not necessarily unique. It's possible to have duplicate class names.
Consequently, if you reference a class by name you may inadvertently reference
the wrong class.
■ Class names are localized; that is, the names are different for different languages.
22-10 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Attributes
There are two predefined concrete classes for the Item class, Document and Part. If
your company hasn't added any Item subclasses to the Agile PLM system, the code in
the previous example should print the following results:
Class Name : Document
ID : 9141
Class Name : Part
ID : 10141
Referencing Attributes
You can reference Agile PLM attributes in the following ways:
■ by object (an IAttribute)
■ by attribute ID constants
All Agile API constants, including attribute ID constants, are contained in classes that
have the suffix Constants. For example, ItemConstants contains all constants related
to IItem objects.
■ by fully qualified name, such as Title Block.Number or Cover Page.Change
Category.
■ by short name, such as Number. However, attribute short names are not unique in
Agile PLM. If you are referencing multiple attributes, you may run into a conflict if
two different attributes have the same short name.
Retrieving Attributes
IAttribute objects are associated with a particular subclass. For example, the
attributes for a Part are different from those of an ECO. Therefore, if you know the
subclass of an object you can retrieve the list of attributes for it. The following table
lists methods that can be used to retrieve attributes.
22-12 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Working with Attributes
Method Description
IAgileClass.getAttribute() Retrieves the specified IAttribute object for a class
IAgileClass.getAttributes() Retrieves an array of IAttribute objects for all tables of a
class
IAgileClass.getTableAttribu Retrieves an array of IAttribute objects for a specified
tes() table of the class
ITable.getAttributes() Retrieves an array of IAttribute objects for a table
ICell.getAttribute() Retrieves the IAttribute object for a cell
Example 22–11 Retrieving BOM table attributes for the Part subclass
try {
// Get the collection of BOM table attributes for the Part subclass
IAttribute[] attrs = partClass.getTableAttributes(ItemConstants.TABLE_BOM);
} catch (APIException ex) {
System.out.println(ex);
}
Another way to retrieve the attributes for a particular table is to first get the table, then
get its attributes using the ITable.getAttributes() method.
Example 22–12 Retrieving the collection of BOM table attributes from the table
try {
22-14 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Users
The SingleList and MultiList properties are different from other types of properties.
You cannot use the IProperty.getValue() and IProperty.setValue() methods to directly
modify a property that contains a list of values. Instead, you use the
IAgileList.setSelection () method to select a list node, and then use the
IProperty.setValue() method to set the value. For more information about how to
modify SingleList and MultiList properties, see "Getting and Setting List Values" on
page 5-6.
Managing Users
Users are data objects that you can create, like items and changes. Consequently, you
can work with users directly without traversing the administrative node hierarchy. If
you have the proper Agile PLM privileges, you can create, modify, and delete users.
For example, you could create a program that periodically synchronizes Agile PLM
users with data available from a corporate directory.
}
for (int i = 0; i < users.size(); i++) {
IUser user =(IUser)users.get(i);
System.out.println(
user.getValue(UserConstants.ATT_GENERAL_INFO_USER_ID) + ", " +
user.getValue(UserConstants.ATT_GENERAL_INFO_FIRST_NAME) + ", " +
user.getValue(UserConstants.ATT_GENERAL_INFO_LAST_NAME));
}
}
Creating a User
A user is like other data objects that you can create with the Agile API. To create a user,
you define the user's parameters and pass them to the IAgileSession.createObject()
method. The required parameters you must specify are user ID and login password.
You can also specify other user attributes, which are listed in the UserConstants class.
22-16 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Users
Passwords that you specify for new users become default values. If you specify an
approval password, it must be different from the login password, unless the
UserConstants.ATT_GENERAL_INFO_USE_LOGIN_PASSWORD_FOR_APPROVAL cell is set to
Yes. The user can always change the password later.
By default, when you create a new user it's assigned the Concurrent user category and
the My User Profile role, a combination that allows the user to only view their own
profile. To create and modify objects, the user must be assigned roles with the
appropriate create and modify privileges. For an example showing how to change a
user's Role settings, see "Configuring User Settings" on page 22-20.
User groups can be global or personal. Global user groups are accessible to all Agile
PLM users. Personal user groups are accessible only to the person who created the
group. The following example shows how to make a user group global.
22-18 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing Users
Example 22–22 Getting user cells for General Info and Page Two
private void getUserCells(IUser user) throws APIException {
ICell[] cells = user.getCells();
for (int i = 0; i < cells.length; i++) {
System.out.println(cells[i].getName() + " : " + cells[i].getValue());
}
}
Two important settings for a user are User Category and Roles. The User Category
setting defines the broad range of actions a user can perform on the Agile PLM system.
Select from one of the following User Category values:
■ Power - User can log in to the server at any time with unrestricted use of the Agile
PLM system. Power users are not subject to the limited number of concurrent
users.
■ Concurrent - User can log in to the server only if a concurrent user agreement is
available.
■ Restricted - User has restricted access to the Agile PLM system. Supplier users are
by default assigned the Restricted category, which allows them to respond to RFQs
and use other features of Agile Product Cost Management (PCM). Restricted users
are not subject to the limited number of concurrent users.
The Roles setting further defines the capabilities of a user, assigning roles and
privileges. A user won't be able to create objects without the proper roles and
privileges. For more information about Agile PLM user roles, and privileges, refer to
the Agile PLM Administrator Guide.
The following example shows how to set a user's User Category and Roles settings.
Example 22–23 Setting the User Category and Roles settings for a user
private void setCategory(IUser user) throws APIException {
22-20 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing User Groups
Deleting a User
To delete a user, use the IDataObject.delete() method. Like other data objects, an object
deleted for the first time is “soft-deleted,” which means it is disabled but not removed
from the database. The Agile Application Server does not allow you to permanently
delete a user.
Note: In Agile Clients such as Agile Web Client, you can send an
object, such as a change, to a user group. The Agile API does not
support sending objects to user groups. However, you can retrieve
users from the Users table of a User Group object and then send them
an object.
22-22 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Managing User Groups
m_session.getObject(IUser.OBJECT_TYPE, "speckinpah")
};
addUsers(group, selUsers);
}
User groups can be global or personal. Global user groups are accessible to all Agile
PLM users. Personal user groups are accessible only to the person who created the
group. The following example shows how to make a user group global.
Example 22–29 Using a Map to add a User Group to a User Group Table
ITable ugTable = user.getTable(UserConstants.TABLE_USERGROUP);
22-24 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
A
Mapping PLM Client Features to Agile API
A
Login Features
The following table lists general features for logging in to the Agile Application Server.
General Features
The following table lists the General features that apply to all Agile PLM business
objects.
Search Features
The table below lists the supported Search (Query) features.
Attachment Features
The table below lists features for working with attachments and file folders.
A-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Folder Features
Workflow Features
The table below lists Workflow features for routable Agile PLM objects.
Folder Features
The following table lists the Folder features for working with folders.
Project Features
The following table lists features for working with Projects.
Administrative Features
The following table provides the list of features for working with Administration
nodes and properties in Agile Java Client.
A-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Administrative Features
A-6 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
B
Migrating Table Constants to Release 9.2.2
B
Overview
This appendix describes how to migrate Table Contents from pre-Release 9.2.2
(Release 9.2.1 and earlier releases) to post-Release 9.2.2 (Release 9.2.2 or later releases).
Information about merging and replacing the Relationship tables first appeared in
"Accessing the New and Merged Relationships Tables" on page 4-3. Tables in this
appendix list the Release 9.2.2 table constants and table constants that were either
merged and mapped into a single table constant, or mapped into a new table constant.
B-2 Agile Product Lifecycle Management SDK Developer Guide – Using APIs
Removed Pre-Release 9.2.2 Table Constants
■ ATT_RELATIONSHIPS_AFFECTS_RESULT
■ MaterialDeclarationConstants.TABLE_RELATIONSHIPSAFFECTEDBY
■ MaterialDeclarationConstants.TABLE_RELATIONSHIPSAFFECTS
■ MaterialDeclarationConstants.TABLE_REFERENCES
B-4 Agile Product Lifecycle Management SDK Developer Guide – Using APIs