| 457 |
rajveer |
1 |
package in.shop2020.util;
|
|
|
2 |
|
| 1226 |
rajveer |
3 |
import in.shop2020.metamodel.core.Bullet;
|
| 8909 |
amit.gupta |
4 |
import in.shop2020.metamodel.core.BulletDataObject;
|
| 479 |
rajveer |
5 |
import in.shop2020.metamodel.core.Entity;
|
| 1226 |
rajveer |
6 |
import in.shop2020.metamodel.core.EntityState;
|
| 7129 |
amit.gupta |
7 |
import in.shop2020.metamodel.core.EntityStatus;
|
| 3873 |
mandeep.dh |
8 |
import in.shop2020.metamodel.core.EnumDataObject;
|
| 7590 |
amit.gupta |
9 |
import in.shop2020.metamodel.core.ExpertReview;
|
| 10692 |
amit.gupta |
10 |
import in.shop2020.metamodel.core.ExpertReviewStatus;
|
| 1226 |
rajveer |
11 |
import in.shop2020.metamodel.core.Feature;
|
| 479 |
rajveer |
12 |
import in.shop2020.metamodel.core.FreeformContent;
|
| 5370 |
amit.gupta |
13 |
import in.shop2020.metamodel.core.Media;
|
|
|
14 |
import in.shop2020.metamodel.core.Media.Type;
|
| 1226 |
rajveer |
15 |
import in.shop2020.metamodel.core.PrimitiveDataObject;
|
| 479 |
rajveer |
16 |
import in.shop2020.metamodel.core.Slide;
|
| 580 |
rajveer |
17 |
import in.shop2020.metamodel.definitions.BulletDefinition;
|
| 457 |
rajveer |
18 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 580 |
rajveer |
19 |
import in.shop2020.metamodel.definitions.Category;
|
|
|
20 |
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
|
| 457 |
rajveer |
21 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 580 |
rajveer |
22 |
import in.shop2020.metamodel.definitions.FeatureDefinition;
|
|
|
23 |
import in.shop2020.metamodel.definitions.SlideDefinition;
|
|
|
24 |
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
|
| 11554 |
amit.gupta |
25 |
import in.shop2020.metamodel.util.ContentPojo;
|
| 479 |
rajveer |
26 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 8749 |
amit.gupta |
27 |
import in.shop2020.metamodel.util.CreationUtils1;
|
| 2720 |
mandeep.dh |
28 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
| 1739 |
rajveer |
29 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 11151 |
amit.gupta |
30 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
|
|
31 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
| 11554 |
amit.gupta |
32 |
import in.shop2020.metamodel.util.Specification;
|
|
|
33 |
import in.shop2020.metamodel.util.SpecificationGroup;
|
| 5945 |
mandeep.dh |
34 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 2287 |
rajveer |
35 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
36 |
import in.shop2020.model.v1.catalog.status;
|
| 11554 |
amit.gupta |
37 |
import in.shop2020.storage.mongo.StorageManager;
|
| 3127 |
rajveer |
38 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 4706 |
amit.gupta |
39 |
import in.shop2020.utils.Logger;
|
| 457 |
rajveer |
40 |
|
| 2720 |
mandeep.dh |
41 |
import java.io.BufferedReader;
|
| 5370 |
amit.gupta |
42 |
import java.io.ByteArrayInputStream;
|
|
|
43 |
import java.io.ByteArrayOutputStream;
|
| 2720 |
mandeep.dh |
44 |
import java.io.DataInputStream;
|
|
|
45 |
import java.io.File;
|
|
|
46 |
import java.io.FileInputStream;
|
| 8014 |
amit.gupta |
47 |
import java.io.FileNotFoundException;
|
| 5370 |
amit.gupta |
48 |
import java.io.FileOutputStream;
|
| 8014 |
amit.gupta |
49 |
import java.io.FileReader;
|
| 5370 |
amit.gupta |
50 |
import java.io.InputStream;
|
| 2720 |
mandeep.dh |
51 |
import java.io.InputStreamReader;
|
| 5370 |
amit.gupta |
52 |
import java.io.ObjectInputStream;
|
|
|
53 |
import java.io.ObjectOutputStream;
|
|
|
54 |
import java.io.OutputStream;
|
| 8014 |
amit.gupta |
55 |
import java.io.Reader;
|
| 5760 |
amit.gupta |
56 |
import java.text.MessageFormat;
|
| 2720 |
mandeep.dh |
57 |
import java.util.ArrayList;
|
| 7037 |
amit.gupta |
58 |
import java.util.Arrays;
|
| 8749 |
amit.gupta |
59 |
import java.util.Calendar;
|
| 5370 |
amit.gupta |
60 |
import java.util.Collection;
|
| 3873 |
mandeep.dh |
61 |
import java.util.Collections;
|
| 7129 |
amit.gupta |
62 |
import java.util.Date;
|
| 4706 |
amit.gupta |
63 |
import java.util.HashMap;
|
| 8909 |
amit.gupta |
64 |
import java.util.HashSet;
|
| 5671 |
amit.gupta |
65 |
import java.util.Iterator;
|
| 7123 |
amit.gupta |
66 |
import java.util.LinkedHashMap;
|
| 9171 |
amit.gupta |
67 |
import java.util.LinkedHashSet;
|
| 2720 |
mandeep.dh |
68 |
import java.util.List;
|
|
|
69 |
import java.util.Map;
|
| 7111 |
amit.gupta |
70 |
import java.util.Set;
|
| 2720 |
mandeep.dh |
71 |
import java.util.TreeMap;
|
| 580 |
rajveer |
72 |
|
| 7932 |
amit.gupta |
73 |
import org.apache.commons.collections.CollectionUtils;
|
| 5370 |
amit.gupta |
74 |
import org.apache.commons.io.IOUtils;
|
| 4818 |
amit.gupta |
75 |
import org.apache.commons.lang.StringUtils;
|
|
|
76 |
|
| 8014 |
amit.gupta |
77 |
import com.google.gson.Gson;
|
|
|
78 |
import com.google.gson.reflect.TypeToken;
|
|
|
79 |
|
| 457 |
rajveer |
80 |
/*
|
| 7997 |
amit.gupta |
81 |
* @author rajveer
|
| 457 |
rajveer |
82 |
*
|
|
|
83 |
*
|
|
|
84 |
*/
|
|
|
85 |
|
|
|
86 |
public class ContentMigrator {
|
| 11151 |
amit.gupta |
87 |
private static final String HYPHON = "-";
|
|
|
88 |
private static final String SPACE = " ";
|
| 457 |
rajveer |
89 |
private String sourceDbPath;
|
|
|
90 |
private String destinationDbPath;
|
| 4964 |
amit.gupta |
91 |
|
| 457 |
rajveer |
92 |
public static void main(String[] args) throws Exception {
|
|
|
93 |
String usage = "Usage: ContentMigrator {source db path}{destination db path}";
|
| 8749 |
amit.gupta |
94 |
|
| 4964 |
amit.gupta |
95 |
String sourceDbPath = null, destinationDbPath = null;
|
|
|
96 |
String dryRun = null;
|
|
|
97 |
// if(args.length < 2) {
|
|
|
98 |
// System.out.println(usage);
|
|
|
99 |
// System.exit(-1);
|
|
|
100 |
// }else{
|
|
|
101 |
// sourceDbPath = args[0];
|
|
|
102 |
// destinationDbPath = args[1];
|
|
|
103 |
// dryRun = args[2];
|
|
|
104 |
// }
|
|
|
105 |
//
|
| 7186 |
amit.gupta |
106 |
ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
|
| 12230 |
amit.gupta |
107 |
contentmigrator.renameTitles();
|
| 8841 |
amit.gupta |
108 |
|
| 4964 |
amit.gupta |
109 |
}
|
| 7398 |
amit.gupta |
110 |
|
| 12230 |
amit.gupta |
111 |
|
|
|
112 |
private void testProd() throws Exception {
|
| 11554 |
amit.gupta |
113 |
Map<Long, EntityState> es1 = StorageManager.getStorageManager().getEntitiesMetadata();
|
|
|
114 |
for(Map.Entry<Long, EntityState> estate : es1.entrySet()){
|
|
|
115 |
EntityState es = estate.getValue();
|
| 11569 |
amit.gupta |
116 |
if(es.getCategoryID()==10006l && es.getStatus().equals(EntityStatus.READY)) {
|
| 11554 |
amit.gupta |
117 |
ContentPojo cp = StorageManager.getById(StorageManager.views.siteContent, estate.getKey(), ContentPojo.class);
|
| 12230 |
amit.gupta |
118 |
if(cp != null && cp.getDetailedSpecs()!= null){
|
| 11557 |
amit.gupta |
119 |
List<SpecificationGroup> sgs = cp.getDetailedSpecs();
|
|
|
120 |
System.out.println(es.getBrand() + " " + es.getModelName() + " " +es.getModelNumber());
|
|
|
121 |
for(SpecificationGroup sg : sgs) {
|
|
|
122 |
String title = sg.getTitle();
|
|
|
123 |
if(title.equals("Look n feel")){
|
|
|
124 |
title = "Appearance";
|
|
|
125 |
}else if (title.equals("Display")){
|
|
|
126 |
title = "Screen";
|
|
|
127 |
}else if (title.equals("Hardware")){
|
|
|
128 |
title = "Processor";
|
|
|
129 |
}else if (title.equals("Communication")){
|
|
|
130 |
title = "Network";
|
|
|
131 |
}else if (title.equals("Software")){
|
|
|
132 |
title = "Operating System";
|
|
|
133 |
}else if (title.equals("Battery")){
|
|
|
134 |
title = "Power";
|
|
|
135 |
}else if (title.equals("Music")){
|
|
|
136 |
title = "Audio";
|
|
|
137 |
}else if (title.equals("Miscellaneous")){
|
|
|
138 |
title = "Other features";
|
|
|
139 |
}else if (title.equals("Package content")){
|
|
|
140 |
title = "Box content";
|
|
|
141 |
}
|
|
|
142 |
System.out.println(title);
|
|
|
143 |
for(Specification spec : sg.getSpecs()){
|
|
|
144 |
System.out.println("\t" + spec.getName() + "\t" + StringUtils.join(spec.getValues().toArray(), ", "));
|
|
|
145 |
}
|
| 11554 |
amit.gupta |
146 |
}
|
| 11557 |
amit.gupta |
147 |
|
|
|
148 |
System.out.println("Box content");
|
|
|
149 |
if(cp.getPackageContents()!=null) System.out.println("\t" + StringUtils.join(cp.getPackageContents().toArray(), ", "));
|
| 11554 |
amit.gupta |
150 |
}
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
}
|
|
|
154 |
|
| 11151 |
amit.gupta |
155 |
//Full run for monge Mobile content
|
|
|
156 |
|
|
|
157 |
private void test1() throws Exception{
|
| 11554 |
amit.gupta |
158 |
//Map<Long,Entity> entities = CreationUtils.getEntities();
|
|
|
159 |
//System.out.println("Expert reviews:" + entities.size());
|
| 11151 |
amit.gupta |
160 |
PojoCreator pc = new PojoCreator();
|
| 11554 |
amit.gupta |
161 |
Entity ent = CreationUtils.getEntity(1010432l);
|
|
|
162 |
//for(Map.Entry<Long, Entity> entry : entities.entrySet()) {
|
|
|
163 |
//if(CreationUtils.getEntityState(entry.getKey()).getStatus().equals(EntityStatus.READY)) {
|
|
|
164 |
//System.out.println("Updated entity:" + entry.getKey());
|
|
|
165 |
ExpandedEntity expEntity = new ExpandedEntity(ent);
|
| 11151 |
amit.gupta |
166 |
Map<String, String > entityParams = getEntityParameters(expEntity);
|
| 11554 |
amit.gupta |
167 |
List<ExpertReview> expertReviews = getExpertReviews(1010432l);
|
| 11151 |
amit.gupta |
168 |
//context.put("expertReviews", expertReviews);
|
|
|
169 |
pc.createAndStoreContentPojo(expEntity, expertReviews,entityParams.get("WARRANTY"));
|
| 11554 |
amit.gupta |
170 |
//}
|
|
|
171 |
//}
|
| 11151 |
amit.gupta |
172 |
}
|
|
|
173 |
|
| 10692 |
amit.gupta |
174 |
private void test() throws Exception{
|
| 10699 |
amit.gupta |
175 |
/*PojoCreator pc = new PojoCreator();
|
|
|
176 |
List<ExpertReview> expertReviews = getExpertReviews(1007379);*/
|
|
|
177 |
Map<Long, Entity> ee = CreationUtils.getEntities();
|
|
|
178 |
Map<Long, EntityState> bb = CreationUtils.getEntitiesState();
|
|
|
179 |
for(Map.Entry<Long, EntityState> ent : bb.entrySet()){
|
|
|
180 |
EntityState es = ent.getValue();
|
|
|
181 |
if(es.getStatus().equals(EntityStatus.READY)) {
|
|
|
182 |
Entity e = ee.get(ent.getKey());
|
|
|
183 |
Slide summarySlide = e.getSlide(130054l);
|
|
|
184 |
if(summarySlide==null){
|
|
|
185 |
System.out.println("Does not have summary slide for entity: " + ent.getKey());
|
|
|
186 |
continue;
|
|
|
187 |
}
|
|
|
188 |
FreeformContent ffc = summarySlide.getFreeformContent();
|
|
|
189 |
if(ffc == null){
|
|
|
190 |
ffc = new FreeformContent();
|
|
|
191 |
summarySlide.setFreeformContent(ffc);
|
|
|
192 |
}
|
|
|
193 |
Map<String, Media> mediamap = ffc.getMedias();
|
| 10703 |
amit.gupta |
194 |
if(mediamap==null || mediamap.size()==0 || mediamap.get("default")==null){
|
| 10699 |
amit.gupta |
195 |
String mediaDirPath = Utils.CONTENT_DB_PATH + "media" + File.separator + ent.getKey();
|
|
|
196 |
String mediaFileName = mediaDirPath + File.separator + "default.jpg";
|
|
|
197 |
File f = new File(mediaFileName);
|
|
|
198 |
if(f.exists()) {
|
|
|
199 |
Media media = new Media("default", Media.Type.IMAGE, mediaFileName);
|
|
|
200 |
media.setTitle("default");
|
|
|
201 |
media.setFileName("default.jpg");
|
|
|
202 |
ffc.addMedia(media);
|
|
|
203 |
System.out.println("Added default media successfully for entity: " + ent.getKey());
|
| 10707 |
amit.gupta |
204 |
CreationUtils.updateEntity(e);
|
| 10699 |
amit.gupta |
205 |
} else {
|
|
|
206 |
System.out.println("Could not get default.jpg for entity: " + ent.getKey());
|
|
|
207 |
}
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
}
|
| 10692 |
amit.gupta |
211 |
}
|
|
|
212 |
|
| 8841 |
amit.gupta |
213 |
private void changeKeys() throws Exception {
|
|
|
214 |
Map<Long, Entity> e = CreationUtils.getEntities();
|
|
|
215 |
for (Map.Entry<Long, Entity> entry : e.entrySet()) {
|
|
|
216 |
CreationUtils.updateEntity(entry.getValue());
|
|
|
217 |
System.out.println("updated " + entry.getValue().getID());
|
|
|
218 |
}
|
|
|
219 |
//CreationUtils.updateEntity(e);
|
|
|
220 |
//CreationUtils.
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
public void getEditedEntities() throws Exception {
|
|
|
224 |
Collection<EntityState> es = CreationUtils1.getEntitiesState().values();
|
|
|
225 |
for (EntityState es1 : es) {
|
| 8843 |
amit.gupta |
226 |
if(es1.getStatus().equals(EntityStatus.READY)){
|
|
|
227 |
long mongotime = CreationUtils.getEntityState(es1.getID()).getMerkedReadyOn().getTime()/1000;
|
|
|
228 |
long bdbtime = es1.getMerkedReadyOn().getTime()/1000;
|
|
|
229 |
if(bdbtime!=mongotime){
|
|
|
230 |
System.out.println(es1.getID());
|
|
|
231 |
}
|
| 8841 |
amit.gupta |
232 |
}
|
|
|
233 |
}
|
|
|
234 |
}
|
|
|
235 |
|
| 8749 |
amit.gupta |
236 |
private void migrateToMongo() throws Exception{
|
| 8841 |
amit.gupta |
237 |
long counter = 0;
|
|
|
238 |
Collection<EntityState> es = CreationUtils1.getEntitiesState().values();
|
|
|
239 |
boolean updated = false;
|
| 8865 |
amit.gupta |
240 |
StringBuffer buffer = new StringBuffer();
|
| 8841 |
amit.gupta |
241 |
for (EntityState es1 : es) {
|
|
|
242 |
if(es1.getStatus().equals(EntityStatus.READY)){
|
| 8865 |
amit.gupta |
243 |
long mongotime = CreationUtils.getEntityState(es1.getID()).getMerkedReadyOn().getTime()/1000;
|
|
|
244 |
long bdbtime = es1.getMerkedReadyOn().getTime()/1000;
|
|
|
245 |
if(bdbtime==mongotime){
|
|
|
246 |
updated = false;
|
|
|
247 |
Entity e = CreationUtils1.getEntity(es1.getID());
|
|
|
248 |
List<Slide> slides = e.getSlides();
|
|
|
249 |
for(Slide slide:slides) {
|
|
|
250 |
FreeformContent ffc = slide.getFreeformContent();
|
|
|
251 |
if (ffc !=null){
|
|
|
252 |
Map<String,Media> m1 = ffc.getMedias();
|
|
|
253 |
if (m1!=null){
|
|
|
254 |
Map<String,Media> m = new LinkedHashMap<String, Media>(m1);
|
|
|
255 |
for (Map.Entry<String, Media> m2 : m.entrySet()){
|
|
|
256 |
m1.put(Long.toString(++counter), m1.remove(m2.getKey()));
|
|
|
257 |
updated = true;
|
|
|
258 |
}
|
| 8841 |
amit.gupta |
259 |
}
|
|
|
260 |
}
|
|
|
261 |
}
|
| 8865 |
amit.gupta |
262 |
if(updated){
|
|
|
263 |
CreationUtils.updateEntity(e);
|
|
|
264 |
System.out.println(e.getID());
|
|
|
265 |
}
|
|
|
266 |
} else {
|
|
|
267 |
buffer.append(es1.getID() + "\n");
|
| 8841 |
amit.gupta |
268 |
}
|
| 8749 |
amit.gupta |
269 |
}
|
|
|
270 |
}
|
| 8865 |
amit.gupta |
271 |
System.out.println("Entities counldnt be updated are :\n" + buffer.toString());
|
| 8749 |
amit.gupta |
272 |
}
|
|
|
273 |
|
|
|
274 |
private void migrateContentStore() throws Exception {
|
|
|
275 |
for (Map.Entry<Long, Entity> entry :CreationUtils.getEntities().entrySet()){
|
|
|
276 |
Entity e = entry.getValue();
|
|
|
277 |
Iterator<Slide> it = e.getSlides().iterator();
|
|
|
278 |
while(it.hasNext()){
|
|
|
279 |
Slide sl = it.next();
|
|
|
280 |
//sl.getFreeformContent().me
|
|
|
281 |
}
|
|
|
282 |
}
|
|
|
283 |
|
|
|
284 |
}
|
|
|
285 |
|
| 7590 |
amit.gupta |
286 |
private void updateSources() throws Exception{
|
|
|
287 |
Map<Long,List<ExpertReview>> erMap = CreationUtils.getExpertReviews();
|
|
|
288 |
for(Map.Entry<Long, List<ExpertReview>> erEntry : erMap.entrySet()){
|
|
|
289 |
List<ExpertReview> erList = erEntry.getValue();
|
|
|
290 |
Iterator<ExpertReview> iter = erList.iterator();
|
|
|
291 |
while (iter.hasNext()){
|
|
|
292 |
ExpertReview er = iter.next();
|
|
|
293 |
if (er.getSource().equals("iGyan")){
|
|
|
294 |
er.setSource("iGyaan");
|
|
|
295 |
System.out.println("changed to iGyaan in entity : " + erEntry.getKey());
|
|
|
296 |
}else if(er.getSource().equals("TheMobileIndian")){
|
|
|
297 |
er.setSource("The Mobile Indian");
|
|
|
298 |
System.out.println("changed to The Mobile Indian in entity : " + erEntry.getKey());
|
|
|
299 |
}
|
|
|
300 |
}
|
|
|
301 |
CreationUtils.storeExpertReview(erEntry.getKey(), erList);
|
|
|
302 |
}
|
|
|
303 |
}
|
| 7507 |
amit.gupta |
304 |
private void touchEntityState(Long eId) throws Exception {
|
|
|
305 |
EntityState es = CreationUtils.getEntityState(eId);
|
|
|
306 |
es.setMerkedReadyOn(new Date());
|
|
|
307 |
CreationUtils.updateEntityState(es);
|
| 9051 |
amit.gupta |
308 |
System.out.println("Entity touched:" + eId);
|
| 7507 |
amit.gupta |
309 |
}
|
| 8798 |
amit.gupta |
310 |
|
|
|
311 |
private void touchEntityStates() throws Exception {
|
|
|
312 |
Map<Long, EntityState> ess = CreationUtils.getEntitiesState();
|
|
|
313 |
Calendar calReady = Calendar.getInstance();
|
|
|
314 |
Calendar cal5daysBack = Calendar.getInstance();
|
|
|
315 |
Date today = new Date();
|
|
|
316 |
cal5daysBack.add(Calendar.DATE, -5);
|
|
|
317 |
for (Map.Entry<Long, EntityState> es : ess.entrySet()) {
|
|
|
318 |
EntityState est = es.getValue();
|
|
|
319 |
if(est.getMerkedReadyOn()!=null){
|
|
|
320 |
calReady.setTime(est.getMerkedReadyOn());
|
|
|
321 |
if(calReady.compareTo(cal5daysBack) > 0){
|
|
|
322 |
est.setMerkedReadyOn(today);
|
|
|
323 |
CreationUtils.updateEntityState(est);
|
|
|
324 |
System.out.println("Entity touched:" + est.getID());
|
|
|
325 |
}
|
|
|
326 |
}
|
|
|
327 |
}
|
|
|
328 |
}
|
| 7398 |
amit.gupta |
329 |
private void updateModelForBBQ10() throws Exception{
|
|
|
330 |
Long entityId = 1007315l;
|
|
|
331 |
EntityState e1 = CreationUtils.getEntityState(entityId);
|
|
|
332 |
Entity e2 = CreationUtils.getEntity(entityId);
|
| 7403 |
amit.gupta |
333 |
e1.setModelName("Blackkberry Q10");
|
|
|
334 |
e2.setModelName("Blackberry Q10");
|
| 7398 |
amit.gupta |
335 |
CreationUtils.updateEntity(e2);
|
|
|
336 |
CreationUtils.updateEntityState(e1);
|
|
|
337 |
}
|
| 4964 |
amit.gupta |
338 |
|
| 5671 |
amit.gupta |
339 |
private void migrateWarrantyForCategory(Long catgoryId) throws Exception {
|
|
|
340 |
Collection<Entity> entities = CreationUtils.getEntities(catgoryId);
|
|
|
341 |
int count = 0;
|
|
|
342 |
for (Entity entity : entities) {
|
|
|
343 |
Slide slide = entity.getSlide(130054l);
|
|
|
344 |
if(slide!=null){
|
|
|
345 |
List<Slide> childrenSlide = slide.getChildrenSlides();
|
| 5672 |
amit.gupta |
346 |
if(childrenSlide != null){
|
|
|
347 |
Iterator<Slide> it = childrenSlide.iterator();
|
|
|
348 |
while (it.hasNext()){
|
|
|
349 |
Slide sl = it.next();
|
|
|
350 |
if (130105l == sl.getSlideDefinitionID()){
|
|
|
351 |
it.remove();
|
|
|
352 |
System.out.println("Removed warranty slide from entity:" + entity.getID());
|
|
|
353 |
break;
|
|
|
354 |
}
|
| 5671 |
amit.gupta |
355 |
}
|
| 5672 |
amit.gupta |
356 |
CreationUtils.updateEntity(entity);
|
| 5671 |
amit.gupta |
357 |
}
|
|
|
358 |
}
|
|
|
359 |
}
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
private void checkYouTube() throws Exception {
|
|
|
363 |
// TODO Auto-generated method stub
|
|
|
364 |
Collection<Entity> entities = CreationUtils.getEntities().values();
|
|
|
365 |
//entities = (List<Entity>)this.clone(entities);
|
|
|
366 |
for (Entity entity : entities) {
|
|
|
367 |
long entityId = entity.getID();
|
|
|
368 |
try {
|
|
|
369 |
List<Slide> entitySlides = entity.getSlides();
|
|
|
370 |
if (entity == null || entitySlides == null) {
|
|
|
371 |
continue;
|
|
|
372 |
}
|
|
|
373 |
Slide summarySlide = null;
|
|
|
374 |
FreeformContent ffc = null;
|
|
|
375 |
|
|
|
376 |
List<Slide> newEntitySlides = new ArrayList<Slide>();
|
|
|
377 |
Slide connectivitySlide = new Slide(130129);
|
|
|
378 |
Slide looknfeelSlide = new Slide(130128);
|
|
|
379 |
for (Slide slide : entitySlides) {
|
|
|
380 |
ffc = slide.getFreeformContent();
|
|
|
381 |
if(ffc != null){
|
|
|
382 |
Map<String, Media> mediaMap = ffc.getMedias();
|
|
|
383 |
if(mediaMap!=null){
|
|
|
384 |
for(Media media : mediaMap.values()){
|
|
|
385 |
if(media.getType().equals(Type.VIDEO_WITHOUT_SKIN) || media.getType().equals(Type.VIDEO_WITH_SKIN)){
|
|
|
386 |
if(media.getYoutubeId().contains("&"))
|
|
|
387 |
System.out.println(entityId + " : " + media.getLabel() + ":" + media.getYoutubeId());
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
}catch(Exception e){
|
|
|
395 |
System.out.println("Could not migrate " + entityId);
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
}
|
|
|
401 |
|
| 4964 |
amit.gupta |
402 |
private void renameTitles() throws Exception {
|
|
|
403 |
Map<Long, Entity> map = CreationUtils.getEntities();
|
|
|
404 |
for (Long entityId : map.keySet()) {
|
|
|
405 |
Entity entity = map.get(entityId);
|
|
|
406 |
if (entity == null || entity.getSlides() == null) {
|
|
|
407 |
continue;
|
| 1314 |
rajveer |
408 |
}
|
| 4964 |
amit.gupta |
409 |
Slide summarySlide = entity.getSlide(130054);
|
|
|
410 |
if(summarySlide != null){
|
| 5760 |
amit.gupta |
411 |
boolean isupdated = false;
|
| 4964 |
amit.gupta |
412 |
for(Feature f : summarySlide.getFeatures()){
|
| 5760 |
amit.gupta |
413 |
if(f.getFeatureDefinitionID()==120132l){
|
|
|
414 |
if(f.getBullets() == null){
|
|
|
415 |
f.setBullets(new ArrayList<Bullet>());
|
| 12230 |
amit.gupta |
416 |
System.out.println("Found null for : " + entityId);
|
| 5760 |
amit.gupta |
417 |
}else {
|
| 12230 |
amit.gupta |
418 |
if(((PrimitiveDataObject)f.getBullets().get(0).getDataObject()).getValue().equals("")){
|
|
|
419 |
System.out.println("Found null for : " + entityId);
|
|
|
420 |
}
|
| 5760 |
amit.gupta |
421 |
f.getBullets().clear();
|
| 4964 |
amit.gupta |
422 |
}
|
| 5760 |
amit.gupta |
423 |
Bullet titleBullet = new Bullet(new PrimitiveDataObject(getTitle(entity)));
|
|
|
424 |
f.getBullets().add(titleBullet);
|
|
|
425 |
isupdated = true;
|
| 4964 |
amit.gupta |
426 |
continue;
|
|
|
427 |
}
|
| 5760 |
amit.gupta |
428 |
if(f.getFeatureDefinitionID()==120133l){
|
|
|
429 |
if(f.getBullets() == null){
|
|
|
430 |
f.setBullets(new ArrayList<Bullet>());
|
| 12230 |
amit.gupta |
431 |
System.out.println("Found null for : " + entityId);
|
| 5760 |
amit.gupta |
432 |
}else {
|
| 12230 |
amit.gupta |
433 |
if(((PrimitiveDataObject)f.getBullets().get(0).getDataObject()).getValue().equals("")){
|
|
|
434 |
System.out.println("Found null for : " + entityId);
|
|
|
435 |
}
|
| 5760 |
amit.gupta |
436 |
f.getBullets().clear();
|
|
|
437 |
}
|
|
|
438 |
Bullet metaDescBullet = new Bullet(new PrimitiveDataObject(getMetaDescription(new ExpandedEntity(entity))));
|
|
|
439 |
f.getBullets().add(metaDescBullet);
|
|
|
440 |
isupdated = true;
|
|
|
441 |
continue;
|
|
|
442 |
}
|
| 4964 |
amit.gupta |
443 |
}
|
| 5760 |
amit.gupta |
444 |
if(isupdated){
|
|
|
445 |
CreationUtils.updateEntity(entity);
|
|
|
446 |
System.out.println("Updated entity : " + entity.getID());
|
|
|
447 |
}
|
| 4964 |
amit.gupta |
448 |
}
|
| 1314 |
rajveer |
449 |
}
|
| 457 |
rajveer |
450 |
}
|
|
|
451 |
|
| 4818 |
amit.gupta |
452 |
private void migrateNetwork() throws Exception {
|
|
|
453 |
Map<Long, Entity> map = CreationUtils.getEntities();
|
| 4964 |
amit.gupta |
454 |
for (Long entityId : map.keySet()) {
|
|
|
455 |
Entity entity = map.get(entityId);
|
|
|
456 |
if (entity == null || entity.getSlides() == null) {
|
|
|
457 |
continue;
|
|
|
458 |
}
|
| 4818 |
amit.gupta |
459 |
|
| 4964 |
amit.gupta |
460 |
for (Slide slide : entity.getSlides()) {
|
| 5281 |
amit.gupta |
461 |
if (slide.getSlideDefinitionID() == 130095) {
|
|
|
462 |
List<Slide> slides = slide.getChildrenSlides();
|
|
|
463 |
for(Slide slide1 : slides){
|
|
|
464 |
if(slide1.getSlideDefinitionID() == 130096){
|
|
|
465 |
List<Feature> features = slide1.getFeatures();
|
|
|
466 |
for (Feature f : features) {
|
|
|
467 |
if (f.getFeatureDefinitionID() == 120175) {
|
|
|
468 |
List<Bullet> bs = f.getBullets();
|
|
|
469 |
for (Bullet b : bs) {
|
|
|
470 |
Long enumValueId = ((EnumDataObject) b
|
|
|
471 |
.getDataObject()).getEnumValueID();
|
|
|
472 |
String value = Catalog.getInstance().getDefinitionsContainer().getEnumValue(enumValueId).getValue();
|
|
|
473 |
if (value.trim().equals("")) {
|
|
|
474 |
continue;
|
|
|
475 |
}
|
|
|
476 |
System.out.println(value);
|
|
|
477 |
|
|
|
478 |
}
|
| 4964 |
amit.gupta |
479 |
}
|
|
|
480 |
}
|
|
|
481 |
}
|
|
|
482 |
}
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
}
|
|
|
486 |
|
|
|
487 |
CreationUtils.updateEntity(entity);
|
|
|
488 |
}
|
| 4818 |
amit.gupta |
489 |
}
|
| 5370 |
amit.gupta |
490 |
private void migrateHeadSet() throws Exception {
|
|
|
491 |
|
|
|
492 |
//Starting entity id for new Category with 10000
|
|
|
493 |
long newCounter = 77777000;
|
|
|
494 |
Collection<Entity> entities = CreationUtils.getEntities(10015);
|
|
|
495 |
|
|
|
496 |
//entities = (List<Entity>)this.clone(entities);
|
|
|
497 |
for (Entity entity : entities) {
|
|
|
498 |
long entityId = entity.getID();
|
|
|
499 |
try {
|
|
|
500 |
List<Slide> entitySlides = entity.getSlides();
|
|
|
501 |
if (entity == null || entitySlides == null) {
|
|
|
502 |
continue;
|
|
|
503 |
}
|
|
|
504 |
Slide summarySlide = null;
|
|
|
505 |
FreeformContent ffc = null;
|
|
|
506 |
|
|
|
507 |
List<Slide> newEntitySlides = new ArrayList<Slide>();
|
|
|
508 |
Slide connectivitySlide = new Slide(130129);
|
|
|
509 |
Slide looknfeelSlide = new Slide(130128);
|
|
|
510 |
for (Slide slide : entitySlides) {
|
|
|
511 |
slide=(Slide)this.clone(slide);
|
|
|
512 |
if (slide.getSlideDefinitionID() == 130068) {
|
|
|
513 |
List<Feature> connectivityFeatures = new ArrayList<Feature>();
|
|
|
514 |
List<Feature> looknfeelFeatures = new ArrayList<Feature>();
|
|
|
515 |
List<Feature> features = slide.getFeatures();
|
|
|
516 |
for (Feature f : features) {
|
|
|
517 |
if (f.getFeatureDefinitionID() == 120105) {
|
|
|
518 |
connectivityFeatures.add(f);
|
|
|
519 |
}
|
|
|
520 |
if (f.getFeatureDefinitionID() == 120106) {
|
|
|
521 |
looknfeelFeatures.add(f);
|
|
|
522 |
}
|
|
|
523 |
}
|
|
|
524 |
ffc = slide.getFreeformContent();
|
|
|
525 |
if(ffc != null){
|
|
|
526 |
Map<String, Media> mediaMap = ffc.getMedias();
|
|
|
527 |
if(mediaMap!=null){
|
|
|
528 |
for(Media media : mediaMap.values()){
|
|
|
529 |
if(media.getType().equals(Type.IMAGE) || media.getType().equals(Type.DOCUMENT)){
|
|
|
530 |
copyMedia(String.valueOf(newCounter), String.valueOf(entityId),media);
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
}
|
|
|
534 |
}
|
|
|
535 |
connectivitySlide.setFeatures(connectivityFeatures);
|
|
|
536 |
looknfeelSlide.setFeatures(looknfeelFeatures);
|
|
|
537 |
looknfeelSlide.setFreeformContent(ffc);
|
|
|
538 |
}
|
|
|
539 |
//Summary slide
|
|
|
540 |
if(slide.getSlideDefinitionID() == 130054) {
|
|
|
541 |
summarySlide = slide;
|
|
|
542 |
FreeformContent ffc1 = slide.getFreeformContent();
|
|
|
543 |
if(ffc1 != null){
|
|
|
544 |
Map<String, Media> mediaMap = ffc1.getMedias();
|
|
|
545 |
if(mediaMap==null){
|
|
|
546 |
continue;
|
|
|
547 |
}
|
|
|
548 |
for(Media media : mediaMap.values()){
|
|
|
549 |
if(media.getType().equals(Type.IMAGE) || media.getType().equals(Type.DOCUMENT)){
|
|
|
550 |
copyMedia(String.valueOf(newCounter), String.valueOf(entityId),media);
|
|
|
551 |
}
|
|
|
552 |
}
|
|
|
553 |
}
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
Entity newEntity = new Entity(newCounter, 10099);
|
| 5374 |
amit.gupta |
559 |
List<Long> newSlideSequence = new ArrayList<Long>();
|
|
|
560 |
newSlideSequence.add(130128L);
|
|
|
561 |
newSlideSequence.add(130129L);
|
|
|
562 |
newSlideSequence.add(130054L);
|
|
|
563 |
newEntity.setSlideSequence(newSlideSequence);
|
| 5370 |
amit.gupta |
564 |
newEntity.setBrand(entity.getBrand());
|
|
|
565 |
newEntity.setModelName(entity.getModelName());
|
|
|
566 |
newEntity.setModelNumber(entity.getModelNumber());
|
|
|
567 |
//entitySlides.remove(featureSlide);
|
|
|
568 |
newEntitySlides.add(connectivitySlide);
|
|
|
569 |
newEntitySlides.add(looknfeelSlide);
|
|
|
570 |
newEntitySlides.add(summarySlide);
|
|
|
571 |
newEntity.setSlides(newEntitySlides);
|
|
|
572 |
EntityState es = new EntityState(newCounter, 10099, "admin");
|
|
|
573 |
es.setBrand(entity.getBrand());
|
|
|
574 |
es.setModelName(entity.getModelName());
|
|
|
575 |
es.setModelNumber(entity.getModelNumber());
|
|
|
576 |
CreationUtils.createEntity(newEntity, es);
|
|
|
577 |
System.out.println("New entity : " + newCounter + " created using : " + entityId);
|
|
|
578 |
System.out.println(CreationUtils.getEntity(newCounter));
|
|
|
579 |
newCounter++;
|
|
|
580 |
}catch(Exception e){
|
|
|
581 |
System.out.println("Could not migrate " + entityId);
|
|
|
582 |
}
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
}
|
| 4818 |
amit.gupta |
586 |
|
|
|
587 |
private long getEnumValueForNetwork(String value, Long entityLong) {
|
|
|
588 |
value = value.toLowerCase().replaceAll(" ", "");
|
|
|
589 |
Map<String, Long> map = new HashMap<String, Long>();
|
| 4964 |
amit.gupta |
590 |
map.put("quadband(gsm850/900/1800/1900)", 110382L);
|
| 4818 |
amit.gupta |
591 |
map.put("quadband(gsm850/900/1800/1900)-sim1", 110383l);
|
|
|
592 |
map.put("quadband(gsm850/900/1800/1900)-sim2", 110384l);
|
|
|
593 |
map.put("triband(gsm900/1800/1900)", 110385l);
|
|
|
594 |
map.put("triband(gsm900/1800/1900)-sim1", 110386l);
|
|
|
595 |
map.put("triband(gsm900/1800/1900)-sim2", 110387l);
|
|
|
596 |
map.put("dualband(gsm900/1800)", 110388l);
|
|
|
597 |
map.put("dualband(gsm900/1800)-sim1", 110389l);
|
|
|
598 |
map.put("dualband(gsm900/1800)-sim2", 110390l);
|
| 4964 |
amit.gupta |
599 |
map.put("cdma800", 110391l); // CDMA 800
|
|
|
600 |
map.put("cdma800-sim2", 110392l); // CDMA 800-SIM 2
|
|
|
601 |
map.put("cdma800-sim3", 110393l); // CDMA 800-SIM 3
|
|
|
602 |
|
|
|
603 |
if (!StringUtils.contains(value, "sim")
|
|
|
604 |
&& StringUtils.contains(value, "850/900/1800/1900")) {
|
| 4818 |
amit.gupta |
605 |
return map.get("quadband(gsm850/900/1800/1900)");
|
|
|
606 |
}
|
| 4964 |
amit.gupta |
607 |
if (StringUtils.contains(value, "sim1")
|
|
|
608 |
&& StringUtils.contains(value, "850/900/1800/1900")) {
|
| 4818 |
amit.gupta |
609 |
return map.get("quadband(gsm850/900/1800/1900)-sim1");
|
|
|
610 |
}
|
| 4964 |
amit.gupta |
611 |
if (StringUtils.contains(value, "sim2")
|
|
|
612 |
&& StringUtils.contains(value, "850/900/1800/1900")) {
|
| 4818 |
amit.gupta |
613 |
return map.get("quadband(gsm850/900/1800/1900)-sim2");
|
|
|
614 |
}
|
| 4964 |
amit.gupta |
615 |
if (!StringUtils.contains(value, "sim")
|
|
|
616 |
&& StringUtils.contains(value, "900/1800/1900")) {
|
| 4818 |
amit.gupta |
617 |
return map.get("triband(gsm900/1800/1900)");
|
|
|
618 |
}
|
| 4964 |
amit.gupta |
619 |
if (StringUtils.contains(value, "sim1")
|
|
|
620 |
&& StringUtils.contains(value, "900/1800/1900")) {
|
| 4818 |
amit.gupta |
621 |
return map.get("triband(gsm900/1800/1900)-sim1");
|
|
|
622 |
}
|
| 4964 |
amit.gupta |
623 |
if (StringUtils.contains(value, "sim2")
|
|
|
624 |
&& StringUtils.contains(value, "900/1800/1900")) {
|
| 4818 |
amit.gupta |
625 |
return map.get("triband(gsm900/1800/1900)-sim2");
|
|
|
626 |
}
|
| 4964 |
amit.gupta |
627 |
if (!StringUtils.contains(value, "sim")
|
|
|
628 |
&& StringUtils.contains(value, "900/1800")) {
|
| 4818 |
amit.gupta |
629 |
return map.get("dualband(gsm900/1800)");
|
|
|
630 |
}
|
| 4964 |
amit.gupta |
631 |
if (StringUtils.contains(value, "sim1")
|
|
|
632 |
&& StringUtils.contains(value, "900/1800")) {
|
| 4818 |
amit.gupta |
633 |
return map.get("dualband(gsm900/1800)-sim1");
|
|
|
634 |
}
|
| 4964 |
amit.gupta |
635 |
if (StringUtils.contains(value, "sim2")
|
|
|
636 |
&& StringUtils.contains(value, "900/1800")) {
|
| 4818 |
amit.gupta |
637 |
return map.get("dualband(gsm900/1800)-sim2");
|
|
|
638 |
}
|
| 4964 |
amit.gupta |
639 |
if (StringUtils.contains(value, "cdma")) {
|
|
|
640 |
if (StringUtils.contains(value, "sim2")) {
|
| 4818 |
amit.gupta |
641 |
return map.get("cdma800-sim2");
|
|
|
642 |
}
|
| 4964 |
amit.gupta |
643 |
if (StringUtils.contains(value, "sim3")) {
|
| 4818 |
amit.gupta |
644 |
return map.get("cdma800-sim3");
|
|
|
645 |
}
|
|
|
646 |
return map.get("cdma800");
|
| 4964 |
amit.gupta |
647 |
} else {
|
|
|
648 |
System.out.println("Unknown networks: " + value + " : "
|
|
|
649 |
+ entityLong);
|
| 4818 |
amit.gupta |
650 |
return 0;
|
|
|
651 |
}
|
|
|
652 |
}
|
|
|
653 |
|
| 457 |
rajveer |
654 |
public ContentMigrator(String sourceDbPath, String destinationDbPath) {
|
| 4964 |
amit.gupta |
655 |
this.sourceDbPath = sourceDbPath;
|
| 457 |
rajveer |
656 |
this.destinationDbPath = destinationDbPath;
|
|
|
657 |
}
|
| 2720 |
mandeep.dh |
658 |
|
| 3873 |
mandeep.dh |
659 |
public void migrateWarrantyType() throws Exception {
|
| 4964 |
amit.gupta |
660 |
Map<Long, Entity> map = CreationUtils.getEntities();
|
|
|
661 |
for (Long entityId : map.keySet()) {
|
|
|
662 |
Entity entity = map.get(entityId);
|
|
|
663 |
if (entity == null || entity.getSlides() == null) {
|
|
|
664 |
continue;
|
|
|
665 |
}
|
|
|
666 |
for (Slide slide : entity.getSlides()) {
|
|
|
667 |
if (slide.getSlideDefinitionID() == 130054) {
|
|
|
668 |
Slide warrantySlide = new Slide(130105);
|
|
|
669 |
warrantySlide.setFeatures(new ArrayList<Feature>());
|
| 3873 |
mandeep.dh |
670 |
|
| 4964 |
amit.gupta |
671 |
Feature feature = new Feature(120219);
|
|
|
672 |
feature.setBullets(Collections.singletonList(new Bullet(
|
|
|
673 |
new EnumDataObject(110299))));
|
|
|
674 |
warrantySlide.getFeatures().add(feature);
|
| 3873 |
mandeep.dh |
675 |
|
| 4964 |
amit.gupta |
676 |
Feature existingWarrantyFeature = null;
|
|
|
677 |
for (Feature summaryFeature : slide.getFeatures()) {
|
|
|
678 |
if (summaryFeature.getFeatureDefinitionID() == 120125) {
|
|
|
679 |
existingWarrantyFeature = summaryFeature;
|
|
|
680 |
warrantySlide.getFeatures().add(summaryFeature);
|
|
|
681 |
break;
|
|
|
682 |
}
|
|
|
683 |
}
|
| 3873 |
mandeep.dh |
684 |
|
| 4964 |
amit.gupta |
685 |
slide.getFeatures().remove(existingWarrantyFeature);
|
|
|
686 |
slide.addChild(warrantySlide);
|
|
|
687 |
break;
|
|
|
688 |
}
|
|
|
689 |
|
|
|
690 |
}
|
|
|
691 |
|
|
|
692 |
CreationUtils.updateEntity(entity);
|
|
|
693 |
}
|
| 3873 |
mandeep.dh |
694 |
}
|
|
|
695 |
|
| 2720 |
mandeep.dh |
696 |
public void migrateMedia() throws Exception {
|
| 4964 |
amit.gupta |
697 |
Map<Long, Entity> map = CreationUtils.getEntities();
|
|
|
698 |
for (Long entityId : map.keySet()) {
|
|
|
699 |
Entity entity = map.get(entityId);
|
|
|
700 |
if (entity == null || entity.getSlides() == null) {
|
|
|
701 |
continue;
|
|
|
702 |
}
|
|
|
703 |
for (Slide slide : entity.getSlides()) {
|
|
|
704 |
FreeformContent ffc = slide.getFreeformContent();
|
| 2720 |
mandeep.dh |
705 |
|
| 4964 |
amit.gupta |
706 |
// if (ffc == null || ffc.getMediasNew() == null) {
|
|
|
707 |
// continue;
|
|
|
708 |
// }
|
|
|
709 |
//
|
|
|
710 |
// Map<String, Media> newMap = new LinkedHashMap<String,
|
|
|
711 |
// Media>();
|
|
|
712 |
// Media media = null;
|
|
|
713 |
// for (String label : ffc.getMediasNew().keySet()) {
|
|
|
714 |
// MediaNew m = ffc.getMediasNew().get(label);
|
|
|
715 |
// media = new Media(m.getLabel(), Media.Type.valueOf(m
|
|
|
716 |
// .getType().name()), m.getLocation());
|
|
|
717 |
// media.setTitle(m.getTitle());
|
|
|
718 |
// media.setFileName(m.getFileName());
|
|
|
719 |
// newMap.put(label, media);
|
|
|
720 |
// }
|
|
|
721 |
// ffc.setMedias(newMap);
|
|
|
722 |
// ffc.setMediasNew(null);
|
| 2720 |
mandeep.dh |
723 |
|
| 4964 |
amit.gupta |
724 |
// if (ffc == null || ffc.getMedias() == null) {
|
|
|
725 |
// continue;
|
|
|
726 |
// }
|
|
|
727 |
// Map<String, MediaNew> newMap = new LinkedHashMap<String,
|
|
|
728 |
// MediaNew>();
|
|
|
729 |
// MediaNew mediaNew = null;
|
|
|
730 |
// for (String label : ffc.getMedias().keySet()) {
|
|
|
731 |
// Media m = ffc.getMedias().get(label);
|
|
|
732 |
// if (m.getType().equalsIgnoreCase("image")) {
|
|
|
733 |
// mediaNew = new MediaNew(m.getLabel(),
|
|
|
734 |
// MediaNew.Type.IMAGE, m.getLocation());
|
|
|
735 |
// mediaNew.setFileName(m.getFileName());
|
|
|
736 |
// } else if (m.getType().equalsIgnoreCase("youtube")) {
|
|
|
737 |
// if (m.getVideoType().equalsIgnoreCase("withskin")) {
|
|
|
738 |
// mediaNew = new MediaNew(m.getLabel(),
|
|
|
739 |
// MediaNew.Type.VIDEO_WITH_SKIN,
|
|
|
740 |
// m.getLocation());
|
|
|
741 |
// } else {
|
|
|
742 |
// mediaNew = new MediaNew(m.getLabel(),
|
|
|
743 |
// MediaNew.Type.VIDEO_WITHOUT_SKIN,
|
|
|
744 |
// m.getLocation());
|
|
|
745 |
// }
|
|
|
746 |
// }
|
|
|
747 |
//
|
|
|
748 |
// if (mediaNew != null) {
|
|
|
749 |
// mediaNew.setTitle(m.getTitle());
|
|
|
750 |
// newMap.put(label, mediaNew);
|
|
|
751 |
// }
|
|
|
752 |
// }
|
|
|
753 |
// ffc.setMediasNew(newMap);
|
|
|
754 |
// ffc.setMedias(null);
|
|
|
755 |
}
|
|
|
756 |
}
|
| 2720 |
mandeep.dh |
757 |
}
|
|
|
758 |
|
| 4964 |
amit.gupta |
759 |
public boolean populateHelpdocEntityIds() throws Exception {
|
|
|
760 |
for (Entity entity : CreationUtils.getEntities().values()) {
|
| 2471 |
rajveer |
761 |
CreationUtils.updateEntity(entity);
|
|
|
762 |
}
|
|
|
763 |
return true;
|
|
|
764 |
}
|
| 2720 |
mandeep.dh |
765 |
|
| 4964 |
amit.gupta |
766 |
public boolean migrateBrandModel(String dryRun) throws Exception {
|
| 3127 |
rajveer |
767 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 2287 |
rajveer |
768 |
Client client = catalogServiceClient.getClient();
|
|
|
769 |
List<Item> items = client.getAllItemsByStatus(status.ACTIVE);
|
|
|
770 |
items.addAll(client.getAllItemsByStatus(status.PAUSED));
|
|
|
771 |
items.addAll(client.getAllItemsByStatus(status.CONTENT_COMPLETE));
|
|
|
772 |
Map<Long, Entity> entities = CreationUtils.getEntities();
|
|
|
773 |
long count = 0;
|
|
|
774 |
StringBuffer sb = new StringBuffer();
|
| 4964 |
amit.gupta |
775 |
for (Item item : items) {
|
| 2287 |
rajveer |
776 |
long entityId = item.getCatalogItemId();
|
|
|
777 |
Entity entity = entities.get(entityId);
|
| 4964 |
amit.gupta |
778 |
if (entity == null) {
|
| 2292 |
rajveer |
779 |
continue;
|
|
|
780 |
}
|
| 2294 |
rajveer |
781 |
String itemBrand = item.getBrand().trim();
|
| 2287 |
rajveer |
782 |
String itemModelName = item.getModelName();
|
| 4964 |
amit.gupta |
783 |
if (itemModelName != null) {
|
| 2294 |
rajveer |
784 |
itemModelName = itemModelName.trim();
|
|
|
785 |
}
|
|
|
786 |
String itemModelNumber = item.getModelNumber().trim();
|
|
|
787 |
String entityBrand = entity.getBrand().trim();
|
|
|
788 |
String entityModelName = entity.getModelName().trim();
|
| 4964 |
amit.gupta |
789 |
if (entityModelName != null) {
|
| 2294 |
rajveer |
790 |
entityModelName = entityModelName.trim();
|
|
|
791 |
}
|
|
|
792 |
String entityModelNumber = entity.getModelNumber().trim();
|
| 4964 |
amit.gupta |
793 |
|
|
|
794 |
if (itemBrand.equals(entityBrand)
|
|
|
795 |
&& itemModelNumber.equals(entityModelNumber)) {
|
|
|
796 |
if (itemModelName != null && entityModelName != null
|
|
|
797 |
&& itemModelName.equals(entityModelName)) {
|
| 2292 |
rajveer |
798 |
continue;
|
| 4964 |
amit.gupta |
799 |
} else if (itemModelName == null && entityModelName == null) {
|
|
|
800 |
continue;
|
| 2292 |
rajveer |
801 |
}
|
| 4964 |
amit.gupta |
802 |
|
| 2287 |
rajveer |
803 |
}
|
|
|
804 |
count++;
|
| 4964 |
amit.gupta |
805 |
sb.append(count + ") Item: " + itemBrand + "\t" + itemModelName
|
|
|
806 |
+ "\t" + itemModelNumber + "\t" + item.getId() + "\n");
|
|
|
807 |
sb.append(count + ") Entity: " + entityBrand + "\t"
|
|
|
808 |
+ entityModelName + "\t" + entityModelNumber + "\t"
|
|
|
809 |
+ entity.getID() + "\n");
|
|
|
810 |
|
|
|
811 |
if (dryRun.equals("false")) {
|
| 2294 |
rajveer |
812 |
item.setBrand(entityBrand);
|
|
|
813 |
item.setModelName(entityModelName);
|
|
|
814 |
item.setModelNumber(entityModelNumber);
|
| 4964 |
amit.gupta |
815 |
client.updateItem(item);
|
| 2287 |
rajveer |
816 |
}
|
|
|
817 |
}
|
|
|
818 |
System.out.println(sb.toString());
|
|
|
819 |
return true;
|
|
|
820 |
}
|
| 2720 |
mandeep.dh |
821 |
|
| 473 |
rajveer |
822 |
/**
|
| 4964 |
amit.gupta |
823 |
* this function will read source definition and source entities, and will
|
|
|
824 |
* convert source entities to destination entities according to destination
|
|
|
825 |
* definitions.
|
| 473 |
rajveer |
826 |
*
|
|
|
827 |
* @return boolean
|
| 4964 |
amit.gupta |
828 |
* @throws Exception
|
| 473 |
rajveer |
829 |
*/
|
| 1226 |
rajveer |
830 |
|
| 4964 |
amit.gupta |
831 |
public void printSlides() throws Exception {
|
|
|
832 |
DefinitionsContainer defc = Catalog.getInstance()
|
|
|
833 |
.getDefinitionsContainer();
|
|
|
834 |
for (Category category : defc.getCategories().values()) {
|
|
|
835 |
if (category.getChildrenCategory() != null)
|
|
|
836 |
continue;
|
|
|
837 |
System.out.println(category.getID() + "\t" + category.getLabel());
|
|
|
838 |
for (CategorySlideDefinition defs : defc
|
|
|
839 |
.getCategorySlideDefinitions(category.getID())) {
|
|
|
840 |
System.out.println(defs.getSlideDefintionID()
|
|
|
841 |
+ "\t"
|
|
|
842 |
+ defs.getEditorialImportance()
|
|
|
843 |
+ "\t"
|
|
|
844 |
+ defc.getSlideDefinition(defs.getSlideDefintionID())
|
|
|
845 |
.getLabel()
|
|
|
846 |
+ "\t"
|
|
|
847 |
+ defc.getSlideDefinition(defs.getSlideDefintionID())
|
|
|
848 |
.getChildrenSlideDefinitionIDs());
|
| 1226 |
rajveer |
849 |
}
|
|
|
850 |
}
|
|
|
851 |
}
|
| 4964 |
amit.gupta |
852 |
|
|
|
853 |
public void removeBrowserBullets() throws Exception {
|
|
|
854 |
Map<Long, List<ExpandedBullet>> learnedBullets = CreationUtils
|
|
|
855 |
.getLearnedBullets();
|
| 1226 |
rajveer |
856 |
learnedBullets.get(new Long(120076));
|
|
|
857 |
learnedBullets.remove(new Long(120076));
|
|
|
858 |
CreationUtils.storeLearnedBullets(learnedBullets);
|
| 4964 |
amit.gupta |
859 |
|
| 1226 |
rajveer |
860 |
}
|
| 4964 |
amit.gupta |
861 |
|
|
|
862 |
public boolean changeEntityState() throws Exception {
|
| 1226 |
rajveer |
863 |
Map<Long, EntityState> entitiesState = CreationUtils.getEntitiesState();
|
| 8548 |
amit.gupta |
864 |
Entity entity;
|
| 4964 |
amit.gupta |
865 |
for (Long entityId : entitiesState.keySet()) {
|
| 1226 |
rajveer |
866 |
EntityState state = entitiesState.get(entityId);
|
| 8548 |
amit.gupta |
867 |
entity = CreationUtils.getEntity(entityId);
|
|
|
868 |
if (state.getCategoryID() == 10006) {
|
|
|
869 |
//state.setCategoryID(10006);
|
|
|
870 |
entity.setCategoryID(10006);
|
|
|
871 |
//CreationUtils.updateEntityState(state);
|
|
|
872 |
CreationUtils.updateEntity(entity);
|
| 8510 |
amit.gupta |
873 |
touchEntityState(entityId);
|
| 1226 |
rajveer |
874 |
}
|
|
|
875 |
}
|
|
|
876 |
return true;
|
|
|
877 |
}
|
| 1739 |
rajveer |
878 |
|
| 4964 |
amit.gupta |
879 |
public boolean migrateDataBack() throws Exception {
|
| 1226 |
rajveer |
880 |
Map<Long, Entity> entities = CreationUtils.getEntities();
|
| 4964 |
amit.gupta |
881 |
for (Entity entity : entities.values()) {
|
|
|
882 |
if (entity == null) {
|
|
|
883 |
continue;
|
|
|
884 |
}
|
| 1226 |
rajveer |
885 |
List<Slide> slides = entity.getSlides();
|
| 4964 |
amit.gupta |
886 |
if (slides != null) {
|
|
|
887 |
for (Slide slide : slides) {
|
|
|
888 |
if (slide.getSlideDefinitionID() == 130054) {
|
|
|
889 |
List<Feature> features = slide.getFeatures();
|
|
|
890 |
int length = features.size();
|
|
|
891 |
features.remove(length - 1);
|
|
|
892 |
features.remove(length - 2);
|
|
|
893 |
features.remove(length - 3);
|
|
|
894 |
/*
|
|
|
895 |
* boolean a = false,b=false,c=false; for(Feature
|
|
|
896 |
* feature: features){ switch
|
|
|
897 |
* ((int)feature.getFeatureDefinitionID()) { case
|
|
|
898 |
* 120132: if(a){
|
|
|
899 |
*
|
|
|
900 |
* }else{ a=true; } break; case 120133: break; case
|
|
|
901 |
* 120134: break; default: break; } }
|
|
|
902 |
*/
|
|
|
903 |
CreationUtils.updateEntity(entity);
|
| 1226 |
rajveer |
904 |
}
|
|
|
905 |
}
|
|
|
906 |
}
|
|
|
907 |
}
|
| 4964 |
amit.gupta |
908 |
return true;
|
| 1226 |
rajveer |
909 |
}
|
| 4964 |
amit.gupta |
910 |
|
|
|
911 |
public boolean migrateData() throws Exception {
|
| 1226 |
rajveer |
912 |
Map<Long, Entity> entities = CreationUtils.getEntities();
|
| 4964 |
amit.gupta |
913 |
for (Entity entity : entities.values()) {
|
|
|
914 |
ExpandedEntity expEntity = new ExpandedEntity(entity);
|
| 1226 |
rajveer |
915 |
List<Slide> slides = entity.getSlides();
|
| 4964 |
amit.gupta |
916 |
if (slides != null) {
|
|
|
917 |
for (Slide slide : slides) {
|
|
|
918 |
if (slide.getSlideDefinitionID() == 130054) {
|
|
|
919 |
List<Feature> features = slide.getFeatures();
|
|
|
920 |
String title = expEntity.getBrand() + " "
|
|
|
921 |
+ expEntity.getModelName() + " "
|
|
|
922 |
+ expEntity.getModelNumber();
|
|
|
923 |
if (expEntity.getCategory().getParentCategory().getID() == 10001) {
|
|
|
924 |
title += " | " + expEntity.getBrand()
|
|
|
925 |
+ " Mobile Phones";
|
| 1226 |
rajveer |
926 |
}
|
| 4964 |
amit.gupta |
927 |
if (expEntity.getCategory().getParentCategory().getID() == 10011) {
|
|
|
928 |
title += " " + expEntity.getCategory().getLabel()
|
|
|
929 |
+ " | " + expEntity.getBrand()
|
|
|
930 |
+ " Mobile Phone Accessories";
|
| 1226 |
rajveer |
931 |
}
|
| 4964 |
amit.gupta |
932 |
title += " | Saholic.com";
|
|
|
933 |
|
|
|
934 |
// Add page title
|
|
|
935 |
Feature feature1 = new Feature(120132);
|
|
|
936 |
PrimitiveDataObject pdo1 = new PrimitiveDataObject(
|
|
|
937 |
title);
|
|
|
938 |
List<Bullet> bullets1 = new ArrayList<Bullet>();
|
|
|
939 |
Bullet bullet1 = new Bullet(pdo1);
|
|
|
940 |
bullets1.add(bullet1);
|
|
|
941 |
feature1.setBullets(bullets1);
|
|
|
942 |
features.add(feature1);
|
|
|
943 |
|
|
|
944 |
String description = "Best Price "
|
|
|
945 |
+ expEntity.getBrand() + " "
|
|
|
946 |
+ expEntity.getModelName() + " "
|
|
|
947 |
+ expEntity.getModelNumber() + " ";
|
|
|
948 |
|
|
|
949 |
if (expEntity.getCategory().getParentCategory().getID() == 10011) {
|
|
|
950 |
description += expEntity.getCategory().getLabel()
|
|
|
951 |
+ " in India.";
|
|
|
952 |
} else {
|
|
|
953 |
description += ".";
|
| 1226 |
rajveer |
954 |
}
|
| 4964 |
amit.gupta |
955 |
description += " Experience n' buy online. FREE Next Day delivery."
|
|
|
956 |
+ " Original product - Full manufacturer warranty. Comprehensive reviews.";
|
| 1226 |
rajveer |
957 |
|
| 4964 |
amit.gupta |
958 |
description = description.replaceAll("--", "-");
|
|
|
959 |
|
|
|
960 |
// Add meta description
|
|
|
961 |
Feature feature2 = new Feature(120133);
|
|
|
962 |
PrimitiveDataObject pdo2 = new PrimitiveDataObject(
|
|
|
963 |
description);
|
|
|
964 |
List<Bullet> bullets2 = new ArrayList<Bullet>();
|
|
|
965 |
Bullet bullet2 = new Bullet(pdo2);
|
|
|
966 |
bullets2.add(bullet2);
|
|
|
967 |
feature2.setBullets(bullets2);
|
|
|
968 |
|
|
|
969 |
features.add(feature2);
|
|
|
970 |
|
|
|
971 |
String keywords = expEntity.getBrand() + " "
|
|
|
972 |
+ expEntity.getModelName() + " "
|
|
|
973 |
+ expEntity.getModelNumber() + ", ";
|
|
|
974 |
if (expEntity.getCategory().getParentCategory().getID() == 10001) {
|
|
|
975 |
keywords += expEntity.getBrand()
|
|
|
976 |
+ " mobile phones, ";
|
| 1226 |
rajveer |
977 |
}
|
| 4964 |
amit.gupta |
978 |
if (expEntity.getCategory().getParentCategory().getID() == 10011) {
|
|
|
979 |
keywords += "phone accessories, ";
|
| 1226 |
rajveer |
980 |
}
|
| 4964 |
amit.gupta |
981 |
keywords += expEntity.getBrand() + " "
|
|
|
982 |
+ expEntity.getModelName() + " "
|
|
|
983 |
+ expEntity.getModelNumber() + " Price, ";
|
|
|
984 |
keywords += expEntity.getBrand() + " "
|
|
|
985 |
+ expEntity.getModelName() + " "
|
|
|
986 |
+ expEntity.getModelNumber() + " India, ";
|
|
|
987 |
if (expEntity.getCategory().getParentCategory().getID() == 10001) {
|
|
|
988 |
keywords += expEntity.getBrand() + " "
|
|
|
989 |
+ expEntity.getModelName() + " "
|
|
|
990 |
+ expEntity.getModelNumber() + " Review, ";
|
| 1226 |
rajveer |
991 |
}
|
| 4964 |
amit.gupta |
992 |
// Add meta keyborad
|
|
|
993 |
Feature feature3 = new Feature(120134);
|
|
|
994 |
PrimitiveDataObject pdo3 = new PrimitiveDataObject(
|
|
|
995 |
keywords);
|
|
|
996 |
List<Bullet> bullets3 = new ArrayList<Bullet>();
|
|
|
997 |
Bullet bullet3 = new Bullet(pdo3);
|
|
|
998 |
bullets3.add(bullet3);
|
|
|
999 |
feature3.setBullets(bullets3);
|
|
|
1000 |
|
|
|
1001 |
features.add(feature3);
|
|
|
1002 |
|
|
|
1003 |
CreationUtils.updateEntity(entity);
|
|
|
1004 |
}
|
|
|
1005 |
}
|
|
|
1006 |
}
|
|
|
1007 |
}
|
|
|
1008 |
return true;
|
|
|
1009 |
}
|
|
|
1010 |
|
|
|
1011 |
public boolean migrateModel2() throws Exception {
|
|
|
1012 |
Map<Long, Entity> entities = CreationUtils.getEntities();
|
|
|
1013 |
for (Entity entity : entities.values()) {
|
|
|
1014 |
List<Slide> slides = entity.getSlides();
|
|
|
1015 |
if (slides != null) {
|
|
|
1016 |
for (Slide slide : slides) {
|
|
|
1017 |
if (slide.getSlideDefinitionID() == 130011) {
|
|
|
1018 |
for (Feature feature : slide.getFeatures()) {
|
|
|
1019 |
if (feature.getFeatureDefinitionID() == 120054) {
|
|
|
1020 |
// feature.setFeatureDefinitionID(120030);
|
|
|
1021 |
System.out.println("* " + entity.getID() + ":"
|
|
|
1022 |
+ entity.getCategoryID());
|
| 1226 |
rajveer |
1023 |
}
|
|
|
1024 |
}
|
| 4964 |
amit.gupta |
1025 |
}
|
| 1226 |
rajveer |
1026 |
|
| 4964 |
amit.gupta |
1027 |
if (slide.getSlideDefinitionID() == 130029) {
|
|
|
1028 |
// System.out.println("** " + entity.getID() + ":" +
|
|
|
1029 |
// entity.getCategoryID());
|
|
|
1030 |
if (entity.getCategoryID() == 10002) {
|
|
|
1031 |
Feature feature = new Feature(120051);
|
|
|
1032 |
slide.getFeatures().add(feature);
|
|
|
1033 |
System.out.println("** " + entity.getID() + ":"
|
|
|
1034 |
+ entity.getCategoryID());
|
| 1226 |
rajveer |
1035 |
}
|
|
|
1036 |
}
|
|
|
1037 |
|
|
|
1038 |
}
|
|
|
1039 |
}
|
| 4964 |
amit.gupta |
1040 |
CreationUtils.updateEntity(entity);
|
| 1226 |
rajveer |
1041 |
}
|
|
|
1042 |
return true;
|
|
|
1043 |
}
|
| 4964 |
amit.gupta |
1044 |
|
|
|
1045 |
/*
|
|
|
1046 |
* public boolean migrateModel1() throws Exception{ //DefinitionsContainer
|
|
|
1047 |
* oldDfc = new DefinitionsContainer(Utils.CONTENT_DB_PATH +
|
|
|
1048 |
* "olddefinitions" + File.separator); //DefinitionsContainer newDfc = new
|
|
|
1049 |
* DefinitionsContainer(Utils.CONTENT_DB_PATH + "olddefinitions" +
|
|
|
1050 |
* File.separator);
|
|
|
1051 |
*
|
|
|
1052 |
* Map<Long, Entity> entities = CreationUtils.getEntities(); for(Entity
|
|
|
1053 |
* entity: entities.values()){ List<Long> slideSequence =
|
|
|
1054 |
* entity.getSlideSequence(); Map<Long,Long> removeMap = new HashMap<Long,
|
|
|
1055 |
* Long>(); List<Slide> slides = entity.getSlides(); if(slides!=null){
|
|
|
1056 |
* for(Slide slide: slides){ List<Feature> features; Slide childSlide;
|
|
|
1057 |
* switch ((int)slide.getSlideDefinitionID()) {
|
|
|
1058 |
*
|
|
|
1059 |
* //Keyboard case 130004: case 130026: case 130027: case 130057:
|
|
|
1060 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130026);
|
|
|
1061 |
* slide.setSlideDefinitionID(130026); break;
|
|
|
1062 |
*
|
|
|
1063 |
* //Voice Calling case 130005: removeMap.put(slide.getSlideDefinitionID(),
|
|
|
1064 |
* (long)130005); slide.setSlideDefinitionID(130005); features = new
|
|
|
1065 |
* ArrayList<Feature>(); features.addAll(slide.getFeatures()); childSlide =
|
|
|
1066 |
* slide.getChildrenSlides().get(0);
|
|
|
1067 |
* features.addAll(childSlide.getFeatures());
|
|
|
1068 |
* if(childSlide.getFreeformContent()!=null){
|
|
|
1069 |
* System.out.println("Voice Calling : HAS FFC : " +
|
|
|
1070 |
* childSlide.getFreeformContent().getFreeformText() +
|
|
|
1071 |
* childSlide.getFreeformContent().getMedias()); }
|
|
|
1072 |
* slide.setChildrenSlides(null); slide.setFeatures(features); break; case
|
|
|
1073 |
* 130035: removeMap.put(slide.getSlideDefinitionID(), (long)130005);
|
|
|
1074 |
* slide.setSlideDefinitionID(130005); for(Feature feata:
|
|
|
1075 |
* slide.getFeatures()){ if(feata.getFeatureDefinitionID()==120055){
|
|
|
1076 |
* feata.setFeatureDefinitionID(120012); } } break;
|
|
|
1077 |
*
|
|
|
1078 |
* //Data Connectivity case 130007: case 130028:
|
|
|
1079 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130007);
|
|
|
1080 |
* slide.setSlideDefinitionID(130007); break;
|
|
|
1081 |
*
|
|
|
1082 |
* //Music case 130029: case 130030: case 130008:
|
|
|
1083 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130029);
|
|
|
1084 |
* slide.setSlideDefinitionID(130029); break;
|
|
|
1085 |
*
|
|
|
1086 |
* //Video case 130031: case 130009:
|
|
|
1087 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130031);
|
|
|
1088 |
* slide.setSlideDefinitionID(130031); break;
|
|
|
1089 |
*
|
|
|
1090 |
* //Camera case 130010: case 130036: case 130037:
|
|
|
1091 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130010);
|
|
|
1092 |
* slide.setSlideDefinitionID(130010); break; case 130060:
|
|
|
1093 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130010);
|
|
|
1094 |
* slide.setSlideDefinitionID(130010);
|
|
|
1095 |
*
|
|
|
1096 |
* features = slide.getFeatures(); // Just to add camera feature in basic
|
|
|
1097 |
* phones Feature feature = new Feature(120056); List<Bullet> bullets = new
|
|
|
1098 |
* ArrayList<Bullet>(); PrimitiveDataObject pdo = new
|
|
|
1099 |
* PrimitiveDataObject("1"); Bullet bullet = new Bullet(pdo);
|
|
|
1100 |
* bullets.add(bullet); feature.setBullets(bullets); features.add(feature);
|
|
|
1101 |
* //Created new feature break;
|
|
|
1102 |
*
|
|
|
1103 |
* //Memory case 130011: removeMap.put(slide.getSlideDefinitionID(),
|
|
|
1104 |
* (long)130011); slide.setSlideDefinitionID(130011); break; case 130032:
|
|
|
1105 |
* case 130061: removeMap.put(slide.getSlideDefinitionID(), (long)130011);
|
|
|
1106 |
* slide.setSlideDefinitionID(130011); features = slide.getFeatures();
|
|
|
1107 |
* for(Feature feat: features){ if(feat.getFeatureDefinitionID() == 120054){
|
|
|
1108 |
* feat.setFeatureDefinitionID(120030); } } break;
|
|
|
1109 |
*
|
|
|
1110 |
* //Battery case 130044: removeMap.put(slide.getSlideDefinitionID(),
|
|
|
1111 |
* (long)130043); slide.setSlideDefinitionID(130043);
|
|
|
1112 |
* if(slide.getChildrenSlides().get(0).getSlideDefinitionID() == 130047){
|
|
|
1113 |
* slide.getChildrenSlides().get(0).setSlideDefinitionID(130046); } break;
|
|
|
1114 |
*
|
|
|
1115 |
* case 130042: removeMap.put(slide.getSlideDefinitionID(), (long)130043);
|
|
|
1116 |
* slide.setSlideDefinitionID(130043); childSlide =
|
|
|
1117 |
* slide.getChildrenSlides().get(0); if(childSlide.getSlideDefinitionID() ==
|
|
|
1118 |
* 130045){ childSlide.setSlideDefinitionID(130046); }
|
|
|
1119 |
*
|
|
|
1120 |
* List<Feature> childFeatures1 = new ArrayList<Feature>(); List<Feature>
|
|
|
1121 |
* childFeatures2 = new ArrayList<Feature>(); Slide childChildSlide1 = new
|
|
|
1122 |
* Slide(130048); Slide childChildSlide2 = new Slide(130049);
|
|
|
1123 |
*
|
|
|
1124 |
* childChildSlide1.setFeatures(childFeatures1);
|
|
|
1125 |
* childChildSlide2.setFeatures(childFeatures2);
|
|
|
1126 |
*
|
|
|
1127 |
* childSlide.addChild(childChildSlide1);
|
|
|
1128 |
* childSlide.addChild(childChildSlide2);
|
|
|
1129 |
*
|
|
|
1130 |
*
|
|
|
1131 |
* for(Feature f: childSlide.getFeatures()){ if(f.getFeatureDefinitionID()
|
|
|
1132 |
* == 120063){ f.setFeatureDefinitionID(120068); childFeatures1.add(f); }
|
|
|
1133 |
* if(f.getFeatureDefinitionID() == 120064){
|
|
|
1134 |
* f.setFeatureDefinitionID(120069); childFeatures2.add(f); } }
|
|
|
1135 |
*
|
|
|
1136 |
* childSlide.setFeatures(null);
|
|
|
1137 |
*
|
|
|
1138 |
* break;
|
|
|
1139 |
*
|
|
|
1140 |
* case 130062: removeMap.put(slide.getSlideDefinitionID(), (long)130043);
|
|
|
1141 |
* slide.setSlideDefinitionID(130043);
|
|
|
1142 |
*
|
|
|
1143 |
* childSlide = new Slide(130046); features = new ArrayList<Feature>();
|
|
|
1144 |
*
|
|
|
1145 |
* slide.addChild(childSlide);
|
|
|
1146 |
*
|
|
|
1147 |
* List<Feature> childFeatures11 = new ArrayList<Feature>(); List<Feature>
|
|
|
1148 |
* childFeatures21 = new ArrayList<Feature>(); Slide childChildSlide11 = new
|
|
|
1149 |
* Slide(130048); Slide childChildSlide21 = new Slide(130049);
|
|
|
1150 |
*
|
|
|
1151 |
* childChildSlide11.setFeatures(childFeatures11);
|
|
|
1152 |
* childChildSlide21.setFeatures(childFeatures21);
|
|
|
1153 |
*
|
|
|
1154 |
* childSlide.addChild(childChildSlide11);
|
|
|
1155 |
* childSlide.addChild(childChildSlide21); for(Feature f:
|
|
|
1156 |
* slide.getFeatures()){ if(f.getFeatureDefinitionID() == 120072){
|
|
|
1157 |
* features.add(f); } if(f.getFeatureDefinitionID() == 120073){
|
|
|
1158 |
* features.add(f); } if(f.getFeatureDefinitionID() == 120063){
|
|
|
1159 |
* f.setFeatureDefinitionID(120068); childFeatures11.add(f); }
|
|
|
1160 |
* if(f.getFeatureDefinitionID() == 120064){
|
|
|
1161 |
* f.setFeatureDefinitionID(120069); childFeatures21.add(f); } }
|
|
|
1162 |
* slide.setFeatures(features); break;
|
|
|
1163 |
*
|
|
|
1164 |
*
|
|
|
1165 |
* //Mail n Msg case 130041: case 130063:
|
|
|
1166 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130039);
|
|
|
1167 |
* slide.setSlideDefinitionID(130039); break; case 130039:
|
|
|
1168 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130039);
|
|
|
1169 |
* slide.setSlideDefinitionID(130039);
|
|
|
1170 |
*
|
|
|
1171 |
* childSlide = slide.getChildrenSlides().get(0);
|
|
|
1172 |
* slide.setFeatures(childSlide.getFeatures());
|
|
|
1173 |
* if(childSlide.getFreeformContent()!=null){
|
|
|
1174 |
* System.out.println("Mail n Msg : HAS FFC : " +
|
|
|
1175 |
* childSlide.getFreeformContent().getFreeformText() +
|
|
|
1176 |
* childSlide.getFreeformContent().getMedias()); }
|
|
|
1177 |
* slide.setChildrenSlides(null); break;
|
|
|
1178 |
*
|
|
|
1179 |
* //Software case 130020: case 130034:
|
|
|
1180 |
* removeMap.put(slide.getSlideDefinitionID(), (long)130020);
|
|
|
1181 |
* slide.setSlideDefinitionID(130020); break;
|
|
|
1182 |
*
|
|
|
1183 |
*
|
|
|
1184 |
* //Internet case 130050: removeMap.put(slide.getSlideDefinitionID(),
|
|
|
1185 |
* (long)130050); slide.setSlideDefinitionID(130050);
|
|
|
1186 |
* slide.setFeatures(slide.getChildrenSlides().get(0).getFeatures());
|
|
|
1187 |
*
|
|
|
1188 |
* if(slide.getChildrenSlides().get(0).getFreeformContent()!=null){ String
|
|
|
1189 |
* ffc = slide.getFreeformContent().getFreeformText();
|
|
|
1190 |
* if(slide.getChildrenSlides
|
|
|
1191 |
* ().get(0).getFreeformContent().getFreeformText()!=null){
|
|
|
1192 |
* if(slide.getChildrenSlides
|
|
|
1193 |
* ().get(0).getFreeformContent().getFreeformText().trim()!=""){ ffc = ffc +
|
|
|
1194 |
* "\n ********* " +
|
|
|
1195 |
* slide.getChildrenSlides().get(0).getFreeformContent().getFreeformText();
|
|
|
1196 |
* System.out.println("**************" +
|
|
|
1197 |
* slide.getChildrenSlides().get(0).getFreeformContent().getFreeformText());
|
|
|
1198 |
* } }
|
|
|
1199 |
*
|
|
|
1200 |
* List<String> ffcs = new ArrayList<String>(); ffcs.add(ffc);
|
|
|
1201 |
* slide.getFreeformContent().setFreeformTexts(ffcs); }
|
|
|
1202 |
*
|
|
|
1203 |
* slide.setChildrenSlides(null); //System.out.println("Slide: 130050");
|
|
|
1204 |
* //printSlideContent(slide); break;
|
|
|
1205 |
*
|
|
|
1206 |
* case 130052: removeMap.put(slide.getSlideDefinitionID(), (long)130050);
|
|
|
1207 |
* slide.setSlideDefinitionID(130050);
|
|
|
1208 |
*
|
|
|
1209 |
* for(Feature f2: slide.getFeatures()){ if(f2.getFeatureDefinitionID() ==
|
|
|
1210 |
* 120077){ f2.setFeatureDefinitionID(120074); // List<Bullet> newBullets =
|
|
|
1211 |
* new ArrayList<Bullet>(); // for(Bullet bul: f2.getBullets()){ //
|
|
|
1212 |
* CompositeDataObject cdo = (CompositeDataObject) bul.getDataObject(); //
|
|
|
1213 |
* for(PrimitiveDataObject pdo1: cdo.getPrimitiveDataObjects()){ //
|
|
|
1214 |
* pdo1.getValue(); // BulletDataObject bdo2 = new
|
|
|
1215 |
* EnumDataObject(enumValueID); // Bullet newbul = new Bullet(bdo2); //
|
|
|
1216 |
* newBullets.add(newbul); // } // // } // f2.setBullets(newBullets); }
|
|
|
1217 |
* if(f2.getFeatureDefinitionID() == 120078){
|
|
|
1218 |
* f2.setFeatureDefinitionID(120075); } } //
|
|
|
1219 |
* slide.setFeatures(slide.getChildrenSlides().get(0).getFeatures()); //
|
|
|
1220 |
* slide.setChildrenSlides(null); //System.out.println("Slide: 130052");
|
|
|
1221 |
*
|
|
|
1222 |
* //printSlideContent(slide); break;
|
|
|
1223 |
*
|
|
|
1224 |
* case 130051: removeMap.put(slide.getSlideDefinitionID(), (long)130050);
|
|
|
1225 |
* slide.setSlideDefinitionID(130050); // System.out.println(slide);
|
|
|
1226 |
* //System.out.println("Slide 130051:"); // printSlideContent(slide);
|
|
|
1227 |
* break;
|
|
|
1228 |
*
|
|
|
1229 |
* default: break; }
|
|
|
1230 |
*
|
|
|
1231 |
* } List<Long> newSequence = new ArrayList<Long>(); for(Long id:
|
|
|
1232 |
* slideSequence){ if(removeMap.containsKey(id)){
|
|
|
1233 |
* newSequence.add(removeMap.get(id)); }else{ newSequence.add(id); } }
|
|
|
1234 |
* entity.setSlideSequence(newSequence); CreationUtils.updateEntity(entity);
|
|
|
1235 |
* } }
|
|
|
1236 |
*
|
|
|
1237 |
* return true; }
|
|
|
1238 |
*/
|
|
|
1239 |
|
|
|
1240 |
public void printSlideContent(Slide slide) {
|
|
|
1241 |
|
|
|
1242 |
System.out.println("Slide: "
|
|
|
1243 |
+ slide.getFreeformContent().getFreeformText());
|
|
|
1244 |
if (slide.getFeatures() != null) {
|
|
|
1245 |
for (Feature feature : slide.getFeatures()) {
|
|
|
1246 |
if (feature.getBullets() != null) {
|
|
|
1247 |
for (Bullet bullet : feature.getBullets()) {
|
|
|
1248 |
// System.out.println(bullet.getDataObject().toString());
|
|
|
1249 |
// System.out.println(bullet.getFreeformContent());
|
| 1226 |
rajveer |
1250 |
}
|
|
|
1251 |
}
|
| 4964 |
amit.gupta |
1252 |
if (feature.getFreeformContent() != null) {
|
|
|
1253 |
System.out.println("Feature: "
|
|
|
1254 |
+ feature.getFreeformContent().getFreeformText());
|
| 1226 |
rajveer |
1255 |
}
|
|
|
1256 |
}
|
|
|
1257 |
}
|
| 4964 |
amit.gupta |
1258 |
if (slide.getChildrenSlides() != null) {
|
|
|
1259 |
for (Slide sl : slide.getChildrenSlides()) {
|
| 1226 |
rajveer |
1260 |
System.out.println("Child1: ");
|
|
|
1261 |
printSlideContent(sl);
|
|
|
1262 |
System.out.println("Child2: ");
|
|
|
1263 |
}
|
|
|
1264 |
}
|
| 4964 |
amit.gupta |
1265 |
|
| 1226 |
rajveer |
1266 |
}
|
| 4964 |
amit.gupta |
1267 |
|
| 1230 |
rajveer |
1268 |
/*
|
| 4964 |
amit.gupta |
1269 |
* public boolean migrateModel() throws Exception{ //DefinitionsContainer
|
|
|
1270 |
* oldDfc = new DefinitionsContainer(Utils.CONTENT_DB_PATH +
|
|
|
1271 |
* "olddefinitions" + File.separator); //DefinitionsContainer newDfc = new
|
|
|
1272 |
* DefinitionsContainer(Utils.CONTENT_DB_PATH + "olddefinitions" +
|
|
|
1273 |
* File.separator);
|
|
|
1274 |
*
|
|
|
1275 |
* Map<Long, Entity> entities = CreationUtils.getEntities(); for(Entity
|
|
|
1276 |
* entity: entities.values()){ List<Slide> slides = entity.getSlides();
|
|
|
1277 |
* if(slides!=null){ List<Slide> newSlides = new ArrayList<Slide>();
|
|
|
1278 |
* for(Slide slide: slides){ Slide newSlide; List<Feature> features; Slide
|
|
|
1279 |
* childSlide; switch ((int)slide.getSlideDefinitionID()) {
|
|
|
1280 |
*
|
|
|
1281 |
* //Keyboard case 130004: case 130026: case 130027: case 130057: newSlide =
|
|
|
1282 |
* new Slide(130026); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1283 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1284 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1285 |
* newSlides.add(newSlide); break;
|
|
|
1286 |
*
|
|
|
1287 |
* //Voice Calling case 130005: newSlide = new Slide(130005);
|
|
|
1288 |
* newSlide.setChildrenSlides(null); features = new ArrayList<Feature>();
|
|
|
1289 |
* features.addAll(slide.getFeatures()); childSlide =
|
|
|
1290 |
* slide.getChildrenSlides().get(0);
|
|
|
1291 |
* features.addAll(childSlide.getFeatures());
|
|
|
1292 |
* if(childSlide.getFreeformContent()!=null){
|
|
|
1293 |
* System.out.println("Voice Calling : HAS FFC : " +
|
|
|
1294 |
* childSlide.getFreeformContent().getFreeformText() +
|
|
|
1295 |
* childSlide.getFreeformContent().getMedias()); }
|
|
|
1296 |
* newSlide.setFeatures(features);
|
|
|
1297 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1298 |
* newSlides.add(newSlide); break; case 130035: newSlide = new
|
|
|
1299 |
* Slide(130035); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1300 |
* for(Feature feata: slide.getFeatures()){
|
|
|
1301 |
* if(feata.getFeatureDefinitionID()==120055){
|
|
|
1302 |
* feata.setFeatureDefinitionID(120012); } }
|
|
|
1303 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1304 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1305 |
* newSlides.add(newSlide); break;
|
|
|
1306 |
*
|
|
|
1307 |
* //Data Connectivity case 130007: case 130028: newSlide = new
|
|
|
1308 |
* Slide(130007); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1309 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1310 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1311 |
* newSlides.add(newSlide); break;
|
|
|
1312 |
*
|
|
|
1313 |
* //Music case 130029: case 130030: case 130008: newSlide = new
|
|
|
1314 |
* Slide(130029); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1315 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1316 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1317 |
* newSlides.add(newSlide); break;
|
|
|
1318 |
*
|
|
|
1319 |
* //Video case 130031: case 130009: newSlide = new Slide(130031);
|
|
|
1320 |
* newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1321 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1322 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1323 |
* newSlides.add(newSlide); break;
|
|
|
1324 |
*
|
|
|
1325 |
* //Camera case 130010: case 130036: case 130037: newSlide = new
|
|
|
1326 |
* Slide(130010); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1327 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1328 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1329 |
* newSlides.add(newSlide); break; case 130060: newSlide = new
|
|
|
1330 |
* Slide(130010); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1331 |
* features = slide.getFeatures(); // Just to add camera feature in basic
|
|
|
1332 |
* phones Feature feature = new Feature(120056); List<Bullet> bullets = new
|
|
|
1333 |
* ArrayList<Bullet>(); PrimitiveDataObject pdo = new
|
|
|
1334 |
* PrimitiveDataObject("1"); Bullet bullet = new Bullet(pdo);
|
|
|
1335 |
* bullets.add(bullet); feature.setBullets(bullets); features.add(feature);
|
|
|
1336 |
* //Created new feature newSlide.setFeatures(features);
|
|
|
1337 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1338 |
* newSlides.add(newSlide); break;
|
|
|
1339 |
*
|
|
|
1340 |
* //Memory case 130011: newSlide = new Slide(130011);
|
|
|
1341 |
* newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1342 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1343 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1344 |
* newSlides.add(newSlide); break; case 130032: case 130061: newSlide = new
|
|
|
1345 |
* Slide(130011); newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1346 |
* features = slide.getFeatures(); for(Feature feat: features){
|
|
|
1347 |
* if(feat.getFeatureDefinitionID() == 130054){
|
|
|
1348 |
* feat.setFeatureDefinitionID(120030); } }
|
|
|
1349 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1350 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1351 |
* newSlides.add(newSlide); break;
|
|
|
1352 |
*
|
|
|
1353 |
* //Battery case 130044: newSlide = new Slide(130043);
|
|
|
1354 |
* if(slide.getChildrenSlides().get(0).getSlideDefinitionID() == 130047){
|
|
|
1355 |
* slide.getChildrenSlides().get(0).setSlideDefinitionID(130046); }
|
|
|
1356 |
* newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1357 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1358 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1359 |
* newSlides.add(newSlide); break;
|
|
|
1360 |
*
|
|
|
1361 |
* case 130042: newSlide = new Slide(130043); childSlide =
|
|
|
1362 |
* slide.getChildrenSlides().get(0); if(childSlide.getSlideDefinitionID() ==
|
|
|
1363 |
* 130045){ childSlide.setSlideDefinitionID(130046); }
|
|
|
1364 |
* newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1365 |
*
|
|
|
1366 |
* List<Feature> childFeatures1 = new ArrayList<Feature>(); List<Feature>
|
|
|
1367 |
* childFeatures2 = new ArrayList<Feature>(); Slide childChildSlide1 = new
|
|
|
1368 |
* Slide(130048); Slide childChildSlide2 = new Slide(130049);
|
|
|
1369 |
*
|
|
|
1370 |
* childChildSlide1.setFeatures(childFeatures1);
|
|
|
1371 |
* childChildSlide2.setFeatures(childFeatures2);
|
|
|
1372 |
*
|
|
|
1373 |
* childSlide.addChild(childChildSlide1);
|
|
|
1374 |
* childSlide.addChild(childChildSlide2);
|
|
|
1375 |
*
|
|
|
1376 |
*
|
|
|
1377 |
* for(Feature f: childSlide.getFeatures()){ if(f.getFeatureDefinitionID()
|
|
|
1378 |
* == 120063){ f.setFeatureDefinitionID(120068); childFeatures1.add(f); }
|
|
|
1379 |
* if(f.getFeatureDefinitionID() == 120064){
|
|
|
1380 |
* f.setFeatureDefinitionID(120069); childFeatures2.add(f); } }
|
|
|
1381 |
*
|
|
|
1382 |
* childSlide.setFeatures(null);
|
|
|
1383 |
*
|
|
|
1384 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1385 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1386 |
* newSlides.add(newSlide); break;
|
|
|
1387 |
*
|
|
|
1388 |
* case 130062: newSlide = new Slide(130043);
|
|
|
1389 |
* newSlide.setChildrenSlides(slide.getChildrenSlides()); childSlide = new
|
|
|
1390 |
* Slide(130046); features = new ArrayList<Feature>();
|
|
|
1391 |
* newSlide.setFeatures(features); newSlide.addChild(childSlide);
|
|
|
1392 |
*
|
|
|
1393 |
* List<Feature> childFeatures11 = new ArrayList<Feature>(); List<Feature>
|
|
|
1394 |
* childFeatures21 = new ArrayList<Feature>(); Slide childChildSlide11 = new
|
|
|
1395 |
* Slide(130048); Slide childChildSlide21 = new Slide(130049);
|
|
|
1396 |
*
|
|
|
1397 |
* childChildSlide11.setFeatures(childFeatures11);
|
|
|
1398 |
* childChildSlide21.setFeatures(childFeatures21);
|
|
|
1399 |
*
|
|
|
1400 |
* childSlide.addChild(childChildSlide11);
|
|
|
1401 |
* childSlide.addChild(childChildSlide21); for(Feature f:
|
|
|
1402 |
* slide.getFeatures()){ if(f.getFeatureDefinitionID() == 120072){
|
|
|
1403 |
* features.add(f); } if(f.getFeatureDefinitionID() == 120073){
|
|
|
1404 |
* features.add(f); } if(f.getFeatureDefinitionID() == 120063){
|
|
|
1405 |
* f.setFeatureDefinitionID(120068); childFeatures11.add(f); }
|
|
|
1406 |
* if(f.getFeatureDefinitionID() == 120064){
|
|
|
1407 |
* f.setFeatureDefinitionID(120069); childFeatures21.add(f); } }
|
|
|
1408 |
*
|
|
|
1409 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1410 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1411 |
* newSlides.add(newSlide); break;
|
|
|
1412 |
*
|
|
|
1413 |
*
|
|
|
1414 |
* //Mail n Msg case 130041: case 130063: newSlide = new Slide(130039);
|
|
|
1415 |
* newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1416 |
* newSlide.setFeatures(slide.getFeatures());
|
|
|
1417 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1418 |
* newSlides.add(newSlide); break; case 130039: newSlide = new
|
|
|
1419 |
* Slide(130039); //newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1420 |
* childSlide = slide.getChildrenSlides().get(0);
|
|
|
1421 |
* newSlide.setFeatures(childSlide.getFeatures());
|
|
|
1422 |
* if(childSlide.getFreeformContent()!=null){
|
|
|
1423 |
* System.out.println("Mail n Msg : HAS FFC : " +
|
|
|
1424 |
* childSlide.getFreeformContent().getFreeformText() +
|
|
|
1425 |
* childSlide.getFreeformContent().getMedias()); }
|
|
|
1426 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1427 |
* newSlides.add(newSlide); break;
|
|
|
1428 |
*
|
|
|
1429 |
* //Software case 130020: case 130034: newSlide = new Slide(130034);
|
|
|
1430 |
* newSlide.setChildrenSlides(slide.getChildrenSlides()); features =
|
|
|
1431 |
* slide.getFeatures(); newSlide.setFeatures(slide.getFeatures());
|
|
|
1432 |
* newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1433 |
* newSlides.add(newSlide); break;
|
|
|
1434 |
*
|
|
|
1435 |
*
|
|
|
1436 |
* default: newSlides.add(slide); break; } } entity.setSlides(newSlides);
|
|
|
1437 |
* CreationUtils.updateEntity(entity); } }
|
|
|
1438 |
*
|
|
|
1439 |
* return true; }
|
|
|
1440 |
*/
|
|
|
1441 |
public boolean migrateRemoveBorrowedCategoryIdFromSlide() throws Exception {
|
| 1226 |
rajveer |
1442 |
Map<Long, Entity> entities = CreationUtils.getEntities();
|
| 4964 |
amit.gupta |
1443 |
for (Entity entity : entities.values()) {
|
|
|
1444 |
if (entity.getID() == 0) {
|
| 1226 |
rajveer |
1445 |
CreationUtils.deleteEntity(entity.getID());
|
|
|
1446 |
}
|
|
|
1447 |
List<Slide> slides = entity.getSlides();
|
| 4964 |
amit.gupta |
1448 |
if (slides != null) {
|
| 1226 |
rajveer |
1449 |
List<Slide> newSlides = new ArrayList<Slide>();
|
| 4964 |
amit.gupta |
1450 |
for (Slide slide : slides) {
|
| 1226 |
rajveer |
1451 |
Slide newSlide = new Slide(slide.getSlideDefinitionID());
|
|
|
1452 |
newSlide.setChildrenSlides(slide.getChildrenSlides());
|
|
|
1453 |
newSlide.setFeatures(slide.getFeatures());
|
|
|
1454 |
newSlide.setFreeformContent(slide.getFreeformContent());
|
|
|
1455 |
newSlides.add(newSlide);
|
|
|
1456 |
}
|
|
|
1457 |
entity.setSlides(newSlides);
|
|
|
1458 |
CreationUtils.updateEntity(entity);
|
|
|
1459 |
}
|
|
|
1460 |
}
|
|
|
1461 |
return true;
|
|
|
1462 |
}
|
| 479 |
rajveer |
1463 |
|
| 4964 |
amit.gupta |
1464 |
public boolean migrate() throws Exception {
|
| 580 |
rajveer |
1465 |
/*
|
| 4964 |
amit.gupta |
1466 |
* DefinitionsContainer sourceDefs = new
|
|
|
1467 |
* DefinitionsContainer(sourceDbPath); DefinitionsContainer
|
|
|
1468 |
* destinationDefs = new DefinitionsContainer(destinationDbPath);
|
|
|
1469 |
* EntityContainer sourceEnts = new EntityContainer(sourceDbPath);
|
|
|
1470 |
* EntityContainer destinationEnts = new
|
|
|
1471 |
* EntityContainer(destinationDbPath);
|
|
|
1472 |
*
|
|
|
1473 |
* Map<Long, Entity> entities = sourceEnts.getEntities();
|
|
|
1474 |
*
|
|
|
1475 |
* File f = new File("/home/rajveer/Desktop/info.txt"); FileWriter
|
|
|
1476 |
* fstream = new FileWriter(f); BufferedWriter out = new
|
|
|
1477 |
* BufferedWriter(fstream); StringBuilder sb = new StringBuilder();
|
|
|
1478 |
*
|
|
|
1479 |
*
|
|
|
1480 |
* for(Entity entity: entities.values()){ List<Slide> slides =
|
|
|
1481 |
* entity.getSlides();
|
|
|
1482 |
*
|
|
|
1483 |
* //List<String> vidLabels =
|
|
|
1484 |
* CreationUtils.getMediaLabels(entity.getID(),"youtube");
|
|
|
1485 |
* //List<String> imgLabels =
|
|
|
1486 |
* CreationUtils.getMediaLabels(entity.getID(),"image");
|
|
|
1487 |
*
|
|
|
1488 |
* //Map<String, Media> rawMedia =
|
|
|
1489 |
* CreationUtils.getRawMedia(entity.getID());
|
|
|
1490 |
*
|
|
|
1491 |
*
|
|
|
1492 |
* // List<String> vidLabels =
|
|
|
1493 |
* OldCreationUtils.getMediaLabels(entity.getID(),"youtube"); //
|
|
|
1494 |
* List<String> imgLabels =
|
|
|
1495 |
* OldCreationUtils.getMediaLabels(entity.getID(),"image");
|
|
|
1496 |
*
|
|
|
1497 |
* Entity newEntity = new Entity(entity.getID(),
|
|
|
1498 |
* entity.getCategoryID()); newEntity.setBrand(entity.getBrand());
|
|
|
1499 |
* newEntity.setModelName(entity.getModelName());
|
|
|
1500 |
* newEntity.setModelNumber(entity.getModelNumber());
|
|
|
1501 |
*
|
|
|
1502 |
*
|
|
|
1503 |
* Map<String, in.shop2020.creation.util.Media> rawMedia =
|
|
|
1504 |
* OldCreationUtils.getRawMedia(entity.getID());
|
|
|
1505 |
*
|
|
|
1506 |
* Map<String, Media> newrawMedia = new HashMap<String, Media>();
|
|
|
1507 |
*
|
|
|
1508 |
*
|
|
|
1509 |
* int totalRawVideos = 0; int totalRawImages = 0;
|
|
|
1510 |
*
|
|
|
1511 |
* if(rawMedia!=null){ for(String label: rawMedia.keySet()){
|
|
|
1512 |
* in.shop2020.creation.util.Media media = rawMedia.get(label);
|
|
|
1513 |
*
|
|
|
1514 |
* label = media.getLabel(); String type = media.getType(); String
|
|
|
1515 |
* location = media.getLocation();
|
|
|
1516 |
*
|
|
|
1517 |
* Media newMedia = new Media(label, type, location);
|
|
|
1518 |
*
|
|
|
1519 |
* newMedia.setTitle("Title"); if(type.equals("image")){
|
|
|
1520 |
* totalRawImages++; newMedia.setFileName(media.getFileName());
|
|
|
1521 |
* newMedia.setVideoType(""); }else{ totalRawVideos++;
|
|
|
1522 |
* newMedia.setVideoType("withoutskin"); newMedia.setFileName(""); }
|
|
|
1523 |
*
|
|
|
1524 |
* newrawMedia.put(label, newMedia); System.out.println("old " +
|
|
|
1525 |
* media.toString()); // System.out.println("new " +
|
|
|
1526 |
* newMedia.toString()); // OldCreationUtils.removeMedia(entity.getID(),
|
|
|
1527 |
* label); // CreationUtils.addMedia(entity.getID(), newMedia); } }
|
|
|
1528 |
*
|
|
|
1529 |
* int totalVideos = 0; int totalImages = 0; if(rawMedia==null){
|
|
|
1530 |
* for(Slide slide: slides ){
|
|
|
1531 |
*/
|
|
|
1532 |
/*
|
|
|
1533 |
* FreeformContent ffc = slide.getFreeformContent(); List<String>
|
|
|
1534 |
* vidList = new ArrayList<String>(); List<String> imgList = new
|
|
|
1535 |
* ArrayList<String>();
|
|
|
1536 |
*
|
|
|
1537 |
* if(ffc!=null){ List<String> vidFfcLabels = ffc.getYoutubeRefs();
|
|
|
1538 |
* if(vidFfcLabels!=null){ for(String vidFfcLabel: vidFfcLabels){
|
|
|
1539 |
* StringTokenizer strTkn = new StringTokenizer(vidFfcLabel,"~!~");
|
|
|
1540 |
* String vidLabel = null; if(strTkn.hasMoreTokens()){ vidLabel =
|
|
|
1541 |
* strTkn.nextToken(); vidList.add(vidFfcLabel);
|
|
|
1542 |
*
|
|
|
1543 |
* // ffc.removeMedia("youtube", vidFfcLabel); //
|
|
|
1544 |
* ffc.addMedia("youtube", vidLabel); } if(vidLabel == null){
|
|
|
1545 |
* System.out.println("Something is really breaking .. bu ha ha !!!"); }
|
|
|
1546 |
* totalVideos++; } } List<String> imgFfcLabels = ffc.getImageRefs();
|
|
|
1547 |
* if(imgFfcLabels!=null){ for(String imgFfcLabel: imgFfcLabels){
|
|
|
1548 |
* StringTokenizer strTkn = new StringTokenizer(imgFfcLabel,"~!~");
|
|
|
1549 |
* String imgLabel = null; if(strTkn.hasMoreTokens()){ imgLabel =
|
|
|
1550 |
* strTkn.nextToken(); imgList.add(imgFfcLabel);
|
|
|
1551 |
*
|
|
|
1552 |
* // ffc.removeMedia("image", imgFfcLabel); // ffc.addMedia("image",
|
|
|
1553 |
* imgLabel); } if(imgLabel == null){
|
|
|
1554 |
* System.out.println("Something is really breaking .. bu ha ha !!!"); }
|
|
|
1555 |
* totalImages++; } }
|
|
|
1556 |
*
|
|
|
1557 |
* for(String vidlab : vidList){ ffc.removeMedia("youtube", vidlab);
|
|
|
1558 |
* ffc.addMedia("youtube", (new StringTokenizer(vidlab,
|
|
|
1559 |
* "~!~")).nextToken()); } for(String imglab : imgList){
|
|
|
1560 |
* ffc.removeMedia("image",imglab); ffc.addMedia("image", (new
|
|
|
1561 |
* StringTokenizer(imglab, "~!~")).nextToken()); }
|
|
|
1562 |
* slide.setFreeformContent(ffc); System.out.println("Slide id is " +
|
|
|
1563 |
* slide.getSlideDefinitionID() + " vid labels: " + vidFfcLabels +
|
|
|
1564 |
* " img labels" + imgFfcLabels); }
|
|
|
1565 |
*/
|
|
|
1566 |
/*
|
|
|
1567 |
* newEntity.addSlide(slide); }
|
|
|
1568 |
*
|
|
|
1569 |
* // System.out.println("entity:"+ entity.getID() + ":trv:" +
|
|
|
1570 |
* totalRawVideos + ":tri:" + totalRawImages +":tv:" + totalVideos
|
|
|
1571 |
* +":ti:" + totalImages); // sb.append("entity:"+ entity.getID() +
|
|
|
1572 |
* ":trv:" + totalRawVideos + ":tri:" + totalRawImages +":tv:" +
|
|
|
1573 |
* totalVideos +":ti:" + totalImages+ ":tr:"
|
|
|
1574 |
* +(totalRawVideos+totalRawImages) + ":t:" +(totalVideos+totalImages) +
|
|
|
1575 |
* ":vd:" +(totalRawVideos-totalVideos) + ":id:"
|
|
|
1576 |
* +(totalRawImages-totalImages) + "\n"); sb.append(entity.getID() +
|
|
|
1577 |
* "\n");
|
|
|
1578 |
*
|
|
|
1579 |
*
|
|
|
1580 |
* destinationEnts.updateEntity(newEntity);
|
|
|
1581 |
* CreationUtils.storeEntity(newEntity);
|
|
|
1582 |
*
|
|
|
1583 |
* Map<Long, List<Entity>> entitiesByCategory =
|
|
|
1584 |
* sourceEnts.getEntitiesbyCategory();
|
|
|
1585 |
*
|
|
|
1586 |
* Map<Long, Entity> xentities = destinationEnts.getEntities();
|
|
|
1587 |
*
|
|
|
1588 |
* CreationUtils.rewriteRepository(xentities, entitiesByCategory); }
|
|
|
1589 |
* else{ sb.append(" " + entity.getID() + "\n"); } }
|
|
|
1590 |
*
|
|
|
1591 |
*
|
|
|
1592 |
* out.write(sb.toString()); out.close();
|
|
|
1593 |
*/
|
| 457 |
rajveer |
1594 |
return true;
|
|
|
1595 |
}
|
| 4964 |
amit.gupta |
1596 |
|
|
|
1597 |
private boolean makeEntitiesObject() throws Exception {
|
|
|
1598 |
// DefinitionsContainer sourceDefs = new
|
|
|
1599 |
// DefinitionsContainer(sourceDbPath);
|
|
|
1600 |
// DefinitionsContainer destinationDefs = new
|
|
|
1601 |
// DefinitionsContainer(destinationDbPath);
|
|
|
1602 |
// EntityContainer sourceEnts = new EntityContainer(sourceDbPath);
|
|
|
1603 |
// EntityContainer destinationEnts = new
|
|
|
1604 |
// EntityContainer(destinationDbPath);
|
|
|
1605 |
|
|
|
1606 |
/*
|
|
|
1607 |
* Map<Long, List<Entity>> catEntities =
|
|
|
1608 |
* sourceEnts.getEntitiesbyCategory();
|
|
|
1609 |
*
|
|
|
1610 |
* Map<Long, Entity> entities = sourceEnts.getEntities(); for(Long
|
|
|
1611 |
* catId: catEntities.keySet()){ List<Entity> ents =
|
|
|
1612 |
* catEntities.get(catId); for(Entity entity: ents){
|
|
|
1613 |
* entities.put(entity.getID(), entity);
|
|
|
1614 |
* System.out.println(entity.getID() + ":" + entity.getCategoryID() +
|
|
|
1615 |
* ":"+ entity.getBrand() + " "+ entity.getModelName() + " " +
|
|
|
1616 |
* entity.getModelNumber()); } }
|
|
|
1617 |
*/
|
|
|
1618 |
|
| 791 |
rajveer |
1619 |
Map<Long, List<Entity>> catEntities = new TreeMap<Long, List<Entity>>();
|
|
|
1620 |
Map<Long, Entity> entities = new TreeMap<Long, Entity>();
|
| 2720 |
mandeep.dh |
1621 |
|
| 4964 |
amit.gupta |
1622 |
FileInputStream fstream = new FileInputStream("/home/rajveer/Desktop/1");
|
|
|
1623 |
DataInputStream in = new DataInputStream(fstream);
|
|
|
1624 |
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
|
|
1625 |
String strLine;
|
| 2720 |
mandeep.dh |
1626 |
|
| 4964 |
amit.gupta |
1627 |
while ((strLine = br.readLine()) != null) {
|
|
|
1628 |
long entityID = Long.parseLong(strLine);
|
|
|
1629 |
String entityDBFile = sourceDbPath + "entities" + File.separator
|
|
|
1630 |
+ entityID + "/entity.ser";
|
|
|
1631 |
System.out.println(entityDBFile);
|
|
|
1632 |
Entity entity = (Entity) DBUtils.read(entityDBFile);
|
|
|
1633 |
entities.put(entityID, entity);
|
| 2720 |
mandeep.dh |
1634 |
|
| 4964 |
amit.gupta |
1635 |
List<Entity> catent = catEntities.get(entity.getCategoryID());
|
|
|
1636 |
if (catent == null) {
|
|
|
1637 |
catent = new ArrayList<Entity>();
|
|
|
1638 |
}
|
|
|
1639 |
catent.add(entity);
|
|
|
1640 |
catEntities.put(entity.getCategoryID(), catent);
|
|
|
1641 |
}
|
|
|
1642 |
in.close();
|
|
|
1643 |
|
|
|
1644 |
String entitiesDBFile = sourceDbPath + "entities" + File.separator
|
|
|
1645 |
+ "entities.ser";
|
|
|
1646 |
String entitiesbycategoryDBFile = sourceDbPath + "entities"
|
|
|
1647 |
+ File.separator + "entitiesbycategory.ser";
|
|
|
1648 |
|
| 791 |
rajveer |
1649 |
DBUtils.delete(entitiesDBFile);
|
|
|
1650 |
DBUtils.store(entities, entitiesDBFile);
|
| 2720 |
mandeep.dh |
1651 |
|
| 4964 |
amit.gupta |
1652 |
// Remove existing
|
| 791 |
rajveer |
1653 |
DBUtils.delete(entitiesbycategoryDBFile);
|
|
|
1654 |
DBUtils.store(catEntities, entitiesbycategoryDBFile);
|
| 2720 |
mandeep.dh |
1655 |
|
| 4964 |
amit.gupta |
1656 |
return false;
|
| 791 |
rajveer |
1657 |
}
|
| 2720 |
mandeep.dh |
1658 |
|
| 4964 |
amit.gupta |
1659 |
private boolean printDataModel() throws Exception {
|
|
|
1660 |
DefinitionsContainer dfc = Catalog.getInstance()
|
|
|
1661 |
.getDefinitionsContainer();
|
| 1226 |
rajveer |
1662 |
StringBuilder sb = new StringBuilder();
|
| 2720 |
mandeep.dh |
1663 |
|
| 1226 |
rajveer |
1664 |
Map<Long, SlideDefinition> allSlideDefs = dfc.getSlideDefinitions();
|
| 4964 |
amit.gupta |
1665 |
for (Long slideDefId : allSlideDefs.keySet()) {
|
| 1226 |
rajveer |
1666 |
SlideDefinition slideDef = allSlideDefs.get(slideDefId);
|
|
|
1667 |
sb.append(slideDefId + " - " + slideDef.getLabel() + "\n");
|
| 4964 |
amit.gupta |
1668 |
if (!slideDef.getChildrenSlideDefinitionIDs().isEmpty()) {
|
|
|
1669 |
sb.append("Child Slides are: \t"
|
|
|
1670 |
+ slideDef.getChildrenSlideDefinitionIDs() + "\n");
|
| 1226 |
rajveer |
1671 |
}
|
| 4964 |
amit.gupta |
1672 |
List<SlideFeatureDefinition> featureDefs = slideDef
|
|
|
1673 |
.getSlideFeatureDefinitions();
|
|
|
1674 |
for (SlideFeatureDefinition featureDef : featureDefs) {
|
|
|
1675 |
sb.append("\t"
|
|
|
1676 |
+ featureDef.getFeatureDefintionID()
|
|
|
1677 |
+ "\t"
|
|
|
1678 |
+ dfc.getFeatureDefinition(
|
|
|
1679 |
featureDef.getFeatureDefintionID()).getLabel()
|
|
|
1680 |
+ "\t" + featureDef.getEditorialImportance() + "\n");
|
| 1226 |
rajveer |
1681 |
}
|
|
|
1682 |
}
|
|
|
1683 |
System.out.println(sb.toString());
|
| 580 |
rajveer |
1684 |
Map<Long, Category> categories = dfc.getCategories();
|
| 4964 |
amit.gupta |
1685 |
if (categories != null) {
|
| 1226 |
rajveer |
1686 |
return true;
|
|
|
1687 |
}
|
| 4964 |
amit.gupta |
1688 |
for (Category category : categories.values()) {
|
|
|
1689 |
if (category.getChildrenCategory() != null) {
|
| 580 |
rajveer |
1690 |
continue;
|
|
|
1691 |
}
|
| 1226 |
rajveer |
1692 |
sb.append(category.getLabel() + "\n");
|
| 4964 |
amit.gupta |
1693 |
List<CategorySlideDefinition> slideDefs = dfc
|
|
|
1694 |
.getCategorySlideDefinitions(category.getID());
|
|
|
1695 |
List<Long> slideSequence = dfc.getCategorySlideSequence(category
|
|
|
1696 |
.getID());
|
|
|
1697 |
for (CategorySlideDefinition slideDef : slideDefs) {
|
|
|
1698 |
sb.append("\t"
|
|
|
1699 |
+ dfc.getSlideDefinition(slideDef.getSlideDefintionID())
|
|
|
1700 |
.getLabel() + "\t"
|
|
|
1701 |
+ slideDef.getEditorialImportance() + "\n");
|
|
|
1702 |
// List<FeatureDefinition> featureDefs =
|
|
|
1703 |
// dfc.getFeatureDefinitions(slideDef.getSlideDefintionID());
|
|
|
1704 |
|
|
|
1705 |
List<SlideFeatureDefinition> slideFeatureDefs = dfc
|
|
|
1706 |
.getSlideDefinition(slideDef.getSlideDefintionID())
|
|
|
1707 |
.getSlideFeatureDefinitions();
|
|
|
1708 |
|
|
|
1709 |
for (SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
|
|
|
1710 |
FeatureDefinition featureDef = dfc
|
|
|
1711 |
.getFeatureDefinition(slideFeatureDef
|
|
|
1712 |
.getFeatureDefintionID());
|
|
|
1713 |
BulletDefinition bulletDef = featureDef
|
|
|
1714 |
.getBulletDefinition();
|
|
|
1715 |
sb.append("\t\t\t" + featureDef.getLabel() + "\t"
|
|
|
1716 |
+ slideFeatureDef.getEditorialImportance() + "\t"
|
|
|
1717 |
+ featureDef.allowsBlank() + "\t"
|
|
|
1718 |
+ bulletDef.isLearned() + "\t"
|
|
|
1719 |
+ bulletDef.isMultivalue());
|
| 580 |
rajveer |
1720 |
List<Long> units = bulletDef.getUnitIDs();
|
| 4964 |
amit.gupta |
1721 |
if (bulletDef.getDatatypeDefinitionID() != null) {
|
|
|
1722 |
sb.append("\t"
|
|
|
1723 |
+ dfc.getDatatypeDefinition(
|
|
|
1724 |
bulletDef.getDatatypeDefinitionID())
|
|
|
1725 |
.getName());
|
|
|
1726 |
|
| 1226 |
rajveer |
1727 |
}
|
| 4964 |
amit.gupta |
1728 |
if (units != null) {
|
|
|
1729 |
for (Long unit : units) {
|
|
|
1730 |
sb.append("\t" + dfc.getUnit(unit).getFullForm()
|
|
|
1731 |
+ "\t" + dfc.getUnit(unit).getShortForm());
|
| 580 |
rajveer |
1732 |
}
|
|
|
1733 |
}
|
| 1226 |
rajveer |
1734 |
sb.append("\n");
|
| 580 |
rajveer |
1735 |
}
|
| 4964 |
amit.gupta |
1736 |
|
| 580 |
rajveer |
1737 |
/*
|
| 4964 |
amit.gupta |
1738 |
* for(FeatureDefinition featureDef: featureDefs){
|
|
|
1739 |
* BulletDefinition bulletDef =
|
|
|
1740 |
* featureDef.getBulletDefinition(); System.out.println(" " +
|
|
|
1741 |
* featureDef.getLabel() + " " + featureDef.allowsBlank() + " "
|
|
|
1742 |
* + bulletDef.isLearned() + " " + bulletDef.isMultivalue());
|
|
|
1743 |
* List<Long> units = bulletDef.getUnitIDs(); if(units!=null){
|
|
|
1744 |
* for(Long unit: units){ System.out.println(" "+
|
|
|
1745 |
* dfc.getUnit(unit).getFullForm() + " "+
|
|
|
1746 |
* dfc.getUnit(unit).getShortForm()); } }
|
|
|
1747 |
* if(bulletDef.getDatatypeDefinitionID()!=null){
|
|
|
1748 |
* System.out.println(" " +
|
|
|
1749 |
* dfc.getDatatypeDefinition(bulletDef
|
|
|
1750 |
* .getDatatypeDefinitionID()).getName());
|
|
|
1751 |
*
|
|
|
1752 |
* } }
|
|
|
1753 |
*/
|
| 580 |
rajveer |
1754 |
}
|
|
|
1755 |
}
|
| 1226 |
rajveer |
1756 |
System.out.println(sb.toString());
|
| 580 |
rajveer |
1757 |
return true;
|
|
|
1758 |
}
|
| 4964 |
amit.gupta |
1759 |
|
|
|
1760 |
public boolean migrateOS() throws Exception {
|
| 4706 |
amit.gupta |
1761 |
Map<Long, Entity> map = CreationUtils.getEntities();
|
| 4964 |
amit.gupta |
1762 |
for (Long entityId : map.keySet()) {
|
|
|
1763 |
Entity entity = map.get(entityId);
|
|
|
1764 |
if (entity == null || entity.getSlides() == null) {
|
|
|
1765 |
continue;
|
|
|
1766 |
}
|
|
|
1767 |
|
|
|
1768 |
for (Slide slide : entity.getSlides()) {
|
|
|
1769 |
if (slide.getSlideDefinitionID() == 130020) {
|
|
|
1770 |
List<Feature> features = slide.getFeatures();
|
|
|
1771 |
for (Feature f : features) {
|
|
|
1772 |
if (f.getFeatureDefinitionID() == 120043) {
|
|
|
1773 |
Bullet b = f.getBullets().get(0);
|
|
|
1774 |
String value = ((PrimitiveDataObject) b
|
|
|
1775 |
.getDataObject()).getValue();
|
|
|
1776 |
long enumValueID = getEnumValueForOS(value);
|
|
|
1777 |
if (enumValueID == 110371L) {
|
|
|
1778 |
Logger.log("Set entity:" + entityId
|
|
|
1779 |
+ " as proprietary software", entity);
|
|
|
1780 |
}
|
| 4706 |
amit.gupta |
1781 |
b.setDataObject(new EnumDataObject(enumValueID));
|
| 4964 |
amit.gupta |
1782 |
}
|
|
|
1783 |
}
|
|
|
1784 |
}
|
| 4706 |
amit.gupta |
1785 |
|
| 4964 |
amit.gupta |
1786 |
}
|
|
|
1787 |
|
|
|
1788 |
CreationUtils.updateEntity(entity);
|
|
|
1789 |
}
|
|
|
1790 |
return true;
|
| 4706 |
amit.gupta |
1791 |
}
|
|
|
1792 |
|
|
|
1793 |
private long getEnumValueForOS(String value) {
|
|
|
1794 |
value = value.toLowerCase();
|
|
|
1795 |
Map<String, Long> map = getOSEnumMap();
|
| 4964 |
amit.gupta |
1796 |
String os = "Proprietary software";
|
|
|
1797 |
if (value.contains("android")) {
|
|
|
1798 |
if (value.contains("1.5")) {
|
|
|
1799 |
os = "Android v1.5 (Cupcake)";
|
|
|
1800 |
}
|
|
|
1801 |
if (value.contains("1.6")) {
|
|
|
1802 |
os = "Android v1.6 (Donut)";
|
|
|
1803 |
}
|
|
|
1804 |
if (value.contains("2.1")) {
|
|
|
1805 |
os = "Android v2.1 (Eclair)";
|
|
|
1806 |
}
|
|
|
1807 |
if (value.contains("2.2")) {
|
|
|
1808 |
os = "Android v2.2 (Froyo)";
|
|
|
1809 |
}
|
|
|
1810 |
if (value.contains("2.3")) {
|
|
|
1811 |
os = "Android v2.3 (Gingerbread)";
|
|
|
1812 |
}
|
|
|
1813 |
if (value.contains("3.0")) {
|
|
|
1814 |
os = "Android v3.0 (Honeycomb)";
|
|
|
1815 |
}
|
|
|
1816 |
if (value.contains("3.1")) {
|
|
|
1817 |
os = "Android v3.1 (Honeycomb)";
|
|
|
1818 |
}
|
|
|
1819 |
if (value.contains("3.2")) {
|
|
|
1820 |
os = "Android v3.2 (Honeycomb)";
|
|
|
1821 |
}
|
| 4706 |
amit.gupta |
1822 |
}
|
| 4964 |
amit.gupta |
1823 |
if (value.contains("blackberry")) {
|
|
|
1824 |
if (value.contains("os")) {
|
| 4706 |
amit.gupta |
1825 |
os = "BlackBerry OS";
|
|
|
1826 |
}
|
| 4964 |
amit.gupta |
1827 |
if (value.contains("5.0")) {
|
| 4706 |
amit.gupta |
1828 |
os = "BlackBerry OS 5.0";
|
|
|
1829 |
}
|
| 4964 |
amit.gupta |
1830 |
if (value.contains("6.0")) {
|
| 4706 |
amit.gupta |
1831 |
os = "BlackBerry OS 6.0";
|
|
|
1832 |
}
|
| 4964 |
amit.gupta |
1833 |
if (value.contains("7.0")) {
|
| 4706 |
amit.gupta |
1834 |
os = "BlackBerry OS 7.0";
|
|
|
1835 |
}
|
| 4964 |
amit.gupta |
1836 |
if (value.contains("tablet os")) {
|
| 4706 |
amit.gupta |
1837 |
os = "BlackBerry Tablet OS";
|
|
|
1838 |
}
|
|
|
1839 |
}
|
| 4964 |
amit.gupta |
1840 |
if (value.contains("brew mobile platform")) {
|
| 4706 |
amit.gupta |
1841 |
os = "Brew Mobile Platform";
|
|
|
1842 |
}
|
| 4964 |
amit.gupta |
1843 |
if (value.contains("maemo 5")) {
|
| 4706 |
amit.gupta |
1844 |
os = "Maemo 5";
|
|
|
1845 |
}
|
| 4964 |
amit.gupta |
1846 |
if (value.contains("windows phone 7")) {
|
| 4706 |
amit.gupta |
1847 |
os = "Windows Phone 7";
|
|
|
1848 |
}
|
| 4964 |
amit.gupta |
1849 |
if (value.contains("windows phone 7.5 mango")) {
|
| 4706 |
amit.gupta |
1850 |
os = "Windows Phone 7.5 Mango";
|
|
|
1851 |
}
|
| 4964 |
amit.gupta |
1852 |
if (value.contains("proprietary")) {
|
|
|
1853 |
if (value.contains("lg"))
|
| 4706 |
amit.gupta |
1854 |
os = "Proprietary LG software";
|
| 4964 |
amit.gupta |
1855 |
else if (value.contains("micromax")) {
|
| 4706 |
amit.gupta |
1856 |
os = "Proprietary Micromax software";
|
| 4964 |
amit.gupta |
1857 |
} else if (value.contains("samsung")) {
|
| 4706 |
amit.gupta |
1858 |
os = "Proprietary Samsung software";
|
| 4964 |
amit.gupta |
1859 |
} else if (value.contains("sony ericsson")) {
|
| 4706 |
amit.gupta |
1860 |
os = "Proprietary Sony Ericsson software";
|
| 4964 |
amit.gupta |
1861 |
} else if (value.contains("spice")) {
|
| 4706 |
amit.gupta |
1862 |
os = "Proprietary Spice software";
|
| 4964 |
amit.gupta |
1863 |
} else if (value.contains("lava")) {
|
| 4706 |
amit.gupta |
1864 |
os = "Proprietary Lava software";
|
| 4964 |
amit.gupta |
1865 |
} else if (value.contains("alcatel")) {
|
| 4706 |
amit.gupta |
1866 |
os = "Proprietary Alcatel software";
|
| 4964 |
amit.gupta |
1867 |
} else if (value.contains("motorola")) {
|
| 4706 |
amit.gupta |
1868 |
os = "Proprietary Motorola software";
|
| 4964 |
amit.gupta |
1869 |
} else if (value.contains("karbonn")) {
|
| 4706 |
amit.gupta |
1870 |
os = "Proprietary Karbonn software";
|
| 4964 |
amit.gupta |
1871 |
} else {
|
| 4706 |
amit.gupta |
1872 |
os = "Proprietary software";
|
|
|
1873 |
}
|
|
|
1874 |
}
|
| 4964 |
amit.gupta |
1875 |
if (value.contains("mmp")) {
|
| 4706 |
amit.gupta |
1876 |
os = "Proprietary Samsung software";
|
|
|
1877 |
}
|
| 4964 |
amit.gupta |
1878 |
if (value.contains("samsung")) {
|
|
|
1879 |
if (value.contains("bada")) {
|
|
|
1880 |
os = "Samsung bada";
|
|
|
1881 |
}
|
|
|
1882 |
if (value.contains("bada 1.2")) {
|
|
|
1883 |
os = "Samsung bada 1.2";
|
|
|
1884 |
}
|
| 4706 |
amit.gupta |
1885 |
}
|
| 4964 |
amit.gupta |
1886 |
if (value.contains("sony ericsson java platform 8")) {
|
| 4706 |
amit.gupta |
1887 |
os = "Proprietary Sony Ericsson software";
|
|
|
1888 |
}
|
| 4964 |
amit.gupta |
1889 |
if (value.contains("s60")) {
|
| 4706 |
amit.gupta |
1890 |
os = "Symbian 60";
|
|
|
1891 |
}
|
| 4964 |
amit.gupta |
1892 |
if (value.contains("symbian")) {
|
|
|
1893 |
if (value.contains("40")) {
|
| 4706 |
amit.gupta |
1894 |
os = "Symbian 40";
|
|
|
1895 |
}
|
| 4964 |
amit.gupta |
1896 |
if (value.contains("60")) {
|
| 4706 |
amit.gupta |
1897 |
os = "Symbian 60";
|
|
|
1898 |
}
|
| 4964 |
amit.gupta |
1899 |
if (value.contains("^3")) {
|
| 4706 |
amit.gupta |
1900 |
os = "Symbian^3";
|
|
|
1901 |
}
|
| 4964 |
amit.gupta |
1902 |
if (value.contains("anna")) {
|
| 4706 |
amit.gupta |
1903 |
os = "Symbian Anna";
|
|
|
1904 |
}
|
| 4964 |
amit.gupta |
1905 |
if (value.contains("belle")) {
|
| 4706 |
amit.gupta |
1906 |
os = "Symbian Belle";
|
|
|
1907 |
}
|
|
|
1908 |
}
|
| 4964 |
amit.gupta |
1909 |
if (value.contains("ios 4")) {
|
| 4706 |
amit.gupta |
1910 |
os = "iOS 4";
|
|
|
1911 |
}
|
| 4964 |
amit.gupta |
1912 |
if (value.contains("ios 5")) {
|
| 4706 |
amit.gupta |
1913 |
os = "iOS 5";
|
|
|
1914 |
}
|
|
|
1915 |
return map.get(os);
|
|
|
1916 |
}
|
| 4964 |
amit.gupta |
1917 |
|
|
|
1918 |
private Map<String, Long> getOSEnumMap() {
|
| 4706 |
amit.gupta |
1919 |
Map<String, Long> map = new HashMap<String, Long>();
|
|
|
1920 |
map.put("Android v1.5 (Cupcake)", 110335L);
|
|
|
1921 |
map.put("Android v1.6 (Donut)", 110336L);
|
|
|
1922 |
map.put("Android v2.1 (Eclair)", 110337L);
|
|
|
1923 |
map.put("Android v2.2 (Froyo)", 110338L);
|
|
|
1924 |
map.put("Android v2.3 (Gingerbread)", 110339L);
|
|
|
1925 |
map.put("Android v3.0 (Honeycomb)", 110340L);
|
|
|
1926 |
map.put("Android v3.1 (Honeycomb)", 110341L);
|
| 4964 |
amit.gupta |
1927 |
map.put("Android v3.2 (Honeycomb)", 110342L);
|
| 4706 |
amit.gupta |
1928 |
map.put("BlackBerry OS", 110343L);
|
|
|
1929 |
map.put("BlackBerry OS 5.0", 110344L);
|
|
|
1930 |
map.put("BlackBerry OS 6.0", 110345L);
|
|
|
1931 |
map.put("BlackBerry OS 7.0", 110346L);
|
|
|
1932 |
map.put("BlackBerry Tablet OS", 110347L);
|
|
|
1933 |
map.put("Brew Mobile Platform", 110348L);
|
|
|
1934 |
map.put("Maemo 5", 110349L);
|
|
|
1935 |
map.put("Windows Phone 7", 110350L);
|
|
|
1936 |
map.put("Windows Phone 7.5 Mango", 110351L);
|
|
|
1937 |
map.put("Proprietary LG software", 110352L);
|
|
|
1938 |
map.put("Proprietary Micromax software", 110353L);
|
|
|
1939 |
map.put("Proprietary Samsung software", 110354L);
|
|
|
1940 |
map.put("Proprietary Sony Ericsson software", 110355L);
|
|
|
1941 |
map.put("Proprietary Spice software", 110356L);
|
|
|
1942 |
map.put("Proprietary Lava software", 110367L);
|
|
|
1943 |
map.put("Proprietary Karbonn software", 110368L);
|
|
|
1944 |
map.put("Proprietary Motorola software", 110369L);
|
|
|
1945 |
map.put("Proprietary Alcatel software", 110370L);
|
| 4964 |
amit.gupta |
1946 |
map.put("Proprietary software", 110371L);
|
| 4706 |
amit.gupta |
1947 |
map.put("Samsung bada", 110357L);
|
|
|
1948 |
map.put("Samsung bada 1.2", 110358L);
|
|
|
1949 |
map.put("Symbian 40", 110360L);
|
|
|
1950 |
map.put("Symbian 60", 110361L);
|
|
|
1951 |
map.put("Symbian^3", 110362L);
|
|
|
1952 |
map.put("Symbian Anna", 110363L);
|
|
|
1953 |
map.put("Symbian Belle", 110364L);
|
|
|
1954 |
map.put("iOS 4", 110365L);
|
|
|
1955 |
map.put("iOS 5", 110366L);
|
| 4964 |
amit.gupta |
1956 |
|
| 4706 |
amit.gupta |
1957 |
return map;
|
| 4964 |
amit.gupta |
1958 |
|
| 4706 |
amit.gupta |
1959 |
}
|
| 5370 |
amit.gupta |
1960 |
|
|
|
1961 |
private Object clone(Object object) throws Exception{
|
|
|
1962 |
// Serializing and deserializing to clone the slide
|
|
|
1963 |
// serialize
|
|
|
1964 |
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
1965 |
ObjectOutputStream out = new ObjectOutputStream(bos);
|
|
|
1966 |
out.writeObject(object);
|
| 4964 |
amit.gupta |
1967 |
|
| 5370 |
amit.gupta |
1968 |
// De-serialization
|
|
|
1969 |
ByteArrayInputStream bis = new ByteArrayInputStream(
|
|
|
1970 |
bos.toByteArray());
|
|
|
1971 |
ObjectInputStream in = new ObjectInputStream(bis);
|
|
|
1972 |
return in.readObject();
|
|
|
1973 |
|
|
|
1974 |
}
|
|
|
1975 |
|
|
|
1976 |
/**
|
|
|
1977 |
*
|
|
|
1978 |
* @throws Exception
|
|
|
1979 |
*/
|
|
|
1980 |
private void copyMedia(String newEntityId, String oldEntityId, Media media) throws Exception {
|
|
|
1981 |
String mediaDirPath = Utils.CONTENT_DB_PATH + "media" + File.separator + newEntityId;
|
|
|
1982 |
File mediaDir = new File(mediaDirPath);
|
|
|
1983 |
if(!mediaDir.exists()) {
|
|
|
1984 |
mediaDir.mkdir();
|
|
|
1985 |
}
|
|
|
1986 |
|
|
|
1987 |
String mediaFilePath = mediaDirPath + File.separator + media.getFileName();
|
|
|
1988 |
String oldMediaFilePath = media.getLocation();
|
|
|
1989 |
|
|
|
1990 |
File mediaFile = new File(mediaFilePath);
|
|
|
1991 |
mediaFile.createNewFile();
|
|
|
1992 |
|
|
|
1993 |
File oldMediaFile = new File(oldMediaFilePath);
|
|
|
1994 |
|
|
|
1995 |
InputStream in = new FileInputStream(oldMediaFile);
|
|
|
1996 |
|
|
|
1997 |
// appending output stream
|
|
|
1998 |
// @rajveer : replacing the existing file
|
|
|
1999 |
OutputStream out = new FileOutputStream(mediaFile);
|
|
|
2000 |
|
|
|
2001 |
try {
|
|
|
2002 |
IOUtils.copy(in, out);
|
|
|
2003 |
}
|
|
|
2004 |
finally {
|
|
|
2005 |
IOUtils.closeQuietly(in);
|
|
|
2006 |
IOUtils.closeQuietly(out);
|
|
|
2007 |
}
|
|
|
2008 |
media.setLocation(mediaFilePath);
|
|
|
2009 |
}
|
| 5396 |
amit.gupta |
2010 |
|
|
|
2011 |
private void migrateHeadSetBack() throws Exception {
|
|
|
2012 |
Map<Long, Long>migratorMap = new HashMap<Long, Long>();
|
|
|
2013 |
migratorMap.put(77777000L,1000291L);
|
|
|
2014 |
migratorMap.put(77777001L,1000292L);
|
|
|
2015 |
migratorMap.put(77777002L,1000293L);
|
|
|
2016 |
migratorMap.put(77777003L,1000294L);
|
|
|
2017 |
migratorMap.put(77777004L,1000295L);
|
|
|
2018 |
migratorMap.put(77777005L,1000296L);
|
|
|
2019 |
migratorMap.put(77777006L,1000297L);
|
|
|
2020 |
migratorMap.put(77777007L,1000298L);
|
|
|
2021 |
migratorMap.put(77777008L,1000299L);
|
|
|
2022 |
migratorMap.put(77777009L,1000300L);
|
|
|
2023 |
migratorMap.put(77777010L,1000301L);
|
|
|
2024 |
migratorMap.put(77777011L,1000302L);
|
|
|
2025 |
migratorMap.put(77777012L,1000303L);
|
|
|
2026 |
migratorMap.put(77777013L,1000304L);
|
|
|
2027 |
migratorMap.put(77777014L,1000305L);
|
|
|
2028 |
migratorMap.put(77777015L,1000306L);
|
|
|
2029 |
migratorMap.put(77777016L,1000351L);
|
|
|
2030 |
migratorMap.put(77777017L,1000352L);
|
|
|
2031 |
migratorMap.put(77777018L,1000353L);
|
|
|
2032 |
migratorMap.put(77777019L,1000363L);
|
|
|
2033 |
migratorMap.put(77777020L,1000364L);
|
|
|
2034 |
migratorMap.put(77777021L,1000365L);
|
|
|
2035 |
migratorMap.put(77777022L,1000425L);
|
|
|
2036 |
migratorMap.put(77777023L,1000426L);
|
|
|
2037 |
migratorMap.put(77777024L,1000430L);
|
|
|
2038 |
migratorMap.put(77777025L,1000434L);
|
|
|
2039 |
migratorMap.put(77777026L,1000435L);
|
|
|
2040 |
migratorMap.put(77777027L,1000436L);
|
|
|
2041 |
migratorMap.put(77777028L,1000437L);
|
|
|
2042 |
migratorMap.put(77777029L,1000438L);
|
|
|
2043 |
migratorMap.put(77777030L,1000439L);
|
|
|
2044 |
migratorMap.put(77777031L,1000440L);
|
|
|
2045 |
migratorMap.put(77777032L,1000441L);
|
|
|
2046 |
migratorMap.put(77777033L,1000442L);
|
|
|
2047 |
migratorMap.put(77777034L,1000443L);
|
|
|
2048 |
migratorMap.put(77777035L,1000444L);
|
|
|
2049 |
migratorMap.put(77777036L,1000445L);
|
|
|
2050 |
migratorMap.put(77777037L,1000446L);
|
|
|
2051 |
migratorMap.put(77777038L,1000447L);
|
|
|
2052 |
migratorMap.put(77777039L,1000449L);
|
|
|
2053 |
migratorMap.put(77777040L,1000450L);
|
|
|
2054 |
migratorMap.put(77777041L,1000451L);
|
|
|
2055 |
migratorMap.put(77777042L,1000452L);
|
|
|
2056 |
migratorMap.put(77777043L,1000453L);
|
|
|
2057 |
migratorMap.put(77777044L,1000454L);
|
|
|
2058 |
migratorMap.put(77777045L,1000455L);
|
|
|
2059 |
migratorMap.put(77777046L,1000518L);
|
|
|
2060 |
migratorMap.put(77777047L,1000521L);
|
|
|
2061 |
migratorMap.put(77777048L,1000572L);
|
|
|
2062 |
migratorMap.put(77777049L,1000575L);
|
|
|
2063 |
migratorMap.put(77777050L,1000623L);
|
|
|
2064 |
migratorMap.put(77777051L,1000625L);
|
|
|
2065 |
migratorMap.put(77777052L,1000626L);
|
|
|
2066 |
migratorMap.put(77777053L,1000627L);
|
|
|
2067 |
migratorMap.put(77777054L,1000628L);
|
|
|
2068 |
migratorMap.put(77777055L,1000874L);
|
|
|
2069 |
migratorMap.put(77777056L,1001200L);
|
|
|
2070 |
migratorMap.put(77777057L,1001375L);
|
|
|
2071 |
migratorMap.put(77777058L,1001376L);
|
|
|
2072 |
migratorMap.put(77777059L,1001378L);
|
|
|
2073 |
migratorMap.put(77777060L,1001382L);
|
|
|
2074 |
migratorMap.put(77777061L,1001808L);
|
|
|
2075 |
migratorMap.put(77777062L,1001809L);
|
|
|
2076 |
migratorMap.put(77777063L,1001810L);
|
|
|
2077 |
migratorMap.put(77777064L,1001811L);
|
|
|
2078 |
migratorMap.put(77777065L,1001812L);
|
|
|
2079 |
migratorMap.put(77777066L,1001814L);
|
|
|
2080 |
migratorMap.put(77777067L,1001815L);
|
|
|
2081 |
migratorMap.put(77777068L,1001816L);
|
|
|
2082 |
migratorMap.put(77777069L,1001817L);
|
|
|
2083 |
migratorMap.put(77777070L,1001818L);
|
|
|
2084 |
migratorMap.put(77777071L,1001819L);
|
|
|
2085 |
migratorMap.put(77777072L,1001820L);
|
|
|
2086 |
migratorMap.put(77777073L,1001821L);
|
|
|
2087 |
migratorMap.put(77777074L,1001822L);
|
|
|
2088 |
migratorMap.put(77777075L,1001823L);
|
|
|
2089 |
migratorMap.put(77777076L,1001824L);
|
|
|
2090 |
migratorMap.put(77777077L,1001825L);
|
|
|
2091 |
migratorMap.put(77777078L,1002318L);
|
|
|
2092 |
migratorMap.put(77777079L,1002320L);
|
|
|
2093 |
migratorMap.put(77777080L,1003852L);
|
|
|
2094 |
migratorMap.put(77777081L,1003853L);
|
|
|
2095 |
migratorMap.put(77777082L,1003854L);
|
|
|
2096 |
migratorMap.put(77777083L,1003855L);
|
|
|
2097 |
migratorMap.put(77777084L,1003856L);
|
|
|
2098 |
migratorMap.put(77777085L,1003857L);
|
|
|
2099 |
migratorMap.put(77777086L,1003916L);
|
|
|
2100 |
migratorMap.put(77777087L,1003917L);
|
|
|
2101 |
migratorMap.put(77777088L,1003918L);
|
|
|
2102 |
migratorMap.put(77777089L,1003919L);
|
|
|
2103 |
migratorMap.put(77777090L,1003920L);
|
|
|
2104 |
migratorMap.put(77777091L,1003921L);
|
|
|
2105 |
migratorMap.put(77777092L,1003922L);
|
|
|
2106 |
migratorMap.put(77777093L,1003923L);
|
|
|
2107 |
migratorMap.put(77777094L,1003924L);
|
|
|
2108 |
migratorMap.put(77777095L,1003925L);
|
|
|
2109 |
migratorMap.put(77777096L,1003926L);
|
|
|
2110 |
migratorMap.put(77777097L,1003927L);
|
|
|
2111 |
migratorMap.put(77777098L,1004087L);
|
|
|
2112 |
migratorMap.put(77777099L,1004088L);
|
|
|
2113 |
migratorMap.put(77777100L,1004089L);
|
|
|
2114 |
migratorMap.put(77777101L,1004134L);
|
|
|
2115 |
migratorMap.put(77777102L,1004135L);
|
|
|
2116 |
migratorMap.put(77777103L,1004139L);
|
|
|
2117 |
|
|
|
2118 |
for(Map.Entry<Long, Long> entry : migratorMap.entrySet()) {
|
|
|
2119 |
Long newId = entry.getKey();
|
|
|
2120 |
Long validId = entry.getValue();
|
|
|
2121 |
Entity entity = CreationUtils.getEntity(newId);
|
|
|
2122 |
EntityState es = CreationUtils.getEntityState(newId);
|
|
|
2123 |
Slide sl = entity.getSlide(130130);
|
| 5397 |
amit.gupta |
2124 |
/*entity.setID(validId);
|
|
|
2125 |
es.setID(validId);*/
|
| 5396 |
amit.gupta |
2126 |
|
| 7129 |
amit.gupta |
2127 |
|
| 5370 |
amit.gupta |
2128 |
|
| 5396 |
amit.gupta |
2129 |
CreationUtils.updateEntity(entity);
|
|
|
2130 |
CreationUtils.updateEntityState(es);
|
|
|
2131 |
CreationUtils.deleteEntity(newId);
|
|
|
2132 |
System.out.println(validId + " : " + es.getCategoryID() + ", removed entity id:" + newId);
|
|
|
2133 |
|
|
|
2134 |
}
|
|
|
2135 |
|
|
|
2136 |
}
|
| 7129 |
amit.gupta |
2137 |
|
|
|
2138 |
private void migrateTabletsBack() throws Exception {
|
| 7131 |
amit.gupta |
2139 |
//This entity is created after migration have to be deleted. Vrinda have to rmk it
|
|
|
2140 |
CreationUtils.deleteEntity(1006812);
|
| 7129 |
amit.gupta |
2141 |
Date now = new Date();
|
|
|
2142 |
Collection<Entity> entities = CreationUtils.getEntities(20010);
|
|
|
2143 |
//entities = (List<Entity>)this.clone(entities);
|
|
|
2144 |
for (Entity entity : entities) {
|
|
|
2145 |
long entityId = entity.getID();
|
|
|
2146 |
if(entityId>9999999){
|
|
|
2147 |
long oldEntityId = entityId%10000000;
|
|
|
2148 |
System.out.println(oldEntityId);
|
|
|
2149 |
EntityState es = CreationUtils.getEntityState(entityId);
|
|
|
2150 |
if(es != null) {
|
|
|
2151 |
if (es.getStatus().equals(EntityStatus.READY) || es.getStatus().equals(EntityStatus.COMPLETE)){
|
|
|
2152 |
es.setStatus(EntityStatus.READY);
|
|
|
2153 |
es.setMerkedReadyOn(now);
|
|
|
2154 |
}
|
|
|
2155 |
es.setID(oldEntityId);
|
|
|
2156 |
entity.setID(oldEntityId);
|
|
|
2157 |
entity.setCategoryID(10010);
|
|
|
2158 |
es.setCategoryID(10010);
|
|
|
2159 |
CreationUtils.updateEntity(entity);
|
|
|
2160 |
CreationUtils.updateEntityState(es);
|
|
|
2161 |
CreationUtils.deleteEntity(entityId);
|
|
|
2162 |
System.out.println(entityId + " moved back");
|
|
|
2163 |
|
|
|
2164 |
} else {
|
|
|
2165 |
CreationUtils.deleteEntity(entityId);
|
|
|
2166 |
System.out.println("Deleted " + entityId + " due to incomplete tablets");
|
|
|
2167 |
}
|
|
|
2168 |
}else {
|
|
|
2169 |
entity.setCategoryID(10010);
|
|
|
2170 |
EntityState es = CreationUtils.getEntityState(entityId);
|
|
|
2171 |
es.setCategoryID(10010);
|
|
|
2172 |
CreationUtils.updateEntity(entity);
|
|
|
2173 |
CreationUtils.updateEntityState(es);
|
|
|
2174 |
}
|
|
|
2175 |
|
|
|
2176 |
|
|
|
2177 |
}
|
|
|
2178 |
|
|
|
2179 |
}
|
| 5760 |
amit.gupta |
2180 |
|
|
|
2181 |
public String getTitle(Entity entity){
|
|
|
2182 |
String brand = entity.getBrand();
|
|
|
2183 |
String modelName = entity.getModelName();
|
|
|
2184 |
String modelNumber = entity.getModelNumber();
|
|
|
2185 |
String titleString = "";
|
|
|
2186 |
if(StringUtils.isEmpty(modelName)){
|
|
|
2187 |
titleString = brand + " " + modelNumber + " Price in India | Specifications, Features and Reviews";
|
|
|
2188 |
}else {
|
|
|
2189 |
titleString = brand + " " + modelName + " Price in India | " + modelNumber + " Specifications, Features and Reviews";
|
|
|
2190 |
}
|
|
|
2191 |
return titleString;
|
|
|
2192 |
}
|
|
|
2193 |
|
|
|
2194 |
public String getMetaDescription(ExpandedEntity expEntity){
|
| 12230 |
amit.gupta |
2195 |
|
|
|
2196 |
Category parentCategory;
|
|
|
2197 |
Category category = expEntity.getCategory();
|
|
|
2198 |
if(category!=null){
|
|
|
2199 |
parentCategory = category.getParentCategory();
|
|
|
2200 |
String categoryName = parentCategory.getLabel();
|
|
|
2201 |
if (parentCategory.getID()== Utils.MOBILE_ACCESSORIES_CATEGORY){
|
|
|
2202 |
categoryName = expEntity.getCategory().getLabel();
|
|
|
2203 |
}
|
|
|
2204 |
String template = "Buy {0} {1} {2} at $minPriceItem.getSellingPrice(). All {3} are 100% Original and carry full Manufacturers Warranty since we procure directly from the Brand. Free Next Day Delivery.";
|
|
|
2205 |
return MessageFormat.format(template, expEntity.getBrand(), expEntity.getModelName(), expEntity.getModelNumber(), categoryName.toLowerCase());
|
|
|
2206 |
} else {
|
|
|
2207 |
System.out.println("category is null for : " + expEntity.getID());
|
|
|
2208 |
return "";
|
| 5760 |
amit.gupta |
2209 |
}
|
|
|
2210 |
}
|
| 7037 |
amit.gupta |
2211 |
|
|
|
2212 |
public void migrateTablets() throws Exception {
|
|
|
2213 |
|
|
|
2214 |
//Starting entity id for new Category with 10000
|
|
|
2215 |
Collection<Entity> entities = CreationUtils.getEntities(10010);
|
|
|
2216 |
long newCounter;
|
|
|
2217 |
//entities = (List<Entity>)this.clone(entities);
|
|
|
2218 |
for (Entity entity : entities) {
|
|
|
2219 |
long entityId = entity.getID();
|
|
|
2220 |
newCounter = Long.parseLong("1" + String.valueOf(entityId));
|
|
|
2221 |
Entity newEntity = new Entity(newCounter, 20010);
|
|
|
2222 |
try {
|
|
|
2223 |
List<Slide> entitySlides = entity.getSlides();
|
|
|
2224 |
if (entity == null || entitySlides == null) {
|
|
|
2225 |
continue;
|
|
|
2226 |
}
|
|
|
2227 |
List<Slide> newEntitySlides = new ArrayList<Slide>();
|
|
|
2228 |
/*Slide introSlide = entity.getSlide(130001);
|
|
|
2229 |
Slide summarySlide = entity.getSlide(130054);
|
|
|
2230 |
Slide packageContents = entity.getSlide(130025);*/
|
|
|
2231 |
for (Slide slide : entitySlides) {
|
|
|
2232 |
if (Arrays.asList(130054L, 130025L, 130001L).contains(slide.getSlideDefinitionID())) {
|
|
|
2233 |
slide=(Slide)this.clone(slide);
|
|
|
2234 |
newEntitySlides.add(slide);
|
|
|
2235 |
}
|
|
|
2236 |
FreeformContent ffc1 = slide.getFreeformContent();
|
|
|
2237 |
if(ffc1 != null){
|
|
|
2238 |
Map<String, Media> mediaMap = ffc1.getMedias();
|
|
|
2239 |
if(mediaMap==null){
|
|
|
2240 |
continue;
|
|
|
2241 |
}
|
|
|
2242 |
for(Media media : mediaMap.values()){
|
|
|
2243 |
if(media.getType().equals(Type.IMAGE) || media.getType().equals(Type.DOCUMENT)){
|
|
|
2244 |
copyMedia(String.valueOf(newCounter), String.valueOf(entityId),media);
|
|
|
2245 |
}
|
|
|
2246 |
}
|
|
|
2247 |
}
|
|
|
2248 |
}
|
|
|
2249 |
|
|
|
2250 |
List<Long> newSlideSequence = new ArrayList<Long>();
|
|
|
2251 |
newSlideSequence.add(130001L);
|
|
|
2252 |
newSlideSequence.add(130054L);
|
|
|
2253 |
newSlideSequence.add(130172L);
|
|
|
2254 |
newSlideSequence.add(130173L);
|
|
|
2255 |
newSlideSequence.add(130174L);
|
|
|
2256 |
newSlideSequence.add(130175L);
|
|
|
2257 |
newSlideSequence.add(130176L);
|
|
|
2258 |
newSlideSequence.add(130177L);
|
|
|
2259 |
newSlideSequence.add(130178L);
|
|
|
2260 |
newSlideSequence.add(130180L);
|
|
|
2261 |
newSlideSequence.add(130183L);
|
|
|
2262 |
newSlideSequence.add(130025L);
|
|
|
2263 |
|
|
|
2264 |
newEntity.setSlideSequence(newSlideSequence);
|
|
|
2265 |
newEntity.setBrand(entity.getBrand());
|
|
|
2266 |
newEntity.setModelName(entity.getModelName());
|
|
|
2267 |
newEntity.setModelNumber(entity.getModelNumber());
|
|
|
2268 |
//entitySlides.remove(featureSlide);
|
|
|
2269 |
newEntity.setSlides(newEntitySlides);
|
|
|
2270 |
EntityState es = new EntityState(newCounter, 20010, "admin");
|
|
|
2271 |
es.setBrand(entity.getBrand());
|
|
|
2272 |
es.setModelName(entity.getModelName());
|
|
|
2273 |
es.setModelNumber(entity.getModelNumber());
|
|
|
2274 |
CreationUtils.createEntity(newEntity, es);
|
|
|
2275 |
System.out.println("New entity : " + newCounter + " created using : " + entityId);
|
|
|
2276 |
System.out.println(CreationUtils.getEntity(newCounter));
|
|
|
2277 |
newCounter++;
|
|
|
2278 |
}catch(Exception e){
|
|
|
2279 |
System.out.println("Could not migrate " + entityId);
|
|
|
2280 |
}
|
|
|
2281 |
}
|
|
|
2282 |
|
|
|
2283 |
}
|
| 5396 |
amit.gupta |
2284 |
|
| 7111 |
amit.gupta |
2285 |
public void migrateImagesInTablets() throws Exception {
|
|
|
2286 |
|
|
|
2287 |
//Starting entity id for new Category with 10000
|
|
|
2288 |
Collection<Entity> entities = CreationUtils.getEntities(10010);
|
|
|
2289 |
long newCounter;
|
|
|
2290 |
//entities = (List<Entity>)this.clone(entities);
|
|
|
2291 |
for (Entity entity : entities) {
|
|
|
2292 |
long entityId = entity.getID();
|
|
|
2293 |
newCounter = Long.parseLong("1" + String.valueOf(entityId));
|
|
|
2294 |
Entity newEntity = CreationUtils.getEntity(newCounter);
|
|
|
2295 |
try {
|
|
|
2296 |
if (newEntity == null) {
|
|
|
2297 |
continue;
|
|
|
2298 |
}
|
|
|
2299 |
Slide introSlide = newEntity.getSlide(130001L);
|
|
|
2300 |
Slide looknfeelSlide = entity.getSlide(130002L);
|
|
|
2301 |
/*
|
|
|
2302 |
* Slide introSlide = entity.getSlide(130001); Slide
|
|
|
2303 |
* summarySlide = entity.getSlide(130054); Slide packageContents
|
|
|
2304 |
* = entity.getSlide(130025);
|
|
|
2305 |
*/
|
| 7037 |
amit.gupta |
2306 |
|
| 7111 |
amit.gupta |
2307 |
if (looknfeelSlide != null) {
|
|
|
2308 |
FreeformContent ffc1 = looknfeelSlide.getFreeformContent();
|
|
|
2309 |
if (ffc1 != null) {
|
|
|
2310 |
Map<String, Media> mediaMap = ffc1.getMedias();
|
|
|
2311 |
if (mediaMap == null) {
|
|
|
2312 |
continue;
|
|
|
2313 |
}
|
|
|
2314 |
FreeformContent introFfc = introSlide
|
|
|
2315 |
.getFreeformContent();
|
| 7123 |
amit.gupta |
2316 |
Map<String, Media> introMediaMap = new LinkedHashMap<String, Media>();
|
|
|
2317 |
introFfc.setMedias(introMediaMap);
|
| 7111 |
amit.gupta |
2318 |
Set<String> introMediaMapKeys = introMediaMap.keySet();
|
| 7123 |
amit.gupta |
2319 |
for (Map.Entry<String, Media> entry : mediaMap.entrySet()) {
|
| 7111 |
amit.gupta |
2320 |
Media entryValue = entry.getValue();
|
|
|
2321 |
String entryKey = entry.getKey();
|
|
|
2322 |
if (!introMediaMapKeys.contains(entryKey)) {
|
|
|
2323 |
introMediaMap.put(entryKey,
|
|
|
2324 |
(Media) clone(entryValue));
|
|
|
2325 |
if (entryValue.getType().equals(Type.IMAGE)
|
|
|
2326 |
|| entryValue.equals(Type.DOCUMENT)) {
|
|
|
2327 |
try {
|
|
|
2328 |
copyMedia(String.valueOf(newCounter),
|
|
|
2329 |
String.valueOf(entityId),
|
|
|
2330 |
entryValue);
|
|
|
2331 |
} catch (Exception e) {
|
|
|
2332 |
System.out
|
|
|
2333 |
.println("could not copy file "
|
|
|
2334 |
+ entityId);
|
|
|
2335 |
}
|
|
|
2336 |
}
|
|
|
2337 |
}
|
|
|
2338 |
}
|
|
|
2339 |
}
|
|
|
2340 |
}
|
|
|
2341 |
|
|
|
2342 |
CreationUtils.updateEntity(newEntity);
|
|
|
2343 |
System.out.println("New entity : " + newCounter
|
|
|
2344 |
+ " created using : " + entityId);
|
|
|
2345 |
} catch (Exception e) {
|
|
|
2346 |
e.printStackTrace();
|
|
|
2347 |
System.out.println("Could not migrate " + entityId);
|
|
|
2348 |
}
|
|
|
2349 |
}
|
|
|
2350 |
|
| 7917 |
amit.gupta |
2351 |
|
| 457 |
rajveer |
2352 |
}
|
| 7917 |
amit.gupta |
2353 |
private void miscilleniousPopulate() throws Exception{
|
|
|
2354 |
|
|
|
2355 |
DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
|
|
|
2356 |
|
|
|
2357 |
//Get All Enum Values of Communication facilities 70114;
|
|
|
2358 |
Map <Long, Entity> allEntities = CreationUtils.getEntities();
|
|
|
2359 |
/*Map <Long, Entity> allEntities =new HashMap<Long, Entity>();
|
|
|
2360 |
allEntities.put(1000069l, CreationUtils.getEntity(1000069l));*/
|
|
|
2361 |
for (Map.Entry<Long, Entity> entry:allEntities.entrySet()){
|
|
|
2362 |
Entity entity = entry.getValue();
|
|
|
2363 |
Long categoryId = entity.getCategoryID();
|
|
|
2364 |
EntityState es = CreationUtils.getEntityState(entity.getID());
|
|
|
2365 |
if ((categoryId == 10002 || categoryId == 10003 || categoryId == 10004 || categoryId == 10005)
|
|
|
2366 |
&& (es != null && es.getStatus().equals(EntityStatus.READY))) {
|
|
|
2367 |
ExpandedEntity expEntity = new ExpandedEntity(entity);
|
|
|
2368 |
Slide miscSlide = expEntity.getSlide(130024l);
|
| 7932 |
amit.gupta |
2369 |
if(miscSlide != null) {
|
|
|
2370 |
List<Feature> miscFeatures = miscSlide.getFeatures();
|
|
|
2371 |
if(CollectionUtils.isNotEmpty(miscFeatures)){
|
| 7933 |
amit.gupta |
2372 |
Iterator<Feature> iter = miscFeatures.iterator();
|
|
|
2373 |
while(iter.hasNext()) {
|
|
|
2374 |
Feature f =iter.next();
|
|
|
2375 |
if (f.getFeatureDefinitionID() == 120484l || f.getFeatureDefinitionID() == 120483l || f.getFeatureDefinitionID() == 1204821 || f.getFeatureDefinitionID() == 120481l){
|
| 7932 |
amit.gupta |
2376 |
List<Bullet> bulletList = f.getBullets();
|
|
|
2377 |
PrimitiveDataObject b = (PrimitiveDataObject)bulletList.get(0).getDataObject();
|
|
|
2378 |
String bulletValue = b.getValue();
|
|
|
2379 |
String newString = bulletValue;
|
| 7933 |
amit.gupta |
2380 |
if(bulletValue.startsWith(", ") || bulletValue.contains(",,") || bulletValue.contains("<li>")){
|
| 7932 |
amit.gupta |
2381 |
System.out.println(entity.getID());
|
|
|
2382 |
bulletList = new ArrayList<Bullet>();
|
| 7933 |
amit.gupta |
2383 |
newString = bulletValue.replaceAll("<li>|</li>|<ul>|</ul>", ",").replaceAll(",,", ",").replaceAll(", ,", ", ").replaceAll(", $", "");
|
|
|
2384 |
|
|
|
2385 |
System.out.println(newString);
|
| 7932 |
amit.gupta |
2386 |
if(newString.startsWith(", ") ){
|
|
|
2387 |
newString = newString.replaceFirst(", ", "");
|
| 7917 |
amit.gupta |
2388 |
}
|
| 7932 |
amit.gupta |
2389 |
bulletList.add(new Bullet(new PrimitiveDataObject(newString)));
|
|
|
2390 |
f.setBullets(bulletList);
|
|
|
2391 |
System.out.println(newString);
|
| 7917 |
amit.gupta |
2392 |
}
|
| 7932 |
amit.gupta |
2393 |
if ( newString.equals(" ") || newString.equals("") || newString.equals(" ") || newString.equals(" ")){
|
| 7933 |
amit.gupta |
2394 |
iter.remove();
|
| 7917 |
amit.gupta |
2395 |
}
|
|
|
2396 |
}
|
| 7932 |
amit.gupta |
2397 |
}
|
| 7933 |
amit.gupta |
2398 |
CreationUtils.updateEntity(entity);
|
|
|
2399 |
touchEntityState(entity.getID());
|
| 7917 |
amit.gupta |
2400 |
}
|
|
|
2401 |
}
|
| 7932 |
amit.gupta |
2402 |
//touchEntityState(entity.getID());
|
|
|
2403 |
}
|
| 7917 |
amit.gupta |
2404 |
}
|
|
|
2405 |
}
|
| 7973 |
amit.gupta |
2406 |
|
|
|
2407 |
private void step2() throws Exception {
|
|
|
2408 |
//Get All Enum Values of Communication facilities 70114;
|
| 7975 |
amit.gupta |
2409 |
//Map <Long, Entity> allEntities = CreationUtils.getEntities();
|
|
|
2410 |
Map <Long, Entity> allEntities =new HashMap<Long, Entity>();
|
|
|
2411 |
allEntities.put(1007937l, CreationUtils.getEntity(1007937l));
|
|
|
2412 |
allEntities.put(1007932l, CreationUtils.getEntity(1007932l));
|
|
|
2413 |
allEntities.put(1007930l, CreationUtils.getEntity(1007930l));
|
|
|
2414 |
allEntities.put(1007934l, CreationUtils.getEntity(1007934l));
|
|
|
2415 |
allEntities.put(1007936l, CreationUtils.getEntity(1007936l));
|
|
|
2416 |
allEntities.put(1007935l, CreationUtils.getEntity(1007935l));
|
| 7973 |
amit.gupta |
2417 |
for (Map.Entry<Long, Entity> entry:allEntities.entrySet()){
|
|
|
2418 |
Entity entity = entry.getValue();
|
|
|
2419 |
Long categoryId = entity.getCategoryID();
|
|
|
2420 |
EntityState es = CreationUtils.getEntityState(entity.getID());
|
| 7975 |
amit.gupta |
2421 |
if ((categoryId == 10002 || categoryId == 10003 || categoryId == 10004 || categoryId == 10005) && es != null ) {
|
| 7973 |
amit.gupta |
2422 |
List<Slide> allSlides = entity.getSlides();
|
|
|
2423 |
Slide slMaps = entity.getSlide(130022l);
|
|
|
2424 |
Slide slConnectivity = (categoryId == 10005 ? entity.getSlide(130058l) : entity.getSlide(130007l));
|
|
|
2425 |
if(slConnectivity != null){
|
|
|
2426 |
if(slConnectivity.getSlideDefinitionID() ==130058l){
|
|
|
2427 |
Slide newSlide = new Slide(130007l);
|
|
|
2428 |
newSlide.setFeatures(slConnectivity.getFeatures());
|
|
|
2429 |
allSlides.remove(slConnectivity);
|
|
|
2430 |
allSlides.add(newSlide);
|
|
|
2431 |
slConnectivity = newSlide;
|
|
|
2432 |
|
|
|
2433 |
List<Long> slideSequence = entity.getSlideSequence();
|
|
|
2434 |
int index =slideSequence.indexOf(130058l);
|
|
|
2435 |
slideSequence.remove(index);;
|
|
|
2436 |
slideSequence.add(index, 130007l);
|
|
|
2437 |
}
|
|
|
2438 |
if(slMaps != null) {
|
|
|
2439 |
List<Feature> mapsFeatures = slMaps.getFeatures();
|
|
|
2440 |
allSlides.remove(slMaps);
|
|
|
2441 |
if(mapsFeatures != null){
|
|
|
2442 |
for (Feature mapsFeature : mapsFeatures){
|
|
|
2443 |
if(mapsFeature.getFeatureDefinitionID() == 120046l){
|
|
|
2444 |
slConnectivity.getFeatures().add(mapsFeature);
|
|
|
2445 |
break;
|
|
|
2446 |
}
|
|
|
2447 |
}
|
|
|
2448 |
|
|
|
2449 |
}
|
|
|
2450 |
}
|
|
|
2451 |
|
|
|
2452 |
}
|
|
|
2453 |
|
|
|
2454 |
Slide slKeyBoard = entity.getSlide(130026l);
|
|
|
2455 |
Slide slDisplay = entity.getSlide(130003l);
|
|
|
2456 |
Slide slSummary = entity.getSlide(130054l);
|
|
|
2457 |
Slide slLookNFeel = entity.getSlide(130002l);
|
|
|
2458 |
Feature hardkeysFeature = null;
|
|
|
2459 |
if (slKeyBoard != null) {
|
|
|
2460 |
List<Feature> keyBoardFeatures = slKeyBoard.getFeatures();
|
|
|
2461 |
Iterator<Feature> iter = keyBoardFeatures.iterator();
|
|
|
2462 |
while(iter.hasNext()){
|
|
|
2463 |
Feature feature = iter.next();
|
|
|
2464 |
if(feature.getFeatureDefinitionID() == 120010l){
|
| 7975 |
amit.gupta |
2465 |
if(slSummary!=null){
|
| 7984 |
amit.gupta |
2466 |
slSummary.getFeatures().add(feature);
|
| 7975 |
amit.gupta |
2467 |
}
|
| 7973 |
amit.gupta |
2468 |
iter.remove();
|
|
|
2469 |
}
|
|
|
2470 |
if(feature.getFeatureDefinitionID() == 120082l){
|
|
|
2471 |
slDisplay.getFeatures().add(feature);
|
|
|
2472 |
iter.remove();
|
|
|
2473 |
}
|
|
|
2474 |
if(feature.getFeatureDefinitionID() == 120009l){
|
|
|
2475 |
slLookNFeel.getFeatures().add(feature);
|
|
|
2476 |
iter.remove();
|
|
|
2477 |
}
|
|
|
2478 |
if(feature.getFeatureDefinitionID() == 120048l ){
|
|
|
2479 |
if(hardkeysFeature == null) {
|
|
|
2480 |
hardkeysFeature = feature;
|
|
|
2481 |
}else {
|
|
|
2482 |
if(feature.getBullets() != null){
|
|
|
2483 |
hardkeysFeature.getBullets().addAll(feature.getBullets());
|
|
|
2484 |
slLookNFeel.getFeatures().add(hardkeysFeature);
|
|
|
2485 |
}
|
|
|
2486 |
}
|
|
|
2487 |
iter.remove();
|
|
|
2488 |
}
|
|
|
2489 |
if(feature.getFeatureDefinitionID() == 120049l ){
|
|
|
2490 |
if(hardkeysFeature == null){
|
|
|
2491 |
hardkeysFeature = new Feature(120048l);
|
|
|
2492 |
hardkeysFeature.setBullets(feature.getBullets());
|
|
|
2493 |
} else {
|
|
|
2494 |
if(feature.getBullets() != null){
|
|
|
2495 |
hardkeysFeature.getBullets().addAll(feature.getBullets());
|
|
|
2496 |
slLookNFeel.getFeatures().add(hardkeysFeature);
|
|
|
2497 |
}
|
|
|
2498 |
}
|
|
|
2499 |
iter.remove();
|
|
|
2500 |
}
|
|
|
2501 |
}
|
|
|
2502 |
|
|
|
2503 |
allSlides.remove(slKeyBoard);
|
|
|
2504 |
}
|
|
|
2505 |
CreationUtils.updateEntity(entity);
|
| 7975 |
amit.gupta |
2506 |
//touchEntityState(entity.getID());
|
| 7973 |
amit.gupta |
2507 |
}
|
|
|
2508 |
}
|
|
|
2509 |
|
|
|
2510 |
}
|
| 7984 |
amit.gupta |
2511 |
|
|
|
2512 |
private void step4() throws Exception {
|
|
|
2513 |
//Get All Enum Values of Communication facilities 70114;
|
|
|
2514 |
Map <Long, Entity> allEntities = CreationUtils.getEntities();
|
|
|
2515 |
/*Map <Long, Entity> allEntities = new HashMap<Long, Entity>();
|
|
|
2516 |
allEntities.put(1002529l, CreationUtils.getEntity(1002529l));
|
|
|
2517 |
allEntities.put(1007932l, CreationUtils.getEntity(1007932l));
|
|
|
2518 |
allEntities.put(1007930l, CreationUtils.getEntity(1007930l));
|
|
|
2519 |
allEntities.put(1007934l, CreationUtils.getEntity(1007934l));
|
|
|
2520 |
allEntities.put(1007936l, CreationUtils.getEntity(1007936l));
|
|
|
2521 |
allEntities.put(1007935l, CreationUtils.getEntity(1007935l));*/
|
|
|
2522 |
for (Map.Entry<Long, Entity> entry:allEntities.entrySet()){
|
|
|
2523 |
Entity entity = entry.getValue();
|
|
|
2524 |
Long categoryId = entity.getCategoryID();
|
|
|
2525 |
EntityState es = CreationUtils.getEntityState(entity.getID());
|
|
|
2526 |
if ((categoryId == 10002 || categoryId == 10003 || categoryId == 10004 || categoryId == 10005) && es != null && !es.getStatus().equals(EntityStatus.UNASSIGNED)) {
|
|
|
2527 |
List<Slide> allSlides = entity.getSlides();
|
|
|
2528 |
if(allSlides != null){
|
|
|
2529 |
for(Slide slide:allSlides) {
|
|
|
2530 |
if(slide!=null){
|
|
|
2531 |
List <Feature> features = slide.getFeatures();
|
|
|
2532 |
Iterator<Feature> fIterator = features.iterator();
|
|
|
2533 |
while (fIterator.hasNext()){
|
|
|
2534 |
Feature f = fIterator.next();
|
|
|
2535 |
long fId = f.getFeatureDefinitionID();
|
|
|
2536 |
if(fId == 120011 || fId == 120020 || fId == 120051 || fId == 120025 || fId == 120056 || fId == 120216 || fId == 120045 || fId == 120010){
|
|
|
2537 |
fIterator.remove();
|
|
|
2538 |
}
|
|
|
2539 |
if(fId==120144){
|
|
|
2540 |
String value = "Adobe flash player";
|
|
|
2541 |
List<Bullet> flashb = f.getBullets();
|
|
|
2542 |
if(flashb !=null && flashb.size() > 0){
|
|
|
2543 |
value = ((PrimitiveDataObject)flashb.get(0).getDataObject()).getValue();
|
|
|
2544 |
}
|
|
|
2545 |
Slide miscSlide1 = entity.getSlide(130024l);
|
|
|
2546 |
if(miscSlide1 != null){
|
|
|
2547 |
List <Feature> mfeatures = miscSlide1.getFeatures();
|
|
|
2548 |
Iterator<Feature> mIterator = mfeatures.iterator();
|
|
|
2549 |
while (mIterator.hasNext()){
|
|
|
2550 |
Feature mf = mIterator.next();
|
|
|
2551 |
if(mf != null){
|
|
|
2552 |
if(mf.getFeatureDefinitionID() == 120484l){
|
|
|
2553 |
Bullet b = mf.getBullets().get(0);
|
|
|
2554 |
String finalValue = ((PrimitiveDataObject)b.getDataObject()).getValue() + ", " + value;
|
|
|
2555 |
b.setDataObject(new PrimitiveDataObject(finalValue));
|
|
|
2556 |
}
|
|
|
2557 |
}
|
|
|
2558 |
}
|
|
|
2559 |
} else {
|
|
|
2560 |
System.out.println("no misc for entity : " + entity.getID());
|
|
|
2561 |
}
|
|
|
2562 |
fIterator.remove();
|
|
|
2563 |
}
|
|
|
2564 |
}
|
|
|
2565 |
}
|
|
|
2566 |
}
|
|
|
2567 |
try{
|
|
|
2568 |
CreationUtils.updateEntity(entity);
|
|
|
2569 |
}catch (Exception e){
|
|
|
2570 |
System.out.println("Could not update entity : " + entity.getID());
|
|
|
2571 |
}
|
|
|
2572 |
touchEntityState(entity.getID());
|
|
|
2573 |
}
|
|
|
2574 |
}
|
|
|
2575 |
}
|
|
|
2576 |
}
|
| 7997 |
amit.gupta |
2577 |
private void step6() throws Exception {
|
|
|
2578 |
//Get All Enum Values of Communication facilities 70114;
|
| 8014 |
amit.gupta |
2579 |
DefinitionsContainer defc = Catalog.getInstance().getDefinitionsContainer();
|
|
|
2580 |
Map <Long, Long> allEntities = getValues();
|
|
|
2581 |
for (Map.Entry<Long, Long> entry:allEntities.entrySet()){
|
|
|
2582 |
Long entityId = entry.getKey();
|
|
|
2583 |
Entity entity = CreationUtils.getEntity(entityId);
|
| 7997 |
amit.gupta |
2584 |
Long categoryId = entity.getCategoryID();
|
| 8014 |
amit.gupta |
2585 |
boolean found = false;
|
| 7997 |
amit.gupta |
2586 |
//System.out.println("entity : " + entity.getID());
|
|
|
2587 |
EntityState es = CreationUtils.getEntityState(entity.getID());
|
|
|
2588 |
if(!es.getStatus().equals(EntityStatus.UNASSIGNED)) {
|
|
|
2589 |
if ((categoryId == 10002 || categoryId == 10003 || categoryId == 10004 || categoryId == 10005)
|
|
|
2590 |
&& es != null) {
|
| 8009 |
amit.gupta |
2591 |
|
| 7997 |
amit.gupta |
2592 |
Slide videoSlide = entity.getSlide(130031l);
|
|
|
2593 |
if(videoSlide != null){
|
| 8014 |
amit.gupta |
2594 |
List<Feature> features = videoSlide.getFeatures();
|
|
|
2595 |
if(features != null) {
|
|
|
2596 |
Iterator<Feature> iter = features.iterator();
|
|
|
2597 |
while(iter.hasNext()){
|
|
|
2598 |
Feature f = iter.next();
|
|
|
2599 |
if(f.getFeatureDefinitionID() == 120475l){
|
|
|
2600 |
found = true;
|
|
|
2601 |
if(!entry.getValue().equals(((EnumDataObject)f.getBullets().get(0).getDataObject()).getEnumValueID())){
|
|
|
2602 |
f.getBullets().get(0).setDataObject(new EnumDataObject(entry.getValue()));
|
|
|
2603 |
try{
|
|
|
2604 |
System.out.println("Recording feature updated:" + entityId);
|
|
|
2605 |
CreationUtils.updateEntity(entity);
|
|
|
2606 |
touchEntityState(entityId);
|
|
|
2607 |
}catch (Exception e){
|
|
|
2608 |
System.out.println("Could not update entity : " + entity.getID());
|
|
|
2609 |
}
|
|
|
2610 |
}
|
|
|
2611 |
break;
|
|
|
2612 |
}
|
| 8009 |
amit.gupta |
2613 |
}
|
| 8014 |
amit.gupta |
2614 |
|
|
|
2615 |
if(!found){
|
|
|
2616 |
Feature f = new Feature(120475l);
|
|
|
2617 |
f.setBullets(Arrays.asList(new Bullet(new EnumDataObject(entry.getValue()))));
|
|
|
2618 |
features.add(f);
|
|
|
2619 |
try{
|
|
|
2620 |
System.out.println("Recording feature created:" + entityId);
|
|
|
2621 |
CreationUtils.updateEntity(entity);
|
|
|
2622 |
touchEntityState(entityId);
|
|
|
2623 |
}catch (Exception e){
|
|
|
2624 |
System.out.println("Could not update entity : " + entity.getID());
|
|
|
2625 |
}
|
|
|
2626 |
}
|
| 7997 |
amit.gupta |
2627 |
}
|
|
|
2628 |
}
|
|
|
2629 |
}
|
|
|
2630 |
|
|
|
2631 |
}
|
|
|
2632 |
}
|
|
|
2633 |
}
|
| 8014 |
amit.gupta |
2634 |
|
|
|
2635 |
private Map<Long,Long> getValues() {
|
|
|
2636 |
try {
|
|
|
2637 |
Reader reader = new FileReader("/root/sample.json");
|
|
|
2638 |
return new Gson().fromJson(reader, new TypeToken<Map<Long,Long>>() {}.getType());
|
|
|
2639 |
} catch (FileNotFoundException e) {
|
|
|
2640 |
e.printStackTrace();
|
|
|
2641 |
return new HashMap<Long, Long>();
|
|
|
2642 |
}
|
|
|
2643 |
}
|
| 8077 |
amit.gupta |
2644 |
|
|
|
2645 |
private void reorderPhones() throws Exception {
|
|
|
2646 |
DefinitionsContainer defc = Catalog.getInstance().getDefinitionsContainer();
|
|
|
2647 |
List<Long> slideSequence = defc.getCategorySlideSequence().get(10003l);
|
|
|
2648 |
Map <Long, Entity> allEntities = CreationUtils.getEntities();
|
|
|
2649 |
for (Map.Entry<Long, Entity> entry:allEntities.entrySet()){
|
|
|
2650 |
Long entityId = entry.getKey();
|
|
|
2651 |
Entity entity = entry.getValue();
|
|
|
2652 |
Long categoryId = entity.getCategoryID();
|
|
|
2653 |
//System.out.println("entity : " + entity.getID());
|
|
|
2654 |
EntityState es = CreationUtils.getEntityState(entity.getID());
|
|
|
2655 |
if(!es.getStatus().equals(EntityStatus.UNASSIGNED)) {
|
|
|
2656 |
if ((categoryId == 10002 || categoryId == 10003 || categoryId == 10004 || categoryId == 10005)
|
|
|
2657 |
&& es != null) {
|
|
|
2658 |
entity.setSlideSequence(slideSequence);
|
|
|
2659 |
CreationUtils.updateEntity(entity);
|
|
|
2660 |
touchEntityState(entityId);
|
|
|
2661 |
}
|
|
|
2662 |
}
|
|
|
2663 |
}
|
|
|
2664 |
}
|
| 8798 |
amit.gupta |
2665 |
|
| 8869 |
amit.gupta |
2666 |
private void getTablets() throws Exception {
|
|
|
2667 |
StringBuffer sb = new StringBuffer();
|
|
|
2668 |
DefinitionsContainer defs = Catalog.getInstance().getDefinitionsContainer();
|
|
|
2669 |
Map<Long,FeatureDefinition> allFeatureDefs = defs.getFeatureDefinitions();
|
|
|
2670 |
List<Long> tabletFds = defs.getFeatureDefinitionIDs(10010l);
|
|
|
2671 |
|
|
|
2672 |
Collection<Entity> es = CreationUtils.getEntities(10010l);
|
|
|
2673 |
String header[] = new String[tabletFds.size()];
|
|
|
2674 |
int index = 0;
|
|
|
2675 |
for(Long fd : tabletFds) {
|
|
|
2676 |
header[index++] = allFeatureDefs.get(fd).getLabel();
|
|
|
2677 |
}
|
|
|
2678 |
sb.append(StringUtils.join(header, "\t")).append("\n");
|
|
|
2679 |
for (Entity entity:es){
|
|
|
2680 |
String as[] = new String[tabletFds.size()];
|
|
|
2681 |
Map<Long, String> m = AmazonSCDataGenerator.extractFeatureValuesForEntity(entity);
|
|
|
2682 |
for(Map.Entry<Long, String> entry : m.entrySet()) {
|
|
|
2683 |
if(tabletFds.indexOf(entry.getKey())==-1){
|
|
|
2684 |
continue;
|
|
|
2685 |
}
|
|
|
2686 |
as[tabletFds.indexOf(entry.getKey())] = entry.getValue();
|
|
|
2687 |
}
|
| 8873 |
amit.gupta |
2688 |
sb.append(entity.getID() + "\t").append(StringUtils.join(as, "\t")).append("\n");
|
| 8869 |
amit.gupta |
2689 |
}
|
|
|
2690 |
System.out.println(sb);
|
|
|
2691 |
}
|
|
|
2692 |
|
| 8909 |
amit.gupta |
2693 |
private void migrateSoftCategories() throws Exception{
|
|
|
2694 |
Long ANDROID = 110614l;
|
|
|
2695 |
Long WINDOWS = 110615l;
|
|
|
2696 |
Long DUALSIM = 110616l;
|
|
|
2697 |
Long TRISIM = 110617l;
|
|
|
2698 |
Long CDMA = 110618l;
|
|
|
2699 |
Long BASIC = 110619l;
|
|
|
2700 |
Long TOUCH = 110620l;
|
|
|
2701 |
Long PHABLET = 110621l;
|
|
|
2702 |
Long IOS = 110622l;
|
|
|
2703 |
Set<Long> softSet = new HashSet<Long>();
|
|
|
2704 |
DefinitionsContainer defc = Catalog.getInstance().getDefinitionsContainer();
|
|
|
2705 |
Collection<Entity> entities = CreationUtils.getEntities(10006l);
|
|
|
2706 |
for(Entity entity : entities){
|
|
|
2707 |
EntityState es = CreationUtils.getEntityState(entity.getID());
|
|
|
2708 |
if (es.getStatus().equals(EntityStatus.READY)) {
|
|
|
2709 |
softSet.clear();
|
|
|
2710 |
System.out.println("Entity ID : " + es.getID());
|
|
|
2711 |
List <Slide> slides = entity.getSlides();
|
|
|
2712 |
if(slides != null) {
|
|
|
2713 |
for(Slide slide : slides){
|
|
|
2714 |
if(slide.getSlideDefinitionID() == 130020l) {
|
|
|
2715 |
List<Feature> fs = slide.getFeatures();
|
|
|
2716 |
if (fs!=null){
|
|
|
2717 |
for (Feature f1 : fs){
|
|
|
2718 |
if(f1.getFeatureDefinitionID()==120043l){
|
|
|
2719 |
List <Bullet> bullets = f1.getBullets();
|
|
|
2720 |
if(bullets != null) {
|
|
|
2721 |
for(Bullet b : bullets){
|
|
|
2722 |
String bulletString = defc.getEnumValue(((EnumDataObject)b.getDataObject()).getEnumValueID()).getValue();
|
|
|
2723 |
if (bulletString.contains("Android")){
|
|
|
2724 |
softSet.add(ANDROID);
|
|
|
2725 |
System.out.println("Added android");
|
|
|
2726 |
break;
|
|
|
2727 |
}
|
|
|
2728 |
else if (bulletString.contains("Windows")){
|
|
|
2729 |
softSet.add(WINDOWS);
|
|
|
2730 |
System.out.println("Added Windows");
|
|
|
2731 |
break;
|
|
|
2732 |
}
|
|
|
2733 |
else if (bulletString.contains("iOS")){
|
|
|
2734 |
softSet.add(IOS);
|
|
|
2735 |
System.out.println("Added Apple");
|
|
|
2736 |
break;
|
|
|
2737 |
}
|
|
|
2738 |
}
|
|
|
2739 |
}
|
|
|
2740 |
}
|
|
|
2741 |
}
|
|
|
2742 |
}
|
|
|
2743 |
}
|
|
|
2744 |
|
|
|
2745 |
if(slide.getSlideDefinitionID() == 130005l) {
|
|
|
2746 |
List<Feature> fs = slide.getFeatures();
|
|
|
2747 |
if (fs!=null){
|
|
|
2748 |
for (Feature f1 : fs){
|
|
|
2749 |
if(f1.getFeatureDefinitionID()==120127l){
|
|
|
2750 |
List <Bullet> bullets = f1.getBullets();
|
|
|
2751 |
if(bullets != null) {
|
|
|
2752 |
for(Bullet b : bullets){
|
|
|
2753 |
String bulletString = defc.getEnumValue(((EnumDataObject)b.getDataObject()).getEnumValueID()).getValue();
|
|
|
2754 |
if (bulletString.equals("Dual-SIM")){
|
|
|
2755 |
softSet.add(DUALSIM);
|
|
|
2756 |
System.out.println("Added Dual-SIM");
|
|
|
2757 |
break;
|
|
|
2758 |
}
|
|
|
2759 |
else if (bulletString.equals("Tri-SIM")){
|
|
|
2760 |
softSet.add(TRISIM);
|
|
|
2761 |
System.out.println("Added Tri-SIM");
|
|
|
2762 |
break;
|
|
|
2763 |
}
|
|
|
2764 |
}
|
|
|
2765 |
}
|
|
|
2766 |
}
|
|
|
2767 |
else if(f1.getFeatureDefinitionID()==120012l){
|
|
|
2768 |
List <Bullet> bullets = f1.getBullets();
|
|
|
2769 |
if(bullets != null) {
|
|
|
2770 |
for(Bullet b : bullets){
|
|
|
2771 |
String bulletString = "";
|
|
|
2772 |
try{
|
|
|
2773 |
bulletString = defc.getEnumValue(((EnumDataObject)b.getDataObject()).getEnumValueID()).getValue();
|
|
|
2774 |
}catch (Exception e){
|
|
|
2775 |
//b.
|
|
|
2776 |
}
|
|
|
2777 |
if (bulletString.contains("CDMA")){
|
| 9051 |
amit.gupta |
2778 |
if(bulletString.contains("WCDMA")){
|
|
|
2779 |
touchEntityState(entity.getID());
|
|
|
2780 |
} else {
|
|
|
2781 |
softSet.add(CDMA);
|
|
|
2782 |
System.out.println("Added CDMA for 2G");
|
|
|
2783 |
break;
|
|
|
2784 |
}
|
| 8909 |
amit.gupta |
2785 |
}
|
|
|
2786 |
}
|
|
|
2787 |
}
|
|
|
2788 |
}
|
|
|
2789 |
else if(f1.getFeatureDefinitionID()==120013l){
|
|
|
2790 |
List <Bullet> bullets = f1.getBullets();
|
|
|
2791 |
if(bullets != null) {
|
|
|
2792 |
for(Bullet b : bullets){
|
|
|
2793 |
String bulletString = ((PrimitiveDataObject)b.getDataObject()).getValue();
|
|
|
2794 |
if (bulletString.contains("CDMA")){
|
| 9051 |
amit.gupta |
2795 |
if(bulletString.contains("WCDMA")){
|
|
|
2796 |
touchEntityState(entity.getID());
|
|
|
2797 |
} else {
|
|
|
2798 |
softSet.add(CDMA);
|
|
|
2799 |
System.out.println("Added CDMA for 3G");
|
|
|
2800 |
break;
|
|
|
2801 |
}
|
| 8909 |
amit.gupta |
2802 |
}
|
|
|
2803 |
}
|
|
|
2804 |
}
|
|
|
2805 |
}
|
|
|
2806 |
}
|
|
|
2807 |
}
|
|
|
2808 |
}
|
|
|
2809 |
|
|
|
2810 |
if(slide.getSlideDefinitionID() == 130002l) {
|
|
|
2811 |
List<Feature> fs = slide.getFeatures();
|
|
|
2812 |
if (fs!=null){
|
|
|
2813 |
for (Feature f1 : fs){
|
|
|
2814 |
if(f1.getFeatureDefinitionID()==120009l){
|
|
|
2815 |
List <Bullet> bullets = f1.getBullets();
|
|
|
2816 |
if(bullets != null) {
|
|
|
2817 |
for(Bullet b : bullets){
|
|
|
2818 |
String bulletString = defc.getEnumValue(((EnumDataObject)b.getDataObject()).getEnumValueID()).getValue();
|
|
|
2819 |
if(bulletString.equals("T9 keyboard")){
|
|
|
2820 |
softSet.add(BASIC);
|
|
|
2821 |
System.out.println("Added Basic phone");
|
|
|
2822 |
break;
|
|
|
2823 |
}
|
|
|
2824 |
}
|
|
|
2825 |
}
|
|
|
2826 |
}
|
|
|
2827 |
}
|
|
|
2828 |
}
|
|
|
2829 |
}
|
|
|
2830 |
|
|
|
2831 |
if(slide.getSlideDefinitionID() == 130003l) {
|
|
|
2832 |
List<Feature> fs = slide.getFeatures();
|
|
|
2833 |
if (fs!=null){
|
|
|
2834 |
for (Feature f1 : fs){
|
|
|
2835 |
if(f1.getFeatureDefinitionID()==120005l){
|
|
|
2836 |
List <Bullet> bullets = f1.getBullets();
|
|
|
2837 |
if(bullets != null) {
|
|
|
2838 |
for(Bullet b : bullets){
|
|
|
2839 |
String bulletString = ((PrimitiveDataObject)b.getDataObject()).getValue();
|
|
|
2840 |
float f = Float.valueOf(bulletString);
|
|
|
2841 |
if(f >= 5f ){
|
|
|
2842 |
softSet.add(PHABLET);
|
|
|
2843 |
System.out.println("Added Basic phone");
|
|
|
2844 |
break;
|
|
|
2845 |
}
|
|
|
2846 |
}
|
|
|
2847 |
}
|
|
|
2848 |
}
|
|
|
2849 |
else if(f1.getFeatureDefinitionID() == 120082l){
|
|
|
2850 |
softSet.add(TOUCH);
|
|
|
2851 |
System.out.println("Added Touch phone");
|
|
|
2852 |
}
|
|
|
2853 |
}
|
|
|
2854 |
}
|
|
|
2855 |
}
|
|
|
2856 |
}
|
|
|
2857 |
}
|
|
|
2858 |
if(softSet.size()>0){
|
|
|
2859 |
Slide summarySlide = entity.getSlide(130054l);
|
|
|
2860 |
Feature f = new Feature(120513l);
|
|
|
2861 |
List<Feature> features = summarySlide.getFeatures();
|
|
|
2862 |
List<Bullet> softBullets = new ArrayList<Bullet>();
|
| 9051 |
amit.gupta |
2863 |
for(Feature f1 : features){
|
|
|
2864 |
if(f.getFeatureDefinitionID()==120513l){
|
|
|
2865 |
features.remove(f1);
|
|
|
2866 |
break;
|
|
|
2867 |
}
|
|
|
2868 |
}
|
| 8909 |
amit.gupta |
2869 |
features.add(f);
|
|
|
2870 |
for(Long enumId : softSet){
|
|
|
2871 |
softBullets.add(new Bullet(new EnumDataObject(enumId)));
|
|
|
2872 |
}
|
|
|
2873 |
f.setBullets(softBullets);
|
|
|
2874 |
CreationUtils.updateEntity(entity);
|
|
|
2875 |
}
|
|
|
2876 |
}
|
|
|
2877 |
}
|
|
|
2878 |
}
|
|
|
2879 |
|
|
|
2880 |
private void clearEmptyPrimitiveBullets() throws Exception{
|
|
|
2881 |
Map<Long, Entity> es = CreationUtils.getEntities();
|
|
|
2882 |
for( Map.Entry<Long, Entity> entry : es.entrySet()){
|
|
|
2883 |
Entity e = entry.getValue();
|
|
|
2884 |
List<Slide> slides = e.getSlides();
|
|
|
2885 |
if(slides != null){
|
|
|
2886 |
for (Slide slide : slides){
|
|
|
2887 |
List<Feature> features = slide.getFeatures();
|
|
|
2888 |
if (features != null){
|
|
|
2889 |
for(Feature feature : features){
|
|
|
2890 |
List<Bullet> bullets = feature.getBullets();
|
|
|
2891 |
if(bullets != null){
|
|
|
2892 |
Iterator<Bullet> bIterator = bullets.iterator();
|
|
|
2893 |
while (bIterator.hasNext()){
|
|
|
2894 |
BulletDataObject b = bIterator.next().getDataObject();
|
|
|
2895 |
if(b.getClass().equals(PrimitiveDataObject.class)){
|
|
|
2896 |
PrimitiveDataObject pdo = (PrimitiveDataObject)b;
|
|
|
2897 |
if(pdo.getValue().equals("")){
|
|
|
2898 |
bIterator.remove();
|
|
|
2899 |
System.out.println("Removed empty Primitive from slide :" + slide.getSlideDefinitionID() + " and entity: " + e.getID());
|
|
|
2900 |
}
|
|
|
2901 |
}
|
|
|
2902 |
}
|
|
|
2903 |
}
|
|
|
2904 |
}
|
|
|
2905 |
}
|
|
|
2906 |
}
|
|
|
2907 |
CreationUtils.updateEntity(e);
|
|
|
2908 |
}
|
|
|
2909 |
}
|
|
|
2910 |
}
|
|
|
2911 |
|
| 8913 |
amit.gupta |
2912 |
private void updateSummaryMediaLabel() throws Exception{
|
|
|
2913 |
Map<Long, Entity> es = CreationUtils.getEntities();
|
|
|
2914 |
for( Map.Entry<Long, Entity> entry : es.entrySet()){
|
|
|
2915 |
Entity e = entry.getValue();
|
|
|
2916 |
Slide summarySlide = e.getSlide(130054l);
|
|
|
2917 |
if(summarySlide!=null){
|
|
|
2918 |
FreeformContent ffc = summarySlide.getFreeformContent();
|
|
|
2919 |
if (ffc !=null){
|
|
|
2920 |
Map<String, Media> mediaMap = ffc.getMedias();
|
|
|
2921 |
if(mediaMap != null){
|
|
|
2922 |
for(Map.Entry<String, Media> mediaEntry : mediaMap.entrySet()) {
|
|
|
2923 |
if(mediaEntry.getValue().getLabel().equals("default") && !mediaEntry.getKey().equals("default")){
|
|
|
2924 |
mediaMap.put("default", mediaMap.remove(mediaEntry.getKey()));
|
|
|
2925 |
CreationUtils.updateEntity(e);
|
|
|
2926 |
System.out.println("Upated summary media for:" + e.getID());
|
| 9171 |
amit.gupta |
2927 |
break;
|
| 8913 |
amit.gupta |
2928 |
}
|
|
|
2929 |
}
|
|
|
2930 |
}
|
|
|
2931 |
}
|
|
|
2932 |
}
|
|
|
2933 |
}
|
|
|
2934 |
}
|
| 9171 |
amit.gupta |
2935 |
|
|
|
2936 |
private void updateCommunication() throws Exception{
|
|
|
2937 |
Map<Long,Entity> es = CreationUtils.getEntities();
|
|
|
2938 |
for( Map.Entry<Long, Entity> entry: es.entrySet()){
|
|
|
2939 |
Entity e = entry.getValue();
|
|
|
2940 |
//Slide commSlide = e.getSlide(130005l);
|
|
|
2941 |
List<Slide> slides = e.getSlides();
|
|
|
2942 |
if(slides != null){
|
|
|
2943 |
for(Slide slide : slides){
|
|
|
2944 |
List<Feature> features = slide.getFeatures();
|
|
|
2945 |
if (features != null){
|
|
|
2946 |
slide.setFeatures(new ArrayList<Feature>(new LinkedHashSet<Feature>(features)));
|
|
|
2947 |
if(slide.getFeatures().size() != features.size()){
|
|
|
2948 |
System.out.println(e.getCategoryID() + ":" + e.getID() + ":" + slide.getFeatures() + "," + features);
|
|
|
2949 |
CreationUtils.updateEntity(e);
|
|
|
2950 |
}
|
|
|
2951 |
}
|
|
|
2952 |
}
|
|
|
2953 |
}
|
|
|
2954 |
}
|
|
|
2955 |
}
|
| 8913 |
amit.gupta |
2956 |
|
| 9900 |
amit.gupta |
2957 |
private void migrateReviews() throws Exception{
|
|
|
2958 |
Map<Long, List<ExpertReview>> a = CreationUtils.getExpertReviews();
|
|
|
2959 |
for(Map.Entry<Long, List<ExpertReview>> entry : a.entrySet()) {
|
|
|
2960 |
List<ExpertReview> ers = entry.getValue();
|
|
|
2961 |
Iterator<ExpertReview> ersIterator = ers.iterator();
|
|
|
2962 |
while (ersIterator.hasNext()){
|
|
|
2963 |
ExpertReview er = ersIterator.next();
|
|
|
2964 |
String review = er.getReviewContent();
|
|
|
2965 |
String review1 = review.replaceAll("<[^>]+>", "");
|
|
|
2966 |
if(review.equals("")){
|
|
|
2967 |
ersIterator.remove();
|
|
|
2968 |
} else if(!review.equals(review1)) {
|
|
|
2969 |
er.setReviewContent(review1);
|
|
|
2970 |
}
|
|
|
2971 |
}
|
|
|
2972 |
CreationUtils.storeExpertReview(entry.getKey(), ers);
|
|
|
2973 |
}
|
|
|
2974 |
}
|
|
|
2975 |
|
| 10692 |
amit.gupta |
2976 |
private List<ExpertReview> getExpertReviews(long catalogId) throws Exception {
|
|
|
2977 |
List<ExpertReview> expertReviews = CreationUtils.getExpertReviewByEntity(catalogId);
|
|
|
2978 |
if(expertReviews != null) {
|
|
|
2979 |
Iterator<ExpertReview> iter = expertReviews.iterator();
|
|
|
2980 |
while (iter.hasNext()){
|
|
|
2981 |
ExpertReview er = iter.next();
|
|
|
2982 |
if(!er.getStatus().equals(ExpertReviewStatus.PUBLISHED)){
|
|
|
2983 |
iter.remove();
|
|
|
2984 |
}
|
|
|
2985 |
}
|
|
|
2986 |
if(expertReviews.size()==0){
|
|
|
2987 |
expertReviews = null;
|
|
|
2988 |
}
|
|
|
2989 |
|
|
|
2990 |
}
|
|
|
2991 |
return expertReviews;
|
|
|
2992 |
}
|
| 11151 |
amit.gupta |
2993 |
|
|
|
2994 |
private Map<String, String> getEntityParameters(ExpandedEntity expEntity)
|
|
|
2995 |
throws Exception {
|
|
|
2996 |
Map<String, String> params = new HashMap<String, String>();
|
|
|
2997 |
String warranty = "";
|
|
|
2998 |
|
|
|
2999 |
// Creating warranty string!
|
|
|
3000 |
for (Slide slide : expEntity.getSlide(130054).getChildrenSlides()) {
|
|
|
3001 |
if (slide.getSlideDefinitionID() == 130105) {
|
|
|
3002 |
ExpandedSlide expSlide = new ExpandedSlide(slide);
|
|
|
3003 |
Feature warrantyDurationFeature = expSlide.getExpandedFeature(120125);
|
|
|
3004 |
if (warrantyDurationFeature != null) {
|
|
|
3005 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyDurationFeature);
|
|
|
3006 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
|
|
3007 |
if (expBullet != null) {
|
|
|
3008 |
String shortForm = expBullet.getUnit().getShortForm();
|
|
|
3009 |
|
|
|
3010 |
// Append 's' to month and year
|
|
|
3011 |
if (!expBullet.getValue().trim().equals("1")) {
|
|
|
3012 |
shortForm += "s";
|
|
|
3013 |
}
|
|
|
3014 |
warranty += expBullet.getValue() + SPACE + shortForm;
|
|
|
3015 |
}
|
|
|
3016 |
}
|
|
|
3017 |
|
|
|
3018 |
Feature warrantyTypeFeature = expSlide.getExpandedFeature(120219);
|
|
|
3019 |
if (warrantyTypeFeature != null) {
|
|
|
3020 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyTypeFeature);
|
|
|
3021 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
|
|
3022 |
if (expBullet != null) {
|
|
|
3023 |
warranty += SPACE + expBullet.getExpandedEnumDataObject()
|
|
|
3024 |
.getEnumValue().getValue();
|
|
|
3025 |
}
|
|
|
3026 |
}
|
|
|
3027 |
|
|
|
3028 |
Feature warrantyCoverageFeature = expSlide.getExpandedFeature(120220);
|
|
|
3029 |
if (warrantyCoverageFeature != null) {
|
|
|
3030 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyCoverageFeature);
|
|
|
3031 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
|
|
3032 |
if (expBullet != null) {
|
|
|
3033 |
warranty += SPACE + HYPHON + SPACE + expBullet.getExpandedEnumDataObject().getEnumValue().getValue();
|
|
|
3034 |
}
|
|
|
3035 |
}
|
|
|
3036 |
}
|
|
|
3037 |
}
|
|
|
3038 |
return params;
|
|
|
3039 |
}
|
| 7111 |
amit.gupta |
3040 |
}
|
|
|
3041 |
|