Skip to main content
1-Visitor
June 25, 2013
Solved

Windchill PDMlink Queue Customization.

  • June 25, 2013
  • 1 reply
  • 4681 views

Can sommebody please help me with, how to create a SCHEDULE QUEUE Programmatically and add a schedule object to it!

Best answer by ks-2

To create a queue you can use the following java code.

public static ScheduleQueue createScheduleQueueIfNecessary(String queueName) throws WTException {

ScheduleQueue sq = (ScheduleQueue) QueueHelper.manager.getQueue(queueName, ScheduleQueue.class);

logger.debug("ScheduledQueue '" + queueName + "' exists? sq=" + sq);

//create queue itself if necessary

if (sq == null) {

sq = QueueHelper.manager.createScheduleQueue(queueName);

logger.debug("created ScheduledQueue '" + queueName + "': sq=" + sq);

}

return sq;

}

And to create an entry in this queue the following method can be used

public static void addNewScheduleQueueEntry(ScheduleQueue sq, String className, String methodName, Timestamp nextTime, String message) throws WTException {

//Adding an entry

Class[] argTypes = {String.class};

Object[] args = {message};

WTPrincipal administrator = SessionHelper.manager.getAdministrator();

WTPrincipal previous = SessionContext.setEffectivePrincipal(administrator);

try {

sq.addEntry(administrator, methodName, className, argTypes, args, nextTime);

logger.debug("added new queueEntry to call '" + className + "." + methodName + "' nextScheduledTime=" + nextTime);

} finally {

SessionContext.setEffectivePrincipal(previous);

}

}

1 reply

ks-28-GravelAnswer
8-Gravel
June 27, 2013

To create a queue you can use the following java code.

public static ScheduleQueue createScheduleQueueIfNecessary(String queueName) throws WTException {

ScheduleQueue sq = (ScheduleQueue) QueueHelper.manager.getQueue(queueName, ScheduleQueue.class);

logger.debug("ScheduledQueue '" + queueName + "' exists? sq=" + sq);

//create queue itself if necessary

if (sq == null) {

sq = QueueHelper.manager.createScheduleQueue(queueName);

logger.debug("created ScheduledQueue '" + queueName + "': sq=" + sq);

}

return sq;

}

And to create an entry in this queue the following method can be used

public static void addNewScheduleQueueEntry(ScheduleQueue sq, String className, String methodName, Timestamp nextTime, String message) throws WTException {

//Adding an entry

Class[] argTypes = {String.class};

Object[] args = {message};

WTPrincipal administrator = SessionHelper.manager.getAdministrator();

WTPrincipal previous = SessionContext.setEffectivePrincipal(administrator);

try {

sq.addEntry(administrator, methodName, className, argTypes, args, nextTime);

logger.debug("added new queueEntry to call '" + className + "." + methodName + "' nextScheduledTime=" + nextTime);

} finally {

SessionContext.setEffectivePrincipal(previous);

}

}

Prabhash1-VisitorAuthor
1-Visitor
June 28, 2013

Hey Kumarappan, thaku very much for your time! But now when i am trying to add a schedule entry in to the queue, it's giving me null pointer exception.

8-Gravel
July 2, 2013

Hi,

this is working code. Try check the name of the queue.

Kumarappan.S