private String serializeTypeSystem(CAS aCas) throws RecommendationException { try (StringWriter out = new StringWriter()) { TypeSystemUtil.typeSystem2TypeSystemDescription(aCas.getTypeSystem()).toXML(out); return out.toString(); } catch (CASRuntimeException | SAXException | IOException e) { throw new RecommendationException("Coud not serialize type system", e); } }
private String serializeTypeSystem(CAS aCas) throws RecommendationException { try (StringWriter out = new StringWriter()) { TypeSystemUtil.typeSystem2TypeSystemDescription(aCas.getTypeSystem()).toXML(out); return out.toString(); } catch (CASRuntimeException | SAXException | IOException e) { throw new RecommendationException("Coud not serialize type system", e); } }
/** * Writes "typesystem.xml" to the output tar.gz * * @param aJCas any jcas from the collection to get the currently active typesystem * @throws IOException IO Exception */ private void writeTypeSystem(JCas aJCas) throws IOException { try { String name = "typesystem.xml"; java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream(); TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(stream); // add to tar addSingleEntryToTar(stream.toByteArray(), name); } catch (SAXException e) { throw new IOException(e); } }
public HashMap<String, String> genTypeDescriptorNClasses(String customTypeDescXml, String srcPath, boolean classOnly) { if (!customTypeDescXml.toLowerCase().endsWith(".xml")) customTypeDescXml += ".xml"; if (!classOnly) try { typeSystemDescription.toXML(new FileWriter(customTypeDescXml)); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } HashMap<String, String> classes; if (srcPath == null) classes = new JcasGen().main(customTypeDescXml, customTypes); else classes = new JcasGen().main(customTypeDescXml, customTypes, srcPath); return classes; }
/** * {@inheritDoc} <p>Writes the type system to the path if it hasn't already been written. Uses the * semaphore with 1 permit {@code writeOnce}.</p> */ public void writeToPath(Path path) throws BiomedicusException { if (writeOnce.tryAcquire()) { try (BufferedWriter bufferedWriter = Files.newBufferedWriter(path)) { TypeSystemDescription description = getCasManager().getCasDefinition().getTypeSystemDescription(); description.toXML(bufferedWriter); } catch (IOException | ResourceInitializationException | SAXException e) { throw new BiomedicusException(e); } } } }
typeSystemDesciptor.toXML(typeSystemBytes);
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private IResourceStream exportUimaTypeSystem() { try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { TypeSystemDescription tsd = annotationService .getProjectTypes(getModelObject().getProject()); tsd.toXML(bos); return new InputStreamResourceStream(new ByteArrayInputStream(bos.toByteArray())); } catch (Exception e) { error("Unable to generate the UIMA type system file: " + ExceptionUtils.getRootCauseMessage(e)); ProjectLayersPanel.LOG.error("Unable to generate the UIMA type system file", e); RequestCycle.get().find(IPartialPageRequestHandler.class) .ifPresent(handler -> handler.addChildren(getPage(), IFeedback.class)); return null; } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private IResourceStream exportUimaTypeSystem() { try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { TypeSystemDescription tsd = annotationService .getProjectTypes(getModelObject().getProject()); tsd.toXML(bos); return new InputStreamResourceStream(new ByteArrayInputStream(bos.toByteArray())); } catch (Exception e) { error("Unable to generate the UIMA type system file: " + ExceptionUtils.getRootCauseMessage(e)); ProjectLayersPanel.LOG.error("Unable to generate the UIMA type system file", e); RequestCycle.get().find(IPartialPageRequestHandler.class) .ifPresent(handler -> handler.addChildren(getPage(), IFeedback.class)); return null; } }
File tsd2xml = new File(((String)casLogDirMap.get(analysisEngineKey))+"/typesystem.xml"); FileOutputStream os = new FileOutputStream(tsd2xml); tsd.toXML(os); os.close(); enableCasLogMap.put(analysisEngineKey, true);
typeSystemDesciptor.toXML(typeSystemBytes);
typeSystemFile.getParentFile().mkdirs(); typeSystemOs = new FileOutputStream(typeSystemFile); typeSystem.toXML(typeSystemOs); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e.getCause());
tsDesc.toXML(aContentHandler); aContentHandler.endDocument();