Search in sources :

Example 1 with Presentation

use of org.openntf.conference.graph.Presentation in project org.openntf.domino by OpenNTF.

the class MiscTester method run.

@Override
public void run() {
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();
    try {
        ConferenceGraph graph = new ConferenceGraph();
        Attendee paul = graph.getAttendee("paulswithers");
        Attendee dv = graph.getAttendee("DanieleVistalli");
        System.out.println(paul.getEmail());
        Iterable<Event> evts = paul.getAttendingEvents();
        FastSet<Presentation> presentations = new FastSet<Presentation>();
        for (Event evt : evts) {
            if (evt instanceof Presentation) {
                presentations.add((Presentation) evt);
            }
        }
        System.out.println("Paul is attending " + presentations.size() + " Sessions");
        evts = dv.getAttendingEvents();
        presentations = new FastSet<Presentation>();
        for (Event evt : evts) {
            if (evt instanceof Presentation) {
                presentations.add((Presentation) evt);
            }
        }
        System.out.println("Paul is attending " + presentations.size() + " Sessions");
        evts = paul.getPresentingEvents();
        presentations = new FastSet<Presentation>();
        for (Event evt : evts) {
            if (evt instanceof Presentation) {
                presentations.add((Presentation) evt);
            }
        }
        System.out.println("Paul is presenting " + presentations.size() + " Sessions");
        Presentation pres = presentations.iterator().next();
        Comment comm = graph.getFramedGraph().addVertex(null, Comment.class);
        comm.setBody("This is a test comment");
        paul.addComment(comm);
        pres.addComment(comm);
        paul.addLikeable(comm);
        paul.addLikeable(pres);
        // Uncomment this and you get a duplicate
        // Rates rate1 = paul.addRates(pres);
        // rate1.setRating(5);
        // This doesn't give a duplicate
        Rates rate3 = pres.addRater(paul);
        rate3.setRating(5);
        Rates rate2 = dv.addRateable(pres);
        rate2.setRating(2);
        System.out.println("Comments by Paul: " + Lists.newArrayList(paul.getComments()).size());
        for (Comment testComm : paul.getComments()) {
            System.out.println(testComm.getBody());
        }
        System.out.println("Likes by Paul: " + Lists.newArrayList(paul.getLikes()).size());
        System.out.println("Comments on Pres: " + Lists.newArrayList(pres.getComments()).size());
        System.out.println("Likes on Pres: " + Lists.newArrayList(pres.countLikedBys()));
        System.out.println("Rates on Pres: " + Lists.newArrayList(pres.getRates()).size());
        for (Rates r : Lists.newArrayList(pres.getRates())) {
            System.out.println("Rating - " + r.asEdge().getId() + " - " + r.getRating());
        }
        System.out.println("Rates by Paul: " + Lists.newArrayList(paul.getRates()).size());
        System.out.println("Rating by Paul: " + pres.getRaterRating(paul));
        System.out.println("Average: " + pres.getAverageRating());
    } catch (Exception e) {
        e.printStackTrace();
    }
    long testEndTime = System.nanoTime();
    System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Also used : Comment(org.openntf.domino.graph2.builtin.social.Comment) FastSet(javolution.util.FastSet) Rates(org.openntf.domino.graph2.builtin.social.Rates) Event(org.openntf.conference.graph.Event) Presentation(org.openntf.conference.graph.Presentation) ConferenceGraph(org.openntf.conference.graph.ConferenceGraph) Attendee(org.openntf.conference.graph.Attendee)

Example 2 with Presentation

use of org.openntf.conference.graph.Presentation in project org.openntf.domino by OpenNTF.

the class SessionsByTimeslot method run.

@Override
public void run() {
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();
    try {
        timelog("Beginning Sessions By TimeSlot...");
        ConferenceGraph graph = new ConferenceGraph();
        Session session = Factory.getSession(SessionType.CURRENT);
        String myName = session.getEffectiveUserName();
        Attendee att = graph.getAttendee(myName, false);
        Ordering<TimeSlot> byStart = new Ordering<TimeSlot>() {

            @Override
            public int compare(final TimeSlot t1, final TimeSlot t2) {
                return t1.getStartTime().compareTo(t2.getStartTime());
            }
        };
        Iterable<TimeSlot> times = graph.getTimeSlots();
        List<TimeSlot> timesSorted = byStart.sortedCopy(times);
        for (TimeSlot ts : timesSorted) {
            System.out.println("Sessions running from " + DATE_FORMAT.format(ts.getStartTime().getTime()) + " to " + DATE_FORMAT.format(ts.getEndTime().getTime()));
            System.out.println(ts.getDuration());
            Iterable<Event> presentations = ts.getEvents();
            for (Event evt : presentations) {
                if (evt instanceof Presentation) {
                    Presentation pres = (Presentation) evt;
                    System.out.println(pres.getSessionId() + ": " + pres.getTitle());
                }
            }
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
    long testEndTime = System.nanoTime();
    System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Also used : TimeSlot(org.openntf.conference.graph.TimeSlot) Presentation(org.openntf.conference.graph.Presentation) ConferenceGraph(org.openntf.conference.graph.ConferenceGraph) Attendee(org.openntf.conference.graph.Attendee) Ordering(com.google.common.collect.Ordering) Event(org.openntf.conference.graph.Event) Session(org.openntf.domino.Session)

Example 3 with Presentation

use of org.openntf.conference.graph.Presentation in project org.openntf.domino by OpenNTF.

the class SessionsByTrack method run.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void run() {
    HashMap<String, String> trackLkup = new HashMap<String, String>();
    trackLkup.put("Special", "Sp");
    trackLkup.put("Strategy/Deployment", "Str");
    trackLkup.put("Administration", "Adm");
    trackLkup.put("Development", "Dev");
    trackLkup.put("Business", "Bus");
    trackLkup.put("Commercial", "Comm");
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();
    try {
        timelog("Beginning Sessions By Track...");
        FramedGraph<DGraph> graph2 = new ConferenceGraph().getFramedGraph();
        Iterable<Sponsor> sponsors = graph2.getVertices("Level", Level.BRONZE, Sponsor.class);
        for (Sponsor s : sponsors) {
            System.out.println("Sponsor " + s.getName() + " - " + s.getUrl());
        }
        ConferenceGraph graph = new ConferenceGraph();
        for (Entry<String, String> track : trackLkup.entrySet()) {
            System.out.println("Outputting sessions ordered by ID for " + track.getKey());
            Track dev = graph.getFramedGraph().getVertex(track.getValue(), Track.class);
            System.out.println(dev.getDescription());
            Iterable<Presentation> presentations = dev.getIncludesSessions();
            Ordering<DVertexFrame> ord = Ordering.from(new DVertexFrameComparator("SessionID"));
            List<Presentation> presOrdered = ord.sortedCopy(presentations);
            for (Presentation pres : presOrdered) {
                Attendee att = pres.getPresentingAttendees().iterator().next();
                System.out.println(att.getFullname());
                System.out.println(pres.getSessionId() + ": " + pres.getTitle());
            }
        }
        for (Entry<String, String> track : trackLkup.entrySet()) {
            System.out.println("Outputting sessions ordered by Title for " + track.getKey());
            Track dev = graph.getFramedGraph().getVertex(track.getValue(), Track.class);
            Iterable<Presentation> presentations = dev.getIncludesSessions();
            Ordering<DVertexFrame> ord = Ordering.from(new DVertexFrameComparator("SessionTitle"));
            List<Presentation> presOrdered = ord.sortedCopy(presentations);
            for (Presentation pres : presOrdered) {
                System.out.println(pres.getSessionId() + ": " + pres.getTitle());
            }
        }
        System.out.println("OUTPUTTING SORTBY");
        FramedVertexList<Sponsor> sponsors2 = (FramedVertexList<Sponsor>) graph2.getVertices(null, null, Sponsor.class);
        List<CaseInsensitiveString> keys = new ArrayList<CaseInsensitiveString>();
        keys.add(new CaseInsensitiveString("Level"));
        keys.add(new CaseInsensitiveString("Name"));
        sponsors2.sortBy((List<CharSequence>) (List<?>) keys, true);
        for (Sponsor spon : sponsors2) {
            System.out.println(spon.getLevel().name() + " - " + spon.getName());
        }
        // Throws java.lang.ClassCastException: com.sun.proxy.$Proxy11 incompatible with com.tinkerpop.blueprints.Vertex
        // Yet to track down why
        List<Presentation> presentations = Lists.newArrayList(graph.getFramedGraph().getVertices(null, null, Presentation.class));
        // GremlinPipeline pipe = new GremlinPipeline(presentations).outE("PresentedBy").outV().dedup();
        GremlinPipeline pipe = new GremlinPipeline(presentations).outE("PresentedBy");
        List<DEdge> edges = pipe.toList();
        for (DEdge edge : edges) {
            System.out.println(edge.getVertex(Direction.OUT).getId());
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
    long testEndTime = System.nanoTime();
    System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) DGraph(org.openntf.domino.graph2.impl.DGraph) FramedVertexList(org.openntf.domino.graph2.annotations.FramedVertexList) FramedVertexList(org.openntf.domino.graph2.annotations.FramedVertexList) ArrayList(java.util.ArrayList) List(java.util.List) GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline) DVertexFrameComparator(org.openntf.domino.graph2.builtin.DVertexFrameComparator) Sponsor(org.openntf.conference.graph.Sponsor) Presentation(org.openntf.conference.graph.Presentation) ConferenceGraph(org.openntf.conference.graph.ConferenceGraph) Attendee(org.openntf.conference.graph.Attendee) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) DVertexFrame(org.openntf.domino.graph2.builtin.DVertexFrame) Track(org.openntf.conference.graph.Track) DEdge(org.openntf.domino.graph2.DEdge)

Aggregations

Attendee (org.openntf.conference.graph.Attendee)3 ConferenceGraph (org.openntf.conference.graph.ConferenceGraph)3 Presentation (org.openntf.conference.graph.Presentation)3 Event (org.openntf.conference.graph.Event)2 Ordering (com.google.common.collect.Ordering)1 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 FastSet (javolution.util.FastSet)1 Sponsor (org.openntf.conference.graph.Sponsor)1 TimeSlot (org.openntf.conference.graph.TimeSlot)1 Track (org.openntf.conference.graph.Track)1 Session (org.openntf.domino.Session)1 DEdge (org.openntf.domino.graph2.DEdge)1 FramedVertexList (org.openntf.domino.graph2.annotations.FramedVertexList)1 DVertexFrame (org.openntf.domino.graph2.builtin.DVertexFrame)1 DVertexFrameComparator (org.openntf.domino.graph2.builtin.DVertexFrameComparator)1 Comment (org.openntf.domino.graph2.builtin.social.Comment)1 Rates (org.openntf.domino.graph2.builtin.social.Rates)1