use of org.structr.net.data.time.PseudoTime in project structr by structr.
the class DefaultRepositoryObject method getProperties.
@Override
public Map<String, Object> getProperties(final PseudoTime instant, final String transactionId) {
final Map<String, Object> map = new HashMap<>();
// do backwards search
final List<PseudoTime> times = new LinkedList<>(history.keySet());
Collections.reverse(times);
for (final PseudoTime time : times) {
if (time.equals(instant) || time.before(instant)) {
final PossibleValue val = history.get(time);
if (val.isComplete(transactionId)) {
for (final Entry<String, Object> entry : val.getData().entrySet()) {
if (!map.containsKey(entry.getKey())) {
map.put(entry.getKey(), entry.getValue());
}
}
} else if (val.isAborted()) {
// remove aborted history entries
history.remove(time);
}
}
}
return map;
}
use of org.structr.net.data.time.PseudoTime in project structr by structr.
the class History method deserialize.
@Override
public void deserialize(final DataInputStream dis) throws IOException {
super.deserialize(dis);
// dis.readUTF();
this.recipient = deserializeUUID(dis);
// dis.readUTF();
this.objectId = deserializeUUID(dis);
this.userId = dis.readUTF();
this.type = dis.readUTF();
this.creationTime = new PseudoTime();
this.creationTime.deserialize(dis);
this.lastModified = new PseudoTime();
this.lastModified.deserialize(dis);
final int size = dis.readInt();
for (int i = 0; i < size; i++) {
try {
final String key = dis.readUTF();
final Object value = deserializeObject(dis);
data.put(key, value);
} catch (Throwable t) {
logger.warn("", t);
}
}
}
use of org.structr.net.data.time.PseudoTime in project structr by structr.
the class PeerToPeerService method create.
// ----- repository connection -----
public void create(final SharedNodeInterface sharedNode) {
final String uuid = sharedNode.getUuid();
final String type = sharedNode.getType();
final String user = sharedNode.getUserId();
final PseudoTime time = sharedNode.getCreationPseudoTime();
logger.info("Shared node with UUID {} CREATED in Structr at {}", new Object[] { sharedNode.getUuid(), time.toString() });
repository.create(uuid, type, peer.getUuid(), user, time, sharedNode.getData());
}
use of org.structr.net.data.time.PseudoTime in project structr by structr.
the class PeerToPeerService method addObjectToRepository.
public void addObjectToRepository(final SharedNodeInterface node) {
final String objectId = node.getProperty(GraphObject.id);
final String objectType = node.getProperty(GraphObject.type);
final PseudoTime modified = node.getLastModificationPseudoTime();
final PseudoTime created = node.getCreationPseudoTime();
final String transactionId = NodeServiceCommand.getNextUuid();
final RepositoryObject obj = repository.add(objectId, objectType, peer.getUuid(), node.getUserId(), created);
for (final Entry<String, Object> entry : node.getData().entrySet()) {
obj.setProperty(modified, transactionId, entry.getKey(), entry.getValue());
}
repository.complete(transactionId);
// add update listener
obj.addListener(new ObjectUpdater(objectId));
}
Aggregations