use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class FactoryDocumentation method create.
@Override
public Documentation create(String docTable, String docField, String docValue, String docLabel, String docDesc, String docAnchor) {
Documentation documentation = new Documentation();
documentation.setDocTable(docTable);
documentation.setDocField(docField);
documentation.setDocValue(docValue);
documentation.setDocLabel(docLabel);
documentation.setDocDesc(docDesc);
documentation.setHavedocDesc(!(StringUtil.isNullOrEmpty(docDesc)));
documentation.setDocAnchor(docAnchor);
documentation.setHaveDocAnchor(!(StringUtil.isNullOrEmpty(docAnchor)));
return documentation;
}
use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class DocumentationDAO method findDocumentationByKey.
@Override
public Documentation findDocumentationByKey(String docTable, String docField, String docValue, String lang) {
Documentation result = null;
final String query = "SELECT * FROM documentation d WHERE d.doctable = ? AND d.docfield = ? AND d.DocValue = ? AND Lang = ? ";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, docTable);
preStat.setString(2, docField);
preStat.setString(3, docValue);
preStat.setString(4, lang);
ResultSet resultSet = preStat.executeQuery();
try {
if (resultSet.first()) {
String docLabel = resultSet.getString("DocLabel");
String description = resultSet.getString("DocDesc");
String docAnchor = resultSet.getString("DocAnchor");
result = factoryDocumentation.create(docTable, docField, docValue, docLabel, description, docAnchor);
} else {
return null;
}
} 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 findAll.
@Override
public List<Documentation> findAll(String lang) {
List<Documentation> result = new ArrayList<Documentation>();
final String query = "SELECT DocTable, DocField, DocValue, DocLabel, DocDesc, DocAnchor FROM documentation where Lang = ?";
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 docAnchor = resultSet.getString("DocAnchor");
result.add(factoryDocumentation.create(table, field, value, label, 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 DocumentationService method findLabelHTML.
@Override
public String findLabelHTML(String docTable, String docField, String defaultLabel, String lang) {
String result = null;
StringBuilder label = new StringBuilder();
String labelFromDB = "";
Documentation myDoc = this.documentationDAO.findDocumentationByKey(docTable, docField, "", lang);
if (myDoc == null) {
label.append("!!NoDoc!! ");
label.append(docTable);
label.append("|");
label.append(docField);
} else {
labelFromDB = myDoc.getDocLabel();
label.append(labelFromDB);
if (!(StringUtil.isNullOrEmpty(myDoc.getDocDesc().trim()))) {
label.append(" <a class=\"docOnline\" href=\'javascript:popup(\"Documentation.jsp?DocTable=");
label.append(docTable);
label.append("&DocField=");
label.append(docField);
label.append("&Lang=");
label.append(lang);
// need for a function in the header of dataTables so the table doesn't sort when we click on '?' anchor
if (defaultLabel.equals("table")) {
label.append("\")\' onclick=\"stopPropagation(event)\">?</a>");
} else {
label.append("\")\'>?</a>");
}
}
}
result = label.toString();
return result;
}
use of org.cerberus.crud.entity.Documentation in project cerberus-source by cerberustesting.
the class DocumentationService method findLabel.
@Override
public String findLabel(String docTable, String docField, String defaultLabel, String lang) {
String result = null;
StringBuilder label = new StringBuilder();
String labelFromDB = "";
Documentation myDoc = this.documentationDAO.findDocumentationByKey(docTable, docField, "", lang);
if (myDoc == null) {
label.append("!!NoDoc!! ");
label.append(docTable);
label.append("|");
label.append(docField);
} else {
labelFromDB = myDoc.getDocLabel();
label.append(labelFromDB);
}
result = label.toString();
return result;
}
Aggregations