pho 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/CHANGES +9 -0
  2. data/Rakefile +2 -1
  3. data/bin/talis_store +263 -0
  4. data/doc/rdoc/classes/Pho.html +3 -21
  5. data/doc/rdoc/classes/Pho/Analyzers.html +22 -0
  6. data/doc/rdoc/classes/Pho/DatatypeProperty.html +42 -10
  7. data/doc/rdoc/classes/Pho/Etags.html +102 -30
  8. data/doc/rdoc/classes/Pho/Facet/Results.html +81 -7
  9. data/doc/rdoc/classes/Pho/Facet/Term.html +13 -2
  10. data/doc/rdoc/classes/Pho/FieldPredicateMap.html +233 -30
  11. data/doc/rdoc/classes/Pho/FieldWeighting.html +38 -10
  12. data/doc/rdoc/classes/Pho/Job.html +488 -9
  13. data/doc/rdoc/classes/Pho/JobUpdate.html +141 -0
  14. data/doc/rdoc/classes/Pho/Jobs.html +538 -0
  15. data/doc/rdoc/classes/Pho/Namespaces.html +33 -2
  16. data/doc/rdoc/classes/Pho/QueryProfile.html +162 -20
  17. data/doc/rdoc/classes/Pho/RDFCollection.html +200 -60
  18. data/doc/rdoc/classes/Pho/Snapshot.html +162 -36
  19. data/doc/rdoc/classes/Pho/Status.html +59 -8
  20. data/doc/rdoc/classes/Pho/Store.html +589 -253
  21. data/doc/rdoc/created.rid +1 -1
  22. data/doc/rdoc/files/CHANGES.html +24 -1
  23. data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +1 -1
  24. data/doc/rdoc/files/lib/pho/job_rb.html +1 -1
  25. data/doc/rdoc/files/lib/pho/snapshot_rb.html +2 -1
  26. data/doc/rdoc/files/lib/pho/status_rb.html +1 -1
  27. data/doc/rdoc/files/lib/pho/store_rb.html +1 -1
  28. data/doc/rdoc/files/lib/pho_rb.html +2 -1
  29. data/doc/rdoc/fr_class_index.html +2 -0
  30. data/doc/rdoc/fr_method_index.html +85 -68
  31. data/lib/pho.rb +18 -10
  32. data/lib/pho/field_predicate_map.rb +6 -1
  33. data/lib/pho/job.rb +326 -6
  34. data/lib/pho/snapshot.rb +46 -19
  35. data/lib/pho/store.rb +22 -56
  36. data/tests/tc_job.rb +262 -0
  37. data/tests/tc_jobcontrol.rb +159 -12
  38. data/tests/tc_snapshots.rb +57 -28
  39. data/tests/ts_pho.rb +1 -0
  40. metadata +9 -110
  41. data/doc/rdoc/classes/Pho/DatatypeProperty.src/M000034.html +0 -21
  42. data/doc/rdoc/classes/Pho/DatatypeProperty.src/M000035.html +0 -29
  43. data/doc/rdoc/classes/Pho/Etags.src/M000088.html +0 -23
  44. data/doc/rdoc/classes/Pho/Etags.src/M000089.html +0 -28
  45. data/doc/rdoc/classes/Pho/Etags.src/M000090.html +0 -21
  46. data/doc/rdoc/classes/Pho/Etags.src/M000091.html +0 -18
  47. data/doc/rdoc/classes/Pho/Etags.src/M000092.html +0 -18
  48. data/doc/rdoc/classes/Pho/Etags.src/M000093.html +0 -18
  49. data/doc/rdoc/classes/Pho/Facet/Results.src/M000001.html +0 -20
  50. data/doc/rdoc/classes/Pho/Facet/Results.src/M000002.html +0 -27
  51. data/doc/rdoc/classes/Pho/Facet/Results.src/M000003.html +0 -54
  52. data/doc/rdoc/classes/Pho/Facet/Term.src/M000004.html +0 -20
  53. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000005.html +0 -38
  54. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000006.html +0 -28
  55. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000007.html +0 -20
  56. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000008.html +0 -18
  57. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000009.html +0 -23
  58. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000010.html +0 -23
  59. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000011.html +0 -18
  60. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000012.html +0 -18
  61. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000013.html +0 -18
  62. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000014.html +0 -18
  63. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000015.html +0 -18
  64. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000016.html +0 -21
  65. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000017.html +0 -21
  66. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000018.html +0 -38
  67. data/doc/rdoc/classes/Pho/FieldPredicateMap.src/M000019.html +0 -18
  68. data/doc/rdoc/classes/Pho/FieldWeighting.src/M000075.html +0 -20
  69. data/doc/rdoc/classes/Pho/FieldWeighting.src/M000076.html +0 -26
  70. data/doc/rdoc/classes/Pho/Job.src/M000074.html +0 -21
  71. data/doc/rdoc/classes/Pho/QueryProfile.src/M000024.html +0 -39
  72. data/doc/rdoc/classes/Pho/QueryProfile.src/M000025.html +0 -24
  73. data/doc/rdoc/classes/Pho/QueryProfile.src/M000026.html +0 -20
  74. data/doc/rdoc/classes/Pho/QueryProfile.src/M000027.html +0 -18
  75. data/doc/rdoc/classes/Pho/QueryProfile.src/M000028.html +0 -18
  76. data/doc/rdoc/classes/Pho/QueryProfile.src/M000029.html +0 -21
  77. data/doc/rdoc/classes/Pho/QueryProfile.src/M000030.html +0 -18
  78. data/doc/rdoc/classes/Pho/QueryProfile.src/M000031.html +0 -18
  79. data/doc/rdoc/classes/Pho/QueryProfile.src/M000032.html +0 -38
  80. data/doc/rdoc/classes/Pho/QueryProfile.src/M000033.html +0 -18
  81. data/doc/rdoc/classes/Pho/RDFCollection.src/M000077.html +0 -23
  82. data/doc/rdoc/classes/Pho/RDFCollection.src/M000078.html +0 -22
  83. data/doc/rdoc/classes/Pho/RDFCollection.src/M000079.html +0 -24
  84. data/doc/rdoc/classes/Pho/RDFCollection.src/M000080.html +0 -23
  85. data/doc/rdoc/classes/Pho/RDFCollection.src/M000081.html +0 -18
  86. data/doc/rdoc/classes/Pho/RDFCollection.src/M000082.html +0 -22
  87. data/doc/rdoc/classes/Pho/RDFCollection.src/M000083.html +0 -22
  88. data/doc/rdoc/classes/Pho/RDFCollection.src/M000084.html +0 -26
  89. data/doc/rdoc/classes/Pho/RDFCollection.src/M000085.html +0 -23
  90. data/doc/rdoc/classes/Pho/RDFCollection.src/M000086.html +0 -18
  91. data/doc/rdoc/classes/Pho/RDFCollection.src/M000087.html +0 -18
  92. data/doc/rdoc/classes/Pho/Snapshot.src/M000070.html +0 -31
  93. data/doc/rdoc/classes/Pho/Snapshot.src/M000071.html +0 -21
  94. data/doc/rdoc/classes/Pho/Snapshot.src/M000072.html +0 -18
  95. data/doc/rdoc/classes/Pho/Snapshot.src/M000073.html +0 -37
  96. data/doc/rdoc/classes/Pho/Status.src/M000020.html +0 -20
  97. data/doc/rdoc/classes/Pho/Status.src/M000021.html +0 -31
  98. data/doc/rdoc/classes/Pho/Status.src/M000022.html +0 -18
  99. data/doc/rdoc/classes/Pho/Status.src/M000023.html +0 -18
  100. data/doc/rdoc/classes/Pho/Store.src/M000036.html +0 -22
  101. data/doc/rdoc/classes/Pho/Store.src/M000037.html +0 -18
  102. data/doc/rdoc/classes/Pho/Store.src/M000038.html +0 -25
  103. data/doc/rdoc/classes/Pho/Store.src/M000039.html +0 -20
  104. data/doc/rdoc/classes/Pho/Store.src/M000040.html +0 -20
  105. data/doc/rdoc/classes/Pho/Store.src/M000041.html +0 -28
  106. data/doc/rdoc/classes/Pho/Store.src/M000042.html +0 -23
  107. data/doc/rdoc/classes/Pho/Store.src/M000043.html +0 -18
  108. data/doc/rdoc/classes/Pho/Store.src/M000044.html +0 -18
  109. data/doc/rdoc/classes/Pho/Store.src/M000045.html +0 -18
  110. data/doc/rdoc/classes/Pho/Store.src/M000046.html +0 -18
  111. data/doc/rdoc/classes/Pho/Store.src/M000047.html +0 -23
  112. data/doc/rdoc/classes/Pho/Store.src/M000048.html +0 -22
  113. data/doc/rdoc/classes/Pho/Store.src/M000049.html +0 -26
  114. data/doc/rdoc/classes/Pho/Store.src/M000050.html +0 -24
  115. data/doc/rdoc/classes/Pho/Store.src/M000051.html +0 -20
  116. data/doc/rdoc/classes/Pho/Store.src/M000052.html +0 -20
  117. data/doc/rdoc/classes/Pho/Store.src/M000053.html +0 -25
  118. data/doc/rdoc/classes/Pho/Store.src/M000054.html +0 -20
  119. data/doc/rdoc/classes/Pho/Store.src/M000055.html +0 -30
  120. data/doc/rdoc/classes/Pho/Store.src/M000056.html +0 -21
  121. data/doc/rdoc/classes/Pho/Store.src/M000057.html +0 -23
  122. data/doc/rdoc/classes/Pho/Store.src/M000058.html +0 -28
  123. data/doc/rdoc/classes/Pho/Store.src/M000059.html +0 -18
  124. data/doc/rdoc/classes/Pho/Store.src/M000060.html +0 -18
  125. data/doc/rdoc/classes/Pho/Store.src/M000061.html +0 -18
  126. data/doc/rdoc/classes/Pho/Store.src/M000062.html +0 -31
  127. data/doc/rdoc/classes/Pho/Store.src/M000063.html +0 -21
  128. data/doc/rdoc/classes/Pho/Store.src/M000064.html +0 -20
  129. data/doc/rdoc/classes/Pho/Store.src/M000065.html +0 -20
  130. data/doc/rdoc/classes/Pho/Store.src/M000066.html +0 -20
  131. data/doc/rdoc/classes/Pho/Store.src/M000067.html +0 -20
  132. data/doc/rdoc/classes/Pho/Store.src/M000068.html +0 -20
  133. data/doc/rdoc/classes/Pho/Store.src/M000069.html +0 -20
@@ -1 +1 @@
1
- Fri, 13 Mar 2009 13:28:12 +0000
1
+ Mon, 06 Apr 2009 16:00:04 +0100
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Mon Mar 02 08:22:54 +0000 2009</td>
59
+ <td>Sat Apr 04 19:19:08 +0100 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -72,6 +72,29 @@
72
72
  <p>
73
73
  Brief notes on significant changes and additions in each release
74
74
  </p>
75
+ <h2>Version 0.4</h2>
76
+ <ul>
77
+ <li>Added support for reading Job lifecycle data exposed in Talis Platform
78
+ Release 21
79
+
80
+ </li>
81
+ <li>Added constants for 2 new analysers added in Talis Platform Release 21
82
+
83
+ </li>
84
+ <li>Refactored job submission code to move methods from the Store class onto
85
+ the Jobs and Job classes instead. This brings that code in line with the
86
+ patterns used elsewhere
87
+
88
+ </li>
89
+ <li>Re-implemented snapshot reading code to use RDF/XML rather than scraping
90
+ the HTML
91
+
92
+ </li>
93
+ <li>Added a fledgling command-line tool for working with the platform
94
+ &quot;pho_store&quot;
95
+
96
+ </li>
97
+ </ul>
75
98
  <h2>Version 0.3</h2>
76
99
  <ul>
77
100
  <li>Added support for QueryProfiles, Facets
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Mar 01 16:50:42 +0000 2009</td>
59
+ <td>Mon Mar 23 16:49:48 +0000 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Feb 22 11:24:24 +0000 2009</td>
59
+ <td>Mon Apr 06 15:19:08 +0100 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Feb 24 17:02:33 +0000 2009</td>
59
+ <td>Fri Apr 03 19:09:15 +0100 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -74,6 +74,7 @@
74
74
 
75
75
  <div class="name-list">
76
76
  digest/md5&nbsp;&nbsp;
77
+ tmpdir&nbsp;&nbsp;
77
78
  </div>
78
79
  </div>
79
80
 
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Mon Mar 02 08:21:59 +0000 2009</td>
59
+ <td>Tue Mar 31 17:41:16 +0100 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Thu Mar 05 18:02:36 +0000 2009</td>
59
+ <td>Mon Apr 06 16:00:01 +0100 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Mar 01 16:52:04 +0000 2009</td>
59
+ <td>Thu Apr 02 17:22:46 +0100 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -85,6 +85,7 @@
85
85
  pho/query_profile&nbsp;&nbsp;
86
86
  pho/status&nbsp;&nbsp;
87
87
  pho/facet&nbsp;&nbsp;
88
+ pho/job&nbsp;&nbsp;
88
89
  pho/rdf_collection&nbsp;&nbsp;
89
90
  </div>
90
91
  </div>
@@ -30,6 +30,8 @@
30
30
  <a href="classes/Pho/FieldPredicateMap.html">Pho::FieldPredicateMap</a><br />
31
31
  <a href="classes/Pho/FieldWeighting.html">Pho::FieldWeighting</a><br />
32
32
  <a href="classes/Pho/Job.html">Pho::Job</a><br />
33
+ <a href="classes/Pho/JobUpdate.html">Pho::JobUpdate</a><br />
34
+ <a href="classes/Pho/Jobs.html">Pho::Jobs</a><br />
33
35
  <a href="classes/Pho/Namespaces.html">Pho::Namespaces</a><br />
34
36
  <a href="classes/Pho/QueryProfile.html">Pho::QueryProfile</a><br />
35
37
  <a href="classes/Pho/RDFCollection.html">Pho::RDFCollection</a><br />
@@ -20,99 +20,116 @@
20
20
  <div id="index">
21
21
  <h1 class="section-bar">Methods</h1>
22
22
  <div id="index-entries">
23
- <a href="classes/Pho/QueryProfile.html#M000027"><< (Pho::QueryProfile)</a><br />
24
23
  <a href="classes/Pho/FieldPredicateMap.html#M000008"><< (Pho::FieldPredicateMap)</a><br />
25
- <a href="classes/Pho/Etags.html#M000090">add (Pho::Etags)</a><br />
26
- <a href="classes/Pho/Etags.html#M000091">add_from_response (Pho::Etags)</a><br />
27
- <a href="classes/Pho/Store.html#M000052">augment (Pho::Store)</a><br />
28
- <a href="classes/Pho/Store.html#M000051">augment_uri (Pho::Store)</a><br />
29
- <a href="classes/Pho/Store.html#M000058">build_job_request (Pho::Store)</a><br />
30
- <a href="classes/Pho/Store.html#M000038">build_uri (Pho::Store)</a><br />
31
- <a href="classes/Pho/Store.html#M000053">configure_headers_for_conditional_get (Pho::Store)</a><br />
24
+ <a href="classes/Pho/QueryProfile.html#M000027"><< (Pho::QueryProfile)</a><br />
25
+ <a href="classes/Pho/Etags.html#M000107">add (Pho::Etags)</a><br />
26
+ <a href="classes/Pho/Etags.html#M000108">add_from_response (Pho::Etags)</a><br />
27
+ <a href="classes/Pho/Store.html#M000062">augment (Pho::Store)</a><br />
28
+ <a href="classes/Pho/Store.html#M000061">augment_uri (Pho::Store)</a><br />
29
+ <a href="classes/Pho/Snapshot.html#M000081">backup (Pho::Snapshot)</a><br />
30
+ <a href="classes/Pho/Jobs.html#M000040">build_job_request (Pho::Jobs)</a><br />
31
+ <a href="classes/Pho/Store.html#M000048">build_uri (Pho::Store)</a><br />
32
+ <a href="classes/Pho/Job.html#M000087">completed? (Pho::Job)</a><br />
33
+ <a href="classes/Pho/Store.html#M000063">configure_headers_for_conditional_get (Pho::Store)</a><br />
32
34
  <a href="classes/Pho/FieldPredicateMap.html#M000006">create_mapping (Pho::FieldPredicateMap)</a><br />
33
35
  <a href="classes/Pho/QueryProfile.html#M000025">create_weighting (Pho::QueryProfile)</a><br />
34
- <a href="classes/Pho/Store.html#M000056">delete_item (Pho::Store)</a><br />
35
- <a href="classes/Pho/Store.html#M000042">describe (Pho::Store)</a><br />
36
- <a href="classes/Pho/Snapshot.html#M000073">download (Pho::Snapshot)</a><br />
37
- <a href="classes/Pho/Store.html#M000049">facet (Pho::Store)</a><br />
38
- <a href="classes/Pho/RDFCollection.html#M000082">failures (Pho::RDFCollection)</a><br />
39
- <a href="classes/Pho/Etags.html#M000092">get (Pho::Etags)</a><br />
40
- <a href="classes/Pho/FieldPredicateMap.html#M000013">get_by_name (Pho::FieldPredicateMap)</a><br />
36
+ <a href="classes/Pho/Store.html#M000066">delete_item (Pho::Store)</a><br />
37
+ <a href="classes/Pho/Store.html#M000052">describe (Pho::Store)</a><br />
38
+ <a href="classes/Pho/Store.html#M000059">facet (Pho::Store)</a><br />
39
+ <a href="classes/Pho/RDFCollection.html#M000099">failures (Pho::RDFCollection)</a><br />
40
+ <a href="classes/Pho/Etags.html#M000109">get (Pho::Etags)</a><br />
41
41
  <a href="classes/Pho/QueryProfile.html#M000028">get_by_name (Pho::QueryProfile)</a><br />
42
+ <a href="classes/Pho/FieldPredicateMap.html#M000013">get_by_name (Pho::FieldPredicateMap)</a><br />
42
43
  <a href="classes/Pho/FieldPredicateMap.html#M000014">get_by_uri (Pho::FieldPredicateMap)</a><br />
43
- <a href="classes/Pho/RDFCollection.html#M000086">get_fail_file_for (Pho::RDFCollection)</a><br />
44
- <a href="classes/Pho/Store.html#M000066">get_field_predicate_map (Pho::Store)</a><br />
45
- <a href="classes/Pho/Store.html#M000057">get_item (Pho::Store)</a><br />
44
+ <a href="classes/Pho/RDFCollection.html#M000103">get_fail_file_for (Pho::RDFCollection)</a><br />
45
+ <a href="classes/Pho/Store.html#M000073">get_field_predicate_map (Pho::Store)</a><br />
46
+ <a href="classes/Pho/Store.html#M000067">get_item (Pho::Store)</a><br />
47
+ <a href="classes/Pho/Store.html#M000068">get_job (Pho::Store)</a><br />
48
+ <a href="classes/Pho/Store.html#M000069">get_jobs (Pho::Store)</a><br />
46
49
  <a href="classes/Pho/FieldPredicateMap.html#M000009">get_name (Pho::FieldPredicateMap)</a><br />
47
- <a href="classes/Pho/RDFCollection.html#M000087">get_ok_file_for (Pho::RDFCollection)</a><br />
50
+ <a href="classes/Pho/RDFCollection.html#M000104">get_ok_file_for (Pho::RDFCollection)</a><br />
48
51
  <a href="classes/Pho/FieldPredicateMap.html#M000010">get_property_uri (Pho::FieldPredicateMap)</a><br />
49
- <a href="classes/Pho/Store.html#M000068">get_query_profile (Pho::Store)</a><br />
50
- <a href="classes/Pho/Store.html#M000050">get_search_params (Pho::Store)</a><br />
51
- <a href="classes/Pho/Store.html#M000065">get_snapshots (Pho::Store)</a><br />
52
- <a href="classes/Pho/Store.html#M000064">get_status (Pho::Store)</a><br />
53
- <a href="classes/Pho/Etags.html#M000093">has_tag? (Pho::Etags)</a><br />
54
- <a href="classes/Pho/RDFCollection.html#M000081">list (Pho::RDFCollection)</a><br />
55
- <a href="classes/Pho/QueryProfile.html#M000031">mapped_name? (Pho::QueryProfile)</a><br />
52
+ <a href="classes/Pho/Store.html#M000075">get_query_profile (Pho::Store)</a><br />
53
+ <a href="classes/Pho/Store.html#M000060">get_search_params (Pho::Store)</a><br />
54
+ <a href="classes/Pho/Store.html#M000072">get_snapshots (Pho::Store)</a><br />
55
+ <a href="classes/Pho/Store.html#M000071">get_status (Pho::Store)</a><br />
56
+ <a href="classes/Pho/Etags.html#M000110">has_tag? (Pho::Etags)</a><br />
57
+ <a href="classes/Pho/RDFCollection.html#M000098">list (Pho::RDFCollection)</a><br />
56
58
  <a href="classes/Pho/FieldPredicateMap.html#M000011">mapped_name? (Pho::FieldPredicateMap)</a><br />
59
+ <a href="classes/Pho/QueryProfile.html#M000031">mapped_name? (Pho::QueryProfile)</a><br />
57
60
  <a href="classes/Pho/FieldPredicateMap.html#M000012">mapped_uri? (Pho::FieldPredicateMap)</a><br />
58
- <a href="classes/Pho/RDFCollection.html#M000077">new (Pho::RDFCollection)</a><br />
59
- <a href="classes/Pho/Store.html#M000036">new (Pho::Store)</a><br />
60
- <a href="classes/Pho/Status.html#M000020">new (Pho::Status)</a><br />
61
- <a href="classes/Pho/DatatypeProperty.html#M000034">new (Pho::DatatypeProperty)</a><br />
62
- <a href="classes/Pho/Etags.html#M000088">new (Pho::Etags)</a><br />
63
- <a href="classes/Pho/FieldWeighting.html#M000075">new (Pho::FieldWeighting)</a><br />
64
- <a href="classes/Pho/QueryProfile.html#M000026">new (Pho::QueryProfile)</a><br />
65
61
  <a href="classes/Pho/FieldPredicateMap.html#M000007">new (Pho::FieldPredicateMap)</a><br />
62
+ <a href="classes/Pho/Job.html#M000082">new (Pho::Job)</a><br />
63
+ <a href="classes/Pho/RDFCollection.html#M000094">new (Pho::RDFCollection)</a><br />
64
+ <a href="classes/Pho/Status.html#M000020">new (Pho::Status)</a><br />
65
+ <a href="classes/Pho/FieldWeighting.html#M000092">new (Pho::FieldWeighting)</a><br />
66
+ <a href="classes/Pho/DatatypeProperty.html#M000044">new (Pho::DatatypeProperty)</a><br />
66
67
  <a href="classes/Pho/Facet/Term.html#M000004">new (Pho::Facet::Term)</a><br />
67
- <a href="classes/Pho/Snapshot.html#M000071">new (Pho::Snapshot)</a><br />
68
+ <a href="classes/Pho/Store.html#M000046">new (Pho::Store)</a><br />
69
+ <a href="classes/Pho/Etags.html#M000105">new (Pho::Etags)</a><br />
70
+ <a href="classes/Pho/Snapshot.html#M000079">new (Pho::Snapshot)</a><br />
71
+ <a href="classes/Pho/QueryProfile.html#M000026">new (Pho::QueryProfile)</a><br />
68
72
  <a href="classes/Pho/Facet/Results.html#M000001">new (Pho::Facet::Results)</a><br />
69
- <a href="classes/Pho/RDFCollection.html#M000084">new_files (Pho::RDFCollection)</a><br />
70
- <a href="classes/Pho/Snapshot.html#M000070">parse (Pho::Snapshot)</a><br />
73
+ <a href="classes/Pho/RDFCollection.html#M000101">new_files (Pho::RDFCollection)</a><br />
71
74
  <a href="classes/Pho/Facet/Results.html#M000003">parse (Pho::Facet::Results)</a><br />
72
- <a href="classes/Pho/Job.html#M000074">parse_jobs (Pho::Job)</a><br />
73
- <a href="classes/Pho/Store.html#M000067">put_field_predicate_map (Pho::Store)</a><br />
74
- <a href="classes/Pho/Store.html#M000069">put_query_profile (Pho::Store)</a><br />
75
- <a href="classes/Pho/Facet/Results.html#M000002">read_from_store (Pho::Facet::Results)</a><br />
75
+ <a href="classes/Pho/Job.html#M000084">parse (Pho::Job)</a><br />
76
+ <a href="classes/Pho/Snapshot.html#M000078">parse (Pho::Snapshot)</a><br />
77
+ <a href="classes/Pho/Job.html#M000085">progress_updates (Pho::Job)</a><br />
78
+ <a href="classes/Pho/Store.html#M000074">put_field_predicate_map (Pho::Store)</a><br />
79
+ <a href="classes/Pho/Store.html#M000076">put_query_profile (Pho::Store)</a><br />
80
+ <a href="classes/Pho/Snapshot.html#M000077">read_from_store (Pho::Snapshot)</a><br />
81
+ <a href="classes/Pho/QueryProfile.html#M000024">read_from_store (Pho::QueryProfile)</a><br />
76
82
  <a href="classes/Pho/FieldPredicateMap.html#M000005">read_from_store (Pho::FieldPredicateMap)</a><br />
77
83
  <a href="classes/Pho/Status.html#M000021">read_from_store (Pho::Status)</a><br />
78
- <a href="classes/Pho/QueryProfile.html#M000024">read_from_store (Pho::QueryProfile)</a><br />
79
- <a href="classes/Pho/Snapshot.html#M000072">read_md5 (Pho::Snapshot)</a><br />
84
+ <a href="classes/Pho/Facet/Results.html#M000002">read_from_store (Pho::Facet::Results)</a><br />
85
+ <a href="classes/Pho/Job.html#M000083">read_from_store (Pho::Job)</a><br />
86
+ <a href="classes/Pho/Jobs.html#M000034">read_from_store (Pho::Jobs)</a><br />
87
+ <a href="classes/Pho/Snapshot.html#M000080">read_md5 (Pho::Snapshot)</a><br />
80
88
  <a href="classes/Pho/Status.html#M000022">readable? (Pho::Status)</a><br />
81
- <a href="classes/Pho/Store.html#M000054">record_etags (Pho::Store)</a><br />
82
- <a href="classes/Pho/Store.html#M000060">reindex (Pho::Store)</a><br />
89
+ <a href="classes/Pho/Store.html#M000064">record_etags (Pho::Store)</a><br />
83
90
  <a href="classes/Pho/QueryProfile.html#M000030">remove (Pho::QueryProfile)</a><br />
84
91
  <a href="classes/Pho/FieldPredicateMap.html#M000015">remove (Pho::FieldPredicateMap)</a><br />
85
92
  <a href="classes/Pho/FieldPredicateMap.html#M000016">remove_by_name (Pho::FieldPredicateMap)</a><br />
86
93
  <a href="classes/Pho/QueryProfile.html#M000029">remove_by_name (Pho::QueryProfile)</a><br />
87
94
  <a href="classes/Pho/FieldPredicateMap.html#M000017">remove_by_uri (Pho::FieldPredicateMap)</a><br />
88
- <a href="classes/Pho/RDFCollection.html#M000080">reset (Pho::RDFCollection)</a><br />
89
- <a href="classes/Pho/Store.html#M000059">reset (Pho::Store)</a><br />
90
- <a href="classes/Pho/Store.html#M000062">restore (Pho::Store)</a><br />
91
- <a href="classes/Pho/RDFCollection.html#M000079">retry_failures (Pho::RDFCollection)</a><br />
92
- <a href="classes/Pho/Etags.html#M000089">save (Pho::Etags)</a><br />
93
- <a href="classes/Pho/Store.html#M000048">search (Pho::Store)</a><br />
94
- <a href="classes/Pho/Store.html#M000037">set_credentials (Pho::Store)</a><br />
95
- <a href="classes/Pho/Store.html#M000061">snapshot (Pho::Store)</a><br />
96
- <a href="classes/Pho/Store.html#M000047">sparql (Pho::Store)</a><br />
97
- <a href="classes/Pho/Store.html#M000045">sparql_ask (Pho::Store)</a><br />
98
- <a href="classes/Pho/Store.html#M000044">sparql_construct (Pho::Store)</a><br />
99
- <a href="classes/Pho/Store.html#M000043">sparql_describe (Pho::Store)</a><br />
100
- <a href="classes/Pho/Store.html#M000046">sparql_select (Pho::Store)</a><br />
101
- <a href="classes/Pho/RDFCollection.html#M000078">store (Pho::RDFCollection)</a><br />
102
- <a href="classes/Pho/Store.html#M000039">store_data (Pho::Store)</a><br />
103
- <a href="classes/Pho/Store.html#M000040">store_file (Pho::Store)</a><br />
104
- <a href="classes/Pho/Store.html#M000041">store_url (Pho::Store)</a><br />
105
- <a href="classes/Pho/Store.html#M000063">submit_job (Pho::Store)</a><br />
106
- <a href="classes/Pho/RDFCollection.html#M000083">successes (Pho::RDFCollection)</a><br />
107
- <a href="classes/Pho/RDFCollection.html#M000085">summary (Pho::RDFCollection)</a><br />
108
- <a href="classes/Pho/FieldPredicateMap.html#M000018">to_rdf (Pho::FieldPredicateMap)</a><br />
109
- <a href="classes/Pho/DatatypeProperty.html#M000035">to_rdf (Pho::DatatypeProperty)</a><br />
110
- <a href="classes/Pho/FieldWeighting.html#M000076">to_rdf (Pho::FieldWeighting)</a><br />
95
+ <a href="classes/Pho/RDFCollection.html#M000097">reset (Pho::RDFCollection)</a><br />
96
+ <a href="classes/Pho/RDFCollection.html#M000096">retry_failures (Pho::RDFCollection)</a><br />
97
+ <a href="classes/Pho/Job.html#M000089">running? (Pho::Job)</a><br />
98
+ <a href="classes/Pho/Etags.html#M000106">save (Pho::Etags)</a><br />
99
+ <a href="classes/Pho/Store.html#M000058">search (Pho::Store)</a><br />
100
+ <a href="classes/Pho/Store.html#M000047">set_credentials (Pho::Store)</a><br />
101
+ <a href="classes/Pho/Store.html#M000057">sparql (Pho::Store)</a><br />
102
+ <a href="classes/Pho/Store.html#M000055">sparql_ask (Pho::Store)</a><br />
103
+ <a href="classes/Pho/Store.html#M000054">sparql_construct (Pho::Store)</a><br />
104
+ <a href="classes/Pho/Store.html#M000053">sparql_describe (Pho::Store)</a><br />
105
+ <a href="classes/Pho/Store.html#M000056">sparql_select (Pho::Store)</a><br />
106
+ <a href="classes/Pho/Job.html#M000086">started? (Pho::Job)</a><br />
107
+ <a href="classes/Pho/RDFCollection.html#M000095">store (Pho::RDFCollection)</a><br />
108
+ <a href="classes/Pho/Store.html#M000049">store_data (Pho::Store)</a><br />
109
+ <a href="classes/Pho/Store.html#M000050">store_file (Pho::Store)</a><br />
110
+ <a href="classes/Pho/Store.html#M000051">store_url (Pho::Store)</a><br />
111
+ <a href="classes/Pho/Jobs.html#M000039">submit_job (Pho::Jobs)</a><br />
112
+ <a href="classes/Pho/Store.html#M000070">submit_job (Pho::Store)</a><br />
113
+ <a href="classes/Pho/Jobs.html#M000036">submit_reindex (Pho::Jobs)</a><br />
114
+ <a href="classes/Pho/Jobs.html#M000035">submit_reset (Pho::Jobs)</a><br />
115
+ <a href="classes/Pho/Jobs.html#M000038">submit_restore (Pho::Jobs)</a><br />
116
+ <a href="classes/Pho/Jobs.html#M000037">submit_snapshot (Pho::Jobs)</a><br />
117
+ <a href="classes/Pho/RDFCollection.html#M000100">successes (Pho::RDFCollection)</a><br />
118
+ <a href="classes/Pho/Job.html#M000088">successful? (Pho::Job)</a><br />
119
+ <a href="classes/Pho/RDFCollection.html#M000102">summary (Pho::RDFCollection)</a><br />
111
120
  <a href="classes/Pho/QueryProfile.html#M000032">to_rdf (Pho::QueryProfile)</a><br />
121
+ <a href="classes/Pho/FieldPredicateMap.html#M000018">to_rdf (Pho::FieldPredicateMap)</a><br />
122
+ <a href="classes/Pho/DatatypeProperty.html#M000045">to_rdf (Pho::DatatypeProperty)</a><br />
123
+ <a href="classes/Pho/FieldWeighting.html#M000093">to_rdf (Pho::FieldWeighting)</a><br />
112
124
  <a href="classes/Pho/FieldPredicateMap.html#M000019">upload (Pho::FieldPredicateMap)</a><br />
113
125
  <a href="classes/Pho/QueryProfile.html#M000033">upload (Pho::QueryProfile)</a><br />
114
- <a href="classes/Pho/Store.html#M000055">upload_item (Pho::Store)</a><br />
126
+ <a href="classes/Pho/Store.html#M000065">upload_item (Pho::Store)</a><br />
127
+ <a href="classes/Pho/Jobs.html#M000042">wait_for (Pho::Jobs)</a><br />
128
+ <a href="classes/Pho/Jobs.html#M000041">wait_for_submitted (Pho::Jobs)</a><br />
129
+ <a href="classes/Pho/Job.html#M000091">with_each (Pho::Job)</a><br />
130
+ <a href="classes/Pho/Job.html#M000090">with_first (Pho::Job)</a><br />
115
131
  <a href="classes/Pho/Status.html#M000023">writeable? (Pho::Status)</a><br />
132
+ <a href="classes/Pho/Jobs.html#M000043">yield_job_update (Pho::Jobs)</a><br />
116
133
  </div>
117
134
  </div>
118
135
  </body>
data/lib/pho.rb CHANGED
@@ -11,6 +11,7 @@ require 'pho/field_predicate_map'
11
11
  require 'pho/query_profile'
12
12
  require 'pho/status'
13
13
  require 'pho/facet'
14
+ require 'pho/job'
14
15
  require 'pho/rdf_collection'
15
16
 
16
17
  module Pho
@@ -19,19 +20,26 @@ module Pho
19
20
  ACCEPT_JSON = { "Accept" => "application/json" }.freeze
20
21
 
21
22
  RDF_XML = {"Content-Type"=>"application/rdf+xml"}.freeze
22
-
23
- JOB_RESET = "http://schemas.talis.com/2006/bigfoot/configuration#ResetDataJob".freeze
24
- JOB_SNAPSHOT = "http://schemas.talis.com/2006/bigfoot/configuration#SnapshotJob".freeze
25
- JOB_REINDEX = "http://schemas.talis.com/2006/bigfoot/configuration#ReindexJob".freeze
26
- JOB_RESTORE = "http://schemas.talis.com/2006/bigfoot/configuration#RestoreJob".freeze
27
-
28
-
29
- module Namespaces
23
+
24
+ class Namespaces
30
25
 
31
26
  CONFIG = "http://schemas.talis.com/2006/bigfoot/configuration#"
32
27
  FRAME = "http://schemas.talis.com/2006/frame/schema#"
33
28
  FACET = "http://schemas.talis.com/2007/facet-results#"
34
-
29
+ RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
30
+ RDFS = "http://www.w3.org/2000/01/rdf-schema#"
31
+ DC = "http://purl.org/dc/elements/1.1/"
32
+ DC_TERMS = "http://purl.org/dc/terms/"
33
+
34
+ MAPPING = {
35
+ "bf" => CONFIG,
36
+ "frm" => FRAME,
37
+ "rdf" => RDF,
38
+ "rdfs" => RDFS,
39
+ "dc" => DC,
40
+ "dcterms" => DC_TERMS
41
+ }
42
+
35
43
  end
36
-
44
+
37
45
  end
@@ -42,7 +42,12 @@ module Pho
42
42
  #English analyzer without stop words and with accent support. This is identical to the standard English analyzer but all words are indexed plus any accented characters in the ISO Latin 1 character set are replaced by their unaccented equivalent
43
43
  #See API documentation at http://n2.talis.com/wiki/Field_Predicate_Map for details of replacements
44
44
  NORMALISE_STANDARD = "http://schemas.talis.com/2007/bigfoot/analyzers#norm-en".freeze
45
-
45
+
46
+ #English analyzer with porter stemming, case normalization, latin 1 normalization, and stop words removal
47
+ PORTER_NORMALIZE_STANDARD = "http://schemas.talis.com/2007/bigfoot/analyzers#porter-norm-en".freeze
48
+
49
+ #English analyzer with porter stemming, case normalization and latin 1 normalization.
50
+ PORTER_NO_STOP_WORD_STANDARD = "http://schemas.talis.com/2007/bigfoot/analyzers#porter-nostop-norm-en".freeze
46
51
  end
47
52
 
48
53
  #Captures information about a mapped datatype from a Field Predicate Map
@@ -1,17 +1,337 @@
1
1
  module Pho
2
+
3
+ #TODO job deletion
4
+
5
+ class Jobs
6
+
7
+ RESET = "http://schemas.talis.com/2006/bigfoot/configuration#ResetDataJob".freeze
8
+ SNAPSHOT = "http://schemas.talis.com/2006/bigfoot/configuration#SnapshotJob".freeze
9
+ REINDEX = "http://schemas.talis.com/2006/bigfoot/configuration#ReindexJob".freeze
10
+ RESTORE = "http://schemas.talis.com/2006/bigfoot/configuration#RestoreJob".freeze
11
+
12
+ #Reads the current list of scheduled jobs from the provided store. Returns an array of
13
+ #job names
14
+ #
15
+ # store:: store from which to read the scheduled job list
16
+ def Jobs.read_from_store(store)
17
+ resp = store.get_jobs()
18
+ if resp.status != 200
19
+ raise "Unable to read jobs from store. Status was {resp.status}"
20
+ end
21
+ jobs = Array.new
22
+
23
+ doc = REXML::Document.new(resp.content)
24
+ REXML::XPath.each(doc.root, "//bf:job", Pho::Namespaces::MAPPING).each do |el|
25
+ jobs << el.attributes["rdf:resource"]
26
+ end
27
+ return jobs
28
+
29
+ end
30
+
31
+ #Submit a reset job to the Platform
32
+ #
33
+ #This method submits the job, and will return an HTTP:Message indicating the
34
+ #response from the Platform. Client code should check this for success. As job
35
+ #processing may not be immediate, clients should determine the URI of the newly created
36
+ #job and then monitor the jobs status if they need to wait for the job to finish.
37
+ def Jobs.submit_reset(store, label="Reset my store", t=Time.now)
38
+ return submit_job(store, Pho::Jobs::RESET, label, t)
39
+ end
40
+
41
+ #Submit a reindex job to the Platform
42
+ #
43
+ #This method submits the job, and will return an HTTP:Message indicating the
44
+ #response from the Platform. Client code should check this for success. As job
45
+ #processing may not be immediate, clients should determine the URI of the newly created
46
+ #job and then monitor the jobs status if they need to wait for the job to finish.
47
+ def Jobs.submit_reindex(store, label="Reindex my store", t=Time.now)
48
+ return submit_job(store, Pho::Jobs::REINDEX, label, t)
49
+ end
50
+
51
+ #Submit a snapshot job to the Platform
52
+ #
53
+ #This method submits the job, and will return an HTTP:Message indicating the
54
+ #response from the Platform. Client code should check this for success. As job
55
+ #processing may not be immediate, clients should determine the URI of the newly created
56
+ #job and then monitor the jobs status if they need to wait for the job to finish.
57
+ def Jobs.submit_snapshot(store, label="Snapshot my store", t=Time.now)
58
+ return submit_job(store, Pho::Jobs::SNAPSHOT, label, t)
59
+ end
60
+
61
+ #Submit a restore job to the Platform
62
+ #
63
+ #This method submits the job, and will return an HTTP:Message indicating the
64
+ #response from the Platform. Client code should check this for success. As job
65
+ #processing may not be immediate, clients should determine the URI of the newly created
66
+ #job and then monitor the jobs status if they need to wait for the job to finish.
67
+ def Jobs.submit_restore(store, snapshot_uri, label="Restore my snapshot", t=Time.now)
68
+ return submit_job(store, Pho::Jobs::RESTORE, label, t, snapshot_uri)
69
+ end
70
+
71
+ #Generic submit job method
72
+ def Jobs.submit_job(store, jobtype, label, t=Time.now, snapshot_uri=nil)
73
+ store.submit_job( build_job_request(jobtype, label, t, snapshot_uri) )
74
+ end
75
+
76
+ # Construct an RDF/XML document containing a job request for submitting to the Platform.
77
+ #
78
+ # t:: a Time object, specifying the time at which the request should be carried out
79
+ def Jobs.build_job_request(type, label, t=Time.now, snapshot_uri=nil)
80
+
81
+ time = t.getutc.strftime("%Y-%m-%dT%H:%M:%SZ")
82
+ data = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" "
83
+ data << " xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" "
84
+ data << " xmlns:bf=\"http://schemas.talis.com/2006/bigfoot/configuration#\"> "
85
+ data << " <bf:JobRequest>"
86
+ data << " <rdfs:label>#{label}</rdfs:label>"
87
+ data << " <bf:jobType rdf:resource=\"#{type}\"/>"
88
+ data << " <bf:startTime>#{time}</bf:startTime>"
89
+
90
+ if (snapshot_uri != nil)
91
+ data << " <bf:snapshotUri rdf:resource=\"#{snapshot_uri}\"/>"
92
+ end
93
+
94
+ data << " </bf:JobRequest>"
95
+ data << "</rdf:RDF>"
96
+ return data
97
+ end
98
+
99
+ #Wait for a newly submitted job to finish
100
+ def Jobs.wait_for_submitted(resp, store, interval=1, &block)
101
+ if resp.status != 201
102
+ raise "Unable to wait, job was not created. Status was #{resp.status}"
103
+ end
104
+ job_url = resp.header["Location"].first
105
+ return wait_for(job_url, store, interval, &block)
106
+ end
107
+
108
+ #Wait for the specified job to finish
109
+ #
110
+ #The method will repeatedly contact the Platform to determine whether the job has finished
111
+ #executing. The requests are made at configurable intervals (once a minute by default). If
112
+ #a block is supplied, then it is passed a reference to the Job (containing current progress
113
+ #updates) after each request. The Job object is returned once completed.
114
+ #
115
+ # uri:: URI of the job to wait for
116
+ # store:: the store on which the job is running
117
+ # interval:: the interval at which checks will be made, in minutes. Default is 1
118
+ def Jobs.wait_for(uri, store, interval=1, &block)
119
+ updates = 0
120
+ job = Job.read_from_store(uri, store)
121
+ updates = yield_job_update(job, updates, &block)
122
+ while !job.completed?
123
+ sleep interval*60
124
+ job = Job.read_from_store(uri, store)
125
+ updates = yield_job_update(job, updates, &block)
126
+ end
127
+ return job
128
+ end
129
+
130
+ protected
131
+
132
+ def Jobs.yield_job_update(job, updates)
133
+ if block_given?
134
+ if job.started?
135
+
136
+ #only yield start message if we've not seen any updates
137
+ if updates == 0
138
+ yield job, job.start_message, job.actual_start_time
139
+ end
140
+
141
+ if job.progress_updates.length > 0
142
+ unseen = job.progress_updates[updates, job.progress_updates.length]
143
+ unseen.each do |update|
144
+ yield job, update.message, update.time
145
+ end
146
+ updates = job.progress_updates.length
147
+ end
148
+
149
+ if job.completed?
150
+ yield job, job.completion_message, job.end_time
151
+ end
152
+
153
+ end
154
+ end
155
+ return updates
156
+ end
157
+
158
+ end
2
159
 
3
- # Captures information about a Platform Job
4
- class Job
160
+ #Simple object encapsulating the status message and time for a job update
161
+ class JobUpdate
5
162
 
163
+ #the status message
164
+ attr_accessor :message
165
+ #the time at which the update was logged
166
+ attr_accessor :time
6
167
 
7
- # Parse out an array of Job objects from a response returned from the Platform
8
- def Job.parse_jobs(resp)
168
+ end
169
+
170
+ # A Platform Job
171
+ #
172
+ # Instances of this class encapsulate all of the core metadata relating to a Platform Job.
173
+ # This includes not only the timing information but also the completion status, etc.
174
+ #
175
+ # The class provides convenience methods for retrieving and parsing data about a specific
176
+ # Job from a platform store
177
+ class Job
178
+
179
+ SUCCESS = "http://schemas.talis.com/2006/bigfoot/configuration#success"
180
+ ABORTED = "http://schemas.talis.com/2006/bigfoot/configuration#aborted"
181
+
182
+ #URI of the job
183
+ attr_reader :uri
184
+ #Label associated with job
185
+ attr_reader :label
186
+ #Type of job
187
+ attr_reader :type
188
+ #Date-time that the job was created
189
+ attr_reader :created
190
+ #Date-time that the job will start
191
+ attr_reader :start_time
192
+ #Date-time that the job actually started
193
+ attr_accessor :actual_start_time
194
+ #URI of snapshot to load. (For RestoreJob only)
195
+ attr_accessor :snapshot_uri
196
+ #Message recorded at the time the job started
197
+ attr_accessor :start_message
198
+ #An array of JobUpdate instances. May be empty if no updates have been logged
199
+ attr_accessor :progress_updates
200
+ #URI indicating completion status of the job
201
+ attr_accessor :completion_status
202
+ #Completion message
203
+ attr_accessor :completion_message
204
+ #Date time that the job actually completed
205
+ attr_accessor :end_time
206
+
207
+ #Constructor. Used in the reading/parsing code
208
+ #
209
+ #uri:: a unique identifier for the job
210
+ #label:: a description of the job
211
+ #type:: the type of the job, e.g. Pho::Jobs::RESTORE
212
+ #created:: date-time the job was created in the system
213
+ #start_time:: scheduled start time for the job
214
+ def initialize(uri, label, type, start_time, created=nil)
215
+ @uri = uri
216
+ @label = label
217
+ @type = type
218
+ @created = created
219
+ @start_time = start_time
220
+ @progress_updates = Array.new
221
+ end
222
+
223
+ #Read a job from a store
224
+ #
225
+ #uri:: uri of the job to read
226
+ #store:: store from which the job will be read
227
+ def Job.read_from_store(uri, store)
228
+ resp = store.get_job(uri)
9
229
  if resp.status != 200
10
- throw
230
+ raise "Unable to read job from store. Response code was #{resp.status}"
231
+ end
232
+
233
+ return parse(uri, resp.content)
234
+ end
235
+
236
+ #Parses job metadata returned from the platform as RDF/XML, creating a fully populated
237
+ #Job instance
238
+ #
239
+ #uri:: uri of the job to be parsed
240
+ #xml:: the RDF/XML text to be parsed
241
+ def Job.parse(uri, xml)
242
+ doc = REXML::Document.new(xml)
243
+ root = doc.root
244
+
245
+ #job_el = REXML::XPath.first(root, "rdf:Description[rdf:type]", Pho::Namespaces::MAPPING )
246
+ job_el = REXML::XPath.first(root, "//*[@rdf:about='#{uri}']", Pho::Namespaces::MAPPING )
247
+ uri = job_el.attributes["rdf:about"]
248
+ label = REXML::XPath.first(job_el, "rdfs:label", Pho::Namespaces::MAPPING ).text
249
+ type_el = REXML::XPath.first(job_el, "rdf:type", Pho::Namespaces::MAPPING )
250
+ type = type_el.attributes["rdf:resource"]
251
+ created = REXML::XPath.first(job_el, "dcterms:created", Pho::Namespaces::MAPPING ).text
252
+ start_time = REXML::XPath.first(job_el, "bf:startTime", Pho::Namespaces::MAPPING ).text
253
+
254
+ job = Job.new(uri, label, type, start_time, created)
255
+ if type == Pho::Jobs::RESTORE
256
+ with_first(job_el, "bf:snapshotUri") do |uri|
257
+ job.snapshot_uri = uri.attributes["rdf:resource"]
258
+ end
259
+ end
260
+
261
+ with_first(job_el, "bf:actualStartTime") do |el|
262
+ job.actual_start_time = el.text
263
+ end
264
+ with_first(job_el, "bf:startMessage") do |el|
265
+ job.start_message = el.text
266
+ end
267
+ with_first(job_el, "bf:completionMessage") do |el|
268
+ job.completion_message = el.text
269
+ end
270
+ with_first(job_el, "bf:endTime") do |el|
271
+ job.end_time = el.text
272
+ end
273
+ with_first(job_el, "bf:completionStatus") do |el|
274
+ job.completion_status = el.attributes["rdf:resource"]
275
+ end
276
+ with_each(job_el, "bf:progressUpdate") do |el|
277
+ update = JobUpdate.new
278
+ with_first(el, "bf:progressUpdateMessage") do |msg|
279
+ update.message = msg.text
280
+ end
281
+ with_first(el, "bf:progressUpdateTime") do |time|
282
+ update.time = time.text
283
+ end
284
+ job.progress_updates << update
11
285
  end
12
- return nil
286
+
287
+ return job
288
+
289
+ end
290
+
291
+ def progress_updates()
292
+ @progress_updates.sort! { |x,y|
293
+ x.time <=> y.time
294
+ }
295
+ return @progress_updates
296
+ end
297
+
298
+ #Has the job started?
299
+ def started?
300
+ return @actual_start_time != nil
301
+ end
302
+
303
+ #Has the job completed?
304
+ def completed?
305
+ return @completion_status != nil
306
+ end
307
+
308
+ #Was the job successful?
309
+ def successful?
310
+ return self.completed? && @completion_status == Pho::Job::SUCCESS
13
311
  end
312
+
313
+ #Is the job still running?
314
+ def running?
315
+ return started? && !completed?
316
+ end
317
+
318
+ protected
319
+
320
+ def Job.with_first(el, xpath)
321
+ found_el = REXML::XPath.first(el, xpath, Pho::Namespaces::MAPPING)
322
+ if found_el != nil
323
+ yield found_el
324
+ end
325
+ end
14
326
 
327
+ def Job.with_each(el, xpath)
328
+ REXML::XPath.each(el, xpath, Pho::Namespaces::MAPPING) do |e|
329
+ root = e.document.root
330
+ uri = e.attributes["rdf:resource"]
331
+ ref_el = REXML::XPath.first(root, "//*[@rdf:about='#{uri}']", Pho::Namespaces::MAPPING)
332
+ yield ref_el
333
+ end
334
+ end
15
335
  end
16
336
 
17
337
  end