| 2838 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.ui.util;
|
|
|
5 |
|
| 22640 |
amit.gupta |
6 |
import in.shop2020.metamodel.core.Entity;
|
| 22649 |
amit.gupta |
7 |
import in.shop2020.metamodel.core.EntityState;
|
| 22640 |
amit.gupta |
8 |
import in.shop2020.metamodel.core.Media;
|
|
|
9 |
import in.shop2020.metamodel.core.Slide;
|
| 2838 |
mandeep.dh |
10 |
import in.shop2020.metamodel.core.SpecialPage;
|
| 22647 |
amit.gupta |
11 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 2838 |
mandeep.dh |
12 |
import in.shop2020.metamodel.util.CreationUtils;
|
|
|
13 |
|
|
|
14 |
import java.io.BufferedWriter;
|
|
|
15 |
import java.io.File;
|
|
|
16 |
import java.io.FileWriter;
|
|
|
17 |
import java.io.IOException;
|
| 22640 |
amit.gupta |
18 |
import java.util.Collection;
|
| 22649 |
amit.gupta |
19 |
import java.util.Date;
|
| 22640 |
amit.gupta |
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
|
| 22649 |
amit.gupta |
31 |
*
|
| 2838 |
mandeep.dh |
32 |
*/
|
|
|
33 |
public class SpecialPageJSONConvertor {
|
| 22649 |
amit.gupta |
34 |
private static Log LOG = LogFactory.getLog(SpecialPageJSONConvertor.class);
|
| 2838 |
mandeep.dh |
35 |
|
| 22649 |
amit.gupta |
36 |
public void writeToJSONFile(File file) throws JSONException, IOException {
|
|
|
37 |
Map<Long, SpecialPage> specialPages = CreationUtils.getSpecialPages();
|
|
|
38 |
if (specialPages == null) {
|
|
|
39 |
return;
|
|
|
40 |
}
|
| 2839 |
mandeep.dh |
41 |
|
| 22649 |
amit.gupta |
42 |
FileWriter fileWriter = new FileWriter(file);
|
|
|
43 |
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
|
|
44 |
for (SpecialPage specialPage : specialPages.values()) {
|
|
|
45 |
LOG.info("Writing specialPage: " + specialPage);
|
|
|
46 |
bufferedWriter.write(new Gson().toJson(specialPage));
|
|
|
47 |
bufferedWriter.newLine();
|
|
|
48 |
}
|
| 2838 |
mandeep.dh |
49 |
|
| 22649 |
amit.gupta |
50 |
bufferedWriter.close();
|
|
|
51 |
fileWriter.close();
|
|
|
52 |
}
|
| 2838 |
mandeep.dh |
53 |
|
| 22649 |
amit.gupta |
54 |
public static void main(String[] args) throws Exception {
|
|
|
55 |
Date when = new Date(CreationUtils.getLastContentGenerationTime() - 86400 * 10 * 1000);
|
|
|
56 |
CreationUtils.getEntitiesState();
|
|
|
57 |
for (Map.Entry<Long, EntityState> es : CreationUtils.getEntitiesState().entrySet()) {
|
|
|
58 |
if (es.getValue().getMerkedReadyOn().after(when)) {
|
|
|
59 |
Entity e = CreationUtils.getEntity(es.getValue().getID());
|
|
|
60 |
LOG.info("Entity ID - " + e.getID());
|
|
|
61 |
List<Slide> slides = e.getSlides();
|
|
|
62 |
if (slides != null) {
|
|
|
63 |
for (Slide slide : slides) {
|
|
|
64 |
if (slide.getFreeformContent() != null && slide.getFreeformContent().getMedias() != null) {
|
|
|
65 |
String slideName = Catalog.getInstance().getDefinitionsContainer()
|
|
|
66 |
.getSlideDefinition(slide.getSlideDefinitionID()).getLabel();
|
|
|
67 |
Collection<Media> medias = slide.getFreeformContent().getMedias().values();
|
|
|
68 |
for (Media media : medias) {
|
|
|
69 |
if (media.getFileName() == null) {
|
|
|
70 |
LOG.info("Slide ID - for media:" + slide.getSlideDefinitionID() + "Slide name is " + slideName);
|
|
|
71 |
LOG.info("Media label -- " + media.getLabel());
|
|
|
72 |
LOG.info("Media file name -- " + media.getFileName());
|
|
|
73 |
}
|
| 22647 |
amit.gupta |
74 |
}
|
| 22640 |
amit.gupta |
75 |
}
|
| 22649 |
amit.gupta |
76 |
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
}
|
| 2838 |
mandeep.dh |
82 |
}
|