|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package: chapi |
|
4
|
|
|
* |
|
5
|
|
|
* @author: msiebeneicher |
|
6
|
|
|
* @since: 2015-08-02 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Chapi\Commands; |
|
12
|
|
|
|
|
13
|
|
|
use Chapi\BusinessCase\JobManagement\StoreJobBusinessCaseFactoryInterface; |
|
14
|
|
|
use Chapi\BusinessCase\JobManagement\StoreJobBusinessCaseInterface; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
17
|
|
|
|
|
18
|
|
|
class PullCommand extends AbstractCommand |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Configures the current command. |
|
22
|
|
|
*/ |
|
23
|
|
|
protected function configure() |
|
24
|
|
|
{ |
|
25
|
|
|
$this->setName('pull') |
|
26
|
|
|
->setDescription('Pull jobs from chronos and add them to local repository') |
|
27
|
|
|
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force to overwrite local jobs') |
|
28
|
|
|
->addArgument('jobnames', InputArgument::IS_ARRAY, 'Jobnames to pull') |
|
29
|
|
|
; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return int |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function process() |
|
36
|
|
|
{ |
|
37
|
|
|
$force = (bool) $this->input->getOption('force'); |
|
38
|
|
|
$jobNames = $this->input->getArgument('jobnames'); |
|
39
|
|
|
|
|
40
|
|
|
/** @var StoreJobBusinessCaseFactoryInterface $storeJobBusinessCaseFactory */ |
|
41
|
|
|
$storeJobBusinessCaseFactory = $this->getContainer()->get(StoreJobBusinessCaseFactoryInterface::DIC_NAME); |
|
42
|
|
|
|
|
43
|
|
|
if (count($jobNames) == 0) { |
|
44
|
|
|
$storeJobBusinessCases = $storeJobBusinessCaseFactory->getAllStoreJobBusinessCase(); |
|
45
|
|
|
/** @var StoreJobBusinessCaseInterface $storeJobBusinessCase */ |
|
46
|
|
|
foreach ($storeJobBusinessCases as $storeJobBusinessCase) { |
|
47
|
|
|
$storeJobBusinessCase->storeJobsToLocalRepository($jobNames, $force); |
|
48
|
|
|
} |
|
49
|
|
|
return 0; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
foreach ($jobNames as $jobName) { |
|
54
|
|
|
// since the job can be of any underlying system |
|
55
|
|
|
// we get teh businesscase for the system |
|
56
|
|
|
// and the update it there. |
|
57
|
|
|
|
|
58
|
|
|
/** @var StoreJobBusinessCaseInterface $_oStoreJobBusinessCase */ |
|
59
|
|
|
$storeJobBusinessCase = $storeJobBusinessCaseFactory->getBusinessCaseWithJob($jobName); |
|
60
|
|
|
if (null == $storeJobBusinessCase) { |
|
61
|
|
|
// not found but process the rest of the jobs |
|
62
|
|
|
continue; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
// TODO: add method for single job to LocalRepository update |
|
66
|
|
|
$storeJobBusinessCase->storeJobsToLocalRepository(array($jobName), $force); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return 0; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|