| 3438 |
varun.gupt |
1 |
package in.shop2020.util;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.metamodel.core.Bullet;
|
|
|
4 |
import in.shop2020.metamodel.core.Entity;
|
|
|
5 |
import in.shop2020.metamodel.core.Feature;
|
|
|
6 |
import in.shop2020.metamodel.core.PrimitiveDataObject;
|
|
|
7 |
import in.shop2020.metamodel.core.Slide;
|
|
|
8 |
|
|
|
9 |
import java.util.ArrayList;
|
|
|
10 |
import java.util.HashMap;
|
|
|
11 |
import java.util.List;
|
|
|
12 |
import java.util.Map;
|
|
|
13 |
|
|
|
14 |
import com.google.gson.Gson;
|
|
|
15 |
|
|
|
16 |
public class SynonymExporter {
|
|
|
17 |
|
|
|
18 |
List<Entity> entities;
|
|
|
19 |
|
|
|
20 |
public SynonymExporter(List<Entity> entities){
|
|
|
21 |
this.entities = entities;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public void storeSynonyms(){
|
|
|
25 |
Map<Long, Map<String,List<String>>> synonyms = new HashMap<Long, Map<String,List<String>>>();
|
|
|
26 |
for(Entity entity: entities) {
|
|
|
27 |
Map<String,List<String>> synonymMap = null;
|
|
|
28 |
Slide slide = entity.getSlide(Utils.SUMMARY_SLIDE_DEFINITION_ID);
|
|
|
29 |
List<Feature> features = slide.getFeatures();
|
|
|
30 |
for(Feature feature: features){
|
|
|
31 |
if(feature.getFeatureDefinitionID() == 120156){
|
|
|
32 |
List<Bullet> bullets = feature.getBullets();
|
|
|
33 |
if(bullets != null){
|
|
|
34 |
List<String> modelNameSynonyms= new ArrayList<String>();
|
|
|
35 |
for(Bullet bullet: bullets){
|
|
|
36 |
PrimitiveDataObject pdo = (PrimitiveDataObject)bullet.getDataObject();
|
|
|
37 |
modelNameSynonyms.add(pdo.getValue());
|
|
|
38 |
}
|
|
|
39 |
if(synonymMap == null){
|
|
|
40 |
synonymMap = new HashMap<String,List<String>>();
|
|
|
41 |
}
|
|
|
42 |
synonymMap.put("MODEL_NAME", modelNameSynonyms );
|
|
|
43 |
}
|
|
|
44 |
}else if(feature.getFeatureDefinitionID() == 120157){
|
|
|
45 |
List<Bullet> bullets = feature.getBullets();
|
|
|
46 |
if(bullets != null){
|
|
|
47 |
List<String> modelNameSynonyms= new ArrayList<String>();
|
|
|
48 |
for(Bullet bullet: bullets){
|
|
|
49 |
PrimitiveDataObject pdo = (PrimitiveDataObject)bullet.getDataObject();
|
|
|
50 |
modelNameSynonyms.add(pdo.getValue());
|
|
|
51 |
}
|
|
|
52 |
if(synonymMap == null){
|
|
|
53 |
synonymMap = new HashMap<String,List<String>>();
|
|
|
54 |
}
|
|
|
55 |
synonymMap.put("MODEL_NUMBER", modelNameSynonyms );
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
}
|
|
|
59 |
if(synonymMap != null){
|
|
|
60 |
synonyms.put(entity.getID(), synonymMap);
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
String synonymFilename = Utils.EXPORT_JAVASCRIPT_CONTENT_PATH + "synonyms.json";
|
|
|
65 |
Gson gson = new Gson();
|
|
|
66 |
try {
|
|
|
67 |
DBUtils.store(gson.toJson(synonyms), synonymFilename);
|
|
|
68 |
} catch (Exception e) {
|
|
|
69 |
e.printStackTrace();
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
}
|