*/
public Iterator<BaseOBObject> getExportableObjectsIterator(DataSetTable dataSetTable,
String moduleId, Map<String, Object> parameters) {
final String entityName = dataSetTable.getTable().getName();
final Entity entity = ModelProvider.getInstance().getEntity(entityName);
if (entity == null) {
log.error("Entity not found using table name " + entityName);
return new ArrayList<BaseOBObject>().iterator();
}
String whereClause = dataSetTable.getSQLWhereClause();
final Map<String, Object> existingParams = new HashMap<String, Object>();
for (final String name : parameters.keySet()) {
if (whereClause.indexOf(":" + name) != -1) {
existingParams.put(name, parameters.get(name));
}
}
if (moduleId != null && whereClause != null) {
while (whereClause.indexOf("@moduleid@") != -1) {
whereClause = whereClause.replace("@moduleid@", "'" + moduleId + "'");
}
if (whereClause.indexOf(":moduleid") != -1 && parameters.get("moduleid") == null) {
existingParams.put("moduleid", moduleId);
}
}
// set the order by, first detect if there is an alias
String alias = "";
// this is a space on purpose
if (whereClause != null && whereClause.toLowerCase().trim().startsWith("as")) {
// strip the as
final String strippedWhereClause = whereClause.toLowerCase().trim().substring(2).trim();
// get the next space
final int index = strippedWhereClause.indexOf(" ");
alias = strippedWhereClause.substring(0, index);
alias += ".";
}
final OBQuery<BaseOBObject> oq = OBDal.getInstance().createQuery(entity.getName(),
(whereClause != null ? whereClause : "") + " order by " + alias + "id");
oq.setFilterOnActive(false);
oq.setNamedParameters(existingParams);
if (OBContext.getOBContext().getRole().getId().equals("0")