Subversion Repositories SmartDukaan

Rev

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

Rev 5672 Rev 5760
Line 37... Line 37...
37
import java.io.InputStream;
37
import java.io.InputStream;
38
import java.io.InputStreamReader;
38
import java.io.InputStreamReader;
39
import java.io.ObjectInputStream;
39
import java.io.ObjectInputStream;
40
import java.io.ObjectOutputStream;
40
import java.io.ObjectOutputStream;
41
import java.io.OutputStream;
41
import java.io.OutputStream;
-
 
42
import java.text.MessageFormat;
42
import java.util.ArrayList;
43
import java.util.ArrayList;
43
import java.util.Collection;
44
import java.util.Collection;
44
import java.util.Collections;
45
import java.util.Collections;
45
import java.util.HashMap;
46
import java.util.HashMap;
46
import java.util.Iterator;
47
import java.util.Iterator;
Line 76... Line 77...
76
		// }
77
		// }
77
		//
78
		//
78
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
79
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
79
		Long catgoryId = 10020L;
80
		Long catgoryId = 10020L;
80
		Long newSummarySlideDefId = 130134L;
81
		Long newSummarySlideDefId = 130134L;
81
		contentmigrator.migrateWarrantyForCategory(catgoryId);
82
		contentmigrator.renameTitles();
82
		//contentmigrator.renameTitles();
83
		//contentmigrator.renameTitles();
83
		// contentmigrator.migrateWarrantyType();
84
		// contentmigrator.migrateWarrantyType();
84
		// CreationUtils.storeComparisonStats(null);n
85
		// CreationUtils.storeComparisonStats(null);n
85
		// contentmigrator.migrateMedia();
86
		// contentmigrator.migrateMedia();
86
		// contentmigrator.populateHelpdocEntityIds();
87
		// contentmigrator.populateHelpdocEntityIds();
Line 201... Line 202...
201
		for (Long entityId : map.keySet()) {
202
		for (Long entityId : map.keySet()) {
202
			Entity entity = map.get(entityId);
203
			Entity entity = map.get(entityId);
203
			if (entity == null || entity.getSlides() == null) {
204
			if (entity == null || entity.getSlides() == null) {
204
				continue;
205
				continue;
205
			}
206
			}
206
			
-
 
207
 
-
 
208
			String brand = entity.getBrand();
-
 
209
			String modelName = entity.getModelName();
-
 
210
			String modelNumber = entity.getModelNumber();
-
 
211
			String value = "";
-
 
212
			if(StringUtils.isEmpty(modelName)){
-
 
213
				value = brand + " " + modelNumber + " Price in India | Specifications, Features and Reviews";
-
 
214
			}else {
-
 
215
				value = brand + " " + modelName + " Price in India | " + modelNumber + " Specifications, Features and Reviews";
-
 
216
			}
-
 
217
			
-
 
218
			Slide summarySlide = entity.getSlide(130054);
207
			Slide summarySlide = entity.getSlide(130054);
219
			if(summarySlide != null){
208
			if(summarySlide != null){
-
 
209
				boolean isupdated = false;
220
				for(Feature f : summarySlide.getFeatures()){
210
				for(Feature f : summarySlide.getFeatures()){
221
					if (f.getFeatureDefinitionID()==120132){
211
					if(f.getFeatureDefinitionID()==120132l){
222
						List<Bullet> bulletList = f.getBullets();
212
						if(f.getBullets() == null){
223
						for (Bullet b : bulletList) {
213
							f.setBullets(new ArrayList<Bullet>());
-
 
214
						}else {
224
							b.setDataObject(new PrimitiveDataObject(value));
215
							f.getBullets().clear();
225
						}
216
						}
-
 
217
						Bullet titleBullet = new Bullet(new PrimitiveDataObject(getTitle(entity)));
226
						CreationUtils.updateEntity(entity);
218
						f.getBullets().add(titleBullet);
-
 
219
						isupdated = true;
-
 
220
						continue;
-
 
221
					}
-
 
222
					if(f.getFeatureDefinitionID()==120133l){
-
 
223
						if(f.getBullets() == null){
-
 
224
							f.setBullets(new ArrayList<Bullet>());
-
 
225
						}else {
-
 
226
							f.getBullets().clear();
-
 
227
						}
-
 
228
						Bullet metaDescBullet = new Bullet(new PrimitiveDataObject(getMetaDescription(new ExpandedEntity(entity))));
-
 
229
						f.getBullets().add(metaDescBullet);
-
 
230
						isupdated = true;
227
						continue;
231
						continue;
228
					}
232
					}
229
				}
233
				}
-
 
234
				if(isupdated){ 
-
 
235
					CreationUtils.updateEntity(entity);
-
 
236
					System.out.println("Updated entity : " + entity.getID());
-
 
237
				}
230
			}
238
			}
231
		}
239
		}
232
	}
240
	}
233
 
241
 
234
	private void migrateNetwork() throws Exception {
242
	private void migrateNetwork() throws Exception {
Line 1945... Line 1953...
1945
			System.out.println(validId + " : " + es.getCategoryID() + ", removed entity id:" + newId);
1953
			System.out.println(validId + " : " + es.getCategoryID() + ", removed entity id:" + newId);
1946
			
1954
			
1947
		}
1955
		}
1948
		
1956
		
1949
	}
1957
	}
-
 
1958
	
-
 
1959
    public String getTitle(Entity entity){
-
 
1960
    	String brand = entity.getBrand();
-
 
1961
    	String modelName = entity.getModelName();
-
 
1962
    	String modelNumber = entity.getModelNumber();
-
 
1963
    	String titleString = "";
-
 
1964
    	if(StringUtils.isEmpty(modelName)){
-
 
1965
    		titleString = brand + " " + modelNumber + " Price in India | Specifications, Features and Reviews";
-
 
1966
    	}else {
-
 
1967
    		titleString = brand + " " + modelName + " Price in India | " + modelNumber + " Specifications, Features and Reviews";
-
 
1968
    	}
-
 
1969
    	return titleString;
-
 
1970
    }
-
 
1971
    
-
 
1972
    public String getMetaDescription(ExpandedEntity expEntity){
-
 
1973
    	Category parentCategory= expEntity.getCategory().getParentCategory();
-
 
1974
    	String categoryName = parentCategory.getLabel();
-
 
1975
    	if (parentCategory.getID()== Utils.MOBILE_ACCESSORIES_CATEGORY){
-
 
1976
    		categoryName = expEntity.getCategory().getLabel();
-
 
1977
    	}
-
 
1978
    	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.";
-
 
1979
    	return MessageFormat.format(template, expEntity.getBrand(), expEntity.getModelName(), expEntity.getModelNumber(), categoryName.toLowerCase());
-
 
1980
    }
1950
 
1981
 
1951
}
1982
}
1952
 
1983