Package org.gephi.io.importer.api

Examples of org.gephi.io.importer.api.Container


        database.setPasswd("");
        database.setNodeQuery("SELECT * FROM node LIMIT 0,1000");
        database.setEdgeQuery("SELECT * FROM edge WHERE id_node_from < 1000 AND id_node_to < 1000");
        database.setSQLDriver(new MySQLDriver());

        Container cont = Lookup.getDefault().lookup(Container.class);
        containerLoader = cont.getLoader();
        containerUnloader = cont.getUnloader();
    }
View Full Code Here


        } catch (IOException ex) {
            //Exceptions.printStackTrace(ex);
        }
        ImportController importController = Lookup.getDefault().lookup(ImportController.class);
        FileImporter fileImporter = importController.getFileImporter(".gexf");
        Container container = importController.importFile(stream, fileImporter);

        importController.process(container, new DefaultProcessor(), workspace);

        PreviewModel model = Lookup.getDefault().lookup(PreviewController.class).getModel();
        model.getNodeSupervisor().setShowNodeLabels(Boolean.TRUE);
View Full Code Here

    assertEquals(date, date2);
    }

    @Test
    public void testAttributeModel() {
        final Container container = Lookup.getDefault().lookup(ContainerFactory.class).newContainer();
        container.setReport(new Report());
        importer.execute(container.getLoader());

        ContainerUnloader unloader = container.getUnloader();
        assertNotNull(unloader.getAttributeModel().getNodeTable().getColumn("0", AttributeType.DYNAMIC_STRING));
        assertNotNull(unloader.getAttributeModel().getNodeTable().getColumn("1", AttributeType.DYNAMIC_FLOAT));
        assertNotNull(unloader.getAttributeModel().getNodeTable().getColumn("2", AttributeType.LIST_STRING));
        assertNotNull(unloader.getAttributeModel().getNodeTable().getColumn("3", AttributeType.DYNAMIC_FLOAT));
        assertNotNull(unloader.getAttributeModel().getNodeTable().getColumn("4", AttributeType.DYNAMIC_FLOAT));
View Full Code Here

        assertNotNull(unloader.getAttributeModel().getEdgeTable().getColumn("weight", AttributeType.DYNAMIC_FLOAT));
    }

    @Test
    public void testNode() {
        final Container container = Lookup.getDefault().lookup(ContainerFactory.class).newContainer();
        container.setReport(new Report());
        importer.execute(container.getLoader());

        NodeDraftGetter n1 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b90d1b4bc2");
        NodeDraftGetter n2 = (NodeDraftGetter) container.getLoader().getNode("4c175b542c9016b9ce1b4bc2");
        NodeDraftGetter n3 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b9071b4bc2");
        NodeDraftGetter n4 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b9101b4bc2");
        NodeDraftGetter n5 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b93a1b4bc2");
        NodeDraftGetter n6 = (NodeDraftGetter) container.getLoader().getNode("4c175b4a2c9016b9a51a4bc2");
        NodeDraftGetter n7 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b9ba1a4bc2");
        NodeDraftGetter n8 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b9ed1a4bc2");
        NodeDraftGetter n9 = (NodeDraftGetter) container.getLoader().getNode("4c175b4b2c9016b9f61a4bc2");

        assertNotNull(n1);
        assertNotNull(n2);
        assertNotNull(n3);
        assertNotNull(n4);
        assertNotNull(n5);
        assertNotNull(n6);
        assertNotNull(n7);
        assertNotNull(n8);
        assertNotNull(n9);

        ContainerUnloader unloader = container.getUnloader();
        AttributeColumn col0 = unloader.getAttributeModel().getNodeTable().getColumn("0");
        AttributeColumn col1 = unloader.getAttributeModel().getNodeTable().getColumn("1");
        AttributeColumn col2 = unloader.getAttributeModel().getNodeTable().getColumn("2");
        AttributeColumn col3 = unloader.getAttributeModel().getNodeTable().getColumn("3");
        AttributeColumn col4 = unloader.getAttributeModel().getNodeTable().getColumn("4");

        try {
            assertEquals("Node 1", n1.getLabel());
            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n1.getTimeInterval().getValues().get(0)[0]));
            assertEquals("2000-12-31", DynamicUtilities.getXMLDateStringFromDouble(n1.getTimeInterval().getValues().get(0)[1]));

            AttributeValue[] values1 = n1.getAttributeRow().getValues();
            assertEquals("0", values1[col0.getIndex()].getColumn().getId());
            assertEquals("3", values1[col3.getIndex()].getColumn().getId());
            assertEquals("Author", ((DynamicType) values1[col0.getIndex()].getValue()).getValue());
            assertEquals(new Float(1), ((DynamicType) values1[col3.getIndex()].getValue()).getValue());

            AttributeValue[] values2 = n2.getAttributeRow().getValues();
            assertEquals("0", values2[col0.getIndex()].getColumn().getId());
            assertEquals("2", values2[col2.getIndex()].getColumn().getId());
            assertEquals("Author", ((DynamicType) values2[col0.getIndex()].getValue()).getValue());
            assertEquals(new StringList("String1, String2, String 3"), values2[col2.getIndex()].getValue());

            AttributeValue[] values3 = n3.getAttributeRow().getValues();
            DynamicType val4 = (DynamicType) values3[col4.getIndex()].getValue();
            double low = DynamicUtilities.getDoubleFromXMLDateString("2009-01-01");
            double high = DynamicUtilities.getDoubleFromXMLDateString("2009-12-31");
            assertEquals(new Float(3f), val4.getValue(low, high));

            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[0]));
            assertEquals("2000-01-15", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[1]));
            assertEquals("2001-01-30", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[0]));
            assertEquals("2001-02-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[1]));
            assertEquals(2, n3.getTimeInterval().getValues().size());

            container.verify();

            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n4.getTimeInterval().getValues().get(0)[0]));
            assertEquals("2010-12-31", DynamicUtilities.getXMLDateStringFromDouble(n4.getTimeInterval().getValues().get(0)[1]));

            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[0]));
            assertEquals("2000-01-15", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[1]));
            assertEquals("2001-01-30", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[0]));
            assertEquals("2001-02-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[1]));

        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
        container.closeLoader();
        System.out.println(container.getReport().getText());
    }
View Full Code Here

        System.out.println(container.getReport().getText());
    }

    @Test
    public void testHierarchy() {
        final Container container = Lookup.getDefault().lookup(ContainerFactory.class).newContainer();
        container.setReport(new Report());
        importer.execute(container.getLoader());

        NodeDraftGetter na = (NodeDraftGetter) container.getLoader().getNode("a");
        NodeDraftGetter nb = (NodeDraftGetter) container.getLoader().getNode("b");
        NodeDraftGetter nc = (NodeDraftGetter) container.getLoader().getNode("c");
        NodeDraftGetter nd = (NodeDraftGetter) container.getLoader().getNode("d");
        NodeDraftGetter ne = (NodeDraftGetter) container.getLoader().getNode("e");
        NodeDraftGetter nf = (NodeDraftGetter) container.getLoader().getNode("f");
        NodeDraftGetter ng = (NodeDraftGetter) container.getLoader().getNode("g");
        NodeDraftGetter nh = (NodeDraftGetter) container.getLoader().getNode("h");
        NodeDraftGetter ni = (NodeDraftGetter) container.getLoader().getNode("i");
        NodeDraftGetter nj = (NodeDraftGetter) container.getLoader().getNode("j");

        assertNotNull(na);
        assertNotNull(nb);
        assertNotNull(nc);
        assertNotNull(nd);
        assertNotNull(ne);
        assertNotNull(nf);
        assertNotNull(ng);

        assertNull(na.getParents());
        assertEquals(1, nb.getParents().length);
        assertEquals(1, nc.getParents().length);
        assertEquals(1, nd.getParents().length);
        assertEquals(1, ne.getParents().length);
        assertEquals(1, nf.getParents().length);
        assertEquals(1, ng.getParents().length);

        assertEquals(na, nb.getParents()[0]);
        assertEquals(nb, nc.getParents()[0]);
        assertEquals(nb, nd.getParents()[0]);
        assertEquals(na, ne.getParents()[0]);
        assertEquals(ne, nf.getParents()[0]);
        assertEquals(ne, ng.getParents()[0]);

        assertEquals(nf, nh.getParents()[0]);
        assertEquals(nj, ni.getParents()[0]);

        System.out.println(container.getReport().getText());
    }
View Full Code Here

        FileObject fileObject = FileUtil.toFileObject(file);
        if (fileObject != null) {
            fileObject = getArchivedFile(fileObject);   //Unzip and return content file
            FileImporterBuilder builder = getMatchingImporter(fileObject);
            if (fileObject != null && builder != null) {
                Container c = importFile(fileObject.getInputStream(), builder.buildImporter());
                if (fileObject.getPath().startsWith(System.getProperty("java.io.tmpdir"))) {
                    try {
                        fileObject.delete();
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
View Full Code Here

    public Container importFile(File file, FileImporter importer) throws FileNotFoundException {
        FileObject fileObject = FileUtil.toFileObject(file);
        if (fileObject != null) {
            fileObject = getArchivedFile(fileObject);   //Unzip and return content file
            if (fileObject != null) {
                Container c = importFile(fileObject.getInputStream(), importer);
                if (fileObject.getPath().startsWith(System.getProperty("java.io.tmpdir"))) {
                    try {
                        fileObject.delete();
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
View Full Code Here

    public void testExport() {
        ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
        pc.newProject();
        Workspace workspace = pc.getCurrentWorkspace();

        Container container = Lookup.getDefault().lookup(ContainerFactory.class).newContainer();
        RandomGraph randomGraph = new RandomGraph();
        randomGraph.generate(container.getLoader());

        //Append container to graph structure
        ImportController importController = Lookup.getDefault().lookup(ImportController.class);
        importController.process(container, new DefaultProcessor(), workspace);
View Full Code Here

        return null;
    }

    public Container importFile(Reader reader, FileImporter importer) {
        //Create Container
        final Container container = Lookup.getDefault().lookup(ContainerFactory.class).newContainer();

        //Report
        Report report = new Report();
        container.setReport(report);

        importer.setReader(reader);

        try {
            if (importer.execute(container.getLoader())) {
                if (importer.getReport() != null) {
                    report.append(importer.getReport());
                }
                return container;
            }
View Full Code Here

        }
    }

    public Container importDatabase(Database database, DatabaseImporter importer) {
        //Create Container
        final Container container = Lookup.getDefault().lookup(ContainerFactory.class).newContainer();

        //Report
        Report report = new Report();
        container.setReport(report);

        importer.setDatabase(database);

        try {
            if (importer.execute(container.getLoader())) {
                if (importer.getReport() != null) {
                    report.append(importer.getReport());
                }
                return container;
            }
View Full Code Here

TOP

Related Classes of org.gephi.io.importer.api.Container

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.