From a43c1cbca93a911a6940838b19044579d5758c01 Mon Sep 17 00:00:00 2001 From: Michael Heppler Date: Fri, 9 Aug 2019 16:13:10 -0400 Subject: [PATCH 01/35] Initial commit for new file pg preview tab [ref #3758, #6048] --- src/main/java/propertyFiles/Bundle.properties | 1 - .../file-download-button-fragment.xhtml | 29 --------- src/main/webapp/file.xhtml | 62 ++++++++++++++++--- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 178efecf03e..99f0293fff0 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1451,7 +1451,6 @@ file.restricted.success=Files "{0}" will be restricted once you click on the Sav file.download.header=Download file.download.subset.header=Download Data Subset file.preview=Preview: -file.previewMap=Preview Map:o file.fileName=File Name file.type.tabularData=Tabular Data file.originalChecksumType=Original File {0} diff --git a/src/main/webapp/file-download-button-fragment.xhtml b/src/main/webapp/file-download-button-fragment.xhtml index 0b22d5fbcc8..405bc8e0018 100644 --- a/src/main/webapp/file-download-button-fragment.xhtml +++ b/src/main/webapp/file-download-button-fragment.xhtml @@ -17,35 +17,6 @@ - - - - - diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 6afe37548d0..46b4b005291 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -349,12 +349,12 @@
- + @@ -362,12 +362,61 @@ + + + + + +
+
+
+ + + + + + + + +
+
+
+ +
+ + + + + + + + + +
+ +
+ +
+ + +
+ +
+ + - +
+
@@ -541,14 +589,8 @@
- - - - Coming soon... - - +
From 4255f3feb277f547c4c560a6877452e3f202c068 Mon Sep 17 00:00:00 2001 From: Michael Heppler Date: Mon, 12 Aug 2019 12:54:54 -0400 Subject: [PATCH 02/35] Added TODO comments outlining design/dev remaining tasks [ref #6048, #3758] --- src/main/webapp/file.xhtml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 46b4b005291..0742a83b2c1 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -385,21 +385,30 @@
- + + + + - +
- + + + + + + +
From e9711526105236c0d9e421ea4f6d92782fcf5143 Mon Sep 17 00:00:00 2001 From: Danny Brooke Date: Tue, 1 Oct 2019 13:59:51 -0400 Subject: [PATCH 03/35] added some content and some stubs for future content --- doc/sphinx-guides/source/admin/external-tools.rst | 12 ++++++++++++ doc/sphinx-guides/source/admin/integrations.rst | 2 +- doc/sphinx-guides/source/user/dataset-management.rst | 10 +++++++--- doc/sphinx-guides/source/user/find-use-data.rst | 8 +++++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/doc/sphinx-guides/source/admin/external-tools.rst b/doc/sphinx-guides/source/admin/external-tools.rst index 6054334e4a6..26663da1e13 100644 --- a/doc/sphinx-guides/source/admin/external-tools.rst +++ b/doc/sphinx-guides/source/admin/external-tools.rst @@ -37,6 +37,8 @@ In the curl command below, replace the placeholder "fabulousFileTool.json" place curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools --upload-file fabulousFileTool.json +TBD, If you'd like to allow the external tool to be used in previews on the file page... + Listing All External Tools in Dataverse +++++++++++++++++++++++++++++++++++++++ @@ -56,6 +58,11 @@ To show one of the external tools that are available in Dataverse, pass its data export TOOL_ID=1 curl http://localhost:8080/api/admin/externalTools/$TOOL_ID +Showing an External Tool in Dataverse in Preview Mode ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +TBD, mention mixed content + Removing an External Tool From Dataverse ++++++++++++++++++++++++++++++++++++++++ @@ -80,6 +87,11 @@ File level explore tools are specific to the file type (content type or MIME typ An "Explore" button will appear (on both the dataset page and the file landing page) for files that match the type that the tool has been built for. When there are multiple explore tools for a filetype, the button becomes a dropdown. +File Level Preview Tools +++++++++++++++++++++++++ + +TBD + File Level Configure Tools ++++++++++++++++++++++++++ diff --git a/doc/sphinx-guides/source/admin/integrations.rst b/doc/sphinx-guides/source/admin/integrations.rst index 2ed8581eb50..5c4ddbff230 100644 --- a/doc/sphinx-guides/source/admin/integrations.rst +++ b/doc/sphinx-guides/source/admin/integrations.rst @@ -90,7 +90,7 @@ Dataverse supports a protocol called OAI-PMH that facilitates harvesting dataset SHARE +++++ -`SHARE `_ is building a free, open, data set about research and scholarly activities across their life cycle. It's possible to add and installation of Dataverse as one of the `sources `_ they include if you contact the SHARE team. +`SHARE `_ is building a free, open, data set about research and scholarly activities across their life cycle. It's possible to add an installation of Dataverse as one of the `sources `_ they include if you contact the SHARE team. Research Data Preservation -------------------------- diff --git a/doc/sphinx-guides/source/user/dataset-management.rst b/doc/sphinx-guides/source/user/dataset-management.rst index 3cdc9aec954..dbfff73a491 100755 --- a/doc/sphinx-guides/source/user/dataset-management.rst +++ b/doc/sphinx-guides/source/user/dataset-management.rst @@ -69,7 +69,7 @@ If there are multiple upload options available, then you must choose which one t You can upload files to a dataset while first creating that dataset. You can also upload files after creating a dataset by clicking the "Edit" button at the top of the dataset page and from the dropdown list selecting "Files (Upload)" or clicking the "Upload Files" button above the files table in the Files tab. From either option you will be brought to the Upload Files page for that dataset. -Certain file types in Dataverse are supported by additional functionality, which can include downloading in different formats, file-level metadata preservation, file-level data citation with UNFs, and exploration through data visualization and analysis. See the :ref:`File Handling ` section of this page for more information. +Certain file types in Dataverse are supported by additional functionality, which can include downloading in different formats, previews, file-level metadata preservation, file-level data citation with UNFs, and exploration through data visualization and analysis. See the :ref:`File Handling ` section of this page for more information. HTTP Upload @@ -143,8 +143,12 @@ DVUploader is a community-developed tool, and its creation was primarily support File Handling ============= -Certain file types in Dataverse are supported by additional functionality, which can include downloading in different formats, file-level metadata preservation, file-level data citation; and exploration through data visualization and analysis. See the sections below for information about special functionality for specific file types. +Certain file types in Dataverse are supported by additional functionality, which can include downloading in different formats, previews, file-level metadata preservation, file-level data citation; and exploration through data visualization and analysis. See the sections below for information about special functionality for specific file types. +File Previews +------------- + +Installations of Dataverse can install previewers for common file types uploaded by their research communities. The previews appear on the file page. If a preview tool for a specific file type is available, the preview will be created and will display automatically. File previews are not available for restricted files. Tabular Data Files ------------------ @@ -296,7 +300,7 @@ Here is an `example of a Data Usage Agreement Date: Wed, 2 Oct 2019 14:35:44 -0400 Subject: [PATCH 04/35] #3758 update logic for World Map add lock icons to preview --- src/main/webapp/file.xhtml | 51 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index c18d82dc3ea..3f15738a8c0 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -366,37 +366,50 @@ - - - - + + + +
+ +
+ +
+
+ +
- + - + -
-
- + - - - - + + + + +
+ +
+ +
+ + - +
- + - +
- - + +
- +
From 1d157804bcc4b5192bfb3b9402d86c24af19db68 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Mon, 7 Oct 2019 15:03:15 -0400 Subject: [PATCH 05/35] #3758 add preview mode boolean to tools table --- .../iq/dataverse/externaltools/ExternalTool.java | 12 ++++++++++++ .../migration/V4.17.0.1__3578-file-page-preview.sql | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 src/main/resources/db/migration/V4.17.0.1__3578-file-page-preview.sql diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java index 230b51e1e2c..a466c8593cd 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java @@ -76,6 +76,10 @@ public class ExternalTool implements Serializable { */ @Column(nullable = true, columnDefinition = "TEXT") private String contentType; + + @Column(nullable = true) + private boolean hasPreviewMode; + /** * This default constructor is only here to prevent this error at @@ -212,7 +216,15 @@ public String getContentType() { public void setContentType(String contentType) { this.contentType = contentType; } + + public boolean getHasPreviewMode() { + return hasPreviewMode; + } + public void setHasPreviewMode(boolean hasPreviewMode) { + this.hasPreviewMode = hasPreviewMode; + } + public JsonObjectBuilder toJson() { JsonObjectBuilder jab = Json.createObjectBuilder(); jab.add("id", getId()); diff --git a/src/main/resources/db/migration/V4.17.0.1__3578-file-page-preview.sql b/src/main/resources/db/migration/V4.17.0.1__3578-file-page-preview.sql new file mode 100644 index 00000000000..86b9e0aee36 --- /dev/null +++ b/src/main/resources/db/migration/V4.17.0.1__3578-file-page-preview.sql @@ -0,0 +1,3 @@ +ALTER TABLE externalTool +ADD COLUMN IF NOT EXISTS hasPreviewMode BOOLEAN; + From 2f5dfd41928876ce147033d4ecd7058dbd27a21a Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 8 Oct 2019 10:51:22 -0400 Subject: [PATCH 06/35] #3758 Add preview links to file page --- .../edu/harvard/iq/dataverse/FilePage.java | 24 ++++++++++++++++- .../externaltools/ExternalToolHandler.java | 15 ++++++++++- .../ExternalToolServiceBean.java | 27 +++++++++++++++---- src/main/webapp/file.xhtml | 10 ++++++- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index 15383eb3d57..9ef777e5702 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -9,6 +9,9 @@ import edu.harvard.iq.dataverse.dataaccess.SwiftAccessIO; import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean; import edu.harvard.iq.dataverse.authorization.Permission; +import edu.harvard.iq.dataverse.authorization.users.ApiToken; +import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; +import edu.harvard.iq.dataverse.authorization.users.User; import edu.harvard.iq.dataverse.dataaccess.StorageIO; import edu.harvard.iq.dataverse.datasetutility.WorldMapPermissionHelper; import edu.harvard.iq.dataverse.engine.command.Command; @@ -22,6 +25,7 @@ import edu.harvard.iq.dataverse.export.ExportService; import edu.harvard.iq.dataverse.export.spi.Exporter; import edu.harvard.iq.dataverse.externaltools.ExternalTool; +import edu.harvard.iq.dataverse.externaltools.ExternalToolHandler; import edu.harvard.iq.dataverse.externaltools.ExternalToolServiceBean; import edu.harvard.iq.dataverse.makedatacount.MakeDataCountLoggingServiceBean; import edu.harvard.iq.dataverse.makedatacount.MakeDataCountLoggingServiceBean.MakeDataCountEntry; @@ -45,6 +49,7 @@ import javax.inject.Inject; import javax.inject.Named; import javax.validation.ConstraintViolation; +import org.primefaces.PrimeFaces; import org.primefaces.component.tabview.TabView; import org.primefaces.event.TabChangeEvent; @@ -71,6 +76,7 @@ public class FilePage implements java.io.Serializable { private String persistentId; private List configureTools; private List exploreTools; + private List toolsWithPreviews; @EJB DataFileServiceBean datafileService; @@ -208,7 +214,8 @@ public String init() { } configureTools = externalToolService.findFileToolsByTypeAndContentType(ExternalTool.Type.CONFIGURE, contentType); exploreTools = externalToolService.findFileToolsByTypeAndContentType(ExternalTool.Type.EXPLORE, contentType); - + toolsWithPreviews = externalToolService.findFileToolsByTypeContentTypeAndAvailablePreview(ExternalTool.Type.EXPLORE, contentType); + } else { return permissionsWrapper.notFound(); @@ -888,6 +895,21 @@ public List getExploreTools() { return exploreTools; } + public List getToolsWithPreviews() { + return toolsWithPreviews; + } + + public String preview(ExternalTool externalTool) { + ApiToken apiToken = null; + User user = session.getUser(); + if (user instanceof AuthenticatedUser) { + apiToken = authService.findApiTokenByUser((AuthenticatedUser) user); + } + ExternalToolHandler externalToolHandler = new ExternalToolHandler(externalTool, file, apiToken, file.getFileMetadata(), session.getLocaleCode()); + String toolUrl = externalToolHandler.getToolUrlForPreviewMode(); + return toolUrl; + } + //Provenance fragment bean calls this to show error dialogs after popup failure //This can probably be replaced by calling JsfHelper from the provpopup bean public void showProvError() { diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolHandler.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolHandler.java index 3f4781c0d27..a4a51666cc5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolHandler.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolHandler.java @@ -101,6 +101,11 @@ public String getLocaleCode() { // TODO: rename to handleRequest() to someday handle sending headers as well as query parameters. public String getQueryParametersForUrl() { + return getQueryParametersForUrl(false); + } + + // TODO: rename to handleRequest() to someday handle sending headers as well as query parameters. + public String getQueryParametersForUrl(boolean preview) { String toolParameters = externalTool.getToolParameters(); JsonReader jsonReader = Json.createReader(new StringReader(toolParameters)); JsonObject obj = jsonReader.readObject(); @@ -118,7 +123,11 @@ public String getQueryParametersForUrl() { } }); }); - return "?" + String.join("&", params); + if (!preview) { + return "?" + String.join("&", params); + } else { + return "?" + String.join("&", params) + "&preview=true"; + } } private String getQueryParam(String key, String value) { @@ -178,6 +187,10 @@ private String getQueryParam(String key, String value) { public String getToolUrlWithQueryParams() { return externalTool.getToolUrl() + getQueryParametersForUrl(); } + + public String getToolUrlForPreviewMode() { + return externalTool.getToolUrl() + getQueryParametersForUrl(true); + } public ExternalTool getExternalTool() { return externalTool; diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java index 6d3490750a3..a877477918f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java @@ -52,7 +52,8 @@ public List findAll() { */ public List findDatasetToolsByType(Type type) { String nullContentType = null; - return findByScopeTypeAndContentType(ExternalTool.Scope.DATASET, type, nullContentType); + String nullPreviewAvailable = null; + return findByScopeTypeAndContentType(ExternalTool.Scope.DATASET, type, nullContentType, nullPreviewAvailable); } /** @@ -61,7 +62,8 @@ public List findDatasetToolsByType(Type type) { */ public List findFileToolsByType(Type type) { String nullContentType = null; - return findByScopeTypeAndContentType(ExternalTool.Scope.FILE, type, nullContentType); + String nullPreviewAvailable = null; + return findByScopeTypeAndContentType(ExternalTool.Scope.FILE, type, nullContentType, nullPreviewAvailable); } /** @@ -70,7 +72,18 @@ public List findFileToolsByType(Type type) { * @return A list of tools or an empty list. */ public List findFileToolsByTypeAndContentType(Type type, String contentType) { - return findByScopeTypeAndContentType(ExternalTool.Scope.FILE, type, contentType); + String nullPreviewAvailable = null; + return findByScopeTypeAndContentType(ExternalTool.Scope.FILE, type, contentType, nullPreviewAvailable); + } + + /** + * @param type explore or configure + * @param contentType file content type (MIME type) + * @return A list of tools or an empty list. + */ + public List findFileToolsByTypeContentTypeAndAvailablePreview(Type type, String contentType) { + String previewAvailable = "true"; + return findByScopeTypeAndContentType(ExternalTool.Scope.FILE, type, contentType, previewAvailable); } /** @@ -79,13 +92,17 @@ public List findFileToolsByTypeAndContentType(Type type, String co * @param contentType file content type (MIME type) * @return A list of tools or an empty list. */ - private List findByScopeTypeAndContentType(Scope scope, Type type, String contentType) { + private List findByScopeTypeAndContentType(Scope scope, Type type, String contentType, String previewAvailable) { List externalTools = new ArrayList<>(); String contentTypeClause = ""; if (contentType != null) { contentTypeClause = "AND o.contentType = :contentType"; } - TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ExternalTool AS o WHERE o.scope = :scope AND o.type = :type " + contentTypeClause, ExternalTool.class); + String previewAvailableClause = ""; + if (previewAvailable != null) { + previewAvailableClause = " AND o.hasPreviewMode = 'true'"; + } + TypedQuery typedQuery = em.createQuery("SELECT OBJECT(o) FROM ExternalTool AS o WHERE o.scope = :scope AND o.type = :type " + contentTypeClause + previewAvailableClause, ExternalTool.class); typedQuery.setParameter("scope", scope); typedQuery.setParameter("type", type); if (contentType != null) { diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 6daf11a6c71..61d6603aa0e 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -429,9 +429,17 @@
- +
+ + + + +
  • #{tool.displayName}
  • +
    + +
    From 0fc8176f1feb4a5edba3673ef0b5aba596d1dabf Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Thu, 10 Oct 2019 10:24:22 -0400 Subject: [PATCH 07/35] #3758 add view preview mode for external tools --- src/main/webapp/file.xhtml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 61d6603aa0e..0d30b887150 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -371,7 +371,7 @@ -
    +
    @@ -433,10 +433,21 @@
    - + -
  • #{tool.displayName}
  • + #{tool.displayName} + +
    + + + + + + + +
    +
    From 6ef4d08a74946011139df75e1f0420aa274d1fa5 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Thu, 10 Oct 2019 12:34:43 -0400 Subject: [PATCH 08/35] #3758 fix render reference --- src/main/webapp/file.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 0d30b887150..2729a2c0b7c 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -433,7 +433,7 @@
    - + #{tool.displayName} From bf4571255e939930622e73724bb2432aad5d9acf Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Fri, 11 Oct 2019 14:29:43 -0400 Subject: [PATCH 09/35] #3758 add multiple preview tools as inner tabs on preview --- src/main/webapp/file.xhtml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 2729a2c0b7c..4945687ada6 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -432,24 +432,27 @@
    - + - - - #{tool.displayName} - -
    - - - - - - - -
    - -
    - + + + + + + + + +
    From 2dfeaf1a3747d3c69fd9a25592428873707b0e0d Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Fri, 11 Oct 2019 15:08:46 -0400 Subject: [PATCH 10/35] #3758 update preview tab render logic --- src/main/webapp/file.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 4945687ada6..70c14559364 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -368,7 +368,7 @@ - +
    From 9e8249af2a9ce261abf237691ddab3830d4aa794 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Fri, 11 Oct 2019 16:16:51 -0400 Subject: [PATCH 11/35] add documentation of new External Tools field --- doc/sphinx-guides/source/api/external-tools.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/sphinx-guides/source/api/external-tools.rst b/doc/sphinx-guides/source/api/external-tools.rst index fc5adf00c2b..e597f8ec2ac 100644 --- a/doc/sphinx-guides/source/api/external-tools.rst +++ b/doc/sphinx-guides/source/api/external-tools.rst @@ -75,6 +75,8 @@ Terminology type Whether the external tool is an **explore** tool or a **configure** tool. Configure tools require an API token because they make changes to data files (files within datasets). Configure tools are currently not supported at the dataset level (no "Configure" button appears in the GUI for datasets). toolUrl The **base URL** of the tool before query parameters are added. + + hasPreviewMode A boolean that when true indicates the tool has a preview mode. contentType File level tools operate on a specific **file type** (content type or MIME type such as "application/pdf") and this must be specified. Dataset level tools do not use contentType. From a2b95ba18f91d1f7771f838d504603088865fc4c Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Fri, 11 Oct 2019 16:18:55 -0400 Subject: [PATCH 12/35] Update Doc --- doc/sphinx-guides/source/api/external-tools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinx-guides/source/api/external-tools.rst b/doc/sphinx-guides/source/api/external-tools.rst index e597f8ec2ac..fc5e83a0631 100644 --- a/doc/sphinx-guides/source/api/external-tools.rst +++ b/doc/sphinx-guides/source/api/external-tools.rst @@ -76,7 +76,7 @@ Terminology toolUrl The **base URL** of the tool before query parameters are added. - hasPreviewMode A boolean that when true indicates the tool has a preview mode. + hasPreviewMode A boolean that indicates whether tool has a preview mode which can be embedded in the File Page. contentType File level tools operate on a specific **file type** (content type or MIME type such as "application/pdf") and this must be specified. Dataset level tools do not use contentType. From 48c04c01e0f4967cd8a838fc3075bae5b9261c18 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Fri, 11 Oct 2019 17:34:56 -0400 Subject: [PATCH 13/35] #3758 formatting preview tab --- src/main/webapp/file.xhtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 70c14559364..3d84376db86 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -433,9 +433,10 @@
    +
    - + - +
    From 4e81e1418e9eabf18fae03ba119b60fe66cf0c7f Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 15 Oct 2019 09:45:01 -0400 Subject: [PATCH 14/35] #3758 reduce logging of external tools --- src/main/java/edu/harvard/iq/dataverse/api/Access.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Access.java b/src/main/java/edu/harvard/iq/dataverse/api/Access.java index dafb2a53133..70a4d827045 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Access.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Access.java @@ -381,7 +381,7 @@ public DownloadInstance datafile(@PathParam("fileId") String fileId, @QueryParam // a NotFoundException. throw new NotFoundException(); } // Else - the file itself was requested or we have the info needed to invoke the service and get the derived info - logger.warning("Returning download instance"); + logger.fine("Returning download instance"); /* * Provide some browser-friendly headers: (?) */ From b0c63661d29feb68b1e71375ed9f61d56ce4f02b Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 15 Oct 2019 10:21:02 -0400 Subject: [PATCH 15/35] #3758 formatting and bundle-izing --- src/main/java/propertyFiles/Bundle.properties | 1 + src/main/webapp/file.xhtml | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index aa14fe079d2..94f0989c601 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1633,6 +1633,7 @@ file.dataFilesTab.versions.description.beAccessedAt=The dataset can now be acces file.dataFilesTab.versions.viewDetails.btn=View Details file.dataFilesTab.versions.widget.viewMoreInfo=To view more information about the versions of this dataset, and to edit it if this is your dataset, please visit the full version of this dataset at the {2}. file.dataFilesTab.versions.preloadmessage=(Loading versions...) +file.previewTab.externalTools.header=Available Previews file.deleteDialog.tip=Are you sure you want to delete this dataset and all of its files? You cannot undelete this dataset. file.deleteDialog.header=Delete Dataset file.deleteDraftDialog.tip=Are you sure you want to delete this draft version? Files will be reverted to the most recently published version. You cannot undelete this draft. diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 3d84376db86..73c693641b9 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -434,27 +434,28 @@
    - - - - - - - - - - - + + + + + + + + + + + +
    From 988133168dd996ed9e95b07284e0ea72cf3bde7c Mon Sep 17 00:00:00 2001 From: Danny Brooke Date: Tue, 15 Oct 2019 17:04:41 -0400 Subject: [PATCH 16/35] docs for external tools --- doc/sphinx-guides/source/api/external-tools.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/external-tools.rst b/doc/sphinx-guides/source/api/external-tools.rst index fc5e83a0631..5e58e68c853 100644 --- a/doc/sphinx-guides/source/api/external-tools.rst +++ b/doc/sphinx-guides/source/api/external-tools.rst @@ -29,7 +29,13 @@ Note: This is the same list that appears in the :doc:`/admin/external-tools` sec How External Tools Are Presented to Users ----------------------------------------- -In short, an external tool appears under an "Explore" or "Configure" button either on a dataset landing page or a file landing page. See also the :ref:`testing-external-tools` section of the Admin Guide for some perspective on how installations of Dataverse will expect to test your tool before announcing it to their users. +An external tool can appear in Dataverse in one of three ways: + +- under an "Explore" or "Configure" button either on a dataset landing page +- under an "Explore" or "Configure" button on a file landing page +- as an embedded preview on the file landing page + +See also the :ref:`testing-external-tools` section of the Admin Guide for some perspective on how installations of Dataverse will expect to test your tool before announcing it to their users. Creating an External Tool Manifest ---------------------------------- @@ -76,7 +82,7 @@ Terminology toolUrl The **base URL** of the tool before query parameters are added. - hasPreviewMode A boolean that indicates whether tool has a preview mode which can be embedded in the File Page. + hasPreviewMode A boolean that indicates whether tool has a preview mode which can be embedded in the File Page. Since this view is designed for embedding within Dataverse, the preview mode for a tool will typically be a view without headers or other options that may be included with a tool that is designed to be launched in a new window. Sometimes, a tool will exist solely to preview files in Dataverse and the preview mode will be the same as the regular view. contentType File level tools operate on a specific **file type** (content type or MIME type such as "application/pdf") and this must be specified. Dataset level tools do not use contentType. From 8dbe32721ee2f382fb45ffb24d71688185eb116e Mon Sep 17 00:00:00 2001 From: Danny Brooke Date: Wed, 16 Oct 2019 18:23:03 -0400 Subject: [PATCH 17/35] filling in those doc stubs from earlier --- doc/sphinx-guides/source/admin/external-tools.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/sphinx-guides/source/admin/external-tools.rst b/doc/sphinx-guides/source/admin/external-tools.rst index 26663da1e13..e5de4b14709 100644 --- a/doc/sphinx-guides/source/admin/external-tools.rst +++ b/doc/sphinx-guides/source/admin/external-tools.rst @@ -37,7 +37,7 @@ In the curl command below, replace the placeholder "fabulousFileTool.json" place curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools --upload-file fabulousFileTool.json -TBD, If you'd like to allow the external tool to be used in previews on the file page... +If you'd like to allow the external tool to be used in previews on the file page, you can define it in the manifest using the `hasPreviewMode` parameter. Listing All External Tools in Dataverse +++++++++++++++++++++++++++++++++++++++ @@ -58,11 +58,6 @@ To show one of the external tools that are available in Dataverse, pass its data export TOOL_ID=1 curl http://localhost:8080/api/admin/externalTools/$TOOL_ID -Showing an External Tool in Dataverse in Preview Mode -+++++++++++++++++++++++++++++++++++++++++++++++++++++ - -TBD, mention mixed content - Removing an External Tool From Dataverse ++++++++++++++++++++++++++++++++++++++++ @@ -83,14 +78,14 @@ Once you have added an external tool to your installation of Dataverse, you will File Level Explore Tools ++++++++++++++++++++++++ -File level explore tools are specific to the file type (content type or MIME type) of the file. For example, there is a tool for exploring PDF files in the "File Previewers" set of tools. +File level explore tools are specific to the file type (content type or MIME type) of the file. For example, Data Explorer is tool for exploring tabular data files. An "Explore" button will appear (on both the dataset page and the file landing page) for files that match the type that the tool has been built for. When there are multiple explore tools for a filetype, the button becomes a dropdown. File Level Preview Tools ++++++++++++++++++++++++ -TBD +Similar to File level explore tools, File Level preview tools are specific to the file type. File level preview tools are designed to be embedded in the file page and can either be a tool designed solely for previewing data or can be a simplified view of another external tool. File Level Configure Tools ++++++++++++++++++++++++++ From 57b3f8f8707469590cca4f6499bb53d002ed552d Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Wed, 23 Oct 2019 10:32:19 -0400 Subject: [PATCH 18/35] #3758 update external tool builder prelim --- .../harvard/iq/dataverse/externaltools/ExternalTool.java | 6 +++++- ...ge-preview.sql => V4.17.0.3__3578-file-page-preview.sql} | 0 2 files changed, 5 insertions(+), 1 deletion(-) rename src/main/resources/db/migration/{V4.17.0.1__3578-file-page-preview.sql => V4.17.0.3__3578-file-page-preview.sql} (100%) diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java index a466c8593cd..7f81c819ead 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java @@ -27,6 +27,7 @@ public class ExternalTool implements Serializable { public static final String TOOL_URL = "toolUrl"; public static final String TOOL_PARAMETERS = "toolParameters"; public static final String CONTENT_TYPE = "contentType"; + public static final String HAS_PREVIEW_MODE = "hasPreviewMode"; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -77,7 +78,7 @@ public class ExternalTool implements Serializable { @Column(nullable = true, columnDefinition = "TEXT") private String contentType; - @Column(nullable = true) + @Column(nullable = false) private boolean hasPreviewMode; @@ -237,6 +238,9 @@ public JsonObjectBuilder toJson() { if (getContentType() != null) { jab.add(CONTENT_TYPE, getContentType()); } + if (getHasPreviewMode()) { + jab.add(CONTENT_TYPE, getContentType()); + } return jab; } diff --git a/src/main/resources/db/migration/V4.17.0.1__3578-file-page-preview.sql b/src/main/resources/db/migration/V4.17.0.3__3578-file-page-preview.sql similarity index 100% rename from src/main/resources/db/migration/V4.17.0.1__3578-file-page-preview.sql rename to src/main/resources/db/migration/V4.17.0.3__3578-file-page-preview.sql From a61d39381c92b2c243a4ebc1d3f43f367ade8ef9 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Wed, 23 Oct 2019 15:39:47 -0400 Subject: [PATCH 19/35] #3758 add preview mode to constructor --- .../iq/dataverse/externaltools/ExternalTool.java | 16 +++++++++++++++- .../V4.17.0.2__3578-file-page-preview.sql | 5 +++++ .../V4.17.0.3__3578-file-page-preview.sql | 3 --- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/db/migration/V4.17.0.2__3578-file-page-preview.sql delete mode 100644 src/main/resources/db/migration/V4.17.0.3__3578-file-page-preview.sql diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java index 7f81c819ead..8e79bd2a0f0 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java @@ -104,6 +104,18 @@ public ExternalTool(String displayName, String description, Type type, Scope sco this.toolUrl = toolUrl; this.toolParameters = toolParameters; this.contentType = contentType; + this.hasPreviewMode = false; + } + + public ExternalTool(String displayName, String description, Type type, Scope scope, String toolUrl, String toolParameters, String contentType, boolean hasPreviewMode) { + this.displayName = displayName; + this.description = description; + this.type = type; + this.scope = scope; + this.toolUrl = toolUrl; + this.toolParameters = toolParameters; + this.contentType = contentType; + this.hasPreviewMode = hasPreviewMode; } public enum Type { @@ -239,7 +251,9 @@ public JsonObjectBuilder toJson() { jab.add(CONTENT_TYPE, getContentType()); } if (getHasPreviewMode()) { - jab.add(CONTENT_TYPE, getContentType()); + jab.add(HAS_PREVIEW_MODE, getHasPreviewMode()); + } else { + } return jab; } diff --git a/src/main/resources/db/migration/V4.17.0.2__3578-file-page-preview.sql b/src/main/resources/db/migration/V4.17.0.2__3578-file-page-preview.sql new file mode 100644 index 00000000000..152700ed96c --- /dev/null +++ b/src/main/resources/db/migration/V4.17.0.2__3578-file-page-preview.sql @@ -0,0 +1,5 @@ +ALTER TABLE externalTool +ADD COLUMN IF NOT EXISTS hasPreviewMode BOOLEAN; +UPDATE externaltool SET hasPreviewMode = false; +ALTER TABLE externaltool ALTER COLUMN hasPreviewMode SET NOT NULL; + diff --git a/src/main/resources/db/migration/V4.17.0.3__3578-file-page-preview.sql b/src/main/resources/db/migration/V4.17.0.3__3578-file-page-preview.sql deleted file mode 100644 index 86b9e0aee36..00000000000 --- a/src/main/resources/db/migration/V4.17.0.3__3578-file-page-preview.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE externalTool -ADD COLUMN IF NOT EXISTS hasPreviewMode BOOLEAN; - From e1e9b4b6f50310f4eea0d79fb313f3b46db28a10 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Wed, 23 Oct 2019 16:28:06 -0400 Subject: [PATCH 20/35] #3758 update unit tests --- .../externaltools/ExternalToolServiceBean.java | 9 ++++++++- .../externaltools/ExternalToolServiceBeanTest.java | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java index a877477918f..d1af3664397 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java @@ -14,6 +14,7 @@ import static edu.harvard.iq.dataverse.externaltools.ExternalTool.TYPE; import static edu.harvard.iq.dataverse.externaltools.ExternalTool.SCOPE; import static edu.harvard.iq.dataverse.externaltools.ExternalTool.CONTENT_TYPE; +import static edu.harvard.iq.dataverse.externaltools.ExternalTool.HAS_PREVIEW_MODE; import java.io.StringReader; import java.util.ArrayList; import java.util.List; @@ -173,6 +174,7 @@ public static ExternalTool parseAddExternalToolManifest(String manifest) { String typeUserInput = getRequiredTopLevelField(jsonObject, TYPE); String scopeUserInput = getRequiredTopLevelField(jsonObject, SCOPE); String contentType = getOptionalTopLevelField(jsonObject, CONTENT_TYPE); + // Allow IllegalArgumentException to bubble up from ExternalTool.Type.fromString ExternalTool.Type type = ExternalTool.Type.fromString(typeUserInput); @@ -235,7 +237,12 @@ public static ExternalTool parseAddExternalToolManifest(String manifest) { } String toolParameters = toolParametersObj.toString(); - return new ExternalTool(displayName, description, type, scope, toolUrl, toolParameters, contentType); + String hasPreviewMode = getOptionalTopLevelField(jsonObject, HAS_PREVIEW_MODE); + boolean hasPreviewModeBoolean = false; + if(hasPreviewMode.equals("true")){ + hasPreviewModeBoolean = true; + } + return new ExternalTool(displayName, description, type, scope, toolUrl, toolParameters, contentType, hasPreviewModeBoolean); } private static String getRequiredTopLevelField(JsonObject jsonObject, String key) { diff --git a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java index 34ba97584da..ea4f7676603 100644 --- a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java @@ -58,6 +58,7 @@ public void testParseAddExternalToolInput() { job.add("type", "explore"); job.add("scope", "file"); job.add("toolUrl", "http://awesometool.com"); + job.add("hasPreviewMode", "false"); job.add("toolParameters", Json.createObjectBuilder() .add("queryParameters", Json.createArrayBuilder() .add(Json.createObjectBuilder() @@ -105,6 +106,7 @@ public void testParseAddFileToolFilePid() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "file"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder() .add("queryParameters", Json.createArrayBuilder() @@ -154,6 +156,7 @@ public void testParseAddExternalToolInputNoFileId() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "file"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder() .add("queryParameters", Json.createArrayBuilder() @@ -206,6 +209,7 @@ public void testParseAddExternalToolInputUnknownReservedWord() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "file"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder() .add("queryParameters", Json.createArrayBuilder() @@ -238,6 +242,7 @@ public void testParseAddExternalToolInputNoDisplayName() { JsonObjectBuilder job = Json.createObjectBuilder(); job.add("description", "This tool is awesome."); job.add("toolUrl", "http://awesometool.com"); + job.add("hasPreviewMode", "false"); job.add("toolParameters", Json.createObjectBuilder().build()); job.add(ExternalTool.CONTENT_TYPE, DataFileServiceBean.MIME_TYPE_TSV_ALT); String tool = job.build().toString(); @@ -256,6 +261,7 @@ public void testParseAddExternalToolInputNoDisplayName() { public void testParseAddExternalToolInputNoDescription() { JsonObjectBuilder job = Json.createObjectBuilder(); job.add("displayName", "AwesomeTool"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder().build()); job.add(ExternalTool.CONTENT_TYPE, DataFileServiceBean.MIME_TYPE_TSV_ALT); @@ -278,6 +284,7 @@ public void testParseAddExternalToolInputNoToolUrl() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "file"); + job.add("hasPreviewMode", "false"); job.add("toolParameters", Json.createObjectBuilder().build()); job.add(ExternalTool.CONTENT_TYPE, DataFileServiceBean.MIME_TYPE_TSV_ALT); String tool = job.build().toString(); @@ -299,6 +306,7 @@ public void testParseAddExternalToolInputWrongType() { job.add("description", "This tool is awesome."); job.add("type", "noSuchType"); job.add("scope", "file"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder().build()); job.add(ExternalTool.CONTENT_TYPE, DataFileServiceBean.MIME_TYPE_TSV_ALT); @@ -322,6 +330,7 @@ public void testParseAddExternalToolInputNoContentType() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "file"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder().add("queryParameters", Json.createArrayBuilder() @@ -352,6 +361,7 @@ public void testParseAddDatasetToolNoRequiredFields() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "dataset"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder().add("queryParameters", Json.createArrayBuilder() @@ -380,6 +390,7 @@ public void testParseAddDatasetToolDatasetId() { job.add("type", "explore"); job.add("scope", "dataset"); job.add("toolUrl", "http://awesometool.com"); + job.add("hasPreviewMode", "true"); job.add("toolParameters", Json.createObjectBuilder().add("queryParameters", Json.createArrayBuilder() .add(Json.createObjectBuilder() @@ -410,6 +421,7 @@ public void testParseAddDatasetToolDatasetPid() { job.add("description", "This tool is awesome."); job.add("type", "explore"); job.add("scope", "dataset"); + job.add("hasPreviewMode", "false"); job.add("toolUrl", "http://awesometool.com"); job.add("toolParameters", Json.createObjectBuilder().add("queryParameters", Json.createArrayBuilder() From 71189395da5c718ebab2825b838ec310b09534c6 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Thu, 24 Oct 2019 11:58:27 -0400 Subject: [PATCH 21/35] #3758 allow null hasPreviewMode --- .../iq/dataverse/externaltools/ExternalToolServiceBean.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java index d1af3664397..8c49dd85fe0 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBean.java @@ -163,6 +163,7 @@ public static List findExternalToolsByFile(List allE } public static ExternalTool parseAddExternalToolManifest(String manifest) { + if (manifest == null || manifest.isEmpty()) { throw new IllegalArgumentException("External tool manifest was null or empty!"); } @@ -237,11 +238,14 @@ public static ExternalTool parseAddExternalToolManifest(String manifest) { } String toolParameters = toolParametersObj.toString(); + String hasPreviewMode = getOptionalTopLevelField(jsonObject, HAS_PREVIEW_MODE); + boolean hasPreviewModeBoolean = false; - if(hasPreviewMode.equals("true")){ + if(hasPreviewMode != null && hasPreviewMode.equals("true")){ hasPreviewModeBoolean = true; } + return new ExternalTool(displayName, description, type, scope, toolUrl, toolParameters, contentType, hasPreviewModeBoolean); } From b0d4e9f5a081530ac7ed3168bf5a18497f8f6db0 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Mon, 28 Oct 2019 10:00:34 -0400 Subject: [PATCH 22/35] #3578 move preview tool render to drop down --- .../edu/harvard/iq/dataverse/FilePage.java | 57 ++++++++++++- .../dataverse/externaltools/ExternalTool.java | 14 +++- src/main/java/propertyFiles/Bundle.properties | 1 + src/main/webapp/file.xhtml | 82 +++++++------------ 4 files changed, 97 insertions(+), 57 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index 9ef777e5702..bd8f483d0ca 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -38,6 +38,8 @@ import edu.harvard.iq.dataverse.util.SystemConfig; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Set; import java.util.logging.Logger; @@ -214,8 +216,10 @@ public String init() { } configureTools = externalToolService.findFileToolsByTypeAndContentType(ExternalTool.Type.CONFIGURE, contentType); exploreTools = externalToolService.findFileToolsByTypeAndContentType(ExternalTool.Type.EXPLORE, contentType); - toolsWithPreviews = externalToolService.findFileToolsByTypeContentTypeAndAvailablePreview(ExternalTool.Type.EXPLORE, contentType); - + toolsWithPreviews = addMapLayerAndSortExternalTools(); + if(!toolsWithPreviews.isEmpty()){ + setSelectedTool(toolsWithPreviews.get(0)); + } } else { return permissionsWrapper.notFound(); @@ -233,6 +237,32 @@ public FileMetadata getFileMetadata() { return fileMetadata; } + private List addMapLayerAndSortExternalTools(){ + List retList = externalToolService.findFileToolsByTypeContentTypeAndAvailablePreview(ExternalTool.Type.EXPLORE, file.getContentType()); + if (file != null && worldMapPermissionHelper.getMapLayerMetadata(file) != null && worldMapPermissionHelper.getMapLayerMetadata(file).getEmbedMapLink() != null) { + ExternalTool wpTool = new ExternalTool(); + wpTool.setDisplayName("World Map"); + wpTool.setToolParameters("{}"); + wpTool.setToolUrl(worldMapPermissionHelper.getMapLayerMetadata(file).getEmbedMapLink()); + retList.add(wpTool); + } + Collections.sort(retList, CompareExternalToolName); + + if(retList.size() > 1){ + int order = 0; + for (ExternalTool t: retList){ + t.setDisplayOrder(order); + order++; + } + } + + return retList; + } + + /* + worldMapPermissionHelper.getMapLayerMetadata(FilePage.fileMetadata.dataFile).getEmbedMapLink() + */ + public boolean isDownloadPopupRequired() { if(fileMetadata.getId() == null || fileMetadata.getDatasetVersion().getId() == null ){ @@ -396,6 +426,7 @@ public int getActiveTabIndex() { } public void setActiveTabIndex(int activeTabIndex) { + System.out.print("setActiveTabIndex: " + activeTabIndex); this.activeTabIndex = activeTabIndex; } @@ -899,14 +930,29 @@ public List getToolsWithPreviews() { return toolsWithPreviews; } + private ExternalTool selectedTool; + + public ExternalTool getSelectedTool() { + return selectedTool; + } + + public void setSelectedTool(ExternalTool selectedTool) { + System.out.print(selectedTool.getDisplayName()); + this.selectedTool = selectedTool; + } + public String preview(ExternalTool externalTool) { ApiToken apiToken = null; User user = session.getUser(); if (user instanceof AuthenticatedUser) { apiToken = authService.findApiTokenByUser((AuthenticatedUser) user); } + if(externalTool == null){ + return ""; + } ExternalToolHandler externalToolHandler = new ExternalToolHandler(externalTool, file, apiToken, file.getFileMetadata(), session.getLocaleCode()); String toolUrl = externalToolHandler.getToolUrlForPreviewMode(); + System.out.print(toolUrl); return toolUrl; } @@ -915,5 +961,12 @@ public String preview(ExternalTool externalTool) { public void showProvError() { JH.addMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("file.metadataTab.provenance.error")); } + + private static final Comparator CompareExternalToolName = new Comparator() { + @Override + public int compare(ExternalTool o1, ExternalTool o2) { + return o1.getDisplayName().toUpperCase().compareTo(o2.getDisplayName().toUpperCase()); + } + }; } diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java index 8e79bd2a0f0..2f981ea6d87 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java @@ -11,6 +11,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Transient; /** * A specification or definition for how an external tool is intended to @@ -79,7 +80,18 @@ public class ExternalTool implements Serializable { private String contentType; @Column(nullable = false) - private boolean hasPreviewMode; + private boolean hasPreviewMode; + + @Transient + private int displayOrder; + + public int getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(int displayOrder) { + this.displayOrder = displayOrder; + } /** diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 8921c6a49a6..ad75340f12e 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1641,6 +1641,7 @@ file.dataFilesTab.versions.viewDetails.btn=View Details file.dataFilesTab.versions.widget.viewMoreInfo=To view more information about the versions of this dataset, and to edit it if this is your dataset, please visit the full version of this dataset at the {2}. file.dataFilesTab.versions.preloadmessage=(Loading versions...) file.previewTab.externalTools.header=Available Previews +file.previewTab.button.label=Previews file.deleteDialog.tip=Are you sure you want to delete this dataset and all of its files? You cannot undelete this dataset. file.deleteDialog.header=Delete Dataset file.deleteDraftDialog.tip=Are you sure you want to delete this draft version? Files will be reverted to the most recently published version. You cannot undelete this draft. diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 73c693641b9..1d2083e11e0 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -394,69 +394,43 @@
    - - - - - + - -
    - -
    +
    + +
    + - +
    + + +
    + +
    + + - - - - + - - + + - - - - - -
    - - - - - - - - - - - - -
    From 16d2a5dd3226db80ddcca1f8822ab1025e830719 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Mon, 28 Oct 2019 10:14:54 -0400 Subject: [PATCH 23/35] #3758 sort tools for Explore Button --- src/main/java/edu/harvard/iq/dataverse/FilePage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index bd8f483d0ca..eb7e76acc6c 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -216,6 +216,7 @@ public String init() { } configureTools = externalToolService.findFileToolsByTypeAndContentType(ExternalTool.Type.CONFIGURE, contentType); exploreTools = externalToolService.findFileToolsByTypeAndContentType(ExternalTool.Type.EXPLORE, contentType); + Collections.sort(exploreTools, CompareExternalToolName); toolsWithPreviews = addMapLayerAndSortExternalTools(); if(!toolsWithPreviews.isEmpty()){ setSelectedTool(toolsWithPreviews.get(0)); From 47d09246ac9c295712764f76c182f3f94f8c973e Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Mon, 28 Oct 2019 10:28:37 -0400 Subject: [PATCH 24/35] #3758 remove debug code --- src/main/java/edu/harvard/iq/dataverse/FilePage.java | 3 --- src/main/webapp/file.xhtml | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index eb7e76acc6c..fecb0aaa282 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -427,7 +427,6 @@ public int getActiveTabIndex() { } public void setActiveTabIndex(int activeTabIndex) { - System.out.print("setActiveTabIndex: " + activeTabIndex); this.activeTabIndex = activeTabIndex; } @@ -938,7 +937,6 @@ public ExternalTool getSelectedTool() { } public void setSelectedTool(ExternalTool selectedTool) { - System.out.print(selectedTool.getDisplayName()); this.selectedTool = selectedTool; } @@ -953,7 +951,6 @@ public String preview(ExternalTool externalTool) { } ExternalToolHandler externalToolHandler = new ExternalToolHandler(externalTool, file, apiToken, file.getFileMetadata(), session.getLocaleCode()); String toolUrl = externalToolHandler.getToolUrlForPreviewMode(); - System.out.print(toolUrl); return toolUrl; } diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 1d2083e11e0..56edeee7ff4 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -425,9 +425,8 @@ - + - From c35268bb5796320ab124e7e2459ca22f04550e7c Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Mon, 28 Oct 2019 16:59:34 -0400 Subject: [PATCH 25/35] #3758 add render logic to preview only publicly downloadable files. --- src/main/java/propertyFiles/Bundle.properties | 1 + src/main/webapp/file.xhtml | 48 ++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index ad75340f12e..f6d5ae33bc4 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1642,6 +1642,7 @@ file.dataFilesTab.versions.widget.viewMoreInfo=To view more information about th file.dataFilesTab.versions.preloadmessage=(Loading versions...) file.previewTab.externalTools.header=Available Previews file.previewTab.button.label=Previews +file.previewTab.previews.not.available=Public previews are not available for this file. file.deleteDialog.tip=Are you sure you want to delete this dataset and all of its files? You cannot undelete this dataset. file.deleteDialog.header=Delete Dataset file.deleteDraftDialog.tip=Are you sure you want to delete this draft version? Files will be reverted to the most recently published version. You cannot undelete this draft. diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 56edeee7ff4..2bbb48c844d 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -368,19 +368,18 @@ - - + -
    +
    -
    +
    -
    +
    @@ -391,20 +390,18 @@
    -
    -
    - - - - +
    + +
    +
    - - - - - - +
    + + + + + + + + +
    +
    From 0700b241e5dbb69425aa74c69ac1a9d28f37ae72 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 29 Oct 2019 14:24:54 -0400 Subject: [PATCH 26/35] #3758 remove transient display order was used for tab --- .../java/edu/harvard/iq/dataverse/FilePage.java | 8 -------- .../iq/dataverse/externaltools/ExternalTool.java | 13 ------------- src/main/webapp/file.xhtml | 4 +--- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index fecb0aaa282..d55b3506580 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -249,14 +249,6 @@ private List addMapLayerAndSortExternalTools(){ } Collections.sort(retList, CompareExternalToolName); - if(retList.size() > 1){ - int order = 0; - for (ExternalTool t: retList){ - t.setDisplayOrder(order); - order++; - } - } - return retList; } diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java index 2f981ea6d87..9c5655b61e3 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java @@ -11,7 +11,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.Transient; /** * A specification or definition for how an external tool is intended to @@ -81,18 +80,6 @@ public class ExternalTool implements Serializable { @Column(nullable = false) private boolean hasPreviewMode; - - @Transient - private int displayOrder; - - public int getDisplayOrder() { - return displayOrder; - } - - public void setDisplayOrder(int displayOrder) { - this.displayOrder = displayOrder; - } - /** * This default constructor is only here to prevent this error at diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 2bbb48c844d..663b2fa9538 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -390,9 +390,7 @@
    -
    - -
    +
    From e319ba92d1cbda50fa1e3fc82ee48907e5720d9b Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 29 Oct 2019 16:30:40 -0400 Subject: [PATCH 27/35] #3758 update preview tab render logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit only “publicly downloadable” files allowed to have preview --- src/main/webapp/file.xhtml | 65 +++++++++++--------------------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 663b2fa9538..969abf76f7c 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -368,58 +368,30 @@ - - -
    -
    -
    - - - -
    - -
    -
    - -
    -
    - - - - -
    -
    - -
    + -
    -
    +
    +
    + + +
    +
    - -
    - +
    -
    From 6668f9dc6584db0b78015f8a341034b95a80e7b1 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 29 Oct 2019 16:56:46 -0400 Subject: [PATCH 28/35] #3758 bundle-ize preview tab labels --- src/main/java/propertyFiles/Bundle.properties | 2 ++ src/main/webapp/file.xhtml | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 9add2497d10..636a90287a0 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1780,6 +1780,8 @@ file.tags.label=Tags file.lastupdated.label=Last Updated file.DatasetVersion=Version +file.previewTab.tool.open=Open +file.previewTab.header=Preview file.metadataTab.fileMetadata.header=File Metadata file.metadataTab.fileMetadata.persistentid.label=Data File Persistent ID file.metadataTab.fileMetadata.downloadUrl.label=Download URL diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 969abf76f7c..a60a8b95278 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -368,7 +368,7 @@
    - +
    @@ -393,13 +393,13 @@
    - - Date: Tue, 29 Oct 2019 17:06:13 -0400 Subject: [PATCH 29/35] #3758 remove unused import --- src/main/java/edu/harvard/iq/dataverse/FilePage.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index d55b3506580..1e92b62c9fe 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -51,7 +51,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.validation.ConstraintViolation; -import org.primefaces.PrimeFaces; import org.primefaces.component.tabview.TabView; import org.primefaces.event.TabChangeEvent; From 6bdff7b20e2b1d1a39f690be7650e5dd18b13248 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Wed, 30 Oct 2019 11:30:59 -0400 Subject: [PATCH 30/35] #3758 fix Open World Map --- .../edu/harvard/iq/dataverse/FilePage.java | 6 +++++ .../dataverse/externaltools/ExternalTool.java | 14 +++++++++++ src/main/webapp/file.xhtml | 24 ++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index 1e92b62c9fe..ccb0eddc16a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -239,11 +239,17 @@ public FileMetadata getFileMetadata() { private List addMapLayerAndSortExternalTools(){ List retList = externalToolService.findFileToolsByTypeContentTypeAndAvailablePreview(ExternalTool.Type.EXPLORE, file.getContentType()); + if(!retList.isEmpty()){ + retList.forEach((et) -> { + et.setWorldMapTool(false); + }); + } if (file != null && worldMapPermissionHelper.getMapLayerMetadata(file) != null && worldMapPermissionHelper.getMapLayerMetadata(file).getEmbedMapLink() != null) { ExternalTool wpTool = new ExternalTool(); wpTool.setDisplayName("World Map"); wpTool.setToolParameters("{}"); wpTool.setToolUrl(worldMapPermissionHelper.getMapLayerMetadata(file).getEmbedMapLink()); + wpTool.setWorldMapTool(true); retList.add(wpTool); } Collections.sort(retList, CompareExternalToolName); diff --git a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java index 9c5655b61e3..7c7d17c19a1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java +++ b/src/main/java/edu/harvard/iq/dataverse/externaltools/ExternalTool.java @@ -11,6 +11,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Transient; /** * A specification or definition for how an external tool is intended to @@ -81,6 +82,19 @@ public class ExternalTool implements Serializable { @Column(nullable = false) private boolean hasPreviewMode; + + + @Transient + private boolean worldMapTool; + + public boolean isWorldMapTool() { + return worldMapTool; + } + + public void setWorldMapTool(boolean worldMapTool) { + this.worldMapTool = worldMapTool; + } + /** * This default constructor is only here to prevent this error at * deployment: diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index a60a8b95278..5c5cc8155a7 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -392,7 +392,7 @@
    - + + + + + + + + #{bundle['file.previewTab.tool.open']} #{bundle['file.mapData.worldMap']} + + + #{bundle['file.previewTab.tool.open']} #{bundle['file.mapData.worldMap']} + + From 7e383a767189170b108f206a6d2bea48cbbc2a89 Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Wed, 30 Oct 2019 11:44:48 -0400 Subject: [PATCH 31/35] #3758 code cleanup --- src/main/webapp/file.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 5c5cc8155a7..198c4eebdf2 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -373,7 +373,7 @@
    -