working on wiki db transition
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -11,4 +11,6 @@ public interface NoteService {
|
||||
Map<Long,Note> getNotes(String module, String entityId) throws UmbrellaException;
|
||||
|
||||
Note save(Note note);
|
||||
|
||||
void updateId(String module, Object oldId, Object newId);
|
||||
}
|
||||
|
||||
@@ -14,17 +14,19 @@ import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFi
|
||||
|
||||
public class WikiPage implements Mappable {
|
||||
|
||||
private String id;
|
||||
private long id;
|
||||
private String title;
|
||||
private int version;
|
||||
private final List<Integer> versions = new ArrayList<>();
|
||||
private final Map<Long,Member> members = new HashMap<>();
|
||||
private String content;
|
||||
private Set<String> dirtyFields = new HashSet<>();
|
||||
|
||||
public WikiPage(String id, int version, String content) {
|
||||
public WikiPage(long id, String title, int version, String content) {
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
this.content = content;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String content(){
|
||||
@@ -43,14 +45,12 @@ public class WikiPage implements Mappable {
|
||||
return Set.copyOf(dirtyFields);
|
||||
}
|
||||
|
||||
public String id(){
|
||||
public long id(){
|
||||
return id;
|
||||
}
|
||||
|
||||
private WikiPage id(String newVal) {
|
||||
if (id.equals(newVal)) return this;
|
||||
public WikiPage id(long newVal){
|
||||
id = newVal;
|
||||
dirtyFields.add(ID);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class WikiPage implements Mappable {
|
||||
}
|
||||
|
||||
public static WikiPage of(ResultSet rs) throws SQLException {
|
||||
return new WikiPage(rs.getString(ID),rs.getInt(VERSION),rs.getString(CONTENT));
|
||||
return new WikiPage(rs.getLong(ID), rs.getString(TITLE),rs.getInt(VERSION),rs.getString(CONTENT));
|
||||
}
|
||||
|
||||
public WikiPage patch(JSONObject json, UserService users) {
|
||||
@@ -72,7 +72,7 @@ public class WikiPage implements Mappable {
|
||||
switch (key){
|
||||
case ID:
|
||||
if (!(val instanceof String s)) throw invalidFieldException(ID,"String");
|
||||
id(s);
|
||||
title(s);
|
||||
break;
|
||||
case CONTENT:
|
||||
if (!(val instanceof String s)) throw invalidFieldException(CONTENT,"String");
|
||||
@@ -106,6 +106,17 @@ public class WikiPage implements Mappable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String title(){
|
||||
return title;
|
||||
}
|
||||
|
||||
private WikiPage title(String newVal) {
|
||||
if (title.equals(newVal)) return this;
|
||||
title = newVal;
|
||||
dirtyFields.add(TITLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
var memberMap = new HashMap<Long,Map<String,Object>>();
|
||||
|
||||
Reference in New Issue
Block a user