cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Windchill PDMlink Queue Customization.

Prabhash
5-Regular Member

Windchill PDMlink Queue Customization.

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

1 ACCEPTED SOLUTION

Accepted Solutions
ks-2
3-Visitor
(To:Prabhash)

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);

}

}

View solution in original post

4 REPLIES 4
ks-2
3-Visitor
(To:Prabhash)

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);

}

}

Prabhash
5-Regular Member
(To:ks-2)

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.

ks-2
3-Visitor
(To:Prabhash)

Hi,

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

Kumarappan.S

Prabhash
5-Regular Member
(To:ks-2)

Hi,

Thanx....It's working now....error was due to method context...:)

Top Tags