Module: Muml_Operation

Defined in:
lib/ontomde-uml2-jpa/mapping.rb,
lib/ontomde-uml2-jpa/simulationAutoImplement.rb

Constant Summary collapse

JPA_ANNOTATE_GETTER =

true puts annotation on getter false puts annotation on attribute

false
JPA_TEST_CODE_TOP =
%{
//TODO: replace this test code by real implementation
//log.error("test method called");\n}

Instance Method Summary collapse

Instance Method Details

#jpa_addPersistence!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ontomde-uml2-jpa/mapping.rb', line 10

def jpa_addPersistence!
  # java_AttributeGlobalSetter
  # java_getter_property
  if java_getter_property.empty?
    return if(umlx_hasStereotype?("Create"))
    #java_annotation_add("@Transient")
    return
  end

  p=java_getter_property_one
  return unless p.jpa_isPersistent?

  if p.uml_type_one.kind_of?(Cuml_Class) && !p.uml_type_one.jpa_isPersistent?
    p.java_annotation_add("/* not persistent */")
    return
  end

  if(JPA_ANNOTATE_GETTER)
    p.jpa_addPersistenceTo!(self)
    # HACK
    p.jpa_addPersistenceTo!(p) #TODO: remove
    #p.java_annotation_add("@Transient")
  else
    p.jpa_addPersistenceTo!(p)
  end
end

#jpa_addTestImplementation!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ontomde-uml2-jpa/simulationAutoImplement.rb', line 22

def jpa_addTestImplementation!
  return unless java_code.empty?
  owner=umlx_owner_one
  return if owner.kind_of?(Muml_Interface)
  return if owner.uml_isAbstract?
  #log.debug { "adding test implementation for #{self.umlx_owner_one}.#{self}" }
  fp=nil
  (uml_returnResult+uml_ownedParameter).each { |p|
    next unless p.uml_direction_one.isReturn?
    fp=p
  }
  if fp.nil?
    self.java_code=JPA_TEST_CODE_TOP
    return
  elsif fp.uml_type_one.kind_of?(Muml_DataType)
    #TODO: create test code
    return
  elsif (!fp.uml_type_one.jpa_isPersistent?) || (fp.uml_type_one.db_isTransient?) || (fp.uml_type_one.java_ignoreMe?)
    #not a persistent class
    return
  elsif fp.umlx_oneSide?
    self.java_code=%{#{JPA_TEST_CODE_TOP}\nreturn #{fp.uml_type_one.db_getFindAllCall}.get(0);}
  elsif fp.uml_isOrdered?
    self.java_code=%{#{JPA_TEST_CODE_TOP}\nreturn #{fp.uml_type_one.db_getFindAllCall};}
  else
    self.java_code=%{
#{JPA_TEST_CODE_TOP}
#{fp.java_propertyAssociationConcreteType} ret=new #{fp.java_propertyAssociationConcreteType}();
ret.addAll(#{fp.uml_type_one.db_getFindAllCall});
return ret;}
  end
end