Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 4659:518d60dfe6bf
Create a Collection if an artifact is added to the CollectionView
If an artifact will be added to a Collection create the collection on demand if
it doesn't exist yet.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 11 Dec 2012 16:23:29 +0100 |
parents | bea519b46919 |
children | bb9ce9aece70 |
comparison
equal
deleted
inserted
replaced
4658:bea519b46919 | 4659:518d60dfe6bf |
---|---|
622 public void addArtifactToCollection(Artifact artifact) { | 622 public void addArtifactToCollection(Artifact artifact) { |
623 Config config = Config.getInstance(); | 623 Config config = Config.getInstance(); |
624 final String locale = config.getLocale(); | 624 final String locale = config.getLocale(); |
625 final Collection collection = getCollection(); | 625 final Collection collection = getCollection(); |
626 | 626 |
627 addArtifactService.add( | 627 GWT.log("CollectionView.addArtifactToCollection " + collection); |
628 collection, artifact, locale, | 628 |
629 new AsyncCallback<Collection>() { | 629 if (collection != null) { |
630 @Override | 630 addArtifactService.add( |
631 public void onFailure(Throwable caught) { | 631 collection, artifact, locale, |
632 GWT.log("An error occured while adding artifact."); | 632 new AsyncCallback<Collection>() { |
633 SC.warn(FLYS.getExceptionString(messages, caught)); | 633 @Override |
634 public void onFailure(Throwable caught) { | |
635 GWT.log("An error occured while adding artifact."); | |
636 SC.warn(FLYS.getExceptionString(messages, caught)); | |
637 } | |
638 | |
639 @Override | |
640 public void onSuccess(Collection newCollection) { | |
641 GWT.log("Successfully added artifacts."); | |
642 setCollection(newCollection, true); | |
643 } | |
634 } | 644 } |
635 | 645 ); |
636 @Override | 646 } |
637 public void onSuccess(Collection newCollection) { | 647 else { |
638 GWT.log("Successfully added artifacts."); | 648 // Create new collection and add artifact |
639 setCollection(newCollection, true); | 649 final Artifact art = artifact; |
650 createCollectionService.create( | |
651 locale, | |
652 flys.getCurrentUser().identifier(), | |
653 new AsyncCallback<Collection>() { | |
654 @Override | |
655 public void onFailure(Throwable caught) { | |
656 GWT.log("Could not create the new collection."); | |
657 SC.warn(FLYS.getExceptionString(messages, caught)); | |
658 } | |
659 | |
660 @Override | |
661 public void onSuccess(Collection collection) { | |
662 GWT.log("Successfully created a new collection."); | |
663 addArtifactService.add( | |
664 collection, art, locale, | |
665 new AsyncCallback<Collection>() { | |
666 @Override | |
667 public void onFailure(Throwable caught) { | |
668 GWT.log("An error occured while adding artifact."); | |
669 SC.warn(FLYS.getExceptionString(messages, caught)); | |
670 } | |
671 | |
672 @Override | |
673 public void onSuccess(Collection newCollection) { | |
674 GWT.log("Successfully added artifacts."); | |
675 setCollection(newCollection); | |
676 } | |
677 } | |
678 ); | |
679 } | |
640 } | 680 } |
641 } | 681 ); |
642 ); | 682 } |
643 } | 683 } |
644 | 684 |
645 | 685 |
646 protected void addRecommendationsToCollection() { | 686 protected void addRecommendationsToCollection() { |
647 Config config = Config.getInstance(); | 687 Config config = Config.getInstance(); |