Commit 8b9bed6b authored by Noel Alonso's avatar Noel Alonso
Browse files

Merge branch 'feature-refactoring' into 'dev'

Actualiza dependencias y adapta código a cambios

See merge request redmic-project/server/library/db!12
parents c47d512a cd0932f1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -14,15 +14,15 @@
	<groupId>es.redmic.lib</groupId>
	<artifactId>db</artifactId>
	<packaging>jar</packaging>
	<version>0.7.0</version>
	<version>0.7.0-feature-refactoring</version>
	<name>DB</name>
	<description>Services, repository and models in DB</description>

	<properties>
		<!-- REDMIC -->
		<redmic.db-commons.version>0.6.0</redmic.db-commons.version>
		<redmic.models.version>0.6.1-legacy-0.6</redmic.models.version>
		<redmic.exceptions.version>0.6.0</redmic.exceptions.version>
		<redmic.db-commons.version>0.7.0</redmic.db-commons.version>
		<redmic.models.version>0.12.0-feature-refactoring</redmic.models.version>
		<redmic.exceptions.version>0.10.0</redmic.exceptions.version>

		<!-- OTHER -->
		<powermock.version>1.7.3</powermock.version>
+79 −1
Original line number Diff line number Diff line
package es.redmic.db.administrative.model;

/*-
 * #%L
 * DB
 * %%
 * Copyright (C) 2019 - 2021 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.HashSet;
import java.util.Set;

@@ -14,6 +34,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import es.redmic.db.maintenance.administrative.model.ActivityType;
import es.redmic.db.maintenance.administrative.model.ThemeInspire;

/**
 * The persistent class for the activity database table.
@@ -35,12 +56,29 @@ public class Activity extends ActivityBase {
	@JoinColumn(name = "embargoid")
	private Embargo embargo;

	// bi-directional many-to-one association to ThemeInspire
	@ManyToOne
	@JoinColumn(name = "themeinspireid")
	private ThemeInspire themeInspire;

	@Column(name = "activitycategory", length = 2)
	private String activityCategory;

	@Column(length = 5000)
	private String licence;

	@Column(length = 5000)
	private String normative;

	@Column(name = "spatialextension")
	private String spatialExtension;

	@Column
	private Boolean starred;

	// bi-directional many-to-one association to ActivityResource
	@OneToMany(mappedBy = "activity", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
	private Set<ActivityResource> resources = new HashSet<ActivityResource>();
	private Set<ActivityResource> resources = new HashSet<>();

	public Activity() {
		// Constructor por defecto para que accedan los mappers
@@ -62,6 +100,14 @@ public class Activity extends ActivityBase {
		this.embargo = embargo;
	}

	public ThemeInspire getThemeInspire() {
		return this.themeInspire;
	}

	public void setThemeInspire(ThemeInspire themeInspire) {
		this.themeInspire = themeInspire;
	}

	public String getActivityCategory() {
		return activityCategory;
	}
@@ -70,10 +116,42 @@ public class Activity extends ActivityBase {
		this.activityCategory = activityCategory;
	}

	public String getLicence() {
		return this.licence;
	}

	public void setLicence(String licence) {
		this.licence = licence;
	}

	public String getNormative() {
		return this.normative;
	}

	public void setNormative(String normative) {
		this.normative = normative;
	}

	public String getSpatialExtension() {
		return this.spatialExtension;
	}

	public void setSpatialExtension(String spatialExtension) {
		this.spatialExtension = spatialExtension;
	}

	public Set<ActivityResource> getResources() {
		return resources;
	}

	public Boolean getStarred() {
		return this.starred;
	}

	public void setStarred(Boolean starred) {
		this.starred = starred;
	}

	public void setResources(Set<ActivityResource> activityResources) {

		this.resources.clear();
+32 −20
Original line number Diff line number Diff line
package es.redmic.db.administrative.model;

/*-
 * #%L
 * DB
 * %%
 * Copyright (C) 2019 - 2021 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;
@@ -10,6 +30,7 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;

import es.redmic.databaselib.common.model.LongModel;
import es.redmic.db.maintenance.administrative.model.ResourceType;

/**
 * The persistent class for the activityresource database table.
@@ -25,14 +46,13 @@ public class ActivityResource extends LongModel implements Serializable {
	@JoinColumn(name = "activityid", nullable = false)
	private ActivityBase activity;

	@Column(nullable = false, length = 100)
	private String name;

	@Column(length = 1500)
	private String description;
	// bi-directional many-to-one association to Rank
	@ManyToOne
	@JoinColumn(name = "resourcetypeid", nullable=false)
	private ResourceType resourcetype;

	@Column(name = "urlresource", length = 500)
	private String urlResource;
	private String urlresource;

	public ActivityResource() {
		// Constructor por defecto para que accedan los mappers
@@ -46,27 +66,19 @@ public class ActivityResource extends LongModel implements Serializable {
		this.activity = activityBase;
	}

	public String getName() {
		return this.name;
	}

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

	public String getDescription() {
		return this.description;
	public ResourceType getResourceType() {
		return this.resourcetype;
	}

	public void setDescription(String description) {
		this.description = description;
	public void setResourceType(ResourceType resourceType) {
		this.resourcetype = resourceType;
	}

	public String getUrlResource() {
		return this.urlResource;
		return this.urlresource;
	}

	public void setUrlResource(String urlResource) {
		this.urlResource = urlResource;
		this.urlresource = urlResource;
	}
}
+20 −0
Original line number Diff line number Diff line
package es.redmic.db.administrative.repository;

/*-
 * #%L
 * DB
 * %%
 * Copyright (C) 2019 - 2021 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 es.redmic.databaselib.common.repository.BaseRepository;
import es.redmic.db.administrative.model.ActivityResource;

+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;
	}
}
Loading