# coding: utf-8
'''
Created on 27.02.2015
@author: v.popov
'''
from java.util import ArrayList
from author._author_orm import eor_statusesCursor
from ru.curs.celesta.showcase.utils import XMLJSONConverter
try:
    from ru.curs.showcase.core.jython import JythonDTO
    from ru.curs.showcase.core.jython import JythonDownloadResult
    from ru.curs.showcase.core.selector import ResultSelectorData
    from ru.beta2.extra.gwt.ui.selector.api import DataRecord
except:
    from ru.curs.celesta.showcase import JythonDTO    


def statusListAndCount(context, main=None, add=None, filterinfo=None, session=None, params=None,
                curvalue=None, startswith=None, firstrecord=None, recordcount=None):
    status = eor_statusesCursor(context)
    recordList = ArrayList()
    count = status.count()
    for status in status.iterate():
        rec = DataRecord()
        rec.setId(str(status.id))
        rec.setName(status.name)
        recordList.add(rec)
    return ResultSelectorData(recordList, count)
