Module: Muml_DataType
- Defined in:
- lib/ontomde-java/java/xsd.rb,
lib/ontomde-java/flex/main.rb,
lib/ontomde-java/java/java.rb,
lib/ontomde-java/struts/jsp_edit.rb,
lib/ontomde-java/crank/validation.rb,
lib/ontomde-java/struts/validation.rb
Constant Summary collapse
- STRUTS_ERROR_STYLE =
error style used for form fields
%{errorStyle="background-color: yellow"}
Instance Method Summary collapse
- #crank_validation_annotation ⇒ Object
- #java_isInteger? ⇒ Boolean
-
#java_qualifiedName ⇒ Object
returns datatype qualified name.
- #struts_edit_writeField(field, owner) ⇒ Object
- #struts_validation_writeField(field) ⇒ Object
-
#xsd_qualifiedName ⇒ Object
returns datatype qualified name.
Instance Method Details
#crank_validation_annotation ⇒ Object
23 24 25 26 |
# File 'lib/ontomde-java/crank/validation.rb', line 23 def crank_validation_annotation tpl=DatatypeMapping.instance.getTemplate(self) tpl.crank_validation_annotation end |
#java_isInteger? ⇒ Boolean
65 66 67 68 |
# File 'lib/ontomde-java/struts/validation.rb', line 65 def java_isInteger? a=self return a.kind_of?(Muml_DataType) && (a.java_qualifiedName.downcase=="java.lang.Integer" || a.java_qualifiedName=="int") end |
#java_qualifiedName ⇒ Object
returns datatype qualified name.
NOTE:
-
A predefined mapping is defined UML_TO_JAVA_PRIMTIVE_TYPE_MAPPING
-
MagicDraw handles primtive types as DataType
-
RSM handles primtive types as PrimitiveType
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 |
# File 'lib/ontomde-java/java/java.rb', line 1342 def java_qualifiedName return super if kind_of?(Muml_Enumeration) return DatatypeMapping.instance.getMapping(self).java_getType ot=uml_name_one mt=::Muml_PrimitiveType::UML_TO_JAVA_PRIMITIVE_TYPE_MAPPING[ot] return mt unless mt.nil? || mt.to_s=="" #avoid multiple messages ::Muml_PrimitiveType::UML_TO_JAVA_PRIMITIVE_TYPE_MAPPING[ot]="String" log.error %{ WARN: A default java mapping has been created for DataType #{ot} HELP: HELP: To declare a new mapping, create a new entry as shown bellow: HELP: module Muml_DataType HELP: UML_TO_JAVA_PRIMITIVE_TYPE_MAPPING["#{ot}"]="your target java type" HELP: end } #(not useful here) unless log_already_displayed?("#{rdf_uri}__datatype") return java_qualifiedName # retry end |
#struts_edit_writeField(field, owner) ⇒ Object
487 488 489 490 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 487 def struts_edit_writeField(field,owner) tpl=DatatypeMapping.instance.getMapping(self) write tpl.getJSP(self,field,owner) end |
#struts_validation_writeField(field) ⇒ Object
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 |
# File 'lib/ontomde-java/struts/validation.rb', line 69 def struts_validation_writeField(field) #return if self.kind_of?(Muml_Enumeration) re=DatatypeMapping.instance.getMapping(field.uml_type_one).getValidationRegexp return if re.nil? #re=STRUTS_PRIMITIVE_TYPE_REGEXP[self.uml_name_one] #n=java_qualifiedName.downcase #n=n.gsub("_","") if "_".include?(n[0,1]) #if self.kind_of?(Muml_Enumeration) # # validation is not necessary #elsif !re.nil? write %{ <field property="#{field.java_Name}" depends="mask"> <arg key="defaultForm.string.displayname" /> <var><var-name>mask</var-name><var-value>#{re.source}</var-value></var> </field> } #elsif java_isInteger? # n="integer" # log.error("struts validator #{n} is not registered.") unless rdf_Repository.struts_validatorExists?(n) # write %{ # <field property="#{field.java_Name}" depends="required,#{n}"> # <arg key="defaultForm.#{n}.displayname" /> # </field> #} #else # log.warn{ "no validation for field: #{field}" } #end #if n=="long" #write %{ # <field property="#{field.java_Name}" depends="required,#{n}"> # <arg key="defaultForm.#{n}.displayname" /> # </field> #} # end end |
#xsd_qualifiedName ⇒ Object
returns datatype qualified name.
NOTE:
-
A predefined mapping is defined UML_TO_JAVA_PRIMTIVE_TYPE_MAPPING
-
MagicDraw handles primtive types as DataType
-
RSM handles primtive types as PrimitiveType
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 |
# File 'lib/ontomde-java/java/xsd.rb', line 1316 def xsd_qualifiedName return super if kind_of?(Muml_Enumeration) return DatatypeMapping.instance.getMapping(self).xsd_getType ot=uml_name_one mt=::Muml_PrimitiveType::UML_TO_JAVA_PRIMITIVE_TYPE_MAPPING[ot] return mt unless mt.nil? || mt.to_s=="" #avoid multiple messages ::Muml_PrimitiveType::UML_TO_JAVA_PRIMITIVE_TYPE_MAPPING[ot]="String" log.error %{ WARN: A default java mapping has been created for DataType #{ot} HELP: HELP: To declare a new mapping, create a new entry as shown bellow: HELP: module Muml_DataType HELP: UML_TO_JAVA_PRIMITIVE_TYPE_MAPPING["#{ot}"]="your target java type" HELP: end } #(not useful here) unless log_already_displayed?("#{rdf_uri}__datatype") return xsd_qualifiedName # retry end |