Complete Example Program - EnterWorks_Process_Exchange_(EPX) - 10.6

EnterWorks EPX Programmers Reference

Product type
Software
Portfolio
Verify
Product family
EnterWorks
Product
Precisely EnterWorks > EnterWorks Process Exchange (EPX)
Version
10.6
Language
English
Product name
Precisely EnterWorks
Title
EnterWorks EPX Programmers Reference
First publish date
2007
Last updated
2023-07-28
Published on
2023-09-20T04:07:07.148709

This program will purge work items from the system, given some date range and completion status criteria. In addition to the default program parameters specified in the LoginExample program, the WorkItemExample program has the following arguments:

  • -workItemName — the name pattern of the work items to be purged. If not provided, the work item name will not be taken into account.

  • -startDate — the beginning date range of the last modification date to purge work items in the format yyyy.MM.dd. It defaults to the day before the current date.

  • -endDate — the end range of the last modification date to purge work items in the format yyyy.MM.dd. It defaults to the current date.

  • -completed — the completion status of work items. Valid values are true and false. If true, only completed work items will be deleted.

For example:

C:\Enterworks\EPX\examples\api\run.bat PurgeWorkItemExample

-server EPX_somehost -user system -password system

-workItemName PurchaseOrder

public static void main(String args[]) throws Exception

{

try

{

String serverUID = null;

String user = "system";

String password = "system";

String workItemName = null;

String startDateString = null;

String endDateString = null;

String completedString = null;

for ( int i=0 ; i < args.length; i++)

{

String arg = args[i];

if (arg.startsWith("-"))

{

if (arg.substring(1).equals("server"))

serverUID = args[++i];

else if (arg.substring(1).equals("user"))

user = args[++i];

else if (arg.substring(1).equals("password"))

password = args[++i];

else if (arg.substring(1).equals("workItemName"))

workItemName = args[++i];

else if (arg.substring(1).equals("startDate"))

startDateString = args[++i];

else if (arg.substring(1).equals("endDate"))

endDateString = args[++i];

else if (arg.substring(1).equals("completed"))

completedString = args[++i];

}

}

boolean completedOnly =

completedString.equalsIgnoreCase("true");

Date startDate;

Date endDate;

SimpleDateFormat formatter =

new SimpleDateFormat ("yyyy.MM.dd");

ParsePosition pos = new ParsePosition(0);

// default the start date to 24 hours previous to

// the date and current time

if ( startDateString == null )

startDate = new Date(

System.currentTimeMillis()- 86400000L);

else

startDate = formatter.parse(startDateString, pos);

// default the end date to the current date and time

if ( endDateString == null )

endDate = new Date(System.currentTimeMillis());

else

endDate = formatter.parse(endDateString, pos);

// create a new work item purge example and login

PurgeWorkItemExample purgeExample;

purgeExample =

new PurgeWorkItemExample (serverUID,user,password);

purgeExample.login();

int purgeCount = purgeExample.purgeWorkItems(

workItemName, startDate, endDate, completedOnly);

String vargs[] = { String.valueOf(purgeCount) };

System.out.println (

purgeExample.getMessage(

"workitem.purge.result", vargs) );

purgeExample.logout();

}

catch( Exception e )

{

System.err.println (

"PurgeWorkItemExample.main(exception):" + e );

e.printStackTrace();

}

}

}