Search in sources :

Example 6 with Documentation

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;
}
Also used : Documentation(org.cerberus.crud.entity.Documentation) IFactoryDocumentation(org.cerberus.crud.factory.IFactoryDocumentation)

Example 7 with 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;
}
Also used : SQLException(java.sql.SQLException) IFactoryDocumentation(org.cerberus.crud.factory.IFactoryDocumentation) Documentation(org.cerberus.crud.entity.Documentation) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 8 with Documentation

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;
}
Also used : SQLException(java.sql.SQLException) IFactoryDocumentation(org.cerberus.crud.factory.IFactoryDocumentation) Documentation(org.cerberus.crud.entity.Documentation) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 9 with Documentation

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;
}
Also used : Documentation(org.cerberus.crud.entity.Documentation)

Example 10 with Documentation

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;
}
Also used : Documentation(org.cerberus.crud.entity.Documentation)

Aggregations

Documentation (org.cerberus.crud.entity.Documentation)10 IFactoryDocumentation (org.cerberus.crud.factory.IFactoryDocumentation)6 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 SQLException (java.sql.SQLException)5 ArrayList (java.util.ArrayList)5 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 IDocumentationService (org.cerberus.crud.service.IDocumentationService)1 PolicyFactory (org.owasp.html.PolicyFactory)1 ApplicationContext (org.springframework.context.ApplicationContext)1