How to use readDistinctValuesByCriteria method of org.cerberus.crud.dao.ITagSystemDAO class

Best Cerberus-source code snippet using org.cerberus.crud.dao.ITagSystemDAO.readDistinctValuesByCriteria

Source:TagSystemService.java Github

copy

Full Screen

...126 }127 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));128 }129 @Override130 public AnswerList<String> readDistinctValuesByCriteria(String searchParameter, Map<String, List<String>> individualSearch, String columnName) {131 return tagSystemDAO.readDistinctValuesByCriteria(searchParameter, individualSearch, columnName);132 }133}...

Full Screen

Full Screen

readDistinctValuesByCriteria

Using AI Code Generation

copy

Full Screen

1 public List<TagSystem> readDistinctValuesByCriteria(String system, String tag, String column, String sort, String searchParameter, String string) {2 List<TagSystem> result = null;3 final String query = "SELECT * FROM tag_system WHERE 1=1 ";4 StringBuilder searchSQL = new StringBuilder();5 searchSQL.append("SELECT DISTINCT ").append(column).append(" FROM tag_system WHERE 1=1 ");6 if (!StringUtil.isNullOrEmpty(system)) {7 searchSQL.append(" and system = ?");8 }9 if (!StringUtil.isNullOrEmpty(tag)) {10 searchSQL.append(" and tag = ?");11 }12 if (!StringUtil.isNullOrEmpty(searchParameter)) {13 searchSQL.append(" and ").append(column).append(" like ?");14 }15 if (!StringUtil.isNullOrEmpty(sort)) {16 searchSQL.append(" order by ").append(column).append(" ").append(sort);17 }18 try (Connection connection = this.databaseSpring.connect();19 PreparedStatement preStat = connection.prepareStatement(searchSQL.toString());) {20 int i = 1;21 if (!StringUtil.isNullOrEmpty(system)) {22 preStat.setString(i++, system);23 }24 if (!StringUtil.isNullOrEmpty(tag)) {25 preStat.setString(i++, tag);26 }27 if (!StringUtil.isNullOrEmpty(searchParameter)) {28 preStat.setString(i++, searchParameter);29 }30 try (ResultSet resultSet = preStat.executeQuery();) {31 result = this.loadDistinctValuesFromResultSet(resultSet, column);32 }33 } catch (SQLException exception) {34 LOG.error("Unable to execute query : " + query, exception);35 MyLogger.log(TagSystemDAO.class.getName(), Level.ERROR, exception.toString());36 }37 return result;38 }39 private List<TagSystem> loadDistinctValuesFromResultSet(ResultSet resultSet, String column) throws SQLException {40 List<TagSystem> result = new ArrayList<>();41 try {42 while (resultSet.next()) {43 TagSystem tagSystem = new TagSystem();44 tagSystem.setColumn(column);45 if (column.equals("system")) {46 tagSystem.setSystem(resultSet.getString("system"));47 }48 if (column.equals("tag")) {49 tagSystem.setTag(resultSet.getString("tag"));50 }51 result.add(tagSystem);52 }53 } catch (SQLException exception) {54 LOG.warn("Unable to load tag from ResultSet", exception);55 }56 return result;57 }58}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in ITagSystemDAO

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful