modified generated xml according to new mapping
This commit is contained in:
parent
c5945c386b
commit
a6b5a80984
|
@ -35,13 +35,11 @@ public class FileJSONCollectorPlugin extends FileCollectorPlugin {
|
|||
public Iterable<String> 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<Entry<String, JsonElement>> keys = aatInfoJsonObj.entrySet();
|
||||
for(Map.Entry<String,JsonElement> 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);
|
||||
|
|
Loading…
Reference in New Issue