Module: Muml_Classifier

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

Constant Summary collapse

DB_OBJECT_VERSION_FIELD =
"objectVersion"

Instance Method Summary collapse

Instance Method Details

#jpa_addOptimisticLockingAnnotation!(p) ⇒ Object



3
4
5
6
# File 'lib/ontomde-uml2-jpa/locking.rb', line 3

def jpa_addOptimisticLockingAnnotation!(p)
  p.java_annotation_add("@Version")
  p.java_annotation_add(%{@SuppressWarnings("unused")})
end

#jpa_addOptimisticLockingVar!Object



9
10
11
12
13
14
15
16
# File 'lib/ontomde-uml2-jpa/locking.rb', line 9

def jpa_addOptimisticLockingVar!
  return unless jpa_hasPersistenceId?
  p=umlx_createAndAddProperty(rdf_uri+"_auto_version",DB_OBJECT_VERSION_FIELD)
  jpa_addOptimisticLockingAnnotation!(p)
  p.uml_type=umlx_dataType_long
  p.uml_visibility=::Cuml_VisibilityKind::Private
  #java_addAccessorsFor!(p)
end

#jpa_addPersistenceId!Object



438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/ontomde-uml2-jpa/jpa.rb', line 438

def jpa_addPersistenceId!
  #return unless uml_generalization.empty?
  return unless context[:db_useOptimisticLocking,true]
  return unless jpa_hasPersistenceId?

  p=umlx_createAndAddProperty(rdf_uri+"_auto_id","id")
  jpa_addPersistenceIdAnnnotation!(p)
  #p.uml_type=umlx_dataType_long
  p.uml_type=umlx_getOrCreateDataType("Long")
  p.uml_visibility=::Cuml_VisibilityKind::Private
  java_addAccessorsFor!(p)

  #TODO Surcharge le getter : A enlever une fois avoir corrig� incompatibilit� avec couche Struts
  gettter = p.java_AttributeGlobalGetter
  #removed ? : operator to make checkstyle happy.
  gettter[0].java_code = %{if(#{p.java_Name} == null) { return Long.valueOf(0);} else {return #{p.java_Name};}}
  
  stereo = umlx_package.umlx_createAndAddStereotype(rdf_uri+"Equals", "EqualsValue")
  p.uml_appliedStereotype = stereo
  
end