XmiFileTreeCorpusDAO implements CorpusDAO { static public TypeSystemDescription getTypeSystem(String corpusPathString) throws SAXException, IOException, ParserConfigurationException { for (File f : new File(corpusPathString) .listFiles((FileFilter) new WildcardFileFilter("*.xml"))) { if (getXMLRootElement(f).equals("typeSystemDescription")) { return createTypeSystemDescriptionFromPath(f.toURI().toString()); } } throw new FileNotFoundException(); } XmiFileTreeCorpusDAO(String corpusPathString); @Override Set<URI> getDocuments(); @Override Set<String> getAnnotatorIds(URI docURI); @Override void getDocumentCas(URI docURI, String annotatorId, CAS aCAS); @Override boolean hasDocument(URI docURI, String annotatorId); @Override void persist(URI docUri, String annotatorId, CAS cas); static TypeSystemDescription getTypeSystem(String corpusPathString); static final String XMI_FILE_EXTENSION; }
@Test public void testGetTypeSystem() throws ResourceInitializationException, InvalidXMLException, SAXException, IOException, ParserConfigurationException { TypeSystemDescription typeSystem = XmiFileTreeCorpusDAO .getTypeSystem(corpusPathString); typeSystem.resolveImports(); Set<String> typeNames = new HashSet<String>(); for (TypeDescription type : typeSystem.getTypes()) { typeNames.add(type.getName()); } assertEquals(Sets.newHashSet( "com.textocat.textokit.commons.DocumentMetadata", "ru.kfu.itis.issst.evex.Person", "ru.kfu.itis.issst.evex.Organization", "ru.kfu.itis.issst.evex.Artifact", "ru.kfu.itis.issst.evex.Weapon", "ru.kfu.itis.issst.evex.Job", "ru.kfu.itis.issst.evex.Time", "ru.kfu.itis.issst.evex.Event", "ru.kfu.itis.issst.evex.Die", "ru.kfu.itis.issst.evex.StartPosition"), typeNames); }