Class: JavaMappingGenericClass

Inherits:
JavaMapping show all
Includes:
Singleton
Defined in:
lib/ontomde-uml2-java/javaMapping.rb

Instance Attribute Summary

Attributes inherited from JavaMapping

#maxStringLength

Instance Method Summary collapse

Methods inherited from JavaMapping

#getGroovyCast, #getMappings, #getTemplate, #getValidationRegexp, #initialize

Constructor Details

This class inherits a constructor from JavaMapping

Instance Method Details

#appliesTo?(datatype) ⇒ Boolean

Returns:

  • (Boolean)


254
255
256
257
258
259
# File 'lib/ontomde-uml2-java/javaMapping.rb', line 254

def appliesTo?(datatype)
  return false if datatype.kind_of?(Muml_Enumeration)
  return false if datatype.kind_of?(Muml_DataType)
  #return true if datatype.kind_of?(Muml_Class)
  return true
end

#getFormCopyTo(field) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/ontomde-uml2-java/javaMapping.rb', line 261

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



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/ontomde-uml2-java/javaMapping.rb', line 285

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

#getJavaTypeObject



303
304
305
# File 'lib/ontomde-uml2-java/javaMapping.rb', line 303

def getJavaType
  return "java.lang.Object"
end