source: TI01-discovery-Ingest/trunk/v4n_MEDIN/ingestAutomation-upgrade/OAIBatch/testISO.py @ 6685

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery-Ingest/trunk/v4n_MEDIN/ingestAutomation-upgrade/OAIBatch/testISO.py@6685
Revision 6685, 3.7 KB checked in by sdonegan, 11 years ago (diff)

roundup updates - ingestion working well

Line 
1from ExtractISO import ExtractISO
2import logging,os,pdb,datetime
3
4def accessIsoDataModel(struct,name):
5        cnt=0
6
7        #are we dealing with a list or dictionary?
8        if type(struct) is dict:
9                for j in struct.keys():
10                        print name + "(" + str(cnt) + "): " + j + " = " + str(struct[j])
11                        cnt = cnt + 1
12                       
13        if type(struct) is list:       
14                for i in struct:
15                        if type(i) is dict:
16                                for j in i.keys():             
17                                        print name + "(" + str(cnt) + "): " + j + " = " + str(i[j])
18                        if type(i) is list:
19                                for j in i:
20                                        print name + "(" + str(cnt) + "): " + j
21               
22                        if len(struct) > 1:
23                                print "-------------------------------"
24                       
25                        cnt = cnt + 1
26
27logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(filename)s:%(lineno)d %(levelname)s %(message)s')
28
29#test dif2stubIso xml file - converted from dif via xquery
30#dif2stubIso_file = 'data/NEODC/stub_iso/neodc.nerc.ac.uk__stubISO__dataent_11658383444211836_DIF_multiDate.xml'
31#dif2stubIso_file = 'data/NEODC/stub_iso/neodc.nerc.ac.uk__stubISO__dataent_11658383444211836_DIF_multiCoord.xml'
32#dif2stubIso_file = 'data/NEODC/stub_iso/neodc.nerc.ac.uk__stubISO__dataent_11658383444211836_DIF.xml'
33
34#inputISO = 'data/MEDIN/ISO_19139_Dataset_DASSH_v1.0.xml'
35inputISO = '../../ingestData/ceh/ceh-core-v-0-6.xml'
36
37#test dif 2 iso
38#isoData = ExtractISO(dif2stubIso_file,'difConvertedto_ISO19139')
39
40#test medin iso extractor
41isoData = ExtractISO(inputISO,'medin_2_3_ISO19139')
42
43
44
45if isoData.createISOdataStructure() is True:
46        logging.info("ISO extractor worked fine! (here are the variables...)")
47elif isoData.createISOdataStructure() is True:
48        logging.info ("Something wrong with ISO extractor... (ExtractISO returned False: xml access problem?)")
49        sys.exit()
50else:
51        logging.info( "Something SERIOUSELY wrong with extractor (couldnt get at ExtractISO class)")
52        sys.exit()
53       
54#sys.exit()
55
56print "\nTesting for bounding dates (list of dictionaries) ..."
57name = "boundingDates"
58accessIsoDataModel(isoData.boundingDates, name)
59
60print "\nTesting for extracting start and end dates (dictionary)"
61name = "boundingDatesRange"
62
63accessIsoDataModel(isoData.boundingDatesRange,name)
64
65print "\nTesting for datasetID (List)..."
66name = "datasetID"
67accessIsoDataModel(isoData.datasetID, name)
68
69print "\nTesting for keywords (List)..."
70name = "keywords"
71accessIsoDataModel(isoData.keywords, name)
72
73print "\nTesting for revision date (List)..."
74name = "revisionDate"
75accessIsoDataModel(isoData.revisionDate, name)
76
77print "\nTesting for creation date (List) ..."
78name = "createDate"
79accessIsoDataModel(isoData.createDate, name)
80
81print "\nTesting for publication date (List) ..."
82name = "publicationDate"
83accessIsoDataModel(isoData.publicationDate, name)
84       
85print "\nTesting for dataset name (List) ..."
86name = "datasetName"
87accessIsoDataModel(isoData.datasetName, name)
88
89print "\nTesting for dataset abstract (List) ..."
90name = "datasetAbstract"
91accessIsoDataModel(isoData.datasetAbstract, name)
92               
93print "\nTesting for original format (List) ..."
94name = "originalFormat"
95accessIsoDataModel(isoData.originalFormat, name)
96       
97print "\nTesting for authors (List) ..."
98name = "authors"
99
100accessIsoDataModel(isoData.authors, name)
101               
102print "\nTesting for data centre name (List) ..."
103name = "datacentreName"
104accessIsoDataModel(isoData.datacentreName, name)
105       
106print "\nTesting for parameters (List) ..."
107name = "parameters"
108accessIsoDataModel(isoData.parameters, name)
109       
110print "\nTesting for data centre name (list of dictionaries) ..."
111name = "boundingBoxCoordinates"
112accessIsoDataModel(isoData.boundingBoxCoordinates, name)
113
114print "\nConverting relevant URLS to NDG redirect URL!"
115if isoData.generateNDGredirectURL("http://scooby.dooby.doo/redirect=","./theRedirectedOutput.xml"):
116        print "Successfully generated redirect url xml!!"
117else:
118        print "Unsuccessfully tried to rewrite urls with ndg redirect url!"
Note: See TracBrowser for help on using the repository browser.