-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
…ng images, and design notes from work done last week
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,48 +23,60 @@ class Serial < ActiveRecord::Base | |
has_many :preceding_serials, through: :serial_chronologies_as_object, class_name: 'Serial' | ||
|
||
# Scopes, clustered by function | ||
This comment has been minimized.
Sorry, something went wrong.
mjy
Member
|
||
# select all serials with this name | ||
# select all serials with this abbreviation | ||
# select all serials with this translation name | ||
# select all serials that match this name or alternate value | ||
|
||
# "Hard" Validations | ||
validates_presence_of :name | ||
# TODO validate language | ||
|
||
# "Soft" Validations | ||
soft_validate(:sv_duplicate?) | ||
|
||
# Getters/Setters | ||
# TODO set language via string name | ||
|
||
# Class methods | ||
|
||
# Instance methods | ||
def duplicate? | ||
# Boolean is there another serial with the same name? | ||
ret_val = false | ||
if self.new_record? | ||
Serial.exists?(name: self.name) | ||
ret_val = Serial.exists?(name: self.name) | ||
else | ||
# where{ geographic_items.flatten.collect { |geographic_item| "id != #{geographic_item.id}" }.join(' and ')} | ||
=begin | ||
f = select { '*' }. | ||
select_distance(column_name, geographic_item). | ||
where_distance_greater_than_zero(column_name,geographic_item). | ||
order { 'distance desc' } | ||
select { "ST_Distance(#{column_name}, GeomFromEWKT('srid=4326;#{geographic_item.geo_object}')) as distance" } | ||
=end | ||
dup = Serial.where("name = ? AND id <> ?", self.name, self.id).to_a | ||
# select { "name = #{self.name} AND NOT (id = #{self.id})"} | ||
dup | ||
ret_val = Serial.where( "name = '#{self.name}' AND NOT (id = #{self.id})").to_a.count > 0 | ||
end | ||
|
||
ret_val # return | ||
end | ||
|
||
def previous_serial | ||
# return previous serial object or nil | ||
end | ||
|
||
def succeeding_serial | ||
# return succeeding serial object or nil | ||
end | ||
|
||
def chronology | ||
# return ordered array of serials associated with this serial | ||
end | ||
|
||
protected | ||
|
||
|
||
def sv_duplicate? | ||
if self.duplicate? | ||
soft_validations.add(:name, 'There is another serial with this name in the database.') | ||
end | ||
# TODO soft validation of name matching an alternate value for name of a different serial | ||
end | ||
|
||
# TODO soft validation of name matching an alternate value for name of a different serial | ||
def match_alternate_value? | ||
#Select value from AlternateValue WHERE alternate_object_type = 'Serial' AND alternate_object_attribute = 'name' | ||
|
||
end | ||
end |
1 comment
on commit 5c614da
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BethFrank Thanks for the stubs, exactly what I was hoping for.
@BethFrank @TuckerJD There should be libraries that accomplish all the heavy lifting in this regard. Rgeo likely does this somewhat. At present let's let Jim handle implementing this, when we assign it to him.