Commit e6165c95 authored by Maxime Lefrançois's avatar Maxime Lefrançois

trace IOException

parent 68cc26cc
package fr.emse.gitlab.saref.entities.utils;
public class SAREFProjectUtils {
}
package fr.emse.gitlab.saref.jobsold;
///*
// * Copyright 2020 ETSI
// *
// * Redistribution and use in source and binary forms, with or without
// * modification, are permitted provided that the following conditions are met:
// * 1. Redistributions of source code must retain the above copyright notice,
// * this list of conditions and the following disclaimer.
// * 2. Redistributions in binary form must reproduce the above copyright notice,
// * this list of conditions and the following disclaimer in the documentation
// * and/or other materials provided with the distribution.
// * 3. Neither the name of the copyright holder nor the names of its contributors
// * may be used to endorse or promote products derived from this software without
// * specific prior written permission.
// *
// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// * OF THE POSSIBILITY OF SUCH DAMAGE.
// */
//package fr.emse.gitlab.saref.jobs;
//
//import org.apache.jena.query.Dataset;
//import org.apache.jena.query.QueryExecution;
//import org.apache.jena.query.QueryExecutionFactory;
//import org.apache.jena.query.QuerySolution;
//import org.apache.jena.query.ReadWrite;
//import org.apache.jena.query.ResultSet;
//import org.apache.jena.rdf.model.Model;
//import org.apache.jena.rdf.model.Resource;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import fr.emse.gitlab.saref.REGEX;
//
///**
//*
//* @author Maxime Lefrançois
//*
//*/
//public class CheckConfig {
//
// static final String FIND_USED_UNDEFINED = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\n" +
// "PREFIX rdfp: <https://w3id.org/rdfp/>\r\n" +
// "PREFIX ex: <http://example.org/>\r\n" +
// "\r\n" +
// "SELECT ?term (SAMPLE(?v) AS ?version) WHERE {\r\n" +
// " ?term a rdfp:Resource ;\r\n" +
// " ex:isUsedBy ?v .\r\n" +
// " FILTER NOT EXISTS {\r\n" +
// " ?term rdfs:isDefinedBy ?ontology .\r\n" +
// " }\r\n" +
// "} GROUP BY ?term \n"
// + "ORDER BY ?term";
//
// static final String FIND_EXAMPLIFIED_UNDEFINED = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\n" +
// "PREFIX rdfp: <https://w3id.org/rdfp/>\r\n" +
// "PREFIX ex: <http://example.org/>\r\n" +
// "\r\n" +
// "SELECT ?term (SAMPLE(?e) AS ?example) WHERE {\r\n" +
// " ?term a rdfp:Resource ;\r\n" +
// " ex:hasExample ?e .\r\n" +
// " FILTER NOT EXISTS {\r\n" +
// " ?term rdfs:isDefinedBy ?ontology .\r\n" +
// " }\r\n" +
// "} GROUP BY ?term \n"
// + "ORDER BY ?term";
//
// static final String FIND_DEFINED_UNEXAMPLIFIED = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\n" +
// "PREFIX rdfp: <https://w3id.org/rdfp/>\r\n" +
// "PREFIX ex: <http://example.org/>\r\n" +
// "\r\n" +
// "SELECT ?term (SAMPLE(?o) AS ?ontology) WHERE {\r\n" +
// " ?term a rdfp:Resource ;\r\n" +
// " rdfs:isDefinedBy ?o .\r\n" +
// " FILTER NOT EXISTS {\r\n" +
// " ?term ex:hasExample ?e .\r\n" +
// " }\r\n" +
// "} GROUP BY ?term \n"
// + "ORDER BY ?term";
//
// public void doJob(Dataset dataset, boolean ignoreExamples) {
// dataset.begin(ReadWrite.READ);
// Model config = dataset.getNamedModel(REGEX.CONFIG);
//
// // check which terms are used but not defined
// Logger logger = LoggerFactory.getLogger(REGEX.LOGGER_BASE + "." + "Terms that are used but never defined");
// try (QueryExecution exec = QueryExecutionFactory.create(FIND_USED_UNDEFINED, config);) {
// for (ResultSet resultSet = exec.execSelect(); resultSet.hasNext();) {
// QuerySolution sol = resultSet.next();
// Resource term = sol.getResource("term");
// Resource version = sol.getResource("version");
// logger.warn(String.format("Term %s is never defined, but is used in version %s", term, version));
// }
// }
//
// if(!ignoreExamples) {
//
// // check which terms are exemplified but not defined
// logger = LoggerFactory.getLogger(REGEX.LOGGER_BASE + "." + "Terms that have examples, but never defined");
// try (QueryExecution exec = QueryExecutionFactory.create(FIND_EXAMPLIFIED_UNDEFINED, config);) {
// for (ResultSet resultSet = exec.execSelect(); resultSet.hasNext();) {
// QuerySolution sol = resultSet.next();
// Resource term = sol.getResource("term");
// Resource example = sol.getResource("example");
// logger.warn(String.format("Term %s is never defined, but is used in example %s", term, example));
// }
// }
//
// // check which terms are defined but not exemplified
// logger = LoggerFactory.getLogger(REGEX.LOGGER_BASE + "." + "Terms that are defined, but have no example");
// try (QueryExecution exec = QueryExecutionFactory.create(FIND_DEFINED_UNEXAMPLIFIED, config);) {
// for (ResultSet resultSet = exec.execSelect(); resultSet.hasNext();) {
// QuerySolution sol = resultSet.next();
// Resource term = sol.getResource("term");
// Resource ontology = sol.getResource("ontology");
// logger.warn(String.format("Term %s is defined in %s, but there is no example that uses it.", term, ontology));
// }
// }
// }
//
//
// dataset.end();
// }
//}
......@@ -138,13 +138,10 @@ public class RepositoryFactory extends SAREFErrorLogger {
errorLogger.warn(msg);
throw new SAREFPipelineException(msg);
}
SAREFVersionName vn = guessVersion(project, directory);
if (isTarget && vn == null) {
originalVersionName = guessVersion(project, directory);
if (isTarget && originalVersionName.equals(SAREFVersionName.DEFAULT)) {
final String msg = getMessage(MESSAGE.develop_branch, originalBranch);
errorLogger.warn(msg);
originalVersionName = SAREFVersionName.DEFAULT;
} else {
originalVersionName = vn;
}
} else {
int major = Integer.parseInt(m.group(SAREF.REGEX_VERSION_MAJOR_VAR));
......@@ -162,11 +159,17 @@ public class RepositoryFactory extends SAREFErrorLogger {
readVersions(git, repository);
return repository;
} catch (IOException ex) {
LOG.trace("IOException " + ex, ex);
if (pipeline.mode == Mode.RELEASE) {
throw new SAREFPipelineException(getMessage(MESSAGE.release_git), ex);
}
return new SAREFRepository(directory, project, false, SAREFVersionName.DEFAULT, null);
final SAREFVersionName versionName = guessVersion(project, directory);
final SAREFRepository repository = new SAREFRepository(directory, project, false, versionName, null);
SAREFVersion version = new SAREFVersion(repository, versionName, null, null, null);
repository.getVersions().put(versionName, version);
return repository;
} catch (GitAPIException ex) {
LOG.trace("GitAPIException " + ex, ex);
throw new SAREFPipelineException("Unexpected Git APIException", ex);
}
}
......@@ -178,9 +181,13 @@ public class RepositoryFactory extends SAREFErrorLogger {
SAREFNamedGraph namedGraph = new SAREFNamedGraph("null");
SAREF.loadModel(namedGraph, ontologyFile, errorLogger);
String uri = namedGraph.getModel().listObjectsOfProperty(OWL2.versionIRI).next().asResource().getURI();
return SAREF.extractVersionName(uri);
SAREFVersionName versionName = SAREF.extractVersionName(uri);
if(versionName == null) {
return SAREFVersionName.DEFAULT;
}
return versionName;
} catch (Exception ex) {
return null;
return SAREFVersionName.DEFAULT;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment