-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workspace Add News, Author fixed in Revisions
- Loading branch information
Showing
20 changed files
with
657 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package de.holarse.backend.db; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.JoinTable; | ||
import jakarta.persistence.ManyToMany; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.Table; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Table(name = "news") | ||
@Entity | ||
public class News extends Base { | ||
|
||
private static final long serialVersionUID = 2L; | ||
|
||
@Column(name = "nodeid") | ||
private int nodeId; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "revisionid", referencedColumnName = "id") | ||
private NewsRevision newsRevision; | ||
|
||
@Column(name = "drupalid") | ||
private Integer drupalId; | ||
|
||
@OneToOne(cascade = { CascadeType.ALL }) | ||
@JoinColumn(name="nodeid", insertable=false, nullable=false, updatable = false, referencedColumnName = "nodeid") | ||
private NodeStatus nodeStatus; | ||
|
||
@ManyToMany(cascade = { CascadeType.ALL }) | ||
@JoinTable( | ||
name = "node_tags", | ||
joinColumns = { @JoinColumn(name = "nodeid", insertable=false, nullable=false, updatable = false, referencedColumnName = "nodeid") }, | ||
inverseJoinColumns = { @JoinColumn(name = "tagid") } | ||
) | ||
private Set<Tag> tags = new HashSet<>(); | ||
|
||
@OneToMany(cascade = { CascadeType.ALL }) | ||
@JoinColumn(name="nodeid", referencedColumnName = "nodeid") | ||
private Set<NodeSlug> slugs = new HashSet<>(); // Muss nodeSlugz heissen, weil nodeSlugs in Article referenziert ist. Siehe Bug https://lists.jboss.org/pipermail/hibernate-issues/2011-January/027658.html | ||
|
||
public int getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
public void setNodeId(int nodeId) { | ||
this.nodeId = nodeId; | ||
} | ||
|
||
public Integer getDrupalId() { | ||
return drupalId; | ||
} | ||
|
||
public void setDrupalId(Integer drupalId) { | ||
this.drupalId = drupalId; | ||
} | ||
|
||
public NewsRevision getNewsRevision() { | ||
return newsRevision; | ||
} | ||
|
||
public void setNewsRevision(NewsRevision articleRevision) { | ||
this.newsRevision = newsRevision; | ||
} | ||
|
||
public NodeStatus getNodeStatus() { | ||
return nodeStatus; | ||
} | ||
|
||
public void setNodeStatus(NodeStatus nodeStatus) { | ||
this.nodeStatus = nodeStatus; | ||
} | ||
|
||
public Set<Tag> getTags() { | ||
return tags; | ||
} | ||
|
||
public void setTags(Set<Tag> tags) { | ||
this.tags = tags; | ||
} | ||
|
||
public Set<NodeSlug> getSlugs() { | ||
return slugs; | ||
} | ||
|
||
public void setSlugs(Set<NodeSlug> slugs) { | ||
this.slugs = slugs; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "News{" + | ||
"nodeId=" + nodeId + | ||
", newsRevision=" + newsRevision + | ||
", drupalId=" + drupalId + | ||
", nodeStatus=" + nodeStatus + | ||
", tags=" + tags + | ||
", slugs=" + slugs + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.holarse.backend.db; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
|
||
@Table(name = "news_categories") | ||
@Entity | ||
public class NewsCategory extends Base { | ||
|
||
@Column(length = 255) | ||
private String name; | ||
|
||
@Column(name="active", columnDefinition = "boolean default false") | ||
private boolean active; | ||
|
||
private int weight; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public boolean isActive() { | ||
return active; | ||
} | ||
|
||
public void setActive(boolean active) { | ||
this.active = active; | ||
} | ||
|
||
public int getWeight() { | ||
return weight; | ||
} | ||
|
||
public void setWeight(int weight) { | ||
this.weight = weight; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.holarse.backend.db; | ||
|
||
import jakarta.persistence.*; | ||
|
||
@Table(name = "news_revisions") | ||
@Entity | ||
public class NewsRevision extends RevisionedNode { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Column(length = 255) | ||
private String title; | ||
@Column(length = 16384) | ||
private String content; | ||
|
||
@ManyToOne(cascade = { CascadeType.ALL }) | ||
@JoinColumn(name="news_category_id", referencedColumnName = "id") | ||
private NewsCategory newsCategory; | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
public NewsCategory getNewsCategory() { | ||
return newsCategory; | ||
} | ||
|
||
public void setNewsCategory(NewsCategory newsCategory) { | ||
this.newsCategory = newsCategory; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NewsRevision{" + | ||
"title='" + title + '\'' + | ||
", content='" + content + '\'' + | ||
", newsCategory=" + newsCategory + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.holarse.backend.db; | ||
|
||
import jakarta.persistence.*; | ||
|
||
@MappedSuperclass | ||
public abstract class RevisionedNode extends TimestampedBase { | ||
|
||
@OneToOne(cascade = { CascadeType.ALL }) | ||
@JoinColumn(name="update_userid", referencedColumnName = "id") | ||
private User author; | ||
|
||
@Column(name = "nodeid", nullable = false) | ||
private Integer nodeId; | ||
|
||
@Column(length = 255) | ||
private String changelog; | ||
|
||
@Column(name = "revision", nullable = false) | ||
private Integer revision; | ||
|
||
public Integer getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
public void setNodeId(Integer nodeId) { | ||
this.nodeId = nodeId; | ||
} | ||
|
||
public String getChangelog() { | ||
return changelog; | ||
} | ||
|
||
public void setChangelog(String changelog) { | ||
this.changelog = changelog; | ||
} | ||
|
||
public Integer getRevision() { | ||
return revision; | ||
} | ||
|
||
public void setRevision(Integer revision) { | ||
this.revision = revision; | ||
} | ||
|
||
public User getAuthor() { | ||
return author; | ||
} | ||
|
||
public void setAuthor(User author) { | ||
this.author = author; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/de/holarse/backend/db/repositories/NewsCategoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.holarse.backend.db.repositories; | ||
|
||
import de.holarse.backend.db.NewsCategory; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.List; | ||
|
||
public interface NewsCategoryRepository extends JpaRepository<NewsCategory, Integer> { | ||
|
||
@Query("from NewsCategory nc where nc.active order by nc.weight desc, nc.name") | ||
List<NewsCategory> findActiveCategories(); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/de/holarse/backend/db/repositories/NewsRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.holarse.backend.db.repositories; | ||
|
||
import de.holarse.backend.db.News; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface NewsRepository extends JpaRepository<News, Integer>, NodeAwareRepository { | ||
} |
Oops, something went wrong.