{
    protected function configure()
    {
        $this->setName('run')->setDescription('Run aggregation')->addArgument('uuid', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'UUID(s)', array(null))->addOption('level', 'l', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Level (hour|day|month|year)', array('day'))->addOption('mode', 'm', InputOption::VALUE_REQUIRED, 'Mode (full|delta)', 'delta')->addOption('period', 'p', InputOption::VALUE_REQUIRED, 'Previous time periods (full|delta)');
    }
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!in_array($mode = $input->getOption('mode'), array('full', 'delta'))) {
            throw new \Exception('Unsupported aggregation mode ' . $mode);
        }
        // loop through all uuids
        foreach ($input->getArgument('uuid') as $uuid) {
            // loop through all aggregation levels
            foreach ($input->getOption('level') as $level) {
                if (!Util\Aggregation::isValidAggregationLevel($level)) {
                    throw new \Exception('Unsupported aggregation level ' . $level);
                }
                $msg = "Performing '" . $mode . "' aggregation";
                if ($uuid) {
                    $msg .= " for UUID " . $uuid;
                }
                echo $msg . " on '" . $level . "' level.\n";
                $rows = $this->aggregator->aggregate($uuid, $level, $mode, $input->getOption('period'));
                echo "Updated {$rows} rows.\n";
            }
        }
    }
}
$app = new Util\ConsoleApplication('Data aggregation tool');
$app->addCommands(array(new CreateCommand(), new OptimizeCommand(), new ClearCommand(), new RunCommand()));
$app->run();
        // "Volkszaehler\\Model\\Channel"
        $entity_groups = array();
        echo "Reporting property usage of '" . $property . "'\n";
        foreach (Definition\EntityDefinition::get() as $entity) {
            if ($model && $entity->getModel() !== $model) {
                continue;
            }
            if (!isset($entity_groups[$entity->getInterpreter()])) {
                $entity_groups[$entity->getInterpreter()] = array();
            }
            $entity_groups[$entity->getInterpreter()][] = $entity;
        }
        foreach ($entity_groups as $group => $entities) {
            echo "\n== " . $group . " ==\n";
            foreach ($entities as $entity) {
                echo str_pad($entity->getName() . ":", 16);
                if (in_array($property, $entity->required)) {
                    echo "required\n";
                } elseif (in_array($property, $entity->optional)) {
                    echo "optional\n";
                } else {
                    echo "not allowed\n";
                }
            }
            echo "\n";
        }
    }
}
$app = new Util\ConsoleApplication('Model validation tool');
$app->addCommands(array(new ValidateCommand()));
$app->run();