Skip to content

Commit

Permalink
For #2957, updates to the MapLayerMetadata object, including SQL upda…
Browse files Browse the repository at this point in the history
…te commands to add columns
  • Loading branch information
raprasad committed Feb 22, 2016
1 parent ccad6ee commit 7a7ea6f
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 3 deletions.
9 changes: 9 additions & 0 deletions scripts/database/upgrades/upgrade_v4.2.4_to_v4.3.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- For #2957, additional columns for mapping of tabular data
-- > Distinguishes a mapped Tabular file from a shapefile
ALTER TABLE maplayermetadata ADD COLUMN isjoinlayer BOOLEAN default false;
-- > Description of the tabular join. e.g. joined to layer XYZ on column TRACT, etc
ALTER TABLE maplayermetadata ADD COLUMN joindescription TEXT default NULL;
-- > For all maps, store the WorldMap links to generate alternative versions,
-- e.g. PNG, zipped shapefile, GeoJSON, Excel, etc
ALTER TABLE maplayermetadata ADD COLUMN maplayerlinks TEXT default NULL;

69 changes: 69 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/MapLayerMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ public class MapLayerMetadata implements Serializable {
@NotBlank(message = "Please specify a WorldMap username.")
private String worldmapUsername;


/**
* Was this layer created by joining a tabular file
* to an existing file?
*/
private boolean isJoinLayer;

/**
* Description if this was created via a tabular join,
*/
@Column(columnDefinition = "TEXT")
private String joinDescription;

/**
* Links to alternative representations of the map
* in JSON format
*/
@Column(columnDefinition = "TEXT")
private String mapLayerLinks;



/**
* Get property layerName.
Expand Down Expand Up @@ -162,6 +183,54 @@ public void setWorldmapUsername(String worldmapUsername) {
}


/**
* Get property isJoinLayer.
* @return value of property isJoinLayer.
*/
public boolean isJoinLayer(){
return this.isJoinLayer;
}

/**
* Set property isJoinLayer.
* @param bool new value of property isJoinLayer.
*/
public void setIsJoinLayer(boolean bool) {
this.isJoinLayer = bool;
}

/**
* Get property joinDescription.
* @return value of property joinDescription.
*/
public String getJoinDescription() {
return this.joinDescription;
}

/**
* Set property joinDescription.
* @param joinDescription new value of property joinDescription.
*/
public void setJoinDescription(String joinDescription) {
this.joinDescription = joinDescription;
}

/**
* Get property mapLayerLinks
* @return value of property joinDescription.
*/
public String getMapLayerLinks() {
return this.mapLayerLinks;
}

/**
* Set property joinDescription.
* @param joinDescription new value of property joinDescription.
*/
public void setMapLayerLinks(String mapLayerLinks) {
this.mapLayerLinks = mapLayerLinks;
}

public Dataset getDataset() {
return dataset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,28 @@ public Response updateWorldMapLayerData(String jsonLayerData){
mapLayerMetadata.setMapImageLink(jsonInfo.getString("mapImageLink"));
}

// If this was a tabular join set the attributes:
// - isJoinLayer
// - joinDescription
//
String joinDescription = jsonInfo.getString("joinDescription");
if ((joinDescription == null) || (joinDescription.equals(""))){
mapLayerMetadata.setIsJoinLayer(true);
mapLayerMetadata.setJoinDescription(joinDescription);
}else{
mapLayerMetadata.setIsJoinLayer(false);
mapLayerMetadata.setJoinDescription(null);
}

// Set the mapLayerLinks
//
String mapLayerLinks = jsonInfo.getString("mapLayerLinks");
if (mapLayerLinks == null){
mapLayerMetadata.setMapLayerLinks(null);
}else{
mapLayerMetadata.setMapLayerLinks(mapLayerLinks);
}


//mapLayer.save();
MapLayerMetadata savedMapLayerMetadata = mapLayerMetadataService.save(mapLayerMetadata);
Expand Down
20 changes: 17 additions & 3 deletions src/main/webapp/filesFragmentWorldMapTestQuery.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,24 @@
<ui:fragment rendered="#{ !DatasetPage.canUserSeeExploreWorldMapButton(fileMetadata)}">
<!-- There is NO map data for this file -->

<ui:fragment rendered="#{ (DatasetPage.canSeeTwoRavensExploreButton(fileMetadata) or fileMetadata.dataFile.isShapefileType())}">
<!-- This is either a tabular or shapefile -->
<ui:fragment rendered="#{ DatasetPage.canSeeTwoRavensExploreButton(fileMetadata)}">
<!-- This tabular file -->
to add sample map data:
<textarea><h:outputText escape="false" value="INSERT INTO maplayermetadata VALUES (DEFAULT, 'https://worldmap.harvard.edu/maps/embed/?layer=geonode:zip_codes_2015_zip_s9i','https://worldmap.harvard.edu/data/geonode:zip_codes_2015_zip_s9i',
<textarea><h:outputText escape="false" value="INSERT INTO maplayermetadata (id, isjoinlayer, joindescription, embedmaplink, layerlink, layername, mapimagelink, worldmapusername, dataset_id, datafile_id)
VALUES (DEFAULT, true, 'This file was joined with WorldMap layer x, y, z',
'https://worldmap.harvard.edu/maps/embed/?layer=geonode:zip_codes_2015_zip_s9i','https://worldmap.harvard.edu/data/geonode:zip_codes_2015_zip_s9i',
'geonode:zip_codes_2015_zip_s9i',
'http://worldmap.harvard.edu/download/wms/27289/png?layers=geonode%3Azip_codes_2015_zip_s9i&#38;width=865&#38;bbox=-71.1911091251%2C42.2270382738%2C-70.9228275369%2C42.3976144794&#38;service=WMS&#38;format=image%2Fpng&#38;srs=EPSG%3A4326&#38;request=GetMap&#38;height=550',
'admin',#{DatasetPage.dataset.id},#{fileMetadata.dataFile.id});" />
</textarea>
</ui:fragment>

<ui:fragment rendered="#{fileMetadata.dataFile.isShapefileType()}">
<!-- This is a tabular shapefile -->
to add sample map data:
<textarea><h:outputText escape="false" value="INSERT INTO maplayermetadata (id, isjoinlayer, embedmaplink, layerlink, layername, mapimagelink, worldmapusername, dataset_id, datafile_id)
VALUES (DEFAULT, false,
'https://worldmap.harvard.edu/maps/embed/?layer=geonode:zip_codes_2015_zip_s9i','https://worldmap.harvard.edu/data/geonode:zip_codes_2015_zip_s9i',
'geonode:zip_codes_2015_zip_s9i',
'http://worldmap.harvard.edu/download/wms/27289/png?layers=geonode%3Azip_codes_2015_zip_s9i&#38;width=865&#38;bbox=-71.1911091251%2C42.2270382738%2C-70.9228275369%2C42.3976144794&#38;service=WMS&#38;format=image%2Fpng&#38;srs=EPSG%3A4326&#38;request=GetMap&#38;height=550',
'admin',#{DatasetPage.dataset.id},#{fileMetadata.dataFile.id});" />
Expand Down

0 comments on commit 7a7ea6f

Please sign in to comment.