Skip to content

Commit

Permalink
AMQ-Passwörter in Properties verschoben; Wiki-Controller mit Übersich…
Browse files Browse the repository at this point in the history
…t und Artikelanzeige über Slug, Tags in Artikel
  • Loading branch information
commel committed Nov 1, 2023
1 parent c34d3bb commit f453b3d
Show file tree
Hide file tree
Showing 35 changed files with 680 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/db2/01_schema/02b_slugs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
create table if not exists node_slugs(
id integer primary key default nextval('hibernate_sequence'),

nodeid integer not null unique,
nodeid integer not null,

name varchar(255) not null,

Expand Down
9 changes: 9 additions & 0 deletions doc/db2/01_schema/03_articles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ create table if not exists articles(
drupalid integer
);

-- view with all current active and published articles and a slug to link to
create or replace view v_articles as (
SELECT ar.nodeid, ar.revision, ar.title1 as title, sl."name" as slug
FROM article_revisions ar
INNER JOIN articles a on a.versionid = ar.id
inner join node_status ns on ns.nodeid = ar.nodeid
left join node_slugs sl on sl.nodeid = ar.nodeid
WHERE NOT ns.deleted AND ns.published and sl.id = (select max(_ns.id) from node_slugs _ns where _ns.nodeid = ar.nodeid)
);
1 change: 1 addition & 0 deletions doc/db2/01_schema/07_logging.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS node_pagevisits (
url varchar(2083),
useragent varchar(255),
bot boolean DEFAULT false,
internal boolean DEFAULT false,
accessed timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL
) PARTITION BY range(accessed);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/holarse/auth/web/HolarsePrincipal.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.holarse.auth.web;

import de.holarse.backend.db.User;
import static de.holarse.config.RoleUserTypes.ROLE_USER;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -21,7 +22,7 @@ public HolarsePrincipal(final User user) {
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
Set<GrantedAuthority> roles = new HashSet<>();
roles.add(new SimpleGrantedAuthority("ROLE_USER")); // Standardrolle
roles.add(new SimpleGrantedAuthority(ROLE_USER)); // Standardrolle "Gast"
roles.addAll(user.getRoles());

return roles;
Expand Down
38 changes: 37 additions & 1 deletion src/main/java/de/holarse/backend/db/ArticleRevision.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package de.holarse.backend.db;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import java.util.HashSet;
import java.util.Set;

@Table(name = "article_revisions")
@Entity
Expand Down Expand Up @@ -37,7 +45,19 @@ public class ArticleRevision extends TimestampedBase {
private String title7;
@Column(length = 16384)
private String content;


@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="nodeid", referencedColumnName = "nodeid")
private NodeStatus nodeStatus;

@ManyToMany(cascade = { CascadeType.REFRESH })
@JoinTable(
name = "node_tags",
joinColumns = { @JoinColumn(name = "nodeid") },
inverseJoinColumns = { @JoinColumn(name = "tagid") }
)
private Set<Tag> tags = new HashSet<>();

public int getNodeId() {
return nodeId;
}
Expand Down Expand Up @@ -117,5 +137,21 @@ public String getContent() {
public void setContent(String content) {
this.content = content;
}

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

}
66 changes: 66 additions & 0 deletions src/main/java/de/holarse/backend/db/NodeSlug.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.holarse.backend.db;

import de.holarse.backend.types.NodeType;
import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.hibernate.annotations.Type;

@Table(name = "node_slugs")
@Entity
public class NodeSlug extends TimestampedBase {

private static final long serialVersionUID = 1L;

private int nodeId;

@Column(length = 255)
private String name;

@Enumerated(EnumType.STRING)
@Type(PostgreSQLEnumType.class)
@Column(columnDefinition = "node_type", name = "slug_context")
private NodeType slugContext;

@ManyToOne
@JoinColumn(name="update_userid", nullable=false, referencedColumnName = "id")
private User user;

public int getNodeId() {
return nodeId;
}

public void setNodeId(int nodeId) {
this.nodeId = nodeId;
}

public String getName() {
return name;
}

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

public NodeType getSlugContext() {
return slugContext;
}

public void setSlugContext(NodeType slugContext) {
this.slugContext = slugContext;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

}
35 changes: 35 additions & 0 deletions src/main/java/de/holarse/backend/db/NodeTag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.holarse.backend.db;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;

@Entity
@Table(name = "node_tags")
public class NodeTag extends TimestampedBase {

@Column(name = "tagid")
private int tagId;

@Column(name = "nodeid")
private int nodeId;

public int getTagId() {
return tagId;
}

public void setTagId(int tagId) {
this.tagId = tagId;
}

public int getNodeId() {
return nodeId;
}

public void setNodeId(int nodeId) {
this.nodeId = nodeId;
}



}
14 changes: 14 additions & 0 deletions src/main/java/de/holarse/backend/db/PageVisit.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public class PageVisit implements Serializable {
@Column(name="bot", columnDefinition = "boolean default false")
private boolean bot;

/**
* Marks Holarse-Core member access so distinguish external users from "us"
*/
@Column(name="internal", columnDefinition = "boolean default false")
private boolean internal;

@Column(insertable = false, name = "accessed", columnDefinition = "TIMESTAMP WITH TIME ZONE default CURRENT_TIMESTAMP")
private OffsetDateTime accessed;

Expand Down Expand Up @@ -178,5 +184,13 @@ public OffsetDateTime getAccessed() {
public void setAccessed(OffsetDateTime accessed) {
this.accessed = accessed;
}

public boolean isInternal() {
return internal;
}

public void setInternal(boolean internal) {
this.internal = internal;
}

}
82 changes: 82 additions & 0 deletions src/main/java/de/holarse/backend/db/Tag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package de.holarse.backend.db;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "tags")
public class Tag extends TimestampedBase {

@Column(length = 255)
private String name;

@Column(length = 12, name = "name_lang")
private String nameLang;

private int weight;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="aliasid", nullable=true, referencedColumnName = "id")
private Tag alias;

@ManyToOne
@JoinColumn(name="taggroupid", nullable=false, referencedColumnName = "id")
private TagGroup tagGroup;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="update_userid", nullable=true, referencedColumnName = "id")
private User user;

public String getName() {
return name;
}

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

public String getNameLang() {
return nameLang;
}

public void setNameLang(String nameLang) {
this.nameLang = nameLang;
}

public int getWeight() {
return weight;
}

public void setWeight(int weight) {
this.weight = weight;
}

public Tag getAlias() {
return alias;
}

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

public TagGroup getTagGroup() {
return tagGroup;
}

public void setTagGroup(TagGroup tagGroup) {
this.tagGroup = tagGroup;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

}
47 changes: 47 additions & 0 deletions src/main/java/de/holarse/backend/db/TagGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.holarse.backend.db;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Table(name = "taggroups")
@Entity
public class TagGroup extends TimestampedBase {

@Column
private String name;
@Column
private int weight;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="update_userid", nullable=false, referencedColumnName = "id")
private User user;

public String getName() {
return name;
}

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

public int getWeight() {
return weight;
}

public void setWeight(int weight) {
this.weight = weight;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

}
10 changes: 10 additions & 0 deletions src/main/java/de/holarse/backend/db/datasets/CurrentArticle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package de.holarse.backend.db.datasets;

public interface CurrentArticle {

int getNodeId();
int getRevision();
String getTitle1();
String getSlug();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import de.holarse.backend.db.ApiUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ApiUserRepository extends JpaRepository<ApiUser, Integer> {

ApiUser findByLogin(final String login);
Expand Down
Loading

0 comments on commit f453b3d

Please sign in to comment.