Subversion Repositories SmartDukaan

Rev

Rev 2839 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2838 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.ui.util;
5
 
6
import in.shop2020.metamodel.core.SpecialPage;
7
import in.shop2020.metamodel.util.CreationUtils;
8
 
9
import java.io.BufferedWriter;
10
import java.io.File;
11
import java.io.FileWriter;
12
import java.io.IOException;
13
import java.util.Map;
14
 
15
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
17
import org.json.JSONException;
18
import org.json.JSONObject;
19
 
20
import com.google.gson.Gson;
21
 
22
/**
23
 * @author mandeep
24
 *
25
 */
26
public class SpecialPageJSONConvertor {
27
    private static Log LOG = LogFactory.getLog(SpecialPageJSONConvertor.class);
28
 
29
    public void writeToJSONFile(File file) throws JSONException, IOException {
30
        Map<Long, SpecialPage> brands = CreationUtils.getSpecialPages();
31
        FileWriter fileWriter = new FileWriter(file);
32
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
33
        for (SpecialPage brand : brands.values()) {
34
            bufferedWriter.write(new Gson().toJson(brand));
35
            bufferedWriter.newLine();
36
        }
37
 
38
        bufferedWriter.close();
39
        fileWriter.close();
40
    }
41
 
42
    public static void main(String[] args) throws JSONException, IOException {
43
        SpecialPageJSONConvertor bjc = new SpecialPageJSONConvertor();
44
        bjc.writeToJSONFile(new File("/home/mandeep/brands.json"));
45
    }
46
}