forked from NatLibFi/RecordManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.php
105 lines (94 loc) · 3.8 KB
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* Command line interface for exporting records
*
* PHP version 5
*
* Copyright (C) The National Library of Finland 2011-2017.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category DataManagement
* @package RecordManager
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://github.com/KDK-Alli/RecordManager
*/
require_once 'cmdline.php';
/**
* Main function
*
* @param string[] $argv Program parameters
*
* @return void
*/
function main($argv)
{
$basePath = __DIR__;
$config = parse_ini_file($basePath . '/conf/recordmanager.ini', true);
$params = parseArgs($argv);
$config = applyConfigOverrides($params, $config);
if (empty($params['file'])) {
echo <<<EOT
Usage: $argv[0] --file=... [...]
Parameters:
--file=... The file for records
--deleted=... The file for deleted record IDs
--from=... Update date (and optional time) where to start the export
(e.g. --from="2017-01-01 17:00")
--until=... Update date (and optional time) where to end the export
(e.g. --until="2017-01-01 23:59:59")
--createdfrom=... Creation date (and optional time) where to start the export
(e.g. --createdfrom="2017-01-01 17:00")
--createduntil=... Creation date (and optional time) where to end the export
(e.g. --createduntil="2017-01-01 23:59:59")
--verbose Enable verbose output
--quiet Quiet, no output apart from the data
--skip=... Skip x records to export only a "representative" subset
--source=... Export only the given source(s)
(separate multiple sources with commas)
--single=... Export single record with the given id
--xpath=... Export only records matching the XPath expression
--config.section.name=...
Set configuration directive to given value overriding
any setting in recordmanager.ini
--sortdedup Sort export file by dedup id
--dedupid=... deduped = Add dedup id's to records that have duplicates
always = Always add dedup id's to the records
Otherwise dedup id's are not added to the records
EOT;
exit(1);
}
$export = new \RecordManager\Base\Controller\Export(
$basePath,
$config,
true,
isset($params['verbose']) ? $params['verbose'] : false
);
$export->launch(
$params['file'],
isset($params['deleted']) ? $params['deleted'] : '',
isset($params['from']) ? $params['from'] : '',
isset($params['until']) ? $params['until'] : '',
isset($params['createdfrom']) ? $params['createdfrom'] : '',
isset($params['createduntil']) ? $params['createduntil'] : '',
isset($params['skip']) ? $params['skip'] : 0,
isset($params['source']) ? $params['source'] : '',
isset($params['single']) ? $params['single'] : '',
isset($params['xpath']) ? $params['xpath'] : '',
isset($params['sortdedup']) ? $params['sortdedup'] : false,
isset($params['dedupid']) ? $params['dedupid'] : ''
);
}
main($argv);