-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
739 html codebook #6081
Merged
Merged
739 html codebook #6081
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c8462e1
Merge pull request #27 from IQSS/develop
lubitchv 7c283ad
html codebook
lubitchv 537afe2
html codebook
lubitchv ff8ba65
html
lubitchv 9722e8f
fix html codebook reading
lubitchv 6e4e80d
commit
lubitchv 70e058f
Merge branch 'IQSS-develop' into html-codebook
lubitchv f6edfdd
adding documentation of new export format
djbrooke e53fbb8
Update dataset-management.rst
djbrooke a2d44d0
capitalize HTML
lubitchv 6201c53
Merge branch '739-html-codebook' of https://github.com/lubitchv/datav…
lubitchv f8e7874
Unit test html codebook
lubitchv 2163dc6
fix HtmlCodeBookExporter
lubitchv 8acc07f
Fix for reading ddi cached file
lubitchv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/edu/harvard/iq/dataverse/export/HtmlCodeBookExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package edu.harvard.iq.dataverse.export; | ||
|
||
import com.google.auto.service.AutoService; | ||
import edu.harvard.iq.dataverse.DatasetVersion; | ||
import edu.harvard.iq.dataverse.export.ddi.DdiExportUtil; | ||
import edu.harvard.iq.dataverse.export.spi.Exporter; | ||
import edu.harvard.iq.dataverse.util.BundleUtil; | ||
|
||
import javax.json.JsonObject; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.xml.stream.XMLStreamException; | ||
import java.io.File; | ||
import java.io.OutputStream; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
@AutoService(Exporter.class) | ||
public class HtmlCodeBookExporter implements Exporter { | ||
|
||
@Override | ||
public String getProviderName() { | ||
return "html"; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return BundleUtil.getStringFromBundle("dataset.exportBtn.itemLabel.html") != null ? BundleUtil.getStringFromBundle("dataset.exportBtn.itemLabel.html") : "DDI html codebook"; | ||
} | ||
|
||
@Override | ||
public void exportDataset(DatasetVersion version, JsonObject json, OutputStream outputStream) throws ExportException { | ||
try { | ||
Path cachedMetadataFilePath = Paths.get(version.getDataset().getFileSystemDirectory().toString(), "export_ddi" + ".cached"); | ||
File datafile = cachedMetadataFilePath.toFile(); | ||
DdiExportUtil.datasetHtmlDDI(datafile, outputStream); | ||
} catch (XMLStreamException xse) { | ||
throw new ExportException ("Caught XMLStreamException performing DDI export"); | ||
} | ||
} | ||
|
||
@Override | ||
public Boolean isXMLFormat() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Boolean isHarvestable() { | ||
// No, we don't want this format to be harvested! | ||
// For datasets with tabular data the <data> portions of the DDIs | ||
// become huge and expensive to parse; even as they don't contain any | ||
// metadata useful to remote harvesters. -- L.A. 4.5 | ||
return false; | ||
} | ||
|
||
@Override | ||
public Boolean isAvailableToUsers() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getXMLNameSpace() throws ExportException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getXMLSchemaLocation() throws ExportException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getXMLSchemaVersion() throws ExportException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setParam(String name, Object value) { | ||
// this exporter does not uses or supports any parameters as of now. | ||
} | ||
|
||
@Override | ||
public String getMediaType() { | ||
return MediaType.TEXT_HTML; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1209,6 +1209,7 @@ dataset.exportBtn.itemLabel.datacite=DataCite | |||||
dataset.exportBtn.itemLabel.json=JSON | ||||||
dataset.exportBtn.itemLabel.oai_ore=OAI_ORE | ||||||
dataset.exportBtn.itemLabel.dataciteOpenAIRE=OpenAIRE | ||||||
dataset.exportBtn.itemLabel.html=DDI HTML codebook | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Title case is used for buttons, like this:
Suggested change
|
||||||
metrics.title=Metrics | ||||||
metrics.title.tip=View more metrics information | ||||||
metrics.comingsoon=Coming soon... | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFileSystemDirectory makes me suspect that this might not work on S3 or Swift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pdurbin You are probably right. I did not test it for S3 or Swift, it probably will not work with it. That is why I just replaced getFileSystemDirectory with getExport from ExportService. As I understand it should work for S3 and Swift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lubitchv perfect, thanks! I just moved this to QA.