indexColl.resolveImports(aResourceManager); } catch (InvalidXMLException e) { throw new ResourceInitializationException(e); FsIndexDescription[] indexes = indexColl.getFsIndexes(); for (int i = 0; i < indexes.length; i++) { FsIndexDescription[] indexArray = new FsIndexDescription[indexes.size()]; indexes.toArray(indexArray); aggIndexColl.setFsIndexes(indexArray); return aggIndexColl;
@Override protected void setModelImportArray(Import[] imports) { if (imports == null) throw new InternalErrorCDE("invalid state"); getFsIndexCollection().setImports(imports); }
/** * used when hovering. * * @param source the source * @return the description from import * @throws InvalidXMLException the invalid XML exception * @throws IOException Signals that an I/O exception has occurred. */ @Override protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException { FsIndexCollection parsedImportItem = UIMAFramework.getXMLParser().parseFsIndexCollection( new XMLInputSource(source)); return parsedImportItem.getDescription(); }
/** * Creates a {@link FsIndexCollection} from all index descriptions that can be found via the * pattern specified in the system property {@code org.apache.uima.fit.fsindex.import_pattern} or * via the {@code META-INF/org.apache.uima.fit/fsindexes.txt} files in the classpath. * * @return the auto-scanned indexes. * @throws ResourceInitializationException * if the index collection could not be assembled */ public static FsIndexCollection createFsIndexCollection() throws ResourceInitializationException { List<FsIndexDescription> fsIndexList = new ArrayList<FsIndexDescription>(); for (String location : scanIndexDescriptors()) { try { XMLInputSource xmlInput = new XMLInputSource(location); FsIndexCollection fsIdxCol = getXMLParser().parseFsIndexCollection(xmlInput); fsIdxCol.resolveImports(); fsIndexList.addAll(asList(fsIdxCol.getFsIndexes())); LogFactory.getLog(FsIndexFactory.class).debug("Detected index at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(FsIndexFactory.class).warn( "[" + location + "] is not a index descriptor file. Ignoring.", e); } } return createFsIndexCollection(fsIndexList.toArray(new FsIndexDescription[fsIndexList.size()])); }
/** * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#getFsIndexes() */ public FsIndexDescription[] getFsIndexes() { return mFsIndexCollection == null ? null : mFsIndexCollection.getFsIndexes(); }
.getFsIndexes(); if (newFsid != indexes) { somethingChanged = true; indexCollection.setFsIndexes(newFsid);
/** * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#setFsIndexes(FsIndexDescription[]) */ public void setFsIndexes(FsIndexDescription[] aFsIndexes) { if (mFsIndexCollection == null) { mFsIndexCollection = new FsIndexCollection_impl(); } mFsIndexCollection.setFsIndexes(aFsIndexes); }
public void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException { if (getTypeSystem() != null) { getTypeSystem().resolveImports(aResourceManager); } if (getTypePriorities() != null) { getTypePriorities().resolveImports(aResourceManager); } if (getFsIndexCollection() != null) { getFsIndexCollection().resolveImports(aResourceManager); } }
@Override protected Import[] getModelImportArray() { return getFsIndexCollection().getImports(); }
private FsIndexCollection mergeFsIndexes() throws ResourceInitializationException { FsIndexCollection aggIndexColl = getCasManagerWrapper().getMetadata() .getFsIndexCollection(); if ( aggregateMetadata.getFsIndexes() != null ) { for ( FsIndexDescription fid : aggregateMetadata.getFsIndexes() ) { getCasManagerWrapper().getMetadata() .getFsIndexCollection().addFsIndex(fid); } List<FsIndexCollection> cl = new ArrayList<FsIndexCollection>(); cl.add(getCasManagerWrapper().getMetadata().getFsIndexCollection()); aggIndexColl = CasCreationUtils. mergeFsIndexes(cl, getCasManagerWrapper().getResourceManager()); } return aggIndexColl; } private TypePriorities mergeTypePriorities() throws ResourceInitializationException {
@Override protected boolean isValidImport(String title, String message) { FsIndexCollection savedIC = editor.getMergedFsIndexCollection(); if (null != savedIC) savedIC = (FsIndexCollection) savedIC.clone(); CAS savedCAS = editor.getCurrentView(); try { editor.setMergedFsIndexCollection(); editor.descriptorCAS.validate(); } catch (ResourceInitializationException e) { revertMsg(title, message, editor.getMessagesToRootCause(e)); editor.setMergedFsIndexCollection(savedIC); editor.descriptorCAS.set(savedCAS); return false; } return true; }
/** * Gets the name. * * @return the name */ public String getName() { if (editor.isLocalProcessingDescriptor()) return editor.getAeDescription().getMetaData().getName(); if (editor.isTypeSystemDescriptor()) return editor.getTypeSystemDescription().getName(); if (editor.isTypePriorityDescriptor()) return editor.getTypePriorities().getName(); if (editor.isFsIndexCollection()) return editor.getFsIndexCollection().getName(); if (editor.isExtResAndBindingsDescriptor()) return editor.getExtResAndBindings().getName(); throw new InternalErrorCDE("invalid state"); }
public CasDefinition(Collection<? extends ProcessingResourceMetaData> aMetaDataToMerge, ResourceManager aResourceManager) throws ResourceInitializationException { // extract TypeSystems, TypePriorities, and FsIndexes from metadata List<TypeSystemDescription> typeSystems = new ArrayList<TypeSystemDescription>(); List<TypePriorities> typePrioritiesList = new ArrayList<TypePriorities>(); List<FsIndexCollection> fsIndexes = new ArrayList<FsIndexCollection>(); Iterator<? extends ProcessingResourceMetaData> it = aMetaDataToMerge.iterator(); while (it.hasNext()) { ProcessingResourceMetaData md = it.next(); if (md.getTypeSystem() != null) typeSystems.add(md.getTypeSystem()); if (md.getTypePriorities() != null) typePrioritiesList.add(md.getTypePriorities()); if (md.getFsIndexCollection() != null) fsIndexes.add(md.getFsIndexCollection()); } // merge TypePriorities and FsIndexes TypePriorities aggTypePriorities = CasCreationUtils.mergeTypePriorities(typePrioritiesList, aResourceManager); FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexes, aResourceManager); TypeSystemDescription aggTypeDesc = CasCreationUtils.mergeTypeSystems(typeSystems, aResourceManager); this.typeSystemDescription = aggTypeDesc; this.typePriorities = aggTypePriorities; this.fsIndexDescriptions = aggIndexColl.getFsIndexes(); this.resourceManager = aResourceManager; }
private void resolveImport(URL aURL, Collection<String> aAlreadyImportedFsIndexCollectionURLs, Collection<FsIndexDescription> aResults, ResourceManager aResourceManager) throws InvalidXMLException, IOException { //check the import cache FsIndexCollection desc; String urlString = aURL.toString(); Map<String, XMLizable> importCache = ((ResourceManager_impl)aResourceManager).getImportCache(); Map<String, Set<String>> importUrlsCache = ((ResourceManager_impl)aResourceManager).getImportUrlsCache(); synchronized(importCache) { XMLizable cachedObject = importCache.get(urlString); if (cachedObject instanceof FsIndexCollection) { desc = (FsIndexCollection)cachedObject; // Add the URLs parsed for this cached object to the list already-parsed (UIMA-5058) aAlreadyImportedFsIndexCollectionURLs.addAll(importUrlsCache.get(urlString)); } else { XMLInputSource input; input = new XMLInputSource(aURL); desc = UIMAFramework.getXMLParser().parseFsIndexCollection(input); TreeSet<String> previouslyImported = new TreeSet<String>(aAlreadyImportedFsIndexCollectionURLs); desc.resolveImports(aAlreadyImportedFsIndexCollectionURLs, aResourceManager); importCache.put(urlString, desc); // Save the URLS parsed by this import TreeSet<String> locallyImported = new TreeSet<String>(aAlreadyImportedFsIndexCollectionURLs); locallyImported.removeAll(previouslyImported); importUrlsCache.put(urlString, locallyImported); } } aResults.addAll(Arrays.asList(desc.getFsIndexes())); }
/** * Constructs and returns a <code>ProcessingResourceMetaData</code> object * that contains the type system, indexes, and type priorities definitions * for the CAS. * * @return processing resource metadata object containing the * relevant parts of the CAS definition */ public ProcessingResourceMetaData getProcessingResourceMetaData() { ProcessingResourceMetaData md = UIMAFramework.getResourceSpecifierFactory().createProcessingResourceMetaData(); md.setTypeSystem(getTypeSystemDescription()); md.setTypePriorities(getTypePriorities()); FsIndexCollection indColl = UIMAFramework.getResourceSpecifierFactory().createFsIndexCollection(); indColl.setFsIndexes(getFsIndexDescriptions()); md.setFsIndexCollection(indColl); return md; } }
/** * Checks if is feature used in index. * * @param fullFeatureName the full feature name * @return true, if is feature used in index */ private boolean isFeatureUsedInIndex(String fullFeatureName) { if (!isLocalProcessingDescriptor()) { return false; } FsIndexCollection indexCollection = editor.getMergedFsIndexCollection(); FsIndexDescription[] fsid = (null == indexCollection) ? null : indexCollection.getFsIndexes(); if (null != fsid) { for (int i = 0; i < fsid.length; i++) { FsIndexKeyDescription[] keys = fsid[i].getKeys(); if (null != keys) { for (int j = 0; j < keys.length; j++) { if (keys[j].getFeatureName().equals(fullFeatureName)) return true; } } } } return false; }
/** * Constructs and returns a <code>ProcessingResourceMetaData</code> object that contains the type * system, indexes, and type priorities definitions for the CAS. * * @return processing resource metadata object containing the relevant parts of the CAS definition */ public ProcessingResourceMetaData getMetadata() throws ResourceInitializationException { CasDefinition casDefinition = casManager.getCasDefinition(); ProcessingResourceMetaData md = UIMAFramework.getResourceSpecifierFactory() .createProcessingResourceMetaData(); md.setTypeSystem(casDefinition.getTypeSystemDescription()); md.setTypePriorities(casDefinition.getTypePriorities()); FsIndexCollection indColl = UIMAFramework.getResourceSpecifierFactory() .createFsIndexCollection(); indColl.setFsIndexes(casDefinition.getFsIndexDescriptions()); md.setFsIndexCollection(indColl); return md; }
/** * Creates a {@link FsIndexCollection} from descriptor names. * * @param descriptorNames * The fully qualified, Java-style, dotted descriptor names. * @return a {@link FsIndexCollection} that includes the indexes from all of the specified files. */ public static FsIndexCollection createFsIndexCollection(String... descriptorNames) { List<Import> imports = new ArrayList<Import>(); for (String descriptorName : descriptorNames) { Import imp = new Import_impl(); imp.setName(descriptorName); imports.add(imp); } Import[] importArray = new Import[imports.size()]; FsIndexCollection fsIndexCollection = new FsIndexCollection_impl(); fsIndexCollection.setImports(imports.toArray(importArray)); return fsIndexCollection; }
/** * Gets the description. * * @return the description */ public String getDescription() { if (editor.isLocalProcessingDescriptor()) return editor.getAeDescription().getMetaData().getDescription(); if (editor.isTypeSystemDescriptor()) return editor.getTypeSystemDescription().getDescription(); if (editor.isTypePriorityDescriptor()) return editor.getTypePriorities().getDescription(); if (editor.isFsIndexCollection()) return editor.getFsIndexCollection().getDescription(); if (editor.isExtResAndBindingsDescriptor()) return editor.getExtResAndBindings().getDescription(); throw new InternalErrorCDE("invalid state"); }
return doCreateCas(aTypeSystem, null, aggTypePriorities, aggIndexColl.getFsIndexes(), aPerformanceTuningSettings, aResourceManager); } else { return doCreateCas(null, aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(), aPerformanceTuningSettings, aResourceManager);