| Line 66... |
Line 66... |
| 66 |
String greenLabel();
|
66 |
String greenLabel();
|
| 67 |
String fieldChanged();
|
67 |
String fieldChanged();
|
| 68 |
}
|
68 |
}
|
| 69 |
|
69 |
|
| 70 |
private Item item, newItem;
|
70 |
private Item item, newItem;
|
| - |
|
71 |
private CatalogDashboard catalogDashboardPanel;
|
| 71 |
|
72 |
|
| 72 |
@UiField ItemDetailStyle style;
|
73 |
@UiField ItemDetailStyle style;
|
| 73 |
@UiField Label itemId;
|
74 |
@UiField Label itemId;
|
| 74 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
75 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
| 75 |
@UiField Label contentCategory, catalogItemId;
|
76 |
@UiField Label contentCategory, catalogItemId;
|
| Line 117... |
Line 118... |
| 117 |
statusDesc.setText(item.getItemStatusDesc());
|
118 |
statusDesc.setText(item.getItemStatusDesc());
|
| 118 |
contentCategory.setText(item.getContentCategory()+"");
|
119 |
contentCategory.setText(item.getContentCategory()+"");
|
| 119 |
comments.setText(item.getComments());
|
120 |
comments.setText(item.getComments());
|
| 120 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
121 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
| 121 |
|
122 |
|
| 122 |
mrp.setText(item.getMrp() != -1 ? item.getMrp()+"" : "");
|
123 |
mrp.setText(item.getMrp() != null ? item.getMrp()+"" : "");
|
| 123 |
sellingPrice.setText(item.getSellingPrice() != -1 ? item.getSellingPrice()+"" : "");
|
124 |
sellingPrice.setText(item.getSellingPrice() != null ? item.getSellingPrice()+"" : "");
|
| 124 |
weight.setText(item.getWeight() != -1 ? item.getWeight()+"" : "");
|
125 |
weight.setText(item.getWeight() != null ? item.getWeight()+"" : "");
|
| 125 |
|
126 |
|
| 126 |
startDate.setValue(new Date(item.getStartDate()));
|
127 |
startDate.setValue(new Date(item.getStartDate()));
|
| 127 |
addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
|
128 |
addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
|
| 128 |
retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
|
129 |
retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
|
| 129 |
updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
|
130 |
updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
|
| 130 |
|
131 |
|
| 131 |
bestDealsText.setText(item.getBestDealsText());
|
132 |
bestDealsText.setText(item.getBestDealsText());
|
| 132 |
bestDealsValue.setText(item.getBestDealsValue() != -1 ? item.getBestDealsValue()+"" : "");
|
133 |
bestDealsValue.setText(item.getBestDealsValue() != null ? item.getBestDealsValue()+"" : "");
|
| 133 |
bestSellingRank.setText(item.getBestSellingRank() != -1 ? item.getBestSellingRank()+"" : "");
|
134 |
bestSellingRank.setText(item.getBestSellingRank() != null ? item.getBestSellingRank()+"" : "");
|
| 134 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
135 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 135 |
risky.setValue(item.isRisky());
|
136 |
risky.setValue(item.isRisky());
|
| 136 |
|
137 |
|
| 137 |
itemStatus.setText(item.getItemStatus());
|
138 |
itemStatus.setText(item.getItemStatus());
|
| 138 |
|
139 |
|
| Line 409... |
Line 410... |
| 409 |
@Override
|
410 |
@Override
|
| 410 |
public void onSuccess(Boolean result) {
|
411 |
public void onSuccess(Boolean result) {
|
| 411 |
if(result) {
|
412 |
if(result) {
|
| 412 |
item = newItem;
|
413 |
item = newItem;
|
| 413 |
GWT.log("Item updated. Id = " + item.getId());
|
414 |
GWT.log("Item updated. Id = " + item.getId());
|
| - |
|
415 |
catalogDashboardPanel.getItemListWidget().updateItem(item);
|
| - |
|
416 |
getFreshItemFromDB(item.getId());
|
| 414 |
Window.alert("Item updated successfully.");
|
417 |
Window.alert("Item updated successfully.");
|
| 415 |
}
|
418 |
}
|
| 416 |
else {
|
419 |
else {
|
| 417 |
GWT.log("Error updating item");
|
420 |
GWT.log("Error updating item");
|
| 418 |
Window.alert("Error updating item");
|
421 |
Window.alert("Error updating item");
|
| Line 424... |
Line 427... |
| 424 |
Window.alert("Error while updating item");
|
427 |
Window.alert("Error while updating item");
|
| 425 |
}
|
428 |
}
|
| 426 |
});
|
429 |
});
|
| 427 |
}
|
430 |
}
|
| 428 |
|
431 |
|
| - |
|
432 |
private void getFreshItemFromDB(long id) {
|
| - |
|
433 |
catalogService.getItem(id, new AsyncCallback<Item>() {
|
| - |
|
434 |
@Override
|
| - |
|
435 |
public void onSuccess(Item result) {
|
| - |
|
436 |
setItemDetails(result);
|
| - |
|
437 |
}
|
| - |
|
438 |
@Override
|
| - |
|
439 |
public void onFailure(Throwable caught) {
|
| - |
|
440 |
caught.printStackTrace();
|
| - |
|
441 |
Window.alert("Unable to fetch item details.");
|
| - |
|
442 |
}
|
| - |
|
443 |
});
|
| - |
|
444 |
}
|
| - |
|
445 |
|
| 429 |
/**
|
446 |
/**
|
| 430 |
* This method is called while updating item.<br> It will create a new Item object and set
|
447 |
* 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
|
448 |
* 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.
|
449 |
* 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.
|
450 |
* <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
|
451 |
* @return true if new Item object is created successfully
|
| 435 |
* <br>false if some error occurs due to NumberFormatException
|
452 |
* <br>false if some error occurs due to NumberFormatException
|
| 436 |
*/
|
453 |
*/
|
| 437 |
private boolean createNewItem() {
|
454 |
private boolean createNewItem() {
|
| 438 |
newItem = new Item();
|
455 |
newItem = new Item();
|
| 439 |
newItem.setId(Long.parseLong(itemId.getText()));
|
456 |
newItem.setId(item.getId());
|
| - |
|
457 |
newItem.setVendorCategory(item.getVendorCategory());
|
| 440 |
newItem.setProductGroup(productGroup.getText().trim());
|
458 |
newItem.setProductGroup(productGroup.getText().trim());
|
| 441 |
newItem.setBrand(brand.getText().trim());
|
459 |
newItem.setBrand(brand.getText().trim());
|
| 442 |
newItem.setModelNumber(modelNumber.getText().trim());
|
460 |
newItem.setModelNumber(modelNumber.getText().trim());
|
| 443 |
newItem.setModelName(modelName.getText().trim());
|
461 |
newItem.setModelName(modelName.getText().trim());
|
| 444 |
newItem.setColor(color.getText().trim());
|
462 |
newItem.setColor(color.getText().trim());
|
| Line 451... |
Line 469... |
| 451 |
double mrpValue = Double.parseDouble(mrp.getText().trim());
|
469 |
double mrpValue = Double.parseDouble(mrp.getText().trim());
|
| 452 |
if(mrpValue <= 0) {
|
470 |
if(mrpValue <= 0) {
|
| 453 |
throw new NumberFormatException("Negative value of MRP");
|
471 |
throw new NumberFormatException("Negative value of MRP");
|
| 454 |
}
|
472 |
}
|
| 455 |
newItem.setMrp(mrpValue);
|
473 |
newItem.setMrp(mrpValue);
|
| 456 |
} else {
|
- |
|
| 457 |
newItem.setMrp(-1);
|
- |
|
| 458 |
}
|
474 |
}
|
| 459 |
} catch(NumberFormatException ex) {
|
475 |
} catch(NumberFormatException ex) {
|
| 460 |
Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
|
476 |
Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
|
| 461 |
return false;
|
477 |
return false;
|
| 462 |
}
|
478 |
}
|
| Line 465... |
Line 481... |
| 465 |
double spValue = Double.parseDouble(sellingPrice.getText().trim());
|
481 |
double spValue = Double.parseDouble(sellingPrice.getText().trim());
|
| 466 |
if(spValue <= 0) {
|
482 |
if(spValue <= 0) {
|
| 467 |
throw new NumberFormatException("Negative value of Selling price");
|
483 |
throw new NumberFormatException("Negative value of Selling price");
|
| 468 |
}
|
484 |
}
|
| 469 |
newItem.setSellingPrice(spValue);
|
485 |
newItem.setSellingPrice(spValue);
|
| 470 |
} else {
|
- |
|
| 471 |
newItem.setSellingPrice(-1);
|
- |
|
| 472 |
}
|
486 |
}
|
| 473 |
} catch(NumberFormatException ex) {
|
487 |
} catch(NumberFormatException ex) {
|
| 474 |
Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
|
488 |
Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
|
| 475 |
return false;
|
489 |
return false;
|
| 476 |
}
|
490 |
}
|
| Line 479... |
Line 493... |
| 479 |
double wtValue = Double.parseDouble(weight.getText().trim());
|
493 |
double wtValue = Double.parseDouble(weight.getText().trim());
|
| 480 |
if(wtValue <= 0) {
|
494 |
if(wtValue <= 0) {
|
| 481 |
throw new NumberFormatException("Negative value of Weight");
|
495 |
throw new NumberFormatException("Negative value of Weight");
|
| 482 |
}
|
496 |
}
|
| 483 |
newItem.setWeight(wtValue);
|
497 |
newItem.setWeight(wtValue);
|
| 484 |
} else {
|
- |
|
| 485 |
newItem.setWeight(-1);
|
- |
|
| 486 |
}
|
498 |
}
|
| 487 |
} catch(NumberFormatException ex) {
|
499 |
} catch(NumberFormatException ex) {
|
| 488 |
Window.alert("Invalid weight format/value. Value shoule be greater than zero");
|
500 |
Window.alert("Invalid weight format/value. Value shoule be greater than zero");
|
| 489 |
return false;
|
501 |
return false;
|
| 490 |
}
|
502 |
}
|
| Line 502... |
Line 514... |
| 502 |
double bdValue = Double.parseDouble(bestDealsValue.getText().trim());
|
514 |
double bdValue = Double.parseDouble(bestDealsValue.getText().trim());
|
| 503 |
if(bdValue < 0) {
|
515 |
if(bdValue < 0) {
|
| 504 |
throw new NumberFormatException("Negative value of BestDealValue");
|
516 |
throw new NumberFormatException("Negative value of BestDealValue");
|
| 505 |
}
|
517 |
}
|
| 506 |
newItem.setBestDealsValue(bdValue);
|
518 |
newItem.setBestDealsValue(bdValue);
|
| 507 |
} else {
|
- |
|
| 508 |
newItem.setBestDealsValue(-1);
|
- |
|
| 509 |
}
|
519 |
}
|
| 510 |
} catch(NumberFormatException ex) {
|
520 |
} catch(NumberFormatException ex) {
|
| 511 |
Window.alert("Invalid best deal value format");
|
521 |
Window.alert("Invalid best deal value format");
|
| 512 |
return false;
|
522 |
return false;
|
| 513 |
}
|
523 |
}
|
| Line 516... |
Line 526... |
| 516 |
long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
|
526 |
long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
|
| 517 |
if(bsrValue < 0) {
|
527 |
if(bsrValue < 0) {
|
| 518 |
throw new NumberFormatException("Negative value of Best Selling Rank");
|
528 |
throw new NumberFormatException("Negative value of Best Selling Rank");
|
| 519 |
}
|
529 |
}
|
| 520 |
newItem.setBestSellingRank(bsrValue);
|
530 |
newItem.setBestSellingRank(bsrValue);
|
| 521 |
} else {
|
- |
|
| 522 |
newItem.setBestSellingRank(-1);
|
- |
|
| 523 |
}
|
531 |
}
|
| 524 |
|
- |
|
| 525 |
} catch(NumberFormatException ex) {
|
532 |
} catch(NumberFormatException ex) {
|
| 526 |
Window.alert("Invalid best selling rank format");
|
533 |
Window.alert("Invalid best selling rank format");
|
| 527 |
return false;
|
534 |
return false;
|
| 528 |
}
|
535 |
}
|
| 529 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
536 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
| Line 630... |
Line 637... |
| 630 |
* @return String showing attributes which are changed by the user for confirmation.
|
637 |
* @return String showing attributes which are changed by the user for confirmation.
|
| 631 |
* <br>Empty string if nothing is changed.
|
638 |
* <br>Empty string if nothing is changed.
|
| 632 |
*/
|
639 |
*/
|
| 633 |
private String isItemChanged() {
|
640 |
private String isItemChanged() {
|
| 634 |
StringBuilder sb = new StringBuilder("");
|
641 |
StringBuilder sb = new StringBuilder("");
|
| 635 |
if(!checkStringsIfEqual(productGroup.getText().trim(), item.getProductGroup())) {
|
642 |
if(!checkParameterIfEqual(productGroup.getText().trim(), item.getProductGroup())) {
|
| 636 |
sb.append("\n-Product Group");
|
643 |
sb.append("\n-Product Group");
|
| 637 |
}
|
644 |
}
|
| 638 |
if(!checkStringsIfEqual(brand.getText().trim(), item.getBrand())) {
|
645 |
if(!checkParameterIfEqual(brand.getText().trim(), item.getBrand())) {
|
| 639 |
sb.append("\n-Brand");
|
646 |
sb.append("\n-Brand");
|
| 640 |
}
|
647 |
}
|
| 641 |
if(!checkStringsIfEqual(modelNumber.getText().trim(), item.getModelNumber())) {
|
648 |
if(!checkParameterIfEqual(modelNumber.getText().trim(), item.getModelNumber())) {
|
| 642 |
sb.append("\n-Model Number");
|
649 |
sb.append("\n-Model Number");
|
| 643 |
}
|
650 |
}
|
| 644 |
if(!checkStringsIfEqual(modelName.getText().trim(), item.getModelName())) {
|
651 |
if(!checkParameterIfEqual(modelName.getText().trim(), item.getModelName())) {
|
| 645 |
sb.append("\n-Model Name");
|
652 |
sb.append("\n-Model Name");
|
| 646 |
}
|
653 |
}
|
| 647 |
if(!checkStringsIfEqual(color.getText().trim(), item.getColor())) {
|
654 |
if(!checkParameterIfEqual(color.getText().trim(), item.getColor())) {
|
| 648 |
sb.append("\n-Color");
|
655 |
sb.append("\n-Color");
|
| 649 |
}
|
656 |
}
|
| 650 |
if(!checkStringsIfEqual(statusDesc.getText().trim(), item.getItemStatusDesc())) {
|
657 |
if(!checkParameterIfEqual(statusDesc.getText().trim(), item.getItemStatusDesc())) {
|
| 651 |
sb.append("\n-Status Description");
|
658 |
sb.append("\n-Status Description");
|
| 652 |
}
|
659 |
}
|
| 653 |
if(!checkStringsIfEqual(comments.getText().trim(), item.getComments())) {
|
660 |
if(!checkParameterIfEqual(comments.getText().trim(), item.getComments())) {
|
| 654 |
sb.append("\n-Comments");
|
661 |
sb.append("\n-Comments");
|
| 655 |
}
|
662 |
}
|
| 656 |
if(newItem.getMrp() != item.getMrp()) {
|
663 |
if(!checkParameterIfEqual(newItem.getMrp(), item.getMrp())) {
|
| 657 |
sb.append("\n-MRP");
|
664 |
sb.append("\n-MRP");
|
| 658 |
}
|
665 |
}
|
| 659 |
if(newItem.getSellingPrice() != item.getSellingPrice()) {
|
666 |
if(!checkParameterIfEqual(newItem.getSellingPrice(), item.getSellingPrice())) {
|
| 660 |
sb.append("\n-Selling Price");
|
667 |
sb.append("\n-Selling Price");
|
| 661 |
}
|
668 |
}
|
| 662 |
if(newItem.getWeight() != item.getWeight()) {
|
669 |
if(!checkParameterIfEqual(newItem.getWeight(), item.getWeight())) {
|
| 663 |
sb.append("\n-Weight");
|
670 |
sb.append("\n-Weight");
|
| 664 |
}
|
671 |
}
|
| 665 |
if(!checkStringsIfEqual(bestDealsText.getText().trim(), item.getBestDealsText())) {
|
672 |
if(!checkParameterIfEqual(bestDealsText.getText().trim(), item.getBestDealsText())) {
|
| 666 |
sb.append("\n-Best Deal Text");
|
673 |
sb.append("\n-Best Deal Text");
|
| 667 |
}
|
674 |
}
|
| 668 |
if(newItem.getBestDealsValue() != item.getBestDealsValue()) {
|
675 |
if(!checkParameterIfEqual(newItem.getBestDealsValue(), item.getBestDealsValue())) {
|
| 669 |
sb.append("\n-Best Deal Value");
|
676 |
sb.append("\n-Best Deal Value");
|
| 670 |
}
|
677 |
}
|
| 671 |
if(newItem.getBestSellingRank() != item.getBestSellingRank()) {
|
678 |
if(!checkParameterIfEqual(newItem.getBestSellingRank(), item.getBestSellingRank())) {
|
| 672 |
sb.append("\n-Best Selling Rank");
|
679 |
sb.append("\n-Best Selling Rank");
|
| 673 |
}
|
680 |
}
|
| 674 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
681 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
| 675 |
sb.append("\n-Default For Entity Flag");
|
682 |
sb.append("\n-Default For Entity Flag");
|
| 676 |
}
|
683 |
}
|
| 677 |
if(item.isRisky() != risky.getValue()) {
|
684 |
if(item.isRisky() != risky.getValue()) {
|
| 678 |
sb.append("\n-Risky Flag");
|
685 |
sb.append("\n-Risky Flag");
|
| 679 |
}
|
686 |
}
|
| 680 |
if(newItem.getStartDate() != item.getStartDate()) {
|
687 |
if(!checkParameterIfEqual(newItem.getStartDate(), item.getStartDate())) {
|
| 681 |
sb.append("\n-Start Date");
|
688 |
sb.append("\n-Start Date");
|
| 682 |
}
|
689 |
}
|
| 683 |
VendorPricings vendorPricings;
|
690 |
VendorPricings vendorPricings;
|
| 684 |
long vendorId;
|
691 |
long vendorId;
|
| 685 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
692 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
| Line 732... |
Line 739... |
| 732 |
}
|
739 |
}
|
| 733 |
return true;
|
740 |
return true;
|
| 734 |
}
|
741 |
}
|
| 735 |
|
742 |
|
| 736 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
743 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
| 737 |
if(item.getMrp() != -1 && item.getMrp() < mop) {
|
744 |
if(item.getMrp() != null && item.getMrp() < mop) {
|
| 738 |
Window.alert("MOP cannot be more than MRP.");
|
745 |
Window.alert("MOP cannot be more than MRP.");
|
| 739 |
return false;
|
746 |
return false;
|
| 740 |
}
|
747 |
}
|
| 741 |
if(tp > mop) {
|
748 |
if(tp > mop) {
|
| 742 |
Window.alert("Transfer Price cannot be more than MOP.");
|
749 |
Window.alert("Transfer Price cannot be more than MOP.");
|
| Line 770... |
Line 777... |
| 770 |
return true;
|
777 |
return true;
|
| 771 |
}
|
778 |
}
|
| 772 |
|
779 |
|
| 773 |
/**
|
780 |
/**
|
| 774 |
* This method is used to check if any of the string item attributes is changed by the user.
|
781 |
* This method is used to check if any of the string item attributes is changed by the user.
|
| 775 |
* @param s1
|
782 |
* @param o1
|
| 776 |
* @param s2
|
783 |
* @param o2
|
| 777 |
* @return true if two strings are equal
|
784 |
* @return true if two strings are equal
|
| 778 |
* <br>true if one of them is null and another is empty.
|
785 |
* <br>true if one of them is null and another is empty.
|
| 779 |
* <br>false otherwise
|
786 |
* <br>false otherwise
|
| 780 |
*/
|
787 |
*/
|
| 781 |
private boolean checkStringsIfEqual(String s1, String s2) {
|
788 |
private boolean checkParameterIfEqual(Object o1, Object o2) {
|
| 782 |
if(s1 == s2) {
|
789 |
if(o1 == o2) {
|
| 783 |
return true;
|
790 |
return true;
|
| 784 |
}
|
791 |
}
|
| 785 |
if(s1 != null && s2 != null && s1.equals(s2)) {
|
792 |
if(o1 != null && o2 != null && o1.equals(o2)) {
|
| 786 |
return true;
|
793 |
return true;
|
| 787 |
}
|
794 |
}
|
| 788 |
if((s1 == null && s2.equals("")) || (s2 == null && s1.equals(""))) {
|
795 |
if((o1 == null && o2.equals("")) || (o2 == null && o1.equals(""))) {
|
| 789 |
return true;
|
796 |
return true;
|
| 790 |
}
|
797 |
}
|
| 791 |
return false;
|
798 |
return false;
|
| 792 |
}
|
799 |
}
|
| - |
|
800 |
|
| - |
|
801 |
public void setCatalogDashboardPanel(CatalogDashboard catalogDashboardPanel) {
|
| - |
|
802 |
this.catalogDashboardPanel = catalogDashboardPanel;
|
| - |
|
803 |
}
|
| 793 |
}
|
804 |
}
|