Added PERSIST detail for nodes and rooms
This commit is contained in:
parent
268853b75e
commit
68efccbe79
@ -11,7 +11,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
public interface NodeRepository {
|
public interface NodeRepository {
|
||||||
|
|
||||||
Set<NodeDetails> ALL_DETAILS = Set.of();
|
Set<NodeDetails> ALL_DETAILS = Set.of(NodeDetails.PERSIST);
|
||||||
|
|
||||||
void register(RNode node, boolean persist) throws InvalidNodeIdentifierException, NodeAlreadyExistException;
|
void register(RNode node, boolean persist) throws InvalidNodeIdentifierException, NodeAlreadyExistException;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
public interface RoomRepository {
|
public interface RoomRepository {
|
||||||
|
|
||||||
Set<RoomDetails> ALL_DETAILS = Set.of(RoomDetails.COUNT_USERS);
|
Set<RoomDetails> ALL_DETAILS = Set.of(RoomDetails.COUNT_USERS, RoomDetails.PERSIST);
|
||||||
|
|
||||||
void register(RRoom room, boolean persist) throws NodeNotFoundException, InvalidRoomIdentifierException, RoomAlreadyExistException;
|
void register(RRoom room, boolean persist) throws NodeNotFoundException, InvalidRoomIdentifierException, RoomAlreadyExistException;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
package ru.dragonestia.picker.api.repository.details;
|
package ru.dragonestia.picker.api.repository.details;
|
||||||
|
|
||||||
public enum NodeDetails {
|
public enum NodeDetails {
|
||||||
|
PERSIST
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package ru.dragonestia.picker.api.repository.details;
|
package ru.dragonestia.picker.api.repository.details;
|
||||||
|
|
||||||
public enum RoomDetails {
|
public enum RoomDetails {
|
||||||
COUNT_USERS
|
COUNT_USERS,
|
||||||
|
PERSIST
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class RNode {
|
|||||||
details.put(detail, value);
|
details.put(detail, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetails(NodeDetails detail, String value) {
|
public String getDetails(NodeDetails detail) {
|
||||||
return details.get(detail);
|
return details.get(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,10 @@ public class DetailsExtractor {
|
|||||||
var response = node.toResponseObject();
|
var response = node.toResponseObject();
|
||||||
|
|
||||||
for (var detail: details) {
|
for (var detail: details) {
|
||||||
// TODO...
|
if (detail == NodeDetails.PERSIST) {
|
||||||
|
response.putDetail(NodeDetails.PERSIST, Boolean.toString(node.persist()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@ -42,6 +45,12 @@ public class DetailsExtractor {
|
|||||||
if (detail == RoomDetails.COUNT_USERS) {
|
if (detail == RoomDetails.COUNT_USERS) {
|
||||||
var users = Integer.toString(userRepository.usersOf(room).size());
|
var users = Integer.toString(userRepository.usersOf(room).size());
|
||||||
response.details().put(RoomDetails.COUNT_USERS, users);
|
response.details().put(RoomDetails.COUNT_USERS, users);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (detail == RoomDetails.PERSIST) {
|
||||||
|
response.details().put(RoomDetails.PERSIST, Boolean.toString(room.isPersist()));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user