Skip to content

Commit

Permalink
Checkpoint - added notes from discussions with Jim about georeferenci…
Browse files Browse the repository at this point in the history
…ng images, and design notes from work done last week
  • Loading branch information
BethFrank committed Apr 15, 2014
1 parent 71f1a91 commit 5c614da
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
5 changes: 5 additions & 0 deletions app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def gps_data
# Altitude should be based on reference of sea level
# GPSAltitudeRef is 0 for above sea level, and 1 for below sea level

# From discussion with Jim -

This comment has been minimized.

Copy link
@mjy

mjy Apr 16, 2014

Member

@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.

# create a utility library called "GeoConvert" and define single method
# that will convert from degrees min sec to decimal degree
# - maybe 2 versions? - one returns string, other decimal?

end

protected
Expand Down
42 changes: 27 additions & 15 deletions app/models/serial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
@mjy

mjy Apr 16, 2014

Member

@BethFrank The first three scopes are necessary, be trivially implemented with .where(name: 'Some name'), so they don't need to be explicitly defined. The fourth, which is an or, is a more reasonable scope target.

This comment has been minimized.

Copy link
@BethFrank

BethFrank via email Apr 16, 2014

Author Contributor

This comment has been minimized.

Copy link
@mjy

mjy Apr 16, 2014

Member

@BethFrank I sort of agree, and definitely see the need for abstraction in general, but two things in this case: 1) If the ActiveRecord interface changes and where() goes away we're globally in trouble; 2) the scope will be something like `scope :named, -> (name) {name: name}, i.e. it will use where(), so when where() get's changed in the future scenario then :named will break. I.e. nothing is really added by adding a scope (since where() itself returns a scope)

This comment has been minimized.

Copy link
@BethFrank

BethFrank via email Apr 16, 2014

Author Contributor

This comment has been minimized.

Copy link
@mjy

mjy Apr 16, 2014

Member

@BethFrank I'm sorry, I guess I don't understand. I'll definitely take your word for it though, especially if you spec out the functionality and make the tests pass ;)

# 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
3 changes: 3 additions & 0 deletions app/models/source/bibtex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def to_bibtex # outputs BibTeX::Entry equivalent to me.
end

# TODO add conversion of identifiers to ruby-bibtex fields, & notations to notes field.
# TODO add conversion of Serial ID to journal name

b.key = self.id
b
Expand Down Expand Up @@ -403,6 +404,8 @@ def self.bibtex_author_to_person(bibtex_author)
suffix: bibtex_author.suffix)
end

#TODO create related Serials

#endregion ruby-bibtex related

#region getters & setters
Expand Down
Binary file added spec/files/images/post_processed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions spec/models/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
expect(j.has_duplicate?).to be_true
image_array = j.duplicate_images
expect(image_array.count).to eq(2)
expect(image_array.sort).to eq([@i,k].sort)
expect(image_array.sort).to eq([@i, k].sort)

j.soft_validate
expect(j.soft_validations.messages).to include 'This image is a duplicate of an image already stored.'
Expand Down Expand Up @@ -99,9 +99,13 @@
expect(File.exists?(Rails.root.to_s + Image::MISSING_IMAGE_PATH)).to be_true
end

specify 'exif data should be available if it was provided in the original image' do
specify 'exif data should be available if it was provided in the image' do
# return empty hash when no EXIF data present
# return correct EXIF data on following images:
# Samsung phone - Samsung_Phone.jpg
# Exif added later - post_processed.jpg
# Exif with comments
# Exif with edited data

end

Expand Down
6 changes: 4 additions & 2 deletions spec/models/serial_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@
expect(k.soft_validations.messages_on(:name).empty?).to be_false
expect(k.soft_validations.messages).to include 'There is another serial with this name in the database.'

# TODO 'should check for duplicate between name & other serial tags'
# create alternate value/types synonym, translation, abbreviation
end
it 'should set the language based on valid languages' do
pending 'not implemented yet'
pending 'no languages in the language table yet'
end

it 'should use English as the default language' do
pending 'is this true?'
end


it 'should list the Serial Chronology'

it 'should list all preceding serials' do
pending 'not implemented yet'
Expand Down
3 changes: 3 additions & 0 deletions spec/models/source/bibtex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
expect(@s.to_bibtex.fields).to eq(@gem_bibtex_entry1.fields)
expect(@s.bibtex_type.to_s).to eq(@gem_bibtex_entry1.type.to_s)
pending 'test that notes gets converted properly to a bibtex note'
# TODO test serial gets converted properly to bibtex journal
end

specify 'valid_bibtex?' do
Expand Down Expand Up @@ -511,6 +512,8 @@
end

end

# TODO if the bibtex entry has a journal create the Serials
end

%w{author editor}.each do |a|
Expand Down

1 comment on commit 5c614da

@mjy
Copy link
Member

@mjy mjy commented on 5c614da Apr 16, 2014

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.

Please sign in to comment.