Class: DatatypeMapping
- Includes:
- Singleton
- Defined in:
- lib/ontomde-uml2/UMLdatatypeMapping.rb,
lib/ontomde-uml2/kb/datatypeMapping.rb
Direct Known Subclasses
DatatypeMappingBLOB, DatatypeMappingBoolean, DatatypeMappingCalendar, DatatypeMappingFile, DatatypeMappingGenericClass, DatatypeMappingGenericEnum, DatatypeMappingText, DatatypeMappingTimeStamp
Constant Summary collapse
- @@types =
Array.new
Instance Attribute Summary collapse
-
#maxStringLength ⇒ Object
max length of this element represented as a string.
Instance Method Summary collapse
-
#appliesTo?(datatype) ⇒ Boolean
returns true if this templates applies to datatype.
-
#getHelp ⇒ Object
return a help message on this datatype mapping definition.
- #getMapping(datatype) ⇒ Object
- #getMappings ⇒ Object
- #getValidationRegexp ⇒ Object
-
#initialize ⇒ DatatypeMapping
constructor
A new instance of DatatypeMapping.
- #prot_getProtegeType ⇒ Object
- #register ⇒ Object
Constructor Details
#initialize ⇒ DatatypeMapping
Returns a new instance of DatatypeMapping.
113 114 115 116 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 113 def initialize super @maxStringLength=nil end |
Instance Attribute Details
#maxStringLength ⇒ Object
max length of this element represented as a string
111 112 113 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 111 def maxStringLength @maxStringLength end |
Instance Method Details
#appliesTo?(datatype) ⇒ Boolean
returns true if this templates applies to datatype
46 47 48 49 50 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 46 def appliesTo?(datatype) # inheriting class should redefine this method log.error %{appliesTo? not implemented for #{self.class}} return false end |
#getHelp ⇒ Object
return a help message on this datatype mapping definition.
124 125 126 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 124 def getHelp return "No help available for datatype mapping #{self.class}" end |
#getMapping(datatype) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 51 def getMapping(datatype) @@types.each {|t| next unless t.appliesTo?(datatype) return t } if !datatype.context[:silentlyForceUnknownDatatypeToString,false] msg= <<END ERROR: OntoMDE generator encountered in your UML model ERROR: an unknown datatype named "#{datatype}". HELP: HELP: OntoMDE should be provided a datatype mapping HELP: definition in order to map your custom datatype HELP: to target code (java conversion, jsp code, HELP: ..., validation code, ...) HELP: This mapping definition should be placed in a HELP: file that is loaded by your ontomde generation script. HELP: (ontomde-java script uses --load option HELP: to load configuration files) HELP: HELP: Sample1: HELP: restriction of DatatypeMappingText for string mapping HELP: a particular regexp: HELP: addDataTypeMapping("#{datatype}", HELP: DatatypeMappingText, HELP: /[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]/ ) HELP: HELP: Sample2: HELP: restriction of DatatypeMappingText for string mapping a particular regexp. HELP: addDataTypeMapping("#{datatype}", HELP: DatatypeMappingText, HELP: /[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]/ ) { HELP: # a datatype mapping definition is a set HELP: # of method called by generator. HELP: # Any method may be redefined : HELP: def java_getType HELP: return "java.lang.String" HELP: end HELP: #def getFormCopyTo(field) HELP: # (...) HELP: #end HELP: #def getFormInitFrom(field) HELP: # (...) HELP: #end HELP: } HELP: HELP: Available datatypes mapping in current running instance are: #{@@types.collect {|t| "HELP: "+"#{t.class} : #{t.getHelp} \n"}}. End of help on adding custom datatype mapping definition. END log.error msg unless log_already_displayed?(msg) end return DatatypeMappingText.instance #return DatatypeMappingerror.instance end |
#getMappings ⇒ Object
36 37 38 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 36 def getMappings return @@types end |
#getValidationRegexp ⇒ Object
118 119 120 121 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 118 def getValidationRegexp #log.error %{getValidationRegexp not implemented for #{self.class}} return nil #%{/* TODO: implement ruby getValidationRegexp for #{self.class}*/} end |
#prot_getProtegeType ⇒ Object
2 3 4 |
# File 'lib/ontomde-uml2/kb/datatypeMapping.rb', line 2 def prot_getProtegeType return nil # no protege mapping defined end |
#register ⇒ Object
40 41 42 43 44 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 40 def register return if self.class==DatatypeMapping @@types << self #log.debug { %{registered(##{@@types.size}): #{self.class}} } end |