<%@ page import="org.apache.log4j.Logger"%>
<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.db.OpenSCGAccessDB" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="ro.emid.common.constants.GlobalAppConstants" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.db.adrese.AdreseHelper" %>
<%
    final Logger LOG = Logger.getLogger("cautTipArteraResp_jsp");
    final String whatToSearch = ObjectUtils.getStringValue(request.getParameter("q")).trim();

    LOG.debug(" whatToSearch=" + whatToSearch);
    try {
//        final String[] tipuriArtera = OpenSCGAccessDB.getTipuriArtera();
        final String[] tipuriArtera = AdreseHelper.getAdreseDao().getTipuriArtera();

        final ArrayList result = new ArrayList();
        for (int i = 0; i < tipuriArtera.length; i++) {
            final String s = tipuriArtera[i];
            if( whatToSearch.length() == 0 || s.toUpperCase().indexOf( whatToSearch.toUpperCase()) == 0){
                result.add( s);
            }
        }
%>
    <respmesg>
        {
            totalCount: <%=result.size()%>,
            list: [

            <% for (int i = 0; i < result.size(); i++) {  %>
            <%   final String tipArtera =  (String ) result.get(i); %>
                <%=(i==0?"":",") %> { key : "-1", value : "<%=ro.emid.common.utils.Util.escapeToJs(AppConstants.format(tipArtera))%>" }
            <% }%>
            ]
        }
    </respmesg>

<%} catch (Throwable t) {
    LOG.error("Eroare get lista localitati", t);
}%>