Subversion Repositories SmartDukaan

Rev

Rev 7984 | Rev 8000 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7984 Rev 7997
Line 53... Line 53...
53
import java.util.List;
53
import java.util.List;
54
import java.util.Map;
54
import java.util.Map;
55
import java.util.Set;
55
import java.util.Set;
56
import java.util.TreeMap;
56
import java.util.TreeMap;
57
 
57
 
-
 
58
import org.apache.axis.utils.ArrayUtil;
58
import org.apache.commons.collections.CollectionUtils;
59
import org.apache.commons.collections.CollectionUtils;
59
import org.apache.commons.io.IOUtils;
60
import org.apache.commons.io.IOUtils;
-
 
61
import org.apache.commons.lang.ArrayUtils;
60
import org.apache.commons.lang.StringUtils;
62
import org.apache.commons.lang.StringUtils;
61
 
63
 
62
/*
64
/*
63
 * @author rajveer 
65
 * @author rajveer 	
64
 * 
66
 * 
65
 *
67
 *
66
 */
68
 */
67
 
69
 
68
public class ContentMigrator {
70
public class ContentMigrator {
Line 86... Line 88...
86
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
88
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
87
		/*List<Long> entityId = Arrays.asList(1001674l,1002575l,1005331l,1005165l,1005164l,1005111l,1005109l,1004952l,1004940l,1004871l,1004701l,1004429l,1004197l,1006174l,1006077l,1005901l,1005757l,1005754l,1005724l,1005704l,1005598l,1005576l,1005558l,1007394l,1007230l,1007226l,1007218l,1007089l,1006925l,1006822l,1006814l,1006175l);
89
		/*List<Long> entityId = Arrays.asList(1001674l,1002575l,1005331l,1005165l,1005164l,1005111l,1005109l,1004952l,1004940l,1004871l,1004701l,1004429l,1004197l,1006174l,1006077l,1005901l,1005757l,1005754l,1005724l,1005704l,1005598l,1005576l,1005558l,1007394l,1007230l,1007226l,1007218l,1007089l,1006925l,1006822l,1006814l,1006175l);
88
		for (Long eId : entityId){
90
		for (Long eId : entityId){
89
			contentmigrator.touchEntityState(eId);
91
			contentmigrator.touchEntityState(eId);
90
		}*/
92
		}*/
91
		contentmigrator.step4();
93
		contentmigrator.step6();
92
 
94
 
93
	}
95
	}
94
	
96
	
95
	private void updateSources() throws Exception{
97
	private void updateSources() throws Exception{
96
		Map<Long,List<ExpertReview>> erMap = CreationUtils.getExpertReviews();
98
		Map<Long,List<ExpertReview>> erMap = CreationUtils.getExpertReviews();
Line 2349... Line 2351...
2349
					touchEntityState(entity.getID());
2351
					touchEntityState(entity.getID());
2350
				}
2352
				}
2351
			}
2353
			}
2352
		}
2354
		}
2353
	}
2355
	}
-
 
2356
	private void step6() throws Exception {
-
 
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(1002529l, CreationUtils.getEntity(1002529l));
-
 
2361
		allEntities.put(1007932l, CreationUtils.getEntity(1007932l));
-
 
2362
		allEntities.put(1007930l, CreationUtils.getEntity(1007930l));
-
 
2363
		allEntities.put(1007934l, CreationUtils.getEntity(1007934l));
-
 
2364
		allEntities.put(1007936l, CreationUtils.getEntity(1007936l));
-
 
2365
		allEntities.put(1007935l, CreationUtils.getEntity(1007935l));*/
-
 
2366
		for (Map.Entry<Long, Entity> entry:allEntities.entrySet()){
-
 
2367
			Entity entity = entry.getValue();
-
 
2368
			Long categoryId = entity.getCategoryID();
-
 
2369
			//System.out.println("entity : " + entity.getID());
-
 
2370
			EntityState es = CreationUtils.getEntityState(entity.getID());
-
 
2371
			if(!es.getStatus().equals(EntityStatus.UNASSIGNED)) {
-
 
2372
				if ((categoryId == 10002 || categoryId == 10003 || categoryId == 10004 || categoryId == 10005) 
-
 
2373
						&& es != null) {
-
 
2374
					List<Slide> allSlides = entity.getSlides();
-
 
2375
					if(categoryId==10005){
-
 
2376
						Slide tobemoved = entity.getSlide(130059l);
-
 
2377
						Slide newSlide = new Slide(130029l);
-
 
2378
						newSlide.setFeatures(tobemoved.getFeatures());
-
 
2379
						allSlides.remove(tobemoved);
-
 
2380
						allSlides.add(newSlide);
-
 
2381
					}
-
 
2382
					Slide videoSlide = entity.getSlide(130031l);
-
 
2383
					if(videoSlide != null){
-
 
2384
						FreeformContent videoffc  = videoSlide.getFreeformContent();
-
 
2385
						if(videoffc != null){
-
 
2386
							List<String> texts= new  ArrayList<String>(videoffc.getFreeformTexts());
-
 
2387
							Bullet b = null;
-
 
2388
							String text1 = null;
-
 
2389
							if(texts != null){
-
 
2390
								for(String text : texts){
-
 
2391
									if (text.contains("1080p HD video recording") || text.contains("Full HD video recording") || text.contains("1080p Full HD video recording")) {
-
 
2392
										text1 = text;
-
 
2393
										b = new Bullet(new EnumDataObject(110599l));
-
 
2394
										break;
-
 
2395
									}
-
 
2396
									else if (text.contains("720p HD video recording") || text.contains("720p video recording") || text.contains("HD video recording")) {
-
 
2397
										text1 = text;
-
 
2398
										b = new Bullet(new EnumDataObject(110598l));
-
 
2399
										break;
-
 
2400
									}
-
 
2401
								}
-
 
2402
							}
-
 
2403
							if(b !=null){
-
 
2404
								Feature f = new Feature(120475l);
-
 
2405
								texts.remove(text1);
-
 
2406
								f.setBullets(Arrays.asList(b));
-
 
2407
								videoSlide.getFeatures().add(f);
-
 
2408
							}
-
 
2409
							else if (categoryId != 10005) {
-
 
2410
								b = new Bullet(new EnumDataObject(110597l));
-
 
2411
								Feature f = new Feature(120475l);
-
 
2412
								f.setBullets(Arrays.asList(b));
-
 
2413
								videoSlide.getFeatures().add(f);
-
 
2414
							}
-
 
2415
						}
-
 
2416
					}
-
 
2417
					try{
-
 
2418
						CreationUtils.updateEntity(entity);
-
 
2419
					}catch (Exception e){
-
 
2420
						System.out.println("Could not update entity : " + entity.getID());
-
 
2421
					}
-
 
2422
					touchEntityState(entity.getID());
-
 
2423
				}
-
 
2424
				
-
 
2425
				if (categoryId == 11002 || categoryId == 11003){
-
 
2426
					Slide sensorSlide = entity.getSlide(130136l);
-
 
2427
					if(sensorSlide == null){
-
 
2428
						sensorSlide = entity.getSlide(130151l);
-
 
2429
					}
-
 
2430
					List<Feature> features = sensorSlide.getFeatures();
-
 
2431
					for(Feature f : features){
-
 
2432
						if(f.getFeatureDefinitionID() == 120026l){
-
 
2433
							f.setFeatureDefinitionID(120485l);
-
 
2434
						}
-
 
2435
					}
-
 
2436
					try{
-
 
2437
						CreationUtils.updateEntity(entity);
-
 
2438
					}catch (Exception e){
-
 
2439
						System.out.println("Could not update entity : " + entity.getID());
-
 
2440
					}
-
 
2441
					touchEntityState(entity.getID());
-
 
2442
				}
-
 
2443
 
-
 
2444
			}
-
 
2445
		}
-
 
2446
	}
2354
}
2447
}
2355
 
2448