diff --git a/data/dev/dataset.csv b/data/dev/dataset.csv index b3e72b7409..4bf6eba536 100644 --- a/data/dev/dataset.csv +++ b/data/dev/dataset.csv @@ -8,4 +8,5 @@ The assembled scaffolds of high quality sequences total 1.23 Gb, with the contig 144,163,147,100094,Data and software to accompany the paper: Applying compressed sensing to genome-wide association studies.,"The aim of a genome-wide association study (GWAS) is to isolate DNA markers for variants affecting phenotypes of interest. Linear regression is employed for this purpose, and in recent years a signal-processing paradigm known as compressed sensing (CS) has coalesced around a particular class of regression techniques. CS is not a method in its own right, but rather a body of theory regarding signal recovery when the number of predictor variables (i.e., genotyped markers) exceeds the sample size. The paper shows the applicability of compressed sensing (CS) theory to genome-wide association studies (GWAS), where the purpose is to find trait-associated tagging markers (genetic variants). Analysis scripts are contained in the compressed CS file. Mock data and scripts are found in the compressed GD file. The example scripts found in the CS repository require the GD files to be unpacked in a separate folder. Please look at accompanying readme pdfs for both repositories and annotations in the example scripts before using.",171860992,ftp://parrot.genomics.cn/gigadb/pub/10.5524/100001_101000/100094,Published,,,2014-06-06,,1,AWLGPriZKd41XEaS,,,, 200,336,212,100142,"Supporting scripts and data for ""Investigation into the annotation of protocol sequencing steps in the Sequence Read Archive"".","The workflow for the production of high-throughput sequencing data from nucleic acid samples is complex. There are a series of protocol steps to be followed in the preparation of samples for next-generation sequencing. The quantification of bias in a number of protocol steps, namely DNA fractionation, blunting, phosphorylation, adapter ligation and library enrichment, remains to be determined. We examined the experimental metadata of the public repository Sequence Read Archive (SRA) in order to ascertain the level of annotation of important sequencing steps in submissions to the database. ",384263168,ftp://parrot.genomics.cn/gigadb/pub/10.5524/100001_101000/100142/,Published,100142newversion.xls,a98f1c13a46501707fb3fba270deb6e3,2015-05-11,,3,eG8EFsRibZQzrtNw,,,, -668,38,669,200070,supporting data for nothing in particular,"well now, how to describe nothing in particular?",32,https://ftp.cngb.org/pub/gigadb/pub,Private,,,,,1,ImP3Bbu7ytRSfYFh,,38,none, \ No newline at end of file +668,38,669,200070,supporting data for nothing in particular,"well now, how to describe nothing in particular?",32,https://ftp.cngb.org/pub/gigadb/pub,Private,,,,,1,ImP3Bbu7ytRSfYFh,,38,none, +700,14,700,300070,test dataset,"test generic image will be display for no image dataset",32,https://ftp.cngb.org/pub/gigadb/pub,Published,,,,,1,,,38,none, \ No newline at end of file diff --git a/data/dev/image.csv b/data/dev/image.csv index 160ea8ef31..57bb92332b 100644 --- a/data/dev/image.csv +++ b/data/dev/image.csv @@ -4,3 +4,4 @@ id,location,tag,url,license,photographer,source 147,"",CS icon1,"",public domain,Shashaank Vattikuti ,Gigascience 212,100142.jpg,Overlap between different protocol search terms,http://gigadb.org/images/data/cropped/100142.jpg,CC0,Alnasir and Shanahan 2015,Alnasir and Shanahan 2015 669,"",no image icon,var/www/hosts/localhost/htdocs/images/uploads/image_upload/Images_1885.png,Public domain,GigaDB,GigaDB +700,no_image.png,no image icon,"",Public domain,GigaDB,GigaDB \ No newline at end of file diff --git a/ops/configuration/yii-conf/migration.php.dist b/ops/configuration/yii-conf/migration.php.dist index 279495c243..91d0c086fe 100644 --- a/ops/configuration/yii-conf/migration.php.dist +++ b/ops/configuration/yii-conf/migration.php.dist @@ -8,7 +8,7 @@ class {{ class_name }} extends CDbMigration {{#each safeup_data}} $this->insert('{{ ../table_name }}', array( {{#each this}} - {{#if this}} + {{#if (isdefined @key this) }} '{{@key}}' => '{{this}}', {{/if}} {{/each}} diff --git a/ops/scripts/csv_yii_migration.js b/ops/scripts/csv_yii_migration.js index 675861acd9..de56b67d1c 100644 --- a/ops/scripts/csv_yii_migration.js +++ b/ops/scripts/csv_yii_migration.js @@ -158,6 +158,13 @@ for(let a = 0; a < files.length; a ++) { safeup_data: parsed.data, safedown_data: filtered_ids }; + // Register sub expression to decide whether a value is defined based on its key + handlebars.registerHelper('isdefined', function (key, value) { + if (key == 'url') { + return value !== undefined; + } + return !handlebars.Utils.isEmpty(value); + }); // Read handlebars template as string let template = fs.readFileSync(HANDLEBARS_TEMPLATE_FILE, "utf8"); const templateScript = handlebars.compile(template); diff --git a/ops/scripts/setup_devdb.sh b/ops/scripts/setup_devdb.sh index c10f3dfdcf..c47ce27eb2 100755 --- a/ops/scripts/setup_devdb.sh +++ b/ops/scripts/setup_devdb.sh @@ -44,6 +44,9 @@ docker-compose run --rm test psql -h database -U gigadb < protected/runtime/drop # Perform data migrations $DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=db --migrationPath=application.migrations.data.$dbSet --interactive=0 +# update the url for project images and dataset images +$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=db --migrationPath=application.migrations.fix_import --interactive=0 + # Restore constraints, indexes and triggers docker-compose run --rm test psql -h database -U gigadb < protected/runtime/addConstraintsQuery.sql docker-compose run --rm test psql -h database -U gigadb < protected/runtime/addIndexQuery.sql diff --git a/ops/scripts/setup_testdb.sh b/ops/scripts/setup_testdb.sh index e535cdea79..f1d8320094 100755 --- a/ops/scripts/setup_testdb.sh +++ b/ops/scripts/setup_testdb.sh @@ -32,5 +32,9 @@ $DOCKER_COMPOSE run --rm application ./protected/yiic migrate to 300000_000000 $DOCKER_COMPOSE run --rm application ./protected/yiic migrate mark 000000_000000 --connectionID=testdb --interactive=0 $DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.schema --interactive=0 $DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.data.$dbSet --interactive=0 + +# update the url for project images and dataset images +$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.fix_import --interactive=0 + # export a binary dump $DOCKER_COMPOSE run --rm test bash -c "pg_dump --no-owner -U gigadb -h database -p 5432 -F custom -d $dbSet -f /var/www/sql/$dbSet.pgdmp" \ No newline at end of file diff --git a/protected/migrations/fix_import/m220126_062259_update_image_location_column_project_tab.php b/protected/migrations/fix_import/m220126_062259_update_image_location_column_project_tab.php index 2d1fbad4cc..12f0d02afc 100644 --- a/protected/migrations/fix_import/m220126_062259_update_image_location_column_project_tab.php +++ b/protected/migrations/fix_import/m220126_062259_update_image_location_column_project_tab.php @@ -8,10 +8,10 @@ public function safeUp() Yii::app()->db->createCommand("update project set image_location = replace(image_location,'http://hpc-bioinformatics.cineca.it/fusion/imgs','');")->execute(); Yii::app()->db->createCommand("update project set image_location = replace(image_location,'https://bioinfotraining.bio.cam.ac.uk/images','');")->execute(); Yii::app()->db->createCommand("update project set image_location = replace(image_location,'http://gigadb.org/images/data/cropped','');")->execute(); - Yii::app()->db->createCommand("ALTER TABLE project ALTER COLUMN image_location TYPE character varying(128);")->execute(); - Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', lower(replace(replace(replace(name, ' ','_'),'_-_','_'),',','')), image_location) where image_location != '' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%' and name not like 'LiGeA%' and name != 'https://www.carmen.org.uk';")->execute(); - Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', replace(name, 'LiGeA: a comprehensive database of human gene fusion events', 'ligea'), image_location) where name like 'LiGeA%' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute(); - Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', replace(name, 'https://www.carmen.org.uk', 'carmen'), image_location) where name = 'https://www.carmen.org.uk' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute(); + Yii::app()->db->createCommand("ALTER TABLE project ALTER COLUMN image_location TYPE character varying(255);")->execute(); + Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', lower(replace(replace(replace(name, ' ','_'),'_-_','_'),',','')), image_location) where image_location != '' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%' and name not like 'LiGeA%' and name != 'https://www.carmen.org.uk';")->execute(); + Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', replace(name, 'LiGeA: a comprehensive database of human gene fusion events', 'ligea'), image_location) where name like 'LiGeA%' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute(); + Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', replace(name, 'https://www.carmen.org.uk', 'carmen'), image_location) where name = 'https://www.carmen.org.uk' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute(); } public function safeDown() diff --git a/protected/migrations/fix_import/m220218_062834_update_url_image_tab.php b/protected/migrations/fix_import/m220218_062834_update_url_image_tab.php new file mode 100644 index 0000000000..cb0bb43d68 --- /dev/null +++ b/protected/migrations/fix_import/m220218_062834_update_url_image_tab.php @@ -0,0 +1,14 @@ +db->createCommand("update image set url = replace(url, 'http://gigadb.org/','https://assets.gigadb-cdn.net/live/images/datasets/') where url like 'http://gigadb.org/%';")->execute(); + Yii::app()->db->createCommand("update image set url = 'https://assets.gigadb-cdn.net/live/images/datasets/no_image.png' where url='' and location like 'no_image%';")->execute(); + } + + public function safeDown() + { + } +} \ No newline at end of file diff --git a/protected/models/Dataset.php b/protected/models/Dataset.php index 9e9ded3b75..5de2455b7f 100644 --- a/protected/models/Dataset.php +++ b/protected/models/Dataset.php @@ -327,13 +327,6 @@ public function getDatasetTypes(){ public function getImageUrl($default='') { if ($this->image) { $url = $this->image->url; - if ($url) { - if (!strstr($url , 'http://')) { - $url = '//' . $url; - } - } else { - $url = $this->image->image('image_upload'); - } return $url; } return $default; diff --git a/tests/acceptance/DatasetView.feature b/tests/acceptance/DatasetView.feature index b0735c8349..c5e198b3d4 100644 --- a/tests/acceptance/DatasetView.feature +++ b/tests/acceptance/DatasetView.feature @@ -55,10 +55,21 @@ Feature: a user visit the dataset page Then I should see "well now, how to describe nothing in particular?" And I should not see "The DOI 200070 cannot be displayed." + @ok + Scenario: Dataset with image associated will show dataset image + Given I have not signed in + When I am on "dataset/100006" + Then I should see an image located in "https://assets.gigadb-cdn.net/live/images/datasets/images/data/cropped/100006_Pygoscelis_adeliae.jpg" + + @ok + Scenario: Dataset with no image associated will show generic image + Given I have not signed in + When I am on "dataset/300070" + Then I should see an image located in "https://assets.gigadb-cdn.net/live/images/datasets/no_image.png" + @ok @issue-895 Scenario: Project image with links Given I have not signed in When I am on "/dataset/100006" - Then I should see an image "https://assets.gigadb-cdn.net/images/projects/genome_10k/G10Klogo.jpg" is linked to "http://www.genome10k.org/" - And I should see an image "https://assets.gigadb-cdn.net/images/projects/the_avian_phylogenomic_project/phylogenomiclogo.png" is linked to "http://avian.genomics.cn/en/index.html" - \ No newline at end of file + Then I should see an image "https://assets.gigadb-cdn.net/live/images/projects/genome_10k/G10Klogo.jpg" is linked to "http://www.genome10k.org/" + And I should see an image "https://assets.gigadb-cdn.net/live/images/projects/the_avian_phylogenomic_project/phylogenomiclogo.png" is linked to "http://avian.genomics.cn/en/index.html"