Class: ProvenanceWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/metadata.rb,
lib/triplify_metadata.rb

Instance Method Summary collapse

Constructor Details

#initializeProvenanceWriter

Returns a new instance of ProvenanceWriter.



12
13
14
# File 'lib/metadata.rb', line 12

def initialize

end

Instance Method Details

#describe_creation(subject, tripleizer) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/metadata.rb', line 62

def describe_creation(subject, tripleizer)
  tripleizer.write_triple( subject, tripleizer.uri('rdf:type'), tripleizer.uri('prv:DataCreation') )
  #TODO: @now in iso time format date("c",...
  tripleizer.write_triple( subject, tripleizer.uri('prv:performedAt'),@now , "true", tripleizer.uri('xsd:dateTime') )

creator = @triplify_instance
source_data = get_new_bnode_id

mapping =  configatron.mapping ? tripleizer.uri(configatron.mapping) : get_new_bnode_id

  tripleizer.write_triple( subject, tripleizer.uri('prv:performedBy'), creator );
  tripleizer.write_triple( subject, tripleizer.uri('prv:usedData'), source_data );
  tripleizer.write_triple( subject, tripleizer.uri('prv:usedGuideline'), mapping );

describe_source_data( source_data, tripleizer );
describe_mapping( mapping, tripleizer );
end

#describe_mapping(subject, tripleizer) ⇒ Object



110
111
112
# File 'lib/metadata.rb', line 110

def describe_mapping ( subject, tripleizer )
tripleizer.write_triple( subject,  tripleizer.uri('rdf:type'),  tripleizer.uri('prvTypes:TriplifyMapping') )
end

#describe_provenance(subject, tripleizer) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/metadata.rb', line 16

def describe_provenance( subject, tripleizer,output)
  @now = Time.new
  @triplify_instance = get_new_bnode_id
  tripleizer.write_triple(subject, tripleizer.uri("rdf:type" ), tripleizer.uri("prv:DataItem" ))

  if configatron.data_set
    tripleizer.write_triple( subject, tripleizer.uri("prv:containedBy"),tripleizer.uri(configatron.data_set ))
	tripleizer.write_triple( tripleizer.uri(configatron.data_set), tripleizer.uri('rdf:type'), tripleizer.uri('void:Dataset') )
  end

  creation = get_new_bnode_id
  tripleizer.write_triple( subject, tripleizer.uri("prv:createdBy"), creation )
describe_creation( creation, tripleizer )
describe_triplify_instance( @triplify_instance, tripleizer );
end

#describe_source_data(subject, tripleizer) ⇒ Object



80
81
82
83
84
85
86
87
88
# File 'lib/metadata.rb', line 80

def describe_source_data ( subject, tripleizer )
doc = get_new_bnode_id
tripleizer.write_triple( subject,  tripleizer.uri('prv:containedBy'), doc )
tripleizer.write_triple( doc,  tripleizer.uri('rdf:type'),  tripleizer.uri('prv:Representation') )

access = get_new_bnode_id
tripleizer.write_triple( doc,  tripleizer.uri('prv:retrievedBy'), access )
describe_source_data_access access, tripleizer
end

#describe_source_data_access(subject, tripleizer) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/metadata.rb', line 90

def describe_source_data_access ( subject, tripleizer )
tripleizer.write_triple( subject,
    tripleizer.uri('rdf:type'),
    tripleizer.uri('prv:DataAccess') )
tripleizer.write_triple( subject,
    tripleizer.uri('prv:performedAt'),
    @now,
    "true",
    tripleizer.uri('xsd:dateTime') )

if configatron.database_server
	tripleizer.write_triple( subject,
      tripleizer.uri('prv:accessedServer'),
      tripleizer.uri(configatron.database_server) )
  end
accessor = @triplify_instance
tripleizer.write_triple( subject,  tripleizer.uri('prv:performedBy'), accessor )
end

#describe_triplify_instance(subject, tripleizer) ⇒ Object



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
# File 'lib/metadata.rb', line 32

def describe_triplify_instance(subject, tripleizer)
  tripleizer.write_triple(subject,tripleizer.uri("rdf:type"),tripleizer.uri("prvTypes:DataCreatingService"))
  tripleizer.write_triple(subject,tripleizer.uri("rdfs:comment"), "Triplify #{tripleizer.version} (http://Triplify.org)", "isliteral")

  operator=""
  if configatron.operator_uri
    operator = tripleizer.uri(configatron.operator_name)
  else
    if configatron.operator_type || configatron.operator_homepage
      operator= get_new_bnode_id
    end
  end

  unless operator.blank?
    tripleizer.write_triple( subject, tripleizer.uri('prv:operatedBy'), operator )
	if configatron.operator_type
		if (  tripleizer.uri(configatron.operator_type) != tripleizer.uri('prv:HumanActor') )
        tripleizer.write_triple(operator, tripleizer.uri('rdf:type'),tripleizer.uri(configatron.operator_type) )
      end
    end
	tripleizer.write_triple(operator, tripleizer.uri('rdf:type'),tripleizer.uri('prv:HumanActor') )
	if configatron.operator_name
      tripleizer.write_triple( operator, tripleizer.uri('foaf:name'), configatron.operator_name, "true" )
    end
	if  configatron.operator_homepage
      tripleizer.write_triple( operator, tripleizer.uri('foaf:homepage'), configatron.operator_homepage )
    end
  end
end

#get_new_bnode_idObject



114
115
116
117
118
# File 'lib/metadata.rb', line 114

def get_new_bnode_id ()
  @bnode_counter ||=0
@bnode_counter+=1
"_:x#{@bnode_counter}"
end