private static PsiValidatorReport writeFile(Document doc, File xmlFile, boolean validate) throws IOException { // create the parent dir if it does not exist if (!xmlFile.getParentFile().exists()) { log.info("Creating dir: "+xmlFile.getParentFile()); xmlFile.getParentFile().mkdirs(); } Writer writer = new FileWriter(xmlFile); DisplayXML.write(doc, writer, " "); writer.close(); if (validate) { return PsiValidator.validate(xmlFile); } return new PsiValidatorReport(); }
@Override public void error( SAXParseException e ) throws SAXException { log.error(e.getMessage()); report.setValid(false); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.ERROR, e); report.addMessage(msg); }
String schemaFeature = "http://apache.org/xml/features/validation/schema"; PsiValidatorReportHandler handler = new PsiValidatorReportHandler(new PsiValidatorReport()); log.debug( "Validation completed. Document is valid: "+handler.getReport().isValid() );
@Override public void warning( SAXParseException e ) throws SAXException { log.warn(e.getMessage()); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.WARN, e); report.addMessage(msg); }
String schemaFeature = "http://apache.org/xml/features/validation/schema"; PsiValidatorReportHandler handler = new PsiValidatorReportHandler(new PsiValidatorReport()); log.debug( "Validation completed. Document is valid: "+handler.getReport().isValid() );
@Override public void warning( SAXParseException e ) throws SAXException { log.warn(e.getMessage()); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.WARN, e); report.addMessage(msg); }
@Override public void error( SAXParseException e ) throws SAXException { log.error(e.getMessage()); report.setValid(false); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.ERROR, e); report.addMessage(msg); }
String schemaFeature = "http://apache.org/xml/features/validation/schema"; PsiValidatorReportHandler handler = new PsiValidatorReportHandler(new PsiValidatorReport()); log.debug( "Validation completed. Document is valid: "+handler.getReport().isValid() );
private static PsiValidatorReport writeFile(Document doc, File xmlFile, boolean validate) throws IOException { // create the parent dir if it does not exist if (!xmlFile.getParentFile().exists()) { log.info("Creating dir: "+xmlFile.getParentFile()); xmlFile.getParentFile().mkdirs(); } Writer writer = new FileWriter(xmlFile); DisplayXML.write(doc, writer, " "); writer.close(); if (validate) { return PsiValidator.validate(xmlFile); } return new PsiValidatorReport(); }
@Override public void warning( SAXParseException e ) throws SAXException { log.warn(e.getMessage()); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.WARN, e); report.addMessage(msg); }
@Override public void error( SAXParseException e ) throws SAXException { log.error(e.getMessage()); report.setValid(false); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.ERROR, e); report.addMessage(msg); }
private static PsiValidatorReport writeFile(Document doc, File xmlFile, boolean validate) throws IOException { // create the parent dir if it does not exist if (!xmlFile.getParentFile().exists()) { log.info("Creating dir: "+xmlFile.getParentFile()); xmlFile.getParentFile().mkdirs(); } Writer writer = new FileWriter(xmlFile); DisplayXML.write(doc, writer, " "); writer.close(); if (validate) { return PsiValidator.validate(xmlFile); } return new PsiValidatorReport(); }
@Override public void fatalError( SAXParseException e ) throws SAXException { log.error(e.getMessage()); report.setValid(false); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.FATAL, e); report.addMessage(msg); }
/** * Writes a file containing the PSI XML, for the information contained in the ExperimentListItem * * @param eli The ExperimentListItem, which contaisn information about the experiment to be fetched, the pagination and files * @param psiVersion The version of PSI to use * @param cvMapping The cv mapping * @param baseDir The base dir where to put the files * @param validate whether to validate the xml * @throws IOException thrown if there is some problem writing to the file * @return a psiValidatorReport */ public static PsiValidatorReport writePsiData(ExperimentListItem eli, PsiVersion psiVersion, CvMapping cvMapping, File baseDir, boolean validate) throws IOException { File xmlFile = new File(baseDir, eli.getFilename()); Document doc = generatePsiData(eli,psiVersion,cvMapping); if (doc == null) { return new PsiValidatorReport(); } return writeFile(doc, xmlFile, validate); }
@Override public void fatalError( SAXParseException e ) throws SAXException { log.error(e.getMessage()); report.setValid(false); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.FATAL, e); report.addMessage(msg); }
/** * Writes a file containing the PSI XML, for the information contained in the ExperimentListItem * * @param eli The ExperimentListItem, which contaisn information about the experiment to be fetched, the pagination and files * @param psiVersion The version of PSI to use * @param cvMapping The cv mapping * @param baseDir The base dir where to put the files * @param validate whether to validate the xml * @throws IOException thrown if there is some problem writing to the file * @return a psiValidatorReport */ public static PsiValidatorReport writePsiData(ExperimentListItem eli, PsiVersion psiVersion, CvMapping cvMapping, File baseDir, boolean validate) throws IOException { File xmlFile = new File(baseDir, eli.getFilename()); Document doc = generatePsiData(eli,psiVersion,cvMapping); if (doc == null) { return new PsiValidatorReport(); } return writeFile(doc, xmlFile, validate); }
@Override public void fatalError( SAXParseException e ) throws SAXException { log.error(e.getMessage()); report.setValid(false); PsiValidatorMessage msg = new PsiValidatorMessage(PsiValidatorMessage.Level.FATAL, e); report.addMessage(msg); }
/** * Writes a file containing the PSI XML, for the information contained in the ExperimentListItem * * @param eli The ExperimentListItem, which contaisn information about the experiment to be fetched, the pagination and files * @param psiVersion The version of PSI to use * @param cvMapping The cv mapping * @param baseDir The base dir where to put the files * @param validate whether to validate the xml * @throws IOException thrown if there is some problem writing to the file * @return a psiValidatorReport */ public static PsiValidatorReport writePsiData(ExperimentListItem eli, PsiVersion psiVersion, CvMapping cvMapping, File baseDir, boolean validate) throws IOException { File xmlFile = new File(baseDir, eli.getFilename()); Document doc = generatePsiData(eli,psiVersion,cvMapping); if (doc == null) { return new PsiValidatorReport(); } return writeFile(doc, xmlFile, validate); }
/** * Writes a file containing the PSI XML, with the interactions provided * * @param interactions * @param psiVersion * @param cvMapping * @param xmlTargetFile * @param validate * @return * @throws IOException */ public static PsiValidatorReport writePsiData(Collection<Interaction> interactions, PsiVersion psiVersion, CvMapping cvMapping, File xmlTargetFile, boolean validate) throws IOException { UserSessionDownload session = new UserSessionDownload(psiVersion); if (cvMapping != null) { session.setReverseCvMapping(cvMapping); } Document doc = generatePsiData(interactions, session); if (doc == null) { return new PsiValidatorReport(); } return writeFile(doc, xmlTargetFile, validate); }
/** * Writes a file containing the PSI XML, with the interactions provided * * @param interactions * @param psiVersion * @param cvMapping * @param xmlTargetFile * @param validate * @return * @throws IOException */ public static PsiValidatorReport writePsiData(Collection<Interaction> interactions, PsiVersion psiVersion, CvMapping cvMapping, File xmlTargetFile, boolean validate) throws IOException { UserSessionDownload session = new UserSessionDownload(psiVersion); if (cvMapping != null) { session.setReverseCvMapping(cvMapping); } Document doc = generatePsiData(interactions, session); if (doc == null) { return new PsiValidatorReport(); } return writeFile(doc, xmlTargetFile, validate); }