Commit 4ee71f76 authored by Noel Alonso's avatar Noel Alonso
Browse files

Merge branch 'feature-addActivityEmbeddedContent' into 'dev'

Añade campo al ORM

See merge request redmic-project/server/library/db!18
parents c6e4f549 d11a949d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,14 +14,14 @@
	<groupId>es.redmic.lib</groupId>
	<artifactId>db</artifactId>
	<packaging>jar</packaging>
	<version>0.9.0</version>
	<version>0.9.0-feature-addActivityEmbeddedContent</version>
	<name>DB</name>
	<description>Services, repository and models in DB</description>

	<properties>
		<!-- REDMIC -->
		<redmic.db-commons.version>0.7.0</redmic.db-commons.version>
		<redmic.models.version>0.14.0</redmic.models.version>
		<redmic.models.version>0.14.0-feature-addActivityEmbeddedContent</redmic.models.version>
		<redmic.exceptions.version>0.10.0</redmic.exceptions.version>

		<!-- OTHER -->
+30 −4
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ public class Activity extends ActivityBase {
	@OneToMany(mappedBy = "activity", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
	private Set<ActivityResource> resources = new HashSet<>();

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

	public Activity() {
		// Constructor por defecto para que accedan los mappers
	}
@@ -140,10 +144,6 @@ public class Activity extends ActivityBase {
		this.spatialExtension = spatialExtension;
	}

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

	public Boolean getStarred() {
		return this.starred;
	}
@@ -152,6 +152,10 @@ public class Activity extends ActivityBase {
		this.starred = starred;
	}

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

	public void setResources(Set<ActivityResource> activityResources) {

		this.resources.clear();
@@ -169,4 +173,26 @@ public class Activity extends ActivityBase {
		getResources().add(resource);
		return resource;
	}

	public Set<ActivityEmbeddedContent> getEmbeddedContents() {
		return this.embeddedContents;
	}

	public void setEmbeddedContents(Set<ActivityEmbeddedContent> embeddedContents) {

		this.embeddedContents.clear();

		if (embeddedContents == null) {
			return;
		}

		for (ActivityEmbeddedContent embeddedContent: embeddedContents)
			addEmbeddedContent(embeddedContent);
	}

	public ActivityEmbeddedContent addEmbeddedContent(ActivityEmbeddedContent activityEmbeddedContent) {
		activityEmbeddedContent.setActivity(this);
		getEmbeddedContents().add(activityEmbeddedContent);
		return activityEmbeddedContent;
	}
}
+70 −0
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;
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 activityembeddedcontent database table.
 *
 */
@Entity
@Table(name = "activityembeddedcontent")
@NamedQuery(name = "ActivityEmbeddedContent.findAll", query = "SELECT a FROM ActivityEmbeddedContent a")
public class ActivityEmbeddedContent extends LongModel implements Serializable {
	private static final long serialVersionUID = 1L;

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

	@Column(name = "embeddedcontent", length = 50000)
	private String embeddedcontent;

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

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

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

	public String getEmbeddedcontent() {
		return this.embeddedcontent;
	}

	public void setEmbeddedcontent(String embeddedcontent) {
		this.embeddedcontent = embeddedcontent;
	}
}