-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
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; | ||
}; | ||
} |