Wednesday, February 11, 2015

Oracle BPM : Get Extended User Properties using BPM API's

The below code retrieves the list of parametric values and its properties.

package com.raylabs.bpm;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import oracle.bpel.services.bpm.common.IBPMContext;
import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpm.client.BPMServiceClientFactory;
import oracle.bpm.services.client.IBPMServiceClient;
import oracle.bpm.services.organization.IBPMOrganizationService;
import oracle.bpm.services.organization.model.Organization;
import oracle.bpm.services.organization.model.ParticipantProperties;
import oracle.bpm.services.organization.model.ParticipantPropertiesList;
import oracle.bpm.services.organization.model.ParticipantProperty;
import oracle.bpm.services.organization.model.PrincipleRefType;
public class Class1 {
private static String username;
private static String password;
private static String environment;
private static String serverPort;
private Class1() {
super();
}
public static void main(String[] args) {
username = "xxx";
password = "xx";
environment = "dev";
serverPort = "12121";
BPMServiceClientFactory wfSvcClient = null;
IBPMContext bpmCtx = null;
IBPMServiceClient bPMServiceClient = null;
try {
final Map connectionProperty = getConnProp();
wfSvcClient =
BPMServiceClientFactory.getInstance(connectionProperty,
null, null);
bPMServiceClient = wfSvcClient.getBPMServiceClient();
IBPMOrganizationService bpmOrgSvc =
bPMServiceClient.getBPMOrganizationService();
bpmCtx =
(IBPMContext)wfSvcClient.getWorkflowServiceClient().getTaskQueryService().authenticate(null,
null,
null);
Organization org = bpmOrgSvc.exportOrganization(bpmCtx);
ParticipantPropertiesList list = org.getParticipantPropertiesList();
List<ParticipantProperties> participantProperties = list.getParticipantProperties();
Iterator<ParticipantProperties> iterator = participantProperties.iterator();
while(iterator.hasNext()){
ParticipantProperties next = iterator.next();
PrincipleRefType participant = next.getParticipant();
System.out.println("Particpant name :"+participant.getName());
System.out.println("Participant type :"+participant.getType());
List<ParticipantProperty> participantProperty = next.getParticipantProperty();
Iterator<ParticipantProperty> iterator1 = participantProperty.iterator();
while(iterator1.hasNext()){
ParticipantProperty property = iterator1.next();
// System.out.println("Property name: "+property.getName());
List<Object> value = property.getValue();
for(int i=0;i<value.size();i++){
String name= (String)value.get(i);
System.out.println("Property name :"+property.getName()+" Property value :"+name);
}
}
System.out.println("---------------------------------------------");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
}
}
public static Map getConnProp() throws Exception {
final Map connProp = new HashMap();
try {
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL,
"t3://" + environment +
"-abc.com:" + serverPort);
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL,
username);
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS,
password);
connProp.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.CLIENT_TYPE,
WorkflowServiceClientFactory.REMOTE_CLIENT);
} catch (Exception e) {
e.printStackTrace();
}
return connProp;
}
}


Libraries :


No comments:

Post a Comment