geohydra 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.travis.yml +1 -2
- data/Gemfile +1 -8
- data/Gemfile.lock +87 -102
- data/README.md +2 -2
- data/VERSION +1 -1
- data/bin/accession.rb +99 -89
- data/bin/assemble.rb +288 -247
- data/bin/assemble_data.rb +54 -51
- data/bin/assemble_placenames.rb +85 -85
- data/bin/build_stage_options.rb +24 -18
- data/bin/derive_wgs84.rb +65 -66
- data/bin/extract_thumbnail.rb +38 -37
- data/bin/geo2mods.rb +78 -0
- data/bin/geohydra +14 -5
- data/bin/ingest_arcgis.rb +80 -60
- data/bin/iso2geo.rb +64 -0
- data/bin/loader_postgis.rb +121 -227
- data/bin/run_task.rb +23 -0
- data/bin/sync_geoserver_metadata.rb +132 -127
- data/bin/xsltproc-saxon +6 -0
- data/geohydra.gemspec +6 -4
- data/lib/geohydra.rb +5 -0
- data/lib/geohydra/accession.rb +24 -13
- data/lib/geohydra/{arcgis_to_iso19139_fc.xsl → arcgis_to_iso19110.xsl} +0 -0
- data/lib/geohydra/gazetteer.csv +842 -36
- data/lib/geohydra/gazetteer.rb +48 -24
- data/lib/geohydra/mods2geoblacklight.xsl +248 -0
- data/lib/geohydra/mods2ogp.xsl +5 -8
- data/lib/geohydra/transform.rb +8 -2
- data/lib/geohydra/utils.rb +6 -0
- data/lib/geohydra/workflow/gisAssemblyWF.rb +109 -0
- data/lib/geohydra/workflow/gisAssemblyWF.xml +85 -0
- data/lib/geohydra/workflow/gisDeliveryWF.rb +33 -0
- data/lib/geohydra/workflow/gisDeliveryWF.xml +36 -0
- data/lib/geohydra/workflow/gisDiscoveryWF.rb +55 -0
- data/lib/geohydra/workflow/gisDiscoveryWF.xml +28 -0
- data/lib/geohydra/workflow/task.rb +82 -0
- data/ogp/README.md +350 -0
- data/ogp/download.rb +92 -0
- data/ogp/fgdc2mods.sh +9 -0
- data/ogp/fgdc2mods.xsl +884 -0
- data/ogp/ingest.rb +48 -0
- data/ogp/select.rb +20 -0
- data/ogp/transform.rb +354 -0
- data/ogp/validate.rb +182 -0
- data/{bin → scripts}/ingest_tufts.rb +0 -0
- data/scripts/iso2html/doit.sh +15 -0
- data/scripts/iso2html/main.css +66 -0
- data/scripts/iso2html/pacioos-iso-html.xsl +1749 -0
- data/scripts/iso2html/utils/replace-newlines.xsl +97 -0
- data/scripts/iso2html/utils/replace-string.xsl +80 -0
- data/scripts/iso2html/utils/strip-digits.xsl +60 -0
- data/{bin → scripts}/loader.rb +0 -0
- data/scripts/rename_shapefiles.rb +5 -0
- data/scripts/render_gazetteer.rb +36 -0
- data/{bin → scripts}/seed.rb +0 -0
- data/{bin → scripts}/solr_indexer.rb +0 -0
- data/scripts/status.csv +253 -0
- data/scripts/status.rb +32 -0
- data/{bin → scripts}/validate_data.rb +1 -1
- data/solr/kurma-app-dev/conf/lang/stopwords_en.txt +34 -0
- data/solr/kurma-app-dev/conf/protwords.txt +21 -0
- data/solr/kurma-app-dev/conf/schema.xml +156 -0
- data/solr/kurma-app-dev/conf/solrconfig.xml +161 -0
- data/solr/kurma-app-dev/conf/synonyms.txt +29 -0
- data/solr/kurma-app-dev/purge.sh +8 -0
- data/solr/kurma-app-test/conf/lang/stopwords_en.txt +34 -0
- data/solr/kurma-app-test/conf/protwords.txt +21 -0
- data/solr/kurma-app-test/conf/schema.xml +158 -0
- data/solr/kurma-app-test/conf/solrconfig.xml +161 -0
- data/solr/kurma-app-test/conf/synonyms.txt +29 -0
- data/solr/kurma-app-test/deploy.sh +15 -0
- data/solr/kurma-app-test/purge.sh +8 -0
- data/solr/ogp-dev/purge.sh +1 -2
- data/spec/fixtures/bw938nk9584/temp/{TRIPURA-iso19139-fc.xml → TRIPURA-iso19110.xml} +0 -0
- data/spec/fixtures/cc142xj8436/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
- data/spec/fixtures/cg716wc7949/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/cm007pv9601/temp/{MEGHALAYA-iso19139-fc.xml → MEGHALAYA-iso19110.xml} +0 -0
- data/spec/fixtures/cp055nb0189/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/cs838pw3418/temp/{OIL_GAS_FIELDS-iso19139-fc.xml → OIL_GAS_FIELDS-iso19110.xml} +0 -0
- data/spec/fixtures/dd308sy5843/temp/{ORISSA-iso19139-fc.xml → ORISSA-iso19110.xml} +0 -0
- data/spec/fixtures/dd452vk1873/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/dg850pt1796/temp/{STATE1951-iso19139-fc.xml → STATE1951-iso19110.xml} +0 -0
- data/spec/fixtures/dn744tf5427/temp/{DISTRICT1991-iso19139-fc.xml → DISTRICT1991-iso19110.xml} +0 -0
- data/spec/fixtures/dq603nz8402/temp/{STATE2001-iso19139-fc.xml → STATE2001-iso19110.xml} +0 -0
- data/spec/fixtures/dv609zt4699/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
- data/spec/fixtures/dz222hw0585/temp/{PUNJAB-iso19139-fc.xml → PUNJAB-iso19110.xml} +0 -0
- data/spec/fixtures/fd673qb9705/temp/{STATE1971-iso19139-fc.xml → STATE1971-iso19110.xml} +0 -0
- data/spec/fixtures/fg451wp8917/temp/{SIKKIM-iso19139-fc.xml → SIKKIM-iso19110.xml} +0 -0
- data/spec/fixtures/fh247yz0156/temp/{RAJASTHAN-iso19139-fc.xml → RAJASTHAN-iso19110.xml} +0 -0
- data/spec/fixtures/fs487vd1465/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
- data/spec/fixtures/fs591bn3317/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/fw920bc5473/temp/{PLSS_TWN-iso19139-fc.xml → PLSS_TWN-iso19110.xml} +0 -0
- data/spec/fixtures/gj831wj3625/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/gp075nv3265/temp/{PONDICHERRY-iso19139-fc.xml → PONDICHERRY-iso19110.xml} +0 -0
- data/spec/fixtures/gv800hj8141/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
- data/spec/fixtures/gw520gz6339/temp/{DADRA_NAGAR_HAVELI_PT-iso19139-fc.xml → DADRA_NAGAR_HAVELI_PT-iso19110.xml} +0 -0
- data/spec/fixtures/gy054hz1045/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
- data/spec/fixtures/gz352mw6982/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/hb489vm9892/temp/{DISTRICT1981-iso19139-fc.xml → DISTRICT1981-iso19110.xml} +0 -0
- data/spec/fixtures/hw125dq0418/temp/{DELHI-iso19139-fc.xml → DELHI-iso19110.xml} +0 -0
- data/spec/fixtures/hw892mn4587/temp/{KERALA-iso19139-fc.xml → KERALA-iso19110.xml} +0 -0
- data/spec/fixtures/jb371hz3868/temp/{INCOME-iso19139-fc.xml → INCOME-iso19110.xml} +0 -0
- data/spec/fixtures/jc017yk9928/temp/{KARNATAKA-iso19139-fc.xml → KARNATAKA-iso19110.xml} +0 -0
- data/spec/fixtures/jf841ys4828/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/jh802mp2160/temp/{DELHI_PT-iso19139-fc.xml → DELHI_PT-iso19110.xml} +0 -0
- data/spec/fixtures/jj806fc3801/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/jq835yn7161/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/jr455pt6676/temp/{TAMILNADU-iso19139-fc.xml → TAMILNADU-iso19110.xml} +0 -0
- data/spec/fixtures/js637zp2537/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
- data/spec/fixtures/jv502wg9611/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
- data/spec/fixtures/jw462ck6560/temp/{JAMMU_KASHMIR-iso19139-fc.xml → JAMMU_KASHMIR-iso19110.xml} +0 -0
- data/spec/fixtures/kj800fb6273/temp/{STATE2011-iso19139-fc.xml → STATE2011-iso19110.xml} +0 -0
- data/spec/fixtures/km504zq3948/temp/{HIMACHAL_PRADESH-iso19139-fc.xml → HIMACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/ks297fy1411/temp/{OFFSH_BLOCKS-iso19139-fc.xml → OFFSH_BLOCKS-iso19110.xml} +0 -0
- data/spec/fixtures/md358hy5049/temp/{MIZORAM-iso19139-fc.xml → MIZORAM-iso19110.xml} +0 -0
- data/spec/fixtures/mg745bq0193/temp/{MADHYA_PRADESH-iso19139-fc.xml → MADHYA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/mh187yx3536/temp/{WEST_BENGAL-iso19139-fc.xml → WEST_BENGAL-iso19110.xml} +0 -0
- data/spec/fixtures/mk488yn6694/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
- data/spec/fixtures/my216kp3008/temp/{DELHI-iso19139-fc.xml → DELHI-iso19110.xml} +0 -0
- data/spec/fixtures/my504nz9827/temp/{JAMMU_KASHMIR-iso19139-fc.xml → JAMMU_KASHMIR-iso19110.xml} +0 -0
- data/spec/fixtures/ng819jm8700/temp/{MANIPUR-iso19139-fc.xml → MANIPUR-iso19110.xml} +0 -0
- data/spec/fixtures/np020jq2139/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/ns377mt1608/temp/{STATE1991-iso19139-fc.xml → STATE1991-iso19110.xml} +0 -0
- data/spec/fixtures/nw926np8508/temp/{metadata.iso19139-fc.xml → metadata.iso19110.xml} +0 -0
- data/spec/fixtures/ny358rm8559/temp/{TRIPURA-iso19139-fc.xml → TRIPURA-iso19110.xml} +0 -0
- data/spec/fixtures/nz176rm8192/temp/{DISTRICT2011-iso19139-fc.xml → DISTRICT2011-iso19110.xml} +0 -0
- data/spec/fixtures/nz252rq2252/temp/{UTTAR_PRADESH-iso19139-fc.xml → UTTAR_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/pd902kb3348/temp/{MADHYA_PRADESH-iso19139-fc.xml → MADHYA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/pz792fz1776/temp/{MAHARASHTRA-iso19139-fc.xml → MAHARASHTRA-iso19110.xml} +0 -0
- data/spec/fixtures/qb767ss4042/temp/{UTTAR_PRADESH-iso19139-fc.xml → UTTAR_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/qc091qw0570/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
- data/spec/fixtures/qc652vr7204/temp/{ANDHRA_PRADESH_PT-iso19139-fc.xml → ANDHRA_PRADESH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/qk786js7484/temp/{DISTRICT1961-iso19139-fc.xml → DISTRICT1961-iso19110.xml} +0 -0
- data/spec/fixtures/qn676pg6767/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
- data/spec/fixtures/qr255jh4074/temp/{LOKSABHA_14-iso19139-fc.xml → LOKSABHA_14-iso19110.xml} +0 -0
- data/spec/fixtures/qr374kj4827/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
- data/spec/fixtures/qy162js1748/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
- data/spec/fixtures/rd446vf2633/temp/{NAGALAND-iso19139-fc.xml → NAGALAND-iso19110.xml} +0 -0
- data/spec/fixtures/rf389hf2983/temp/{CHHATTISGARH_PT-iso19139-fc.xml → CHHATTISGARH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/rf859ff4582/temp/{JHARKHAND-iso19139-fc.xml → JHARKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/rh343ds8931/temp/{BIHAR-iso19139-fc.xml → BIHAR-iso19110.xml} +0 -0
- data/spec/fixtures/rn815xk8157/temp/{SIKKIM-iso19139-fc.xml → SIKKIM-iso19110.xml} +0 -0
- data/spec/fixtures/rq653sz4470/temp/{CHHATTISGARH-iso19139-fc.xml → CHHATTISGARH-iso19110.xml} +0 -0
- data/spec/fixtures/rt625ws6022/temp/{GULF_FAIRWAYS-iso19139-fc.xml → GULF_FAIRWAYS-iso19110.xml} +0 -0
- data/spec/fixtures/sc330vf4259/temp/{JHARKHAND-iso19139-fc.xml → JHARKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/sq479mx3086/temp/{OFFSH_PLATF-iso19139-fc.xml → OFFSH_PLATF-iso19110.xml} +0 -0
- data/spec/fixtures/sr686bm4098/temp/{DAMAN_DIU_PT-iso19139-fc.xml → DAMAN_DIU_PT-iso19110.xml} +0 -0
- data/spec/fixtures/sv303sh5583/temp/{ARUNACHAL_PRADESH-iso19139-fc.xml → ARUNACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/sy319nh8520/temp/{GUJARAT-iso19139-fc.xml → GUJARAT-iso19110.xml} +0 -0
- data/spec/fixtures/td363vx2792/temp/{HIMACHAL_PRADESH_PT-iso19139-fc.xml → HIMACHAL_PRADESH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/tf374bd2484/temp/{DISTRICT1951-iso19139-fc.xml → DISTRICT1951-iso19110.xml} +0 -0
- data/spec/fixtures/tj797mj7877/temp/{LOKSABHA_15-iso19139-fc.xml → LOKSABHA_15-iso19110.xml} +0 -0
- data/spec/fixtures/tv060wq5179/temp/{ASSAM-iso19139-fc.xml → ASSAM-iso19110.xml} +0 -0
- data/spec/fixtures/tv536bn1915/temp/{ARUNACHAL_PRADESH-iso19139-fc.xml → ARUNACHAL_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/tz359cc2977/temp/{MANIPUR-iso19139-fc.xml → MANIPUR-iso19110.xml} +0 -0
- data/spec/fixtures/vb525my6511/temp/{UTTARAKHAND-iso19139-fc.xml → UTTARAKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/vh802fs4240/temp/{PONDICHERRY-iso19139-fc.xml → PONDICHERRY-iso19110.xml} +0 -0
- data/spec/fixtures/vk120xn2474/temp/{PLSS_SEC-iso19139-fc.xml → PLSS_SEC-iso19110.xml} +0 -0
- data/spec/fixtures/vn439bc7316/temp/{KERALA-iso19139-fc.xml → KERALA-iso19110.xml} +0 -0
- data/spec/fixtures/vq745jk0695/temp/{MEGHALAYA-iso19139-fc.xml → MEGHALAYA-iso19110.xml} +0 -0
- data/spec/fixtures/vr593vj7147/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/vw911qb5271/temp/{DISTRICT2001-iso19139-fc.xml → DISTRICT2001-iso19110.xml} +0 -0
- data/spec/fixtures/wg680pz0365/temp/{ANDHRA_PRADESH-iso19139-fc.xml → ANDHRA_PRADESH-iso19110.xml} +0 -0
- data/spec/fixtures/wg761xn1926/temp/{HARYANA-iso19139-fc.xml → HARYANA-iso19110.xml} +0 -0
- data/spec/fixtures/wh870qw1934/temp/{PUNJAB-iso19139-fc.xml → PUNJAB-iso19110.xml} +0 -0
- data/spec/fixtures/wk775mm4673/temp/{MAHARASHTRA-iso19139-fc.xml → MAHARASHTRA-iso19110.xml} +0 -0
- data/spec/fixtures/ws171yz2165/temp/{ARUNACHAL_PRADESH_PT-iso19139-fc.xml → ARUNACHAL_PRADESH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/wt473hz7153/temp/{CHANDIGARH_PT-iso19139-fc.xml → CHANDIGARH_PT-iso19110.xml} +0 -0
- data/spec/fixtures/ww217dj0457/temp/{CO2_PIPE-iso19139-fc.xml → CO2_PIPE-iso19110.xml} +0 -0
- data/spec/fixtures/wy875pk9849/temp/{STATE1961-iso19139-fc.xml → STATE1961-iso19110.xml} +0 -0
- data/spec/fixtures/xb018tk2042/temp/{STATE1981-iso19139-fc.xml → STATE1981-iso19110.xml} +0 -0
- data/spec/fixtures/xg539vw8586/temp/{ORISSA-iso19139-fc.xml → ORISSA-iso19110.xml} +0 -0
- data/spec/fixtures/xv475kp4644/temp/{ASSAM_PT-iso19139-fc.xml → ASSAM_PT-iso19110.xml} +0 -0
- data/spec/fixtures/xy096gc2959/temp/{GOA-iso19139-fc.xml → GOA-iso19110.xml} +0 -0
- data/spec/fixtures/xz518gz3362/temp/{UTTARAKHAND-iso19139-fc.xml → UTTARAKHAND-iso19110.xml} +0 -0
- data/spec/fixtures/yh986wy4737/temp/{NAGALAND-iso19139-fc.xml → NAGALAND-iso19110.xml} +0 -0
- data/spec/fixtures/yn187fq4474/temp/{KARNATAKA-iso19139-fc.xml → KARNATAKA-iso19110.xml} +0 -0
- data/spec/fixtures/yn236mw3250/temp/{TAMILNADU-iso19139-fc.xml → TAMILNADU-iso19110.xml} +0 -0
- data/spec/fixtures/yz596nz0112/temp/{WEST_BENGAL-iso19139-fc.xml → WEST_BENGAL-iso19110.xml} +0 -0
- data/spec/fixtures/zk596gy7380/temp/{DISTRICT1971-iso19139-fc.xml → DISTRICT1971-iso19110.xml} +0 -0
- data/spec/fixtures/zn452hh7431/temp/{RAJASTHAN-iso19139-fc.xml → RAJASTHAN-iso19110.xml} +0 -0
- data/spec/fixtures/zt093fw6519/temp/{MIZORAM-iso19139-fc.xml → MIZORAM-iso19110.xml} +0 -0
- data/spec/fixtures/zv925hd6723/temp/{OGWELLS-iso19139-fc.xml → OGWELLS-iso19110.xml} +0 -0
- data/spec/fixtures/zy658cr1728/temp/{ANDAMAAN_NICOBAR_PT-iso19139-fc.xml → ANDAMAAN_NICOBAR_PT-iso19110.xml} +0 -0
- data/spec/fixtures/zz943vx1492/temp/{BASINS-iso19139-fc.xml → BASINS-iso19110.xml} +0 -0
- data/spec/unit/gazetteer_spec.rb +100 -35
- data/spec/unit/task_spec.rb +68 -0
- data/spec/unit/transform_spec.rb +1 -1
- data/spec/unit/utils_spec.rb +17 -3
- data/workflow.rb +35 -0
- metadata +323 -316
data/bin/assemble.rb
CHANGED
@@ -5,303 +5,344 @@ require 'druid-tools'
|
|
5
5
|
require 'optparse'
|
6
6
|
require 'json'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
class Assemble < GeoHydra::Process
|
9
|
+
def setup_druid(obj, flags)
|
10
|
+
druid = DruidTools::Druid.new(obj.druid, flags[:workspacedir])
|
11
|
+
raise ArgumentError unless DruidTools::Druid.valid?(druid.druid)
|
12
|
+
%w{path content_dir metadata_dir temp_dir}.each do |k|
|
13
|
+
d = druid.send(k.to_sym)
|
14
|
+
unless File.directory? d
|
15
|
+
$stderr.puts "Creating directory #{d}" if flags[:verbose]
|
16
|
+
FileUtils.mkdir_p d
|
17
|
+
end
|
16
18
|
end
|
19
|
+
druid
|
17
20
|
end
|
18
|
-
druid
|
19
|
-
end
|
20
21
|
|
21
|
-
def find_mef(druid, uuid, flags)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
def find_mef(druid, uuid, flags)
|
23
|
+
# export MEF -- the .iso19139.xml file is preferred
|
24
|
+
puts "Exporting MEF for #{uuid}" if flags[:verbose]
|
25
|
+
client.export(uuid, flags[:tmpdir])
|
26
|
+
system(['unzip',
|
27
|
+
'-oq',
|
28
|
+
"'#{flags[:tmpdir]}/#{uuid}.mef'",
|
29
|
+
'-d',
|
30
|
+
"'#{flags[:tmpdir]}'"].join(' '))
|
31
|
+
found_metadata = false
|
32
|
+
%w{metadata.iso19139.xml metadata.xml}.each do |fn| # priority order as per MEF
|
33
|
+
unless found_metadata
|
34
|
+
fn = File.join(flags[:tmpdir], uuid, 'metadata', fn)
|
35
|
+
next unless File.exist? fn
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
found_metadata = true
|
38
|
+
# original ISO 19139
|
39
|
+
ifn = File.join(druid.temp_dir, 'iso19139.xml')
|
40
|
+
FileUtils.link fn, ifn, :verbose => flags[:verbose], :force => true
|
41
|
+
end
|
40
42
|
end
|
43
|
+
ifn
|
41
44
|
end
|
42
|
-
ifn
|
43
|
-
end
|
44
45
|
|
45
|
-
def find_local(druid, xml, fcXml, flags)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def find_local(druid, xml, fcXml, flags)
|
47
|
+
ifn = File.join(druid.temp_dir, 'iso19139.xml')
|
48
|
+
unless File.exist?(ifn)
|
49
|
+
File.open(ifn, "w") {|f| f << xml.to_s}
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
fcfn = File.join(druid.temp_dir, 'iso19110.xml')
|
53
|
+
unless File.exist?(fcfn)
|
54
|
+
File.open(fcfn, "w") {|f| f << fcXml.to_s}
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
end
|
57
|
+
[ifn, fcfn]
|
58
|
+
end
|
58
59
|
|
59
|
-
def convert_iso2geo(druid, ifn, isoXml, fcXml, flags)
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
def convert_iso2geo(druid, ifn, isoXml, fcXml, flags)
|
61
|
+
isoXml = Nokogiri::XML(isoXml)
|
62
|
+
if isoXml.nil? or isoXml.root.nil?
|
63
|
+
raise ArgumentError, "Empty ISO 19139"
|
64
|
+
end
|
65
|
+
fcXml = Nokogiri::XML(fcXml)
|
66
|
+
ap({:ifn => ifn, :isoXml => isoXml, :fcXml => fcXml, :flags => flags}) if flags[:debug]
|
67
|
+
# GeoMetadataDS
|
68
|
+
gfn = File.join(druid.metadata_dir, 'geoMetadata.xml')
|
69
|
+
puts "Generating #{gfn}" if flags[:verbose]
|
70
|
+
xml = GeoHydra::Transform.to_geoMetadataDS(isoXml, fcXml, { 'purl' => "#{flags[:purl]}/#{druid.id}"})
|
71
|
+
File.open(gfn, 'w') {|f| f << xml.to_xml(:indent => 2) }
|
72
|
+
gfn
|
63
73
|
end
|
64
|
-
fcXml = Nokogiri::XML(fcXml)
|
65
|
-
ap({:ifn => ifn, :isoXml => isoXml, :fcXml => fcXml, :flags => flags}) if flags[:debug]
|
66
|
-
# GeoMetadataDS
|
67
|
-
gfn = File.join(druid.metadata_dir, 'geoMetadata.xml')
|
68
|
-
puts "Generating #{gfn}" if flags[:verbose]
|
69
|
-
xml = GeoHydra::Transform.to_geoMetadataDS(isoXml, fcXml, { 'purl' => "#{flags[:purl]}/#{druid.id}"})
|
70
|
-
File.open(gfn, 'w') {|f| f << xml.to_xml(:indent => 2) }
|
71
|
-
gfn
|
72
|
-
end
|
73
74
|
|
74
|
-
def convert_geo2mods(druid, geoMetadata, flags)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
75
|
+
def convert_geo2mods(druid, geoMetadata, flags)
|
76
|
+
# MODS from GeoMetadataDS
|
77
|
+
ap({:geoMetadata => geoMetadata.ng_xml}) if flags[:debug]
|
78
|
+
dfn = File.join(druid.metadata_dir, 'descMetadata.xml')
|
79
|
+
puts "Generating #{dfn}" if flags[:verbose]
|
80
|
+
File.open(dfn, 'w') { |f| f << geoMetadata.to_mods.to_xml(:index => 2) }
|
81
|
+
dfn
|
82
|
+
end
|
82
83
|
|
83
|
-
def convert_geo2solrspatial(druid, geoMetadata, flags)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
def convert_geo2solrspatial(druid, geoMetadata, flags)
|
85
|
+
# Solr document from GeoMetadataDS
|
86
|
+
sfn = File.join(druid.temp_dir, 'spatialSolr.xml')
|
87
|
+
puts "Generating #{sfn}" if flags[:verbose]
|
88
|
+
h = geoMetadata.to_solr_spatial
|
89
|
+
ap({:to_solr_spatial => h}) if flags[:debug]
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
doc = Nokogiri::XML::Builder.new do |xml|
|
92
|
+
xml.add {
|
93
|
+
xml.doc_ {
|
94
|
+
h.each do |k, v|
|
95
|
+
v.each do |s|
|
96
|
+
xml.field s, :name => k
|
97
|
+
end unless v.nil?
|
98
|
+
end unless h.nil?
|
99
|
+
}
|
98
100
|
}
|
99
|
-
|
101
|
+
end
|
102
|
+
File.open(sfn, 'w') { |f| f << doc.to_xml(:indent => 2) }
|
103
|
+
sfn
|
100
104
|
end
|
101
|
-
File.open(sfn, 'w') { |f| f << doc.to_xml(:indent => 2) }
|
102
|
-
sfn
|
103
|
-
end
|
104
105
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
106
|
+
def convert_mods2geoblacklight(druid, dfn, flags)
|
107
|
+
raise ArgumentError, 'Missing required :geoserver flag' if flags[:geoserver].nil?
|
108
|
+
raise ArgumentError, 'Missing required :purl flag' if flags[:purl].nil?
|
108
109
|
|
109
|
-
|
110
|
-
|
110
|
+
geoserver = flags[:geoserver]
|
111
|
+
purl = "#{flags[:purl]}/#{druid.id}"
|
111
112
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
113
|
+
# OGP Solr document from descMetadataDS
|
114
|
+
sfn = File.join(druid.temp_dir, 'geoblacklightSolr.xml')
|
115
|
+
FileUtils.rm_f(sfn) if File.exist?(sfn)
|
116
|
+
cmd = ['xsltproc',
|
117
|
+
"--stringparam geoserver_root '#{geoserver}'",
|
118
|
+
"--stringparam purl '#{purl}'",
|
119
|
+
"--output '#{sfn}'",
|
120
|
+
"'#{File.expand_path(File.dirname(__FILE__) + '/../lib/geohydra/mods2geoblacklight.xsl')}'",
|
121
|
+
"'#{dfn}'"
|
122
|
+
].join(' ')
|
123
|
+
puts "Generating #{sfn} using #{cmd}" if flags[:verbose]
|
124
|
+
ap({:cmd => cmd}) if flags[:debug]
|
125
|
+
system(cmd)
|
125
126
|
|
126
|
-
|
127
|
-
end
|
127
|
+
sfn
|
128
|
+
end
|
129
|
+
|
130
|
+
def convert_mods2ogpsolr(druid, dfn, flags)
|
131
|
+
raise ArgumentError, 'Missing required :geoserver flag' if flags[:geoserver].nil?
|
132
|
+
raise ArgumentError, 'Missing required :purl flag' if flags[:purl].nil?
|
128
133
|
|
129
|
-
|
130
|
-
|
131
|
-
dcfn = File.join(druid.temp_dir, 'dc.xml')
|
132
|
-
puts "Generating #{dcfn}" if flags[:verbose]
|
133
|
-
File.open(dcfn, 'w') { |f| f << geoMetadata.to_dublin_core.to_xml(:indent => 2) }
|
134
|
-
dcfn
|
135
|
-
end
|
134
|
+
geoserver = flags[:geoserver]
|
135
|
+
purl = "#{flags[:purl]}/#{druid.id}"
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
137
|
+
# OGP Solr document from descMetadataDS
|
138
|
+
sfn = File.join(druid.temp_dir, 'ogpSolr.xml')
|
139
|
+
FileUtils.rm_f(sfn) if File.exist?(sfn)
|
140
|
+
cmd = ['xsltproc',
|
141
|
+
"--stringparam geoserver_root '#{geoserver}'",
|
142
|
+
"--stringparam purl '#{purl}'",
|
143
|
+
"--output '#{sfn}'",
|
144
|
+
"'#{File.expand_path(File.dirname(__FILE__) + '/../lib/geohydra/mods2ogp.xsl')}'",
|
145
|
+
"'#{dfn}'"
|
146
|
+
].join(' ')
|
147
|
+
puts "Generating #{sfn} using #{cmd}" if flags[:verbose]
|
148
|
+
ap({:cmd => cmd}) if flags[:debug]
|
149
|
+
system(cmd)
|
150
|
+
|
151
|
+
sfn
|
152
|
+
end
|
153
|
+
|
154
|
+
def convert_geo2dc(geoMetadata, flags)
|
155
|
+
# Solr document from GeoMetadataDS
|
156
|
+
dcfn = File.join(druid.temp_dir, 'dc.xml')
|
157
|
+
puts "Generating #{dcfn}" if flags[:verbose]
|
158
|
+
File.open(dcfn, 'w') { |f| f << geoMetadata.to_dublin_core.to_xml(:indent => 2) }
|
159
|
+
dcfn
|
160
|
+
end
|
161
|
+
|
162
|
+
def export_images(druid, uuid, flags)
|
163
|
+
# export any thumbnail images
|
164
|
+
%w{png jpg}.each do |fmt|
|
165
|
+
Dir.glob("#{flags[:tmpdir]}/#{uuid}/{private,public}/*.#{fmt}") do |fn|
|
166
|
+
ext = '.' + fmt
|
167
|
+
tfn = File.basename(fn, ext)
|
168
|
+
# convert _s to _small as per GeoNetwork convention
|
169
|
+
tfn = tfn.gsub(/_s$/, '_small')
|
170
|
+
imagefn = File.join(druid.content_dir, tfn + ext)
|
171
|
+
FileUtils.link fn, imagefn, :verbose => flags[:debug], :force => true
|
172
|
+
yield imagefn if block_given?
|
173
|
+
end
|
148
174
|
end
|
149
175
|
end
|
150
|
-
end
|
151
176
|
|
152
|
-
def export_local_images(druid, tempdir, flags)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
177
|
+
def export_local_images(druid, tempdir, flags)
|
178
|
+
# export any thumbnail images
|
179
|
+
n = 0
|
180
|
+
%w{png jpg}.each do |fmt|
|
181
|
+
Dir.glob("#{flags[:stagedir]}/#{druid.id}/content/*.#{fmt}") do |fn|
|
182
|
+
imagefn = File.join(druid.content_dir, 'preview' + '.' + fmt)
|
183
|
+
FileUtils.link fn, imagefn, :verbose => flags[:debug], :force => true
|
184
|
+
yield imagefn if block_given?
|
185
|
+
n = n + 1
|
186
|
+
end
|
161
187
|
end
|
188
|
+
puts "WARNING: Multiple images for #{druid.id}" if n > 1
|
162
189
|
end
|
163
|
-
puts "WARNING: Multiple images for #{druid.id}" if n > 1
|
164
|
-
end
|
165
190
|
|
166
|
-
def export_attachments(druid, flags)
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
191
|
+
def export_attachments(druid, flags)
|
192
|
+
Dir.glob("#{flags[:stagedir]}/#{druid.id}/content/*") do |fn|
|
193
|
+
unless %w{.png .jpg .zip}.include?(File.extname(fn))
|
194
|
+
afn = File.join(druid.content_dir, File.basename(fn))
|
195
|
+
FileUtils.link fn, afn, :verbose => flags[:debug], :force => true
|
196
|
+
yield afn if block_given?
|
197
|
+
end
|
172
198
|
end
|
173
199
|
end
|
174
|
-
end
|
175
200
|
|
176
|
-
def export_zip(druid, flags)
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
201
|
+
def export_zip(druid, flags)
|
202
|
+
# export content into zip files
|
203
|
+
Dir.glob(File.join(flags[:stagedir], "#{druid.id}/content/*.zip")) do |fn|
|
204
|
+
ofn = File.join(druid.content_dir, File.basename(fn))
|
205
|
+
FileUtils.link fn, ofn, :verbose => flags[:verbose], :force => true
|
206
|
+
yield ofn if block_given?
|
207
|
+
end
|
182
208
|
end
|
183
|
-
end
|
184
209
|
|
185
|
-
def doit(client, uuid, obj, flags)
|
186
|
-
|
187
|
-
|
210
|
+
def doit(client, uuid, obj, flags)
|
211
|
+
puts "Processing #{obj.druid}"
|
212
|
+
druid = setup_druid(obj, flags)
|
188
213
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
214
|
+
if flags[:geonetwork]
|
215
|
+
puts "Processing #{uuid} from geonetwork" if flags[:debug]
|
216
|
+
ifn = find_mef(druid, uuid, flags)
|
217
|
+
else
|
218
|
+
raise ArgumentError, druid if obj.content.empty?
|
219
|
+
ifn, fcfn = find_local(druid, obj.content.to_s, obj.fc.to_s, flags)
|
220
|
+
end
|
196
221
|
|
197
|
-
|
222
|
+
puts "Processing #{ifn}" if flags[:verbose]
|
198
223
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
224
|
+
optfn = File.expand_path("#{flags[:stagedir]}/#{obj.druid}/temp/geoOptions.json")
|
225
|
+
puts "Loading extra out-of-band options #{optfn}" if flags[:debug]
|
226
|
+
if File.exist?(optfn)
|
227
|
+
h = JSON.parse(File.read(optfn))
|
228
|
+
flags = flags.merge(h).symbolize_keys
|
229
|
+
ap({:optfn => optfn, :h => h, :flags => flags}) if flags[:debug]
|
230
|
+
else
|
231
|
+
puts "WARNING: #{obj.druid} is missing options .json parameters: #{optfn}"
|
232
|
+
flags[:geometryType] ||= 'Polygon' # XXX: placeholder
|
233
|
+
end
|
209
234
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
235
|
+
gfn = convert_iso2geo(druid, ifn, obj.content, obj.fc, flags)
|
236
|
+
geoMetadata = Dor::GeoMetadataDS.from_xml File.read(gfn)
|
237
|
+
geoMetadata.geometryType = flags[:geometryType] || 'Polygon'
|
238
|
+
geoMetadata.zipName = 'data.zip'
|
239
|
+
geoMetadata.purl = File.join(flags[:purl], druid.id)
|
215
240
|
|
216
|
-
|
217
|
-
|
241
|
+
dfn = convert_geo2mods(druid, geoMetadata, flags)
|
242
|
+
sfn = convert_mods2geoblacklight(druid, dfn, flags) if flags[:geoblacklight]
|
243
|
+
ofn = convert_mods2ogpsolr(druid, dfn, flags) if flags[:ogp]
|
218
244
|
|
219
|
-
|
245
|
+
if flags[:geonetwork]
|
246
|
+
export_images(druid, uuid, flags)
|
247
|
+
else
|
248
|
+
export_local_images(druid, File.expand_path(File.dirname(obj.zipfn) + '/../temp'), flags)
|
249
|
+
end
|
220
250
|
|
221
|
-
|
222
|
-
|
223
|
-
else
|
224
|
-
export_local_images(druid, File.expand_path(File.dirname(obj.zipfn) + '/../temp'), flags)
|
251
|
+
export_attachments(druid, flags)
|
252
|
+
export_zip(druid, flags)
|
225
253
|
end
|
226
|
-
|
227
|
-
export_attachments(druid, flags)
|
228
|
-
export_zip(druid, flags)
|
229
|
-
end
|
230
254
|
|
231
|
-
def main(flags)
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
255
|
+
def main(flags)
|
256
|
+
File.umask(002)
|
257
|
+
if flags[:geonetwork]
|
258
|
+
client = GeoHydra::GeoNetwork.new
|
259
|
+
client.each do |uuid|
|
260
|
+
begin
|
261
|
+
puts "Processing #{uuid}"
|
262
|
+
obj = client.fetch(uuid)
|
263
|
+
doit client, uuid, obj, flags
|
264
|
+
rescue Exception => e
|
265
|
+
$stderr.puts e
|
266
|
+
$stderr.puts e.backtrace if flags[:debug]
|
267
|
+
end
|
243
268
|
end
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
269
|
+
else
|
270
|
+
puts "Searching for staged content..." if flags[:verbose]
|
271
|
+
puts flags[:stagedir] + '/' + DruidTools::Druid.glob + '/content/data.zip' if flags[:debug]
|
272
|
+
Dir.glob(flags[:stagedir] + '/' + DruidTools::Druid.glob + '/content/data.zip') do |zipfn|
|
273
|
+
Dir.glob(File.join(File.dirname(zipfn), '..', 'temp', '*iso19139.xml')) do |xmlfn|
|
274
|
+
druid = File.basename(File.dirname(File.dirname(zipfn)))
|
275
|
+
begin
|
276
|
+
fcXml = File.read(xmlfn.gsub('19139.xml', '19110.xml'))
|
277
|
+
rescue Exception => e
|
278
|
+
begin
|
279
|
+
fcXml = File.read(xmlfn.gsub('19139.xml', '19139-fc.xml'))
|
280
|
+
rescue Exception => e
|
281
|
+
fcXml = ''
|
282
|
+
end
|
283
|
+
end
|
284
|
+
obj = Struct.new(:content, :status, :druid, :zipfn, :fc).new(File.read(xmlfn), nil, druid, zipfn, fcXml)
|
285
|
+
ap({:zipfn => zipfn, :obj => obj}) if flags[:debug]
|
286
|
+
doit client, nil, obj, flags
|
287
|
+
end
|
254
288
|
end
|
255
289
|
end
|
256
290
|
end
|
257
|
-
end
|
258
291
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
292
|
+
def run(args)
|
293
|
+
flags = {
|
294
|
+
:debug => false,
|
295
|
+
:verbose => false,
|
296
|
+
:geonetwork => false,
|
297
|
+
:geoserver => GeoHydra::Config.ogp.geoserver,
|
298
|
+
:solr => GeoHydra::Config.ogp.solr,
|
299
|
+
:geoblacklight => true,
|
300
|
+
:ogp => true,
|
301
|
+
:purl => GeoHydra::Config.ogp.purl,
|
302
|
+
:stagedir => GeoHydra::Config.geohydra.stage || 'stage',
|
303
|
+
:xinclude => false,
|
304
|
+
:workspacedir => GeoHydra::Config.geohydra.workspace || 'workspace',
|
305
|
+
:tmpdir => GeoHydra::Config.geohydra.tmpdir || 'tmp'
|
306
|
+
}
|
273
307
|
|
274
|
-
|
275
|
-
|
276
|
-
Usage: #{File.basename(__FILE__)} [options]
|
308
|
+
OptionParser.new do |opts|
|
309
|
+
opts.banner = <<EOM
|
310
|
+
Usage: #{File.basename(__FILE__)} [options]
|
277
311
|
EOM
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
312
|
+
opts.on('--geonetwork', 'Run against GeoNetwork server (deprecated)') do |v|
|
313
|
+
flags[:geonetwork] = true
|
314
|
+
end
|
315
|
+
opts.on('-v', '--verbose', 'Run verbosely') do |v|
|
316
|
+
flags[:debug] = true if flags[:verbose]
|
317
|
+
flags[:verbose] = true
|
318
|
+
end
|
319
|
+
opts.on('--stagedir DIR', "Staging directory with ZIP files (default: #{flags[:stagedir]})") do |v|
|
320
|
+
flags[:stagedir] = v
|
321
|
+
end
|
322
|
+
opts.on('--workspace DIR', "Workspace directory for assembly (default: #{flags[:workspacedir]})") do |v|
|
323
|
+
flags[:workspacedir] = v
|
324
|
+
end
|
325
|
+
opts.on('--tmpdir DIR', "Temporary directory for assembly (default: #{flags[:tmpdir]})") do |v|
|
326
|
+
flags[:tmpdir] = v
|
327
|
+
end
|
328
|
+
opts.on('--[no-]geoblacklight', 'Generate geoblacklightSolr.xml') do |v|
|
329
|
+
flags[:geoblacklight] = v
|
330
|
+
end
|
331
|
+
opts.on('--[no-]ogp', 'Generate ogpSolr.xml') do |v|
|
332
|
+
flags[:ogp] = v
|
333
|
+
end
|
334
|
+
end.parse!(args)
|
335
|
+
|
336
|
+
%w{tmpdir stagedir workspacedir}.each do |k|
|
337
|
+
d = flags[k.to_sym]
|
338
|
+
raise ArgumentError, "Missing directory #{d}" unless d.nil? or File.directory? d
|
293
339
|
end
|
294
|
-
end.parse!
|
295
340
|
|
296
|
-
|
297
|
-
|
298
|
-
|
341
|
+
ap({:flags => flags}) if flags[:debug]
|
342
|
+
raise NotImplementError, 'geonetwork code is stale' if flags[:geonetwork]
|
343
|
+
main flags
|
299
344
|
end
|
300
|
-
|
301
|
-
ap({:flags => flags}) if flags[:debug]
|
302
|
-
raise NotImplementError, 'geonetwork code is stale' if flags[:geonetwork]
|
303
|
-
main flags
|
304
|
-
rescue SystemCallError => e
|
305
|
-
$stderr.puts "ERROR: #{e.message}"
|
306
|
-
exit(-1)
|
307
345
|
end
|
346
|
+
|
347
|
+
# __MAIN__
|
348
|
+
Assemble.new().run(ARGV)
|