From f2255749c348d7c6010436e1b18b4c2681d09e5f Mon Sep 17 00:00:00 2001 From: Egon Willighagen Date: Sun, 3 Jul 2016 17:17:25 +0200 Subject: [PATCH] Create the resource IRIs only once (a bit more efficient) --- .../wp2rdf/converter/DataNodeConverter.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/WP2RDF/src/main/java/org/wikipathways/wp2rdf/converter/DataNodeConverter.java b/WP2RDF/src/main/java/org/wikipathways/wp2rdf/converter/DataNodeConverter.java index 78f15e1..af65675 100644 --- a/WP2RDF/src/main/java/org/wikipathways/wp2rdf/converter/DataNodeConverter.java +++ b/WP2RDF/src/main/java/org/wikipathways/wp2rdf/converter/DataNodeConverter.java @@ -83,16 +83,19 @@ public static void parseDataNodeWp(PathwayElement elem, Model model, DataHandler Resource datanodeRes = data.getDataNodes().get(elem.getXref()); if(datanodeRes == null) { if (url.contains("chebi/CHEBI:")){ - datanodeRes = model.createResource(url.trim().replaceAll(" ", "_")); - datanodeRes.addProperty(DC.identifier, model.createResource(url.trim().replaceAll(" ", "_"))); + String resourceURL = url.trim().replaceAll(" ", "_"); + datanodeRes = model.createResource(resourceURL); + datanodeRes.addProperty(DC.identifier, model.createResource(resourceURL)); } else if (url.contains("chebi")){ - datanodeRes = model.createResource(url.trim().replaceAll(" ", "_").replace("chebi/","chebi/CHEBI:")); - datanodeRes.addProperty(DC.identifier, model.createResource(url.trim().replaceAll(" ", "_").replace("chebi/","chebi/CHEBI:"))); + String resourceURL = url.trim().replaceAll(" ", "_").replace("chebi/","chebi/CHEBI:"); + datanodeRes = model.createResource(resourceURL); + datanodeRes.addProperty(DC.identifier, model.createResource(resourceURL)); } else{ - datanodeRes = model.createResource(url.trim().replaceAll(" ", "_")); - datanodeRes.addProperty(DC.identifier, model.createResource(url.trim().replaceAll(" ", "_"))); + String resourceURL = url.trim().replaceAll(" ", "_"); + datanodeRes = model.createResource(resourceURL); + datanodeRes.addProperty(DC.identifier, model.createResource(resourceURL)); } datanodeRes.addLiteral(DC.source, elem.getXref().getDataSource().getFullName());