Commit 27c95407 authored by Noel Alonso's avatar Noel Alonso
Browse files

Cambia clase que retorna getCapabilities

De este modo devuelve solo los campos que se obtienen en este método,
pudiendo enviarlo a la vista directamente para realizar un
partialUpdated.

Es necesario cambiar los mapper y los componentes que hacen uso de este
método.

Actualiza los tests
parent 5ebfb379
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -26,26 +26,18 @@ import org.mapstruct.NullValuePropertyMappingStrategy;

import es.redmic.atlaslib.dto.layer.LayerDTO;
import es.redmic.atlaslib.dto.layerinfo.LayerInfoDTO;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;

@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface LayerInfoDTOMapper {

	// @formatter:off

	@Mapping(source = "layerInfoDTO.id", target = "id")
	@Mapping(source = "layerDTO.name", target = "name")
	@Mapping(source = "layerInfoDTO.themeInspire", target = "themeInspire")
	@Mapping(source = "layerInfoDTO.latLonBoundsImage", target = "latLonBoundsImage")
	@Mapping(source = "layerInfoDTO.protocols", target = "protocols")
	@Mapping(source = "layerInfoDTO.description", target = "description")
	@Mapping(source = "layerWMSDTO.name", target = "name")
	@Mapping(target = "alias",
		expression = "java(layerInfoDTO.getAlias() != null ? "
				+ "layerInfoDTO.getAlias() : (layerDTO.getTitle() != null ? layerDTO.getTitle() : layerDTO.getName()))")
	@Mapping(source = "layerInfoDTO.atlas", target = "atlas", defaultValue = "false")
	@Mapping(source = "layerInfoDTO.refresh", target = "refresh", defaultValue = "0")
	@Mapping(source = "layerDTO.urlSource", target = "urlSource")
	@Mapping(source = "layerInfoDTO.parent", target = "parent")
	LayerDTO map(LayerInfoDTO layerInfoDTO, LayerDTO layerDTO);
	LayerDTO map(LayerInfoDTO layerInfoDTO, LayerWMSDTO layerWMSDTO);
	
	// @formatter:on
}
+3 −11
Original line number Diff line number Diff line
@@ -40,12 +40,12 @@ import org.mapstruct.Named;
import es.redmic.atlaslib.dto.layer.ActivityDTO;
import es.redmic.atlaslib.dto.layer.AttributionDTO;
import es.redmic.atlaslib.dto.layer.DimensionDTO;
import es.redmic.atlaslib.dto.layer.LayerDTO;
import es.redmic.atlaslib.dto.layer.LogoURLDTO;
import es.redmic.atlaslib.dto.layer.StyleLayerDTO;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;

@Mapper
public interface LayerMapper {
public interface LayerWMSMapper {

	final int SRID = 4326;

@@ -63,8 +63,6 @@ public interface LayerMapper {
			legendGraphicUrlParameters = "?request=GetLegendGraphic&version=1.0.0&format=image/png&layer=topp:states";
	
	// @formatter:on

	@Mapping(source = "layer", target = "urlSource", qualifiedByName = "urlSource")
	@Mapping(source = "layer", target = "legend", qualifiedByName = "legend")
	@Mapping(source = "layer", target = "timeDimension", qualifiedByName = "timeDimension")
	@Mapping(source = "layer", target = "elevationDimension", qualifiedByName = "elevationDimension")
@@ -74,13 +72,7 @@ public interface LayerMapper {
	@Mapping(source = "layer", target = "geometry", qualifiedByName = "geometry")
	@Mapping(source = "layer", target = "keywords", qualifiedByName = "keywords")
	@Mapping(source = "layer", target = "attribution", qualifiedByName = "attribution")
	LayerDTO map(Layer layer, @Context String urlSource);

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

		return urlSource;
	}
	LayerWMSDTO map(Layer layer, @Context String urlSource);

	@Named("legend")
	default String getLegend(Layer layer, @Context String urlSource) {
+4 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import es.redmic.atlascommands.handler.LayerCommandHandler;
import es.redmic.atlascommands.mapper.LayerInfoDTOMapper;
import es.redmic.atlaslib.dto.layer.LayerDTO;
import es.redmic.atlaslib.dto.layerinfo.LayerInfoDTO;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;
import es.redmic.commandslib.service.CommandServiceItfc;

@Service
@@ -55,10 +56,10 @@ public class LayerService implements CommandServiceItfc<LayerInfoDTO> {

		logger.debug("Create Layer");

		LayerDTO layerDTO = ogcService.getLayerFromWMSService(layerInfo.getUrlSource(), layerInfo.getName());
		LayerWMSDTO layerWMSDTO = ogcService.getLayerFromWMSService(layerInfo.getUrlSource(), layerInfo.getName());

		return commandHandler
				.save(new CreateLayerCommand(Mappers.getMapper(LayerInfoDTOMapper.class).map(layerInfo, layerDTO)));
				.save(new CreateLayerCommand(Mappers.getMapper(LayerInfoDTOMapper.class).map(layerInfo, layerWMSDTO)));
	}

	@Override
@@ -66,7 +67,7 @@ public class LayerService implements CommandServiceItfc<LayerInfoDTO> {

		logger.debug("Update Layer");

		LayerDTO layerDTO = ogcService.getLayerFromWMSService(layerInfo.getUrlSource(), layerInfo.getName());
		LayerWMSDTO layerDTO = ogcService.getLayerFromWMSService(layerInfo.getUrlSource(), layerInfo.getName());

		return commandHandler.update(id,
				new UpdateLayerCommand(Mappers.getMapper(LayerInfoDTOMapper.class).map(layerInfo, layerDTO)));
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;

import es.redmic.atlascommands.utils.Capabilities;
import es.redmic.atlaslib.dto.layer.LayerDTO;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;

@Service
public class OGCLayerService {
@@ -37,7 +38,7 @@ public class OGCLayerService {
		return new ArrayList(Capabilities.getCapabilities(urlSource).values());
	}

	public LayerDTO getLayerFromWMSService(String urlSource, String name) {
	public LayerWMSDTO getLayerFromWMSService(String urlSource, String name) {

		return Capabilities.getCapabilities(urlSource).get(name);
	}
+6 −6
Original line number Diff line number Diff line
@@ -34,14 +34,14 @@ import org.mapstruct.factory.Mappers;
import org.opengis.metadata.citation.ResponsibleParty;

import es.redmic.atlascommands.mapper.ContactMapper;
import es.redmic.atlascommands.mapper.LayerMapper;
import es.redmic.atlascommands.mapper.LayerWMSMapper;
import es.redmic.atlaslib.dto.layer.ContactDTO;
import es.redmic.atlaslib.dto.layer.LayerDTO;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;
import es.redmic.exception.custom.ResourceNotFoundException;

public abstract class Capabilities {

	public static HashMap<String, LayerDTO> getCapabilities(String url) {
	public static HashMap<String, LayerWMSDTO> getCapabilities(String url) {

		URL serverURL;

@@ -66,9 +66,9 @@ public abstract class Capabilities {
		return getLayers(url, wms.getCapabilities());
	}

	private static HashMap<String, LayerDTO> getLayers(String url, WMSCapabilities capabilities) {
	private static HashMap<String, LayerWMSDTO> getLayers(String url, WMSCapabilities capabilities) {

		HashMap<String, LayerDTO> layers = new HashMap<String, LayerDTO>();
		HashMap<String, LayerWMSDTO> layers = new HashMap<String, LayerWMSDTO>();

		List<Layer> layerList = capabilities.getLayerList();

@@ -76,7 +76,7 @@ public abstract class Capabilities {

			if (layerList.get(i).getName() != null) {

				LayerDTO layerAux = Mappers.getMapper(LayerMapper.class).map(layerList.get(i), url);
				LayerWMSDTO layerAux = Mappers.getMapper(LayerWMSMapper.class).map(layerList.get(i), url);
				layerAux.setContact(getContact(capabilities.getService().getContactInformation()));
				layerAux.setFormats(capabilities.getRequest().getGetMap().getFormats());
				layers.put(layerAux.getName(), layerAux);
Loading