Class: DatatypeMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/ontomde-java/jpa/mapping.rb,
lib/ontomde-java/struts/jsp_edit.rb,
lib/ontomde-java/crank/validation.rb,
lib/ontomde-java/kbjava/rdfToJava.rb,
lib/ontomde-java/flex/ValueObjectAS.rb,
lib/ontomde-java/flex/Editor.mxml.as.rb,
lib/ontomde-java/struts/mappingForJsp.rb,
lib/ontomde-java/struts/mappingForBean.rb,
lib/ontomde-java/java/xsdDatatypeMapping.rb,
lib/ontomde-java/java/javaDatatypeMapping.rb,
lib/ontomde-java/struts/mappingToJavaHierarchy.rb,
lib/ontomde-java/struts/mappingToJavaHierarchy.rb

Instance Method Summary collapse

Instance Method Details

#addActionFieldMethod!(field, action, form) ⇒ Object

adds special action for this type



13
14
# File 'lib/ontomde-java/struts/mappingForJsp.rb', line 13

def addActionFieldMethod!(field,action,form)
end

#crank_validation_annotationObject



31
32
33
# File 'lib/ontomde-java/crank/validation.rb', line 31

def crank_validation_annotation
  return nil
end

#flex_writeMXML_Form_item_property(prop) ⇒ Object

prop.write(“<!– # no mapping for #DatatypeMapping.propprop.java_Name errcode=5 (#DatatypeMapping.selfself.class) –>n”)



149
150
151
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 149

def flex_writeMXML_Form_item_property(prop)
  	prop.write("<!-- # no mapping for #{prop.java_Name} errcode=6 (#{self.class}) -->\n")
end

#flex_writeMXML_Form_item_property_column(prop) ⇒ Object



152
153
154
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 152

def flex_writeMXML_Form_item_property_column(prop)
	prop.write("<!-- # no mapping for #{prop.java_Name} errcode=7 (#{self.class}) -->\n")
end

#flex_writeMXML_MXvalidator(prop) ⇒ Object



133
134
135
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 133

def flex_writeMXML_MXvalidator(prop)
	#nop
end

#flex_writeMXML_validate(prop) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 125

def flex_writeMXML_validate(prop)
	prop.write("//#{prop.java_Name}")
        prop.write(" mapping=#{self.class}")
	prop.write(" maxStringLength=#{self.maxStringLength}")
	re=self.getValidationRegexp
	prop.write(%{ regexp=#{re.nil? ? "nil" : re.source}})
	prop.write("\n")
end

#flex_writeMXML_vo_mapping(prop) ⇒ Object



144
145
146
147
148
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 144

def flex_writeMXML_vo_mapping(prop)
         puts("WARNING: Unknown flex_writeMXML_vo_mapping for property #{prop.java_Name} and mapping=#{self.class}")
         #ignore element
       	#prop.write("<!-- # no mapping for #{prop.java_Name} errcode=5 (#{self.class}) -->\n")
end

#flex_writeVO_getParameter(prop) ⇒ Object



134
135
136
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 134

def flex_writeVO_getParameter(prop)
	prop.write("<!-- # no mapping for #{prop.java_Name} errcode=2 (#{self.class}) -->\n")
end

#flex_writeVO_initFromXML_mapping(prop) ⇒ Object



141
142
143
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 141

def flex_writeVO_initFromXML_mapping(prop)
       	prop.write("<!-- # no mapping for #{prop.java_Name} errcode=4 (#{self.class}) -->\n")
end

#flex_writeVO_initItemFromXML_mapping(prop) ⇒ Object



137
138
139
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 137

def flex_writeVO_initItemFromXML_mapping(prop)
         	prop.write("<!-- # no mapping for #{prop.java_Name} errcode=3 (#{self.class}) -->\n")
end

#flex_writeVO_vars_datatype(prop) ⇒ Object



131
132
133
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 131

def flex_writeVO_vars_datatype(prop)
	prop.write("<!-- # no mapping for #{prop.java_Name} errcode=1 (#{self.class}) -->\n")
end

#getFormCopyTo(field) ⇒ Object

returns code to be inserted in struts form copyTo def getFormCopyTo(field) # inheriting class should redefine this method log.error %not implemented for #{self.class} return %TODO: implement ruby getFormCopyTo for #{self.class*/} end returns code to be inserted in struts form initFrom def getFormInitFrom(field) # inheriting class should redefine this method log.error %not implemented for #{self.class} return %TODO: implement ruby getFormInitFrom for #{self.class*/} end



17
18
19
# File 'lib/ontomde-java/struts/mappingForBean.rb', line 17

def getFormCopyTo(field)
  return %{_to.set#{field.java_NameBean}(#{java_getJavaParse(%{this.get#{field.java_NameBean}()})});\n}
end

#getFormInitFrom(field) ⇒ Object



20
21
22
# File 'lib/ontomde-java/struts/mappingForBean.rb', line 20

def getFormInitFrom(field)
  return %{this.set#{field.java_NameBean}(#{java_getJavaToString(%{_from.get#{field.java_NameBean}()})});\n}
end

#getFormType(field) ⇒ Object



23
24
25
# File 'lib/ontomde-java/struts/mappingForBean.rb', line 23

def getFormType(field)
  return field.umlx_dataType_string
end

#getJSP(datatype, field, owner) ⇒ Object

returns true if this templates applies to datatype



6
7
8
9
10
# File 'lib/ontomde-java/struts/mappingForJsp.rb', line 6

def getJSP(datatype,field,owner)
  # inheriting class should redefine this method
  log.error %{getJSP not implemented for #{self.class}}
  return %{<!-- TODO: implement ruby getJSP for #{self.class} --!>}
end

#java_getTypeObject



2
3
4
5
6
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 2

def java_getType
  # inheriting class should redefine this method
  log.error %{java_getType not implemented for #{self.class}}
  return %{/* TODO: implement ruby java_getType for #{self.class}*/}
end

#java_getUndefinedValueObject



7
8
9
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 7

def java_getUndefinedValue
  return "null /* undefined */" 
end

#java_helper_addMethods!(c) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/ontomde-java/struts/mappingToJavaHierarchy.rb', line 75

def java_helper_addMethods!(c)
	return
	m=c.umlx_createAndAddOperation(self.rdf_uri+"_parse","parse")
	r=m.umlx_createAndAddReturnParameter(m.rdf_uri+"ret")
	r.uml_type=c.umlx_getOrCreateClass("java.lang.Object") #TODO

	r=m.umlx_createAndAddParameter(m.rdf_uri+"tr","tr")
	r.uml_type=c.umlx_dataType_string

	m=c.umlx_createAndAddOperation(self.rdf_uri+"_parse","to_s")
	r=m.umlx_createAndAddReturnParameter(m.rdf_uri+"ret")
	r.uml_type=c.umlx_getOrCreateClass("java.lang.Object") #TODO

	r=m.umlx_createAndAddParameter(m.rdf_uri+"elt","elt")
	r.uml_type=c.umlx_dataType_string

end

#java_helper_customCodeObject



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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ontomde-java/struts/mappingToJavaHierarchy.rb', line 35

def java_helper_customCode
	return if self.class==DatatypeMapping
	return <<END
protected #{java_Name}() {};
private static #{java_Name} instance=new #{java_Name}();
public #{java_Name} getInstance() {
return instance;
}

public #{java_getType} parse(final String str,final #{java_getType} nullCast ) {
#{if respond_to?(:java_getJavaParse)
 	"return #{java_getJavaParse("str")};"
else
	%{throw new java.lang.RuntimeException("Method not implemented");}
end
}
}

public String getValidationRegexp() {
#{if !respond_to?(:getValidationRegexp)
	%{throw new java.lang.RuntimeException("Method not implemented");}
elsif getValidationRegexp.nil?
	%{return null;}
else
 	%{return "#{getValidationRegexp.source.java_stringEscape}";}
end
}
}

public String toString(final #{java_getType} elt) {
#{if respond_to?(:java_getJavaToString)
 	"return #{java_getJavaToString("elt")};"
else
	%{throw new java.lang.RuntimeException("Method not implemented");}
end
}
}

END
end

#java_NameObject



12
13
14
# File 'lib/ontomde-java/struts/mappingToJavaHierarchy.rb', line 12

def java_Name
	return self.class.name
end

#java_qualifiedNameObject



15
16
17
# File 'lib/ontomde-java/struts/mappingToJavaHierarchy.rb', line 15

def java_qualifiedName
	return rdf_uri
end

#jpa_addTypeModificator(ah) ⇒ Object



326
327
328
329
330
331
332
# File 'lib/ontomde-java/jpa/mapping.rb', line 326

def jpa_addTypeModificator(ah)
	n=ah.jpa_addNameAnnotation
	return if n.nil?
    ah.java_annotation_add(%{@Column(#{n})}) 
    ah.umlx_owner_one.java_import_add('javax.persistence.Column')
  #nop
end

#prot_init(umlprop, valitem) ⇒ Object



346
347
348
# File 'lib/ontomde-java/kbjava/rdfToJava.rb', line 346

def prot_init(umlprop,valitem)
  return ""
end

#rdf_uriObject



18
19
20
# File 'lib/ontomde-java/struts/mappingToJavaHierarchy.rb', line 18

def rdf_uri
	return "xmda.datatypes.#{java_Name}"
end

#struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(prop) ⇒ Object



869
870
871
872
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 869

def struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(prop)
  # One decorator for every type
  prop.write %{<display:column property="#{prop.java_Name}" titleKey="#{prop.umlx_owner_one.java_qualifiedName}.#{prop.java_Name}" decorator="xmda.displayTag.extensions.I18nColumnDecorator"/>\n}
end

#struts_generateHelper(model) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ontomde-java/struts/mappingToJavaHierarchy.rb', line 21

def struts_generateHelper(model)
	return unless self.respond_to?("java_getType")
	c=model.umlx_reserved_model.umlx_getOrCreateClass(java_qualifiedName)
	return c unless c.umlx_external?
	c.umlx_external=RDF_FALSE
	c.db_isTransient=RDF_TRUE
	c.struts_isForm=RDF_FALSE
	c.umlx_businessMethod=RDF_FALSE

	c.umlx_createAndAddGeneralization(self.class.superclass.instance.struts_generateHelper(model)) if self.class.superclass.respond_to?("instance")
	c.java_customCode=java_helper_customCode
	java_helper_addMethods!(c)
	return c
end

#xsd_getTypeObject



2
3
4
5
6
# File 'lib/ontomde-java/java/xsdDatatypeMapping.rb', line 2

def xsd_getType
  # inheriting class should redefine this method
  log.error %{xsd_getType not implemented for #{self.class}}
  return %{/* TODO: implement ruby xsd_getType for #{self.class}*/}
end