Subversion Repositories SmartDukaan

Rev

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

Rev 7123 Rev 7129
Line 1... Line 1...
1
package in.shop2020.util;
1
package in.shop2020.util;
2
 
2
 
3
import in.shop2020.metamodel.core.Bullet;
3
import in.shop2020.metamodel.core.Bullet;
4
import in.shop2020.metamodel.core.Entity;
4
import in.shop2020.metamodel.core.Entity;
5
import in.shop2020.metamodel.core.EntityState;
5
import in.shop2020.metamodel.core.EntityState;
-
 
6
import in.shop2020.metamodel.core.EntityStatus;
6
import in.shop2020.metamodel.core.EnumDataObject;
7
import in.shop2020.metamodel.core.EnumDataObject;
7
import in.shop2020.metamodel.core.Feature;
8
import in.shop2020.metamodel.core.Feature;
8
import in.shop2020.metamodel.core.FreeformContent;
9
import in.shop2020.metamodel.core.FreeformContent;
9
import in.shop2020.metamodel.core.Media;
10
import in.shop2020.metamodel.core.Media;
10
import in.shop2020.metamodel.core.Media.Type;
11
import in.shop2020.metamodel.core.Media.Type;
Line 42... Line 43...
42
import java.text.MessageFormat;
43
import java.text.MessageFormat;
43
import java.util.ArrayList;
44
import java.util.ArrayList;
44
import java.util.Arrays;
45
import java.util.Arrays;
45
import java.util.Collection;
46
import java.util.Collection;
46
import java.util.Collections;
47
import java.util.Collections;
-
 
48
import java.util.Date;
47
import java.util.HashMap;
49
import java.util.HashMap;
48
import java.util.Iterator;
50
import java.util.Iterator;
49
import java.util.LinkedHashMap;
51
import java.util.LinkedHashMap;
50
import java.util.List;
52
import java.util.List;
51
import java.util.Map;
53
import java.util.Map;
Line 78... Line 80...
78
		// destinationDbPath = args[1];
80
		// destinationDbPath = args[1];
79
		// dryRun = args[2];
81
		// dryRun = args[2];
80
		// }
82
		// }
81
		//
83
		//
82
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
84
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath,destinationDbPath);
83
		contentmigrator.migrateImagesInTablets();
85
		contentmigrator.migrateTabletsBack();
84
 
86
 
85
	}
87
	}
86
 
88
 
87
	private void migrateWarrantyForCategory(Long catgoryId) throws Exception {
89
	private void migrateWarrantyForCategory(Long catgoryId) throws Exception {
88
		Collection<Entity> entities = CreationUtils.getEntities(catgoryId);
90
		Collection<Entity> entities = CreationUtils.getEntities(catgoryId);
Line 1865... Line 1867...
1865
			EntityState es = CreationUtils.getEntityState(newId);
1867
			EntityState es = CreationUtils.getEntityState(newId);
1866
			Slide sl = entity.getSlide(130130);
1868
			Slide sl = entity.getSlide(130130);
1867
			/*entity.setID(validId);
1869
			/*entity.setID(validId);
1868
			es.setID(validId);*/
1870
			es.setID(validId);*/
1869
			
1871
			
1870
			long newCategoryId = 10015;
-
 
1871
			if(sl==null){
-
 
1872
				newCategoryId = 10082;
-
 
1873
			}else{			
-
 
1874
				for (Feature f : sl.getFeatures()){
-
 
1875
					if(f.getFeatureDefinitionID() == 120323){
-
 
1876
						newCategoryId = 10015;
-
 
1877
					} else {
-
 
1878
						newCategoryId = 10082;
-
 
1879
					}
-
 
1880
				}
-
 
1881
			}
1872
			
1882
			entity.setCategoryID(newCategoryId);
-
 
1883
			es.setCategoryID(newCategoryId);
-
 
1884
 
1873
 
1885
			if(entity.getSlides()!=null){
-
 
1886
				for(Slide sl1 : entity.getSlides()) {
-
 
1887
					FreeformContent ffc = sl1.getFreeformContent();
-
 
1888
					if(ffc != null){
-
 
1889
						Map<String, Media> mediaMap = ffc.getMedias();
-
 
1890
						if(mediaMap!=null){
-
 
1891
							for(Media media : mediaMap.values()){
-
 
1892
								if(media.getType().equals(Type.IMAGE) || media.getType().equals(Type.DOCUMENT)){
-
 
1893
									copyMedia(String.valueOf(validId), String.valueOf(newId),media);
-
 
1894
								}
-
 
1895
							}
-
 
1896
						}
-
 
1897
					}
-
 
1898
				}
-
 
1899
			}
-
 
1900
			CreationUtils.updateEntity(entity);
1874
			CreationUtils.updateEntity(entity);
1901
			CreationUtils.updateEntityState(es);
1875
			CreationUtils.updateEntityState(es);
1902
			CreationUtils.deleteEntity(newId);
1876
			CreationUtils.deleteEntity(newId);
1903
			System.out.println(validId + " : " + es.getCategoryID() + ", removed entity id:" + newId);
1877
			System.out.println(validId + " : " + es.getCategoryID() + ", removed entity id:" + newId);
1904
			
1878
			
1905
		}
1879
		}
1906
		
1880
		
1907
	}
1881
	}
-
 
1882
 
-
 
1883
	private void migrateTabletsBack() throws Exception {
-
 
1884
		Date now = new Date();
-
 
1885
		Collection<Entity> entities = CreationUtils.getEntities(20010);
-
 
1886
		//entities = (List<Entity>)this.clone(entities);
-
 
1887
		for (Entity entity : entities) {
-
 
1888
			long entityId = entity.getID();
-
 
1889
			if(entityId>9999999){
-
 
1890
				long oldEntityId = entityId%10000000;
-
 
1891
				System.out.println(oldEntityId);
-
 
1892
				EntityState es = CreationUtils.getEntityState(entityId);
-
 
1893
				if(es != null) {
-
 
1894
					if (es.getStatus().equals(EntityStatus.READY) || es.getStatus().equals(EntityStatus.COMPLETE)){
-
 
1895
						es.setStatus(EntityStatus.READY);
-
 
1896
						es.setMerkedReadyOn(now);
-
 
1897
					}
-
 
1898
					es.setID(oldEntityId);
-
 
1899
					entity.setID(oldEntityId);
-
 
1900
					entity.setCategoryID(10010);
-
 
1901
					es.setCategoryID(10010);
-
 
1902
					CreationUtils.updateEntity(entity);
-
 
1903
					CreationUtils.updateEntityState(es);
-
 
1904
					CreationUtils.deleteEntity(entityId);
-
 
1905
					System.out.println(entityId + " moved back");
-
 
1906
 
-
 
1907
				} else {
-
 
1908
					CreationUtils.deleteEntity(entityId);
-
 
1909
					System.out.println("Deleted " + entityId + " due to incomplete tablets");
-
 
1910
				}
-
 
1911
			}else {
-
 
1912
				entity.setCategoryID(10010);
-
 
1913
				EntityState es = CreationUtils.getEntityState(entityId);
-
 
1914
				es.setCategoryID(10010);
-
 
1915
				CreationUtils.updateEntity(entity);
-
 
1916
				CreationUtils.updateEntityState(es);
-
 
1917
			}
-
 
1918
			
-
 
1919
			
-
 
1920
		}
-
 
1921
		
-
 
1922
	}
1908
	
1923
	
1909
    public String getTitle(Entity entity){
1924
    public String getTitle(Entity entity){
1910
    	String brand = entity.getBrand();
1925
    	String brand = entity.getBrand();
1911
    	String modelName = entity.getModelName();
1926
    	String modelName = entity.getModelName();
1912
    	String modelNumber = entity.getModelNumber();
1927
    	String modelNumber = entity.getModelNumber();