Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
7 replies
Subscribers
7 subscribers
Views
2705 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Finding out whether process model instance is completed from java code
surendrab
over 8 years ago
Hello All,
I am writing a java plugin and this plugins starts a process instance but I am unable to get information on whether this process instance is completed or not. I am using Process controller concludeProcess() method but this is throwing exception and not reliable to get that information. Any help on pointers would be appreciated
OriginalPostID-234691
Discussion posts and replies are publicly visible
0
Eduardo Fuentes
Appian Employee
over 8 years ago
Starting a process is an asynchronous procedure. Only if the process has reached a terminate event or all end events, the process will complete.
To check the status of a process:
int processStatus = pes.getProcessDetails(processId).getStatus();
if(processStatus == ProcessDetails.STATE_COMPLETED){
....
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
surendrab
over 8 years ago
Thank you Eduardo. Which class is pes?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 8 years ago
com.appiancorp.suiteapi.process.ProcessExecutionService
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
surendrab
over 8 years ago
Thank you. Since this is an interface I will have to implement my own class ?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
surendrab
over 8 years ago
I was concerned about the which process instance status it will fetch since I am using process controller's start process. I believe this will fetch the most current process instance in which case I will have to synchoronize it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 8 years ago
No. Plug-ins can use injected services in their constructor that are automatically injected by Appian by simply having them as arguments in your constructor. Check the examples under Shared Components. They have the source code, they will be good training.
For example: "Process Management Services" has ResumeProcesses.java which in its constructor states that Appian should inject ProcessExecutionService automatically, so all the creator needed was to put that in the constructor and store that reference in a variable.
The author designed a slightly more complex architecture than what you normally need but what she did basically translates into this (see how she can use the "pes" variable in her run method just because she declared it as a variable that'll be populated automatically by Appian in the constructor)
@ProcessManagement
public class ResumeProcesses extends extends AppianSmartService{
private ProcessExecutionService pes;
public ResumeProcesses(ProcessExecutionService pes) {
this.pes = pes
}
@Override
public void run() throws SmartServiceException {
Integer[] resultCodeIds;
if (dryRun) {
resultCodeIds = new ProcessManagerDryRun(pes).resumeProcesses(processIds);
} else {
resultCodeIds = pes.resumeProcesses(processIds);
}
setResultCodeList(resultCodeIds);
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 8 years ago
More information at
forum.appian.com/.../Custom_Smart_Service_Plug-ins.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel