'Return a dictionary keyed to possible dataset states and valued with lists
containing the ids of each HDA in that state.'

def serialize_state_ids(self, history, key, **context):

    state_ids = {}
    for state in model.Dataset.states.values():
        state_ids[state] = []
    for hda in history.datasets:
        encoded_id = self.app.security.encode_id(hda.id)
        state_ids[hda.state].append(encoded_id)
    return state_ids
