Module: DAO

Included in:
Muml_Class
Defined in:
lib/ontomde-uml2-jpa/jpa.rb

Instance Method Summary collapse

Instance Method Details

#jpa_addDAO!Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 114

def jpa_addDAO!
  return if db_isDAO?
  return if java_ignoreMe?

  if !context[:db_autonomousDAO,false]
    self.java_DAOClass=self
    self.java_persistentClass=self
  else

    #log.debug { "adding dao for #{self}" }
    p=umlx_package




    #p=self
    p=p.umlx_getOrCreatePackage(context[:dbDAOsubPackage,"dao"],p)
    c=p.umlx_createAndAddClass(rdf_uri+"_dao")
    c.db_isDAO=RDF_TRUE
    c.db_isTransient=RDF_TRUE
    self.java_DAOClass=c
    c.java_persistentClass=self
    c.uml_name=uml_name_one+"Dao"

    #log.debug { "DAO added: #{c.uml_name} in #{c.umlx_package.uml_name}"}
    java_DAOClass_one.jpa_addEntityManager!()
    java_DAOClass_one.jpa_addStdImports!
    #jpa_addGetDao!()
  end
  jpa_addPersist!
  jpa_addMerge!
  jpa_addRemove!
  jpa_addFindByPrimaryKey!(java_DAOClass_one)
  jpa_addFindAll!(java_DAOClass_one)
end

#jpa_addGetDao!Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 149

def jpa_addGetDao!()
  return if uml_isAbstract?
  umlx_classifier_generalization_indirect.each {|c|
    return unless c.uml_isAbstract?
  }
  m=umlx_createAndAddOperation(rdf_uri+"_getdao")
  m.uml_name="dao"
  m.uml_class=self
  m.uml_visibility=Cuml_VisibilityKind::Public
  m.uml_isStatic=RDF_TRUE
  #m.db_isTransient=RDF_TRUE

  #em=m.umlx_createAndAddParameter(m.rdf_uri+"_entityManager","entityManager")
  #em.uml_type=umlx_getOrCreateClass(DB::EntityManager)
  #em.uml_direction=Cuml_ParameterDirectionKind::In
  #em.uml_upperValue=umlx_literal(1)
  #em.uml_lowerValue=umlx_literal(1)

  rp=m.umlx_createAndAddParameter(m.rdf_uri+"_ret_param","return")
  rp.uml_direction=Cuml_ParameterDirectionKind::Return
  rp.uml_upperValue=umlx_literal(1)
  rp.uml_lowerValue=umlx_literal(1)
  rp.uml_type=java_DAOClass_one
  m.java_code="return new #{java_DAOClass_one.java_qualifiedName}();"
  return m
end

#jpa_addMerge!Object



103
104
105
106
107
108
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 103

def jpa_addMerge!
  c=umlx_createAndAddOperation(rdf_uri+"_merge","merge")
  c.java_code="return (#{self.java_qualifiedName})getEntityManager().merge(this);"
  r=c.umlx_createAndAddReturnParameter("#{c.rdf_uri}_ret")
  r.uml_type=self
end

#jpa_addPersist!Object



99
100
101
102
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 99

def jpa_addPersist!
  c=umlx_createAndAddOperation(rdf_uri+"_persist","persist")
  c.java_code="getEntityManager().persist(this);"
end

#jpa_addPersistenceContext!Object



97
98
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 97

def jpa_addPersistenceContext!
end

#jpa_addRemove!Object



110
111
112
113
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 110

def jpa_addRemove!
  c=umlx_createAndAddOperation(rdf_uri+"_remove","remove")
  c.java_code="getEntityManager().remove(this);"
end