Package net.fortytwo.twitlogic.persistence.beans

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


                               final UserAccount account) {
        if (null != user.getScreenName()) {
            account.setId(user.getScreenName());
        }

        Agent agent = account.getAccountOf();

        if (null == agent) {
            agent = agentForUser(user);
            account.setAccountOf(agent);
        }
View Full Code Here


    }

    public UserAccount persist(final User tweetUser) {
        UserAccount userAccount = accountForUser(tweetUser);

        Agent agent = agentForUser(tweetUser, userAccount);

        Set<Thing> equivalentAgents = new HashSet<Thing>();
        String semanticTweetUri
                = "http://semantictweet.com/" + tweetUser.getScreenName() + "#me";
        equivalentAgents.add(
                designate(semanticTweetUri, Thing.class));
        agent.setOwlSameAs(equivalentAgents);

        if (null != tweetUser.getName()) {
            agent.setName(tweetUser.getName());
        }

        if (null != tweetUser.getDescription()) {
            agent.setRdfsComment(tweetUser.getDescription());
        }

        if (null != tweetUser.getLocation()) {
            SpatialThing basedNear = agent.getBasedNear();
            if (null == basedNear) {
                basedNear = spatialThing();
                agent.setBasedNear(basedNear);
            }

            basedNear.setRdfsComment(tweetUser.getLocation());
        }

        if (null != tweetUser.getUrl()
                && TweetSyntax.URL_PATTERN.matcher(tweetUser.getUrl()).matches()) {
            // Note: we can't easily delete an existing homepage (removing its
            // rdf:type statement), as it might be the homepage of another
            // agent.  Therefore, "orphaned" Document resources are possible.

            Document homepage = designate(tweetUser.getUrl(), Document.class);
            agent.setHomepage(homepage);
        }

        if (null != tweetUser.getProfileImageUrl()
                && TweetSyntax.URL_PATTERN.matcher(tweetUser.getProfileImageUrl()).matches()) {
            // Note: we can't easily delete an existing image (removing its
            // rdf:type statement), as it might be the image of another
            // agent.  Therefore, "orphaned" Image resources are possible.

            Image depiction = designate(tweetUser.getProfileImageUrl(), Image.class);
            agent.setDepiction(depiction);
        }

        if (null != tweetUser.getFollowers()) {
            Set<Agent> agents = new HashSet<Agent>();
            for (User u : tweetUser.getFollowers()) {
                UserAccount ua = accountForUser(u);
                Agent ag = agentForUser(u, ua);
                agents.add(ag);
            }

            agent.setKnownBy(agents);
        }

        if (null != tweetUser.getFollowees()) {
            Set<Agent> agents = new HashSet<Agent>();
            for (User u : tweetUser.getFollowees()) {
                UserAccount ua = accountForUser(u);
                Agent ag = agentForUser(u, ua);
                agents.add(ag);
            }

            agent.setKnows(agents);
        }
View Full Code Here

TOP

Related Classes of net.fortytwo.twitlogic.persistence.beans.Agent

Copyright © 2018 www.massapicom. 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.