Subversion Repositories SmartDukaan

Rev

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

Rev 2068 Rev 2105
Line 2... Line 2...
2
 
2
 
3
import in.shop2020.catalog.dashboard.client.CatalogService;
3
import in.shop2020.catalog.dashboard.client.CatalogService;
4
import in.shop2020.catalog.dashboard.client.CatalogServiceAsync;
4
import in.shop2020.catalog.dashboard.client.CatalogServiceAsync;
5
 
5
 
6
import java.util.Date;
6
import java.util.Date;
-
 
7
import java.util.List;
7
import java.util.Map;
8
import java.util.Map;
-
 
9
import java.util.Map.Entry;
8
 
10
 
9
import com.google.gwt.core.client.GWT;
11
import com.google.gwt.core.client.GWT;
10
import com.google.gwt.user.client.rpc.AsyncCallback;
12
import com.google.gwt.user.client.rpc.AsyncCallback;
11
 
13
 
12
public class Utils {
14
public class Utils {
13
    
15
    public static int MODE_ADD = 0, MODE_EDIT = 1;
14
    private static Map<Long, String> vendors, warehouses;
16
    private static Map<Long, String> vendors, warehouses;
15
    private static final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
17
    private static final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
16
    static {
18
    static {
17
        catalogService.getAllVendors(new AsyncCallback<Map<Long,String>>() {
19
        catalogService.getAllVendors(new AsyncCallback<Map<Long,String>>() {
18
            @Override
20
            @Override
Line 32... Line 34...
32
            @Override
34
            @Override
33
            public void onFailure(Throwable caught) {
35
            public void onFailure(Throwable caught) {
34
            }
36
            }
35
        });
37
        });
36
    }
38
    }
-
 
39
        
-
 
40
    public static Map<Long, String> getAllVendors() {
-
 
41
        return vendors;
-
 
42
    }
-
 
43
    
-
 
44
    public static Map<Long, String> getAllWarehouses() {
-
 
45
        return warehouses;
-
 
46
    }
37
    
47
    
38
    public static String getVendorDesc(long id) {
48
    public static String getVendorDesc(long id) {
39
        if(vendors == null) {
49
        if(vendors == null) {
40
            return null;
50
            return null;
41
        }
51
        }
Line 55... Line 65...
55
        String dateString = date.toString();
65
        String dateString = date.toString();
56
        dateString = dateString.substring(0, dateString.lastIndexOf(" "));
66
        dateString = dateString.substring(0, dateString.lastIndexOf(" "));
57
        dateString = dateString.substring(0, dateString.lastIndexOf(" "));
67
        dateString = dateString.substring(0, dateString.lastIndexOf(" "));
58
        return dateString;      
68
        return dateString;      
59
    }
69
    }
-
 
70
    
-
 
71
    public static long getVendorId(String vendorDesc) {
-
 
72
        if(vendors == null) {
-
 
73
            return 0;
-
 
74
        }
-
 
75
        for(Entry<Long, String> v : vendors.entrySet()) {
-
 
76
            if(v.getValue().equals(vendorDesc)) {
-
 
77
                return v.getKey();
-
 
78
            }
-
 
79
        }
-
 
80
        return 0;
-
 
81
    }
60
}
82
}