From a6b5a80984f28387f3cdd385a95aabd0f76ef1f9 Mon Sep 17 00:00:00 2001 From: Enrico Ottonello Date: Fri, 14 Feb 2020 16:56:34 +0100 Subject: [PATCH] modified generated xml according to new mapping --- .../ads/FileJSONCollectorPlugin.java | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/dnet-ariadneplus/src/main/java/eu/dnetlib/data/collector/plugins/ariadneplus/ads/FileJSONCollectorPlugin.java b/dnet-ariadneplus/src/main/java/eu/dnetlib/data/collector/plugins/ariadneplus/ads/FileJSONCollectorPlugin.java index a7b93e1..3e4adaf 100644 --- a/dnet-ariadneplus/src/main/java/eu/dnetlib/data/collector/plugins/ariadneplus/ads/FileJSONCollectorPlugin.java +++ b/dnet-ariadneplus/src/main/java/eu/dnetlib/data/collector/plugins/ariadneplus/ads/FileJSONCollectorPlugin.java @@ -35,13 +35,11 @@ public class FileJSONCollectorPlugin extends FileCollectorPlugin { public Iterable collect(final InterfaceDescriptor interfaceDescriptor, final String fromDate, final String untilDate) throws CollectorServiceException { log.info("FileJSONCollectorPlugin"); - System.out.println("FileJSONCollectorPlugin"); final String identifierFieldKey = interfaceDescriptor.getParams().get("identifierFieldKey"); URL u = null; try { u = new URL(interfaceDescriptor.getBaseUrl()); - System.out.println(u.toString()); } catch (MalformedURLException e1) { e1.printStackTrace(); throw new CollectorServiceException(e1); @@ -75,10 +73,8 @@ public class FileJSONCollectorPlugin extends FileCollectorPlugin { public FileJSONIterator(final FileReader fileReader, final String identifierFieldKey) { this.identifierFieldKey = identifierFieldKey; jsonReader = new JsonReader(fileReader); - System.out.println("parsing ..."); JsonElement jsonElement = new JsonParser().parse(jsonReader); JsonArray jsonArrays = jsonElement.getAsJsonArray(); - System.out.println("size: "+ jsonArrays.size()); aatInfosIterator = jsonArrays.iterator(); next = calculateNext(); } @@ -97,25 +93,19 @@ public class FileJSONCollectorPlugin extends FileCollectorPlugin { private String calculateNext() { try { - System.out.println("calculateNext()"); Document document = DocumentHelper.createDocument(); - Element root = document.addElement("jsonRecord"); + Element root = document.addElement("Entry"); if (!aatInfosIterator.hasNext()) { - System.out.println("son entries finished"); log.info("json entries finished, closing RESULT SET"); jsonReader.close(); return null; } - System.out.println("parsing next entry"); JsonElement aatInfos = aatInfosIterator.next(); JsonObject aatInfoJsonObj = aatInfos.getAsJsonObject(); Set> keys = aatInfoJsonObj.entrySet(); for(Map.Entry entry : keys) { String key = entry.getKey(); -// if (key.equals("updated")) { -// continue; -// } JsonElement jsonElement = aatInfoJsonObj.get(key); if (jsonElement.isJsonNull()) { continue; @@ -124,21 +114,10 @@ public class FileJSONCollectorPlugin extends FileCollectorPlugin { if (StringUtils.isEmpty(value)) { continue; } - System.out.println("key: "+key+" value: "+value); - Element element = root.addElement("Entry"); String name = new String(key); - if (name.equals("sourceURI")) { - name = new String("Source_ID"); - } else if (name.equals("targetURI")) { - name = new String("Target_URI"); - } + Element element = root.addElement(name); value = StringEscapeUtils.escapeXml11(value.replace('\r',' ').replace('\t',' ')); - if (name.equals(identifierFieldKey)) { - element.addAttribute("isID", "true"); - element.addAttribute("name", name).addText(value); - } else { - element.addAttribute("name", name).addText(value); - } + element.addText(value); } String xmlRecord = new String(document.asXML()); log.debug(xmlRecord);