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

Merge branch 'legacy-0.6' into dev

parents 3f0f6c88 7107f213
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
	<properties>
		<!-- REDMIC -->
		<redmic.db-commons.version>0.6.0</redmic.db-commons.version>
		<redmic.models.version>0.6.1</redmic.models.version>
		<redmic.models.version>0.6.1-legacy-0.6</redmic.models.version>
		<redmic.exceptions.version>0.6.0</redmic.exceptions.version>

		<!-- OTHER -->
@@ -74,6 +74,18 @@
			<artifactId>hibernate-spatial</artifactId>
		</dependency>

		<!-- Logs -->
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<scope>provided</scope>
		</dependency>

		<!-- Test -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
+34 −21
Original line number Diff line number Diff line
package es.redmic.db.administrative.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.util.HashSet;
import java.util.Set;

import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

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

@@ -52,7 +38,12 @@ public class Activity extends ActivityBase {
	@Column(name = "activitycategory", length = 2)
	private String activityCategory;

	// 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>();

	public Activity() {
		// Constructor por defecto para que accedan los mappers
	}

	public ActivityType getActivityType() {
@@ -78,4 +69,26 @@ public class Activity extends ActivityBase {
	public void setActivityCategory(String activityCategory) {
		this.activityCategory = activityCategory;
	}

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

	public void setResources(Set<ActivityResource> activityResources) {

		this.resources.clear();

		if (activityResources == null)
			return;

		for (ActivityResource resource: activityResources)
			addResource(resource);
	}

	public ActivityResource addResource(ActivityResource resource) {

		resource.setActivity(this);
		getResources().add(resource);
		return resource;
	}
}
+72 −0
Original line number Diff line number Diff line
package es.redmic.db.administrative.model;

import java.io.Serializable;

import javax.persistence.Column;
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;

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

	@ManyToOne
	@JoinColumn(name = "activityid", nullable = false)
	private ActivityBase activity;

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

	@Column(length = 1500)
	private String description;

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

	public ActivityResource() {
		// Constructor por defecto para que accedan los mappers
	}

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

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

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

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

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

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

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

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

import es.redmic.databaselib.common.repository.BaseRepository;
import es.redmic.db.administrative.model.ActivityResource;

public interface ActivityResourceRepository extends BaseRepository<ActivityResource, Long> {

}
+1 −2
Original line number Diff line number Diff line
@@ -108,13 +108,12 @@ public abstract class ServiceRWImpl<TModel extends LongModel, TDTO extends DTO>
	public TModel persist(TModel model) {
		try {
			model = repository.saveAndFlush(model);
			repository.refresh(model);
			return findById(model.getId());
		} catch (DataIntegrityViolationException e) {
			throw new DBConstraintViolationException(e);
		} catch (ConstraintViolationException e) {
			throw new DBPropertyValueException(e);
		}
		return model;
	}

	@Override