| 2838 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.ui.util;
|
|
|
5 |
|
| 22640 |
amit.gupta |
6 |
import in.shop2020.metamodel.core.Entity;
|
|
|
7 |
import in.shop2020.metamodel.core.Media;
|
|
|
8 |
import in.shop2020.metamodel.core.Slide;
|
| 2838 |
mandeep.dh |
9 |
import in.shop2020.metamodel.core.SpecialPage;
|
|
|
10 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 22640 |
amit.gupta |
11 |
import in.shop2020.metamodel.util.MediaPojo;
|
| 2838 |
mandeep.dh |
12 |
|
|
|
13 |
import java.io.BufferedWriter;
|
|
|
14 |
import java.io.File;
|
|
|
15 |
import java.io.FileWriter;
|
|
|
16 |
import java.io.IOException;
|
| 22640 |
amit.gupta |
17 |
import java.text.MessageFormat;
|
|
|
18 |
import java.util.Arrays;
|
|
|
19 |
import java.util.Collection;
|
|
|
20 |
import java.util.List;
|
| 2838 |
mandeep.dh |
21 |
import java.util.Map;
|
|
|
22 |
|
|
|
23 |
import org.apache.commons.logging.Log;
|
|
|
24 |
import org.apache.commons.logging.LogFactory;
|
|
|
25 |
import org.json.JSONException;
|
|
|
26 |
|
|
|
27 |
import com.google.gson.Gson;
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* @author mandeep
|
|
|
31 |
*
|
|
|
32 |
*/
|
|
|
33 |
public class SpecialPageJSONConvertor {
|
|
|
34 |
private static Log LOG = LogFactory.getLog(SpecialPageJSONConvertor.class);
|
|
|
35 |
|
|
|
36 |
public void writeToJSONFile(File file) throws JSONException, IOException {
|
| 2839 |
mandeep.dh |
37 |
Map<Long, SpecialPage> specialPages = CreationUtils.getSpecialPages();
|
|
|
38 |
if (specialPages == null) {
|
|
|
39 |
return;
|
|
|
40 |
}
|
|
|
41 |
|
| 2838 |
mandeep.dh |
42 |
FileWriter fileWriter = new FileWriter(file);
|
|
|
43 |
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
| 2839 |
mandeep.dh |
44 |
for (SpecialPage specialPage : specialPages.values()) {
|
|
|
45 |
LOG.info("Writing specialPage: " + specialPage);
|
|
|
46 |
bufferedWriter.write(new Gson().toJson(specialPage));
|
| 2838 |
mandeep.dh |
47 |
bufferedWriter.newLine();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
bufferedWriter.close();
|
|
|
51 |
fileWriter.close();
|
|
|
52 |
}
|
|
|
53 |
|
| 22640 |
amit.gupta |
54 |
public static void main(String[] args) throws Exception {
|
|
|
55 |
List<Long> entityIds = Arrays.asList();
|
|
|
56 |
for (Long entityId : entityIds) {
|
|
|
57 |
Entity e = CreationUtils.getEntity(entityId);
|
|
|
58 |
List<Slide> slides = e.getSlides();
|
|
|
59 |
if (slides != null) {
|
|
|
60 |
for (Slide slide: slides){
|
|
|
61 |
if(slide.getFreeformContent() !=null && slide.getFreeformContent().getMedias() !=null){
|
|
|
62 |
LOG.info("Slide ID - for media:" + slide.getSlideDefinitionID());
|
|
|
63 |
Collection<Media> medias = slide.getFreeformContent().getMedias().values();
|
|
|
64 |
for (Media media : medias){
|
|
|
65 |
LOG.info("Media label -- " + media.getLabel());
|
|
|
66 |
LOG.info("Media file name -- " + media.getFileName());
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
}
|
| 2838 |
mandeep.dh |
73 |
}
|
|
|
74 |
}
|