use of org.edamontology.edammap.core.input.xml.Biotools14 in project edammap by edamontology.
the class Xml method load.
public static List<InputType> load(String queryPath, QueryType type, int timeout, String userAgent) throws IOException, ParseException {
List<InputType> inputs = new ArrayList<>();
if (type == QueryType.biotools14) {
XMLStreamReader reader = null;
try (InputStream is = Input.newInputStream(queryPath, true, timeout, userAgent)) {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty("javax.xml.stream.isCoalescing", true);
reader = factory.createXMLStreamReader(is, StandardCharsets.UTF_8.name());
Biotools14 biotools = null;
String text = null;
while (reader.hasNext()) {
switch(reader.next()) {
case XMLStreamConstants.START_ELEMENT:
String uri = reader.getAttributeValue(null, "uri");
switch(reader.getLocalName()) {
case "resource":
biotools = new Biotools14();
break;
case "topic":
if (uri != null)
biotools.addTopic(uri);
break;
case "functionName":
if (uri != null)
biotools.addFunctionName(uri);
break;
case "dataType":
if (uri != null)
biotools.addDataType(uri);
break;
case "dataFormat":
if (uri != null)
biotools.addDataFormat(uri);
break;
}
text = null;
break;
case XMLStreamConstants.CHARACTERS:
text = reader.getText();
break;
case XMLStreamConstants.END_ELEMENT:
switch(reader.getLocalName()) {
case "resource":
inputs.add(biotools);
biotools = null;
break;
case "name":
if (biotools.getName() == null)
biotools.setName(text);
break;
case "homepage":
if (biotools.getHomepage() == null)
biotools.setHomepage(text);
break;
case "mirror":
biotools.addMirror(text);
break;
case "description":
if (biotools.getDescription() == null)
biotools.setDescription(text);
break;
case "docsHome":
if (biotools.getDocsHome() == null)
biotools.setDocsHome(text);
break;
case "docsGithub":
if (biotools.getDocsGithub() == null)
biotools.setDocsGithub(text);
break;
case "publicationsPrimaryID":
if (biotools.getPublicationsPrimaryID() == null)
biotools.setPublicationsPrimaryID(text);
break;
case "publicationsOtherID":
biotools.addPublicationsOtherID(text);
break;
}
break;
}
}
} catch (XMLStreamException e) {
throw new ParseException(e.getLocalizedMessage(), e.getLocation().getLineNumber());
} finally {
if (reader != null) {
try {
reader.close();
} catch (XMLStreamException e) {
throw new ParseException(e.getLocalizedMessage(), e.getLocation().getLineNumber());
}
}
}
}
int i = 0;
for (InputType inputType : inputs) {
inputType.check(++i);
}
return inputs;
}
use of org.edamontology.edammap.core.input.xml.Biotools14 in project edammap by edamontology.
the class QueryLoader method get.
public static List<Query> get(String queryPath, QueryType type, Map<EdamUri, Concept> concepts, int timeout, String userAgent) throws IOException, ParseException {
if (type == QueryType.server) {
throw new IllegalArgumentException("Query of type \"" + QueryType.server.name() + "\" is not loadable from path, but has to be provided");
}
List<? extends InputType> inputs;
if (type == QueryType.biotools) {
inputs = Json.load(queryPath, type, timeout, userAgent);
} else if (type == QueryType.biotools14) {
inputs = Xml.load(queryPath, type, timeout, userAgent);
} else {
inputs = Csv.load(queryPath, type, timeout, userAgent);
}
Set<Query> queries = new LinkedHashSet<>();
for (InputType input : inputs) {
switch(type) {
case generic:
queries.add(getGeneric((Generic) input, concepts));
break;
case SEQwiki:
queries.add(getSEQwiki((SEQwiki) input, concepts));
break;
case msutils:
queries.add(getMsutils((Msutils) input, concepts));
break;
case Bioconductor:
queries.add(getBioconductor((Bioconductor) input, concepts));
break;
case biotools14:
queries.add(getBiotools14((Biotools14) input, concepts));
break;
case biotools:
queries.add(getBiotools((ToolInput) input, concepts));
break;
case server:
break;
}
}
return new ArrayList<>(queries);
}
Aggregations