TypePriorities tp = it.next(); try { tp.resolveImports(aResourceManager); } catch (InvalidXMLException e) { throw new ResourceInitializationException(e); TypePriorityList[] pls = tp.getPriorityLists(); if (pls != null) { for (int i = 0; i < pls.length; i++) { aggTypePriorities.addPriorityList(pls[i]);
/** * Save good version of type priorities. */ private void saveGoodVersionOfTypePriorities() { TypePriorities tp = getAeDescription().getAnalysisEngineMetaData().getTypePriorities(); m_typePrioritiesBackup = (null == tp) ? null : (TypePriorities) tp.clone(); }
/** * 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 { TypePriorities parsedImportItem = UIMAFramework.getXMLParser().parseTypePriorities( new XMLInputSource(source)); return parsedImportItem.getDescription(); }
private void resolveImport(URL aURL, Collection<String> aAlreadyImportedTypePrioritiesURLs, Collection<TypePriorityList> aResults, ResourceManager aResourceManager) throws InvalidXMLException, IOException { //check the import cache TypePriorities 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 TypePriorities) { desc = (TypePriorities)cachedObject; // Add the URLs parsed for this cached object to the list already-parsed (UIMA-5058) aAlreadyImportedTypePrioritiesURLs.addAll(importUrlsCache.get(urlString)); } else { XMLInputSource input; input = new XMLInputSource(aURL); desc = UIMAFramework.getXMLParser().parseTypePriorities(input); TreeSet<String> previouslyImported = new TreeSet<String>(aAlreadyImportedTypePrioritiesURLs); desc.resolveImports(aAlreadyImportedTypePrioritiesURLs, aResourceManager); importCache.put(urlString, desc); // Save the URLS parsed by this import TreeSet<String> locallyImported = new TreeSet<String>(aAlreadyImportedTypePrioritiesURLs); locallyImported.removeAll(previouslyImported); importUrlsCache.put(urlString, locallyImported); } } aResults.addAll(Arrays.asList(desc.getPriorityLists())); }
getTypePriorities().addPriorityList(typePriorityList); TypePriorityList removedTypePriorityList = getTypePriorityListFromTreeItem(item); TypePriorityList[] oldPriorityLists = getAnalysisEngineMetaData().getTypePriorities() .getPriorityLists(); TypePriorityList[] newPriorityLists = new TypePriorityList[oldPriorityLists.length - 1]; getAnalysisEngineMetaData().getTypePriorities().setPriorityLists(newPriorityLists); setFileDirty(); TypePriorityList[] tpl = getTypePriorities().getPriorityLists(); tpl[tree.indexOf(parent)] = typePriorityList; getTypePriorities().setPriorityLists(tpl); } else if (event.widget == exportButton) { typePriorityImportSection.exportImportablePart("<typePriorities>",
private TypePriorities mergeTypePriorities() throws ResourceInitializationException { TypePriorities aggTypePriorities = getCasManagerWrapper().getMetadata().getTypePriorities(); if ( aggregateMetadata.getTypePriorities() != null && aggregateMetadata.getTypePriorities().getPriorityLists() != null) { for( TypePriorityList pl : aggregateMetadata.getTypePriorities().getPriorityLists()) { getCasManagerWrapper(). getMetadata(). getTypePriorities(). addPriorityList(pl); } List<? extends TypePriorities> tpl = Arrays.asList(getCasManagerWrapper().getMetadata().getTypePriorities()); aggTypePriorities = CasCreationUtils.mergeTypePriorities(tpl, getCasManagerWrapper().getResourceManager()); } return aggTypePriorities; } protected void startProcessing() throws Exception {
/** * Gets the type priority list from tree item. * * @param item the item * @return the type priority list from tree item */ public TypePriorityList getTypePriorityListFromTreeItem(TreeItem item) { TypePriorityList[] typePriorityLists = getAnalysisEngineMetaData().getTypePriorities() .getPriorityLists(); return typePriorityLists[tree.indexOf(item)]; }
/** * Create a TypePriorities given a sequence of ordered type names * * @param prioritizedTypeNames * a sequence of ordered type names * @return type priorities created from the ordered type names */ public static TypePriorities createTypePriorities(String... prioritizedTypeNames) { TypePriorities typePriorities = new TypePriorities_impl(); TypePriorityList typePriorityList = typePriorities.addPriorityList(); for (String typeName : prioritizedTypeNames) { typePriorityList.addType(typeName); } return typePriorities; }
XMLInputSource xmlInput = new XMLInputSource(location); TypePriorities typePriorities = getXMLParser().parseTypePriorities(xmlInput); typePriorities.resolveImports(); typePrioritiesList.add(typePriorities); LogFactory.getLog(TypePrioritiesFactory.class).debug(
@Override protected Import[] getModelImportArray() { return getTypePriorities().getImports(); }
/** * 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"); }
TypePriorityList[] priorityLists = priorities.getPriorityLists(); if (priorityLists != null) { for (int i = 0; i < priorityLists.length; i++) {
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); } }
TypePriorities priorities = getAnalysisEngineMetaData().getTypePriorities(); if (priorities != null) { TypePriorityList[] priorityLists = priorities.getPriorityLists(); if (priorityLists != null) { for (int i = 0; i < priorityLists.length; i++) {
aTypePriorities.resolveImports(aResourceManager);
@Override protected boolean isValidImport(String title, String message) { CAS savedCAS = editor.getCurrentView(); TypePriorities savedTP = editor.getMergedTypePriorities(); if (null != savedTP) savedTP = (TypePriorities) savedTP.clone(); try { editor.setMergedTypePriorities(); editor.descriptorCAS.validate(); } catch (ResourceInitializationException e1) { revertMsg(title, message, editor.getMessagesToRootCause(e1)); editor.setMergedTypePriorities(savedTP); editor.descriptorCAS.set(savedCAS); return false; } return true; }
/** * 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"); }
LinearTypeOrderBuilder typeOrderBuilder = aCASMgr.getIndexRepositoryMgr() .getDefaultOrderBuilder(); TypePriorityList[] priorityLists = aTypePriorities.getPriorityLists(); for (int i = 0; i < priorityLists.length; i++) {
@Override public void refresh() { if (null == typePriorityImportSection) typePriorityImportSection = editor.getIndexesPage().getTypePriorityImportSection(); super.refresh(); tree.removeAll(); TypePriorities typePriorities = getTypePriorities(); if (typePriorities != null) { TypePriorityList[] priorityLists = typePriorities.getPriorityLists(); for (int i = 0; i < priorityLists.length; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText(PRIORITY_LIST); String[] types = priorityLists[i].getTypes(); if (null != types) { for (int j = 0; j < types.length; j++) { TreeItem tItem = new TreeItem(item, SWT.NONE); tItem.setText(formatName(types[j])); } } item.setExpanded(true); } } if (tree.getItemCount() > 0) tree.setSelection(new TreeItem[] { tree.getItems()[0] }); enable(); }