Subversion Repositories SmartDukaan

Rev

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

Rev 5397 Rev 5671
Line 41... Line 41...
41
import java.io.OutputStream;
41
import java.io.OutputStream;
42
import java.util.ArrayList;
42
import java.util.ArrayList;
43
import java.util.Collection;
43
import java.util.Collection;
44
import java.util.Collections;
44
import java.util.Collections;
45
import java.util.HashMap;
45
import java.util.HashMap;
-
 
46
import java.util.Iterator;
46
import java.util.List;
47
import java.util.List;
47
import java.util.Map;
48
import java.util.Map;
48
import java.util.TreeMap;
49
import java.util.TreeMap;
49
 
50
 
50
import org.apache.commons.io.IOUtils;
51
import org.apache.commons.io.IOUtils;
Line 73... Line 74...
73
		// destinationDbPath = args[1];
74
		// destinationDbPath = args[1];
74
		// dryRun = args[2];
75
		// dryRun = args[2];
75
		// }
76
		// }
76
		//
77
		//
77
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
78
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
-
 
79
		Long catgoryId = 10020L;
-
 
80
		Long newSummarySlideDefId = 130134L;
78
		contentmigrator.migrateHeadSetBack();
81
		contentmigrator.migrateWarrantyForCategory(catgoryId);
79
		//contentmigrator.renameTitles();
82
		//contentmigrator.renameTitles();
80
		// contentmigrator.migrateWarrantyType();
83
		// contentmigrator.migrateWarrantyType();
81
		// CreationUtils.storeComparisonStats(null);n
84
		// CreationUtils.storeComparisonStats(null);n
82
		// contentmigrator.migrateMedia();
85
		// contentmigrator.migrateMedia();
83
		// contentmigrator.populateHelpdocEntityIds();
86
		// contentmigrator.populateHelpdocEntityIds();
Line 128... Line 131...
128
		// boolean result = contentmigrator.migrate();
131
		// boolean result = contentmigrator.migrate();
129
		// System.out.println("Content migration status:  "+ result);
132
		// System.out.println("Content migration status:  "+ result);
130
 
133
 
131
	}
134
	}
132
 
135
 
-
 
136
	private void migrateWarrantyForCategory(Long catgoryId) throws Exception {
-
 
137
		Collection<Entity> entities = CreationUtils.getEntities(catgoryId);
-
 
138
		int count = 0;
-
 
139
		for (Entity entity : entities) {
-
 
140
			Slide slide = entity.getSlide(130054l);
-
 
141
			if(slide!=null){
-
 
142
				List<Slide> childrenSlide = slide.getChildrenSlides();
-
 
143
				Iterator<Slide> it = childrenSlide.iterator();
-
 
144
				while (it.hasNext()){
-
 
145
					Slide sl = it.next();
-
 
146
					if (130105l == sl.getSlideDefinitionID()){
-
 
147
						it.remove();
-
 
148
						System.out.println("Removed warranty slide from entity:" + entity.getID());
-
 
149
						break;
-
 
150
					}
-
 
151
				}
-
 
152
				CreationUtils.updateEntity(entity);
-
 
153
			}
-
 
154
		}
-
 
155
	}
-
 
156
 
-
 
157
	private void checkYouTube() throws Exception {
-
 
158
		// TODO Auto-generated method stub
-
 
159
		Collection<Entity> entities = CreationUtils.getEntities().values();
-
 
160
		//entities = (List<Entity>)this.clone(entities);
-
 
161
		for (Entity entity : entities) {
-
 
162
			long entityId = entity.getID();
-
 
163
			try {
-
 
164
				List<Slide> entitySlides = entity.getSlides();
-
 
165
				if (entity == null || entitySlides == null) {
-
 
166
					continue;
-
 
167
				}
-
 
168
				Slide summarySlide = null;
-
 
169
				FreeformContent ffc = null;
-
 
170
				 
-
 
171
				List<Slide> newEntitySlides = new ArrayList<Slide>(); 
-
 
172
				Slide connectivitySlide = new Slide(130129);
-
 
173
				Slide looknfeelSlide = new Slide(130128);
-
 
174
				for (Slide slide : entitySlides) {
-
 
175
						ffc = slide.getFreeformContent();
-
 
176
						if(ffc != null){
-
 
177
							Map<String, Media> mediaMap = ffc.getMedias();
-
 
178
							if(mediaMap!=null){
-
 
179
								for(Media media : mediaMap.values()){
-
 
180
									if(media.getType().equals(Type.VIDEO_WITHOUT_SKIN) || media.getType().equals(Type.VIDEO_WITH_SKIN)){
-
 
181
										if(media.getYoutubeId().contains("&"))
-
 
182
										System.out.println(entityId + " : " + media.getLabel() + ":" + media.getYoutubeId());
-
 
183
									}
-
 
184
								}
-
 
185
							}
-
 
186
						}
-
 
187
				}
-
 
188
						
-
 
189
			}catch(Exception e){
-
 
190
				System.out.println("Could not migrate " + entityId);
-
 
191
			}
-
 
192
		}
-
 
193
 
-
 
194
		
-
 
195
	}
-
 
196
 
133
	private void renameTitles() throws Exception {
197
	private void renameTitles() throws Exception {
134
		Map<Long, Entity> map = CreationUtils.getEntities();
198
		Map<Long, Entity> map = CreationUtils.getEntities();
135
		for (Long entityId : map.keySet()) {
199
		for (Long entityId : map.keySet()) {
136
			Entity entity = map.get(entityId);
200
			Entity entity = map.get(entityId);
137
			if (entity == null || entity.getSlides() == null) {
201
			if (entity == null || entity.getSlides() == null) {