ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r900143 - in /incubator/ace/trunk/webui/src/org/apache/ace: client/Main.java client/services/AssociationService.java client/services/AssociationServiceAsync.java server/AssociationServiceImpl.java
Date Sun, 17 Jan 2010 13:52:27 GMT
Author: marrs
Date: Sun Jan 17 13:52:27 2010
New Revision: 900143

URL: http://svn.apache.org/viewvc?rev=900143&view=rev
Log:
Exposed the option to create either static or dynamic associations between bundles and groups.
Dynamic associations automatically keep pointing to the newest version of a bundle, whereas
static associations keep pointing to the version of the bundle you associated the group to.
Dynamic associations make it easier to update bundles, as the only thing you need to do is
to simply add the new version of the bundle and all associations will find it. The option
applies to associations you create, so once an association has been created, it won't change.
The button can be found in the top right corner, and it's a non-persistent toggle button,
meaning you loose its setting when you end your session (because we're not yet logging in,
we have no means of storing user-specific settings anyway).

Modified:
    incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationService.java
    incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationServiceAsync.java
    incubator/ace/trunk/webui/src/org/apache/ace/server/AssociationServiceImpl.java

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java?rev=900143&r1=900142&r2=900143&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java Sun Jan 17 13:52:27 2010
@@ -30,6 +30,7 @@
 import org.apache.ace.client.services.TargetDescriptor;
 import org.apache.ace.client.services.TargetService;
 import org.apache.ace.client.services.TargetServiceAsync;
+import org.apache.ace.client.services.AssociationService.AssocationType;
 
 import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.EntryPoint;
@@ -45,6 +46,7 @@
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.ScrollPanel;
+import com.google.gwt.user.client.ui.ToggleButton;
 import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
 
 /**
@@ -127,18 +129,53 @@
             }
         });
         
+        final ToggleButton associationTypeButton = new ToggleButton("STATIC");
+        m_assocationService.getAssocationType(new AsyncCallback<AssocationType>() {
+            public void onSuccess(AssocationType result) {
+                switch (result) {
+                case STATIC:
+                    associationTypeButton.setDown(false);
+                    associationTypeButton.setText("STATIC");
+                    break;
+                case DYNAMIC:
+                    associationTypeButton.setDown(true);
+                    associationTypeButton.setText("DYNAMIC");
+                    break;
+                }
+            };
+            public void onFailure(Throwable caught) {
+            }
+        });
+        associationTypeButton.addStyleDependentName("add");
+        associationTypeButton.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent event) {
+                m_assocationService.getAssocationType(new AsyncCallback<AssocationType>()
{
+                    public void onSuccess(AssocationType result) {
+                        switch (result) {
+                            case STATIC:
+                                m_assocationService.setAssocationType(AssocationType.DYNAMIC,
null);
+                                associationTypeButton.setText("DYNAMIC");
+                                break;
+                            case DYNAMIC:
+                                m_assocationService.setAssocationType(AssocationType.STATIC,
null);
+                                associationTypeButton.setText("STATIC");
+                                break;
+                        }
+                    };
+                    public void onFailure(Throwable caught) {
+                    }
+                });
+            }
+        });
+        
         // Create some scrollpanels with our tables
         ScrollPanel bundleScrollPanel = new ScrollPanel(m_bundleTable);
-//        bundleScrollPanel.setHeight("30em");
         bundleScrollPanel.setStyleName("objectTable");
         ScrollPanel groupScrollPanel = new ScrollPanel(m_groupTable);
-//        groupScrollPanel.setHeight("30em");
         groupScrollPanel.setStyleName("objectTable");
         ScrollPanel licenseScrollPanel = new ScrollPanel(m_licenseTable);
-//        licenseScrollPanel.setHeight("30em");
         licenseScrollPanel.setStyleName("objectTable");
         ScrollPanel targetScrollPanel = new ScrollPanel(m_targetTable);
-//        targetScrollPanel.setHeight("30em");
         targetScrollPanel.setStyleName("objectTable");
         
         FlexTable rootPanel = new FlexTable();
@@ -162,7 +199,8 @@
         formatter.setWidth(1, 3, "25%");
         rootPanel.setWidget(3, 3, targetScrollPanel);
         rootPanel.setWidget(0, 0, new CheckoutPanel(this));
-        formatter.setColSpan(0, 0, 4);
+        formatter.setColSpan(0, 0, 3);
+        rootPanel.setWidget(0, 1, associationTypeButton);
         rootPanel.setWidget(4, 0, m_statusLabel);
         formatter.setColSpan(4, 0, 4);
         RootPanel.get("body").add(rootPanel);

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationService.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationService.java?rev=900143&r1=900142&r2=900143&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationService.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationService.java Sun
Jan 17 13:52:27 2010
@@ -26,6 +26,9 @@
  */
 @RemoteServiceRelativePath("associations")
 public interface AssociationService extends RemoteService {
+    public static enum AssocationType {
+        STATIC, DYNAMIC
+    }
     /**
      * Links a bundle and a group; note that this will create a link to a given bundle,
      * not to its symbolic name.
@@ -52,4 +55,20 @@
      * Gets all the descriptors that are in some way related to the given one.
      */
     Descriptor[] getRelated(Descriptor o) throws Exception;
+    
+    /**
+     * Sets the association type between artifacts and groups. There are two types:
+     * static and dynamic. The former means that when you create an association, it
+     * is linked to that specific version of an artifact. The latter means it is
+     * always linked to the latest version of an artifact. This setting affects the
+     * creation of associations. Once an association is created, you cannot change its
+     * type anymore.
+     */
+    void setAssocationType(AssocationType type);
+    
+    /**
+     * Returns the association type that is used when creating an association between
+     * an artifact and a group.
+     */
+    AssocationType getAssocationType();
 }

Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationServiceAsync.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationServiceAsync.java?rev=900143&r1=900142&r2=900143&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationServiceAsync.java
(original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/AssociationServiceAsync.java
Sun Jan 17 13:52:27 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.ace.client.services;
 
+import org.apache.ace.client.services.AssociationService.AssocationType;
+
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
 /**
@@ -29,4 +31,6 @@
     void link(LicenseDescriptor license, TargetDescriptor target, AsyncCallback<Void>
callback);
     void unlink(Descriptor license, Descriptor target, AsyncCallback<Void> callback);
     void getRelated(Descriptor o, AsyncCallback<Descriptor[]> callback);
+    void setAssocationType(AssocationType type, AsyncCallback<Void> callback);
+    void getAssocationType(AsyncCallback<AssocationType> callback);
 }

Modified: incubator/ace/trunk/webui/src/org/apache/ace/server/AssociationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/server/AssociationServiceImpl.java?rev=900143&r1=900142&r2=900143&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/server/AssociationServiceImpl.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/server/AssociationServiceImpl.java Sun Jan
17 13:52:27 2010
@@ -19,12 +19,15 @@
 package org.apache.ace.server;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.ace.client.repository.RepositoryAdmin;
 import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.helper.bundle.BundleHelper;
 import org.apache.ace.client.repository.object.ArtifactObject;
 import org.apache.ace.client.repository.object.GatewayObject;
 import org.apache.ace.client.repository.object.GroupObject;
@@ -48,19 +51,37 @@
  * each of the descriptor objects.
  */
 public class AssociationServiceImpl extends RemoteServiceServlet implements AssociationService
{
+    
     /**
      * Generated serialVersionUID
      */
     private static final long serialVersionUID = 2413722456179463935L;
+    private AssocationType m_assocationType = AssocationType.DYNAMIC;
 
+    public void setAssocationType(AssocationType type) {
+        m_assocationType  = type;
+    }
+    public AssocationType getAssocationType() {
+        return m_assocationType;
+    }
+    
     public void link(BundleDescriptor bundle, GroupDescriptor group) throws Exception {
         HttpServletRequest request = getThreadLocalRequest();
         Artifact2GroupAssociationRepository a2gr = Activator.getService(request, Artifact2GroupAssociationRepository.class);
         
         ArtifactObject a = (ArtifactObject) ObjectMapping.unwrap(request, bundle);
         GroupObject g = (GroupObject) ObjectMapping.unwrap(request, group);
-        
-        a2gr.create(a, g);
+
+        switch (m_assocationType) {
+            case STATIC:
+                a2gr.create(a, g);
+                break;
+            case DYNAMIC:
+                Map<String, String> properties = new HashMap<String, String>();
+                properties.put(BundleHelper.KEY_ASSOCIATION_VERSIONSTATEMENT, "0.0.0");
+                a2gr.create(a, properties, g, null);
+                break;
+        }
     }
 
     private void unlink(BundleDescriptor bundle, GroupDescriptor group) throws Exception
{
@@ -210,4 +231,5 @@
         }
         return result;
     }
+    
 }



Mime
View raw message