edu.ucsd.ccdb.cil.xml2json.XML2JsonDriver.java Source code

Java tutorial

Introduction

Here is the source code for edu.ucsd.ccdb.cil.xml2json.XML2JsonDriver.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.ucsd.ccdb.cil.xml2json;

import java.io.*;
import java.net.*;
import org.json.*;
import java.util.*;
import edu.ucsd.ccdb.cil.xml2json.database.*;

/**
 *
 * @author ncmir
 */
public class XML2JsonDriver {

    public static void main(String[] args) throws Exception {
        boolean debug = false;
        long debugID = 29;
        XML2JsonUtil xutil = new XML2JsonUtil();
        CCDBXMLResource xmlResource = new CCDBXMLResource();
        HashMap<String, String> xmlMap = xmlResource.getXMLPaths();
        DBUtil dbutil = new DBUtil();
        Vector<Long> vIDs = dbutil.getCCDBPublicIDs();

        for (int i = 0; i < vIDs.size(); i++) {

            long id = vIDs.get(i);
            if (!debug) {
                System.out.println("-----Working on:" + id);
                String path = xmlMap.get(id + "");
                //System.out.println(path);
                String xml = xmlResource.getXMLContent(new File(path));
                String json = xutil.xml2Json(xml);
                File f = new File(Constants.jsonOutputFolder2 + "/" + id + ".json");
                xutil.outputStringToFile(f, json);
            } else if (debugID == id) {
                System.out.println("-----Working on:" + id);
                String path = xmlMap.get(id + "");
                //System.out.println(path);
                String xml = xmlResource.getXMLContent(new File(path));
                String json = xutil.xml2Json(xml);
                File f = new File(Constants.jsonOutputFolder2 + "/" + id + ".json");
                xutil.outputStringToFile(f, json);
            }
        }

    }

}