Subversion Repositories SmartDukaan

Rev

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

Rev 2566 Rev 3558
Line 30... Line 30...
30
    // role column in helper.catalogdashboarduser table. role specifies 
30
    // role column in helper.catalogdashboarduser table. role specifies 
31
    // the username-pwd pair for staging or for production.
31
    // the username-pwd pair for staging or for production.
32
    // production password is needed while updating item on production server.
32
    // production password is needed while updating item on production server.
33
    public static final int ROLE_STAGING = 0, ROLE_PRODUCTION = 1;
33
    public static final int ROLE_STAGING = 0, ROLE_PRODUCTION = 1;
34
    
34
    
35
    private static Map<Long, String> vendors, warehouses;
35
    private static Map<Long, String> vendors, warehouses, sources;
36
    
36
    
37
    private static final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
37
    private static final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
38
    
38
    
39
    static {
39
    static {
40
        catalogService.getAllVendors(new AsyncCallback<Map<Long,String>>() {
40
        catalogService.getAllVendors(new AsyncCallback<Map<Long,String>>() {
Line 56... Line 56...
56
            @Override
56
            @Override
57
            public void onFailure(Throwable caught) {
57
            public void onFailure(Throwable caught) {
58
                caught.printStackTrace();
58
                caught.printStackTrace();
59
            }
59
            }
60
        });
60
        });
-
 
61
        
-
 
62
        catalogService.getAllSources(new AsyncCallback<Map<Long,String>>() {
-
 
63
            @Override
-
 
64
            public void onSuccess(Map<Long, String> result) {
-
 
65
                sources = result;
-
 
66
            }
-
 
67
            @Override
-
 
68
            public void onFailure(Throwable caught) {
-
 
69
                caught.printStackTrace();
-
 
70
            }
-
 
71
        });
-
 
72
 
61
    }
73
    }
62
    
74
    
63
    public static Map<Long, String> getAllVendors() {
75
    public static Map<Long, String> getAllVendors() {
64
        return vendors;
76
        return vendors;
65
    }
77
    }
-
 
78
 
-
 
79
    public static Map<Long, String> getAllSources() {
-
 
80
        return sources;
-
 
81
    }
66
    
82
    
67
    public static Map<Long, String> getAllWarehouses() {
83
    public static Map<Long, String> getAllWarehouses() {
68
        return warehouses;
84
        return warehouses;
69
    }
85
    }
70
    
86
    
Line 73... Line 89...
73
            return null;
89
            return null;
74
        }
90
        }
75
        return vendors.get(id);
91
        return vendors.get(id);
76
    }
92
    }
77
    
93
    
-
 
94
    public static String getSourceDesc(long id) {
-
 
95
        if(sources == null) {
-
 
96
            return null;
-
 
97
        }
-
 
98
        return sources.get(id);
-
 
99
    }
-
 
100
    
78
    public static String getWarehouseDesc(long id) {
101
    public static String getWarehouseDesc(long id) {
79
        if(warehouses == null) {
102
        if(warehouses == null) {
80
            return null;
103
            return null;
81
        }
104
        }
82
        return warehouses.get(id);
105
        return warehouses.get(id);
Line 105... Line 128...
105
                return v.getKey();
128
                return v.getKey();
106
            }
129
            }
107
        }
130
        }
108
        return 0;
131
        return 0;
109
    }
132
    }
-
 
133
 
-
 
134
    
-
 
135
    /**
-
 
136
     * Since in source combo box, source name is populated, this method is used to get Id from name
-
 
137
     * @param source name
-
 
138
     * @return source Id corresponding to the name
-
 
139
     */
-
 
140
    public static long getSourceId(String sourceDesc) {
-
 
141
        if(sources == null) {
-
 
142
            return 0;
-
 
143
        }
-
 
144
        for(Entry<Long, String> s : sources.entrySet()) {
-
 
145
            if(s.getValue().equals(sourceDesc)) {
-
 
146
                return s.getKey();
-
 
147
            }
-
 
148
        }
-
 
149
        return 0;
-
 
150
    }
110
    
151
    
111
    /**
152
    /**
112
     * validates item object. ProductGroup, brand, modelNumber, modelName should not be empty or null.
153
     * validates item object. ProductGroup, brand, modelNumber, modelName should not be empty or null.
113
     * Also does item and vendor prices validations (MRP >= SP, MRP >= MOP, TP <= MOP)
154
     * Also does item and vendor prices validations (MRP >= SP, MRP >= MOP, TP <= MOP)
114
     * Vendor Item Key should not be empty or null
155
     * Vendor Item Key should not be empty or null