public TreeSet<String> getImportedTypeNames() { TreeSet<String> typeNames = new TreeSet<>(); for (TypeDescription typeDescription : typeSystemDescription.getTypes()) { typeNames.add(typeDescription.getName()); } return typeNames; }
private boolean fillTypeNameMap(Map<String, String> typeNameMap, TypeSystemDescription desc) { boolean contained = false; for (TypeDescription each : desc.getTypes()) { String name = each.getName(); int lastIndexOf = name.lastIndexOf("."); String shortName = name.substring(lastIndexOf + 1, name.length()); typeNameMap.put(shortName, name); } return contained; }
private List<String> checkOnAmbiguousShortNames(TypeSystemDescription tsDesc) { List<String> checkDuplicateShortNames = new ArrayList<String>(); for (TypeDescription each : tsDesc.getTypes()) { String longName = each.getName(); String shortName = getShortName(longName); Set<String> set = ambiguousTypeAlias.get(shortName); if (set != null && set.size() > 1) { checkDuplicateShortNames.addAll(set); } } return checkDuplicateShortNames; }
private void analyzeTypeSystem(TypeSystemDescription aTSD) throws ResourceInitializationException { // We create a CAS from which we can obtain an instantiated type system. With that, it // is easier to check type inheritance. CAS cas = CasCreationUtils.createCas(aTSD, null, null); TypeSystem ts = cas.getTypeSystem(); for (TypeDescription td : aTSD.getTypes()) { analyzeType(ts, aTSD, td); } log.debug("Recognized {} of {} types as layers ({}%)", getLayers().size(), aTSD.getTypes().length, getLayers().size() * 100 / aTSD.getTypes().length); }
private void analyzeTypeSystem(TypeSystemDescription aTSD) throws ResourceInitializationException { // We create a CAS from which we can obtain an instantiated type system. With that, it // is easier to check type inheritance. CAS cas = CasCreationUtils.createCas(aTSD, null, null); TypeSystem ts = cas.getTypeSystem(); for (TypeDescription td : aTSD.getTypes()) { analyzeType(ts, aTSD, td); } log.debug("Recognized {} of {} types as layers ({}%)", getLayers().size(), aTSD.getTypes().length, getLayers().size() * 100 / aTSD.getTypes().length); }
/** * Removes the type. * * @param td the td * @param tsd the tsd */ private void removeType(TypeDescription td, TypeSystemDescription tsd) { tsd.setTypes((TypeDescription[]) Utility.removeElementFromArray(tsd.getTypes(), td, TypeDescription.class)); }
"color:white; background:mediumpurple;" }; TypeDescription[] types = aTypeSystem.getTypes();
/** * Gets the types requiring this one. * * @param typeName the type name * @return the types requiring this one */ private String[] getTypesRequiringThisOne(String typeName) { List upstreamTypeNames = new ArrayList(); TypeSystemDescription typeSystem = getMergedTypeSystemDescription(); TypeDescription[] types = typeSystem.getTypes(); for (int i = 0; i < types.length; i++) { if (!types[i].getName().equals(typeName)) { if (typeRequiresType(types[i], typeName)) { upstreamTypeNames.add(types[i].getName()); } } } return (String[]) upstreamTypeNames.toArray(new String[upstreamTypeNames.size()]); }
@Override public void enable() { jcasGenButton.setEnabled(tt.getItemCount() > 0); TypeSystemDescription tsd = getTypeSystemDescription(); exportButton.setEnabled(false); if (null != tsd) { TypeDescription[] tsa = tsd.getTypes(); if (null != tsa) exportButton.setEnabled(tsa.length > 0); } if (isAggregate()) { addTypeButton.setEnabled(false); addButton.setEnabled(false); editButton.setEnabled(false); removeButton.setEnabled(false); } else { addTypeButton.setEnabled(true); boolean editable = tt.getSelectionCount() == 1 && isLocalItem(tt.getSelection()[0]); addButton.setEnabled(editable); editButton.setEnabled(editable); removeButton.setEnabled(editable); } }
private Set<String> getTypes(URL resource, ResourceManager resMgr) throws IOException, InvalidXMLException { Set<String> types = new HashSet<String>(); TypeSystemDescription typeSysDescr = null; typeSysDescr = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(resource)); typeSysDescr.resolveImports(resMgr); for (TypeDescription each : typeSysDescr.getTypes()) { String name = each.getName(); String[] nameSpace = name.split("[.]"); types.add(nameSpace[nameSpace.length - 1]); StringBuffer fullName = new StringBuffer(); if (nameSpace.length > 0) { fullName.append(nameSpace[0]); } for (int i = 1; i < nameSpace.length; i++) { // TODO fix workaround if (!nameSpace[i].equals("type")) { fullName.append('.'); fullName.append(nameSpace[i]); } } types.add(fullName.toString()); } return types; }
TypeDescription[] oldTypes = (null == oldTsd || null == oldTsd.getTypes()) ? new TypeDescription[0] : oldTsd.getTypes(); HashMap oldTypeHash = new HashMap(oldTypes.length); TypeDescription[] newTypes = mergedTypeSystemDescription.getTypes(); for (int i = 0; i < newTypes.length; i++) { TypeDescription newType = newTypes[i];
@Override protected void activate(ComponentContext ctx) throws ConfigurationException { super.activate(ctx); Dictionary<String, Object> props = ctx.getProperties(); this.uimaUri = (String) props.get(UIMA_CONTENTPART_URIREF); this.uimaSourceName = (String) props.get(UIMA_SOURCENAME); this.uimaDescriptorPath = (String) props.get(UIMA_DESCRIPTOR_PATH); SUPPORTED_MIMETYPES = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList((String[]) props.get(UIMA_SUPPORTED_MIMETYPES)))); aeProvider = AEProviderFactory.getInstance().getAEProvider(uimaSourceName, uimaDescriptorPath, new HashMap<String, Object>()); try { AnalysisEngine ae = aeProvider.getAE(); TypeDescription[] aeTypes = ae.getAnalysisEngineMetaData().getTypeSystem().getTypes(); uimaTypeNames = new ArrayList<String>(); for (TypeDescription aeType : aeTypes) { String aeTypeName = aeType.getName(); logger.info("Configuring Analysis Engine Type:" + aeTypeName); uimaTypeNames.add(aeTypeName); } } catch (ResourceInitializationException ex) { logger.error("Cannot retrieve AE from AEProvider. ", ex); throw new ConfigurationException(uimaDescriptorPath, "Cannot retreive AE from AEProvider", ex); } }
private void resolveImport(URL aURL, Collection<String> aAlreadyImportedTypeSystemURLs, Collection<TypeDescription> aResults, ResourceManager aResourceManager) throws InvalidXMLException, IOException { //check the import cache TypeSystemDescription 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 TypeSystemDescription) { desc = (TypeSystemDescription)cachedObject; // Add the URLs parsed for this cached object to the list already-parsed (UIMA-5058) aAlreadyImportedTypeSystemURLs.addAll(importUrlsCache.get(urlString)); } else { XMLInputSource input; input = new XMLInputSource(aURL); desc = UIMAFramework.getXMLParser().parseTypeSystemDescription(input); TreeSet<String> previouslyImported = new TreeSet<String>(aAlreadyImportedTypeSystemURLs); desc.resolveImports(aAlreadyImportedTypeSystemURLs, aResourceManager); importCache.put(urlString, desc); // Save the URLS parsed by this import TreeSet<String> locallyImported = new TreeSet<String>(aAlreadyImportedTypeSystemURLs); locallyImported.removeAll(previouslyImported); importUrlsCache.put(urlString, locallyImported); } } aResults.addAll(Arrays.asList(desc.getTypes())); }
for (TypeDescription td : tsd.getTypes()) { String qname = td.getName(); if (packageName == null
/** * Update. */ private void update() { cachedResult.clear(); // for aggregates, this is the fully-merged type system // for all systems, it is the type system with imports resolved TypeSystemDescription typeSystemDescription = modelRoot.getMergedTypeSystemDescription(); if (typeSystemDescription == null) return; // cleared table TypeDescription[] types = typeSystemDescription.getTypes(); TypeSystem typeSystem = modelRoot.descriptorCAS.get().getTypeSystem(); String typeName; Map allTypes = modelRoot.allTypes.get(); for (int i = 0; i < types.length; i++) { cachedResult.add(typeName = types[i].getName()); Type nextType = (Type) allTypes.get(typeName); while (nextType != null) { nextType = typeSystem.getParent(nextType); if (nextType != null) cachedResult.add(nextType.getName()); } } } }
/** * Import all typesystems that are imported in the script. * * @param casTS * Type system containing all known types. * @throws InvalidXMLException * When import cannot be resolved. */ private void importDeclaredTypesystems(TypeSystem casTS) throws InvalidXMLException { String[] descriptors = typesystems.toArray(new String[typesystems.size()]); TypeSystemDescription ts = TypeSystemDescriptionFactory.createTypeSystemDescription(descriptors); ts.resolveImports(getResourceManager()); for (TypeDescription td : ts.getTypes()) { Type type = casTS.getType(td.getName()); if (type != null) { addType(type); } else { throw new RuntimeException("Type '" + td.getName() + "' not found"); } } }
for (TypeDescription each : tsDesc.getTypes()) { String longName = each.getName(); String shortName = getShortName(longName);
@Override public void refresh() { super.refresh(); tt.removeAll(); TypeSystemDescription tsdFull = getMergedTypeSystemDescription(); TypeDescription[] tdsFull = tsdFull.getTypes(); if (null != tdsFull) { for (int i = 0; i < tdsFull.length; i++) { addTypeToGUI(tdsFull[i]); } } if (tt.getItemCount() > 0) tt.setSelection(new TableTreeItem[] { tt.getItems()[0] }); packTable(tt.getTable()); enable(); }
final TypeDescription[] types = mergedTypeSystemDescription.getTypes(); final String outputDirectory = getPrimarySourceFolder().getLocation().toOSString(); final String inputFile = file.getLocation().toOSString(); // path to descriptor file
nextType: for (TypeDescription tdesc : aTargetTypeSystem.getTypes()) { Type t = ts.getType(tdesc.getName());