Examples of MicroblogPost


Examples of net.fortytwo.twitlogic.persistence.beans.MicroblogPost

                TwitLogic.AVOID_REDUNDANT_TYPE_DESIGNATION, false);
    }

    public MicroblogPost persist(final Tweet tweet,
                                 final boolean persistGraph) {
        MicroblogPost post = postForTweet(tweet);

        if (persistGraph) {
            post.setEmbedsKnowledge(graphForTweet(tweet));
        }

        if (null != tweet.getCreatedAt()) {
            // TODO: put these in the ISO 8601 format
            post.setCreated(SesameTools.toXMLGregorianCalendar(tweet.getCreatedAt()));
        }

        if (null != tweet.getText()) {
            post.setContent(tweet.getText());
        }

        if (null != tweet.getUser()) {
            UserAccount userAccount = accountForUser(tweet.getUser());
            post.setHasCreator(userAccount);
        }

        if (null != tweet.getInReplyToTweet()) {
            MicroblogPost p = postForTweet(tweet.getInReplyToTweet());
            post.setReplyOf(p);
        }

        // Note: we assume that no tweet will be simultaneously a retweet of one tweet and a reply to another.
        if (null != tweet.getRetweetOf()) {
            MicroblogPost p = postForTweet(tweet.getRetweetOf());
            post.setReplyOf(p);
        }

        Set<Thing> topics = new HashSet<Thing>();
        if (null != tweet.getEntities()) {
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.beans.MicroblogPost

                placeHelper.flush();
            }

            boolean hasAnnotations = 0 < tweet.getAnnotations().size();

            MicroblogPost currentMicroblogPost = persistenceContext.persist(tweet, hasAnnotations);

            if (null != tweet.getUser()) {
                persistenceContext.persist(tweet.getUser());
            } else {
                LOGGER.fine("null user for tweet: " + tweet);
            }

            if (null != tweet.getGeo()) {
                Point p = persistenceContext.persist(tweet.getGeo());

                Set<SpatialThing> s = currentMicroblogPost.getLocation();
                s.add(p);
                currentMicroblogPost.setLocation(s);
            }

            if (null != tweet.getPlace()) {
                Feature f = persistenceContext.persist(tweet.getPlace());
                if (null != placeHelper) {
                    try {
                        placeHelper.submit(tweet.getPlace(), f);
                    } catch (TwitterClientException e) {
                        throw new HandlerException(e);
                    }
                }

                Set<SpatialThing> s = currentMicroblogPost.getLocation();
                s.add(f);
                currentMicroblogPost.setLocation(s);
            }

            // end Elmo operations

            try {
                storeConnection.commit();
            } catch (TweetStoreException e) {
                throw new HandlerException(e);
            }

            // Note: we assume that Twitter and any other services which supply these posts will not allow a cycle
            // of replies and/or retweets.
            // Note: these tweets are persisted in their own transactions.
            if (null != tweet.getInReplyToTweet()) {
                this.handle(tweet.getInReplyToTweet());
            }
            if (null != tweet.getRetweetOf()) {
                this.handle(tweet.getRetweetOf());
            }

            //System.out.println("    ...ending transaction");

            // Note: these Sail operations are performed outside of the Elmo transaction.  If they were to be
            // carried out inside the transaction, apparently Sesame would kill the thread without throwing
            // an exception or logging an error.
            if (hasAnnotations) {
                for (Triple triple : tweet.getAnnotations()) {
                    System.out.println("\t (" + triple.getWeight() + ")\t" + triple);
                    Statement st;

                    try {
                        st = toRDF(triple, uriOf(currentMicroblogPost.getEmbedsKnowledge()));
                    } catch (TwitterClientException e) {
                        throw new HandlerException(e);
                    }

                    if (null != st) {
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.beans.MicroblogPost

    public boolean isOpen() {
        return true;
    }

    public void handle(final Tweet tweet) throws HandlerException {
        MicroblogPost p = persistenceContext.find(tweet);

        if (null != p) {
            LOGGER.fine("deleting tweet " + tweet.getId());

            try {
                SailConnection c = storeConnection.getSailConnection();
                try {
                    c.begin();
                    // TODO: remove only from the authoritative graph
                    c.removeStatements(uriOf(p), null, null);

                    Graph g = p.getEmbedsKnowledge();
                    if (null != g) {
                        c.removeStatements(null, null, null, uriOf(g));
                    }

                    c.commit();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.