class ListActivitiCommand extends ActivitiCommand {

    @Override
    protected Object doExecute() throws Exception {
        ProcessEngine pe = this.getProcessEngine();

        if (pe == null) {
            out().println("Process Engine NOT Found!");
            return null;
        }

        if (!(this.active || this.definitions || this.history || this.deployments)) {
            // none of them set, display everything 
            // set all to true;
            this.active = this.definitions = this.history = this.deployments = true;
        }

        if (this.deployments) {
            RepositoryService repo = pe.getRepositoryService();
            printDeployments(out(), repo);
        }

        if (this.definitions) {
            RepositoryService repo = pe.getRepositoryService();
            printProcessDefinitions(out(), repo);
        }

        if (this.history) {
            HistoryService his = pe.getHistoryService();
            boolean printActive = !this.active; // if we show active process, dont print then in history 
            printHistoricProcessInstances(out(), his, printActive);
        }

        if (this.active) {
            RuntimeService rt = pe.getRuntimeService();
            printActiveProcessInstances(out(), rt);
        }


        return null;
    }

}