Subversion Repositories SmartDukaan

Rev

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

Rev 2768 Rev 2838
Line 1... Line 1...
1
package in.shop2020.metamodel.util;
1
package in.shop2020.metamodel.util;
2
 
2
 
3
import in.shop2020.metamodel.core.Brand;
3
import in.shop2020.metamodel.core.SpecialPage;
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.Feature;
6
import in.shop2020.metamodel.core.Feature;
7
import in.shop2020.metamodel.core.Helpdoc;
7
import in.shop2020.metamodel.core.Helpdoc;
8
import in.shop2020.metamodel.core.Slide;
8
import in.shop2020.metamodel.core.Slide;
Line 37... Line 37...
37
	private static final String INCONSISTENT_ENTITIES = "INCONSISTENT_ENTITIES";
37
	private static final String INCONSISTENT_ENTITIES = "INCONSISTENT_ENTITIES";
38
	private static final String HELPDOC_ENTITYIDS = "HELPDOC_ENTITYIDS";
38
	private static final String HELPDOC_ENTITYIDS = "HELPDOC_ENTITYIDS";
39
	private static final String RELATED_ACCESSORIES = "RELATED_ACCESSORIES";
39
	private static final String RELATED_ACCESSORIES = "RELATED_ACCESSORIES";
40
	private static final String COMPARISON_STATS = "COMPARISON_STATS";
40
	private static final String COMPARISON_STATS = "COMPARISON_STATS";
41
	private static long helpDocId;
41
	private static long helpDocId;
42
    private static long brandId;
42
    private static long specialPageId;
43
 
43
 
44
	/**
44
	/**
45
	 * 
45
	 * 
46
	 * @param aThrowable
46
	 * @param aThrowable
47
	 * @return
47
	 * @return
Line 682... Line 682...
682
		}
682
		}
683
		return categoryID;
683
		return categoryID;
684
	}
684
	}
685
 
685
 
686
	/**
686
	/**
687
	 * Brand ids start from 300000. Here, we pick the last one used and return
687
	 * Special page ids start from 300000. Here, we pick the last one used and return
688
     * a value one more than it.
688
     * a value one more than it.
689
	 */
689
	 */
690
    public static long getNewBrandId() {
690
    public static long getNewSpecialPageId() {
691
        if (brandId == 0) {
691
        if (specialPageId == 0) {
692
            brandId = 300000;
692
            specialPageId = 300000;
693
            Map<Long, Brand> brands = StorageManager.getStorageManager().getBrands();
693
            Map<Long, SpecialPage> specialPages = StorageManager.getStorageManager().getSpecialPages();
694
            if (brands != null) {
694
            if (specialPages != null) {
695
                for (long id : StorageManager.getStorageManager().getBrands().keySet()) {
695
                for (long id : StorageManager.getStorageManager().getSpecialPages().keySet()) {
696
                    if (brandId <= id) {
696
                    if (specialPageId <= id) {
697
                        brandId = id;
697
                        specialPageId = id;
698
                    }
698
                    }
699
                }
699
                }
700
            }
700
            }
701
        }
701
        }
702
 
702
 
703
        return ++brandId;
703
        return ++specialPageId;
704
    }
704
    }
705
 
705
 
706
    /**
706
    /**
707
     * Updates a given brand object in database.
707
     * Updates a given special page object in database.
708
     */
708
     */
709
    public static void storeBrand(Brand brand) {
709
    public static void storeSpecialPage(SpecialPage specialPage) {
710
        StorageManager.getStorageManager().updateBrand(brand);        
710
        StorageManager.getStorageManager().updateSpecialPage(specialPage);        
711
    }
711
    }
712
 
712
 
713
    /**
713
    /**
714
     * Looks up a brand object given its Id from database and returns the same.
714
     * Looks up a special page given its Id from database and returns the same.
715
     */
715
     */
716
    public static Brand getBrand(long brandId) {
716
    public static SpecialPage getSpecialPage(long specialPageId) {
717
        return StorageManager.getStorageManager().getBrand(brandId);
717
        return StorageManager.getStorageManager().getSpecialPage(specialPageId);
718
    }
718
    }
719
 
719
 
720
    /**
720
    /**
721
     * Returns all brands in the database.
721
     * Returns all special pages in the database.
722
     */
722
     */
723
    public static Map<Long, Brand> getBrands() {
723
    public static Map<Long, SpecialPage> getSpecialPages() {
724
        return StorageManager.getStorageManager().getBrands();
724
        return StorageManager.getStorageManager().getSpecialPages();
725
    }
725
    }
726
}
726
}