int partStart = 0; Import imp = UIMAFramework.getResourceSpecifierFactory().createImport(); ResourceManager rm = editor.createResourceManager();
/** * @param descriptor * @param cpeDescSaveFile */ private void updateImport(CpeComponentDescriptor descriptor, File cpeDescSaveFile) throws Exception { //don't touch import by name if (descriptor.getImport() != null && descriptor.getImport().getName() != null) return; //for include or import by location, get the absolute URL of the descriptor URL descUrl = descriptor.findAbsoluteUrl(defaultResourceManager); //don't touch URLs with protocol other than file: if ("file".equals(descUrl.getProtocol())) { File descFile = urlToFile(descUrl); //try to find relative path from cpeDescSaveFile to descFile String relPath = FileUtils.findRelativePath(descFile, cpeDescSaveFile.getParentFile()); if (relPath != null) { //update CPE descriptor descriptor.setInclude(null); Import newImport = UIMAFramework.getResourceSpecifierFactory().createImport(); newImport.setLocation(relPath); descriptor.setImport(newImport); } } }
/** * Update import. * * @param descriptor the descriptor * @param cpeDescSaveFile the cpe desc save file * @throws Exception the exception */ private void updateImport(CpeComponentDescriptor descriptor, File cpeDescSaveFile) throws Exception { //don't touch import by name if (descriptor.getImport() != null && descriptor.getImport().getName() != null) return; //for include or import by location, get the absolute URL of the descriptor URL descUrl = descriptor.findAbsoluteUrl(defaultResourceManager); //don't touch URLs with protocol other than file: if ("file".equals(descUrl.getProtocol())) { File descFile = urlToFile(descUrl); //try to find relative path from cpeDescSaveFile to descFile String relPath = FileUtils.findRelativePath(descFile, cpeDescSaveFile.getParentFile()); if (relPath != null) { //update CPE descriptor descriptor.setInclude(null); Import newImport = UIMAFramework.getResourceSpecifierFactory().createImport(); newImport.setLocation(relPath); descriptor.setImport(newImport); } } }
/** * Get a CollectionReader from the name (Java-style, dotted) of an XML descriptor file, and a set * of configuration parameters. * * @param descriptorName * The fully qualified, Java-style, dotted name of the XML descriptor file. * @param configurationData * Any additional configuration parameters to be set. These should be supplied as (name, * value) pairs, so there should always be an even number of parameters. * @return The AnalysisEngine created from the XML descriptor and the configuration parameters. * @throws UIMAException * if the descriptor could not be created or if the component could not be instantiated * @throws IOException * if the descriptor could not be read */ public static CollectionReader createReader(String descriptorName, Object... configurationData) throws UIMAException, IOException { Import imp = UIMAFramework.getResourceSpecifierFactory().createImport(); imp.setName(descriptorName); URL url = imp.findAbsoluteUrl(ResourceManagerFactory.newResourceManager()); ResourceSpecifier specifier = createResourceCreationSpecifier(url, configurationData); return UIMAFramework.produceCollectionReader(specifier, ResourceManagerFactory.newResourceManager(), null); }
String dlgDescPath = dlgInsD.getMainComponentDesc(); Import dlgImport = rsFactory.createImport();