Skip to content

Commit

Permalink
Show the MapData button for tabular files #2957
Browse files Browse the repository at this point in the history
  • Loading branch information
raprasad committed Feb 17, 2016
1 parent f37fdbd commit d9c0d30
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,20 @@ public String getDisplayName() {
// currently this method is not being used
return getLatestFileMetadata().getLabel();
}

/**
* Check if the Geospatial Tag has been assigned to this file
* @return
*/
public boolean hasGeospatialTag(){
if (this.dataFileTags == null){
return false;
}
for (DataFileTag tag : this.dataFileTags){
if (tag.isGeospatialTag()){
return true;
}
}
return false;
}
}
15 changes: 15 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFileTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public TagType getType() {
return this.type;
}


public void setType(TagType type) {
this.type = type;
}
Expand All @@ -127,6 +128,20 @@ public String getTypeLabel() {
return null;
}

/**
* Is this a geospatial tag, e.g. TagType.Geospatial
* @return
*/
public boolean isGeospatialTag(){
if (this.type == null){
return false;
}
if (this.type == TagType.Geospatial){
return true;
}
return false;
}

@Override
public int hashCode() {
int hash = 0;
Expand Down
37 changes: 34 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ public boolean canUserSeeMapDataButton(FileMetadata fm){
// (2) Is this file a Shapefile or a Tabular file tagged as Geospatial?
// TO DO: EXPAND FOR TABULAR FILES TAGGED AS GEOSPATIAL!
//
if (!(this.isShapefileType(fm))){
if (!(this.isPotentiallyMappableFileType(fm))){
return false;
}

Expand All @@ -1131,8 +1131,7 @@ public boolean canUserSeeMapDataButton(FileMetadata fm){
if (!settingsService.isTrueForKey(SettingsServiceBean.Key.GeoconnectCreateEditMaps, false)){
return false;
}



// (5) Is File released?
//
if (fm.getDataFile().isReleased()){
Expand All @@ -1143,6 +1142,38 @@ public boolean canUserSeeMapDataButton(FileMetadata fm){
return false;
}


/**
* Check if this is a mappable file type.
*
* Currently (2/2016)
* - Shapefile (zipped shapefile)
* - Tabular file with Geospatial Data tag
*
* @param fm
* @return
*/
private boolean isPotentiallyMappableFileType(FileMetadata fm){
if (fm==null){
return false;
}

// Yes, it's a shapefile
//
if (this.isShapefileType(fm)){
return true;
}

// Yes, it's tabular with a geospatial tag
//
if (fm.getDataFile().isTabularData()){
if (fm.getDataFile().hasGeospatialTag()){
return true;
}
}
return false;
}

/**
* Should there be a Explore WorldMap Button for this file?
* See table in: https://github.com/IQSS/dataverse/issues/1618
Expand Down

0 comments on commit d9c0d30

Please sign in to comment.