Subversion Repositories SmartDukaan

Rev

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

Rev 7037 Rev 7111
Line 46... Line 46...
46
import java.util.Collections;
46
import java.util.Collections;
47
import java.util.HashMap;
47
import java.util.HashMap;
48
import java.util.Iterator;
48
import java.util.Iterator;
49
import java.util.List;
49
import java.util.List;
50
import java.util.Map;
50
import java.util.Map;
-
 
51
import java.util.Set;
51
import java.util.TreeMap;
52
import java.util.TreeMap;
52
 
53
 
53
import org.apache.commons.io.IOUtils;
54
import org.apache.commons.io.IOUtils;
54
import org.apache.commons.lang.StringUtils;
55
import org.apache.commons.lang.StringUtils;
55
 
56
 
Line 76... Line 77...
76
		// destinationDbPath = args[1];
77
		// destinationDbPath = args[1];
77
		// dryRun = args[2];
78
		// dryRun = args[2];
78
		// }
79
		// }
79
		//
80
		//
80
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
81
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
81
		contentmigrator.migrateTablets();
82
		contentmigrator.migrateImagesInTablets();
82
 
83
 
83
	}
84
	}
84
 
85
 
85
	private void migrateWarrantyForCategory(Long catgoryId) throws Exception {
86
	private void migrateWarrantyForCategory(Long catgoryId) throws Exception {
86
		Collection<Entity> entities = CreationUtils.getEntities(catgoryId);
87
		Collection<Entity> entities = CreationUtils.getEntities(catgoryId);
Line 1998... Line 1999...
1998
			}
1999
			}
1999
		}
2000
		}
2000
		
2001
		
2001
	}
2002
	}
2002
 
2003
 
-
 
2004
public void migrateImagesInTablets() throws Exception {
-
 
2005
	
-
 
2006
	//Starting entity id for new Category with 10000
-
 
2007
	Collection<Entity> entities = CreationUtils.getEntities(10010);
-
 
2008
	long newCounter;
-
 
2009
	//entities = (List<Entity>)this.clone(entities);
-
 
2010
	for (Entity entity : entities) {
-
 
2011
		long entityId = entity.getID();
-
 
2012
		newCounter = Long.parseLong("1" + String.valueOf(entityId));
-
 
2013
		Entity newEntity = CreationUtils.getEntity(newCounter);
-
 
2014
		try {
-
 
2015
			if (newEntity == null) {
-
 
2016
				continue;
-
 
2017
			}
-
 
2018
			Slide introSlide = newEntity.getSlide(130001L);
-
 
2019
			Slide looknfeelSlide = entity.getSlide(130002L);
-
 
2020
			/*
-
 
2021
			 * Slide introSlide = entity.getSlide(130001); Slide
-
 
2022
			 * summarySlide = entity.getSlide(130054); Slide packageContents
-
 
2023
			 * = entity.getSlide(130025);
-
 
2024
			 */
-
 
2025
 
-
 
2026
			if (looknfeelSlide != null) {
-
 
2027
				FreeformContent ffc1 = looknfeelSlide.getFreeformContent();
-
 
2028
				if (ffc1 != null) {
-
 
2029
					Map<String, Media> mediaMap = ffc1.getMedias();
-
 
2030
					if (mediaMap == null) {
-
 
2031
						continue;
-
 
2032
					}
-
 
2033
					FreeformContent introFfc = introSlide
-
 
2034
							.getFreeformContent();
-
 
2035
					Map<String, Media> introMediaMap = introFfc.getMedias();
-
 
2036
					if (introMediaMap == null) {
-
 
2037
						introMediaMap = new HashMap<String, Media>();
-
 
2038
						introFfc.setMedias(introMediaMap);
-
 
2039
					}
-
 
2040
					Set<String> introMediaMapKeys = introMediaMap.keySet();
-
 
2041
					for (Map.Entry<String, Media> entry : mediaMap
-
 
2042
							.entrySet()) {
-
 
2043
						Media entryValue = entry.getValue();
-
 
2044
						String entryKey = entry.getKey();
-
 
2045
						if (!introMediaMapKeys.contains(entryKey)) {
-
 
2046
							introMediaMap.put(entryKey,
-
 
2047
									(Media) clone(entryValue));
-
 
2048
							if (entryValue.getType().equals(Type.IMAGE)
-
 
2049
									|| entryValue.equals(Type.DOCUMENT)) {
-
 
2050
								try {
-
 
2051
									copyMedia(String.valueOf(newCounter),
-
 
2052
											String.valueOf(entityId),
-
 
2053
											entryValue);
-
 
2054
								} catch (Exception e) {
-
 
2055
									System.out
-
 
2056
											.println("could not copy file "
-
 
2057
													+ entityId);
-
 
2058
								}
-
 
2059
							}
-
 
2060
						}
-
 
2061
					}
-
 
2062
				}
-
 
2063
			}
-
 
2064
 
-
 
2065
			CreationUtils.updateEntity(newEntity);
-
 
2066
			System.out.println("New entity : " + newCounter
-
 
2067
					+ " created using : " + entityId);
-
 
2068
		} catch (Exception e) {
-
 
2069
			e.printStackTrace();
-
 
2070
			System.out.println("Could not migrate " + entityId);
-
 
2071
		}
-
 
2072
	}
-
 
2073
	
-
 
2074
}
-
 
2075
 
2003
 
2076
 
2004
}
2077
}
2005
 
2078