This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathssTest.php
128 lines (103 loc) · 3.45 KB
/
ssTest.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
// ssTest.php - test sharedshelf object
require_once('SharedShelfService.php');
require_once('SolrUpdater.php');
try {
$user = parse_ini_file('ssUser.ini');
if ($user === FALSE) {
throw new Exception("Need to create ssUser.ini. See README.md", 1);
}
$ss = new SharedShelfService($user['email'], $user['password']);
if ($ss->logged_in()) {
echo "User is logged in\n";
}
$projects = $ss->projects();
print_r($projects);
/*
48 - Campus Artifacts, Art & Memorabilia
78 - NYS Aerial Photographs
370 - Reps Slides
522 - Tamang
589 - Reps Bastides
616 - Gamelan
659 - PJ Mode Map Collection
687 - Beyond the Taj: Architectural Traditions and Landscape Experience in South Asia
746 - Ragamala Paintings
*/
$selected_project_id = 687;
for ($page = 13; $page < 101; $page += 10) {
$time_start = microtime(TRUE);
print "Trying $page per page:";
$ids = $ss->project_asset_list($selected_project_id, $page);
$time_end = microtime(TRUE);
$took = $time_end - $time_start;
print " took $took seconds.\n";
}
$metadata = $ss->project_fields($selected_project_id);
print_r($metadata);
$assets = $ss->project_asset_ids($selected_project_id);
//print_r($assets);
$count = count($assets);
$asset_count = $ss->project_assets_count($selected_project_id);
if ($count != $asset_count) {
print "ERROR: Asset count mismatch: $count vs. $asset_count\n";
}
$missing = 3857010;
if (in_array($missing, $assets)) {
print "Found $missing in the returned assset list.\n";
}
else {
print "Asset $missing is missing from the asset list.\n";
}
// try getting all assets one by one
$assets_piecemeal = array();
for ($offset = 0; $offset < $asset_count; $offset++) {
$asset_list = $ss->project_assets($selected_project_id, $offset, 1);
$asset = array_shift($asset_list);
$assets_piecemeal[] = $asset['id'];
}
if (in_array($missing, $assets_piecemeal)) {
print "Found $missing in the returned piecemeal assset list.\n";
}
else {
print "Asset $missing is missing from the piecemeal asset list.\n";
}
$piecemeal_count = count($assets_piecemeal);
print "collection has $asset_count, piecemeal requests found $piecemeal_count.\n";
$diff = array_diff($assets, $assets_piecemeal);
print "Difference:\n";
print_r($diff);
// $id = rand(0, $count-1);
// $asset_id = $assets["$id"];
$asset_id = $missing;
$asset = $ss->asset($asset_id);
//print_r($asset);
$values = $ss->asset_field_values($asset);
print_r($values);
$url = $ss->media_url($asset_id);
print_r($url);
$values['Media_URL_s'] = $url;
echo "\n\n";
// echo $ss->project_fields_ini($selected_project_id);
// echo "\n\n";
// $solr = new SolrUpdater('http://jrc88.solr.library.cornell.edu/solr', 'ss2solr.gamelan.ini');
// $solr->add_custom_fields($values);
// $json = $solr->format_update_asset_field_values($values);
// echo $json;
// echo "\n\n";
// $json = $solr->format_add_asset_field_values($values);
// echo $json;
//$asset_list = $ss->project_assets($selected_project_id, 0, 5);
//print_r($asset_list);
// $modified = $ss->assets_modified_since_request($selected_project_id);
// print_r($modified);
// echo "\n\n";
// $asset_ids = $ss->project_asset_ids($selected_project_id, '2014-10-10T14:39:58+00:00');
// print_r($asset_ids);
// $t = count($asset_ids);
// echo "Counted $t\n";
echo "\n\n";
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}