Commit c83ced1c authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade edición de actividades para una capa

De esta manera se puede relacionar una capa con distintas actividades
directamente desde el servicio y no desde geoserver

Adapta tests
parent 820f4785
Loading
Loading
Loading
Loading
+6 −49
Original line number Diff line number Diff line
@@ -25,18 +25,17 @@ import javax.validation.constraints.NotNull;
import org.apache.avro.Schema;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase
		implements org.apache.avro.specific.SpecificRecord {
@JsonIgnoreProperties(ignoreUnknown = true)
public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {

	// @formatter:off

	@JsonIgnore
	public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse(
		"{\"type\":\"record\",\"name\":\"ActivityDTO\",\"namespace\":\"es.redmic.atlaslib.dto.layer\",\"fields\":["
				+ "{\"name\": \"id\",\"type\": \"string\"},"
				+ "{\"name\": \"name\",\"type\": [\"string\", \"null\"]},"
				+ "{\"name\": \"path\",\"type\": [\"string\", \"null\"]}]}");
				+ "{\"name\": \"id\",\"type\": \"string\"}]}");
	// @formatter:on

	public ActivityDTO() {
@@ -45,10 +44,6 @@ public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase
	@NotNull
	String id;

	private String name;

	private String path;

	public String getId() {
		return id;
	}
@@ -57,29 +52,11 @@ public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getName() {
		return name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

@@ -97,16 +74,6 @@ public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (path == null) {
			if (other.path != null)
				return false;
		} else if (!path.equals(other.path))
			return false;
		return true;
	}

@@ -122,10 +89,6 @@ public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase
		switch (field$) {
		case 0:
			return id;
		case 1:
			return name;
		case 2:
			return path;
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
		}
@@ -138,12 +101,6 @@ public class ActivityDTO extends org.apache.avro.specific.SpecificRecordBase
		case 0:
			id = value$ != null ? value$.toString() : null;
			break;
		case 1:
			name = value$ != null ? value$.toString() : null;
			break;
		case 2:
			path = value$ != null ? value$.toString() : null;
			break;
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
		}
+81 −0
Original line number Diff line number Diff line
package es.redmic.atlaslib.dto.layer;

/*-
 * #%L
 * Atlas-lib
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */


import org.apache.avro.Schema;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaUrl;

public class LayerActivityDTO extends org.apache.avro.specific.SpecificRecordBase {

	// @formatter:off

	@JsonIgnore
	public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse(
		"{\"type\":\"record\",\"name\":\"LayerActivityDTO\",\"namespace\":\"es.redmic.atlaslib.dto.layer\",\"fields\":["
				+ "{\"name\": \"activity\",\"type\":" + ActivityDTO.SCHEMA$ + "}]}");
	// @formatter:on

	public LayerActivityDTO() {
	}

	@JsonSchemaUrl(value="controller.mapping.ACTIVITY")
	private ActivityDTO activity;

	public ActivityDTO getActivity() {
		return this.activity;
	}

	public void setActivity(ActivityDTO activity) {
		this.activity = activity;
	}

	@JsonIgnore
	@Override
	public Schema getSchema() {
		return SCHEMA$;
	}

	@JsonIgnore
	@Override
	public java.lang.Object get(int field$) {
		switch (field$) {
		case 0:
			return activity;
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
		}
	}

	@JsonIgnore
	@Override
	public void put(int field$, java.lang.Object value$) {
		switch (field$) {
		case 0:
			activity = (ActivityDTO) value$;
			break;
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
		}
	}
}
+22 −3
Original line number Diff line number Diff line
@@ -39,9 +39,14 @@ public abstract class LayerCompactDTO extends LayerBaseDTO {

	public LayerCompactDTO() {
		super();
		this.protocols = new ArrayList<ProtocolDTO>();
		this.protocols = new ArrayList<>();
		this.activities = new ArrayList<>();
	}

	@JsonSchemaUniqueItemsByRequiredProperties
	@Valid
	private List<LayerActivityDTO> activities;

	@JsonDeserialize(using = CustomRelationDeserializer.class)
	@JsonSchemaUrl(value = "controller.mapping.THEME_INSPIRE")
	private ThemeInspireDTO themeInspire;
@@ -72,6 +77,14 @@ public abstract class LayerCompactDTO extends LayerBaseDTO {
	@NotNull
	private String urlSource;

	public List<LayerActivityDTO> getActivities() {
		return this.activities;
	}

	public void setActivities(List<LayerActivityDTO> activities) {
		this.activities = activities;
	}

	public ThemeInspireDTO getThemeInspire() {
		return themeInspire;
	}
@@ -148,6 +161,7 @@ public abstract class LayerCompactDTO extends LayerBaseDTO {
		result = prime * result + ((refresh == null) ? 0 : refresh.hashCode());
		result = prime * result + ((urlSource == null) ? 0 : urlSource.hashCode());
		result = prime * result + ((themeInspire == null) ? 0 : themeInspire.hashCode());
		result = prime * result + ((activities == null) ? 0 : activities.hashCode());
		return result;
	}

@@ -200,6 +214,11 @@ public abstract class LayerCompactDTO extends LayerBaseDTO {
				return false;
		} else if (!themeInspire.equals(other.themeInspire))
			return false;
		if (activities == null) {
			if (other.activities != null)
				return false;
		} else if (!activities.equals(other.activities))
			return false;
		return true;
	}
}
+28 −45
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ public class LayerDTO extends LayerInfoDTO {
			+ "{\"name\":\"srs\",\"type\":{\"type\":\"array\",\"items\":\"string\"}},"
			+ "{\"name\":\"stylesLayer\",\"type\":[{\"type\": \"array\",\"items\":" + StyleLayerDTO.SCHEMA$ + "},\"null\"]},"
			+ "{\"name\":\"contact\",\"type\":[" + ContactDTO.SCHEMA$ + ",\"null\"]},"
			+ "{\"name\": \"activities\",\"type\": [{\"type\": \"array\",\"items\": "+ ActivityDTO.SCHEMA$ +"},\"null\"]},"
			+ "{\"name\":\"queryable\",\"type\":\"boolean\", \"default\": \"true\"},"
			+ "{\"name\":\"formats\",\"type\":{\"type\":\"array\",\"items\":\"string\"}},"
			+ "{\"name\":\"image\",\"type\":[\"string\", \"null\"]},"
@@ -81,6 +80,7 @@ public class LayerDTO extends LayerInfoDTO {
			+ "{\"name\":\"updated\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}],"
				+ "\"default\": null},"
			+ "{\"name\":\"parent\",\"type\":" + CategoryDTO.SCHEMA$ + "},"
			+ "{\"name\": \"activities\",\"type\": [{\"type\": \"array\",\"items\": "+ LayerActivityDTO.SCHEMA$ +"},\"null\"]},"
			+ "{\"name\":\"themeInspire\",\"type\":["+ ThemeInspireDTO.SCHEMA$ +", \"null\"]},"
			+ "{\"name\":\"latLonBoundsImage\",\"type\":[" + LatLonBoundingBoxDTO.SCHEMA$ + ", \"null\"]},"
			+ "{\"name\": \"protocols\",\"type\": [{\"type\": \"array\",\"items\":" + ProtocolDTO.SCHEMA$ + "},\"null\"]},"
@@ -115,9 +115,6 @@ public class LayerDTO extends LayerInfoDTO {
	@Valid
	private ContactDTO contact;

	@Valid
	private List<ActivityDTO> activities;

	@JsonSchemaDefault(value = "true")
	@NotNull
	private Boolean queryable = true;
@@ -197,14 +194,6 @@ public class LayerDTO extends LayerInfoDTO {
		this.contact = contact;
	}

	public List<ActivityDTO> getActivities() {
		return activities;
	}

	public void setActivities(List<ActivityDTO> activities) {
		this.activities = activities;
	}

	public Boolean getQueryable() {
		return queryable;
	}
@@ -313,34 +302,34 @@ public class LayerDTO extends LayerInfoDTO {
		case 5:
			return contact;
		case 6:
			return activities;
		case 7:
			return queryable;
		case 8:
		case 7:
			return formats;
		case 9:
		case 8:
			return image;
		case 10:
		case 9:
			try {
				return mapper.writeValueAsString(getGeometry());
			} catch (JsonProcessingException e) {
				e.printStackTrace();
				return null;
			}
		case 11:
		case 10:
			return legend;
		case 12:
		case 11:
			return attribution;
		case 13:
		case 12:
			return timeDimension;
		case 14:
		case 13:
			return elevationDimension;
		case 15:
		case 14:
			return getInserted() != null ? getInserted().getMillis() : null;
		case 16:
		case 15:
			return getUpdated() != null ? getUpdated().getMillis() : null;
		case 17:
		case 16:
			return getParent();
		case 17:
			return getActivities();
		case 18:
			return getThemeInspire();
		case 19:
@@ -390,18 +379,15 @@ public class LayerDTO extends LayerInfoDTO {
			contact = value != null ? (ContactDTO) value : null;
			break;
		case 6:
			activities = value != null ? (java.util.List) value : null;
			break;
		case 7:
			queryable = value != null ? (Boolean) value : null;
			break;
		case 8:
		case 7:
			formats = value != null ? getStringList((java.util.List) value) : null;
			break;
		case 9:
		case 8:
			image = value != null ? value.toString() : null;
			break;
		case 10:
		case 9:
			try {
				if (value != null) {
					setGeometry(mapper.readValue(value.toString(), Polygon.class));
@@ -410,27 +396,30 @@ public class LayerDTO extends LayerInfoDTO {
				e.printStackTrace();
			}
			break;
		case 11:
		case 10:
			legend = value != null ? value.toString() : null;
			break;
		case 12:
		case 11:
			attribution = value != null ? (AttributionDTO) value : null;
			break;
		case 13:
		case 12:
			timeDimension = value != null ? (DimensionDTO) value : null;
			break;
		case 14:
		case 13:
			elevationDimension = value != null ? (DimensionDTO) value : null;
			break;
		case 15:
		case 14:
			setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			break;
		case 16:
		case 15:
			setUpdated(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null);
			break;
		case 17:
		case 16:
			setParent((CategoryDTO) value);
			break;
		case 17:
			setActivities(value != null ? (java.util.List) value : null);
			break;
		case 18:
			setThemeInspire(value != null ? (ThemeInspireDTO) value : null);
			break;
@@ -477,7 +466,6 @@ public class LayerDTO extends LayerInfoDTO {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((abstractLayer == null) ? 0 : abstractLayer.hashCode());
		result = prime * result + ((activities == null) ? 0 : activities.hashCode());
		result = prime * result + ((contact == null) ? 0 : contact.hashCode());
		result = prime * result + ((formats == null) ? 0 : formats.hashCode());
		result = prime * result + ((geometry == null) ? 0 : geometry.hashCode());
@@ -510,11 +498,6 @@ public class LayerDTO extends LayerInfoDTO {
				return false;
		} else if (!abstractLayer.equals(other.abstractLayer))
			return false;
		if (activities == null) {
			if (other.activities != null)
				return false;
		} else if (!activities.equals(other.activities))
			return false;
		if (contact == null) {
			if (other.contact != null)
				return false;
+30 −23
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ package es.redmic.atlaslib.dto.layerinfo;
 */

import javax.validation.constraints.NotNull;

import org.apache.avro.Schema;

import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -30,6 +29,8 @@ import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaUrl;

import es.redmic.atlaslib.dto.category.CategoryDTO;
import es.redmic.atlaslib.dto.layer.LatLonBoundingBoxDTO;
import es.redmic.atlaslib.dto.layer.LayerActivityDTO;

import es.redmic.atlaslib.dto.layer.LayerCompactDTO;
import es.redmic.atlaslib.dto.layer.ProtocolDTO;
import es.redmic.atlaslib.dto.themeinspire.ThemeInspireDTO;
@@ -50,6 +51,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\": \"activities\",\"type\": [{\"type\": \"array\",\"items\":" + LayerActivityDTO.SCHEMA$ + "},\"null\"]},"
			+ "{\"name\":\"themeInspire\",\"type\":[" + ThemeInspireDTO.SCHEMA$ + ", \"null\"]},"
			+ "{\"name\":\"latLonBoundsImage\",\"type\":[" + LatLonBoundingBoxDTO.SCHEMA$ + ", \"null\"]},"
			+ "{\"name\": \"protocols\",\"type\": [{\"type\": \"array\",\"items\":" + ProtocolDTO.SCHEMA$ + "},\"null\"]},"
@@ -92,24 +94,26 @@ public class LayerInfoDTO extends LayerCompactDTO {
		case 0:
			return getParent();
		case 1:
			return getThemeInspire();
			return getActivities();
		case 2:
			return getLatLonBoundsImage();
			return getThemeInspire();
		case 3:
			return getProtocols();
			return getLatLonBoundsImage();
		case 4:
			return getDescription();
			return getProtocols();
		case 5:
			return getAlias();
			return getDescription();
		case 6:
			return getAtlas();
			return getAlias();
		case 7:
			return getRefresh();
			return getAtlas();
		case 8:
			return getUrlSource();
			return getRefresh();
		case 9:
			return getName();
			return getUrlSource();
		case 10:
			return getName();
		case 11:
			return getId();
		default:
			throw new org.apache.avro.AvroRuntimeException("Bad index");
@@ -125,33 +129,36 @@ public class LayerInfoDTO extends LayerCompactDTO {
			setParent((CategoryDTO) value);
			break;
		case 1:
			setThemeInspire(value != null ? (ThemeInspireDTO) value : null);
			setActivities(value != null ? (java.util.List) value : null);
			break;
		case 2:
			setLatLonBoundsImage(value != null ? (LatLonBoundingBoxDTO) value : null);
			setThemeInspire(value != null ? (ThemeInspireDTO) value : null);
			break;
		case 3:
			setProtocols(value != null ? (java.util.List) value : null);
			setLatLonBoundsImage(value != null ? (LatLonBoundingBoxDTO) value : null);
			break;
		case 4:
			setDescription(value != null ? value.toString() : null);
			setProtocols(value != null ? (java.util.List) value : null);
			break;
		case 5:
			setAlias(value != null ? value.toString() : null);
			setDescription(value != null ? value.toString() : null);
			break;
		case 6:
			setAtlas((Boolean) value);
			setAlias(value != null ? value.toString() : null);
			break;
		case 7:
			setRefresh((int) value);
			setAtlas((Boolean) value);
			break;
		case 8:
			setUrlSource(value != null ? value.toString() : null);
			setRefresh((int) value);
			break;
		case 9:
			setName(value.toString());
			setUrlSource(value != null ? value.toString() : null);
			break;
		case 10:
			setName(value.toString());
			break;
		case 11:
			setId(value.toString());
			break;
		default:
Loading