Subversion Repositories SmartDukaan

Rev

Rev 242 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 242 Rev 245
Line 929... Line 929...
929
		}
929
		}
930
 
930
 
931
		return brands;
931
		return brands;
932
	}
932
	}
933
 
933
 
-
 
934
	/**
-
 
935
	 * 
-
 
936
	 * @return
-
 
937
	 */
934
    protected EntityContainer getEntityContainer() {
938
    protected EntityContainer getEntityContainer() {
935
    	if(this.ents == null) {
939
    	if(this.ents == null) {
936
    		this.ents = new EntityContainer();
940
    		this.ents = Catalog.getInstance().getEntityContainer();
937
    	}
941
    	}
938
    	
942
    	
939
	    return this.ents;
943
	    return this.ents;
940
    }
944
    }
941
 
945
    
-
 
946
    /**
-
 
947
     * 
-
 
948
     * @return
-
 
949
     */
942
    protected DefinitionsContainer getDefinitionsContainer() {
950
    protected DefinitionsContainer getDefinitionsContainer() {
943
    	if(this.defs == null) {
951
    	if(this.defs == null) {
944
    		this.defs = new DefinitionsContainer();
952
    		this.defs = Catalog.getInstance().getDefinitionsContainer();
945
    	}
953
    	}
946
    	
954
    	
947
	    return this.defs;
955
	    return this.defs;
948
    }
956
    }
949
 
957
 
Line 951... Line 959...
951
     * 
959
     * 
952
     * @param entity
960
     * @param entity
953
     * @throws Exception
961
     * @throws Exception
954
     */
962
     */
955
	private void addEntity(Entity entity) throws Exception {			
963
	private void addEntity(Entity entity) throws Exception {			
956
		EntityContainer entContainer = new EntityContainer();
964
		EntityContainer entContainer = this.getEntityContainer();
957
 
965
 
958
		entContainer.addEntity(entity);
966
		entContainer.addEntity(entity);
959
		
967
		
960
		DBUtils.store(entContainer.getEntities(), Utils.ENTITIES_DB_PATH + 
-
 
961
				"entities" + ".ser");
968
		this.storeEntities();
962
		
-
 
963
		String entitiesbycategoryDBFile = Utils.ENTITIES_DB_PATH + 
-
 
964
			"entitiesbycategory" + ".ser";
-
 
965
		
-
 
966
		DBUtils.store(entContainer.getEntitiesbyCategory(), 
-
 
967
				entitiesbycategoryDBFile);
-
 
968
	}
969
	}
969
 
970
 
970
    /**
971
    /**
971
     * 
972
     * 
972
     * @param entity
973
     * @param entity
973
     * @throws Exception
974
     * @throws Exception
974
     */
975
     */
975
	private void updateEntity(Entity entity) throws Exception {			
976
	private void updateEntity(Entity entity) throws Exception {			
976
		EntityContainer entContainer = new EntityContainer();
977
		EntityContainer entContainer = this.getEntityContainer();
977
 
978
 
978
		entContainer.updateEntity(entity);
979
		entContainer.updateEntity(entity);
979
		
980
		
-
 
981
		this.storeEntities();
-
 
982
	}
-
 
983
 
-
 
984
	/**
-
 
985
	 * 
-
 
986
	 * @throws Exception
-
 
987
	 */
-
 
988
	private void storeEntities() throws Exception {	
-
 
989
		EntityContainer entContainer = this.getEntityContainer();
-
 
990
	
980
		DBUtils.store(entContainer.getEntities(), Utils.ENTITIES_DB_PATH + 
991
		String entityDBFile = Utils.ENTITIES_DB_PATH + "entities.ser";
-
 
992
		
981
				"entities" + ".ser");
993
		// Remove existing
-
 
994
		DBUtils.delete(entityDBFile);
-
 
995
		
-
 
996
		log.info("getEntities().size():" + entContainer.getEntities().size());
-
 
997
		DBUtils.store(entContainer.getEntities(), entityDBFile);
982
		
998
		
983
		String entitiesbycategoryDBFile = Utils.ENTITIES_DB_PATH + 
999
		String entitiesbycategoryDBFile = Utils.ENTITIES_DB_PATH + 
984
			"entitiesbycategory" + ".ser";
1000
			"entitiesbycategory.ser";
-
 
1001
	
-
 
1002
		// Remove existing
-
 
1003
		DBUtils.delete(entitiesbycategoryDBFile);
-
 
1004
 
-
 
1005
		log.info("entgetEntitiesbyCategory().size():" + 
-
 
1006
				entContainer.getEntitiesbyCategory().size());
985
		
1007
		
986
		DBUtils.store(entContainer.getEntitiesbyCategory(), 
1008
		DBUtils.store(entContainer.getEntitiesbyCategory(), 
987
				entitiesbycategoryDBFile);
1009
				entitiesbycategoryDBFile);
988
	}
1010
	}
989
	
1011