Skip to content

Commit

Permalink
Merge pull request #3833 from devgateway/task/AMP-30234/wms-layes-hf3401
Browse files Browse the repository at this point in the history
Task/amp-30234/wms layes hf3401
  • Loading branch information
jdeanquin-dg authored Jun 24, 2021
2 parents 0696045 + f7ae1f8 commit 50fd50f
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 62 deletions.
18 changes: 9 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ stage('Quick Test') {
println "AMP Version: ${codeVersion}"

countries = sh(returnStdout: true,
script: "ssh sulfur 'cd /opt/amp_dbs && amp-db ls ${codeVersion} | sort'")
script: "ssh sulfur.migrated.devgateway.org 'cd /opt/amp_dbs && amp-db ls ${codeVersion} | sort'")
.trim()
if (countries == "") {
println "There are no database backups compatible with ${codeVersion}"
Expand Down Expand Up @@ -153,9 +153,9 @@ stage('Build') {

def format = branch != null ? "%H" : "%P"
def hash = sh(returnStdout: true, script: "git log --pretty=${format} -n 1").trim()
sh(returnStatus: true, script: "docker pull phosphorus:5000/amp-webapp:${tag} > /dev/null")
sh(returnStatus: true, script: "docker pull phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} > /dev/null")
def imageIds = sh(returnStdout: true, script: "docker images -q -f \"label=git-hash=${hash}\"").trim()
sh(returnStatus: true, script: "docker rmi phosphorus:5000/amp-webapp:${tag} > /dev/null")
sh(returnStatus: true, script: "docker rmi phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} > /dev/null")

if (imageIds.equals("")) {
withEnv(["PATH+MAVEN=${tool 'M339'}/bin"]) {
Expand All @@ -166,12 +166,12 @@ stage('Build') {
sh "cd amp && mvn -T 4 clean compile war:exploded ${legacyMvnOptions} -DskipTests -DbuildSource=${tag} -e"

// Build Docker images & push it
sh "docker build -q -t phosphorus:5000/amp-webapp:${tag} --build-arg AMP_EXPLODED_WAR=target/amp --build-arg AMP_PULL_REQUEST='${pr}' --build-arg AMP_BRANCH='${branch}' --build-arg AMP_REGISTRY_PRIVATE_KEY='${registryKey}' --label git-hash='${hash}' amp"
sh "docker push phosphorus:5000/amp-webapp:${tag} > /dev/null"
sh "docker build -q -t phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} --build-arg AMP_EXPLODED_WAR=target/amp --build-arg AMP_PULL_REQUEST='${pr}' --build-arg AMP_BRANCH='${branch}' --build-arg AMP_REGISTRY_PRIVATE_KEY='${registryKey}' --label git-hash='${hash}' amp"
sh "docker push phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} > /dev/null"
} finally {

// Cleanup after Docker & Maven
sh returnStatus: true, script: "docker rmi phosphorus:5000/amp-webapp:${tag}"
sh returnStatus: true, script: "docker rmi phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag}"
sh returnStatus: true, script: "cd amp && mvn clean -Djdbc.db=dummy"
sh returnStatus: true, script: "tar -cf ../amp-node-cache.tar --remove-files" +
" amp/TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node" +
Expand Down Expand Up @@ -203,10 +203,10 @@ stage('Deploy') {
node {
try {
// Find latest database version compatible with ${codeVersion}
dbVersion = sh(returnStdout: true, script: "ssh sulfur 'cd /opt/amp_dbs && amp-db find ${codeVersion} ${country}'").trim()
dbVersion = sh(returnStdout: true, script: "ssh sulfur.migrated.devgateway.org 'cd /opt/amp_dbs && amp-db find ${codeVersion} ${country}'").trim()

// Deploy AMP
sh "ssh sulfur 'cd /opt/docker/amp && ./up.sh ${tag} ${country} ${dbVersion}'"
sh "ssh sulfur.migrated.devgateway.org 'cd /opt/docker/amp && ./up.sh ${tag} ${country} ${dbVersion}'"

slackSend(channel: 'amp-ci', color: 'good', message: "Deploy AMP - Success\nDeployed ${changePretty} will be ready for testing at ${ampUrl} in about 3 minutes")

Expand All @@ -231,7 +231,7 @@ stage('Deploy again') {
}
node {
try {
sh "ssh sulfur 'cd /opt/docker/amp && ./up.sh ${tag} ${country} ${dbVersion}'"
sh "ssh sulfur.migrated.devgateway.org 'cd /opt/docker/amp && ./up.sh ${tag} ${country} ${dbVersion}'"

slackSend(channel: 'amp-ci', color: 'good', message: "Deploy AMP - Success\nDeployed ${changePretty} will be ready for testing at ${ampUrl} in about 3 minutes")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
var Deferred = require('jquery').Deferred;
var when = require('jquery').when;
var $ = require('jquery');
var _ = require('underscore');
var Backbone = require('backbone');
var LoadOnceMixin = require('../../mixins/load-once-mixin');
var L = require('../../../../../node_modules/esri-leaflet/dist/esri-leaflet.js');



module.exports = Backbone.Model
.extend(LoadOnceMixin).extend({
.extend(LoadOnceMixin).extend({

initialize: function() {
// TODO: factor this behavior into an indicator base class
this.listenTo(this, 'change:selected', function(blah, show) {
this.trigger(show ? 'show' : 'hide', this);
initialize: function () {
// TODO: factor this behavior into an indicator base class
this.listenTo(this, 'change:selected', function (blah, show) {
this.trigger(show ? 'show' : 'hide', this);
});
},
fetch: function () {
if (!_(this).has('_wmsLoaded')) {
this._wmsLoaded = new Deferred();;
this.wmsLayer = new L.tileLayer.wms(this.get('link'), {
layers: this.get('layer'),
format: 'image/png',
transparent: true,
opacity: 0.75,
updateWhenIdle:true
});
this._wmsLoaded.resolveWith(this, [this, this.wmsLayer]);
}
return this._wmsLoaded.promise();
},
loadAll: function (options) {
debugger;
return when(this.load(options)).promise().done(function () {
$('#map-loading').hide();
});
},
});
},

fetch: function() {
return (new Deferred()).resolve().promise(); // nothing to actually do here...
}

});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = Backbone.View.extend({

render: function() {
var base = this.model.get('link');
var qs = '?request=GetLegendGraphic&version=1.1.1&format=image/png%26layer=';
var qs = '?request=GetLegendGraphic&version=1.1.1&format=image/png&layer=';
var wmsLayer = this.model.get('layer');
var self = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = Backbone.View.extend({
// only add it to the map if is still selected.
if (layer.get('selected')) {
self.map.addLayer(loadedLayer);
if (loadedLayer.bringToBack) {
if (loadedLayer.bringToBack && layerType !== 'wms') {
loadedLayer.bringToBack();
//TODO: drs, very dirty way of hiding boundaries so they don't hijack click events
// I need to pull out boundaries into own view.
Expand Down Expand Up @@ -205,13 +205,7 @@ module.exports = Backbone.View.extend({
},

getNewWMSLayer: function(layer) {
return L.tileLayer.wms(layer.get('link'), {
layers: layer.get('layer'),
// TODO: should these details be obtained from the API?
format: 'image/png',
transparent: true,
opacity: 0.75
});
return layer.wmsLayer;
},

getNewArcGISLayer: function(layer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ module.exports = Backbone.View.extend({

refresh: function(model_) {
//debugger
if (model_.get('type') === "Indicator Layers" || model_.get('type') === "joinBoundaries") {
if (model_.get('type') === "Indicator Layers"
|| model_.get('type') === "joinBoundaries"
|| model_.get('type') === "wms"
) {
this.model.set('isGapAnalysisAvailable', model_.get('canDoGapAnalysis') && model_.get('selected'));
this.render();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ module.exports = Backbone.View.extend({
},
toggleSelect: function() {
this.model.trigger('toggleSelect', this.model);
if (this.model.get('type') === "Indicator Layers" || this.model.get('type') === "joinBoundaries") {
if (this.model.get('type') === "Indicator Layers"
|| this.model.get('type') === "joinBoundaries"
|| this.model.get('type') === "wms"
) {
debugger;
this.app.mapView.headerGapAnalysisView.refresh(this.model);
}
this.app.translator.translateDOM(this.el);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
filterLayers:function(layers){
return layers.models.filter(function(layer){
return (layer.attributes.type === layerTypes.INDICATOR_LAYERS ||
layer.attributes.type === layerTypes.wms ||
layer.attributes.type === layerTypes.WMS ||
layer.attributes.type === layerTypes.ARCGIS ||
layer.attributes.accessTypeId == accessTypes.STANDARD);

Expand Down
2 changes: 1 addition & 1 deletion amp/TEMPLATE/ampTemplate/site-config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE page [
<!ENTITY ampVersion "${project.version}">
<!ENTITY releaseDate "10.01.2020">
<!ENTITY releaseDate "23.06.2021">
<!ENTITY buildDate "${buildDate}">
<!ENTITY buildSource "${buildSource}">
]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class IndicatorLayers {
private String title;
private String type;
private String link;
private String layer;
private String legendNotes;

public IndicatorLayers() {
Expand Down Expand Up @@ -46,7 +47,16 @@ public void setLink(String link) {
public void setLegendNotes(String legendNotes) {
this.legendNotes = legendNotes;
}

public String getLegendNotes() {
return legendNotes;
}

public String getLayer() {
return layer;
}

public void setLayer(String layer) {
this.layer = layer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public List<IndicatorLayers> getIndicatorLayers() {
String type = MapConstants.mapTypeNames.get(ampMapConfig
.getMapType());
i.setType(type);
i.setLayer(ampMapConfig.getLayer());
indicatorLayers.add(i);
}
return indicatorLayers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ else if (!urlValidator.isValid(cleanedUrl)) {
if (mapForm.getLegend().getFileData().length > 0) map.setLegendImage(mapForm.getLegend().getFileData());
map.setConfigName(mapForm.getConfigName());
map.setCountField(mapForm.getCount());
map.setLayer(mapForm.getLayer());
DbHelper.save(map);

return mapping.findForward("save");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<property name="legendImage" column="legend_image" type="binary" length="500000"/>
<property name="configName" column="config_name" type="java.lang.String" />
<property name="legendNotes" column="legend_notes" type="text" />
<property name="layer" column="layer" type="text" />



Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.digijava.module.esrigis.dbentity;

import static org.digijava.module.esrigis.helpers.MapConstants.mapSubTypeNames;
import static org.digijava.module.esrigis.helpers.MapConstants.mapTypeNames;

public class AmpMapConfig {

private Long id;
Expand All @@ -13,6 +16,7 @@ public class AmpMapConfig {
private byte[] legendImage;
private String configName;
private String legendNotes;
private String layer;

public Long getId() {
return id;
Expand Down Expand Up @@ -92,11 +96,27 @@ public void setConfigName(String configName) {
this.configName = configName;
}


public String getLegendNotes() {
return legendNotes;
}

public void setLegendNotes(String legendNotes) {
this.legendNotes = legendNotes;
}

public String getLayer() {
return layer;
}

public void setLayer(String layer) {
this.layer = layer;
}

public String getMapTypeName() {
return mapTypeNames.get(this.mapType);
}
public String getMapSubTypeName(){
return mapSubTypeNames.get(this.mapSubType);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.digijava.module.esrigis.form;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

public class MapsConfigurationForm extends ActionForm {

/**
Expand All @@ -28,6 +27,7 @@ public class MapsConfigurationForm extends ActionForm {
private HashMap<Integer, String> mapTypeList;
private HashMap<Integer, String> mapSubTypeList;
private String configName;
private String layer;


private boolean reset;
Expand Down Expand Up @@ -158,4 +158,12 @@ public void setLegendNotes(String legendNotes) {
public String getLegendNotes() {
return legendNotes;
}

public String getLayer() {
return layer;
}

public void setLayer(String layer) {
this.layer = layer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public final static class MapType {
public final static Integer BASEMAPS_ROOT = 8;
public final static Integer NATIONAL_LAYER = 9;
public final static Integer INDICATOR_LAYER = 10;
public final static Integer WMS_LAYER = 11;
}
public final static class MapSubType {
public final static Integer BASE = 1;
Expand All @@ -31,6 +32,7 @@ public final static class MapSubType {
mapTypeNames.put(MapType.BASEMAPS_ROOT, "Base Map Root path");
mapTypeNames.put(MapType.NATIONAL_LAYER, "National Layer");
mapTypeNames.put(MapType.INDICATOR_LAYER, "Indicator Layers");
mapTypeNames.put(MapType.WMS_LAYER, "wms");
}

public final static HashMap<Integer, String> mapSubTypeNames = new HashMap<Integer, String>();
Expand Down
2 changes: 1 addition & 1 deletion amp/docker/setenv.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

JAVA_OPTS="-server -Xmx2g -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -DsmtpHost=sulfur -DsmtpFrom=system@digijava.org"
JAVA_OPTS="$JAVA_OPTS -DsmtpHost=sulfur.migrated.devgateway.org -DsmtpFrom=system@digijava.org"
JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=/opt/heapdumps -XX:+HeapDumpOnOutOfMemoryError"

CATALINA_OPTS="-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false"
Expand Down
2 changes: 1 addition & 1 deletion amp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.devgateway</groupId>
<artifactId>amp</artifactId>
<version>3.4</version>
<version>3.4.0.1</version>
<packaging>war</packaging>
<name>Aid Management Platform</name>
<properties>
Expand Down
Loading

0 comments on commit 50fd50f

Please sign in to comment.