Project

General

Profile

« Previous | Next » 

Revision 7290

save point - adding more columns for access, data packaging, revision history
https://redmine.dataone.org/issues/2815

View differences:

src/doi_registration.sql
279 279
where guid like 'doi:10.6073%';
280 280
--49482
281 281

  
282
COPY (select ezid_account, guid as doi, url, title, creator, publisher, pub_date from doi_registration order by doi) 
282
/**
283
 * Additional modifications, July 5th, 2012
284
 */
285
ALTER TABLE doi_registration
286
ADD COLUMN resourceType text,
287
ADD COLUMN objectFormat text,
288
ADD COLUMN obsoletedBy text,
289
ADD COLUMN obsoletes text,
290
ADD COLUMN resourceMapId text,
291
ADD COLUMN resourceMapLocation text,
292
ADD COLUMN access text;
293

  
294
-- update access values
295
update doi_registration
296
set access = 'protected';
297

  
298
update doi_registration doi
299
set access = 'public'
300
from xml_access a
301
where doi.guid = a.guid
302
and a.principal_name = 'public'
303
and a.permission >= '4'
304
and a.perm_type = 'allow';
305

  
306
-- update the objectFormat from xml_documents
307
update doi_registration doi
308
set objectFormat = doc.doctype
309
from identifier id, xml_documents doc
310
where doi.guid = id.guid
311
and id.docid = doc.docid;
312

  
313
-- update the objectFormat from xml_revisions
314
update doi_registration doi
315
set objectFormat = rev.doctype
316
from identifier id, xml_revisions rev
317
where doi.guid = id.guid
318
and id.docid = rev.docid;
319

  
320
--update resourceType
321
update doi_registration
322
set resourceType = 'Dataset/METADATA';
323

  
324
update doi_registration
325
set resourceType = 'Dataset/DATA'
326
where objectFormat = 'BIN';
327

  
328
-- update the objectFormat from SM table (will be subset)
329
update doi_registration doi
330
set objectFormat = sm.object_format
331
from systemMetadata sm
332
where doi.guid = sm.guid;
333
--16938
334

  
335
--update revision history from SM
336
update doi_registration doi
337
set obsoletes = sm.obsoletes,
338
obsoletedBy = sm.obsoleted_by
339
from systemMetadata sm
340
where doi.guid = sm.guid;
341

  
342
--update resourceMap pointer TBD
343
-- NOTE: some of these maps might not actually exist
344
update doi_registration doi
345
set resourceMapId = 'resourceMap_'||id.docid||'.'||id.rev
346
from identifier id
347
where doi.guid = id.guid
348
and id.docid = rev.docid
349
and objectFormat like 'eml%';
350

  
351
--update the resourcemapid for described data
352
CREATE TABLE ecogrid_docids AS
353

  
354
select distinct id.docid, id.rev, id.guid, substring(xpi.nodedata from 'ecogrid://knb/(.*)$') as data_docid
355
from xml_path_index xpi, identifier id, xml_documents xmld
356
where xpi.docid = xmld.docid 
357
and xmld.docid = id.docid
358
and xmld.rev = id.rev
359
and xpi.path like 'dataset/%/physical/distribution/online/url' 
360
and xpi.nodedata like 'ecogrid%';
361

  
362
-- TODO: include revisions for described data
363

  
364
-- NOTE: some of thee maps might not actually exist
365
update doi_registration doi
366
set resourceMapId = 'resourceMap_'||eco.docid||'.'||eco.rev
367
from identifier id, ecogrid_docids eco
368
where doi.guid = id.guid
369
and id.docid||'.'||id.rev = eco.data_docid;
370

  
371
--update the resource map location
372
update doi_registration
373
set resourceMapLocation = 'https://cn.dataone.org/cn/v1/resolve/' || resourceMapId
374
where resourceMapId is not null;
375

  
376
--update creator usinig LDAP lookup
377

  
378
-- copy to the external file
379
COPY 
380
(select ezid_account, 
381
guid as dc_identifier, 
382
url as datacite_url, 
383
title as dc_title, 
384
creator as dc_creator, 
385
publisher as dc_publisher, 
386
pub_date as datacite_publicationYear,
387
resourceType,
388
objectFormat,
389
obsoletedBy,
390
obsoletes,
391
resourceMapId,
392
resourceMapLocation,
393
access
394
from doi_registration 
395
order by doi) 
283 396
TO '/tmp/doi_registration.csv'
284 397
WITH CSV HEADER;
285 398
--164548
286 399

  
287 400
--drop table doi_registration;
401
--drop table ecogrid_docids;
288 402

  

Also available in: Unified diff