Skip to content

Commit

Permalink
#24 Add distribution download URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-podolskiy90 committed Jul 29, 2024
1 parent 2272b82 commit 1549632
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ public static Eml build(InputStream xml)
"eml/dataset/methods/sampling/samplingDescription/para", "sampleDescription");
digester.addBeanPropertySetter(
"eml/dataset/methods/qualityControl/description/para", "qualityControl");
digester.addBeanPropertySetter("eml/dataset/distribution/online/url", "distributionUrl");

digester.addCallMethod("eml/dataset/distribution/online/url", "setDistribution", 2);
digester.addCallParam("eml/dataset/distribution/online/url", 0);
digester.addCallParam("eml/dataset/distribution/online/url", 1, "function");

digester.addBeanPropertySetter("eml/dataset/purpose/para", "purpose");
digester.addBeanPropertySetter(
"eml/dataset/maintenance/description/para", "updateFrequencyDescription");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ public class Eml implements Serializable {
* to "information".
*/
private String distributionUrl;
/**
* Download URL
*/
private String distributionDownloadUrl;
/**
* Serialised data
*/
Expand Down Expand Up @@ -474,6 +478,25 @@ public void setDistributionUrl(String distributionUrl) {
this.distributionUrl = distributionUrl;
}

public String getDistributionDownloadUrl() {
if (distributionDownloadUrl == null || distributionDownloadUrl.isEmpty()) {
return null;
}
return distributionDownloadUrl;
}

public void setDistributionDownloadUrl(String distributionDownloadUrl) {
this.distributionDownloadUrl = distributionDownloadUrl;
}

public void setDistribution(String distribution, String function) {
if ("information".equals(function)) {
setDistributionUrl(distribution);
} else if ("download".equals(function)) {
setDistributionDownloadUrl(distribution);
}
}

public BigDecimal getEmlVersion() {
return emlVersion;
}
Expand Down Expand Up @@ -1217,6 +1240,7 @@ public boolean equals(Object o) {
&& Objects.equals(citation, eml.citation)
&& Objects.equals(dateStamp, eml.dateStamp)
&& Objects.equals(distributionUrl, eml.distributionUrl)
&& Objects.equals(distributionDownloadUrl, eml.distributionDownloadUrl)
&& Objects.equals(emlVersion, eml.emlVersion)
&& Objects.equals(previousEmlVersion, eml.previousEmlVersion)
&& Objects.equals(geospatialCoverages, eml.geospatialCoverages)
Expand Down Expand Up @@ -1262,6 +1286,7 @@ public int hashCode() {
citation,
dateStamp,
distributionUrl,
distributionDownloadUrl,
emlVersion,
previousEmlVersion,
majorVersion,
Expand Down Expand Up @@ -1309,6 +1334,7 @@ public String toString() {
.add("citation=" + citation)
.add("dateStamp=" + dateStamp)
.add("distributionUrl='" + distributionUrl + "'")
.add("distributionDownloadUrl='" + distributionDownloadUrl + "'")
.add("emlVersion=" + emlVersion)
.add("previousEmlVersion=" + previousEmlVersion)
.add("majorVersion=" + majorVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@
</online>
</distribution>
</#if>
<#if (eml.getDistributionDownloadUrl())??>
<distribution scope="document">
<online>
<url function="download">${eml.distributionDownloadUrl!}</url>
</online>
</distribution>
</#if>
<#if ((eml.geospatialCoverages ? size > 0)
|| (eml.taxonomicCoverages ? size > 0)
|| (eml.temporalCoverages ? size > 0))>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ public void testBuild() {
assertNotNull(eml.getDistributionUrl());
assertEquals("http://www.any.org/fauna/coleoptera/beetleList.html", eml.getDistributionUrl());

// download URL
assertNotNull(eml.getDistributionDownloadUrl());
assertEquals("https://ipt.gbif.org/archive.do?r=res", eml.getDistributionDownloadUrl());

// geospatial coverages tests
assertNotNull(eml.getGeospatialCoverages());
assertEquals(2, eml.getGeospatialCoverages().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
</url>
</online>
</distribution>
<distribution scope="document">
<online>
<url function="download">https://ipt.gbif.org/archive.do?r=res</url>
</online>
</distribution>

<!-- 3 types of coverage are supported with example repetition -->
<coverage>
Expand Down

0 comments on commit 1549632

Please sign in to comment.