public static List<RepoItem> getRepoItems(String search) throws Exception { if (search == null || search.trim().isEmpty()) { return new ArrayList<RepoItem>(); } String queryBegin = "select * from " + RepoItem.class.getName() + " where 1=1 and "; return BeanUtil.query(getRepoItems(), queryBegin + search); }
public static List<Machine> getMachines(String uid, String search) { if (search == null || search.trim().isEmpty()) { return new ArrayList<Machine>(); } String queryBegin = "select * from " + Machine.class.getName() + " where"; User user = getUser(uid); String sql = queryBegin; if (!uid.equals(User.ADMIN)) { StringBuilder cc = new StringBuilder(); for (String q : user.machines) { cc.append("'" + q + "',"); } if (cc.length() > 0) { cc.deleteCharAt(cc.length() - 1); } sql += " 1=1 and id in(" + cc + ") and "; } else { sql += " 1=1 and "; } sql += search; return BeanUtil.query(getMachines(), sql); }