Top Level Namespace

Defined Under Namespace

Modules: ActiveRubic, ActiveRubinstein, OWL, RDFS Classes: Array, Image

Constant Summary collapse

RUBIC_VERSION =
ActiveRubic::VERSION
RUBIC_DATASTORES =

the data sources that will be queried

[ :jena, :joseki, :mysql, :lucene, :geolucene ]
RUBIC_CONNECTION_ADAPTERS =

unused

[ :rubinstein ]
RUBIC_HOME =

unless defined? RUBIC_HOME

RAILS_ROOT + '/lib/active_rubic/lib/'
RUBINSTEIN_HOME =

expect the libraries to be installed under RAILS_ROOT/lib

RAILS_ROOT + '/lib/rubinstein'
RUBINSTEIN_CONFIG =
RUBINSTEIN_HOME + '/config'

Instance Method Summary collapse

Instance Method Details

#find_from_jena(s, p, o) ⇒ Object Also known as: find

constructs a common triplet-query



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_rubinstein/deprecated/base.rb', line 34

def find_from_jena( s, p, o )
  begin
#       STDERR.puts "find: #{s}, #{p}, #{o}"
    lang = @language || nil
    # using the lang tag slows the queries down really bad..
    # so we better use it only when necessary
    @@jena.find( s, p, o )
    # @@joseki.find( s, p, o, lang )
  rescue
    Array.new
  end
end

#find_from_joseki(s, p, o) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/active_rubinstein/deprecated/base.rb', line 197

def find_from_joseki( s, p, o )
  begin
#       STDERR.puts "find: #{s}, #{p}, #{o}"
    lang = @language || nil
    # using the lang tag slows the queries down really bad..
    # so we better use it only when necessary
    @@joseki.find( s, p, o )
    # @@joseki.find( s, p, o, lang )
  rescue
    Array.new
  end
end

#getAncestors(subject) ⇒ Object

Returns the ancestors of the subject parameters:

1 subject (RdfAbout, OwlClass, RDFS::Resource or URI string)


96
97
98
99
100
101
102
103
# File 'lib/active_rubinstein/deprecated/base.rb', line 96

def getAncestors( subject )
  begin
    x = @@jena.getAncestors( subject )
    # do not return the RDFS::Resource object
    x.delete( RDFS::Resource )
    return x
  end
end

#getChildren(subject) ⇒ Object

Returns the children of the subject parameters:

1 subject (RdfAbout, OwlClass, RDFS::Resource or URI string)


78
79
80
81
82
# File 'lib/active_rubinstein/deprecated/base.rb', line 78

def getChildren( subject )
  begin
    @@jena.getChildren( subject, false )
  end
end

#getClassesWithin(subject, radius = 0.2) ⇒ Object

returns the classes from the semantic circle, around a certain uri, within a certain radius

1 subject (RdfAbout, OwlClass, RDFS::Resource or URI string)
2 radius (Float)


153
154
155
156
157
# File 'lib/active_rubinstein/deprecated/base.rb', line 153

def getClassesWithin( subject, radius=0.2 )
  begin
    @@jena.getClassesWithin( subject, radius )
  end
end

#getDescendants(subject) ⇒ Object

Returns the descendants of the subject parameters:

1 subject (RdfAbout, OwlThing, RDFS::Resource or URI string)


68
69
70
71
72
73
# File 'lib/active_rubinstein/deprecated/base.rb', line 68

def getDescendants( subject )
  @@log.rubinstein( "getDescendants: #{subject}" )
  begin
    @@jena.getDescendants( subject )
  end
end

#getFullPath(subject) ⇒ Object

returns the full graph path in RDFS::Resource Array

1 subject (RdfAbout, OwlClass, RDFS::Resource or URI string)


161
162
163
164
165
166
167
168
169
170
# File 'lib/active_rubinstein/deprecated/base.rb', line 161

def getFullPath( subject )
  begin

    # this uses the Java function
    @@jena.getFullPath( subject )

    # this uses the Ruby function
#         @@jena.getFullPath_( subject )
  end
end

#getInstanceClass(subject) ⇒ Object

getInstanceClass # gets the immediate RDF::type of an instance Parameters:

1 subject (RdfAbout, OwlClass, RDFS::Resource or URI string)


124
125
126
127
128
129
130
131
# File 'lib/active_rubinstein/deprecated/base.rb', line 124

def getInstanceClass( subject )
  @@log.rubinstein " * getInstanceClass for #{subject}"
  begin
    results = @@jena.getInstanceClass( subject )
    do_log( results )
    return results
  end
end

#getInstances(subject, reasoner = true) ⇒ Object

getInstances # Returns the instances of a specific class Parameters:

1  subject (RdfAbout, OwlClass, RDFS::Resource or URI string)
2  reasoner (boolean)


110
111
112
113
114
115
116
117
# File 'lib/active_rubinstein/deprecated/base.rb', line 110

def getInstances( subject, reasoner=true )
  @@log.rubinstein " * getInstances of #{subject}, reasoner: #{reasoner}"
  begin
    x = @@jena.getInstances( subject, reasoner )
    @@log.deep "  => #{x.size} results: #{x}"
    return x
  end
end

#getInverse(property) ⇒ Object

getInverse # returns the inverse of the given property

eg.  getInverse: KUOPIO::isLocatedIn => KUOPIO::isLocationOf

Parameters:

1  Property ( Property, RDFS::Resource or URI string )


140
141
142
143
144
145
146
147
# File 'lib/active_rubinstein/deprecated/base.rb', line 140

def getInverse( property )
  @@log.rubinstein " * getInverse of #{property}"
  begin
    results = @@jena.getInverse( property )
    do_log( results ) # crashes
    return results
  end
end

#getNearbyTargets(lat, long, radius) ⇒ Object



173
174
175
176
177
# File 'lib/active_rubinstein/deprecated/base.rb', line 173

def getNearbyTargets( lat, long, radius )
  begin
    @@jena.getNearbyTargets( lat, long, radius )
  end
end

#getParents(subject) ⇒ Object

Returns the parents of the subject parameters:

1 subject (RdfAbout, OwlClass, RDFS::Resource or URI string)


87
88
89
90
91
# File 'lib/active_rubinstein/deprecated/base.rb', line 87

def getParents( subject )
  begin
    @@jena.getParents( subject, false )
  end
end

#getRoot(ontology = nil) ⇒ Object

Returns the roots of the ontology parameters:

1 subject (OwlThing, RDFS::Resource or URI string)


56
57
58
59
60
61
62
63
# File 'lib/active_rubinstein/deprecated/base.rb', line 56

def getRoot( ontology=nil )
  begin
    @@log.rubinstein "getRoot of #{ontology}"
    @@jena.getRoot( ontology )
  rescue
    @@log.error $!
  end
end

#jena_query(query, options = {}, &block) ⇒ Object Also known as: query_from_jena

jena_query # Pass an unadultered query to Rubinstein daemon

this may be called from several places, mostly from the models.

Parameters:

1  Query


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_rubinstein/deprecated/base.rb', line 12

def jena_query( query, options={}, &block )
  begin
    # @language might be set here
    unless options[ :lang ]
      options.update :lang => @language if @language
    end

    @@log.rubinstein "  => Querying Jena, options: #{options.values.join(' ')}"
    @@log.debug " * Sparql: #{query.to_sp}"
    @@log.debug "@@jena = #{@@jena.inspect}"
    results = @@jena.query( query, options )
    do_log( results )
    return results
  rescue
    @@log.error $!
    return Array.new
  end
end

#joseki_query(query, options = {}, &block) ⇒ Object Also known as: query_from_joseki



183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/active_rubinstein/deprecated/base.rb', line 183

def joseki_query( query, options={}, &block )
  begin
    @@log.rubinstein "  => Querying Joseki, options: #{options}"
    @@log.debug " * Sparql: #{query.to_sp}"
    results = @@joseki.query( query )
    do_log( results )
    return results
  rescue
    @@log.error $!
    return Array.new
  end
end

#load_adapter(s) ⇒ Object



325
326
327
328
329
330
331
# File 'lib/active_rubic.rb', line 325

def load_adapter s
  begin
    require s
  rescue Exception => e
    @@log.error "Could not load adapter #{s}: #{e}"
  end
end