Search in sources :

Example 1 with JavaHandlerModule

use of com.tinkerpop.frames.modules.javahandler.JavaHandlerModule in project org.openntf.domino by OpenNTF.

the class Graph2Demo method run3.

public void run3() {
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();
    try {
        timelog("Beginning graph2 test3...");
        DElementStore crewStore = new DElementStore();
        crewStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(crewId));
        crewStore.addType(Crew.class);
        DElementStore movieStore = new DElementStore();
        movieStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(movieId));
        movieStore.addType(Movie.class);
        DElementStore characterStore = new DElementStore();
        characterStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(characterId));
        characterStore.addType(Character.class);
        DElementStore edgeStore = new DElementStore();
        edgeStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(edgeId));
        DElementStore usersStore = new DElementStore();
        usersStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(nabId));
        usersStore.setProxyStoreKey(NoteCoordinate.Utils.getLongFromReplid(usersId));
        usersStore.addType(Person.class);
        DConfiguration config = new DConfiguration();
        config.addElementStore(crewStore);
        config.addElementStore(movieStore);
        config.addElementStore(characterStore);
        config.addElementStore(edgeStore);
        config.addElementStore(usersStore);
        config.setDefaultElementStore(NoteCoordinate.Utils.getLongFromReplid(edgeId));
        graph = new DGraph(config);
        JavaHandlerModule jhm = new JavaHandlerModule();
        Module module = new TypedGraphModuleBuilder().withClass(Person.class).withClass(Movie.class).withClass(Character.class).withClass(Crew.class).build();
        DFramedGraphFactory factory = new DFramedGraphFactory(module, jhm);
        FramedTransactionalGraph<DGraph> framedGraph = factory.create(graph);
        Person ntfUser = framedGraph.getVertex(nabId + ntfUnid, Person.class);
        Movie newhopeMovie = framedGraph.getVertex("Star Wars", Movie.class);
        Movie empireMovie = framedGraph.getVertex("The Empire Strikes Back", Movie.class);
        Movie jediMovie = framedGraph.getVertex("Return of the Jedi", Movie.class);
        Movie phantomMovie = framedGraph.getVertex("The Phantom Menace", Movie.class);
        Movie clonesMovie = framedGraph.getVertex("Attack of the Clones", Movie.class);
        Movie revengeMovie = framedGraph.getVertex("Revenge of the Sith", Movie.class);
        System.out.println("***************************");
        System.out.println("Don't miss " + newhopeMovie.getTitle());
        Iterable<Starring> starrings = newhopeMovie.getStarring();
        for (Starring starring : starrings) {
            Crew crew = starring.getStar();
            Character character = crew.getPortraysCharacters().iterator().next();
            System.out.println(crew.getFirstName() + " " + crew.getLastName() + " as " + character.getName());
        }
        System.out.println("***************************");
        System.out.println("Don't miss " + empireMovie.getTitle());
        starrings = empireMovie.getStarring();
        for (Starring starring : starrings) {
            Crew crew = starring.getStar();
            Character character = crew.getPortraysCharacters().iterator().next();
            System.out.println(crew.getFirstName() + " " + crew.getLastName() + " as " + character.getName());
        }
        System.out.println("***************************");
        System.out.println("Don't miss " + jediMovie.getTitle());
        starrings = jediMovie.getStarring();
        for (Starring starring : starrings) {
            Crew crew = starring.getStar();
            Character character = crew.getPortraysCharacters().iterator().next();
            System.out.println(crew.getFirstName() + " " + crew.getLastName() + " as " + character.getName());
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) TypedGraphModuleBuilder(com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder) DElementStore(org.openntf.domino.graph2.impl.DElementStore) DGraph(org.openntf.domino.graph2.impl.DGraph) DConfiguration(org.openntf.domino.graph2.impl.DConfiguration) JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) Module(com.tinkerpop.frames.modules.Module) Person(org.openntf.domino.graph2.builtin.identity.Person) DFramedGraphFactory(org.openntf.domino.graph2.impl.DFramedGraphFactory)

Example 2 with JavaHandlerModule

use of com.tinkerpop.frames.modules.javahandler.JavaHandlerModule in project org.openntf.domino by OpenNTF.

the class Graph2Demo method run1.

public void run1() {
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();
    try {
        timelog("Beginning graph2 test...");
        DElementStore crewStore = new DElementStore();
        crewStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(crewId));
        crewStore.addType(Crew.class);
        DElementStore movieStore = new DElementStore();
        movieStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(movieId));
        movieStore.addType(Movie.class);
        DElementStore characterStore = new DElementStore();
        characterStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(characterId));
        characterStore.addType(Character.class);
        DElementStore edgeStore = new DElementStore();
        edgeStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(edgeId));
        DElementStore usersStore = new DElementStore();
        usersStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(nabId));
        usersStore.setProxyStoreKey(NoteCoordinate.Utils.getLongFromReplid(usersId));
        usersStore.addType(Person.class);
        DConfiguration config = new DConfiguration();
        config.addElementStore(crewStore);
        config.addElementStore(movieStore);
        config.addElementStore(characterStore);
        config.addElementStore(edgeStore);
        config.addElementStore(usersStore);
        config.setDefaultElementStore(NoteCoordinate.Utils.getLongFromReplid(edgeId));
        graph = new DGraph(config);
        JavaHandlerModule jhm = new JavaHandlerModule();
        Module module = new TypedGraphModuleBuilder().withClass(Person.class).withClass(Movie.class).withClass(Character.class).withClass(Crew.class).build();
        DFramedGraphFactory factory = new DFramedGraphFactory(module, jhm);
        FramedTransactionalGraph<DGraph> framedGraph = factory.create(graph);
        ((org.openntf.domino.Database) crewStore.getStoreDelegate()).getAllDocuments().removeAll(true);
        ((org.openntf.domino.Database) movieStore.getStoreDelegate()).getAllDocuments().removeAll(true);
        ((org.openntf.domino.Database) characterStore.getStoreDelegate()).getAllDocuments().removeAll(true);
        ((org.openntf.domino.Database) edgeStore.getStoreDelegate()).getAllDocuments().removeAll(true);
        Person ntfUser = framedGraph.getVertex(nabId + ntfUnid, Person.class);
        Movie newhopeMovie = framedGraph.addVertex("Star Wars", Movie.class);
        newhopeMovie.setTitle("Star Wars");
        Rates ntfRatesNH = ntfUser.addRateable(newhopeMovie);
        ntfRatesNH.setRating(4);
        Movie empireMovie = framedGraph.addVertex("The Empire Strikes Back", Movie.class);
        empireMovie.setTitle("The Empire Strikes Back");
        Rates ntfRatesESB = ntfUser.addRateable(empireMovie);
        ntfRatesESB.setRating(5);
        Movie jediMovie = framedGraph.addVertex("Return of the Jedi", Movie.class);
        jediMovie.setTitle("Return of the Jedi");
        Rates ntfRatesRoJ = ntfUser.addRateable(jediMovie);
        ntfRatesRoJ.setRating(5);
        Movie phantomMovie = framedGraph.addVertex("The Phantom Menace", Movie.class);
        phantomMovie.setTitle("The Phantom Menace");
        Movie clonesMovie = framedGraph.addVertex("Attack of the Clones", Movie.class);
        clonesMovie.setTitle("Attack of the Clones");
        Movie revengeMovie = framedGraph.addVertex("Revenge of the Sith", Movie.class);
        revengeMovie.setTitle("Revenge of the Sith");
        Crew lucasCrew = framedGraph.addVertex("George Lucas", Crew.class);
        lucasCrew.setFullName("George Lucas");
        Crew kershnerCrew = framedGraph.addVertex("Irvin Kershner", Crew.class);
        kershnerCrew.setFullName("Irvin Kershner");
        Crew marquandCrew = framedGraph.addVertex("Richard Marquand", Crew.class);
        marquandCrew.setFullName("Richard Marquand");
        DirectedBy nhDirector = newhopeMovie.addDirectedBy(lucasCrew);
        nhDirector.setRating(4);
        DirectedBy esbDirector = empireMovie.addDirectedBy(kershnerCrew);
        esbDirector.setRating(5);
        DirectedBy rojDirector = jediMovie.addDirectedBy(marquandCrew);
        rojDirector.setRating(4);
        DirectedBy pmDirector = phantomMovie.addDirectedBy(lucasCrew);
        pmDirector.setRating(3);
        DirectedBy aocDirector = clonesMovie.addDirectedBy(lucasCrew);
        aocDirector.setRating(2);
        DirectedBy rosDirector = revengeMovie.addDirectedBy(lucasCrew);
        rosDirector.setRating(1);
        Character luke = framedGraph.addVertex("Luke Skywalker", Character.class);
        luke.setName("Luke Skywalker");
        luke.addAppearsIn(newhopeMovie);
        luke.addAppearsIn(empireMovie);
        luke.addAppearsIn(jediMovie);
        Character leia = framedGraph.addVertex("Leia Organa", Character.class);
        leia.setName("Leia Organa");
        leia.addAppearsIn(newhopeMovie);
        leia.addAppearsIn(empireMovie);
        leia.addAppearsIn(jediMovie);
        Character han = framedGraph.addVertex("Han Solo", Character.class);
        han.setName("Han Solo");
        han.addAppearsIn(newhopeMovie);
        han.addAppearsIn(empireMovie);
        han.addAppearsIn(jediMovie);
        Character chewy = framedGraph.addVertex("Chewbacca", Character.class);
        chewy.setName("Chewbacca");
        chewy.addAppearsIn(newhopeMovie);
        chewy.addAppearsIn(empireMovie);
        chewy.addAppearsIn(jediMovie);
        chewy.addAppearsIn(revengeMovie);
        Character threepio = framedGraph.addVertex("C-3PO", Character.class);
        threepio.setName("C-3PO");
        threepio.addAppearsIn(newhopeMovie);
        threepio.addAppearsIn(empireMovie);
        threepio.addAppearsIn(jediMovie);
        threepio.addAppearsIn(phantomMovie);
        threepio.addAppearsIn(clonesMovie);
        threepio.addAppearsIn(revengeMovie);
        Character artoo = framedGraph.addVertex("R2D2", Character.class);
        artoo.setName("R2D2");
        artoo.addAppearsIn(newhopeMovie);
        artoo.addAppearsIn(empireMovie);
        artoo.addAppearsIn(jediMovie);
        artoo.addAppearsIn(phantomMovie);
        artoo.addAppearsIn(clonesMovie);
        artoo.addAppearsIn(revengeMovie);
        Character lando = framedGraph.addVertex("Lando Calrissian", Character.class);
        lando.setName("Lando Calrissian");
        lando.addAppearsIn(empireMovie);
        lando.addAppearsIn(jediMovie);
        Character anakin = framedGraph.addVertex("Anakin Skywalker", Character.class);
        anakin.setName("Anakin Skywalker");
        anakin.addAppearsIn(newhopeMovie);
        anakin.addAppearsIn(empireMovie);
        anakin.addAppearsIn(jediMovie);
        anakin.addAppearsIn(phantomMovie);
        anakin.addAppearsIn(clonesMovie);
        anakin.addAppearsIn(revengeMovie);
        Character palpatine = framedGraph.addVertex("Darth Sidious", Character.class);
        palpatine.setName("Darth Sidious");
        palpatine.addAppearsIn(empireMovie);
        palpatine.addAppearsIn(jediMovie);
        palpatine.addAppearsIn(phantomMovie);
        palpatine.addAppearsIn(clonesMovie);
        palpatine.addAppearsIn(revengeMovie);
        Character obiwan = framedGraph.addVertex("Obi-Wan Kenobi", Character.class);
        obiwan.setName("Obi-Wan Kenobi");
        obiwan.addAppearsIn(newhopeMovie);
        obiwan.addAppearsIn(empireMovie);
        obiwan.addAppearsIn(jediMovie);
        obiwan.addAppearsIn(phantomMovie);
        obiwan.addAppearsIn(clonesMovie);
        obiwan.addAppearsIn(revengeMovie);
        Character quigon = framedGraph.addVertex("Qui-Gon Jinn", Character.class);
        quigon.setName("Qui-Gon Jinn");
        quigon.addAppearsIn(phantomMovie);
        Character yoda = framedGraph.addVertex("Yoda", Character.class);
        yoda.setName("Yoda");
        yoda.addAppearsIn(empireMovie);
        yoda.addAppearsIn(jediMovie);
        yoda.addAppearsIn(phantomMovie);
        yoda.addAppearsIn(clonesMovie);
        yoda.addAppearsIn(revengeMovie);
        Character jango = framedGraph.addVertex("Jango Fett", Character.class);
        jango.setName("Jango Fett");
        jango.addAppearsIn(clonesMovie);
        Character boba = framedGraph.addVertex("Boba Fett", Character.class);
        boba.setName("Boba Fett");
        boba.addAppearsIn(empireMovie);
        boba.addAppearsIn(jediMovie);
        boba.addAppearsIn(clonesMovie);
        Character padme = framedGraph.addVertex("Padme", Character.class);
        padme.setName("Padme");
        padme.addAppearsIn(phantomMovie);
        padme.addAppearsIn(clonesMovie);
        padme.addAppearsIn(revengeMovie);
        Character shmi = framedGraph.addVertex("Shmi Skywalker", Character.class);
        shmi.setName("Shmi Skywalker");
        shmi.addAppearsIn(phantomMovie);
        shmi.addAppearsIn(clonesMovie);
        Character tyranus = framedGraph.addVertex("Darth Tyranus", Character.class);
        tyranus.setName("Darth Tyranus");
        tyranus.addAppearsIn(clonesMovie);
        tyranus.addAppearsIn(revengeMovie);
        Character maul = framedGraph.addVertex("Darth Maul", Character.class);
        maul.setName("Darth Maul");
        maul.addAppearsIn(phantomMovie);
        maul.addAppearsIn(clonesMovie);
        Character tarkin = framedGraph.addVertex("Grand Moff Tarkin", Character.class);
        tarkin.setName("Grand Moff Tarkin");
        tarkin.addAppearsIn(newhopeMovie);
        Character windu = framedGraph.addVertex("Mace Windu", Character.class);
        windu.setName("Mace Windu");
        windu.addAppearsIn(phantomMovie);
        windu.addAppearsIn(clonesMovie);
        windu.addAppearsIn(revengeMovie);
        Character greedo = framedGraph.addVertex("Greedo", Character.class);
        greedo.setName("Greedo");
        greedo.addAppearsIn(newhopeMovie);
        Character wedge = framedGraph.addVertex("Wedge Antilles", Character.class);
        wedge.setName("Wedge Antilles");
        wedge.addAppearsIn(newhopeMovie);
        wedge.addAppearsIn(empireMovie);
        wedge.addAppearsIn(jediMovie);
        Crew ford = framedGraph.addVertex("Harrison Ford", Crew.class);
        ford.setFullName("Harrison Ford");
        ford.addStarsInMovie(newhopeMovie);
        ford.addStarsInMovie(empireMovie);
        ford.addStarsInMovie(jediMovie);
        han.addPortrayedBy(ford);
        Crew fischer = framedGraph.addVertex("Carrie Fischer", Crew.class);
        fischer.setFullName("Carrie Fischer");
        fischer.addStarsInMovie(newhopeMovie);
        fischer.addStarsInMovie(empireMovie);
        fischer.addStarsInMovie(jediMovie);
        fischer.addPortrayals(leia);
        Crew hammill = framedGraph.addVertex("Mark Hammill", Crew.class);
        hammill.setFullName("Mark Hammill");
        hammill.addStarsInMovie(newhopeMovie);
        hammill.addStarsInMovie(empireMovie);
        hammill.addStarsInMovie(jediMovie);
        hammill.addPortrayals(luke);
        Crew daniels = framedGraph.addVertex("Anthony Daniels", Crew.class);
        daniels.setFullName("Anthony Daniels");
        daniels.addStarsInMovie(newhopeMovie);
        daniels.addStarsInMovie(empireMovie);
        daniels.addStarsInMovie(jediMovie);
        daniels.addStarsInMovie(phantomMovie);
        daniels.addStarsInMovie(clonesMovie);
        daniels.addStarsInMovie(revengeMovie);
        daniels.addPortrayals(threepio);
        Crew baker = framedGraph.addVertex("Kenny Baker", Crew.class);
        baker.setFullName("Kenny Baker");
        baker.addStarsInMovie(newhopeMovie);
        baker.addStarsInMovie(empireMovie);
        baker.addStarsInMovie(jediMovie);
        baker.addStarsInMovie(phantomMovie);
        baker.addStarsInMovie(clonesMovie);
        baker.addStarsInMovie(revengeMovie);
        baker.addPortrayals(artoo);
        Crew prowse = framedGraph.addVertex("David Prowse", Crew.class);
        prowse.setFullName("David Prowse");
        prowse.addStarsInMovie(newhopeMovie);
        prowse.addStarsInMovie(empireMovie);
        prowse.addStarsInMovie(jediMovie);
        prowse.addPortrayals(anakin);
        Crew williams = framedGraph.addVertex("Billy Dee Williams", Crew.class);
        williams.setFullName("Billy Dee Williams");
        williams.addStarsInMovie(empireMovie);
        williams.addStarsInMovie(jediMovie);
        williams.addPortrayals(lando);
        Crew guinness = framedGraph.addVertex("Alec Guinness", Crew.class);
        guinness.setFullName("Alec Guinness");
        guinness.addStarsInMovie(newhopeMovie);
        guinness.addStarsInMovie(empireMovie);
        guinness.addStarsInMovie(jediMovie);
        guinness.addPortrayals(obiwan);
        Crew ewan = framedGraph.addVertex("Ewan McGregor", Crew.class);
        ewan.setFullName("Ewan McGregor");
        ewan.addStarsInMovie(phantomMovie);
        ewan.addStarsInMovie(clonesMovie);
        ewan.addStarsInMovie(revengeMovie);
        ewan.addPortrayals(obiwan);
        Crew cushing = framedGraph.addVertex("Peter Cushing", Crew.class);
        cushing.setFullName("Peter Cushing");
        cushing.addStarsInMovie(newhopeMovie);
        cushing.addPortrayals(tarkin);
        Crew mayhew = framedGraph.addVertex("Peter Mayhew", Crew.class);
        mayhew.setFullName("Peter Mayhew");
        mayhew.addStarsInMovie(newhopeMovie);
        mayhew.addStarsInMovie(empireMovie);
        mayhew.addStarsInMovie(jediMovie);
        mayhew.addStarsInMovie(revengeMovie);
        mayhew.addPortrayals(chewy);
        Crew oz = framedGraph.addVertex("Frank Oz", Crew.class);
        oz.setFullName("Frank Oz");
        oz.addStarsInMovie(empireMovie);
        oz.addStarsInMovie(jediMovie);
        oz.addStarsInMovie(phantomMovie);
        oz.addStarsInMovie(clonesMovie);
        oz.addStarsInMovie(revengeMovie);
        oz.addPortrayals(yoda);
        Crew bulloch = framedGraph.addVertex("Jeremy Bulloch", Crew.class);
        bulloch.setFullName("Jeremy Bulloch");
        bulloch.addStarsInMovie(empireMovie);
        bulloch.addStarsInMovie(jediMovie);
        bulloch.addPortrayals(boba);
        Crew revill = framedGraph.addVertex("Clive Revill", Crew.class);
        revill.setFullName("Clive Revill");
        revill.addStarsInMovie(empireMovie);
        revill.addPortrayals(palpatine);
        Crew ian = framedGraph.addVertex("Ian McDiarmid", Crew.class);
        ian.setFullName("Ian McDiarmid");
        ian.addStarsInMovie(jediMovie);
        ian.addStarsInMovie(phantomMovie);
        ian.addStarsInMovie(clonesMovie);
        ian.addStarsInMovie(revengeMovie);
        ian.addPortrayals(palpatine);
        Crew shaw = framedGraph.addVertex("Sebastian Shaw", Crew.class);
        shaw.setFullName("Sebastian Shaw");
        shaw.addStarsInMovie(jediMovie);
        shaw.addPortrayals(anakin);
        Crew liam = framedGraph.addVertex("Liam Neeson", Crew.class);
        liam.setFullName("Liam Neeson");
        liam.addStarsInMovie(phantomMovie);
        liam.addPortrayals(quigon);
        Crew portman = framedGraph.addVertex("Natalie Portman", Crew.class);
        portman.setFullName("Natalie Portman");
        portman.addStarsInMovie(phantomMovie);
        portman.addStarsInMovie(clonesMovie);
        portman.addStarsInMovie(revengeMovie);
        portman.addPortrayals(padme);
        Crew lloyd = framedGraph.addVertex("Jake Lloyd", Crew.class);
        lloyd.setFullName("Jake Lloyd");
        lloyd.addStarsInMovie(phantomMovie);
        lloyd.addPortrayals(anakin);
        Crew hayden = framedGraph.addVertex("Hayden Christensen", Crew.class);
        hayden.setFullName("Hayden Christensen");
        hayden.addStarsInMovie(clonesMovie);
        hayden.addStarsInMovie(revengeMovie);
        hayden.addPortrayals(anakin);
        Crew august = framedGraph.addVertex("Pernill August", Crew.class);
        august.setFullName("Pernill August");
        august.addStarsInMovie(phantomMovie);
        august.addStarsInMovie(clonesMovie);
        august.addPortrayals(shmi);
        Crew park = framedGraph.addVertex("Ray Park", Crew.class);
        park.setFullName("Ray Park");
        park.addStarsInMovie(phantomMovie);
        park.addPortrayals(maul);
        Crew samuel = framedGraph.addVertex("Samuel L. Jackson", Crew.class);
        samuel.setFullName("Samuel L. Jackson");
        samuel.addStarsInMovie(phantomMovie);
        samuel.addStarsInMovie(clonesMovie);
        samuel.addStarsInMovie(revengeMovie);
        samuel.addPortrayals(windu);
        Crew lee = framedGraph.addVertex("Christopher Lee", Crew.class);
        lee.setFullName("Christopher Lee");
        lee.addStarsInMovie(clonesMovie);
        lee.addStarsInMovie(revengeMovie);
        lee.addPortrayals(tyranus);
        Crew morrison = framedGraph.addVertex("Temuera Morrison", Crew.class);
        morrison.setFullName("Temuera Morrison");
        morrison.addStarsInMovie(clonesMovie);
        morrison.addPortrayals(jango);
        Crew logan = framedGraph.addVertex("Daniel Logan", Crew.class);
        logan.setFullName("Daniel Logan");
        logan.addStarsInMovie(clonesMovie);
        logan.addPortrayals(boba);
        Crew blake = framedGraph.addVertex("Paul Blake", Crew.class);
        blake.setFullName("Paul Blake");
        blake.addStarsInMovie(newhopeMovie);
        blake.addPortrayals(greedo);
        Crew lawson = framedGraph.addVertex("Denis Lawson", Crew.class);
        lawson.setFullName("Denis Lawson");
        lawson.addStarsInMovie(newhopeMovie);
        lawson.addStarsInMovie(empireMovie);
        lawson.addStarsInMovie(jediMovie);
        lawson.addPortrayals(wedge);
        Kills curKills = null;
        curKills = anakin.addKills(obiwan);
        curKills.setFilm(newhopeMovie.asVertex().getId().toString());
        curKills = luke.addKills(tarkin);
        curKills.setFilm(newhopeMovie.asVertex().getId().toString());
        curKills = windu.addKills(jango);
        curKills.setFilm(clonesMovie.asVertex().getId().toString());
        curKills = palpatine.addKills(windu);
        curKills.setFilm(revengeMovie.asVertex().getId().toString());
        curKills = wedge.addKills(palpatine);
        curKills.setFilm(jediMovie.asVertex().getId().toString());
        curKills = lando.addKills(palpatine);
        curKills.setFilm(jediMovie.asVertex().getId().toString());
        curKills = maul.addKills(quigon);
        curKills.setFilm(phantomMovie.asVertex().getId().toString());
        curKills = obiwan.addKills(maul);
        curKills.setFilm(phantomMovie.asVertex().getId().toString());
        curKills = han.addKills(greedo);
        curKills.setFilm(newhopeMovie.asVertex().getId().toString());
        curKills = han.addKills(boba);
        curKills.setFilm(jediMovie.asVertex().getId().toString());
        curKills = anakin.addKills(tyranus);
        curKills.setFilm(revengeMovie.asVertex().getId().toString());
        curKills = palpatine.addKills(anakin);
        curKills.setFilm(jediMovie.asVertex().getId().toString());
        anakin.addSpawns(threepio);
        anakin.addSpawns(luke);
        anakin.addSpawns(leia);
        padme.addSpawns(luke);
        padme.addSpawns(leia);
        shmi.addSpawns(anakin);
        jango.addSpawns(boba);
        graph.commit();
    } catch (Throwable t) {
        t.printStackTrace();
    }
    long testEndTime = System.nanoTime();
    System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Also used : JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) Rates(org.openntf.domino.graph2.builtin.social.Rates) TypedGraphModuleBuilder(com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder) DElementStore(org.openntf.domino.graph2.impl.DElementStore) DGraph(org.openntf.domino.graph2.impl.DGraph) DConfiguration(org.openntf.domino.graph2.impl.DConfiguration) JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) Module(com.tinkerpop.frames.modules.Module) Person(org.openntf.domino.graph2.builtin.identity.Person) DFramedGraphFactory(org.openntf.domino.graph2.impl.DFramedGraphFactory)

Example 3 with JavaHandlerModule

use of com.tinkerpop.frames.modules.javahandler.JavaHandlerModule in project pentaho-metaverse by pentaho.

the class BaseMetaverseValidationIT method init.

/**
 * Call in the child class's BeforeClass method.
 */
public static void init(final String rootTestFolder, final String targetOutputFile) throws Exception {
    IntegrationTestUtil.initializePentahoSystem("src/it/resources/solution/system/pentahoObjects.spring.xml");
    // we only care about the demo folder
    FileSystemLocator fileSystemLocator = PentahoSystem.get(FileSystemLocator.class);
    IDocumentLocatorProvider provider = PentahoSystem.get(IDocumentLocatorProvider.class);
    // remove the original locator so we can set the modified one back on it
    provider.removeDocumentLocator(fileSystemLocator);
    fileSystemLocator.setRootFolder(rootTestFolder);
    provider.addDocumentLocator(fileSystemLocator);
    MetaverseUtil.setDocumentController(PentahoSystem.get(IDocumentController.class));
    // build the graph using our updated locator/provider
    graph = IntegrationTestUtil.buildMetaverseGraph(provider);
    reader = PentahoSystem.get(IMetaverseReader.class);
    framedGraphFactory = new FramedGraphFactory(new GremlinGroovyModule(), new JavaHandlerModule());
    framedGraph = framedGraphFactory.create(graph);
    root = (RootNode) framedGraph.getVertex("entity", RootNode.class);
    final List<Vertex> allVertices = IteratorUtils.toList(framedGraph.getVertices().iterator());
    for (final Vertex vertex : allVertices) {
        final String vertexId = vertex.getId().toString();
        if (vertexId.startsWith("entity_")) {
            entityNodes.put(vertexId.replace("entity_", ""), (Concept) framedGraph.getVertex(vertexId, Concept.class));
        }
    }
    File exportFile = new File(targetOutputFile);
    FileUtils.writeStringToFile(exportFile, reader.exportToXml(), "UTF-8");
}
Also used : IMetaverseReader(org.pentaho.metaverse.api.IMetaverseReader) IDocumentLocatorProvider(org.pentaho.metaverse.api.IDocumentLocatorProvider) Vertex(com.tinkerpop.blueprints.Vertex) JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) GremlinGroovyModule(com.tinkerpop.frames.modules.gremlingroovy.GremlinGroovyModule) IDocumentController(org.pentaho.metaverse.api.IDocumentController) FramedGraphFactory(com.tinkerpop.frames.FramedGraphFactory) FileSystemLocator(org.pentaho.metaverse.locator.FileSystemLocator) File(java.io.File)

Example 4 with JavaHandlerModule

use of com.tinkerpop.frames.modules.javahandler.JavaHandlerModule in project org.openntf.domino by OpenNTF.

the class DFramedGraphFactory method getConfiguration.

/**
 * Returns a configuration that can be used when constructing a framed graph.
 *
 * @param requiredType
 *            The type of graph required after configuration e.g. {@link TransactionalGraph}
 * @param baseGraph
 *            The base graph to get a configuration for.
 * @return The configuration.
 */
@SuppressWarnings("nls")
protected <T extends Graph> FramedGraphConfiguration getConfiguration(final Class<T> requiredType, final T baseGraph) {
    Graph configuredGraph = baseGraph;
    DConfiguration config;
    if (baseGraph instanceof DGraph) {
        config = (DConfiguration) ((DGraph) baseGraph).getConfiguration();
    } else {
        config = getBaseConfig();
    }
    if (modules == null) {
        Module module = configuration_.getModule();
        configuredGraph = module.configure(configuredGraph, config);
        configuredGraph = new JavaHandlerModule().configure(configuredGraph, config);
    } else {
        boolean hasJHM = false;
        for (Module module : modules) {
            if (module instanceof JavaHandlerModule)
                hasJHM = true;
            configuredGraph = module.configure(configuredGraph, config);
            if (!(requiredType.isInstance(configuredGraph))) {
                throw new UnsupportedOperationException("Module '" + module.getClass() + "' returned a '" + baseGraph.getClass().getName() + "' but factory requires '" + requiredType.getName() + "'");
            }
        }
        if (!hasJHM) {
            configuredGraph = new JavaHandlerModule().configure(configuredGraph, config);
        }
    }
    config.setConfiguredGraph(configuredGraph);
    return config;
}
Also used : JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) FramedTransactionalGraph(com.tinkerpop.frames.FramedTransactionalGraph) Graph(com.tinkerpop.blueprints.Graph) JavaHandlerModule(com.tinkerpop.frames.modules.javahandler.JavaHandlerModule) Module(com.tinkerpop.frames.modules.Module)

Aggregations

JavaHandlerModule (com.tinkerpop.frames.modules.javahandler.JavaHandlerModule)4 Module (com.tinkerpop.frames.modules.Module)3 TypedGraphModuleBuilder (com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)2 Person (org.openntf.domino.graph2.builtin.identity.Person)2 DConfiguration (org.openntf.domino.graph2.impl.DConfiguration)2 DElementStore (org.openntf.domino.graph2.impl.DElementStore)2 DFramedGraphFactory (org.openntf.domino.graph2.impl.DFramedGraphFactory)2 DGraph (org.openntf.domino.graph2.impl.DGraph)2 Graph (com.tinkerpop.blueprints.Graph)1 TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)1 Vertex (com.tinkerpop.blueprints.Vertex)1 FramedGraphFactory (com.tinkerpop.frames.FramedGraphFactory)1 FramedTransactionalGraph (com.tinkerpop.frames.FramedTransactionalGraph)1 GremlinGroovyModule (com.tinkerpop.frames.modules.gremlingroovy.GremlinGroovyModule)1 File (java.io.File)1 Rates (org.openntf.domino.graph2.builtin.social.Rates)1 IDocumentController (org.pentaho.metaverse.api.IDocumentController)1 IDocumentLocatorProvider (org.pentaho.metaverse.api.IDocumentLocatorProvider)1 IMetaverseReader (org.pentaho.metaverse.api.IMetaverseReader)1 FileSystemLocator (org.pentaho.metaverse.locator.FileSystemLocator)1