use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class DocumentationDAO method findAllWithEmptyDocValue.
@Override
public List<Documentation> findAllWithEmptyDocValue(String lang) {
List<Documentation> result = new ArrayList<Documentation>();
final String query = "SELECT DocTable, DocField, DocValue, DocLabel, DocDesc, DocAnchor FROM documentation where Lang = ? and docValue='' ORDER BY DocTable, DocField, DocValue asc";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, lang);
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
String table = resultSet.getString("DocTable");
String field = resultSet.getString("DocField");
String value = resultSet.getString("DocValue");
String label = resultSet.getString("DocLabel");
String description = resultSet.getString("DocDesc");
String anchor = resultSet.getString("DocAnchor");
result.add(factoryDocumentation.create(table, field, value, label, description, anchor));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
return result;
}
use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class DocumentationDAO method findDocumentationsWithNotEmptyValueAndDescription.
@Override
public List<Documentation> findDocumentationsWithNotEmptyValueAndDescription(String docTable, String docField, String lang) {
List<Documentation> result = new ArrayList<Documentation>();
final String query = "SELECT DocValue, DocDesc, DocLabel, DocAnchor FROM documentation where DocTable = ? and docfield = ? and Lang = ? and docValue IS NOT NULL and length(docValue) > 1 AND length(docdesc) > 1";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, docTable);
preStat.setString(2, docField);
preStat.setString(3, lang);
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
String docLabel = resultSet.getString("DocLabel");
String description = resultSet.getString("DocDesc");
String docValue = resultSet.getString("DocValue");
String docAnchor = resultSet.getString("DocAnchor");
result.add(factoryDocumentation.create(docTable, docField, docValue, docLabel, description, docAnchor));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
return result;
}
use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class DocumentationDAO method findDocumentationsWithEmptyValueAndNotEmptyDescription.
@Override
public List<Documentation> findDocumentationsWithEmptyValueAndNotEmptyDescription(String docTable, String docField, String lang) {
List<Documentation> result = new ArrayList<Documentation>();
final String query = "SELECT DocDesc, DocLabel FROM documentation where DocTable = ? and docfield = ? and Lang = ? and length(docvalue)=0 and length(docdesc) > 1";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, docTable);
preStat.setString(2, docField);
preStat.setString(3, lang);
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
String docLabel = resultSet.getString("DocLabel");
String description = resultSet.getString("DocDesc");
String docAnchor = resultSet.getString("DocAnchor");
result.add(factoryDocumentation.create(docTable, docField, "", docLabel, description, docAnchor));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
return result;
}
use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class ReadDocumentation method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse response) throws ServletException, IOException {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
IDocumentationService docService = appContext.getBean(IDocumentationService.class);
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
JSONObject jsonResponse = new JSONObject();
List<Documentation> result = new ArrayList<Documentation>();
JSONObject format = new JSONObject();
response.setContentType("application/json");
response.setCharacterEncoding("utf8");
String lang = ParameterParserUtil.parseStringParamAndSanitize(httpServletRequest.getParameter("lang"), "en");
result = docService.findAllWithEmptyDocLabel(lang);
format = docService.formatGroupByDocTable(result);
try {
jsonResponse.put("labelTable", format);
} catch (JSONException ex) {
LOG.warn(ex);
}
response.getWriter().print(jsonResponse.toString());
}
use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class DocumentationService method formatGroupByDocTable.
@Override
public JSONObject formatGroupByDocTable(List<Documentation> docList) {
JSONObject result = new JSONObject();
for (Documentation doc : docList) {
String docTable = doc.getDocTable();
if (result.has(docTable)) {
try {
result.getJSONObject(docTable).put(doc.getDocField(), convertDocToJSONObject(doc));
} catch (JSONException ex) {
LOG.warn(ex);
}
} else {
try {
result.put(docTable, new JSONObject());
result.getJSONObject(docTable).put(doc.getDocField(), convertDocToJSONObject(doc));
} catch (JSONException ex) {
LOG.warn(ex);
}
}
}
return result;
}
Aggregations