[Dive4elements-commits] [PATCH 3 of 7] Create a Collection if an artifact is added to the CollectionView
Wald Commits
scm-commit at wald.intevation.org
Tue Dec 11 16:27:38 CET 2012
# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1355239409 -3600
# Node ID 518d60dfe6bf2af06a50e3443381ff2a87140f85
# Parent bea519b46919a11662bd5157787b23f885992b96
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.
diff -r bea519b46919 -r 518d60dfe6bf flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Tue Dec 11 16:11:20 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Tue Dec 11 16:23:29 2012 +0100
@@ -624,22 +624,62 @@
final String locale = config.getLocale();
final Collection collection = getCollection();
- addArtifactService.add(
- collection, artifact, locale,
- new AsyncCallback<Collection>() {
- @Override
- public void onFailure(Throwable caught) {
- GWT.log("An error occured while adding artifact.");
- SC.warn(FLYS.getExceptionString(messages, caught));
+ GWT.log("CollectionView.addArtifactToCollection " + collection);
+
+ if (collection != null) {
+ addArtifactService.add(
+ collection, artifact, locale,
+ new AsyncCallback<Collection>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("An error occured while adding artifact.");
+ SC.warn(FLYS.getExceptionString(messages, caught));
+ }
+
+ @Override
+ public void onSuccess(Collection newCollection) {
+ GWT.log("Successfully added artifacts.");
+ setCollection(newCollection, true);
+ }
}
+ );
+ }
+ else {
+ // Create new collection and add artifact
+ final Artifact art = artifact;
+ createCollectionService.create(
+ locale,
+ flys.getCurrentUser().identifier(),
+ new AsyncCallback<Collection>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Could not create the new collection.");
+ SC.warn(FLYS.getExceptionString(messages, caught));
+ }
- @Override
- public void onSuccess(Collection newCollection) {
- GWT.log("Successfully added artifacts.");
- setCollection(newCollection, true);
+ @Override
+ public void onSuccess(Collection collection) {
+ GWT.log("Successfully created a new collection.");
+ addArtifactService.add(
+ collection, art, locale,
+ new AsyncCallback<Collection>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("An error occured while adding artifact.");
+ SC.warn(FLYS.getExceptionString(messages, caught));
+ }
+
+ @Override
+ public void onSuccess(Collection newCollection) {
+ GWT.log("Successfully added artifacts.");
+ setCollection(newCollection);
+ }
+ }
+ );
+ }
}
- }
- );
+ );
+ }
}
More information about the Dive4elements-commits
mailing list