excludeDict={
    'CommonExclude':[
                     'ModifiedAt','ModifiedBy','CreatedAt','CreatedBy'
                     ],
     'CellMetadata':[
                    'CellReferenceCount','ColumnName','ColumnSpanned','NumberFormat'
                    'ColumnWidth','FinalHeight','FinalWidth','FormulaError','Hidden','RowHeight','RowSpanned'
          ],
    'Formula':[
             'CellReferenceCount','Error'
             ],
    'Node':[
          'CellReferenceCount','Error','IsCellReference','IsPublicRef','LeadingWS','TrailingWS'
          ]
}

excludeStylePropList = ['CreatedAt','DisplayText','SheetMetadataName','CreatedBy','SheetName','ModifiedAt','AssignedTo','SheetId','Application',
                'Category','ModifiedBy','ModifiedIn','Caption']

import logging
def getDisplayCellName(refCell):
    searchList = refCell.getSearchDefinitionList()
    if len(searchList) > 0:
        searchDef = searchList.pop()
        displayCell = searchDef.getDisplayCell()
        if displayCell:
            return displayCell.getCellName()
        else:
            logging.error("display cell is null for the reference cell "+refCell.getCellName()+"["+refCell.getCellDisplayName()+"]("+searchDef.getSheetId()+")"+" in the sheet "+refCell.getSheetMetadata().getSheetName())
    return 'SheetName'

def getDependancyList(refCell):
    searchList = refCell.getSearchDefinitionList()
    if len(searchList) > 0:
        searchDef = searchList.pop()
        parentRefCell = searchDef.getParentReferenceCell()
        searchRefCell = searchDef.getSearchReferenceCell()
        if parentRefCell and searchRefCell:
            return parentRefCell,searchRefCell
        else:
            return None

def getFilteredList(parentObj, refCell, session):
    from orangescape.model.server.util.ServerUtil import createFormulaNode
    if parentObj:
        searchDef = refCell.getSearchDefinitionList()[0]
        searchRefCell = searchDef.getSearchReferenceCell()
        resultFormula= createFormulaNode( searchDef.getCriteriaList()[0], session)
        if resultFormula:
            return session.filter(parentObj, searchRefCell, resultFormula)
        else:
            return session.getList(parentObj, searchRefCell)
    else:
        return []
