Class: DatatypeMappingGenericClass

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

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, #rdf_uri, #struts_edit_writeFieldGeneric_DisplayTable_displayTag_column, #struts_generateHelper

Instance Method Details

#flex_prefixObject



550
551
552
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 550

def flex_prefix
	return "cmb"
end

#flex_writeMXML_Form_item_property(prop) ⇒ Object

EXAMPLE: <mx:DataGrid height=“49” dataProvider=“DatatypeMappingGenericClass.modelmodel.adresse”> <mx:columns> <mx:DataGridColumn headerText=“Column 1” dataField=“ident”/> <mx:DataGridColumn headerText=“Column 2” dataField=“numero”/> <mx:DataGridColumn dataField=“ident” width=“30” headerText=“” editable=“false”> <mx:itemRenderer> <mx:Component > <mx:LinkButton label=“” click=“DatatypeMappingGenericClass.outerDocumentouterDocument.removeAndDeleteAdresse(dataouterDocument.removeAndDeleteAdresse(data.ident)”> </mx:LinkButton> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> <mx:DataGridColumn dataField=“ident” width=“30” headerText=“” editable=“false”> <mx:itemRenderer> <mx:Component > <mx:LinkButton label=“” click=“DatatypeMappingGenericClass.outerDocumentouterDocument.editAdresse(dataouterDocument.editAdresse(data.ident)” > </mx:LinkButton> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <mx:ComboBox id=“cmbAdresse” prompt=“Select one…” labelFunction=“myLabelFunction” dataProvider=“DatatypeMappingGenericClass.modelmodel.adressesSug” labelField=“value” change=“createAndAddAdresse(cmbAdresse.selectedItem.key)”> </mx:ComboBox>



587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 587

def flex_writeMXML_Form_item_property(prop)
	before= <<-END_BEFORE
<mx:HBox>
<mx:VBox>

#{ %{<mx:Button styleName="Add" width="32" height="32" click="{showSug(dg#{prop.java_NameBean},model.#{prop.java_Name}Sug,add#{prop.java_NameBean})}" buttonMode="true" useHandCursor="true" />
} if  !(prop.uml_isReadOnly?) && !(prop.umlx_isComposite?) }

#{ %{<mx:Button styleName="#{ prop.umlx_isComposite? ? "Delete" : "Remove" }" width="32" height="32" enabled="{dg#{prop.java_NameBean}.selectedItem}" click="removeAndDelete#{prop.java_NameBean}(dg#{prop.java_NameBean}.selectedItem.id)" buttonMode="true" useHandCursor="true" includeInLayout="{model.#{prop.java_Name}.length>0}" visible="{dg#{prop.java_NameBean}.visible}" />} if  !prop.uml_isReadOnly? }

<mx:Button styleName="Edit" width="32" height="32" enabled="{dg#{prop.java_NameBean}.selectedItem}" click="edit#{prop.java_NameBean}(dg#{prop.java_NameBean}.selectedItem.id)" includeInLayout="{model.#{prop.java_Name}.length>0}" buttonMode="true" useHandCursor="true" visible="{dg#{prop.java_NameBean}.visible}"/>
</mx:VBox>

<mx:VBox>
<components:AdvancedDatagrid id="dg#{prop.java_NameBean}" width="100%" horizontalScrollPolicy="auto" maxWidth="{this.width - dg#{prop.java_NameBean}.x -50}" dataProvider="{model.#{prop.java_Name}}" doubleClickEnabled="true" itemDoubleClick="edit#{prop.java_NameBean}(dg#{prop.java_NameBean}.selectedItem.id)" includeInLayout="{model.#{prop.java_Name}.length>0}" visible="{model.#{prop.java_Name}.length>0}">
<components:columns>
	END_BEFORE
	after= <<-END_AFTER
</components:columns>
</components:AdvancedDatagrid>
#{%{<mx:ComboBox id="#{flex_prefix}#{prop.java_NameBean}"
					prompt="Select one...(create)"
					labelFunction="myLabelFunction"
					dataProvider="{model.#{prop.java_Name}CreateAndAddSug}"
					labelField="value"
					change="createAndAdd#{prop.java_NameBean}(#{flex_prefix}#{prop.java_NameBean}.selectedItem.key)">
			</mx:ComboBox>} if !prop.uml_isReadOnly? && prop.umlx_isComposite?}
</mx:VBox>
</mx:HBox>
	END_AFTER

	prop.encloseWrite(before,after) {
		noId=true
		prop.uml_type_one.flex_ownedAttributeSet(noId).each { |pcol|
			tpl=DatatypeMapping.instance.getMapping(pcol.uml_type_one)
			tpl.flex_writeMXML_Form_item_property_column(pcol)
		}
	}
end

#flex_writeMXML_Form_item_property_column(pcol) ⇒ Object

nop



693
694
695
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 693

def flex_writeMXML_Form_item_property_column(pcol)
	#nop
end

#flex_writeMXML_validate(prop) ⇒ Object



181
182
183
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 181

def flex_writeMXML_validate(prop)
	super
end

#flex_writeMXML_vo_mapping(prop) ⇒ Object

def flex_writeMXML_Form_item_property(prop)

before=“”

before=before+ <<-ENDHEAD <mx:DataGrid id=“dg#DatatypeMappingGenericClass.propprop.java_NameBean” dataProvider=“DatatypeMappingGenericClass.model.model.#{propmodel.#{prop.java_Name}”> <mx:columns> ENDHEAD after=“” after= prop.uml_isReadOnly? ? “” : <<-ENDBOTTOM <mx:DataGridColumn dataField=“id” width=“30” headerText=“” editable=“false”> <mx:itemRenderer> <mx:Component > <mx:LinkButton label=“” click=“DatatypeMappingGenericClass.outerDocumentouterDocument.removeAndDeleteouterDocument.removeAndDelete#{propouterDocument.removeAndDelete#{prop.java_NameBean(data.id)}”> </mx:LinkButton> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> ENDBOTTOM after=after + <<-ENDBOTTOM <mx:DataGridColumn dataField=“id” width=“30” headerText=“” editable=“false”> <mx:itemRenderer> <mx:Component > <mx:LinkButton label=“” click=“DatatypeMappingGenericClass.outerDocumentouterDocument.editouterDocument.edit#{propouterDocument.edit#{prop.java_NameBean(data.id)}” > </mx:LinkButton> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> ENDBOTTOM

prop.encloseWrite(before,after) { noId=true prop.uml_type_one.flex_ownedAttributeSet(noId).each { |pcol| tpl=DatatypeMapping.instance.getMapping(pcol.uml_type_one) tpl.flex_writeMXML_Form_item_property_column(pcol) } }

# si composition if prop.uml_isReadOnly? #nop elsif prop.umlx_isComposite? prop.write <<-END <mx:ComboBox id=“##flex_prefix#DatatypeMappingGenericClass.propprop.java_NameBean” prompt=“Select one…(create)” labelFunction=“myLabelFunction” dataProvider=“DatatypeMappingGenericClass.model.model.#{propmodel.#{prop.java_NameCreateAndAddSug}” labelField=“value” change=“createAndAdd#DatatypeMappingGenericClass.propprop.java_NameBean(##flex_prefix#DatatypeMappingGenericClass.propprop.java_NameBean.selectedItem.key)”> </mx:ComboBox> END else #prop.write <<-END # <mx:Button label=“+” click=“DatatypeMappingGenericClass.showSug(dgshowSug(dg#{propshowSug(dg#{prop.java_NameBean,model.#DatatypeMappingGenericClass.propprop.java_NameSug,add#DatatypeMappingGenericClass.propprop.java_NameBean)}” /> #END

end end



690
691
692
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 690

def flex_writeMXML_vo_mapping(prop)
	#nop
end

#flex_writeVO_getParameter(prop) ⇒ Object



310
311
312
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 310

def flex_writeVO_getParameter(prop)
	prop.write("// #{prop.java_Name}\n")
end

#flex_writeVO_initFromXML_mapping(prop) ⇒ Object

EXAMPLES: For a composition:

adresseSug = DeserializeXMLUtil.getFormAttributeAssignable(source, 'adresse');
adresse = DeserializeXMLUtil.getFormAttributSelection(source, 'adresse', AdresseVO);

for an association:

adresse = DeserializeXMLUtil.getFormAttributSelection(source, 'adresse', AdresseVO);
favorisSug = DeserializeXMLUtil.getFormAttributSug(source, 'favoris', ContratVO);


321
322
323
324
325
326
327
328
329
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 321

def flex_writeVO_initFromXML_mapping(prop)

	if(prop.umlx_isComposite?)
		prop.write("#{prop.java_Name}CreateAndAddSug = DeserializeXMLUtil.getFormAttributeAssignable(source, '#{prop.java_Name}');\n")
	else
		prop.write("#{prop.java_Name}Sug = DeserializeXMLUtil.getFormAttributSug(source, '#{prop.java_Name}',#{prop.uml_type_one.java_Name}VO);\n")
	end
	prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormAttributSelection(source, '#{prop.java_Name}', #{prop.uml_type_one.java_Name}VO);\n")
end

#flex_writeVO_initItemFromXML_mapping(prop) ⇒ Object



331
332
333
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 331

def flex_writeVO_initItemFromXML_mapping(prop)
	#nop
end

#flex_writeVO_vars_datatype(prop) ⇒ Object

EXAMPLES: public var adresse:ArrayCollection; public var adressesSug:ArrayCollection; public var dernierContrat:ArrayCollection; public var dernierContratSug:ArrayCollection;



301
302
303
304
305
306
307
308
309
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 301

def flex_writeVO_vars_datatype(prop)
	prop.write("public var #{prop.java_Name}:ArrayCollection;\n")
	if(prop.umlx_isComposite?)
		prop.write("public var #{prop.java_Name}CreateAndAddSug:ArrayCollection;\n")
		prop.write("public var #{prop.java_Name}Sug:ArrayCollection;\n")
	else
		prop.write("public var #{prop.java_Name}Sug:ArrayCollection;\n")
	end
end

#getFormCopyTo(field) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 104

def getFormCopyTo(field)
  a=field
  return "/* #{a.java_NameBean} is transient */\n" if a.uml_type_one.java_DAOClass.empty?
  if a.umlx_oneSide?
    return %{_to.set#{a.java_NameBean}(this.get#{a.java_NameBean}().compareTo("nil")==0 ? null : #{a.uml_type_one.java_DAOClass_one.java_qualifiedName}.find(Long.parseLong(this.get#{a.java_NameBean}())));\n}
  else # many
    cm=a.java_getCollectionMapping
    return <<END333
{ // UML: #{field.uml_name}
	String[] src=this.get#{a.java_NameBean}();
	#{cm.addCollectionInterface(a.uml_type_one.java_qualifiedName)} newCol= #{cm.addNew(a.uml_type_one.java_qualifiedName)};
	int max=src==null ? 0 : src.length;
	#{a.uml_type_one.java_qualifiedName} item=null;
	for(int i=0; i<max;i++) {
//log.error("loading : "+src[i]);
if(src[i]==null) continue;
item=#{a.uml_type_one.java_DAOClass_one.java_qualifiedName}.find(Long.parseLong(src[i]));
newCol.add(item);
}
	_to.set#{a.java_NameBean}(newCol);
}
END333
  end
end

#getFormInitFrom(field) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 128

def getFormInitFrom(field)
  a=field
  if a.umlx_oneSide?
    return %{this.set#{a.java_NameBean}(_from.get#{a.java_NameBean}()==null? "nil" : Long.toString(_from.get#{a.java_NameBean}().getId()));\n}
  else
    return %{
	{ /*STRUTS:2001*/
	this.set#{a.java_NameBean}(null);
    java.util.Iterator<?> iter=_from.get#{a.java_NameBean}().iterator();
    #{a.uml_type_one.java_qualifiedName} item=null;
    while(iter.hasNext()){
    item=(#{a.uml_type_one.java_qualifiedName})iter.next();
    this.add#{a.java_NameBean}(Long.toString(item.getId()));
    }
	}
    }
  end
end

#getJSP(datatype, field, owner) ⇒ Object



153
154
155
# File 'lib/ontomde-java/struts/mappingForJsp.rb', line 153

def getJSP(datatype,field,owner)
  return "<!-- TODO:JSP #{self.class.name} -->"
end

#java_getTypeObject



146
147
148
# File 'lib/ontomde-java/java/javaDatatypeMapping.rb', line 146

def java_getType
  return "java.lang.Object"
end

#prot_convertToJava(umlprop, valitem) ⇒ Object

Protege string to Java code conversions



406
407
408
# File 'lib/ontomde-java/kbjava/rdfToJava.rb', line 406

def prot_convertToJava(umlprop,valitem)
  return "#{valitem.kbjava_property_one.java_AttributeGlobalGetter_one.java_Name}()"
end

#prot_init(umlprop, valitem) ⇒ Object



409
410
411
412
# File 'lib/ontomde-java/kbjava/rdfToJava.rb', line 409

def prot_init(umlprop,valitem)
  return ""
  #return "init#{umlprop.java_NameBean}();/* #{umlprop.class} */"
end

#xsd_getTypeObject



70
71
72
# File 'lib/ontomde-java/java/xsdDatatypeMapping.rb', line 70

def xsd_getType
  return "java.lang.Object"
end