Commit 62ea8cb4 authored by Noel Alonso's avatar Noel Alonso
Browse files

Cambia funcionalidad del campo legend

En lugar de establecer el de getCapability, se utiliza para
sobrescribir en el caso de necesitar una leyenda externa.
parent 9b040326
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -58,11 +58,9 @@ public interface LayerWMSMapper {
			refInBracketsRegex = ".*(" + refRegex + ").*",
			formatRegex = ".*&format=(\\w*)%2F(\\w*)&.*",
			timeDimensionProperty = "time",
			elevationDimensionProperty = "elevation",
			legendGraphicUrlParameters = "?request=GetLegendGraphic&version=1.0.0&format=image/png&layer=topp:states";
			elevationDimensionProperty = "elevation";

	// @formatter:on
	@Mapping(source = "layer", target = "legend", qualifiedByName = "legend")
	@Mapping(source = "layer", target = "timeDimension", qualifiedByName = "timeDimension")
	@Mapping(source = "layer", target = "elevationDimension", qualifiedByName = "elevationDimension")
	@Mapping(source = "layer", target = "stylesLayer", qualifiedByName = "stylesLayer")
@@ -72,12 +70,6 @@ public interface LayerWMSMapper {
	@Mapping(source = "layer", target = "attribution", qualifiedByName = "attribution")
	LayerWMSDTO map(Layer layer, @Context String urlSource);

	@Named("legend")
	default String getLegend(Layer layer, @Context String urlSource) {

		return urlSource + legendGraphicUrlParameters;
	}

	@Named("timeDimension")
	default DimensionDTO getElevationDimension(Layer layer, @Context String urlSource) {

+15 −31
Original line number Diff line number Diff line
@@ -70,13 +70,13 @@ public class LayerDTO extends LayerInfoDTO {
			+ "{\"name\":\"formats\",\"type\":{\"type\":\"array\",\"items\":\"string\"}},"
			+ "{\"name\":\"image\",\"type\":[\"null\", \"string\"]},"
			+ "{\"name\":\"geometry\",\"type\":\"string\"},"
			+ "{\"name\":\"legend\",\"type\":[\"null\", \"string\"]},"
			+ "{\"name\":\"attibution\",\"type\":[\"null\", " + AttributionDTO.SCHEMA$ + "]},"
			+ "{\"name\":\"timeDimension\",\"type\":[\"null\", " + DimensionDTO.SCHEMA$ + "]},"
			+ "{\"name\":\"elevationDimension\"," + "\"type\":[\"null\", \"es.redmic.atlaslib.dto.layer.DimensionDTO\"]},"
			+ "{\"name\":\"inserted\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}]},"
			+ "{\"name\":\"updated\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}]},"
			+ "{\"name\":\"parent\",\"type\":" + CategoryDTO.SCHEMA$ + "},"
			+ "{\"name\":\"legend\",\"type\":[\"null\", \"string\"]},"
			+ "{\"name\":\"relatedActivities\",\"type\": [\"null\", {\"type\": \"array\",\"items\": "+ LayerActivityDTO.SCHEMA$ +"}]},"
			+ "{\"name\":\"themeInspire\",\"type\":[\"null\", "+ ThemeInspireDTO.SCHEMA$ +"]},"
			+ "{\"name\":\"latLonBoundsImage\",\"type\":[\"null\", " + LatLonBoundingBoxDTO.SCHEMA$ + "]},"
@@ -128,8 +128,6 @@ public class LayerDTO extends LayerInfoDTO {
	@NotNull
	private Polygon geometry;

	private String legend;

	private AttributionDTO attribution;

	private DimensionDTO timeDimension;
@@ -226,14 +224,6 @@ public class LayerDTO extends LayerInfoDTO {
		this.geometry = geometry;
	}

	public String getLegend() {
		return legend;
	}

	public void setLegend(String legend) {
		this.legend = legend;
	}

	public AttributionDTO getAttribution() {
		return attribution;
	}
@@ -315,19 +305,19 @@ public class LayerDTO extends LayerInfoDTO {
				return null;
			}
		case 10:
			return legend;
		case 11:
			return attribution;
		case 12:
		case 11:
			return timeDimension;
		case 13:
		case 12:
			return elevationDimension;
		case 14:
		case 13:
			return getInserted() != null ? getInserted().getMillis() : null;
		case 15:
		case 14:
			return getUpdated() != null ? getUpdated().getMillis() : null;
		case 16:
		case 15:
			return getParent();
		case 16:
			return getLegend();
		case 17:
			return getRelatedActivities();
		case 18:
@@ -403,25 +393,25 @@ public class LayerDTO extends LayerInfoDTO {
			}
			break;
		case 10:
			legend = value != null ? value.toString() : null;
			attribution = value != null ? (AttributionDTO) value : null;
			break;
		case 11:
			attribution = value != null ? (AttributionDTO) value : null;
			timeDimension = value != null ? (DimensionDTO) value : null;
			break;
		case 12:
			timeDimension = value != null ? (DimensionDTO) value : null;
			elevationDimension = value != null ? (DimensionDTO) value : null;
			break;
		case 13:
			elevationDimension = value != null ? (DimensionDTO) value : null;
			setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			break;
		case 14:
			setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			setUpdated(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			break;
		case 15:
			setUpdated(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			setParent((CategoryDTO) value);
			break;
		case 16:
			setParent((CategoryDTO) value);
			setLegend(value != null ? value.toString() : null);
			break;
		case 17:
			setRelatedActivities(value != null ? (java.util.List) value : null);
@@ -484,7 +474,6 @@ public class LayerDTO extends LayerInfoDTO {
		result = prime * result + ((contact == null) ? 0 : contact.hashCode());
		result = prime * result + ((formats == null) ? 0 : formats.hashCode());
		result = prime * result + ((geometry == null) ? 0 : geometry.hashCode());
		result = prime * result + ((legend == null) ? 0 : legend.hashCode());
		result = prime * result + ((attribution == null) ? 0 : attribution.hashCode());
		result = prime * result + ((timeDimension == null) ? 0 : timeDimension.hashCode());
		result = prime * result + ((elevationDimension == null) ? 0 : elevationDimension.hashCode());
@@ -528,11 +517,6 @@ public class LayerDTO extends LayerInfoDTO {
				return false;
		} else if (!geometry.equals(other.geometry))
			return false;
		if (legend == null) {
			if (other.legend != null)
				return false;
		} else if (!legend.equals(other.legend))
			return false;
		if (attribution == null) {
			if (other.attribution != null)
				return false;
+16 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public class LayerInfoDTO extends LayerCompactDTO {
	public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse(
		"{\"type\":\"record\",\"name\":\"LayerDTO\",\"namespace\":\"es.redmic.atlaslib.dto.layerinfo\",\"fields\":["
			+ "{\"name\":\"parent\",\"type\":" + CategoryDTO.SCHEMA$ + "},"
			+ "{\"name\":\"legend\",\"type\":[\"null\", \"string\"]},"
			+ "{\"name\":\"relatedActivities\",\"type\": [\"null\", {\"type\": \"array\",\"items\": "+ LayerActivityDTO.SCHEMA$ +"}]},"
			+ "{\"name\":\"themeInspire\",\"type\":[\"null\", " + ThemeInspireDTO.SCHEMA$ + "]},"
			+ "{\"name\":\"latLonBoundsImage\",\"type\":[\"null\", " + LatLonBoundingBoxDTO.SCHEMA$ + "]},"
@@ -79,6 +80,8 @@ public class LayerInfoDTO extends LayerCompactDTO {
	@JsonSchemaUrlUuid(value = "controller.mapping.CATEGORY")
	CategoryDTO parent;

	private String legend;

	public CategoryDTO getParent() {
		return parent;
	}
@@ -87,6 +90,14 @@ public class LayerInfoDTO extends LayerCompactDTO {
		this.parent = parent;
	}

	public String getLegend() {
		return legend;
	}

	public void setLegend(String legend) {
		this.legend = legend;
	}

	@JsonIgnore
	@Override
	public Schema getSchema() {
@@ -209,6 +220,11 @@ public class LayerInfoDTO extends LayerCompactDTO {
				return false;
		} else if (!parent.equals(other.parent))
			return false;
		if (legend == null) {
			if (other.legend != null)
				return false;
		} else if (!legend.equals(other.legend))
			return false;
		return true;
	}
}
+8 −30
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ public class LayerWMSDTO extends LayerBaseDTO {
			+ "{\"name\":\"formats\",\"type\":{\"type\":\"array\",\"items\":\"string\"}},"
			+ "{\"name\":\"image\",\"type\":[\"string\", \"null\"]},"
			+ "{\"name\":\"geometry\",\"type\":\"string\"},"
			+ "{\"name\":\"legend\",\"type\":[\"string\", \"null\"]},"
			+ "{\"name\":\"attibution\",\"type\":[" + AttributionDTO.SCHEMA$ + ",\"null\"]},"
			+ "{\"name\":\"timeDimension\",\"type\":[" + DimensionDTO.SCHEMA$ + ",\"null\"]},"
			+ "{\"name\":\"elevationDimension\"," + "\"type\":"
@@ -109,8 +108,6 @@ public class LayerWMSDTO extends LayerBaseDTO {
	@NotNull
	private Polygon geometry;

	private String legend;

	private AttributionDTO attribution;

	private DimensionDTO timeDimension;
@@ -197,14 +194,6 @@ public class LayerWMSDTO extends LayerBaseDTO {
		this.geometry = geometry;
	}

	public String getLegend() {
		return legend;
	}

	public void setLegend(String legend) {
		this.legend = legend;
	}

	public AttributionDTO getAttribution() {
		return attribution;
	}
@@ -265,16 +254,14 @@ public class LayerWMSDTO extends LayerBaseDTO {
				return null;
			}
		case 10:
			return legend;
		case 11:
			return attribution;
		case 12:
		case 11:
			return timeDimension;
		case 13:
		case 12:
			return elevationDimension;
		case 14:
		case 13:
			return getName();
		case 15:
		case 14:
			return getId();
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
@@ -323,21 +310,18 @@ public class LayerWMSDTO extends LayerBaseDTO {
			}
			break;
		case 10:
			legend = value != null ? value.toString() : null;
			break;
		case 11:
			attribution = value != null ? (AttributionDTO) value : null;
			break;
		case 12:
		case 11:
			timeDimension = value != null ? (DimensionDTO) value : null;
			break;
		case 13:
		case 12:
			elevationDimension = value != null ? (DimensionDTO) value : null;
			break;
		case 14:
		case 13:
			setName(value.toString());
			break;
		case 15:
		case 14:
			setId(value.toString());
			break;
		default:
@@ -359,7 +343,6 @@ public class LayerWMSDTO extends LayerBaseDTO {
		result = prime * result + ((contact == null) ? 0 : contact.hashCode());
		result = prime * result + ((formats == null) ? 0 : formats.hashCode());
		result = prime * result + ((geometry == null) ? 0 : geometry.hashCode());
		result = prime * result + ((legend == null) ? 0 : legend.hashCode());
		result = prime * result + ((attribution == null) ? 0 : attribution.hashCode());
		result = prime * result + ((timeDimension == null) ? 0 : timeDimension.hashCode());
		result = prime * result + ((elevationDimension == null) ? 0 : elevationDimension.hashCode());
@@ -401,11 +384,6 @@ public class LayerWMSDTO extends LayerBaseDTO {
				return false;
		} else if (!geometry.equals(other.geometry))
			return false;
		if (legend == null) {
			if (other.legend != null)
				return false;
		} else if (!legend.equals(other.legend))
			return false;
		if (attribution == null) {
			if (other.attribution != null)
				return false;
+26 −2
Original line number Diff line number Diff line
@@ -284,4 +284,28 @@ public class LayerInfoEqualTest {
		dto1.setParent(null);
		assertFalse(dto1.equals(dto2));
	}

	@Test
	public void equal_returnFalse_IfLayerInfoLegendIsDifferent() {

		LayerInfoDTO dto1 = LayerDataUtil.getLayerInfo();

		LayerInfoDTO dto2 = LayerDataUtil.getLayerInfo();

		dto1.setLegend("aaaa");

		assertFalse(dto1.equals(dto2));
	}

	@Test
	public void equal_returnFalse_IfLayerInfoLegendIsNull() {

		LayerInfoDTO dto1 = LayerDataUtil.getLayerInfo();

		LayerInfoDTO dto2 = LayerDataUtil.getLayerInfo();

		dto1.setLegend(null);
		assertFalse(dto1.equals(dto2));
	}

}
Loading