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

Elimina componentes no usados de atlas

parent f685f017
Loading
Loading
Loading
Loading
+0 −80
Original line number Diff line number Diff line
package es.redmic.db.atlas.layer.mapper;

/*-
 * #%L
 * DB
 * %%
 * 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 java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import es.redmic.db.atlas.layer.model.Layer;
import es.redmic.models.es.atlas.LatLonBoundingBox;
import es.redmic.models.es.atlas.dto.LayerDTO;
import ma.glasnost.orika.CustomMapper;
import ma.glasnost.orika.MappingContext;

@Component
public class LayerMapper extends CustomMapper<Layer, LayerDTO> {
	
	@Value("${property.URL_LAYERS_MEDIASTORAGE}")
	private String URL_LAYERS;
	
	@Override
	public void mapAtoB(Layer a, LayerDTO b, MappingContext context) {
		
		if (a.getLatLonBoundsImage() != null && a.getLatLonBoundsImage().length > 0) {
			b.setLatLonBoundsImage(getLatLonBoundsImageDTO(a.getLatLonBoundsImage()));
			b.setImage(URL_LAYERS + a.getId() + ".png");
		}
	}

	@Override
	public void mapBtoA(LayerDTO b, Layer a, MappingContext context) {
		
		if (b.getLatLonBoundsImage() != null)
			a.setLatLonBoundsImage(getLatLonBoundsImage(b.getLatLonBoundsImage()));
	}
	
	private Double[] getLatLonBoundsImage(LatLonBoundingBox latLonBoundingBoxDTO) {
		
		List<Double> latLonBoundsImage = new ArrayList<Double>();
		latLonBoundsImage.add(latLonBoundingBoxDTO.getMaxX());
		latLonBoundsImage.add(latLonBoundingBoxDTO.getMaxY());
		latLonBoundsImage.add(latLonBoundingBoxDTO.getMinX());
		latLonBoundsImage.add(latLonBoundingBoxDTO.getMinY());
		return latLonBoundsImage.toArray(new Double[latLonBoundsImage.size()]);
	}
	
	private LatLonBoundingBox getLatLonBoundsImageDTO(Double[] latLonBoundingBox) {
		
		if (latLonBoundingBox == null || latLonBoundingBox.length < 4)
			return null;
		
		LatLonBoundingBox latLonBoundsImageDTO = new LatLonBoundingBox();
		latLonBoundsImageDTO.setMaxX(latLonBoundingBox[0]);
		latLonBoundsImageDTO.setMaxY(latLonBoundingBox[1]);
		latLonBoundsImageDTO.setMinX(latLonBoundingBox[2]);
		latLonBoundsImageDTO.setMinY(latLonBoundingBox[3]);
		
		return latLonBoundsImageDTO;
	}
}
+0 −177
Original line number Diff line number Diff line
package es.redmic.db.atlas.layer.model;

/*-
 * #%L
 * DB
 * %%
 * 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 java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Type;

import es.redmic.databaselib.common.model.LongModel;

@Entity
@Table(name = "servicewms")
@NamedQuery(name = "Layer.findAll", query = "SELECT l FROM Layer l")
public class Layer extends LongModel implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private String name;
	
	private String description;
	
	private String alias;
	
	private Boolean atlas;
	
	@OneToMany(mappedBy = "layer", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
	private Set<Protocols> protocols = new HashSet<Protocols>();

	@Type(type = "es.redmic.db.common.type.DoubleArrayType")
	@Column(name="latlonboundsimage")
	private Double[] latLonBoundsImage;
	
	@Column(name="urlsource")
	private String urlSource;
	
	@Transient
	private String path;
	
	@ManyToOne
	@JoinColumn(name = "parentid")
	private Layer parent;
	
	@ManyToOne
	@JoinColumn(name = "themeinspireid")
	private ThemeInspire themeInspire;

	public String getName() {
		return name;
	}

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

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	public Boolean getAtlas() {
		return atlas;
	}

	public void setAtlas(Boolean atlas) {
		this.atlas = atlas;
	}

	public Set<Protocols> getProtocols() {
		return protocols;
	}

	public void setProtocols(Set<Protocols> protocols) {
		
		this.protocols.clear();
		
		if (protocols == null)
			return;
			
		for (Protocols protocol : protocols)
			addProtocol(protocol);
	}

	public Protocols addProtocol(Protocols protocol) {
		
		protocol.setLayer(this);
		getProtocols().add(protocol);
		return protocol;
	}
	
	public void removeProtocol(Protocols protocol) {
		
		protocol.setLayer(null);
		getProtocols().remove(protocol);
	}

	public Double[] getLatLonBoundsImage() {
		return latLonBoundsImage;
	}

	public void setLatLonBoundsImage(Double[] latLonBoundsImage) {
		this.latLonBoundsImage = latLonBoundsImage;
	}

	public String getUrlSource() {
		return urlSource;
	}

	public void setUrlSource(String urlSource) {
		this.urlSource = urlSource;
	}

	public String getPath() {
		return path;
	}

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

	public Layer getParent() {
		return parent;
	}

	public void setParent(Layer parent) {
		this.parent = parent;
	}
	
	public ThemeInspire getThemeInspire() {
		return themeInspire;
	}

	public void setThemeInspire(ThemeInspire themeInspire) {
		this.themeInspire = themeInspire;
	}
}
+0 −71
Original line number Diff line number Diff line
package es.redmic.db.atlas.layer.model;

/*-
 * #%L
 * DB
 * %%
 * 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 java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import es.redmic.databaselib.common.model.LongModel;

@Entity
@Table(name = "protocols")
@NamedQuery(name = "Protocols.findAll", query = "SELECT p FROM Protocols p")
public class Protocols extends LongModel implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private String type;
	
	private String url;
	
	@ManyToOne
	@JoinColumn(name = "servicewmsid", nullable = false)
	private Layer layer;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Layer getLayer() {
		return layer;
	}

	public void setLayer(Layer layer) {
		this.layer = layer;
	}
}
+0 −57
Original line number Diff line number Diff line
package es.redmic.db.atlas.layer.model;

/*-
 * #%L
 * DB
 * %%
 * 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 java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import es.redmic.db.common.model.DomainModel;


/**
 * The persistent class for the themeinspire database table.
 * 
 */
@Entity
@Table(name="themeinspire")
@NamedQuery(name = "ThemeInspire.findAll", query = "SELECT a FROM ThemeInspire a")
public class ThemeInspire extends DomainModel implements Serializable {
	private static final long serialVersionUID = 1L;

	@Column(length = 50)
	private String code;
	
	public ThemeInspire() {
		
	}
	
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}
}
+0 −35
Original line number Diff line number Diff line
package es.redmic.db.atlas.layer.repository;

/*-
 * #%L
 * DB
 * %%
 * 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.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import es.redmic.databaselib.common.repository.BaseRepository;
import es.redmic.db.atlas.layer.model.Layer;

@Repository
public interface LayerRepository extends BaseRepository<Layer, Long> {

	@Query("SELECT l FROM Layer l WHERE l.name = :name AND l.urlSource = :urlSource")
	Layer findByNameAndUrlSource(@Param("name") String name, @Param("urlSource") String urlSource);
}
Loading