| Line 96... |
Line 96... |
| 96 |
// destinationDbPath = args[1];
|
96 |
// destinationDbPath = args[1];
|
| 97 |
// dryRun = args[2];
|
97 |
// dryRun = args[2];
|
| 98 |
// }
|
98 |
// }
|
| 99 |
//
|
99 |
//
|
| 100 |
ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
|
100 |
ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
|
| - |
|
101 |
|
| - |
|
102 |
|
| 101 |
/*List<Long> entityId = Arrays.asList(1001674l,1002575l,1005331l,1005165l,1005164l,1005111l,1005109l,1004952l,1004940l,1004871l,1004701l,1004429l,1004197l,1006174l,1006077l,1005901l,1005757l,1005754l,1005724l,1005704l,1005598l,1005576l,1005558l,1007394l,1007230l,1007226l,1007218l,1007089l,1006925l,1006822l,1006814l,1006175l);
|
103 |
/*List<Long> entityId = Arrays.asList(1001674l,1002575l,1005331l,1005165l,1005164l,1005111l,1005109l,1004952l,1004940l,1004871l,1004701l,1004429l,1004197l,1006174l,1006077l,1005901l,1005757l,1005754l,1005724l,1005704l,1005598l,1005576l,1005558l,1007394l,1007230l,1007226l,1007218l,1007089l,1006925l,1006822l,1006814l,1006175l);
|
| 102 |
for (Long eId : entityId){
|
104 |
for (Long eId : entityId){
|
| 103 |
}*/
|
105 |
}*/
|
| 104 |
//contentmigrator.reorderPhones();
|
106 |
//contentmigrator.reorderPhones();
|
| 105 |
//System.out.println(contentmigrator.getItems().size());
|
107 |
//System.out.println(contentmigrator.getItems().size());
|
| 106 |
/*contentmigrator.touchEntityState(1008423l);
|
108 |
/*contentmigrator.touchEntityState(1008423l);
|
| 107 |
contentmigrator.touchEntityState(1008424l);
|
109 |
contentmigrator.touchEntityState(1008424l);
|
| 108 |
contentmigrator.touchEntityState(1008427l);
|
110 |
contentmigrator.touchEntityState(1008427l);
|
| 109 |
contentmigrator.touchEntityState(1008428l);*/
|
111 |
contentmigrator.touchEntityState(1008428l);*/
|
| 110 |
|
112 |
|
| - |
|
113 |
//contentmigrator.migrateToMongo();
|
| 111 |
contentmigrator.touchEntityStates();
|
114 |
contentmigrator.getEditedEntities();
|
| 112 |
}
|
115 |
}
|
| 113 |
|
116 |
|
| 114 |
private void migrateToMongo() throws Exception{
|
117 |
private void changeKeys() throws Exception {
|
| 115 |
Map<String,Map<String,String>> m = CreationUtils1.getSynonyms();
|
- |
|
| 116 |
CreationUtils.storeSynonyms(m);
|
- |
|
| 117 |
|
- |
|
| 118 |
Map<Long, Entity> entities= CreationUtils1.getEntities();
|
118 |
Map<Long, Entity> e = CreationUtils.getEntities();
|
| 119 |
for(Map.Entry<Long, Entity> e : entities.entrySet()){
|
119 |
for (Map.Entry<Long, Entity> entry : e.entrySet()) {
|
| 120 |
StorageManager.getStorageManager().updateEntity(e.getValue());
|
120 |
CreationUtils.updateEntity(entry.getValue());
|
| 121 |
}
|
- |
|
| 122 |
//StorageManager.getStorageManager().updateEntity(entity);
|
- |
|
| 123 |
Map<Long,EntityState> entityStates = CreationUtils1.getEntitiesState();
|
- |
|
| 124 |
for(Map.Entry<Long, EntityState> e : entityStates.entrySet()){
|
121 |
System.out.println("updated " + entry.getValue().getID());
|
| 125 |
StorageManager.getStorageManager().updateEntityMetadata(e.getValue());
|
- |
|
| 126 |
}
|
122 |
}
|
| 127 |
|
- |
|
| 128 |
Map<Long,Helpdoc> helpdocs = CreationUtils1.getHelpdocs();
|
123 |
//CreationUtils.updateEntity(e);
|
| 129 |
for(Map.Entry<Long, Helpdoc> h : helpdocs.entrySet()){
|
124 |
//CreationUtils.
|
| 130 |
StorageManager.getStorageManager().updateHelpdoc(h.getValue());
|
- |
|
| 131 |
}
|
125 |
}
|
| 132 |
|
126 |
|
| 133 |
Map<Long,SpecialPage> specialPages = CreationUtils1.getSpecialPages();
|
127 |
public void getEditedEntities() throws Exception {
|
| 134 |
for(Map.Entry<Long, SpecialPage> specialPage : specialPages.entrySet()){
|
- |
|
| 135 |
StorageManager.getStorageManager().updateSpecialPage(specialPage.getValue());
|
- |
|
| 136 |
}
|
- |
|
| 137 |
|
- |
|
| 138 |
Collection<Entity> entities2 = CreationUtils1.getEntities(10006);
|
128 |
Collection<EntityState> es = CreationUtils1.getEntitiesState().values();
|
| 139 |
for(Entity e : entities2) {
|
129 |
for (EntityState es1 : es) {
|
| 140 |
Map<Long,Double> slideCmpScores = CreationUtils1.getCustomSlideComparisonScores(e.getID());
|
130 |
if(es1.getStatus().equals(EntityStatus.READY) && !CreationUtils.getEntityState(es1.getID()).getMerkedReadyOn().equals(es1.getMerkedReadyOn())){
|
| 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());
|
131 |
System.out.println(es1.getID());
|
| 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 |
}
|
132 |
}
|
| 171 |
}
|
133 |
}
|
| 172 |
|
- |
|
| 173 |
Iterator<ExpertReviewSource> sources = CreationUtils1.getExpertReviewSources().iterator();
|
- |
|
| 174 |
while(sources.hasNext()){
|
- |
|
| 175 |
CreationUtils.addExpertReviewSource(sources.next());
|
- |
|
| 176 |
}
|
134 |
}
|
| 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 |
|
135 |
|
| - |
|
136 |
private void migrateToMongo() throws Exception{
|
| - |
|
137 |
long counter = 0;
|
| 185 |
Map<Long, Map<Long, List<Long>>> relatedAccessories = CreationUtils1.getRelatedAccessories();
|
138 |
Collection<EntityState> es = CreationUtils1.getEntitiesState().values();
|
| - |
|
139 |
boolean updated = false;
|
| - |
|
140 |
for (EntityState es1 : es) {
|
| - |
|
141 |
if(es1.getStatus().equals(EntityStatus.READY)){
|
| - |
|
142 |
updated = false;
|
| - |
|
143 |
Entity e = CreationUtils1.getEntity(es1.getID());
|
| - |
|
144 |
List<Slide> slides = e.getSlides();
|
| - |
|
145 |
for(Slide slide:slides) {
|
| - |
|
146 |
FreeformContent ffc = slide.getFreeformContent();
|
| - |
|
147 |
if (ffc !=null){
|
| - |
|
148 |
Map<String,Media> m1 = ffc.getMedias();
|
| - |
|
149 |
if (m1!=null){
|
| - |
|
150 |
Map<String,Media> m = new LinkedHashMap<String, Media>(m1);
|
| - |
|
151 |
for (Map.Entry<String, Media> m2 : m.entrySet()){
|
| - |
|
152 |
m1.put(Long.toString(++counter), m1.remove(m2.getKey()));
|
| - |
|
153 |
updated = true;
|
| - |
|
154 |
}
|
| - |
|
155 |
}
|
| - |
|
156 |
}
|
| - |
|
157 |
}
|
| - |
|
158 |
if(updated){
|
| 186 |
CreationUtils.storeRelatedAccessories(relatedAccessories);
|
159 |
CreationUtils.updateEntity(e);
|
| - |
|
160 |
}
|
| - |
|
161 |
}
|
| - |
|
162 |
}
|
| 187 |
}
|
163 |
}
|
| 188 |
|
164 |
|
| 189 |
private void migrateContentStore() throws Exception {
|
165 |
private void migrateContentStore() throws Exception {
|
| 190 |
for (Map.Entry<Long, Entity> entry :CreationUtils.getEntities().entrySet()){
|
166 |
for (Map.Entry<Long, Entity> entry :CreationUtils.getEntities().entrySet()){
|
| 191 |
Entity e = entry.getValue();
|
167 |
Entity e = entry.getValue();
|