Subversion Repositories SmartDukaan

Rev

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

Rev 1061 Rev 1069
Line 16... Line 16...
16
import in.shop2020.metamodel.core.Entity;
16
import in.shop2020.metamodel.core.Entity;
17
import in.shop2020.metamodel.core.EntityState;
17
import in.shop2020.metamodel.core.EntityState;
18
import in.shop2020.metamodel.core.FreeformContent;
18
import in.shop2020.metamodel.core.FreeformContent;
19
import in.shop2020.metamodel.core.Media;
19
import in.shop2020.metamodel.core.Media;
20
import in.shop2020.metamodel.core.Slide;
20
import in.shop2020.metamodel.core.Slide;
21
//import in.shop2020.metamodel.definitions.OldEntityContainer;
21
import in.shop2020.metamodel.definitions.OldEntityContainer;
22
import in.shop2020.metamodel.util.CreationUtils;
22
import in.shop2020.metamodel.util.CreationUtils;
23
import in.shop2020.metamodel.util.ExpandedBullet;
23
import in.shop2020.metamodel.util.ExpandedBullet;
24
//import in.shop2020.metamodel.util.OldCreationUtils;
24
import in.shop2020.metamodel.util.OldCreationUtils;
25
import in.shop2020.storage.bdb.StorageManager;
25
import in.shop2020.storage.bdb.StorageManager;
26
 
26
 
27
 
27
 
28
/*
28
/*
29
 * @author rajveer 
29
 * @author rajveer 
Line 45... Line 45...
45
		}else{
45
		}else{
46
			sourceDbPath = args[0];
46
			sourceDbPath = args[0];
47
			destinationDbPath = args[1];
47
			destinationDbPath = args[1];
48
		}
48
		}
49
		
49
		
50
		//StorageManager.getStorageManager().close();
50
		StorageManager.getStorageManager().close();
51
		
51
		
52
		ContentMigratorToBDB contentmigrator = new ContentMigratorToBDB(sourceDbPath, destinationDbPath);
52
		ContentMigratorToBDB contentmigrator = new ContentMigratorToBDB(sourceDbPath, destinationDbPath);
53
		//boolean result = contentmigrator.addMedia();
53
		//boolean result = contentmigrator.addMedia();
54
//		boolean result = contentmigrator.addLearnedFields();
54
		//boolean result = contentmigrator.addLearnedFields();
55
		//boolean result = contentmigrator.migrate();
55
		//boolean result = contentmigrator.migrate();
56
		//System.out.println("Content migration status:  "+ result);
56
		//System.out.println("Content migration status:  "+ result);
57
	}
57
	}
58
 
58
 
59
	public ContentMigratorToBDB(String sourceDbPath, String destinationDbPath) {
59
	public ContentMigratorToBDB(String sourceDbPath, String destinationDbPath) {
60
		this.sourceDbPath = sourceDbPath;
60
		this.sourceDbPath = sourceDbPath;
61
		this.destinationDbPath = destinationDbPath;
61
		this.destinationDbPath = destinationDbPath;
62
	}
62
	}
63
	/*
63
	
64
	public boolean addLearnedFields() throws Exception{
64
	public boolean addLearnedFields() throws Exception{
65
		OldEntityContainer oldEnts = new OldEntityContainer(sourceDbPath);
65
		OldEntityContainer oldEnts = new OldEntityContainer(sourceDbPath);
66
		Map<Long, List<ExpandedBullet>> learnedBullets = oldEnts.getLearnedBullets();
66
		Map<Long, List<ExpandedBullet>> learnedBullets = oldEnts.getLearnedBullets();
67
		CreationUtils.storeLearnedBullets(learnedBullets);
67
		CreationUtils.storeLearnedBullets(learnedBullets);
68
		return true;
68
		return true;
Line 104... Line 104...
104
	    	StorageManager.getStorageManager().updateEntity(entity);
104
	    	StorageManager.getStorageManager().updateEntity(entity);
105
	    }
105
	    }
106
	    in.close();
106
	    in.close();
107
	    return true;
107
	    return true;
108
}
108
}
109
*/
109
 
110
	/**
110
	/**
111
	 * this function will read source definition and source entities, and will convert
111
	 * this function will read source definition and source entities, and will convert
112
	 * source entities to destination entities according to destination definitions.  
112
	 * source entities to destination entities according to destination definitions.  
113
	 * 
113
	 * 
114
	 * @return boolean
114
	 * @return boolean
115
	 * @throws Exception 
115
	 * @throws Exception 
116
	 */
116
	 */
117
	/*
-
 
118
	public boolean migrate() throws Exception{
117
	public boolean migrate() throws Exception{
119
		OldEntityContainer sourceEnts = new OldEntityContainer(sourceDbPath);
118
		OldEntityContainer sourceEnts = new OldEntityContainer(sourceDbPath);
120
		
119
		
121
		StringBuilder sb = new StringBuilder();
120
		StringBuilder sb = new StringBuilder();
122
		Map<Long, Entity> entities = sourceEnts.getEntities();
121
		Map<Long, Entity> entities = sourceEnts.getEntities();
123
		for(Long entityId: entities.keySet()){
122
		for(Long entityId: entities.keySet()){
124
			entityId = (long) 1000146;
-
 
125
			Entity entity = OldCreationUtils.getEntity(entityId);
123
			Entity entity = OldCreationUtils.getEntity(entityId);
126
			if(entity.getID() == 0){
124
			if(entity.getID() == 0){
127
				continue;
125
				continue;
128
			}
126
			}
129
			Entity newEntity = new Entity(entity.getID(), entity.getCategoryID());
127
			Entity newEntity = new Entity(entity.getID(), entity.getCategoryID());
Line 141... Line 139...
141
				FreeformContent newFfc = new FreeformContent();
139
				FreeformContent newFfc = new FreeformContent();
142
				newFfc.setFreeformTexts(ffc.getFreeformTexts());
140
				newFfc.setFreeformTexts(ffc.getFreeformTexts());
143
				slide.setFreeformContent(newFfc);
141
				slide.setFreeformContent(newFfc);
144
				//if(ffc.getAllLabels()!=null && !ffc.getAllLabels().isEmpty()){
142
				//if(ffc.getAllLabels()!=null && !ffc.getAllLabels().isEmpty()){
145
					//sb.append(entity.getID() + ":" + slide.getSlideDefinitionID() + ":" + ffc.getAllLabels() + "\n");
143
					//sb.append(entity.getID() + ":" + slide.getSlideDefinitionID() + ":" + ffc.getAllLabels() + "\n");
146
				//	sb.append(entity.getID() + ":" + slide.getSlideDefinitionID() + ":" + ffc.getImageLabels() + ":" + ffc.getYoutubeLabels() + "\n");
144
					//sb.append(entity.getID() + ":" + slide.getSlideDefinitionID() + ":" + ffc.getImageLabels() + ":" + ffc.getYoutubeLabels() + "\n");
147
					//System.out.println(entity.getID() + ":" + slide.getSlideDefinitionID() + ":" + ffc.getImageLabels() + ":" + ffc.getYoutubeLabels());
145
					//System.out.println(entity.getID() + ":" + slide.getSlideDefinitionID() + ":" + ffc.getImageLabels() + ":" + ffc.getYoutubeLabels());
148
//					System.out.println("some image found");
146
//					System.out.println("some image found");
149
//					System.out.println(ffc.getImageLabels());
147
//					System.out.println(ffc.getImageLabels());
150
//					System.out.println(ffc.getYoutubeLabels());
148
//					System.out.println(ffc.getYoutubeLabels());
151
				//}
149
				//}
Line 155... Line 153...
155
				//newFfc.setFreeformTexts(ffc.getFreeformTexts());
153
				//newFfc.setFreeformTexts(ffc.getFreeformTexts());
156
			}
154
			}
157
			}
155
			}
158
			newEntity.setSlides(slides);
156
			newEntity.setSlides(slides);
159
			EntityState entityMetadata = new EntityState(entityId, "admin");
157
			EntityState entityMetadata = new EntityState(entityId, "admin");
160
			//StorageManager.getStorageManager().createEntity(newEntity, entityMetadata);
158
			StorageManager.getStorageManager().createEntity(newEntity, entityMetadata);
161
			
159
			
162
			System.out.println(StorageManager.getStorageManager().getStorageManager().getEntity(entityId).getSlide(130033).getFreeformContent().getFreeformTexts());
160
			//System.out.println(StorageManager.getStorageManager().getStorageManager().getEntity(entityId).getSlide(130033).getFreeformContent().getFreeformTexts());
163
			
161
			
164
			StorageManager.getStorageManager().close();
162
			//StorageManager.getStorageManager().close();
165
			System.out.println("Entity id is" + entity.getID());
163
			//System.out.println("Entity id is" + entity.getID());
166
		}
164
		}
167
		
165
		
168
		//StorageManager.getStorageManager().close();
166
		StorageManager.getStorageManager().close();
169
		System.out.println(sb.toString());
167
		//System.out.println(sb.toString());
170
		return true;
168
		return true;
171
	}
169
	}
172
	*/
-
 
173
}
170
}