Class: DatatypeMappingGenericEnum

Inherits:
DatatypeMapping show all
Defined in:
lib/ontomde-java/flex/Editor.mxml.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/java/xsdDatatypeMapping.rb,
lib/ontomde-java/java/javaDatatypeMapping.rb

Constant Summary collapse

NULL_ENUM_VALUE_AS_STRING =
"nil"

Instance Method Summary collapse

Methods inherited from DatatypeMapping

#addActionFieldMethod!, #crank_validation_annotation, #flex_writeMXML_MXvalidator, #getFormType, #java_Name, #java_getUndefinedValue, #java_helper_addMethods!, #java_helper_customCode, #java_qualifiedName, #jpa_addTypeModificator, #prot_init, #rdf_uri, #struts_edit_writeFieldGeneric_DisplayTable_displayTag_column, #struts_generateHelper

Instance Method Details

#flex_prefixObject



506
507
508
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 506

def flex_prefix
	return "cmb"
end

#flex_writeMXML_Form_item_property(prop) ⇒ Object

EXAMPLE: <mx:ComboBox id=“cmbCivilite” dataProvider=“DatatypeMappingGenericEnum.modelmodel.civiliteSug” selectedItem=“DatatypeMappingGenericEnum.modelmodel.civilite” labelFunction=“myLabelFunction” labelField=“value”> </mx:ComboBox>



513
514
515
516
517
518
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 513

def flex_writeMXML_Form_item_property(prop)
	prop.write <<-END
	<mx:ComboBox id="#{flex_prefix}#{prop.java_NameBean}" dataProvider="{model.#{prop.java_Name}Sug}" selectedItem="{model.#{prop.java_Name}}" labelFunction="myLabelFunction" labelField="value">
	</mx:ComboBox>
	END
end

#flex_writeMXML_Form_item_property_column(pcol) ⇒ Object



525
526
527
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 525

def flex_writeMXML_Form_item_property_column(pcol)
	pcol.write(%{<mx:DataGridColumn headerText="Column " dataField="#{pcol.java_Name}"/>\n})
end

#flex_writeMXML_validate(prop) ⇒ Object



171
172
173
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 171

def flex_writeMXML_validate(prop)
	super
end

#flex_writeMXML_vo_mapping(prop) ⇒ Object

civilite=“DatatypeMappingGenericEnum.cmbCivilitecmbCivilite.selectedItem”



521
522
523
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 521

def flex_writeMXML_vo_mapping(prop)
	prop.write(%{ #{prop.java_Name}="{#{flex_prefix}#{prop.java_NameBean}.selectedItem}"})
end

#flex_writeVO_getParameter(prop) ⇒ Object

EXAMPLES:

//key car c'est un item de l'enum
param.civilite = civilite.key;


277
278
279
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 277

def flex_writeVO_getParameter(prop)
	prop.write("param.#{prop.java_Name} = #{prop.java_Name}.key;\n")
end

#flex_writeVO_initFromXML_mapping(prop) ⇒ Object

EXAMPLES: civiliteSug = DeserializeXMLUtil.getFormEnum(source, ‘civilite’); civilite = DeserializeXMLUtil.getFormEnumAttributSelected(source, ‘civilite’, civiliteSug);



284
285
286
287
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 284

def flex_writeVO_initFromXML_mapping(prop)
	prop.write("#{prop.java_Name}Sug = DeserializeXMLUtil.getFormEnum(source, '#{prop.java_Name}');\n")
	prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormEnumAttributSelected(source, '#{prop.java_Name}', #{prop.java_Name}Sug);\n")
end

#flex_writeVO_initItemFromXML_mapping(prop) ⇒ Object



289
290
291
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 289

def flex_writeVO_initItemFromXML_mapping(prop)
	#nop
end

#flex_writeVO_vars_datatype(prop) ⇒ Object

public var civiliteSug:ArrayCollection;



268
269
270
271
272
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 268

def flex_writeVO_vars_datatype(prop)
	prop.write("public var #{prop.java_Name}:Object;\n")
	prop.write("public var #{prop.java_Name}Sug:ArrayCollection;\n")
	prop.write("public var selectedItem#{prop.java_Name}:Object;\n")
end

#getFormCopyTo(field) ⇒ Object



153
154
155
156
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 153

def getFormCopyTo(field)
  a=field
  return %{_to.set#{a.java_NameBean}(this.get#{a.java_NameBean}().compareTo("#{NULL_ENUM_VALUE_AS_STRING}")!=0 ? Enum.valueOf(#{a.uml_type_one.java_qualifiedName}.class,this.get#{a.java_NameBean}()):null);\n}
end

#getFormInitFrom(field) ⇒ Object



157
158
159
160
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 157

def getFormInitFrom(field)
  #return "this.set#{field.java_NameBean}(_from.get#{field.java_NameBean}()==null ? -1 :_from.get#{field.java_NameBean}().ordinal());\n"
  return %{this.set#{field.java_NameBean}(_from.get#{field.java_NameBean}()==null ? "#{NULL_ENUM_VALUE_AS_STRING}" :_from.get#{field.java_NameBean}().name());\n}
end

#getJSP(datatype, field, owner) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/ontomde-java/struts/mappingForJsp.rb', line 159

def getJSP(datatype,field,owner)
  if field.context[:jspUseXmdaTaglib]
    return getJSP_XmdaTagLib(datatype,field,owner)
  else
    return getJSP_StrutsOnly(datatype,field,owner)
  end
end

#getJSP_StrutsOnly(datatype, field, owner) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/ontomde-java/struts/mappingForJsp.rb', line 175

def getJSP_StrutsOnly(datatype,field,owner)
  return <<END
<html:select property="#{field.java_Name}" >
 <logic:iterate id="_#{field.java_Name}" name="#{owner.java_Name}StrutsForm" property="#{field.java_Name}Sug" >
<option value="<bean:write name="_#{field.java_Name}" property="value" />" >
 <bean:define id="_id">
   <bean:write name="_#{field.java_Name}" property="label" />
 </bean:define>
 <%-- TODO: eviter entrelacement balises XML --%>
 <bean:message key="<%= _id %>"/>
</option>
 </logic:iterate>
</html:select>
<SCRIPT> <%-- TODO : supprimer javascript --%>
document.forms[0].#{field.java_Name}.value="<bean:write name="#{owner.java_Name}StrutsForm" property="#{field.java_Name}" />";
</SCRIPT>
END
end

#getJSP_XmdaTagLib(datatype, field, owner) ⇒ Object



167
168
169
170
171
172
173
# File 'lib/ontomde-java/struts/mappingForJsp.rb', line 167

def getJSP_XmdaTagLib(datatype,field,owner)
  return %{
<html:select property="#{field.java_Name}" >
<xmda:i18noptionsCollection name="#{owner.java_Name}StrutsForm" property="#{field.java_Name}Sug" label="label" value="value"/>
</html:select>
  }
end

#java_getTypeObject



161
162
163
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 161

def java_getType
  return "java.lang.Object"
end

#prot_convertToJava(umlprop, valitem) ⇒ Object

Protege string to Java code conversions



416
417
418
419
420
421
422
423
# File 'lib/ontomde-java/kbjava/rdfToJava.rb', line 416

def prot_convertToJava(umlprop,valitem)
  lit=nil
  umlprop.uml_type_one.uml_ownedLiteral.each { |i|
    next if i.to_s!=valitem.to_s
    lit=i
  }
  return "#{umlprop.uml_type_one.java_qualifiedName}.#{lit.java_Name}"
end

#xsd_getTypeObject



76
77
78
# File 'lib/ontomde-java/java/xsdDatatypeMapping.rb', line 76

def xsd_getType
  return "java.lang.Object"
end