Skip to content

Introducing to reports based on Java

  • Install the iReport tool.
  • Execute the iReport tool.

  • Click on the Designer tab.
  • Click on the report query button.

  • Create an empty list.
  • Iterate through all users by calling the API method AuthSrv.findAllUsers(false).
  • Create a Map for each DbUser object where each value corresponds to a column.
  • Add each map to the list, where each map corresponds to a row.
import com.openkm.db.service.*;import com.openkm.db.bean.*;import com.openkm.util.ContextWrapper;import org.springframework.web.context.WebApplicationContext;WebApplicationContext cc = (WebApplicationContext) ContextWrapper.getContext();AuthSrv authSrv = cc.getBean(AuthSrv.class);List al = new ArrayList();for (DbUser user : authSrv.findAllUsers(false)) { Map usr = new HashMap(); usr.put("id", user.getId()); usr.put("name", user.getName()); usr.put("email", user.getEmail()); usr.put("roles", user.getRoles().toString()); al.add(usr);}return al;
  • For each key in the map, create a field.
  • Use the field in the report.