Search in sources :

Example 1 with UnreadMessageInfoForAtom

use of won.protocol.model.unread.UnreadMessageInfoForAtom in project webofneeds by researchstudio-sat.

the class LinkedDataServiceImpl method getUnreadInformationForAtom.

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, readOnly = true)
public Model getUnreadInformationForAtom(URI atomURI, Collection<URI> lastSeenMessageURIs) {
    UnreadMessageInfoForAtom unreadInfo = this.unreadInformationService.getUnreadInformation(atomURI, lastSeenMessageURIs);
    Model ret = ModelFactory.createDefaultModel();
    Resource atomRes = ret.createResource(atomURI.toString());
    addUnreadInfoWithProperty(ret, atomRes, WON.unreadSuggested, unreadInfo.getUnreadInfoByConnectionState().get(ConnectionState.SUGGESTED));
    addUnreadInfoWithProperty(ret, atomRes, WON.unreadConnected, unreadInfo.getUnreadInfoByConnectionState().get(ConnectionState.CONNECTED));
    addUnreadInfoWithProperty(ret, atomRes, WON.unreadRequestSent, unreadInfo.getUnreadInfoByConnectionState().get(ConnectionState.REQUEST_SENT));
    addUnreadInfoWithProperty(ret, atomRes, WON.unreadRequestReceived, unreadInfo.getUnreadInfoByConnectionState().get(ConnectionState.REQUEST_RECEIVED));
    addUnreadInfoWithProperty(ret, atomRes, WON.unreadClosed, unreadInfo.getUnreadInfoByConnectionState().get(ConnectionState.CLOSED));
    unreadInfo.getUnreadMessageInfoForConnections().forEach(info -> {
        Resource connRes = ret.createResource(info.getConnectionURI().toString());
        addUnreadInfoWithProperty(ret, connRes, null, info.getUnreadInformation());
    });
    return ret;
}
Also used : Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) UnreadMessageInfoForAtom(won.protocol.model.unread.UnreadMessageInfoForAtom) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with UnreadMessageInfoForAtom

use of won.protocol.model.unread.UnreadMessageInfoForAtom in project webofneeds by researchstudio-sat.

the class UnreadInformationService method getUnreadInformation.

public UnreadMessageInfoForAtom getUnreadInformation(URI atomURI, Collection<URI> lastSeenMessageURIs) {
    List<UnreadMessageInfoForConnection> unreadInfoForConnections = messageEventRepository.getUnreadInfoForAtom(atomURI, lastSeenMessageURIs);
    UnreadMessageInfoForAtom result = new UnreadMessageInfoForAtom(atomURI);
    unreadInfoForConnections.forEach(result::addUnreadMessageInfoForConnection);
    return result;
}
Also used : UnreadMessageInfoForAtom(won.protocol.model.unread.UnreadMessageInfoForAtom) UnreadMessageInfoForConnection(won.protocol.model.unread.UnreadMessageInfoForConnection)

Aggregations

UnreadMessageInfoForAtom (won.protocol.model.unread.UnreadMessageInfoForAtom)2 Model (org.apache.jena.rdf.model.Model)1 Resource (org.apache.jena.rdf.model.Resource)1 Transactional (org.springframework.transaction.annotation.Transactional)1 UnreadMessageInfoForConnection (won.protocol.model.unread.UnreadMessageInfoForConnection)1