Тема: Generate report in JAVA
We are creating a service that will send a report to the users using the JAVA SDK.
However I'm having trouble figuring out what to do exactly.
I'd like to generate a ride report for a user, and I understand how to get all the users under our account, but what now?
I realise I need to receive a report template using the searchItems method, so I'm doing this like this:
SearchSpec reportSearchSpec = new SearchSpec();
// get report templates
// Set items type to search avl_units
reportSearchSpec.setItemsType(Item.ItemType.avl_resource);
// Set sort type by units name
reportSearchSpec.setSortType("sys_name");
reportSearchSpec.setPropName("avl_resource");
reportSearchSpec.setPropValueMask("*");
session.searchItems(reportSearchSpec, 1, Resource.dataFlag.reports.getValue() , 0,
Integer.MAX_VALUE, new SearchResponseHandler() {
@Override
public void onSuccessSearch(Item... reportTemplates) {
super.onSuccessSearch(reportTemplates);
}
@Override
public void onFailure(int errorCode, Throwable throwableError) {
super.onFailure(errorCode, throwableError);
// search item failed, print error
System.out.println("error " + Errors.getErrorText(errorCode));
}
});
This gives a lot of nullpointer exceptions for some reason.
Does anybody have an example of how to generate a report using the JAVA SDK?
I tried using the execReport function of the Report class but I have no idea what to put in the constructor and method parameters.
Thanks in advance!