Subversion Repositories SmartDukaan

Rev

Rev 2387 | Rev 2489 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1961 ankur.sing 1
package in.shop2020.catalog.dashboard.client;
2
 
3
import in.shop2020.catalog.dashboard.shared.Item;
2066 ankur.sing 4
import in.shop2020.catalog.dashboard.shared.Utils;
2119 ankur.sing 5
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
6
import in.shop2020.catalog.dashboard.shared.VendorPricings;
1961 ankur.sing 7
 
8
import java.util.Date;
2066 ankur.sing 9
import java.util.HashMap;
1992 ankur.sing 10
import java.util.Map;
11
import java.util.Map.Entry;
1961 ankur.sing 12
 
13
import com.google.gwt.core.client.GWT;
14
import com.google.gwt.event.dom.client.ClickEvent;
1992 ankur.sing 15
import com.google.gwt.event.dom.client.ClickHandler;
16
import com.google.gwt.resources.client.CssResource;
1961 ankur.sing 17
import com.google.gwt.uibinder.client.UiBinder;
18
import com.google.gwt.uibinder.client.UiField;
19
import com.google.gwt.uibinder.client.UiHandler;
20
import com.google.gwt.user.client.Window;
2126 ankur.sing 21
import com.google.gwt.user.client.rpc.AsyncCallback;
1961 ankur.sing 22
import com.google.gwt.user.client.ui.Button;
2066 ankur.sing 23
import com.google.gwt.user.client.ui.CheckBox;
1992 ankur.sing 24
import com.google.gwt.user.client.ui.FlexTable;
25
import com.google.gwt.user.client.ui.HTMLTable.Cell;
1961 ankur.sing 26
import com.google.gwt.user.client.ui.Label;
27
import com.google.gwt.user.client.ui.ResizeComposite;
28
import com.google.gwt.user.client.ui.TextBox;
29
import com.google.gwt.user.client.ui.Widget;
2068 ankur.sing 30
import com.google.gwt.user.datepicker.client.DateBox;
1961 ankur.sing 31
 
2427 ankur.sing 32
/**
33
 * Panel contains fields for item details. Some of these fields are editable.
34
 * It also contains vendor item pricings, vendor item keys, and item availability in tabular format.
35
 * Item availability is made invisible for time being 
36
 */
1961 ankur.sing 37
public class ItemDetails extends ResizeComposite {
38
 
2359 ankur.sing 39
    private final int TABLE_INDEX_MAPPING_VENDOR_DESC = 0, 
40
                      TABLE_INDEX_MAPPING_ITEM_KEY = 1,
41
                      TABLE_INDEX_MAPPING_BUTTON = 2,
42
                      TABLE_INDEX_MAPPING_VENDORID = 3, 
43
                      TABLE_INDEX_MAPPING_ITEM_KEY_OLD = 4;
44
 
45
    private final int TABLE_INDEX_PRICING_VENDOR_DESC = 0, 
46
                      TABLE_INDEX_PRICING_MOP = 1,
47
                      TABLE_INDEX_PRICING_DP = 2,
48
                      TABLE_INDEX_PRICING_TP = 3,
49
                      TABLE_INDEX_PRICING_BUTTON = 4,
50
                      TABLE_INDEX_PRICING_VENDORID = 5;
51
 
2119 ankur.sing 52
    private final int TABLE_INDEX_WAREHOUSE_ID = 0,
53
                      TABLE_INDEX_WAREHOUSE_DESC = 1,
54
                      TABLE_INDEX_WAREHOUSE_INV = 2;
2359 ankur.sing 55
 
56
    private final String PRICE_WIDTH = "100px", VENDOR_DESC_WIDTH = "130px",
57
                         VENDOR_ID_WIDTH = "100px", ITEM_KEY_WIDTH = "200px",
58
                         BUTTON_WIDTH = "50px";
2066 ankur.sing 59
 
60
    interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
61
    private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
2126 ankur.sing 62
    private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
2066 ankur.sing 63
 
1961 ankur.sing 64
 
2066 ankur.sing 65
    interface ItemDetailStyle extends CssResource{
66
        String greenLabel();
67
        String fieldChanged();
68
    }
1961 ankur.sing 69
 
2105 ankur.sing 70
    private Item item, newItem;
2066 ankur.sing 71
 
72
    @UiField ItemDetailStyle style;
73
    @UiField Label itemId;
74
    @UiField TextBox productGroup, brand, modelNumber, modelName, color;
2105 ankur.sing 75
    @UiField Label contentCategory, catalogItemId;
2359 ankur.sing 76
    @UiField TextBox statusDesc, comments;
2105 ankur.sing 77
    @UiField TextBox sellingPrice, mrp, weight;
78
    @UiField Label addedOn, retireDate, updatedOn;
2066 ankur.sing 79
    @UiField Label itemStatus;
80
    @UiField TextBox bestDealsText, bestDealsValue; 
81
    @UiField FlexTable headerAvailability, availabilityTable;
2427 ankur.sing 82
    @UiField FlexTable headerVendorItemKey, tableVendorItemKey;
83
    @UiField FlexTable headerVendorPrices, tableVendorPrices;
2066 ankur.sing 84
    @UiField TextBox bestSellingRank;
2252 ankur.sing 85
    @UiField CheckBox defaultForEntity, risky;
2068 ankur.sing 86
    @UiField DateBox startDate;
2066 ankur.sing 87
 
88
    public ItemDetails(Item item){
2105 ankur.sing 89
        this();
2066 ankur.sing 90
        setItemDetails(item);
91
    }
92
 
93
    public ItemDetails() {
94
        initWidget(uiBinder.createAndBindUi(this));
95
        initAvailabilityHeader();
2427 ankur.sing 96
        initVendorKeysHeader();
97
        initVendorPricingHeader();
2119 ankur.sing 98
 
2105 ankur.sing 99
        headerAvailability.setVisible(false);
100
        availabilityTable.setVisible(false);
2066 ankur.sing 101
    }
102
 
2427 ankur.sing 103
    /**
104
     * Sets the UI fields with item object attributes
105
     * Also populates tables for vendor prices, keys and item availability
106
     * @param item
107
     */
2066 ankur.sing 108
    public void setItemDetails(Item item){
109
        this.item = item;
110
        itemId.setText(item.getId()+"");
111
        productGroup.setText(item.getProductGroup());
112
        brand.setText(item.getBrand());
113
        modelNumber.setText(item.getModelNumber());
114
        modelName.setText(item.getModelName());
115
        color.setText(item.getColor());
116
 
2359 ankur.sing 117
        statusDesc.setText(item.getItemStatusDesc());
2105 ankur.sing 118
        contentCategory.setText(item.getContentCategory()+"");
2066 ankur.sing 119
        comments.setText(item.getComments());
120
        catalogItemId.setText(item.getCatalogItemId() + "");
121
 
2126 ankur.sing 122
        mrp.setText(item.getMrp() != -1 ? item.getMrp()+"" : "");
123
        sellingPrice.setText(item.getSellingPrice() != -1 ? item.getSellingPrice()+"" : "");
2138 ankur.sing 124
        weight.setText(item.getWeight() != -1 ? item.getWeight()+"" : "");
2068 ankur.sing 125
 
126
        startDate.setValue(new Date(item.getStartDate()));
127
        addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
128
        retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
129
        updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
1992 ankur.sing 130
 
2066 ankur.sing 131
        bestDealsText.setText(item.getBestDealsText());
2126 ankur.sing 132
        bestDealsValue.setText(item.getBestDealsValue() != -1 ? item.getBestDealsValue()+"" : "");
133
        bestSellingRank.setText(item.getBestSellingRank() != -1 ? item.getBestSellingRank()+"" : "");
2066 ankur.sing 134
        defaultForEntity.setValue(item.isDefaultForEntity());
2252 ankur.sing 135
        risky.setValue(item.isRisky());
1992 ankur.sing 136
 
2066 ankur.sing 137
        itemStatus.setText(item.getItemStatus());
138
 
139
        updateAvailabilityTable(item.getAvailability());
2427 ankur.sing 140
        updateVendorKeysTable(item.getVendorKeysMap());
141
        updateVendorPricingTable(item.getVendorPricesMap());
1992 ankur.sing 142
    }
2066 ankur.sing 143
 
2427 ankur.sing 144
    /**
145
     * initialise item availability table header.
146
     */
2066 ankur.sing 147
    private void initAvailabilityHeader(){
148
        headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
2105 ankur.sing 149
        headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
2066 ankur.sing 150
        headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
151
 
152
        headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
153
        headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
154
        headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
1992 ankur.sing 155
 
156
    }
2066 ankur.sing 157
 
2427 ankur.sing 158
    /**
159
     * initialises vendor item key table header. Creates an Add button and
160
     * adds click event listener to it to create and pop up a dialog for adding 
161
     * a new vendor item key. 
162
     */
163
    private void initVendorKeysHeader(){
164
        headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
165
        headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
166
        headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
167
        headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
168
        headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
2119 ankur.sing 169
 
2427 ankur.sing 170
        headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDORID, "Vendor Id");
171
        headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDOR_DESC, "Vendor");
172
        headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY, "Item Key");
173
        headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, "Prev Item Key");
2119 ankur.sing 174
 
2427 ankur.sing 175
        headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_VENDORID, false);
176
        headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
2359 ankur.sing 177
 
2119 ankur.sing 178
        Button addButton = new Button("Add");
2427 ankur.sing 179
        headerVendorItemKey.setWidget(0, TABLE_INDEX_MAPPING_BUTTON, addButton);
2119 ankur.sing 180
        addButton.addClickHandler(new ClickHandler() {
181
            @Override
182
            public void onClick(ClickEvent event) {
2126 ankur.sing 183
                VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
184
                        modelNumber.getText().trim(), color.getText().trim());
2119 ankur.sing 185
                vendorMappingDialog.updateButton.setText("Add");
186
                vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
187
                    @Override
188
                    public boolean onUpdate(String key, long vendorId) {
2427 ankur.sing 189
                        int row = tableVendorItemKey.getRowCount();
190
                        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
191
                        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
192
                        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
193
                        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
2119 ankur.sing 194
 
2427 ankur.sing 195
                        tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDORID, vendorId + "");
196
                        tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
197
                        tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, key);
198
                        tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, key);
2359 ankur.sing 199
 
2427 ankur.sing 200
                        tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_VENDORID, false);
201
                        tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
2119 ankur.sing 202
                        return true;
203
                    }
204
                });
205
                vendorMappingDialog.show();
206
            }
207
        });
208
    }
209
 
2427 ankur.sing 210
    /**
211
     * initialises vendor prices table header. Creates an Add button and
212
     * adds click event listener to it to create and pop up a dialog for adding 
213
     * a prices for a new vendor 
214
     */
215
    private void initVendorPricingHeader(){
216
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
217
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
218
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
219
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
220
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
221
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
2066 ankur.sing 222
 
2427 ankur.sing 223
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
224
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
225
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
226
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
227
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
2105 ankur.sing 228
 
2427 ankur.sing 229
        headerVendorPrices.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
2359 ankur.sing 230
 
2105 ankur.sing 231
        Button addButton = new Button("Add");
2427 ankur.sing 232
        headerVendorPrices.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
2105 ankur.sing 233
        addButton.addClickHandler(new ClickHandler() {
234
            @Override
235
            public void onClick(ClickEvent event) {
2119 ankur.sing 236
                VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
237
                vendorPricesDialog.updateButton.setText("Add");
238
                vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
2105 ankur.sing 239
                    @Override
2119 ankur.sing 240
                    public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
2105 ankur.sing 241
                        if(!vendorExists(vendorId)) {
242
                            Window.alert("Vendor already exists");
243
                            return false;
244
                        }
2119 ankur.sing 245
                        /*if(!validateVendorPrices(mop, dp, tp)) {
2105 ankur.sing 246
                            return false;
2119 ankur.sing 247
                        }*/
2427 ankur.sing 248
                        int row = tableVendorPrices.getRowCount();
249
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
250
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
251
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
252
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
253
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
2105 ankur.sing 254
 
2427 ankur.sing 255
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
256
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
257
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
258
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
259
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
2359 ankur.sing 260
 
2427 ankur.sing 261
                        tableVendorPrices.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
2105 ankur.sing 262
                        return true;
263
                    }
264
                });
2119 ankur.sing 265
                vendorPricesDialog.show();
2105 ankur.sing 266
            }
267
        });
2066 ankur.sing 268
    }
2105 ankur.sing 269
 
2427 ankur.sing 270
    /**
271
     * Clear and populate item availability table.
272
     * @param availabilityMap
273
     */
1992 ankur.sing 274
    private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
275
        availabilityTable.removeAllRows();
276
        if(availabilityMap == null) {
277
            return;
278
        }
2066 ankur.sing 279
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
2105 ankur.sing 280
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
2066 ankur.sing 281
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
282
 
1992 ankur.sing 283
        int i=0;
284
        for(Entry<Long, Long> availability : availabilityMap.entrySet()){
2066 ankur.sing 285
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, availability.getKey() + "");
286
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
287
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
1992 ankur.sing 288
            i++;
289
        }
290
    }
2119 ankur.sing 291
 
2427 ankur.sing 292
    /**
293
     * Clear and populate vendor item key table with keys in the passed argument.
294
     * With each row in the table, an edit button is created and click event listener 
295
     * is added to it to edit that vendor item key row.
296
     * @param vendorKeysMap
297
     */
298
    private void updateVendorKeysTable(Map<String, VendorItemMapping> vendorKeysMap){
299
        tableVendorItemKey.removeAllRows();
2119 ankur.sing 300
 
2427 ankur.sing 301
        if(vendorKeysMap == null || vendorKeysMap.isEmpty()) {
2119 ankur.sing 302
            return;
303
        }
2427 ankur.sing 304
        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
305
        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
306
        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
307
        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
308
        tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
2066 ankur.sing 309
 
2119 ankur.sing 310
        int i=0;
2427 ankur.sing 311
        for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()){
2359 ankur.sing 312
            VendorItemMapping vendorMapping = e.getValue();
2427 ankur.sing 313
            tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDORID, vendorMapping.getVendorId() + "");
314
            tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
315
            tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY, vendorMapping.getItemKey());
316
            tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1));
2119 ankur.sing 317
            Button editButton = new Button("Edit");
2427 ankur.sing 318
            tableVendorItemKey.setWidget(i, TABLE_INDEX_MAPPING_BUTTON, editButton);
2119 ankur.sing 319
            editButton.addClickHandler(new ClickHandler() {
320
                @Override
321
                public void onClick(ClickEvent event) {
2427 ankur.sing 322
                    Cell cell = tableVendorItemKey.getCellForEvent(event);
2119 ankur.sing 323
                    int row = cell.getRowIndex();
2427 ankur.sing 324
                    long vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
325
                    editVendorKey(vendorId, row);
2119 ankur.sing 326
                }
327
            });
2427 ankur.sing 328
            tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_VENDORID, false);
329
            tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
2359 ankur.sing 330
            i++;
2119 ankur.sing 331
        }
332
    }
333
 
2427 ankur.sing 334
    /**
335
     * Clear and populate vendor prices table with prices in the passed argument.
336
     * With each row in the table, an edit button is created and click event listener 
337
     * is added to it to edit that vendor prices row.
338
     * @param vendorPricingMap
339
     */
340
    private void updateVendorPricingTable(Map<Long, VendorPricings> vendorPricingMap){
341
        tableVendorPrices.removeAllRows();
2105 ankur.sing 342
 
2119 ankur.sing 343
        if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
1992 ankur.sing 344
            return;
345
        }
2427 ankur.sing 346
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
347
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
348
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
349
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
350
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
351
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
2066 ankur.sing 352
 
353
 
1992 ankur.sing 354
        int i=0;
2119 ankur.sing 355
        for(VendorPricings vendorDetail : vendorPricingMap.values()){
2427 ankur.sing 356
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
357
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
358
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
359
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
360
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
1992 ankur.sing 361
            Button editButton = new Button("Edit");
2427 ankur.sing 362
            tableVendorPrices.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
1992 ankur.sing 363
            editButton.addClickHandler(new ClickHandler() {
364
                @Override
365
                public void onClick(ClickEvent event) {
2427 ankur.sing 366
                    Cell cell = tableVendorPrices.getCellForEvent(event);
1992 ankur.sing 367
                    int row = cell.getRowIndex();
2427 ankur.sing 368
                    long vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
369
                    editVendorPrices(vendorId, row);
1992 ankur.sing 370
                }
371
            });
2427 ankur.sing 372
            tableVendorPrices.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
2359 ankur.sing 373
            i++;
1992 ankur.sing 374
        }
375
    }
2066 ankur.sing 376
 
2427 ankur.sing 377
    /**
378
     * called on the click event of update item button in ItemActions
379
     */
2126 ankur.sing 380
    void updateItem() {
381
        if(item == null) {
382
            Window.alert("Please select an item to update.");
383
            return;
384
        }
2066 ankur.sing 385
        try {
2126 ankur.sing 386
            if(!createNewItem()) {
387
                return;
388
            }
2252 ankur.sing 389
            String paramsChanged = isItemChanged();
390
            if(paramsChanged.equals("")) {
2066 ankur.sing 391
                Window.alert("Nothing to update. Please change intended item parameters and try again.");
392
                return;
2252 ankur.sing 393
            } else {
394
                paramsChanged = "You have changed following items.\n" + paramsChanged;
395
                Window.alert(paramsChanged);
2066 ankur.sing 396
            }
397
        } catch(NumberFormatException ex) {
2126 ankur.sing 398
            ex.printStackTrace();
399
            GWT.log("Number format exception");
400
        }
401
        if(!Utils.validateItem(newItem)) {
2066 ankur.sing 402
            return;
403
        }
2126 ankur.sing 404
 
405
        /*if(!validatePrices()) {
406
            return;
407
        }*/
408
        catalogService.updateItem(newItem, new AsyncCallback<Boolean>() {
409
            @Override
410
            public void onSuccess(Boolean result) {
411
                if(result) {
412
                    item = newItem;
413
                    GWT.log("Item updated. Id = " + item.getId());
414
                    Window.alert("Item updated successfully.");
415
                }
416
                else {
417
                    GWT.log("Error updating item");
418
                    Window.alert("Error updating item");
419
                }
420
            }
421
            @Override
422
            public void onFailure(Throwable caught) {
423
                caught.printStackTrace();
424
                Window.alert("Error while updating item");
425
            }
426
        });
2066 ankur.sing 427
    }
2126 ankur.sing 428
 
2427 ankur.sing 429
    /**
430
     * This method is called while updating item.<br> It will create a new Item object and set 
431
     * its editable attributes with UI fields values and non-editable attributes with old Item
432
     * object attributes. This new Item object is then passed to the service to update item in the database.
433
     * <br>If update is successful, the old Item object is replaced with the new Item object. 
434
     * @return true if new Item object is created successfully
435
     *     <br>false if some error occurs due to NumberFormatException
436
     */
2126 ankur.sing 437
    private boolean createNewItem() {
2066 ankur.sing 438
        newItem = new Item();
439
        newItem.setId(Long.parseLong(itemId.getText()));
440
        newItem.setProductGroup(productGroup.getText().trim());
441
        newItem.setBrand(brand.getText().trim());
442
        newItem.setModelNumber(modelNumber.getText().trim());
443
        newItem.setModelName(modelName.getText().trim());
444
        newItem.setColor(color.getText().trim());
2119 ankur.sing 445
        newItem.setContentCategory(contentCategory.getText());
2066 ankur.sing 446
        newItem.setComments(comments.getText().trim());
447
        newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
2126 ankur.sing 448
 
2068 ankur.sing 449
        try {
2126 ankur.sing 450
            if(!mrp.getText().trim().isEmpty()) {
451
                double mrpValue = Double.parseDouble(mrp.getText().trim());
452
                if(mrpValue <= 0) {
453
                    throw new NumberFormatException("Negative value of MRP");
454
                }
455
                newItem.setMrp(mrpValue);
456
            } else {
457
                newItem.setMrp(-1);
458
            }
2068 ankur.sing 459
        } catch(NumberFormatException ex) {
2126 ankur.sing 460
            Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
461
            return false;
2068 ankur.sing 462
        }
463
        try {
2126 ankur.sing 464
            if(!sellingPrice.getText().trim().isEmpty()) {
465
            double spValue = Double.parseDouble(sellingPrice.getText().trim());
466
            if(spValue <= 0) {
467
                throw new NumberFormatException("Negative value of Selling price");
468
            }
469
            newItem.setSellingPrice(spValue);
470
            } else {
471
                newItem.setSellingPrice(-1);
472
            }
473
        } catch(NumberFormatException ex) {
474
            Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
475
            return false;
2068 ankur.sing 476
        }
477
        try {
2126 ankur.sing 478
            if(!weight.getText().trim().isEmpty()) {
479
                double wtValue = Double.parseDouble(weight.getText().trim());
480
                if(wtValue <= 0) {
481
                    throw new NumberFormatException("Negative value of Weight");
482
                }
483
                newItem.setWeight(wtValue);
484
            } else {
485
                newItem.setWeight(-1);
486
            }
2068 ankur.sing 487
        } catch(NumberFormatException ex) {
2126 ankur.sing 488
            Window.alert("Invalid weight format/value. Value shoule be greater than zero");
489
            return false;
2068 ankur.sing 490
        }
2126 ankur.sing 491
        try {
492
            if(!startDate.getTextBox().getText().trim().equals("")) {
493
                newItem.setStartDate(startDate.getValue().getTime());
494
            }
495
        } catch(Exception ex) {
496
            Window.alert("Invalid start date format");
497
            return false;
498
        }
2066 ankur.sing 499
        newItem.setBestDealsText(bestDealsText.getText().trim());
2068 ankur.sing 500
        try {
2126 ankur.sing 501
            if(!bestDealsValue.getText().trim().equals("")) {
502
                double bdValue = Double.parseDouble(bestDealsValue.getText().trim());
503
                if(bdValue < 0) {
504
                    throw new NumberFormatException("Negative value of BestDealValue");
505
                }
506
                newItem.setBestDealsValue(bdValue);
507
            } else {
508
                newItem.setBestDealsValue(-1);
509
            }
2068 ankur.sing 510
        } catch(NumberFormatException ex) {
2126 ankur.sing 511
            Window.alert("Invalid best deal value format");
512
            return false;
2068 ankur.sing 513
        }
514
        try {
2126 ankur.sing 515
            if(!bestSellingRank.getText().trim().equals("")) {
516
                long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
517
                if(bsrValue < 0) {
518
                    throw new NumberFormatException("Negative value of Best Selling Rank");
519
                }
520
                newItem.setBestSellingRank(bsrValue);
521
            } else {
522
                newItem.setBestSellingRank(-1);
523
            }
524
 
525
        } catch(NumberFormatException ex) {
526
            Window.alert("Invalid best selling rank format");
527
            return false;
2068 ankur.sing 528
        }
2066 ankur.sing 529
        newItem.setDefaultForEntity(defaultForEntity.getValue());
2252 ankur.sing 530
        newItem.setRisky(risky.getValue());
2119 ankur.sing 531
 
2126 ankur.sing 532
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
533
          Add the instance to map and set the map to the item instance created above.*/
534
        Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
2119 ankur.sing 535
        VendorPricings v;
2427 ankur.sing 536
        for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
2119 ankur.sing 537
            v = new VendorPricings();
2427 ankur.sing 538
            v.setMop(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP)));
539
            v.setDealerPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP)));
540
            v.setTransferPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP)));
541
            v.setVendorId(Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID)));
2126 ankur.sing 542
            vendorPrices.put(v.getVendorId(), v);
2105 ankur.sing 543
            newItem.setMop(v.getMop());
544
            newItem.setDealerPrice(v.getDealerPrice());
545
            newItem.setTransferPrice(v.getTransferPrice());
2066 ankur.sing 546
        }
2126 ankur.sing 547
        newItem.setVendorPricesMap(vendorPrices);
2359 ankur.sing 548
        newItem.setItemStatusDesc(statusDesc.getText().trim());
2427 ankur.sing 549
 
2126 ankur.sing 550
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
551
        Add the instance to map and set the map to the item instance created above.*/
2359 ankur.sing 552
        Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
2126 ankur.sing 553
        VendorItemMapping vMapping;
2427 ankur.sing 554
        for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
2126 ankur.sing 555
            vMapping = new VendorItemMapping();
2427 ankur.sing 556
            vMapping.setItemKey(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY));
557
            vMapping.setVendorId(Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID)));
558
            vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD), vMapping);
2119 ankur.sing 559
        }
2359 ankur.sing 560
        newItem.setVendorKeysMap(vendorMappings);
2119 ankur.sing 561
 
2126 ankur.sing 562
        newItem.setContentCategoryId(item.getContentCategoryId());
563
        newItem.setFeatureId(item.getFeatureId());
564
        newItem.setFeatureDescription(item.getFeatureDescription());
565
        newItem.setAddedOn(item.getAddedOn());
566
        newItem.setRetireDate(item.getRetireDate());
567
        newItem.setUpdatedOn(item.getUpdatedOn());
568
        newItem.setItemStatus(item.getItemStatus());
569
        newItem.setOtherInfo(item.getOtherInfo());
570
        newItem.setAvailability(item.getAvailability());
2119 ankur.sing 571
 
2126 ankur.sing 572
        return true;
2066 ankur.sing 573
    }
574
 
2427 ankur.sing 575
    /**
576
     * This method is called when Edit button is clicked corresponding to a row in 
577
     * vendor prices table. It will pop up a form to edit the vendor prices.
578
     * @param vendorId
579
     * @param row
580
     */
581
    private void editVendorPrices(final long vendorId, final int row) {
582
        String mop = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP);
583
        String dp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP);
584
        String tp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP);
2119 ankur.sing 585
        VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
2105 ankur.sing 586
        pricesDialog.updateButton.setText("Update");
2119 ankur.sing 587
        pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
2066 ankur.sing 588
            @Override
2119 ankur.sing 589
            public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
590
                if(!validateVendorPrices(mop, dp, tp)) {
2105 ankur.sing 591
                    return false;
592
                }
2427 ankur.sing 593
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
594
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
595
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
2105 ankur.sing 596
                return true;
2066 ankur.sing 597
            }
598
        });
599
        pricesDialog.show();
600
    }
2119 ankur.sing 601
 
2427 ankur.sing 602
    /**
603
     * This method is called when Edit button is clicked corresponding to a row in 
604
     * vendor item key table. It will pop up a form to edit the item key.
605
     * @param vendorId
606
     * @param row
607
     */
608
    private void editVendorKey(final long vendorId, final int row) {
609
        String key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
2126 ankur.sing 610
        VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
611
                modelNumber.getText().trim(), color.getText().trim(), key);
2119 ankur.sing 612
        mappingDialog.updateButton.setText("Update");
613
        mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
614
            @Override
615
            public boolean onUpdate(String itemKey, long vendorId) {
616
                if(itemKey == null || itemKey.equals("")) {
617
                    Window.alert("Item key cannot be empty.");
618
                    return false;
619
                }
2427 ankur.sing 620
                tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, itemKey);
2119 ankur.sing 621
                return true;
622
            }
623
        });
624
        mappingDialog.show();
625
    }
2066 ankur.sing 626
 
2427 ankur.sing 627
    /**
628
     * This method compares all the editable UI fields values with attributes in the item object.
629
     * If they differ, the attribute name is appended to a string.
630
     * @return String showing attributes which are changed by the user for confirmation.
631
     *      <br>Empty string if nothing is changed.
632
     */
2252 ankur.sing 633
    private String isItemChanged() {
634
        StringBuilder sb = new StringBuilder("");
2387 ankur.sing 635
        if(!checkStringsIfEqual(productGroup.getText().trim(), item.getProductGroup())) {
636
            sb.append("\n-Product Group");
2066 ankur.sing 637
        }
2387 ankur.sing 638
        if(!checkStringsIfEqual(brand.getText().trim(), item.getBrand())) {
639
            sb.append("\n-Brand");
2066 ankur.sing 640
        }
2387 ankur.sing 641
        if(!checkStringsIfEqual(modelNumber.getText().trim(), item.getModelNumber())) {
642
            sb.append("\n-Model Number");
2066 ankur.sing 643
        }
2387 ankur.sing 644
        if(!checkStringsIfEqual(modelName.getText().trim(), item.getModelName())) {
645
            sb.append("\n-Model Name");
2066 ankur.sing 646
        }
2387 ankur.sing 647
        if(!checkStringsIfEqual(color.getText().trim(), item.getColor())) {
648
            sb.append("\n-Color");
2066 ankur.sing 649
        }
2387 ankur.sing 650
        if(!checkStringsIfEqual(statusDesc.getText().trim(), item.getItemStatusDesc())) {
651
            sb.append("\n-Status Description");
2359 ankur.sing 652
        }
2387 ankur.sing 653
        if(!checkStringsIfEqual(comments.getText().trim(), item.getComments())) {
654
            sb.append("\n-Comments");
2066 ankur.sing 655
        }
2126 ankur.sing 656
        if(newItem.getMrp() != item.getMrp()) {
2387 ankur.sing 657
            sb.append("\n-MRP");
2066 ankur.sing 658
        }
2126 ankur.sing 659
        if(newItem.getSellingPrice() != item.getSellingPrice()) {
2387 ankur.sing 660
            sb.append("\n-Selling Price");
2027 ankur.sing 661
        }
2126 ankur.sing 662
        if(newItem.getWeight() != item.getWeight()) {
2387 ankur.sing 663
            sb.append("\n-Weight");
2027 ankur.sing 664
        }
2387 ankur.sing 665
        if(!checkStringsIfEqual(bestDealsText.getText().trim(), item.getBestDealsText())) {
666
            sb.append("\n-Best Deal Text");
2066 ankur.sing 667
        }
2126 ankur.sing 668
        if(newItem.getBestDealsValue() != item.getBestDealsValue()) {
2387 ankur.sing 669
            sb.append("\n-Best Deal Value");
2027 ankur.sing 670
        }
2126 ankur.sing 671
        if(newItem.getBestSellingRank() != item.getBestSellingRank()) {
2387 ankur.sing 672
            sb.append("\n-Best Selling Rank");
2066 ankur.sing 673
        }
674
        if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
2387 ankur.sing 675
            sb.append("\n-Default For Entity Flag");
2066 ankur.sing 676
        }
2252 ankur.sing 677
        if(item.isRisky() != risky.getValue()) {
2387 ankur.sing 678
            sb.append("\n-Risky Flag");
2252 ankur.sing 679
        }
2068 ankur.sing 680
        if(newItem.getStartDate() != item.getStartDate()) {
2387 ankur.sing 681
            sb.append("\n-Start Date");
2068 ankur.sing 682
        }
2126 ankur.sing 683
        VendorPricings vendorPricings;
2066 ankur.sing 684
        long vendorId;
2427 ankur.sing 685
        for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
686
            vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
2126 ankur.sing 687
            vendorPricings = item.getVendorPricesMap().get(vendorId);
2359 ankur.sing 688
            if(vendorPricings == null) {
2387 ankur.sing 689
                sb.append("\n-Vendor Prices (Vendor:" + vendorId + ")");
2359 ankur.sing 690
                continue;
691
            }
2427 ankur.sing 692
            if(vendorPricings.getMop() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP))) {
2387 ankur.sing 693
                sb.append("\n-MOP (Vendor:" + vendorId + ")");
2066 ankur.sing 694
            }
2427 ankur.sing 695
            if(vendorPricings.getDealerPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP))) {
2387 ankur.sing 696
                sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
2066 ankur.sing 697
            }
2427 ankur.sing 698
            if(vendorPricings.getTransferPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP))) {
2387 ankur.sing 699
                sb.append("\n-Transfer Price (Vendor:" + vendorId + ")");
2066 ankur.sing 700
            }
701
        }
2387 ankur.sing 702
 
703
        VendorItemMapping mapping;
704
        String old_key, new_key;
2427 ankur.sing 705
        for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
706
            vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
707
            old_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD);
708
            new_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
2387 ankur.sing 709
            mapping = item.getVendorKeysMap().get(vendorId + Item.KEY_SEPARATOR + old_key);
710
            if(mapping == null || !old_key.equals(new_key)) {
711
                sb.append("\n-Vendor Key (Vendor:" + vendorId + ",Key: = " + old_key + ")");
712
                continue;
713
            }
714
        }
2252 ankur.sing 715
        return sb.toString();
2066 ankur.sing 716
    }
717
 
718
    private boolean validatePrices() {
719
        if(newItem.getSellingPrice() > newItem.getMrp()) {
720
            Window.alert("Selling price cannot be more than MRP");
721
            return false;
722
        }
2119 ankur.sing 723
        for(VendorPricings v : newItem.getVendorPricesMap().values()) {
2105 ankur.sing 724
            if(newItem.getMrp() < v.getMop()) {
725
                Window.alert("MRP cannot be less than MOP. Vendor: " + v.getVendorId());
2066 ankur.sing 726
                return false;
727
            }
2105 ankur.sing 728
            if(v.getTransferPrice() > v.getMop()) {
729
                Window.alert("Transfer Price cannot be more than MOP. Vendor: " + v.getVendorId());
2066 ankur.sing 730
                return false;
731
            }
732
        }
733
        return true;
734
    }
2105 ankur.sing 735
 
2119 ankur.sing 736
    private boolean validateVendorPrices(double mop, double dp, double tp) {
2126 ankur.sing 737
        if(item.getMrp() != -1 && item.getMrp() < mop) {
2105 ankur.sing 738
            Window.alert("MOP cannot be more than MRP.");
739
            return false;
1992 ankur.sing 740
        }
2105 ankur.sing 741
        if(tp > mop) {
742
            Window.alert("Transfer Price cannot be more than MOP.");
743
            return false;
1992 ankur.sing 744
        }
2105 ankur.sing 745
        return true;
1992 ankur.sing 746
    }
2105 ankur.sing 747
 
748
    public long getItemId() {
749
        return item == null ? 0 : item.getId();
750
    }
751
 
752
    public Item getItem() {
753
        return item;
754
    }
755
 
2427 ankur.sing 756
    /**
757
     * This method is used while adding vendor prices to ensure that there is only one row in the table for a vendor.
758
     * @param vendorId
759
     * @return true if parameter vendor Id is already added to vendor prices table.
760
     *      <br>else false
761
     */
2105 ankur.sing 762
    private boolean vendorExists(long vendorId) {
763
        long id;
2427 ankur.sing 764
        for(int i = 0; i < tableVendorPrices.getRowCount(); i++) {
765
            id = Long.parseLong(tableVendorPrices.getText(i, TABLE_INDEX_PRICING_VENDORID));
2105 ankur.sing 766
            if(vendorId == id) {
767
                return false;
768
            }
1992 ankur.sing 769
        }
2105 ankur.sing 770
        return true;
1992 ankur.sing 771
    }
2387 ankur.sing 772
 
2427 ankur.sing 773
    /**
774
     * This method is used to check if any of the string item attributes is changed by the user.
775
     * @param s1
776
     * @param s2
777
     * @return true if two strings are equal
778
     *      <br>true if one of them is null and another is empty.
779
     *      <br>false otherwise
780
     */
2387 ankur.sing 781
    private boolean checkStringsIfEqual(String s1, String s2) {
782
        if(s1 == s2) {
783
            return true;
784
        }
785
        if(s1 != null && s2 != null && s1.equals(s2)) {
786
            return true;
787
        }
788
        if((s1 == null && s2.equals("")) || (s2 == null && s1.equals(""))) {
789
            return true;
790
        }
791
        return false;
792
    }
1961 ankur.sing 793
}