Search in sources :

Example 26 with Invariant

use of org.cerberus.crud.entity.Invariant in project cerberus-source by cerberustesting.

the class InvariantService method readToHashMapGp1StringByIdname.

@Override
public HashMap<String, String> readToHashMapGp1StringByIdname(String idName, String defaultValue) {
    HashMap<String, String> result = new HashMap<String, String>();
    // TODO: handle if the response does not turn ok
    AnswerList answer = readByIdname(idName);
    for (Invariant inv : (List<Invariant>) answer.getDataList()) {
        String gp1 = ParameterParserUtil.parseStringParam(inv.getGp1(), defaultValue);
        result.put(inv.getValue(), gp1);
    }
    return result;
}
Also used : Invariant(org.cerberus.crud.entity.Invariant) AnswerList(org.cerberus.util.answer.AnswerList) HashMap(java.util.HashMap) AnswerList(org.cerberus.util.answer.AnswerList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 27 with Invariant

use of org.cerberus.crud.entity.Invariant in project cerberus-source by cerberustesting.

the class InvariantService method getPublicPrivateFilter.

@Override
public String getPublicPrivateFilter(String filter) {
    String searchSQL = " 1=0 ";
    AnswerList answer = this.readByIdname(filter);
    List<Invariant> invPrivate = answer.getDataList();
    List<String> idnameList = null;
    idnameList = new ArrayList<String>();
    for (Invariant toto : invPrivate) {
        idnameList.add(toto.getValue());
    }
    searchSQL = SqlUtil.createWhereInClause("idname", idnameList, true);
    return searchSQL;
}
Also used : Invariant(org.cerberus.crud.entity.Invariant) AnswerList(org.cerberus.util.answer.AnswerList)

Example 28 with Invariant

use of org.cerberus.crud.entity.Invariant in project cerberus-source by cerberustesting.

the class Homepage method extractRow.

private JSONObject extractRow(String application, HashMap<String, HashMap<String, Integer>> totalMap, List<Invariant> myInvariants) throws JSONException {
    JSONObject row = new JSONObject();
    row.put("Application", application);
    HashMap mapApplication = totalMap.get(application);
    int totalPerApplication = 0;
    for (Invariant i : myInvariants) {
        Integer total = (Integer) mapApplication.get(i.getValue());
        totalPerApplication += (total == null ? 0 : total);
    }
    row.put("Total", totalPerApplication);
    for (Invariant i : myInvariants) {
        Integer total = (Integer) mapApplication.get(i.getValue());
        if (total == null) {
            row.put(i.getValue(), 0);
        } else {
            row.put(i.getValue(), total);
        }
    }
    return row;
}
Also used : Invariant(org.cerberus.crud.entity.Invariant) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap)

Aggregations

Invariant (org.cerberus.crud.entity.Invariant)28 AnswerList (org.cerberus.util.answer.AnswerList)18 IInvariantService (org.cerberus.crud.service.IInvariantService)15 JSONObject (org.json.JSONObject)15 ArrayList (java.util.ArrayList)13 List (java.util.List)11 MessageEvent (org.cerberus.engine.entity.MessageEvent)10 IFactoryInvariant (org.cerberus.crud.factory.IFactoryInvariant)8 JSONArray (org.json.JSONArray)8 ApplicationContext (org.springframework.context.ApplicationContext)8 Connection (java.sql.Connection)7 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 SQLException (java.sql.SQLException)7 AnswerItem (org.cerberus.util.answer.AnswerItem)7 JSONException (org.json.JSONException)7 HashMap (java.util.HashMap)6 CerberusException (org.cerberus.exception.CerberusException)5 PolicyFactory (org.owasp.html.PolicyFactory)4 IOException (java.io.IOException)3