Package org.apache.stanbol.entityhub.indexing.core.source

Examples of org.apache.stanbol.entityhub.indexing.core.source.ResourceLoader


    @Test
    public void testSingleFile(){
        DummyResourceImporter importer = new DummyResourceImporter(
            Arrays.asList(rootDir+"singleFileTest.txt"));
        ResourceLoader loader = new ResourceLoader(importer, false, false);
        loader.addResource(new File(rootDir,"singleFileTest.txt"));
        assertEquals(new HashSet<String>(Arrays.asList(rootDir+"singleFileTest.txt")),
            loader.getResources(ResourceState.REGISTERED));
        assertTrue(loader.getResources(ResourceState.ERROR).isEmpty());
        assertTrue(loader.getResources(ResourceState.LOADED).isEmpty());
        assertTrue(loader.getResources(ResourceState.IGNORED).isEmpty());
        loader.loadResources();
        assertEquals(new HashSet<String>(Arrays.asList(rootDir+"singleFileTest.txt")),
            loader.getResources(ResourceState.LOADED));
        assertTrue(loader.getResources(ResourceState.REGISTERED).isEmpty());
        assertTrue(loader.getResources(ResourceState.IGNORED).isEmpty());
        assertTrue(loader.getResources(ResourceState.ERROR).isEmpty());
        importer.checkAllProcessed();
       
    }
View Full Code Here


            folder+"fileInFolder.txt",
            folder+"ignoreFileInFolder.txt",
            folder+"otherFileInFolder.txt"));
        DummyResourceImporter importer = new DummyResourceImporter(
            expectedFolderResources);
        ResourceLoader loader = new ResourceLoader(importer, false, false);
        loader.addResource(new File(rootDir,"testFolder"));
        assertEquals(expectedFolderResources, loader.getResources(ResourceState.REGISTERED));
        assertTrue(loader.getResources(ResourceState.ERROR).isEmpty());
        assertTrue(loader.getResources(ResourceState.LOADED).isEmpty());
        assertTrue(loader.getResources(ResourceState.IGNORED).isEmpty());
        loader.loadResources();
        assertEquals(new HashSet<String>(Arrays.asList(
            folder+"archiveInFolder.zip", folder+"fileInFolder.txt",
            folder+"otherFileInFolder.txt",folder+"archiveWithIgnore.zip",
            folder+"archiveWithError.zip")),
            loader.getResources(ResourceState.LOADED));
        assertTrue(loader.getResources(ResourceState.REGISTERED).isEmpty());
        assertEquals(new HashSet<String>(Arrays.asList(
            folder+"errorFileInFolder.txt")),
            loader.getResources(ResourceState.ERROR));
        assertEquals(new HashSet<String>(Arrays.asList(
            folder+"ignoreFileInFolder.txt")),
            loader.getResources(ResourceState.IGNORED));
    }
View Full Code Here

            "fileInFolder.txt",
            "ignoreFileInFolder.txt",
            "otherFileInFolder.txt");
        DummyResourceImporter importer = new DummyResourceImporter(
            expectedResourceNames);
        ResourceLoader loader = new ResourceLoader(importer, true, false);
        loader.addResource(new File(rootDir,TEST_FOLDER_NAME));

        assertEquals(expectedResources, loader.getResources(ResourceState.REGISTERED));
        assertTrue(loader.getResources(ResourceState.ERROR).isEmpty());
        assertTrue(loader.getResources(ResourceState.LOADED).isEmpty());
        assertTrue(loader.getResources(ResourceState.IGNORED).isEmpty());
        loader.loadResources();
        assertEquals(new HashSet<String>(Arrays.asList(
            folder+"archiveInFolder.zip",
            folder+"archiveWithIgnore.zip", //ignored files in archives are OK
            folder+"fileInFolder.txt",folder+"otherFileInFolder.txt")),
            loader.getResources(ResourceState.LOADED));
        assertTrue(loader.getResources(ResourceState.REGISTERED).isEmpty());
        assertEquals(new HashSet<String>(Arrays.asList(
            folder+"errorFileInFolder.txt",
            folder+"archiveWithError.zip")), //archive with errors MUST be ERROR
            loader.getResources(ResourceState.ERROR));
        assertEquals(new HashSet<String>(Arrays.asList(
            folder+"ignoreFileInFolder.txt")),
            loader.getResources(ResourceState.IGNORED));
    }
View Full Code Here

    private boolean isFailedOnError(boolean failOnError){
    String folder = rootDir + TEST_FOLDER_NAME;
    boolean failed = false;
    DummyResourceImporter importer = new DummyResourceImporter(
        Arrays.asList(folder + "errorFileInFolder.txt"));
    ResourceLoader loader = new ResourceLoader(importer, false, failOnError);
    loader.addResource(new File(folder, "errorFileInFolder.txt"));
    try {
      loader.loadResources();
    } catch (IllegalStateException ex) {
      failed = true;
    }
    return failed;
    }
View Full Code Here

            throw new IllegalArgumentException("The parsed model location MUST NOT be NULL!");
        }
        //init the store
        this.indexingDataset = initTDBDataset(modelLocation);
        //use a ResourceLoader that fails on the first invalid RDF file (STANBOL-328)
        this.loader =  new ResourceLoader(new RdfResourceImporter(indexingDataset,importFilter), true,true);
        loader.addResource(sourceFileOrDirectory);
    }
View Full Code Here

            }
        }
       
        boolean failOnError = indexingConfig.isFailOnError();
        //create the ResourceLoader
        this.loader =  new ResourceLoader(new RdfResourceImporter(indexingDataset, importFilter), failOnError);
       
        value = config.get(PARAM_IMPORTED_FOLDER);
        String importedFolderName;
        if(value != null && !value.toString().isEmpty()){
            importedFolderName = value.toString();
View Full Code Here

            throw new IllegalArgumentException("The parsed model location MUST NOT be NULL!");
        }
        //init the store
        this.indexingDataset = initTDBDataset(modelLocation);
        //use a ResourceLoader that fails on the first invalid RDF file (STANBOL-328)
        this.loader =  new ResourceLoader(new RdfResourceImporter(indexingDataset), true,true);
        loader.addResource(sourceFileOrDirectory);
    }
View Full Code Here

        IndexingConfig indexingConfig = (IndexingConfig)config.get(IndexingConfig.KEY_INDEXING_CONFIG);
        //first init the RDF Model
        this.indexingDataset = Utils.getTDBDataset(config);
        //second we need to check if we need to import RDF files to the RDF model
        //create the ResourceLoader
        this.loader =  new ResourceLoader(new RdfResourceImporter(indexingDataset), true);
       
        Object value = config.get(PARAM_IMPORTED_FOLDER);
        String importedFolderName;
        if(value != null && !value.toString().isEmpty()){
            importedFolderName = value.toString();
View Full Code Here

            throw new IllegalArgumentException("The parsed model location MUST NOT be NULL!");
        }
        //init the store
        this.indexingDataset = initTDBDataset(modelLocation);
        //use a ResourceLoader that fails on the first invalid RDF file (STANBOL-328)
        this.loader =  new ResourceLoader(new RdfResourceImporter(indexingDataset), true,true);
        loader.addResource(sourceFileOrDirectory);
    }
View Full Code Here

        IndexingConfig indexingConfig = (IndexingConfig)config.get(IndexingConfig.KEY_INDEXING_CONFIG);
        //first init the RDF Model
        this.indexingDataset = Utils.getTDBDataset(config);
        //second we need to check if we need to import RDF files to the RDF model
        //create the ResourceLoader
        this.loader =  new ResourceLoader(new RdfResourceImporter(indexingDataset), true);
        //check if importing is deactivated
        boolean importSource = true; //default is true
        Object value = config.get(PARAM_IMPORT_SOURCE);
        if(value != null){
            importSource = Boolean.parseBoolean(value.toString());
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.indexing.core.source.ResourceLoader

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.