Search in sources :

Example 26 with NeedModelWrapper

use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.

the class GroupCycleBot method createNeedDataset.

private Dataset createNeedDataset(String title, String description) {
    URI needURI = getEventListenerContext().getWonNodeInformationService().generateNeedURI();
    NeedModelWrapper needModelWrapper = new NeedModelWrapper(needURI.toString());
    needModelWrapper.setContentPropertyStringValue(NeedContentPropertyType.IS, DC.title, title);
    needModelWrapper.setContentPropertyStringValue(NeedContentPropertyType.IS, DC.description, description);
    return needModelWrapper.copyDataset();
}
Also used : NeedModelWrapper(won.protocol.util.NeedModelWrapper) URI(java.net.URI)

Example 27 with NeedModelWrapper

use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.

the class LinkedDataCacheInvalidator method process.

@Override
public WonMessage process(final WonMessage message) throws WonMessageProcessingException {
    WonMessageType type = message.getMessageType();
    if (type == WonMessageType.SUCCESS_RESPONSE) {
        type = message.getIsResponseToMessageType();
    }
    URI webId = message.getReceiverNeedURI();
    if (message.getReceiverURI() != null) {
        // the cached list of events of the receiver need for the involved connection
        // should be invalidated, since one more
        // message was created
        logger.debug("invalidating events list for need " + message.getReceiverNeedURI() + " for connection " + message.getReceiverURI());
        URI eventContainerUri = WonLinkedDataUtils.getEventContainerURIforConnectionURI(message.getReceiverURI(), linkedDataSource);
        invalidate(eventContainerUri, webId);
        if (type.causesConnectionStateChange()) {
            invalidate(message.getReceiverURI(), webId);
        }
    }
    if (type.causesNewConnection()) {
        // the list of connections of the receiver need should be invalidated, since
        // these type
        // of messages mean that the new connection has been created recently
        logger.debug("invalidating connections list for need " + message.getReceiverNeedURI());
        Dataset need = linkedDataSource.getDataForResource(message.getReceiverNeedURI());
        NeedModelWrapper wrapper = new NeedModelWrapper(need);
        URI connectionsListUri = URI.create(wrapper.getConnectionContainerUri());
        invalidate(connectionsListUri, webId);
    }
    if (type.causesNeedStateChange()) {
        invalidate(message.getReceiverNeedURI(), webId);
    }
    return message;
}
Also used : Dataset(org.apache.jena.query.Dataset) WonMessageType(won.protocol.message.WonMessageType) NeedModelWrapper(won.protocol.util.NeedModelWrapper) URI(java.net.URI)

Aggregations

NeedModelWrapper (won.protocol.util.NeedModelWrapper)27 Dataset (org.apache.jena.query.Dataset)14 Resource (org.apache.jena.rdf.model.Resource)12 Model (org.apache.jena.rdf.model.Model)9 DefaultNeedModelWrapper (won.protocol.util.DefaultNeedModelWrapper)6 URI (java.net.URI)5 LinkedList (java.util.LinkedList)5 Test (org.junit.Test)5 GoalInstantiationProducer (won.utils.goals.GoalInstantiationProducer)4 GoalInstantiationResult (won.utils.goals.GoalInstantiationResult)4 WonMessage (won.protocol.message.WonMessage)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 Event (won.bot.framework.eventbot.event.Event)2 FailureResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)2 EventListener (won.bot.framework.eventbot.listener.EventListener)2 Coordinate (won.protocol.model.Coordinate)2 WonNodeInformationService (won.protocol.service.WonNodeInformationService)2 DistributedPubSubMediator (akka.cluster.pubsub.DistributedPubSubMediator)1 StringWriter (java.io.StringWriter)1