| Line 4... |
Line 4... |
| 4 |
import in.shop2020.metamodel.core.Entity;
|
4 |
import in.shop2020.metamodel.core.Entity;
|
| 5 |
import in.shop2020.metamodel.core.EntityState;
|
5 |
import in.shop2020.metamodel.core.EntityState;
|
| 6 |
import in.shop2020.metamodel.core.EntityStatus;
|
6 |
import in.shop2020.metamodel.core.EntityStatus;
|
| 7 |
import in.shop2020.metamodel.core.EnumDataObject;
|
7 |
import in.shop2020.metamodel.core.EnumDataObject;
|
| 8 |
import in.shop2020.metamodel.core.ExpertReview;
|
8 |
import in.shop2020.metamodel.core.ExpertReview;
|
| - |
|
9 |
import in.shop2020.metamodel.core.ExpertReviewSource;
|
| 9 |
import in.shop2020.metamodel.core.Feature;
|
10 |
import in.shop2020.metamodel.core.Feature;
|
| 10 |
import in.shop2020.metamodel.core.FreeformContent;
|
11 |
import in.shop2020.metamodel.core.FreeformContent;
|
| - |
|
12 |
import in.shop2020.metamodel.core.Helpdoc;
|
| 11 |
import in.shop2020.metamodel.core.Media;
|
13 |
import in.shop2020.metamodel.core.Media;
|
| 12 |
import in.shop2020.metamodel.core.Media.Type;
|
14 |
import in.shop2020.metamodel.core.Media.Type;
|
| 13 |
import in.shop2020.metamodel.core.PrimitiveDataObject;
|
15 |
import in.shop2020.metamodel.core.PrimitiveDataObject;
|
| 14 |
import in.shop2020.metamodel.core.Slide;
|
16 |
import in.shop2020.metamodel.core.Slide;
|
| - |
|
17 |
import in.shop2020.metamodel.core.SpecialPage;
|
| 15 |
import in.shop2020.metamodel.definitions.BulletDefinition;
|
18 |
import in.shop2020.metamodel.definitions.BulletDefinition;
|
| 16 |
import in.shop2020.metamodel.definitions.Catalog;
|
19 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 17 |
import in.shop2020.metamodel.definitions.Category;
|
20 |
import in.shop2020.metamodel.definitions.Category;
|
| 18 |
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
|
21 |
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
|
| 19 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
22 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 20 |
import in.shop2020.metamodel.definitions.FeatureDefinition;
|
23 |
import in.shop2020.metamodel.definitions.FeatureDefinition;
|
| 21 |
import in.shop2020.metamodel.definitions.SlideDefinition;
|
24 |
import in.shop2020.metamodel.definitions.SlideDefinition;
|
| 22 |
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
|
25 |
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
|
| 23 |
import in.shop2020.metamodel.util.CreationUtils;
|
26 |
import in.shop2020.metamodel.util.CreationUtils;
|
| - |
|
27 |
import in.shop2020.metamodel.util.CreationUtils1;
|
| 24 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
28 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
| 25 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
29 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 26 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
30 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 27 |
import in.shop2020.model.v1.catalog.Item;
|
31 |
import in.shop2020.model.v1.catalog.Item;
|
| 28 |
import in.shop2020.model.v1.catalog.status;
|
32 |
import in.shop2020.model.v1.catalog.status;
|
| - |
|
33 |
import in.shop2020.storage.mongo.StorageManager;
|
| 29 |
import in.shop2020.thrift.clients.CatalogClient;
|
34 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 30 |
import in.shop2020.utils.Logger;
|
35 |
import in.shop2020.utils.Logger;
|
| 31 |
|
36 |
|
| 32 |
import java.io.BufferedReader;
|
37 |
import java.io.BufferedReader;
|
| 33 |
import java.io.ByteArrayInputStream;
|
38 |
import java.io.ByteArrayInputStream;
|
| Line 43... |
Line 48... |
| 43 |
import java.io.ObjectInputStream;
|
48 |
import java.io.ObjectInputStream;
|
| 44 |
import java.io.ObjectOutputStream;
|
49 |
import java.io.ObjectOutputStream;
|
| 45 |
import java.io.OutputStream;
|
50 |
import java.io.OutputStream;
|
| 46 |
import java.io.Reader;
|
51 |
import java.io.Reader;
|
| 47 |
import java.text.MessageFormat;
|
52 |
import java.text.MessageFormat;
|
| - |
|
53 |
import java.text.SimpleDateFormat;
|
| 48 |
import java.util.ArrayList;
|
54 |
import java.util.ArrayList;
|
| 49 |
import java.util.Arrays;
|
55 |
import java.util.Arrays;
|
| - |
|
56 |
import java.util.Calendar;
|
| 50 |
import java.util.Collection;
|
57 |
import java.util.Collection;
|
| 51 |
import java.util.Collections;
|
58 |
import java.util.Collections;
|
| 52 |
import java.util.Date;
|
59 |
import java.util.Date;
|
| 53 |
import java.util.HashMap;
|
60 |
import java.util.HashMap;
|
| 54 |
import java.util.Iterator;
|
61 |
import java.util.Iterator;
|
| 55 |
import java.util.LinkedHashMap;
|
62 |
import java.util.LinkedHashMap;
|
| 56 |
import java.util.List;
|
63 |
import java.util.List;
|
| 57 |
import java.util.Map;
|
64 |
import java.util.Map;
|
| 58 |
import java.util.Set;
|
65 |
import java.util.Set;
|
| - |
|
66 |
import java.util.TimeZone;
|
| 59 |
import java.util.TreeMap;
|
67 |
import java.util.TreeMap;
|
| 60 |
|
68 |
|
| 61 |
import org.apache.commons.collections.CollectionUtils;
|
69 |
import org.apache.commons.collections.CollectionUtils;
|
| 62 |
import org.apache.commons.io.IOUtils;
|
70 |
import org.apache.commons.io.IOUtils;
|
| 63 |
import org.apache.commons.lang.StringUtils;
|
71 |
import org.apache.commons.lang.StringUtils;
|
| Line 75... |
Line 83... |
| 75 |
private String sourceDbPath;
|
83 |
private String sourceDbPath;
|
| 76 |
private String destinationDbPath;
|
84 |
private String destinationDbPath;
|
| 77 |
|
85 |
|
| 78 |
public static void main(String[] args) throws Exception {
|
86 |
public static void main(String[] args) throws Exception {
|
| 79 |
String usage = "Usage: ContentMigrator {source db path}{destination db path}";
|
87 |
String usage = "Usage: ContentMigrator {source db path}{destination db path}";
|
| 80 |
|
88 |
|
| 81 |
String sourceDbPath = null, destinationDbPath = null;
|
89 |
String sourceDbPath = null, destinationDbPath = null;
|
| 82 |
String dryRun = null;
|
90 |
String dryRun = null;
|
| 83 |
// if(args.length < 2) {
|
91 |
// if(args.length < 2) {
|
| 84 |
// System.out.println(usage);
|
92 |
// System.out.println(usage);
|
| 85 |
// System.exit(-1);
|
93 |
// System.exit(-1);
|
| Line 98... |
Line 106... |
| 98 |
/*contentmigrator.touchEntityState(1008423l);
|
106 |
/*contentmigrator.touchEntityState(1008423l);
|
| 99 |
contentmigrator.touchEntityState(1008424l);
|
107 |
contentmigrator.touchEntityState(1008424l);
|
| 100 |
contentmigrator.touchEntityState(1008427l);
|
108 |
contentmigrator.touchEntityState(1008427l);
|
| 101 |
contentmigrator.touchEntityState(1008428l);*/
|
109 |
contentmigrator.touchEntityState(1008428l);*/
|
| 102 |
|
110 |
|
| 103 |
contentmigrator.changeEntityState();
|
111 |
contentmigrator.migrateToMongo();
|
| 104 |
}
|
112 |
}
|
| 105 |
|
113 |
|
| - |
|
114 |
private void migrateToMongo() throws Exception{
|
| - |
|
115 |
Map<String,Map<String,String>> m = CreationUtils1.getSynonyms();
|
| - |
|
116 |
CreationUtils.storeSynonyms(m);
|
| - |
|
117 |
|
| - |
|
118 |
Map<Long, Entity> entities= CreationUtils1.getEntities();
|
| - |
|
119 |
for(Map.Entry<Long, Entity> e : entities.entrySet()){
|
| - |
|
120 |
StorageManager.getStorageManager().updateEntity(e.getValue());
|
| - |
|
121 |
}
|
| - |
|
122 |
//StorageManager.getStorageManager().updateEntity(entity);
|
| - |
|
123 |
Map<Long,EntityState> entityStates = CreationUtils1.getEntitiesState();
|
| - |
|
124 |
for(Map.Entry<Long, EntityState> e : entityStates.entrySet()){
|
| - |
|
125 |
StorageManager.getStorageManager().updateEntityMetadata(e.getValue());
|
| - |
|
126 |
}
|
| - |
|
127 |
|
| - |
|
128 |
Map<Long,Helpdoc> helpdocs = CreationUtils1.getHelpdocs();
|
| - |
|
129 |
for(Map.Entry<Long, Helpdoc> h : helpdocs.entrySet()){
|
| - |
|
130 |
StorageManager.getStorageManager().updateHelpdoc(h.getValue());
|
| - |
|
131 |
}
|
| - |
|
132 |
|
| - |
|
133 |
Map<Long,SpecialPage> specialPages = CreationUtils1.getSpecialPages();
|
| - |
|
134 |
for(Map.Entry<Long, SpecialPage> specialPage : specialPages.entrySet()){
|
| - |
|
135 |
StorageManager.getStorageManager().updateSpecialPage(specialPage.getValue());
|
| - |
|
136 |
}
|
| - |
|
137 |
|
| - |
|
138 |
Collection<Entity> entities2 = CreationUtils1.getEntities(10006);
|
| - |
|
139 |
for(Entity e : entities2) {
|
| - |
|
140 |
Map<Long,Double> slideCmpScores = CreationUtils1.getCustomSlideComparisonScores(e.getID());
|
| - |
|
141 |
if(slideCmpScores!=null){
|
| - |
|
142 |
StorageManager.getStorageManager().storeCustomSlideScores(e.getID(), slideCmpScores);
|
| - |
|
143 |
}
|
| - |
|
144 |
}
|
| - |
|
145 |
|
| - |
|
146 |
Long time = CreationUtils1.getLastContentGenerationTime();
|
| - |
|
147 |
StorageManager.getStorageManager().storeDataObject("CONTENT_GENERATION_TIME", time);
|
| - |
|
148 |
//System.out.println(StorageManager.getStorageManager().getDataObject("CONTENT_GENERATION_TIME", Long.class));
|
| - |
|
149 |
|
| - |
|
150 |
Map<Long,Map<Long,Double>> scores = CreationUtils1.getSlideScores();
|
| - |
|
151 |
StorageManager.getStorageManager().storeDataObject("SLIDE_SCORES", scores);
|
| - |
|
152 |
|
| - |
|
153 |
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("IST"));
|
| - |
|
154 |
List<String> searchTerms=null;
|
| - |
|
155 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
| - |
|
156 |
int i=1;
|
| - |
|
157 |
while(i<=30){
|
| - |
|
158 |
i++;
|
| - |
|
159 |
cal.add(Calendar.DATE, -1);
|
| - |
|
160 |
String date = sdf.format(cal.getTime());
|
| - |
|
161 |
try {
|
| - |
|
162 |
searchTerms = CreationUtils1.getSearchStats(sdf.format(cal.getTime()));
|
| - |
|
163 |
if(searchTerms != null){
|
| - |
|
164 |
CreationUtils.storeSearchStats(date, searchTerms);
|
| - |
|
165 |
} else continue;
|
| - |
|
166 |
} catch (Exception e) {
|
| - |
|
167 |
// TODO Auto-generated catch block
|
| - |
|
168 |
e.printStackTrace();
|
| - |
|
169 |
continue;
|
| - |
|
170 |
}
|
| - |
|
171 |
}
|
| - |
|
172 |
|
| - |
|
173 |
Iterator<ExpertReviewSource> sources = CreationUtils1.getExpertReviewSources().iterator();
|
| - |
|
174 |
while(sources.hasNext()){
|
| - |
|
175 |
CreationUtils.addExpertReviewSource(sources.next());
|
| - |
|
176 |
}
|
| - |
|
177 |
|
| - |
|
178 |
for (Map.Entry<Long, List<ExpertReview>> entry : CreationUtils1.getExpertReviews().entrySet()){
|
| - |
|
179 |
CreationUtils.storeExpertReview(entry.getKey(), entry.getValue());
|
| - |
|
180 |
}
|
| - |
|
181 |
|
| - |
|
182 |
Map<Long, List<ExpandedBullet>> learnedBullets = CreationUtils1.getLearnedBullets();
|
| - |
|
183 |
CreationUtils.storeLearnedBullets(learnedBullets);
|
| - |
|
184 |
|
| - |
|
185 |
Map<Long, Map<Long, List<Long>>> relatedAccessories = CreationUtils1.getRelatedAccessories();
|
| - |
|
186 |
CreationUtils.storeRelatedAccessories(relatedAccessories);
|
| - |
|
187 |
}
|
| - |
|
188 |
|
| - |
|
189 |
private void migrateContentStore() throws Exception {
|
| - |
|
190 |
for (Map.Entry<Long, Entity> entry :CreationUtils.getEntities().entrySet()){
|
| - |
|
191 |
Entity e = entry.getValue();
|
| - |
|
192 |
Iterator<Slide> it = e.getSlides().iterator();
|
| - |
|
193 |
while(it.hasNext()){
|
| - |
|
194 |
Slide sl = it.next();
|
| - |
|
195 |
//sl.getFreeformContent().me
|
| - |
|
196 |
}
|
| - |
|
197 |
}
|
| - |
|
198 |
|
| - |
|
199 |
}
|
| - |
|
200 |
|
| 106 |
private void updateSources() throws Exception{
|
201 |
private void updateSources() throws Exception{
|
| 107 |
Map<Long,List<ExpertReview>> erMap = CreationUtils.getExpertReviews();
|
202 |
Map<Long,List<ExpertReview>> erMap = CreationUtils.getExpertReviews();
|
| 108 |
for(Map.Entry<Long, List<ExpertReview>> erEntry : erMap.entrySet()){
|
203 |
for(Map.Entry<Long, List<ExpertReview>> erEntry : erMap.entrySet()){
|
| 109 |
List<ExpertReview> erList = erEntry.getValue();
|
204 |
List<ExpertReview> erList = erEntry.getValue();
|
| 110 |
Iterator<ExpertReview> iter = erList.iterator();
|
205 |
Iterator<ExpertReview> iter = erList.iterator();
|
| Line 544... |
Line 639... |
| 544 |
// }
|
639 |
// }
|
| 545 |
// }
|
640 |
// }
|
| 546 |
// ffc.setMediasNew(newMap);
|
641 |
// ffc.setMediasNew(newMap);
|
| 547 |
// ffc.setMedias(null);
|
642 |
// ffc.setMedias(null);
|
| 548 |
}
|
643 |
}
|
| 549 |
CreationUtils.updateEntity(entity);
|
- |
|
| 550 |
}
|
644 |
}
|
| 551 |
}
|
645 |
}
|
| 552 |
|
646 |
|
| 553 |
public boolean populateHelpdocEntityIds() throws Exception {
|
647 |
public boolean populateHelpdocEntityIds() throws Exception {
|
| 554 |
for (Entity entity : CreationUtils.getEntities().values()) {
|
648 |
for (Entity entity : CreationUtils.getEntities().values()) {
|