Search in sources :

Example 1 with Repository

use of org.structr.net.repository.Repository in project structr by structr.

the class Committed method onMessage.

@Override
public void onMessage(Peer peer, PeerInfo sender) {
    final Repository repository = peer.getRepository();
    repository.complete(transactionId);
}
Also used : Repository(org.structr.net.repository.Repository)

Example 2 with Repository

use of org.structr.net.repository.Repository in project structr by structr.

the class Update method onMessage.

@Override
public void onMessage(final Peer peer, final PeerInfo sender) {
    final Repository repository = peer.getRepository();
    final RepositoryObject obj = repository.getObject(objectId);
    if (obj != null) {
        repository.update(obj, type, objectId, userId, lastModified, data);
    } else {
        repository.objectCreated(objectId, type, getSender(), userId, created, lastModified, data);
    }
}
Also used : Repository(org.structr.net.repository.Repository) RepositoryObject(org.structr.net.repository.RepositoryObject)

Example 3 with Repository

use of org.structr.net.repository.Repository in project structr by structr.

the class History method onMessage.

@Override
public void onMessage(Peer peer, PeerInfo sender) {
    if (peer.getUuid().equals(recipient)) {
        final Repository repository = peer.getRepository();
        if (!repository.contains(objectId)) {
            repository.objectCreated(objectId, type, getSender(), userId, creationTime, lastModified, data);
        } else {
            // store history
            final RepositoryObject obj = repository.getObject(objectId);
            if (obj != null) {
                final String transactionId = UUID.randomUUID().toString().replaceAll("\\-", "");
                for (final Entry<String, Object> entry : data.entrySet()) {
                    obj.setProperty(lastModified, transactionId, entry.getKey(), entry.getValue());
                }
                repository.complete(transactionId);
            }
        }
    }
}
Also used : Repository(org.structr.net.repository.Repository) RepositoryObject(org.structr.net.repository.RepositoryObject) RepositoryObject(org.structr.net.repository.RepositoryObject)

Aggregations

Repository (org.structr.net.repository.Repository)3 RepositoryObject (org.structr.net.repository.RepositoryObject)2