diff --git a/CHANGELOG b/CHANGELOG index af4ff48bca5d91abcc556a3791c83031cf93620c..d1c2ef7c9e211bf29e25e3806bd7fc429d408167 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,211 +1,218 @@ -minerva (11.0.3) stable; urgency=medium - * Bug fix: removing empty project removed images from all projects - * Bug fix: clicking on map when left panel was hidden threw error - * Bug fix: links to invalid annotations were opening invalid web page - * Bug fix: service resolving miriam resources doesn't worki over http - anymore - * Bug fux: chebi annotator doesn't work over http anymore - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 19 Oct 2017 13:50:00 +0200 - -minerva (11.0.2) stable; urgency=medium - * Bug fix: login issues when default page is in secure area - - -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 25 Sep 2017 12:00:00 +0200 - -minerva (11.0.1) stable; urgency=medium - * Bug fix: logout caused issues with session data - - -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 08 Sep 2017 12:00:00 +0200 - -minerva (11.0.0) stable; urgency=medium - - * Bug fix: security issue - access to specific map can be restricted - by the userlogin - * Bug fix: sbgn import - * Bug fix: mesh connector - * Rest API (documentation can be found here: - https://git-r3lab.uni.lu/piotr.gawron/minerva/blob/master/README.md) - * Selecting an element on the map shows info about it in the bottom left - corner (when Search tab is not open) - * Upload of data overlays allows to upload just names of the proteins - (or other elements), it can be done via file or just by typing in the - proper text box - * Layout changes: the main one is that there are only 3 tab panels - (search, overlay, info), so it should be easier to navigate - - -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 28 Aug 2017 12:00:00 +0200 - -minerva (10.0.5) stable; urgency=medium - - * Bug fix: interacting drugs can be found for RNAs - * Bug fix: error handling improved on map upload - * Bug fix: taxonomy ncbi server switched to https - * Overlay presents description field if possible - - - -- Piotr Gawron <piotr.gawron@uni.lu> Sat, 04 Mar 2017 12:00:00 +0200 - -minerva (10.0.4) stable; urgency=medium - - * Bug fix: overlays colors are centered in white (not black) - * Bug fix: export to CellDesigner fixed - * Bug fix: DrugBank connector updated due to change in DrugBank website - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 29 Dec 2016 17:01:16 +0200 - -minerva (10.0.3) stable; urgency=medium - - * Bug fix: login cannot contain whitespace - * Bug fix: search for multiple drugs will not return more drugs than - queried for - * Bug fix: drug list for some proteins (like RHOA) hung webpage - * Bug fix: comments on submaps issue - * Bug fix: link to submap from comment panel - * Overlay coloring can be defined in Configuration - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 15 Dec 2016 15:01:16 +0200 - -minerva (10.0.2) stable; urgency=medium - - * Bug fix: markers for mirna targets visibility - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 29 Sep 2016 10:01:16 +0200 - -minerva (10.0.1) stable; urgency=medium - - * Bug fix: export to image - * Bug fix: trigger reaction and physical stimulation reactions are no - longer allowed (CellDesigner data model issue) - * Bug fix: clicking on reactions in submaps - - -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 21 Sep 2016 13:01:16 +0200 - -minerva (10) stable; urgency=medium - - * Project info tab available for users - * Management of overlays in admin panel - * Bug fix: Visualization of text mining - * Bug fix: Exception when accessing non-existing project - * Bug fix: Zooming issue when searching for results on submaps - * Bug fix: Out of memory when caching a lot of data - * Bug fix: Corrupted drug names - * Bug fix: Unexpected errors when uploading layouts - * Bug fix: Coordinates in url - * Bug fix: Hiding left panel - * Bug fix: CellDesigner font size is processed properly - * Bug fix: Search by reaction id is not case sensitive - - -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 22 Aug 2016 13:01:16 +0200 - -minerva (9) stable; urgency=medium - - * Fix on install script of version 8 that crashed some new installations - - -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 29 Jun 2016 09:58:34 +0200 - -minerva (8) stable; urgency=medium - - * Micro RNA interface - * Toxic chemicals interdace - * Data sets (layouts) visualized dynamically in the browser - * Reverse query for drugs, chemicals, micro RNAs interfaces - * Small bug fixes - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 14 Apr 2016 13:03:55 +0200 - -minerva (7) stable; urgency=low - - * Uploaded datasets are available for download - * Entrez annotator - * Ensembl annotator - * Valid/required annotations and used annotations saved in user profile - * Export to pdf/png/jpg/svg - * New web interface - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 3 Dec 2015 22:00:00 +0200 - -minerva (6) stable; urgency=low - - * Searching by annotations - * Errors from parsing data forwarded to client - * Notification email system added - * Warnings are downloadable - * Complex map (composed from many small maps) - * Visualization of Recon specific annotations - * Versioning system - * Galaxy connector - * Miriam types report - * Advanced annotation options - * Uniprot annotation module - * Customized validation of miriam annotations - * Recon annotation service - * Bug fix: Data autofill problem in user management - * Bug fix: User privileges for adding project - * Bug fix: Problem with some miriam entries in RDF format - * Bug fix: Reporting of drawing problems - * Bug fix: Visualization of posttranslationa modification - * Bug fix: Drugbank problem after update of Drugbank interface - * Bug fix: Session scope fixed (browsing many maps at the same time) - * Bug fix: Asynchronous removing/adding maps - * Bug fix: Export to CellDesigner rarely produced corrupted CellDesigner file - * Bug fix: Recon annotations of reactions - * Bug fix: Login problem when browsing not default map - * Bug fix: Multimers are available for every element - - -- Piotr Gawron <piotr.gawron@uni.lu> Tue, 21 Jul 2015 22:00:00 +0200 - -minerva (5) stable; urgency=low - - * Additional checkboxes in upload model: annotate automatically, cache data, verify annotations - * Popup window in admin panel that list warnings - * Information about build - * Parsing and annotation warnings for models in admin panel - * Custom reaction visualization in upload overlay - * Bug fix: Problem with touch interface on Windows 8.1 - * Bug fix: Google Maps API problem with floating bubbles - * Bug fix: Error handling in admin panel - * Bug fix: Reaction color in CellDesigner file - * Bug fix: Reaction line width - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Dec 2014 22:00:00 +0200 - -minerva (4) stable; urgency=low - - * Export of the part of the map into CellDesigner file - * Logo files managable via config webpage - * Import data from GO - * Custom overlay upload - * Additional structural information imported from annotation service - * Bug fix: Fonts and lines in hierarchical view - * Bug fix: Visualization of residues in rna, antisense rna, proteins - * Bug fix: Problem with touching bubbles on touch interface - * Bug fix: Problem with special UTF-8 characters in CellDesigner file - * Bug fix: Problem with users and session expire - * Bug fix: Export problem - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 11 Sep 2014 22:00:00 +0200 - -minerva (3) stable; urgency=low - - * Drug targeting interface - * Export to CellDesigner - * Status page of all dependent services - * Configuration page - - -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 5 Jun 2014 22:00:00 +0200 - -minerva (2) stable; urgency=low - - * Upload of the CellDesigner map - * Bug fix: Problem with touch interface after update of browsers engine - * Bug fix: Problem in Safari when searching for elements - - -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 2 Apr 2014 22:00:00 +0200 - -minerva (1) stable; urgency=low - - * Initial release - - -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 4 Dec 2013 22:00:00 +0200 - +minerva (11.0.4) stable; urgency=medium + * Bug fix: fix on connection to taxonomy database + * Bug fix: color coding for reactions (wrong color was chosen) + * Bug fix: overlays with many reactions did not work properly + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 09 Nov 2017 14:50:00 +0200 + +minerva (11.0.3) stable; urgency=medium + * Bug fix: removing empty project removed images from all projects + * Bug fix: clicking on map when left panel was hidden threw error + * Bug fix: links to invalid annotations were opening invalid web page + * Bug fix: service resolving miriam resources doesn't work over http + anymore + * Bug fix: chebi annotator doesn't work over http anymore + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 19 Oct 2017 13:50:00 +0200 + +minerva (11.0.2) stable; urgency=medium + * Bug fix: login issues when default page is in secure area + + -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 25 Sep 2017 12:00:00 +0200 + +minerva (11.0.1) stable; urgency=medium + * Bug fix: logout caused issues with session data + + -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 08 Sep 2017 12:00:00 +0200 + +minerva (11.0.0) stable; urgency=medium + + * Bug fix: security issue - access to specific map can be restricted + by the user login + * Bug fix: sbgn import + * Bug fix: mesh connector + * Rest API (documentation can be found here: + https://git-r3lab.uni.lu/piotr.gawron/minerva/blob/master/README.md) + * Selecting an element on the map shows info about it in the bottom left + corner (when Search tab is not open) + * Upload of data overlays allows to upload just names of the proteins + (or other elements), it can be done via file or just by typing in the + proper text box + * Layout changes: the main one is that there are only 3 tab panels + (search, overlay, info), so it should be easier to navigate + + -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 28 Aug 2017 12:00:00 +0200 + +minerva (10.0.5) stable; urgency=medium + + * Bug fix: interacting drugs can be found for RNAs + * Bug fix: error handling improved on map upload + * Bug fix: taxonomy ncbi server switched to https + * Overlay presents description field if possible + + + -- Piotr Gawron <piotr.gawron@uni.lu> Sat, 04 Mar 2017 12:00:00 +0200 + +minerva (10.0.4) stable; urgency=medium + + * Bug fix: overlays colors are centered in white (not black) + * Bug fix: export to CellDesigner fixed + * Bug fix: DrugBank connector updated due to change in DrugBank website + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 29 Dec 2016 17:01:16 +0200 + +minerva (10.0.3) stable; urgency=medium + + * Bug fix: login cannot contain whitespace + * Bug fix: search for multiple drugs will not return more drugs than + queried for + * Bug fix: drug list for some proteins (like RHOA) hung webpage + * Bug fix: comments on submaps issue + * Bug fix: link to submap from comment panel + * Overlay coloring can be defined in Configuration + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 15 Dec 2016 15:01:16 +0200 + +minerva (10.0.2) stable; urgency=medium + + * Bug fix: markers for mirna targets visibility + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 29 Sep 2016 10:01:16 +0200 + +minerva (10.0.1) stable; urgency=medium + + * Bug fix: export to image + * Bug fix: trigger reaction and physical stimulation reactions are no + longer allowed (CellDesigner data model issue) + * Bug fix: clicking on reactions in submaps + + -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 21 Sep 2016 13:01:16 +0200 + +minerva (10) stable; urgency=medium + + * Project info tab available for users + * Management of overlays in admin panel + * Bug fix: Visualization of text mining + * Bug fix: Exception when accessing non-existing project + * Bug fix: Zooming issue when searching for results on submaps + * Bug fix: Out of memory when caching a lot of data + * Bug fix: Corrupted drug names + * Bug fix: Unexpected errors when uploading layouts + * Bug fix: Coordinates in url + * Bug fix: Hiding left panel + * Bug fix: CellDesigner font size is processed properly + * Bug fix: Search by reaction id is not case sensitive + + -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 22 Aug 2016 13:01:16 +0200 + +minerva (9) stable; urgency=medium + + * Fix on install script of version 8 that crashed some new installations + + -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 29 Jun 2016 09:58:34 +0200 + +minerva (8) stable; urgency=medium + + * Micro RNA interface + * Toxic chemicals interface + * Data sets (layouts) visualized dynamically in the browser + * Reverse query for drugs, chemicals, micro RNAs interfaces + * Small bug fixes + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 14 Apr 2016 13:03:55 +0200 + +minerva (7) stable; urgency=low + + * Uploaded datasets are available for download + * Entrez annotator + * Ensembl annotator + * Valid/required annotations and used annotations saved in user profile + * Export to pdf/png/jpg/svg + * New web interface + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 3 Dec 2015 22:00:00 +0200 + +minerva (6) stable; urgency=low + + * Searching by annotations + * Errors from parsing data forwarded to client + * Notification email system added + * Warnings are downloadable + * Complex map (composed from many small maps) + * Visualization of Recon specific annotations + * Versioning system + * Galaxy connector + * Miriam types report + * Advanced annotation options + * Uniprot annotation module + * Customized validation of miriam annotations + * Recon annotation service + * Bug fix: Data autofill problem in user management + * Bug fix: User privileges for adding project + * Bug fix: Problem with some miriam entries in RDF format + * Bug fix: Reporting of drawing problems + * Bug fix: Visualization of posttranslationa modification + * Bug fix: Drugbank problem after update of Drugbank interface + * Bug fix: Session scope fixed (browsing many maps at the same time) + * Bug fix: Asynchronous removing/adding maps + * Bug fix: Export to CellDesigner rarely produced corrupted CellDesigner file + * Bug fix: Recon annotations of reactions + * Bug fix: Login problem when browsing not default map + * Bug fix: Multimers are available for every element + + -- Piotr Gawron <piotr.gawron@uni.lu> Tue, 21 Jul 2015 22:00:00 +0200 + +minerva (5) stable; urgency=low + + * Additional checkboxes in upload model: annotate automatically, cache data, verify annotations + * Popup window in admin panel that list warnings + * Information about build + * Parsing and annotation warnings for models in admin panel + * Custom reaction visualization in upload overlay + * Bug fix: Problem with touch interface on Windows 8.1 + * Bug fix: Google Maps API problem with floating bubbles + * Bug fix: Error handling in admin panel + * Bug fix: Reaction color in CellDesigner file + * Bug fix: Reaction line width + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Dec 2014 22:00:00 +0200 + +minerva (4) stable; urgency=low + + * Export of the part of the map into CellDesigner file + * Logo files managable via config webpage + * Import data from GO + * Custom overlay upload + * Additional structural information imported from annotation service + * Bug fix: Fonts and lines in hierarchical view + * Bug fix: Visualization of residues in rna, antisense rna, proteins + * Bug fix: Problem with touching bubbles on touch interface + * Bug fix: Problem with special UTF-8 characters in CellDesigner file + * Bug fix: Problem with users and session expire + * Bug fix: Export problem + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 11 Sep 2014 22:00:00 +0200 + +minerva (3) stable; urgency=low + + * Drug targeting interface + * Export to CellDesigner + * Status page of all dependent services + * Configuration page + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 5 Jun 2014 22:00:00 +0200 + +minerva (2) stable; urgency=low + + * Upload of the CellDesigner map + * Bug fix: Problem with touch interface after update of browsers engine + * Bug fix: Problem in Safari when searching for elements + + -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 2 Apr 2014 22:00:00 +0200 + +minerva (1) stable; urgency=low + + * Initial release + + -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 4 Dec 2013 22:00:00 +0200 + diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/TaxonomyBackend.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/TaxonomyBackend.java index e6d3655a19c8da6a8ed2a98aebaed3c3cef0e9b9..ee307c12d466ca203e66d33bf4bd1ffce016a4e2 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/TaxonomyBackend.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/TaxonomyBackend.java @@ -180,9 +180,8 @@ public class TaxonomyBackend extends CachableInterface implements IExternalServi try { String url = "https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=" + miriamData.getResource(); - logger.debug(url); String page = getWebPageContent(url); - Pattern idPattern = Pattern.compile("<h2>([A-Za-z0-9\\ \\.]+)</h2>"); + Pattern idPattern = Pattern.compile("<title>Taxonomy browser \\(([A-Za-z0-9\\ \\.]+)\\)</title>"); Matcher matcher = idPattern.matcher(page); if (!matcher.find()) { logger.warn("Unknown organism: " + miriamData); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/TaxonomyBackendTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/TaxonomyBackendTest.java index 3c8b521e144a99725ba4a3d7910c72872828b5dc..a694153509919fc90df21c47f164e66b84715a75 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/TaxonomyBackendTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/TaxonomyBackendTest.java @@ -27,96 +27,96 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; public class TaxonomyBackendTest extends AnnotationTestFunctions { - Logger logger = Logger.getLogger(TaxonomyBackendTest.class); - - @Autowired - TaxonomyBackend taxonomyBackend; - - GeneralCacheInterface cache; - - @Before - public void setUp() throws Exception { - cache = taxonomyBackend.getCache(); - // exclude first cached value - taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); - } - - @After - public void tearDown() throws Exception { - taxonomyBackend.setCache(cache); - } - - @Test - public void testByName() throws Exception { - try { - MiriamData md = taxonomyBackend.getByName("Human"); - assertTrue(md.equals(TaxonomyBackend.HUMAN_TAXONOMY)); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByComplexName() throws Exception { - try { - assertNotNull(taxonomyBackend.getByName("Aplysia californica (Sea Hare)")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByCommonName() throws Exception { - try { - assertNotNull(taxonomyBackend.getByName("Rat")); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByEmptyName() throws Exception { - try { - assertNull(taxonomyBackend.getByName(null)); - assertNull(taxonomyBackend.getByName("")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByAbreviationName() throws Exception { - try { - taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); - assertNotNull(taxonomyBackend.getByName("C. elegans")); - taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); - assertNotNull(taxonomyBackend.getByName("D. sechellia")); - taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); - assertNotNull(taxonomyBackend.getByName("P. pacificus")); - taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); - assertNotNull(taxonomyBackend.getByName("T. castaneum")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testGetName() throws Exception { - try { - String name = taxonomyBackend.getNameForTaxonomy(new MiriamData(MiriamType.TAXONOMY, "9606")); - assertTrue(name.contains("Homo sapiens")); - assertNotNull(taxonomyBackend.getNameForTaxonomy(new MiriamData(MiriamType.TAXONOMY, "9605"))); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + Logger logger = Logger.getLogger(TaxonomyBackendTest.class); + + @Autowired + TaxonomyBackend taxonomyBackend; + + GeneralCacheInterface cache; + + @Before + public void setUp() throws Exception { + cache = taxonomyBackend.getCache(); + // exclude two first cached values + taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 2)); + } + + @After + public void tearDown() throws Exception { + taxonomyBackend.setCache(cache); + } + + @Test + public void testByName() throws Exception { + try { + MiriamData md = taxonomyBackend.getByName("Human"); + assertTrue(md.equals(TaxonomyBackend.HUMAN_TAXONOMY)); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByComplexName() throws Exception { + try { + assertNotNull(taxonomyBackend.getByName("Aplysia californica (Sea Hare)")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByCommonName() throws Exception { + try { + assertNotNull(taxonomyBackend.getByName("Rat")); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByEmptyName() throws Exception { + try { + assertNull(taxonomyBackend.getByName(null)); + assertNull(taxonomyBackend.getByName("")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByAbreviationName() throws Exception { + try { + taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); + assertNotNull(taxonomyBackend.getByName("C. elegans")); + taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); + assertNotNull(taxonomyBackend.getByName("D. sechellia")); + taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); + assertNotNull(taxonomyBackend.getByName("P. pacificus")); + taxonomyBackend.setCache(new GeneralCacheWithExclusion(cache, 1)); + assertNotNull(taxonomyBackend.getByName("T. castaneum")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetName() throws Exception { + try { + String name = taxonomyBackend.getNameForTaxonomy(new MiriamData(MiriamType.TAXONOMY, "9606")); + assertTrue(name.contains("Homo sapiens")); + assertNotNull(taxonomyBackend.getNameForTaxonomy(new MiriamData(MiriamType.TAXONOMY, "9605"))); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } @Test public void testGetNameWhenProblemWithDb() throws Exception { @@ -137,128 +137,129 @@ public class TaxonomyBackendTest extends AnnotationTestFunctions { } } - @Test - public void testGetNameForInvalidTax() throws Exception { - try { - String name = taxonomyBackend.getNameForTaxonomy(new MiriamData(MiriamType.TAXONOMY, "-a-")); - assertNull(name); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testGetNameForInvalidInputData() throws Exception { - try { - String name = taxonomyBackend.getNameForTaxonomy(null); - assertNull(name); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByName2() throws Exception { - try { - MiriamData md = taxonomyBackend.getByName("homo sapiens"); - assertTrue(md.equals(TaxonomyBackend.HUMAN_TAXONOMY)); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByName3() throws Exception { - try { - MiriamData md = taxonomyBackend.getByName("bla bla kiwi"); - assertNull(md); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByMusMusculusName() throws Exception { - try { - MiriamData md = taxonomyBackend.getByName("Mus musculus"); - assertTrue(md.equals(new MiriamData(MiriamType.TAXONOMY, "10090"))); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testByMouseName() throws Exception { - try { - MiriamData md = taxonomyBackend.getByName("Mouse"); - assertTrue(md.equals(new MiriamData(MiriamType.TAXONOMY, "10090"))); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testRefreshCacheQuery() throws Exception { - try { - String result = taxonomyBackend.refreshCacheQuery(TaxonomyBackend.TAXONOMY_CACHE_PREFIX + "homo sapiens"); - assertNotNull(result); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testRefreshCacheQuery2() throws Exception { - try { - String result = taxonomyBackend.refreshCacheQuery(TaxonomyBackend.TAXONOMY_NAME_CACHE_PREFIX + TaxonomyBackend.HUMAN_TAXONOMY.getResource()); - assertNotNull(result); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testRefreshCacheQuery3() throws Exception { - try { - String result = taxonomyBackend.refreshCacheQuery("http://google.pl/"); - assertNotNull(result); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testRefreshInvalidCacheQuery() throws Exception { - try { - taxonomyBackend.refreshCacheQuery("unk_query"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Don't know what to")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testRefreshInvalidCacheQuery2() throws Exception { - try { - taxonomyBackend.refreshCacheQuery(new Object()); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Don't know what to")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testGetNameForInvalidTax() throws Exception { + try { + String name = taxonomyBackend.getNameForTaxonomy(new MiriamData(MiriamType.TAXONOMY, "-a-")); + assertNull(name); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetNameForInvalidInputData() throws Exception { + try { + String name = taxonomyBackend.getNameForTaxonomy(null); + assertNull(name); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByName2() throws Exception { + try { + MiriamData md = taxonomyBackend.getByName("homo sapiens"); + assertTrue(md.equals(TaxonomyBackend.HUMAN_TAXONOMY)); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByName3() throws Exception { + try { + MiriamData md = taxonomyBackend.getByName("bla bla kiwi"); + assertNull(md); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByMusMusculusName() throws Exception { + try { + MiriamData md = taxonomyBackend.getByName("Mus musculus"); + assertTrue(md.equals(new MiriamData(MiriamType.TAXONOMY, "10090"))); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testByMouseName() throws Exception { + try { + MiriamData md = taxonomyBackend.getByName("Mouse"); + assertTrue(md.equals(new MiriamData(MiriamType.TAXONOMY, "10090"))); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testRefreshCacheQuery() throws Exception { + try { + String result = taxonomyBackend.refreshCacheQuery(TaxonomyBackend.TAXONOMY_CACHE_PREFIX + "homo sapiens"); + assertNotNull(result); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testRefreshCacheQuery2() throws Exception { + try { + String result = taxonomyBackend + .refreshCacheQuery(TaxonomyBackend.TAXONOMY_NAME_CACHE_PREFIX + TaxonomyBackend.HUMAN_TAXONOMY.getResource()); + assertNotNull(result); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testRefreshCacheQuery3() throws Exception { + try { + String result = taxonomyBackend.refreshCacheQuery("http://google.pl/"); + assertNotNull(result); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testRefreshInvalidCacheQuery() throws Exception { + try { + taxonomyBackend.refreshCacheQuery("unk_query"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Don't know what to")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testRefreshInvalidCacheQuery2() throws Exception { + try { + taxonomyBackend.refreshCacheQuery(new Object()); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Don't know what to")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } @Test public void testRefreshCacheQueryNotAvailable() throws Exception { @@ -278,15 +279,15 @@ public class TaxonomyBackendTest extends AnnotationTestFunctions { } } - @Test - public void testStatus() throws Exception { - try { - assertEquals(ExternalServiceStatusType.OK, taxonomyBackend.getServiceStatus().getStatus()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testStatus() throws Exception { + try { + assertEquals(ExternalServiceStatusType.OK, taxonomyBackend.getServiceStatus().getStatus()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } @Test public void testSimulateDownStatus() throws Exception { diff --git a/checkstyle.xml b/checkstyle.xml index cf13403c2f932c8bf48a761e81ef0b95ba94ae76..b4ae1463262e7beed047c9c943c4a4abc7d7b2f1 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> -<!-- - This configuration file was written by the eclipse-cs plugin configuration editor +<!-- + This configuration file was written by the eclipse-cs plugin configuration editor --> -<!-- - Checkstyle-Configuration: MapViewer checkstyle - Description: none +<!-- + Checkstyle-Configuration: MapViewer checkstyle + Description: none --> <module name="Checker"> <property name="severity" value="warning"/> diff --git a/converter-CellDesigner/.settings/org.eclipse.wst.common.component b/converter-CellDesigner/.settings/org.eclipse.wst.common.component index 21d6d142e0167ea7171a1ec7140e8ab92072fcde..547a0c08e066ce2bbb19695db30871b995ff9509 100644 --- a/converter-CellDesigner/.settings/org.eclipse.wst.common.component +++ b/converter-CellDesigner/.settings/org.eclipse.wst.common.component @@ -1,6 +1,5 @@ -<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> - <wb-module deploy-name="MapViewer-converter-CellDesigner"> - <wb-resource deploy-path="/" source-path="/src/main/java"/> - <wb-resource deploy-path="/" source-path="/src/main/resources"/> - </wb-module> -</project-modules> +<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> + <wb-module deploy-name="MapViewer-converter-CellDesigner"> + <wb-resource deploy-path="/" source-path="/src/main/java"/> + </wb-module> +</project-modules> diff --git a/converter-graphics/.settings/org.eclipse.wst.common.component b/converter-graphics/.settings/org.eclipse.wst.common.component index 26ce8011de8cd0cfe1fc284ae00b6fd6876cde02..2faa3f2b4556a750b4d43d4248dd12fe2fcfb759 100644 --- a/converter-graphics/.settings/org.eclipse.wst.common.component +++ b/converter-graphics/.settings/org.eclipse.wst.common.component @@ -1,6 +1,5 @@ -<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> - <wb-module deploy-name="MapViewer-converter-graphics"> - <wb-resource deploy-path="/" source-path="/src/main/java"/> - <wb-resource deploy-path="/" source-path="/src/main/resources"/> - </wb-module> -</project-modules> +<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> + <wb-module deploy-name="MapViewer-converter-graphics"> + <wb-resource deploy-path="/" source-path="/src/main/java"/> + </wb-module> +</project-modules> diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh index 1a6936e6fc9fa7c2cd17bd88b313eb2a8acc7a19..654df170b9de5f453019e137908583eb9650cc6b 100755 --- a/debian/create-debian-pkg.sh +++ b/debian/create-debian-pkg.sh @@ -9,6 +9,8 @@ versionCompLt() { [ "$1" = "$2" ] && return 1 || versionCompLte $1 $2 } +# file with bash code generating DB schema diffs for different versions +dbschemadiff=management_scripts/db_schema_and_diff.sh #Where source file of the debian package should be placed SRC_DIR=debian/src @@ -54,22 +56,9 @@ cp debian/scripts/common.sh $SRC_DIR/ #copy changelog file cp CHANGELOG $ROOT_DIR/debian/template/changelog -#this variable will contain all available versions of the package -versions=(); - -#this is current (latest) version of the package -current_version=-1; - -#find all available versions - -for version in `ls $DB_SCHEMA_DIR | sort -V`; -do - if [ -d "$DB_SCHEMA_DIR/$version" ] - then - versions+=($version); - current_version=$version; - fi -done +# set $versions and $current_version; generate upgrade scripts in SRC_DIR +DBSCRIPT_DEST_DIR=$SRC_DIR +source $dbschemadiff echo "Current version: " $current_version @@ -81,47 +70,6 @@ then exit 1; fi -#-------------------------------------- -# GENERATE DB schemas and diff files -#-------------------------------------- - -#last version (used for generating db diff files) -last_version=-1; -for version_A in ${versions[*]} -do - #main update file (used to create this version - it's a diff - #between base.sql and current version) - update_file=$SRC_DIR/db_0_to_$current_version".sql"; - - #now iterate through all versions - for file in `ls $DB_SCHEMA_DIR/$version_A | sort -V`; - do - if [ -f "$DB_SCHEMA_DIR/$version_A/$file" ] - then - #add differemce tp current db schema diff - printf "\n\n-- UPDATE $version_A/$file\n\n" >>$update_file; - cat $DB_SCHEMA_DIR/$version_A/$file >> $update_file; - - #and now iterate again through all versions to add diffs - #between previous versions and current one - for version_B in ${versions[*]} - do - #update from version_B should contain all db changes that appeard - #after #version_B (so version_A must be later) - if versionCompLt $version_B $version_A - then - upd_file=$SRC_DIR/db_"$version_B"_to_$current_version".sql"; - printf "\n\n-- UPDATE $version_A/$file\n\n" >>$upd_file; - cat $DB_SCHEMA_DIR/$version_A/$file >> $upd_file; - - fi - done - fi - done - - last_version=$version_A -done - #------------------------------------------ # Now we have all db schema diff files. Let's start preparing # debian package diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index b533358e8ae4ea67767851406e6567696d52e951..97e626f51715551c80431c453095d07363e8a540 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -1178,7 +1178,7 @@ ServerConnector.getReactions = function (params) { var filterParams = { id: params.ids, columns: params.columns, - participantId: params.participantId + participantId: params.participantId, }; return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index 2746a2973a215bca9d456dae973d620111695edd..c5c7167867ed2a964ecb728470c5536619155de5 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -638,8 +638,9 @@ AbstractCustomMap.prototype._showSelectedLayout = function (layoutId, index, len return Promise.each(layoutReactions, function (layoutReaction) { if (layoutReaction.getModelId() === self.getId()) { return self.getModel().getReactionById(layoutReaction.getId()).then(function (reactionData) { + var surface; var element = new IdentifiedElement(reactionData); - var surface = new ReactionSurface({ + return ReactionSurface.create({ layoutReaction: layoutReaction, reaction: reactionData, map: self, @@ -649,10 +650,11 @@ AbstractCustomMap.prototype._showSelectedLayout = function (layoutId, index, len return self.getTopMap().callListeners("onBioEntityClick", element); }], customized: (length === 1) + }).then(function(result){ + surface = result; + self.selectedLayoutOverlays[layoutId].push(surface); + surface.show(); }); - - self.selectedLayoutOverlays[layoutId].push(surface); - surface.show(); }); } }); diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 6a5f9e5d47e7e78847d06badd4899f3a55596478..b884e97df68cb43985ae0aded88aae7a19b347d9 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -1303,7 +1303,7 @@ CustomMap.prototype.createSurfaceForDbOverlay = function (element, dbOverlay) { }); } else if (element.getType() === "REACTION") { return map.getModel().getReactionById(element.getId()).then(function (reactionData) { - var result = new ReactionSurface({ + return ReactionSurface.create({ reaction: reactionData, map: map, customized: true, @@ -1313,10 +1313,12 @@ CustomMap.prototype.createSurfaceForDbOverlay = function (element, dbOverlay) { }, function () { return self.callListeners("onBioEntityClick", element); }] + }).then(function(surface){ + result = surface; + result.show(); + dbOverlay.mapOverlays[element.getType()][element.getId()] = result; + return result; }); - result.show(); - dbOverlay.mapOverlays[element.getType()][element.getId()] = result; - return result; }); } else if (element.getType() === "POINT") { throw new Error("Not implemented"); diff --git a/frontend-js/src/main/js/map/surface/ReactionSurface.js b/frontend-js/src/main/js/map/surface/ReactionSurface.js index de28af972e8ff53628b7301cfbb98c14cf903edc..c858a0a739bd15023e8875f5aa059d96fb185d05 100644 --- a/frontend-js/src/main/js/map/surface/ReactionSurface.js +++ b/frontend-js/src/main/js/map/surface/ReactionSurface.js @@ -11,7 +11,7 @@ var IdentifiedElement = require('../data/IdentifiedElement'); /** * Class representing overlay of the reaction on the map relevant for a specific * layout. - * + * * @param layoutReaction * {@link LayoutReaction} for which overlay is created * @param reactionData @@ -39,7 +39,6 @@ function ReactionSurface(params) { if (overlayData.width) { this.width = overlayData.width; } - color = functions.overlayToColor(overlayData); } if (color === undefined) { color = "#0000FF"; @@ -58,11 +57,11 @@ ReactionSurface.prototype.constructor = ReactionSurface; /** * Returns {@link google.maps.Bounds bounds} of all google maps elements * included in the object. - * + * * @returns {@link google.maps.Bounds bounds} of all google maps elements * included in the object */ -ReactionSurface.prototype.getBounds = function() { +ReactionSurface.prototype.getBounds = function () { var bounds = new google.maps.LatLngBounds(); for (var i = 0; i < this.getGoogleMapObjects().length; i++) { @@ -74,23 +73,23 @@ ReactionSurface.prototype.getBounds = function() { return bounds; }; -ReactionSurface.prototype.setCustomized = function(customized) { +ReactionSurface.prototype.setCustomized = function (customized) { this.customized = customized; }; /** * Sets color to be used by the reaction overlay visualization when visualized * in customized mode. - * + * * @param color * new color value */ -ReactionSurface.prototype.setColor = function(color) { +ReactionSurface.prototype.setColor = function (color) { this._color = color; var gmapObjects = this.getGoogleMapObjects(); for (var i = 0; i < gmapObjects.length; i++) { gmapObjects[i].setOptions({ - strokeColor : color, + strokeColor: color, }); } this.customized = true; @@ -99,11 +98,11 @@ ReactionSurface.prototype.setColor = function(color) { /** * Sets width of line to be used by the reaction overlay visualization when * visualized in customized mode. - * + * * @param width * new width value */ -ReactionSurface.prototype.setWidth = function(width) { +ReactionSurface.prototype.setWidth = function (width) { if (width !== undefined || width !== null) { this.width = width; } else { @@ -114,19 +113,19 @@ ReactionSurface.prototype.setWidth = function(width) { /** * Returns color that should be used when visualized in customized mode. - * + * * @returns color that should be used when visualized in customized mode. */ -ReactionSurface.prototype.getColor = function() { +ReactionSurface.prototype.getColor = function () { return this._color; }; /** * Returns width that should be used when visualized in customized mode. - * + * * @returns width that should be used when visualized in customized mode. */ -ReactionSurface.prototype.getWidth = function() { +ReactionSurface.prototype.getWidth = function () { return this.width; }; @@ -138,7 +137,7 @@ ReactionSurface.prototype.getWidth = function() { * of reaction should turn to some default mode where we know that reaction is * highlighted, but we have no more information. In this way user will know that * he should investigate the reaction manually. - * + * * @param startX * see {AliasSurface} class for details, in this implementation the * only important information is that when there are more than one @@ -150,7 +149,7 @@ ReactionSurface.prototype.getWidth = function() { * layout visualized at least one of the two parameters (startX,endX) * will differ from {0.0, 1.0} values */ -ReactionSurface.prototype.setBoundsForAlias = function(startX, endX) { +ReactionSurface.prototype.setBoundsForAlias = function (startX, endX) { if (this.isCustomized() && (startX > 0 || endX < 1)) { this.changedToDefault(); } else if (!this.isCustomized() && (startX <= 0 && endX >= 1)) { @@ -162,11 +161,11 @@ ReactionSurface.prototype.setBoundsForAlias = function(startX, endX) { * Changes visualization of the ReactionSurface to default mode where we mark * reaction as highlighted, but we skip customized reaction layout data. */ -ReactionSurface.prototype.changedToDefault = function() { +ReactionSurface.prototype.changedToDefault = function () { for (var i = 0; i < this.getGoogleMapObjects().length; i++) { this.getGoogleMapObjects()[i].setOptions({ - strokeColor : "#0000FF", - strokeWeight : 5, + strokeColor: "#0000FF", + strokeWeight: 5, }); } this.customized = false; @@ -179,8 +178,8 @@ ReactionSurface.prototype.changedToDefault = function() { ReactionSurface.prototype.changedToCustomized = function() { for (var i = 0; i < this.getGoogleMapObjects().length; i++) { this.getGoogleMapObjects()[i].setOptions({ - strokeColor : this.getColor(), - strokeWeight : this.getWidth(), + strokeColor: this.getColor(), + strokeWeight: this.getWidth(), }); } this.customized = true; @@ -188,7 +187,7 @@ ReactionSurface.prototype.changedToCustomized = function() { /** * Creates {google.maps.Polyline} from input data. - * + * * @param line * raw data about line taken from server * @param color @@ -199,41 +198,41 @@ ReactionSurface.prototype.changedToCustomized = function() { * {google.maps.Map} where line should be visualized * @returns {google.maps.Polyline} from input data */ -ReactionSurface.createLine = function(line, color, width, map) { +ReactionSurface.createLine = function (line, color, width, map) { var pointA = new google.maps.Point(line.start.x, line.start.y); var pointB = new google.maps.Point(line.end.x, line.end.y); var latLngA = map.fromPointToLatLng(pointA); var latLngB = map.fromPointToLatLng(pointB); - var path = [ latLngA, latLngB ]; + var path = [latLngA, latLngB]; var googleLine = new google.maps.Polyline({ - strokeColor : color, - strokeOpacity : 1.0, - strokeWeight : width, - path : path, - map : map.map + strokeColor: color, + strokeOpacity: 1.0, + strokeWeight: width, + path: path, + map: map.map }); return googleLine; }; /** * Returns {@link Reaction} data for this marker. - * + * * @returns {@link Reaction} data for this marker */ -ReactionSurface.prototype.getReactionData = function() { +ReactionSurface.prototype.getReactionData = function () { return this.reactionData; }; -ReactionSurface.prototype.getId = function() { +ReactionSurface.prototype.getId = function () { return this._id; }; -ReactionSurface.prototype.setId = function(id) { +ReactionSurface.prototype.setId = function (id) { this._id = id; }; -ReactionSurface.prototype.setReactionData = function(value) { +ReactionSurface.prototype.setReactionData = function (value) { if (value === undefined || value === null) { throw new Error("Reaction must be defined"); } @@ -241,11 +240,11 @@ ReactionSurface.prototype.setReactionData = function(value) { this.setId(value.getId()); }; -ReactionSurface.prototype.isCustomized = function() { +ReactionSurface.prototype.isCustomized = function () { return this.customized; }; -ReactionSurface.prototype.init = function() { +ReactionSurface.prototype.init = function () { var i; var line; var googleLine; @@ -269,4 +268,24 @@ ReactionSurface.prototype.init = function() { } }; +ReactionSurface.create = function (params) { + var overlayData = params.layoutReaction; + + var promise = Promise.resolve(params.color); + if (overlayData !== undefined && overlayData !== null) { + if (overlayData.width) { + this.width = overlayData.width; + } + promise = functions.overlayToColor(overlayData); + } + return promise.then(function (color) { + logger.debug(color); + if (color === undefined) { + color = "#0000FF"; + } + params.color = color; + return new ReactionSurface(params); + }); +}; + module.exports = ReactionSurface; diff --git a/frontend-js/src/test/js/map/data/MapModel-test.js b/frontend-js/src/test/js/map/data/MapModel-test.js index 267e598a481881805dfd6bb0ae5f51010faa8658..46f6ae592091ffdb458c9267aaa878ccdaecac21 100644 --- a/frontend-js/src/test/js/map/data/MapModel-test.js +++ b/frontend-js/src/test/js/map/data/MapModel-test.js @@ -1,6 +1,6 @@ "use strict"; -require("../../mocha-config.js"); +require("../../mocha-config"); var IdentifiedElement = require('../../../../main/js/map/data/IdentifiedElement'); var LayoutData = require('../../../../main/js/map/data/LayoutData'); diff --git a/frontend-js/src/test/js/map/surface/ReactionSurface-test.js b/frontend-js/src/test/js/map/surface/ReactionSurface-test.js index 724cf409071a95550ce673f5177953ec043e2b78..c2e3290e116151eca5a8039557f3a8f1ef916ea1 100644 --- a/frontend-js/src/test/js/map/surface/ReactionSurface-test.js +++ b/frontend-js/src/test/js/map/surface/ReactionSurface-test.js @@ -1,22 +1,21 @@ "use strict"; +require("../../mocha-config"); var ReactionSurface = require('../../../../main/js/map/surface/ReactionSurface'); var assert = require('assert'); var logger = require('../../logger'); -describe('ReactionSurface', function() { - it("Constructor", function() { +describe('ReactionSurface', function () { + it("Constructor", function () { var map = helper.createAbstractCustomMap(); var reaction = helper.createReaction(map); - var layoutReaction = helper.createLayoutReaction(reaction); var reactionOverlay = new ReactionSurface({ - overlayData : layoutReaction, - reaction : reaction, - map : map, - customized : false + reaction: reaction, + map: map, + customized: false }); assert.ok(reactionOverlay.getGoogleMapObjects().length > 0); @@ -26,19 +25,41 @@ describe('ReactionSurface', function() { assert.ok(reactionOverlay.getReactionData()); assert.ok(reactionOverlay.getCustomMap()); assert.ok(reactionOverlay.getId()); + assert.ok(typeof reactionOverlay.getColor() === "string"); + }); + it("create", function () { + var map = helper.createAbstractCustomMap(); + var reaction = helper.createReaction(map); + var layoutReaction = helper.createLayoutReaction(reaction); + return ReactionSurface.create({ + layoutReaction: layoutReaction, + reaction: reaction, + map: map, + customized: false + }).then(function(reactionOverlay){ + + assert.ok(reactionOverlay.getGoogleMapObjects().length > 0); + assert.ok(reactionOverlay.getColor()); + assert.ok(reactionOverlay.getWidth()); + assert.ok(reactionOverlay.getBounds()); + assert.ok(reactionOverlay.getReactionData()); + assert.ok(reactionOverlay.getCustomMap()); + assert.ok(reactionOverlay.getId()); + assert.ok(typeof reactionOverlay.getColor() === "string"); + }); }); - it("show", function() { + it("show", function () { var map = helper.createCustomMap(); var reaction = helper.createReaction(map); var layoutReaction = helper.createLayoutReaction(reaction); var reactionOverlay = new ReactionSurface({ - overlayData : layoutReaction, - reaction : reaction, - map : map, - customized : false + overlayData: layoutReaction, + reaction: reaction, + map: map, + customized: false }); reactionOverlay.hide(); @@ -61,10 +82,10 @@ describe('ReactionSurface', function() { var layoutReaction = helper.createLayoutReaction(reaction); var reactionOverlay = new ReactionSurface({ - overlayData : layoutReaction, - reaction : reaction, - map : map, - customized : false + overlayData: layoutReaction, + reaction: reaction, + map: map, + customized: false }); reactionOverlay.changedToCustomized(); @@ -76,13 +97,13 @@ describe('ReactionSurface', function() { var map = helper.createAbstractCustomMap(); var line = ReactionSurface.createLine({ - start : { - x : 0, - y : 10 + start: { + x: 0, + y: 10 }, - end : { - x : 100, - y : 100 + end: { + x: 100, + y: 100 }, }, "#000000", 3, map); diff --git a/management_scripts/db_schema_and_diff.sh b/management_scripts/db_schema_and_diff.sh new file mode 100644 index 0000000000000000000000000000000000000000..c6c0783e00fec80662cdb30d86aec5ed637e53a2 --- /dev/null +++ b/management_scripts/db_schema_and_diff.sh @@ -0,0 +1,77 @@ +# shell snippet which extracts all available MINERVA versions from +# subdirectories available in DB_SCHEMA_DIR (typically +# `persist/src/db`) and generates database upgrade scripts (diff +# files) + +# Precondition: the following variables have to be correctly initialised +# * DB_SCHEMA_DIR set to the directory containing database initialisation and upgrade sql commands +# * DBSCRIPT_DEST_DIR set to the directory that will be populated with database upgrade scripts + +# Postcondition: +# * versions is set to the available MINERVA versions (bash array) +# * current_version is set to the latest available version +# * DBSCRIPT_DEST_DIR contains script to initialise the database from any version to the current version + + +#this variable will contain all available versions of the package +versions=(); + +#this is current (latest) version of the package +current_version=-1; + +#find all available versions + +for version in `ls "$DB_SCHEMA_DIR" | sort -V`; +do + if [ -d "$DB_SCHEMA_DIR/$version" ] + then + versions+=($version); + current_version=$version; + fi +done + +#-------------------------------------- +# GENERATE DB schemas and diff files +#-------------------------------------- + +versionCompLte() { + [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] +} + + +versionCompLt() { + [ "$1" = "$2" ] && return 1 || versionCompLte $1 $2 +} + +#last version (used for generating db diff files) +for version_A in ${versions[*]} +do + #main update file (used to create this version - it's a diff + #between base.sql and current version) + update_file="$DBSCRIPT_DEST_DIR/db_0_to_${current_version}.sql"; + + #now iterate through all versions + for file in `ls "$DB_SCHEMA_DIR/$version_A" | sort -V`; + do + if [ -f "$DB_SCHEMA_DIR/$version_A/$file" ] + then + #add difference to current db schema diff + printf "\n\n-- UPDATE $version_A/$file\n\n" >> "$update_file"; + cat "$DB_SCHEMA_DIR/$version_A/$file" >> "$update_file"; + + #and now iterate again through all versions to add diffs + #between previous versions and current one + for version_B in ${versions[*]} + do + #update from version_B should contain all db changes that appeared + #after #version_B (so version_A must be later) + if versionCompLt $version_B $version_A + then + upd_file="$DBSCRIPT_DEST_DIR/db_${version_B}_to_${current_version}.sql"; + printf "\n\n-- UPDATE $version_A/$file\n\n" >> "$upd_file"; + cat "$DB_SCHEMA_DIR/$version_A/$file" >> "$upd_file"; + fi + done + fi + done +done diff --git a/persist/src/db/11.0.4/fix_db_20171109.sql b/persist/src/db/11.0.4/fix_db_20171109.sql new file mode 100644 index 0000000000000000000000000000000000000000..a33b6ad89d4881c84fb355b8c56d309760e66b70 --- /dev/null +++ b/persist/src/db/11.0.4/fix_db_20171109.sql @@ -0,0 +1 @@ +-- empty file to force directory to be commited to git repo diff --git a/rpm/INSTALL.rst b/rpm/INSTALL.rst new file mode 100644 index 0000000000000000000000000000000000000000..11116e05510ccd5a849e643b27b14355ff8d7acf --- /dev/null +++ b/rpm/INSTALL.rst @@ -0,0 +1,120 @@ +MINERVA installation instructions using RPM Package Manager +=========================================================== + +These instructions guide you through the installation process of +`MINERVA <https://git-r3lab.uni.lu/piotr.gawron/minerva>`_ on Red Hat +Enterprise Linux 7 or CentOS 7. The server will also host the database +required for the functioning of MINERVA. + +.. note:: + + Content visualization of MINERVA platform is supported by Google + Maps API. Users of MINERVA platform are obliged to comply with the + `Google Maps/Google Earth APIs Terms of Service + <https://www.google.com/intl/en-US_US/help/terms_maps.html>`_. + + +Overview +-------- + +The main steps are + +* Install `PostgreSQL <https://www.postgresql.org/>`_ and set up a + database. +* Install and configure `Apache Tomcat <https://tomcat.apache.org/>`_. +* Install the MINERVA RPM. + + +PostgreSQL +---------- + +Install PostgreSQL and initialise it with + +.. code:: shell + + yum install -y postgresql-server + postgresql-setup initdb + +Ensure that the database authentication on IPv4 on ``localhost`` is +done with md5-based passwords by adding the following line to +``/var/lib/pgsql/data/pg_hba.conf`` + +.. code:: + + host all all 127.0.0.1/32 md5 + + +Enable and start postgresql + +.. code:: shell + + systemctl enable postgresql + systemctl start postgresql + +Create the MINERVA database user and the database + +.. code:: shell + + su - postgres -c "createuser -d -r -s map_viewer" + su - postgres -c "echo \"ALTER USER map_viewer WITH PASSWORD '123qweasdzxc';\"| psql" + su - postgres -c "createdb -O map_viewer map_viewer" + +.. warning:: + + Currently the password for the database user ``map_viewer`` is + hardcoded, therefore make sure the database cannot be accessed + from distrusted hosts. + + +Apache Tomcat +------------- + +Install and enable (don't start yet) Apache Tomcat with + +.. code:: shell + + yum install -y tomcat + systemctl enable tomcat + +In ``/etc/sysconfig/tomcat``, adjust the memory settings, e.g. + +.. code:: + + JAVA_OPTS="-Xms2048M -Xmx4096M" + +Make sure to open the port (by default port 8080) to allow incoming +connections, e.g. using ``firewalld`` this can be accomplished with + +.. code:: shell + + firewall-cmd --permanent --zone=public --add-port=8080/tcp + +.. warning:: + + Currently the administrator password of MINERVA is hardcoded, + therefore make sure the MINERVA cannot be accessed from distrusted + hosts until the password was changed. + +MINERVA +------- + +Install MINERVA using ``yum`` + +.. code:: shell + + yum install -y minerva-X.Y.Z-1.el7.centos.noarch.rpm + +and start tomcat + +.. code:: shell + + systemctl start tomcat + +Now point your browser to the newly installed service, e.g. on a local +network this could be `<http://192.168.0.42:8080/minerva/>`_. + +.. warning:: + + This way of installing MINERVA does **not** ensure that security + updates are installed with ``yum update``, therefore you have to + establish a process to install such updates manually. diff --git a/rpm/buildrpm.sh b/rpm/buildrpm.sh new file mode 100755 index 0000000000000000000000000000000000000000..eb3166272ad7a7d7dab709facd55f6340cfe7f32 --- /dev/null +++ b/rpm/buildrpm.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +MINERVA_SRC_DIR="$(dirname "$(dirname "$0")")" + +# where generated files will be written +RPMBUILD_TEMP="${RPMBUILD_TEMP:-$MINERVA_SRC_DIR/rpm/rpmbuildtemp}" + +if [[ "$RPMBUILD_TEMP" =~ ' ' ]]; then + echo "RPMBUILD_TEMP contains whitespace: '$RPMBUILD_TEMP'" + echo "This is not allowed. Please provide a different directory to create the RPM with" + echo " RPMBUILD_TEMP=/path/without/whitespace/ \"$0\"" + exit 1 +fi + +# current date (for automatic changelog) +CURDATE=$(date +"%a %b %d %Y") + +# file that should be deployed on tomcat +TOMCAT_FILE="$MINERVA_SRC_DIR/web/target/web-1.0.war" + +# file with bash code generating DB schema diffs for different versions +dbschemadiff="$MINERVA_SRC_DIR/management_scripts/db_schema_and_diff.sh" + +# directory with database schema +DB_SCHEMA_DIR="$MINERVA_SRC_DIR/persist/src/db" + +# destination directory for database upgrade scripts +DBSCRIPT_DEST_DIR="$RPMBUILD_TEMP/BUILD/sql" + +# clean build directories +rm -rf "$RPMBUILD_TEMP" + +# create directory +mkdir -p "$RPMBUILD_TEMP/"{BUILD,SPECS} + +# copy war file and other files +cp "$TOMCAT_FILE" "$RPMBUILD_TEMP/BUILD/minerva.war" +cp "$MINERVA_SRC_DIR/README.md" "$MINERVA_SRC_DIR/CHANGELOG" "$MINERVA_SRC_DIR/rpm/INSTALL.rst" "$MINERVA_SRC_DIR/rpm/logrotate_minerva" "$RPMBUILD_TEMP/BUILD" + +mkdir -p "$DBSCRIPT_DEST_DIR" +# copy base sql schema +cp "$DB_SCHEMA_DIR/base.sql" "$DBSCRIPT_DEST_DIR/db_0.sql" + +# set $versions and $current_version; generate upgrade scripts in DBSCRIPT_DEST_DIR +source "$dbschemadiff" + +# create RPM spec file +cp "$MINERVA_SRC_DIR/rpm/minerva.spec.in" "$RPMBUILD_TEMP/SPECS/minerva.spec" +sed -i "s/__CURRENT_VERSION__/$current_version/g" "$RPMBUILD_TEMP/SPECS/minerva.spec" +sed -i "s/__DATE__/$CURDATE/g" "$RPMBUILD_TEMP/SPECS/minerva.spec" + +# build RPM +RPMBUILD_TEMP_ABS="$(readlink -f "$RPMBUILD_TEMP")" +echo "****** Building miverva $current_version RPM in $RPMBUILD_TEMP_ABS ****** " +set -x +rpmbuild -bb --define "_topdir $RPMBUILD_TEMP_ABS" "$RPMBUILD_TEMP_ABS/SPECS/minerva.spec" +set +x +echo "****** Finished building RPM ****** " diff --git a/rpm/logrotate_minerva b/rpm/logrotate_minerva new file mode 100644 index 0000000000000000000000000000000000000000..001adf1a0734bbf445836bf465621a49565c98c2 --- /dev/null +++ b/rpm/logrotate_minerva @@ -0,0 +1,10 @@ +/var/log/tomcat/minerva.txt { + copytruncate + size 32k + weekly + dateext + rotate 52 + compress + missingok + create 0640 tomcat tomcat +} diff --git a/rpm/minerva.spec.in b/rpm/minerva.spec.in new file mode 100644 index 0000000000000000000000000000000000000000..2edcdf292154137850bb234c22e28361f72d51ac --- /dev/null +++ b/rpm/minerva.spec.in @@ -0,0 +1,95 @@ +Name: minerva +Version: __CURRENT_VERSION__ +Release: 1%{?dist} +Summary: Platform for visualization and curation of molecular interaction networks + +License: AGPLv3 +URL: http://r3lab.uni.lu/web/minerva-website/ +Source0: https://git-r3lab.uni.lu/piotr.gawron/minerva/repository/archive.tar.gz?ref=v%{version} + +Requires: tomcat, postgresql +BuildArch: noarch + +%description +Web application for visualization, exploration and management of +molecular networks encoded in SBGN-compliant format. The resource is +used and managed via a webbrowser. + +%pre -p /bin/bash +# check that postgres is started and tomcat is stopped, otherwise abort installation/upgrade +if ! $(systemctl -q is-active postgresql); then + echo "postgresql not running, aborting installation/upgrade of minerva" >&2 + exit -1 +fi +if $(systemctl -q is-active tomcat); then + echo "tomcat is running, aborting installation/upgrade of minerva" >&2 + exit -1 +fi +# make sure the user `map_viewer` has the required permissions +attributes_map_viewer=$(su - postgres -c "psql -F $'\t' --no-align -t -c '\du map_viewer'" | cut -f 2) +if ! [[ $attributes_map_viewer == *"Superuser"* ]] || ! [[ $attributes_map_viewer == *"Create role"* ]] || ! [[ $attributes_map_viewer == *"Create DB"* ]]; then + echo "Postgres user map_viewer does not exist or does not have the required attributes." >&2 + echo "Make sure to create map_viewer with the permission 'Superuser, Create role, Create DB'." >&2 + echo "Attributes are: '$attributes_map_viewer'" >&2 + echo "Aborting installation/upgrade of minerva." >&2 + exit -1 +fi +# make sure the database map_viewer exists +if ! su - postgres -c "psql --dbname map_viewer -q -c '\q'" 2> /dev/null; then + echo "Database map_viewer does not exist, aborting installation/upgrade of minerva." >&2 + exit -1 +fi + +%preun -p /bin/bash +# save version information of the old package to make sure we run the correct DB-update script after installation +if [ $1 == 1 ]; then + mkdir -p %{_sharedstatedir}/rpm-state/%{name} + echo -n %{version} > %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION +fi + +%posttrans -p /bin/bash +LOGFILE=%{_localstatedir}/log/minerva-install.log +if [ -e %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION ]; then + OLD_VERSION=$(cat %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION) + echo $(date) "Upgrading minerva from $OLD_VERSION to %{version}" >> $LOGFILE + if [ ! -e %{_datadir}/%{name}/schema/db_${OLD_VERSION}_to_%{version}.sql ]; then + echo "ERROR: missing DB-update script %{_datadir}/%{name}/schema/db_${OLD_VERSION}_to_%{version}.sql" >&2 + exit -1 + fi + su - postgres -c "psql map_viewer -f %{_datadir}/%{name}/schema/db_${OLD_VERSION}_to_%{version}.sql" >> $LOGFILE 2>&1 + rm -f %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION + rmdir %{_sharedstatedir}/rpm-state/%{name} +else + echo $(date) "Installing minerva %{version}" >> $LOGFILE + if [ $(su - postgres -c "psql --dbname map_viewer -F $'\t' --no-align -t -c '\dt'" | wc -l) -gt 51 ]; then + echo "The database map_viewer is not empty, aborting initialisation of database." >&2 + echo "The database map_viewer is not empty, aborting initialisation of database." >> $LOGFILE + exit -1 + fi + # install base version of the framework + su - postgres -c "psql map_viewer -f %{_datadir}/%{name}/schema/db_0.sql" >> $LOGFILE 2>&1 + # install patch to current version + su - postgres -c "psql map_viewer -f %{_datadir}/%{name}/schema/db_0_to_%{version}.sql" >> $LOGFILE 2>&1 +fi + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/%{_datadir}/%{name}/schema +install -m 0644 sql/*.sql %{buildroot}/%{_datadir}/%{name}/schema +install -m 0644 %{name}.war %{buildroot}/%{_datadir}/%{name}/%{name}.war +mkdir -p %{buildroot}/%{_sysconfdir}/logrotate.d +install -m 0644 logrotate_minerva %{buildroot}/%{_sysconfdir}/logrotate.d/minerva +mkdir -p %{buildroot}/%{_sharedstatedir}/tomcat/webapps +ln -s %{_datadir}/%{name}/%{name}.war %{buildroot}/%{_sharedstatedir}/tomcat/webapps/ + +%files +%defattr(-,root,root,-) +%doc README.md CHANGELOG INSTALL.rst +%{_datadir}/%{name}/%{name}.war +%{_datadir}/%{name}/schema/* +%config(noreplace) %{_sysconfdir}/logrotate.d/minerva +%attr(-,tomcat,tomcat) %{_sharedstatedir}/tomcat/webapps/%{name}.war + +%changelog +* __DATE__ - %{version}-%{release} +- Automatically packaged