Module: Muml_Property

Defined in:
lib/ontomde-uml2-crank/crankJpa.rb

Constant Summary collapse

CRANK_DEFAULT_CASCADE =
"(cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})"
CRANK_DEFAULT_CASCADE_I =
",cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}"

Instance Method Summary collapse

Instance Method Details

#crank_isDetailFromMasterDetail?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 36

def crank_isDetailFromMasterDetail?
  oe=umlx_otherEnd
  binav=(!oe.nil?) && oe.umlx_isNavigable?
  return false if !binav
  return oe.crank_isMasterFromMasterDetail?
end

#crank_isMasterFromMasterDetail?Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 32

def crank_isMasterFromMasterDetail?
  return true if self.umlx_isComposite?
  return false 
end

#jpa_addPersistenceToAssociation!(ah) ⇒ Object



28
29
30
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 28

def jpa_addPersistenceToAssociation!(ah)
  super_jpa_addPersistenceToAssociation!(ah)
end

#jpa_addRelationCascadeType(isIncludeType = true) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 3

def jpa_addRelationCascadeType(isIncludeType=true)
  if crank_isMasterFromMasterDetail?
    self.java_annotation_add("@xmda.jpa.annotations.MasterDetail")
    self.umlx_owner_one.java_import_add("org.hibernate.annotations.Cascade");
    self.java_annotation_add("@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})")
    if (isIncludeType)
      return ",cascade={CascadeType.ALL}"
    else
      return "(cascade={CascadeType.ALL})"
    end       
  elsif crank_isDetailFromMasterDetail?
    self.java_annotation_add("@xmda.jpa.annotations.Detail")
  end

  if (isIncludeType)
    return CRANK_DEFAULT_CASCADE_I
  else
    return CRANK_DEFAULT_CASCADE
  end     
end

#super_jpa_addPersistenceToAssociation!Object



27
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 27

alias super_jpa_addPersistenceToAssociation! jpa_addPersistenceToAssociation!