Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
299 naveen 1
/**
2
 * 
3
 */
4
package in.shop2020.util;
5
 
6
import java.io.File;
7
import java.util.Map;
8
 
9
import in.shop2020.metamodel.core.Entity;
10
import in.shop2020.metamodel.definitions.Catalog;
11
import in.shop2020.metamodel.definitions.EntityContainer;
12
 
13
/**
14
 * @author naveen
15
 *
16
 */
17
public class MISC {
18
 
19
	/**
20
	 * @param args
21
	 * @throws Exception 
22
	 */
23
	public static void main(String[] args) throws Exception {
24
		MISC m = new MISC();
25
 
26
		m.serializeIndivisually();
27
	}
28
 
29
	/**
30
	 * @throws Exception 
31
	 * 
32
	 */
33
	public void serializeIndivisually() throws Exception {
34
		EntityContainer ents = Catalog.getInstance().getEntityContainer();
35
		Map<Long, Entity> entities = ents.getEntities();
36
 
37
		for(Long entityID : entities.keySet()) {
38
			Entity entity = entities.get(entityID);
39
			System.out.println("ID:" + entity.getID());
40
 
41
			String dir = Utils.ENTITIES_DB_PATH + "/" + entityID;
42
			File dirFile = new File(dir);
43
 
44
			if(!dirFile.exists()) {
45
				dirFile.mkdir();
46
			}
47
 
48
			String fileName = Utils.ENTITIES_DB_PATH + "/" + entityID + 
49
				"/entity.ser";
50
			File fileNameFile = new File(fileName);
51
			if(fileNameFile.exists()) {
52
				fileNameFile.delete();
53
			}
54
 
55
			fileNameFile.createNewFile();
56
 
57
			DBUtils.store(entity, fileName);
58
		}
59
	}
60
}