Class: Lutaml::Qea::Models::EaObjectConstraint

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/lutaml/qea/models/ea_object_constraint.rb

Overview

EA Object Constraint model

Represents OCL constraints attached to UML objects in the t_objectconstraint table.

Examples:

Create from database row

row = {
  "Object_ID" => 4,
  "Constraint" => "count(self.legalConstraints) >= 1",
  "ConstraintType" => "Invariant",
  "Weight" => "0.0",
  "Notes" => nil,
  "Status" => "Approved"
}
constraint = EaObjectConstraint.from_db_row(row)

Class Method Summary collapse

Methods inherited from BaseModel

#primary_key

Class Method Details

.from_db_row(row) ⇒ EaObjectConstraint?

Create from database row

Parameters:

  • row (Hash)

    Database row with string keys

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/lutaml/qea/models/ea_object_constraint.rb', line 46

def self.from_db_row(row)
  return nil if row.nil?

  new(
    constraint_id: row["ConstraintID"],
    ea_object_id: row["Object_ID"],
    constraint: row["Constraint"],
    constraint_type: row["ConstraintType"],
    weight: row["Weight"]&.to_f,
    notes: row["Notes"],
    status: row["Status"],
  )
end

.primary_key_columnSymbol

Returns Primary key column name.

Returns:

  • (Symbol)

    Primary key column name



33
34
35
# File 'lib/lutaml/qea/models/ea_object_constraint.rb', line 33

def self.primary_key_column
  :constraint_id
end

.table_nameString

Returns Database table name.

Returns:

  • (String)

    Database table name



38
39
40
# File 'lib/lutaml/qea/models/ea_object_constraint.rb', line 38

def self.table_name
  "t_objectconstraint"
end