Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added message to GBIF maps #EOLINFRASTRUCTURE-1538; added data_object…

…s_taxon_concepts

git-svn-id: file:///data/subversion/eol/trunk@1816 78829999-583a-0410-bd01-8a9b849fd409
  • Loading branch information...
commit 675605e1e1d5c29fc2ff88904dc4be3a4e360f05 1 parent 573466c
pleary authored
View
2  app/helpers/taxa_helper.rb
@@ -126,7 +126,7 @@ def video_hash(video,taxon_concept_id='')
data_supplier_icon = data_supplier ? agent_icons_partial(data_supplier) : ''
return "{author: '" + escape_javascript(agent_partial(video.authors)) +
- "', nameString: '" + escape_javascript(video.scientific_name) +
+ "', nameString: '" + escape_javascript(video.taxa_names_ids[0]['taxon_name']) +
"', collection: '" + escape_javascript(agent_partial(video.sources)) +
"', location: '" + escape_javascript(video.location || '') +
"', info_url: '" + escape_javascript(video.source_url || '') +
View
12 app/models/data_object.rb
@@ -1030,22 +1030,20 @@ def self.build_query(taxon, type, options)
data_type_ids = DataObject.get_type_ids(type)
query_string = %Q{
-(SELECT DISTINCT dt.label media_type, dato.*, t.scientific_name, he.taxon_concept_id taxon_id,
+(SELECT dt.label media_type, dato.*, dotc.taxon_concept_id taxon_id,
l.description license_text, l.logo_url license_logo, l.source_url license_url #{add_toc} #{add_cp}, v.view_order as vetted_view_order
- FROM hierarchy_entries he
- JOIN taxa t ON (he.id = t.hierarchy_entry_id)
- JOIN data_objects_taxa dot ON (t.id = dot.taxon_id)
- JOIN data_objects dato ON (dot.data_object_id = dato.id)
+ FROM data_objects_taxon_concepts dotc
+ JOIN data_objects dato ON (dotc.data_object_id = dato.id)
JOIN vetted v ON (dato.vetted_id=v.id)
JOIN data_types dt ON (dato.data_type_id = dt.id)
#{join_agents} #{join_toc}
LEFT OUTER JOIN licenses l ON (dato.license_id = l.id)
- WHERE he.taxon_concept_id = #{taxon.id}
+ WHERE dotc.taxon_concept_id = #{taxon.id}
AND data_type_id IN (#{data_type_ids.join(',')})
#{DataObject.visibility_clause(options.merge(:taxon => taxon))}
#{where_toc})
UNION
-(SELECT dt.label media_type, dato.*, '' scientific_name, taxon_concept_id taxon_id, l.description license_text, l.logo_url license_logo, l.source_url license_url #{add_toc} #{add_cp}, v.view_order vetted_view_order
+(SELECT dt.label media_type, dato.*, taxon_concept_id taxon_id, l.description license_text, l.logo_url license_logo, l.source_url license_url #{add_toc} #{add_cp}, v.view_order vetted_view_order
FROM data_objects dato
JOIN vetted v ON (dato.vetted_id=v.id)
JOIN #{ UsersDataObject.full_table_name } udo ON (dato.id=udo.data_object_id)
View
8 app/models/data_objects_taxon_concept.rb
@@ -0,0 +1,8 @@
+# a denormalized table containing all the objects a concept
+# should show in its RSS feed
+class DataObjectsTaxonConcept < SpeciesSchemaModel
+ set_primary_keys :taxon_concept_id, :data_object_id
+ belongs_to :taxon_concept
+ belongs_to :data_object
+ belongs_to :data_type
+end
View
5 app/views/taxa/mediacenter/_tab_maps.html.haml
@@ -1,4 +1,6 @@
-#media-maps.wrapper-mc.clearfix{ :style => "display: none;" }
+#media-maps.wrapper-mc.clearfix{ :style => "display: none; height: 400px;" }
+ %p.gbif_disclaimer
+ = external_link_to "This map is based on occurrence records available through GBIF and may not represent the entire taxon distribution", "http://data.gbif.org/species/#{@taxon_concept.gbif_map_id}/"
%input#map-taxon-concept-id{ :name => "map-taxon-concept-id", :type => "hidden", :value => @taxon_concept.gbif_map_id }
%input#map-data-server-endpoint{ :name => "map-data-server-endpoint", :type => "hidden", :value => $MAP_DATA_SERVER_ENDPOINT }
%input#map-gmap-key{ :name => "map-gmap-key", :type => "hidden", :value => $GOOGLE_MAP_API_KEY }
@@ -7,4 +9,5 @@
%input#map-tile-server-3{ :name => "map-tile-server-3", :type => "hidden", :value => $MAP_TILE_SERVER_3 }
%input#map-tile-server-4{ :name => "map-tile-server-4", :type => "hidden", :value => $MAP_TILE_SERVER_4 }
#map-image{ :style => "display:none" }
+
/ end media-maps
View
18 db/migrate/20100401162942_create_data_objects_taxon_concepts.rb
@@ -0,0 +1,18 @@
+class CreateDataObjectsTaxonConcepts < ActiveRecord::Migration
+ def self.database_model
+ return "SpeciesSchemaModel"
+ end
+
+ def self.up
+ execute 'CREATE TABLE IF NOT EXISTS `data_objects_taxon_concepts` (
+ `taxon_concept_id` int(10) unsigned NOT NULL,
+ `data_object_id` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`taxon_concept_id`,`data_object_id`),
+ KEY `data_object_id` (`data_object_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8'
+ end
+
+ def self.down
+ drop_table :data_objects_taxon_concepts
+ end
+end
View
40 lib/eol/taxon_concept_builder.rb
@@ -89,10 +89,13 @@ def build
add_map
add_toc
add_iucn
- gen_random_hierarchy_image
gen_bhl
gen_biomedical_terms
+
+ #denormalized tables
+ gen_random_hierarchy_image
add_feed_objects
+ add_data_objects_taxon_concepts
end
# There isn't much involved with the actual TaxonConcept, in terms of the database and/or generation of the model
@@ -249,18 +252,6 @@ def add_toc
# TODO Outlinks: create a Collection related to any agent, and then give it a mapping with a foreign_key that links to some external
# site. (optionally, you could use collection.uri and replace the FOREIGN_KEY bit)
end
-
- def gen_random_hierarchy_image
- puts "** Enter: gen_random_hierarchy_image" if @debugging
- return if @image_objs.blank? or @sname.blank?
- # TODO - we really don't want to denormalize the names, so remove them (but check that this will work!)
- options = {:data_object => @image_objs.last,
- :name => @sname.italicized,
- :hierarchy_entry => @tc.hierarchy_entries[0],
- :hierarchy => @tc.hierarchy_entries[0].hierarchy,
- :taxon_concept => @tc }
- RandomHierarchyImage.gen(options)
- end
# TODO - This is one of the slower methods.
def gen_bhl
@@ -291,6 +282,21 @@ def gen_biomedical_terms
end
end
+ #
+ # Denormalized Tables
+ #
+ def gen_random_hierarchy_image
+ puts "** Enter: gen_random_hierarchy_image" if @debugging
+ return if @image_objs.blank? or @sname.blank?
+ # TODO - we really don't want to denormalize the names, so remove them (but check that this will work!)
+ options = {:data_object => @image_objs.last,
+ :name => @sname.italicized,
+ :hierarchy_entry => @tc.hierarchy_entries[0],
+ :hierarchy => @tc.hierarchy_entries[0].hierarchy,
+ :taxon_concept => @tc }
+ RandomHierarchyImage.gen(options)
+ end
+
def add_feed_objects
@tc.data_objects.each do |obj|
unless FeedDataObject.find_by_taxon_concept_id_and_data_object_id(@tc.id, obj.id)
@@ -298,6 +304,14 @@ def add_feed_objects
end
end
end
+
+ def add_data_objects_taxon_concepts
+ @tc.data_objects.each do |obj|
+ unless DataObjectsTaxonConcept.find_by_taxon_concept_id_and_data_object_id(@tc.id, obj.id)
+ DataObjectsTaxonConcept.gen(:taxon_concept => @tc, :data_object => obj)
+ end
+ end
+ end
def build_entry_in_hierarchy(options)
puts "**** Enter: build_entry_in_hierarchy" if @debugging
View
11 public/javascripts/application.js
@@ -95,7 +95,7 @@ Event.addBehavior(
'#tab_media_center #maps a:click': function(e) {
var map_div = $$('#media-maps div')[0];
if (map_div && map_div.style.display == 'none') {
-
+
var taxon_concept_id = $('map-taxon-concept-id').value;
var data_server_endpoint = $('map-data-server-endpoint').value;
var gmap_key = $('map-gmap-key').value;
@@ -103,7 +103,7 @@ Event.addBehavior(
var tile_server_2 = $('map-tile-server-2').value;
var tile_server_3 = $('map-tile-server-3').value;
var tile_server_4 = $('map-tile-server-4').value;
-
+
var so = new SWFObject("/EOLSpeciesMap.swf", "swf", "100%", "100%", "9");
so.addParam("allowFullScreen", "true");
so.addVariable("swf", "");
@@ -112,16 +112,15 @@ Event.addBehavior(
so.addVariable("taxon_id", taxon_concept_id);
so.addVariable("data_server_endpoint", data_server_endpoint);
so.addVariable("gmap_key", gmap_key);
-
+
var tileServers = new Array();
tileServers[0] = tile_server_1;
tileServers[1] = tile_server_2;
tileServers[2] = tile_server_3;
tileServers[3] = tile_server_4;
so.addVariable("tile_servers", tileServers);
-
- so.write("media-maps");
-
+ so.write("map-image");
+
map_div.style.display = 'block';
}
e.stop();
View
8 public/stylesheets/main.css
@@ -411,6 +411,14 @@ div#media-videos {
background-color: #f4f4f4;
position: relative;
z-index: 1000; }
+ #media-maps .gbif_disclaimer {
+ text-align: center;
+ text-decoration: none; }
+ #media-maps .gbif_disclaimer a {
+ text-decoration: none;}
+ #map-image {
+ height: 96%;
+ width: 100%; }
#left-mc {
float: left;
View
2  spec/eol_spec_helpers.rb
@@ -355,6 +355,8 @@ def add_toc_item(toc_item, options = {})
DataObjectsTableOfContent.gen(:data_object => dato, :toc_item => toc_item)
dato.save!
DataObjectsTaxon.gen(:data_object => dato, :taxon => taxa.first)
+ FeedDataObject.gen(:taxon_concept => self, :data_object => dato, :data_type => dato.data_type)
+ DataObjectsTaxonConcept.gen(:taxon_concept => self, :data_object => dato)
end
# Add a synonym to this TC.
View
5 spec/factories.rb
@@ -510,6 +510,11 @@ def attribution
dot.identifier '' # No idea what this is supposed to be, but it cannot be nil
end
+Factory.define :data_objects_taxon_concept do |fdo|
+ fdo.association :taxon_concept
+ fdo.association :data_object
+end
+
Factory.define :data_type do |dt|
dt.schema_value ''
dt.label { Factory.next(:string) }
Please sign in to comment.
Something went wrong with that request. Please try again.