working implementation of journal display
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -13,7 +13,7 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Bookmark extends ObjectWithId {
|
||||
public final class Bookmark extends UmbrellaObject {
|
||||
private final String url;
|
||||
private final String comment;
|
||||
private final LocalDateTime timestamp;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Item extends ObjectWithId {
|
||||
public class Item extends UmbrellaObject {
|
||||
private long ownerNumber; // id is the database key, number the owner-relative id
|
||||
private final Owner owner;
|
||||
private String code, description, name;
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Project extends ObjectWithId {
|
||||
public class Project extends UmbrellaObject {
|
||||
private final Map<Long,Member> members;
|
||||
private final Collection<Status> allowedStates;
|
||||
private boolean showClosed;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Task extends ObjectWithId {
|
||||
public class Task extends UmbrellaObject {
|
||||
public static final System.Logger LOG = System.getLogger(Task.class.getSimpleName());
|
||||
private final long projectId;
|
||||
private Long parentTaskId;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Transaction extends ObjectWithId {
|
||||
public class Transaction extends UmbrellaObject {
|
||||
private final long accountId;
|
||||
private LocalDateTime date;
|
||||
private IdOrString source, destination;
|
||||
|
||||
@@ -3,11 +3,13 @@ package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.tools.Optionals.*;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Translatable {
|
||||
public class Translatable implements Mappable {
|
||||
protected final String message;
|
||||
private final Map<String, Object> fills;
|
||||
private final HashMap<String,String> translated = new HashMap<>();
|
||||
@@ -40,6 +42,11 @@ public class Translatable {
|
||||
return new Translatable(message,args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(Field.TEXT,message,Field.DATA,fills);
|
||||
}
|
||||
|
||||
public String translate(String language){
|
||||
var translation = language == null ? null : translated.get(language);
|
||||
if (translation == null){
|
||||
|
||||
+11
-7
@@ -7,10 +7,10 @@ import java.security.InvalidParameterException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ObjectWithId implements Mappable {
|
||||
public abstract class UmbrellaObject implements Mappable {
|
||||
private long id;
|
||||
|
||||
public ObjectWithId(long id){
|
||||
public UmbrellaObject(long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@ public abstract class ObjectWithId implements Mappable {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ObjectWithId setId(long newValue){
|
||||
id = newValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Map<String, Object> map(Object ... keysAndValues) {
|
||||
if (keysAndValues.length % 2 != 0) throw new InvalidParameterException("Expected even number of keys and parameters!");
|
||||
var map = new HashMap<String, Object>();
|
||||
@@ -30,4 +25,13 @@ public abstract class ObjectWithId implements Mappable {
|
||||
for (var idx = 0; idx<keysAndValues.length; idx+=2) map.put(keysAndValues[idx].toString(),keysAndValues[idx+1]);
|
||||
return map;
|
||||
}
|
||||
|
||||
public String path(){
|
||||
return getClass().getSimpleName().toLowerCase()+"/"+id()+"/view";
|
||||
}
|
||||
|
||||
public UmbrellaObject setId(long newValue){
|
||||
id = newValue;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class WikiPage extends ObjectWithId {
|
||||
public class WikiPage extends UmbrellaObject {
|
||||
|
||||
private String title;
|
||||
private int version;
|
||||
|
||||
Reference in New Issue
Block a user