Thursday, 18 February 2016

Get List of Accounts Provisioned to User

public List<String> getAccountsProviisonedToUser(String userLogin,String appInstName){



String userKey=getUserKey(userLogin);

try {

if(userKey.length()>0){


List<Account> accounts=provisionService.getAccountsProvisionedToUser(userKey);


FormService formService=new FormService();


for (Account account : accounts)


{

String accountId = account.getAccountID();

String accntName = account.getAppInstance().getApplicationInstanceName();

String accountStatus = account.getAccountStatus();

Date date=account.getProvisionedOnDate();

String pid=account.getProcessInstanceKey();


FormInfo formInfo = account.getAppInstance().getAccountForm();



if(appInstName.equalsIgnoreCase(accntName) ){



System.out.println("App Inst Name::"+accntName);

System.out.println("App Inst Status::"+accountStatus);



System.out.println("**********************************************************************************");

System.out.println("*************************FORM DETAILS*********************************************");

System.out.println("*******FOR USER::"+userLogin+"****App Inst Status::"+accountStatus+"**************");


@SuppressWarnings("unchecked")

Map<Object,Object> formValues= formService.getProcessFormValues(Long.parseLong(pid),formInstOp);


if(formValues.containsKey(formInfo.getName()+"_NOTE")){

formValues.remove(formInfo.getName()+"_NOTE");


}
//System.out.println("FormValues::"+formValues);


for (String singleField : formValues.toString().split(",")) {

System.out.println(singleField);


}
System.out.println("**********************************************************************************");





}

}
}else{

System.out.println("USER NOT FOUND");


}
} catch (UserNotFoundException e) {


e.printStackTrace();
} catch (GenericProvisioningException e) {



e.printStackTrace();
} catch (NumberFormatException e) {

// TODO Auto-generated catch block


e.printStackTrace();
} catch (Exception e) {

// TODO Auto-generated catch block


e.printStackTrace();

}
return null;



}

Trigger a Scheduler task using API

public void runScheduler(){


try {

schedulerService.triggerNow("Evaluate User Policies");

System.out.println("Scheduler Run ended...");

} catch (SchedulerException e) {

// TODO Auto-generated catch block


e.printStackTrace();
} catch (SchedulerAccessDeniedException e) {

// TODO Auto-generated catch block


e.printStackTrace();

}


}


Note:Initialize the SchedulerService  class while running from standalone.