Module: Mrdf_Resource

Includes:
Mmtk_helper
Included in:
Crdf_Resource
Defined in:
lib/ontomde-core/resource.rb,
lib/ontomde-core/meta.rb,
lib/ontomde-core/clone.rb,
lib/ontomde-core/helper.rb,
lib/ontomde-core/context.rb,
lib/ontomde-core/resource.rb

Overview

SC2=“::”

Constant Summary

Constants included from Mmtk_helper

Mmtk_helper::MTK_WRITE_SESSION_FILE_NAMES, Mmtk_helper::NOREVERSE, Mmtk_helper::REVERSE, Mmtk_helper::TEMP_FILE_SUFFIX, Mmtk_helper::WITHOUT_MARKER

Instance Attribute Summary

Attributes included from Mmtk_helper

#fileGenerated

Instance Method Summary collapse

Methods included from Mmtk_helper

#encloseWrite, #mtk_annotation, #mtk_autoNewFileCreationCheck, #mtk_out, #mtk_protected, #mtk_qualifyBlockURI, #mtk_retrieveProtected, #mtk_shouldAlreadyBeenReversed, #mtk_sprotected, #mtk_stringWriteSession, #mtk_stss, #mtk_wprotected, #mtk_writeSession, #mtk_writeSessionNameClashErrorDetection, #notifyFileGenerated, #write

Instance Method Details

#contextObject

Please refer to #WarningHash [] method for information on how to access context content.

Please refer to #mtk_context method for information on how to populate context.



121
122
123
# File 'lib/ontomde-core/context.rb', line 121

def context
  return @rdf_Repository.context
end

#dotIdObject

returns this object uri converted to a dot/graphviz compatible identifier.



285
286
287
# File 'lib/ontomde-core/resource.rb', line 285

def dotId
  return  rdf_uri.tr('^a-zA-Z0-9','_')
end

#dumpObject

Debug method Dumps to screen the current object.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ontomde-core/resource.rb', line 12

def dump
  log.debug("\n#{self} dump #{self.class}>\n")
  instance_variables.each {
    |c|
    log.debug("-#{c}- #{instance_variable_get(c).to_s}\n" )
  }
  log.debug('methods: ( ')
  #out.write('methods: ( ')
  public_methods.each { |m|
    log.debug( "#{m}, " )
  }
  log.debug('<\n')
end

#log_error_nil_one(meth) ⇒ Object

generates an error message used when “meth” returns unexpectedly no data.

Raises:



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/ontomde-core/meta.rb', line 381

def log_error_nil_one(meth)
  return if log_already_displayed?("#{rdf_uri}__#{meth}")
  log.error {

    <<END
#{meth}_one nil for #{self}::#{self.class.name} (uri=#{rdf_uri})
********* INVALID DATA DETECTED **********
** This software expects the model element specified bellow
**#{mtk_object_message}
** to have exactly one "#{meth}".
**
** This is most likely caused by a missing data in source model.
** Please check that previous element has a #{meth} defined.
**
** This model element is related to these other model elements:
#{mtk_related_message}
********* INVALID DATA DETECTED **********
END
  }
  raise Warning.new,"#{meth}_one nil null" if context[:failOnEmptyCallto_one,true]
end

#mtk_context(*args, &block) ⇒ Object

cf: Mrdf_Repository::mtk_context



126
127
128
# File 'lib/ontomde-core/context.rb', line 126

def mtk_context(*args,&block)
  return @rdf_Repository.mtk_context(*args,&block)
end

#mtk_default_context(*args, &block) ⇒ Object

cf: Mrdf_Repository::mtk_default_context



131
132
133
# File 'lib/ontomde-core/context.rb', line 131

def mtk_default_context(*args,&block)
  return @rdf_Repository.mtk_default_context(*args,&block)
end

#mtk_object_messageObject

return a string describing this object (used for error log messages)



361
362
363
364
365
366
367
# File 'lib/ontomde-core/meta.rb', line 361

def mtk_object_message
  return <<END
**      uri =#{rdf_uri}
**      type=#{self.class.name}
**      to_s=#{self.to_s}
END
end

return a string describing object related to this object (used for error log messages)



370
371
372
373
374
375
376
# File 'lib/ontomde-core/meta.rb', line 370

def mtk_related_message
  related=''
  ext_isReferencedBy.each { |g|
    related=related+"**  (#{g.class.name}) #{g}\n"
  }
  return related
end

#rdfx_cloneObject

Clones a uml resource. Referenced objects are cloned if rdfx_copyOnClone says so.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ontomde-core/clone.rb', line 14

def rdfx_clone
  c=self.clone
  c.rdf_uri="_transient_#{c.object_id}"
  c.rdf_Repository[c.rdf_uri]=c

  instance_variables.each { |v|
    ivg=instance_variable_get(v)
    next if (!ivg.kind_of?(ArrayOrSingleElement)) ||
      (!isResetable?(v)) ||
      (!rdfx_copyOnClone?(v))

    newVal=createEmptyAttributeValue
    #puts "clone v=#{v}"
    self.instance_variable_get(v).each { | res|
      newVal.push(res.rdfx_clone)
      c.instance_variable_set(v,newVal)
    }
  }
  return c
end

#rdfx_copyOnClone?(prop) ⇒ Boolean

Returns true if object should be copied on clone for this property. NOTE:

returns true if property name contains "_owned". (works for UML)

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
# File 'lib/ontomde-core/clone.rb', line 38

def rdfx_copyOnClone?(prop)
  return prop.include?('_owned')
  #copyOrClone=copyOnCloneProperties[prop]
  #if copyOrClone.nil?
  #puts "WARNING: unspecified copy on clone for #{prop} on #{self.class.name}"
  #end
  #return copyOrClone
end