incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r925476 - in /incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace: client/Main.java client/services/AssociationService.java client/services/AssociationServiceAsync.java server/AssociationServiceImpl.java
Date Fri, 19 Mar 2010 23:15:31 GMT
Author: marrs
Date: Fri Mar 19 23:15:31 2010
New Revision: 925476

URL: http://svn.apache.org/viewvc?rev=925476&view=rev
Log:
Applied r900143.

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

Modified: incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/Main.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/Main.java?rev=925476&r1=925475&r2=925476&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/Main.java (original)
+++ incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/Main.java Fri Mar 19
23:15:31 2010
@@ -18,6 +18,9 @@
  */
 package org.apache.ace.client;
 
+import static org.apache.ace.client.services.AssociationService.AssociationType.DYNAMIC;
+import static org.apache.ace.client.services.AssociationService.AssociationType.STATIC;
+
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -30,6 +33,7 @@ import org.apache.ace.client.services.De
 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.AssociationType;
 
 import com.allen_sauer.gwt.dnd.client.PickupDragController;
 import com.google.gwt.core.client.EntryPoint;
@@ -45,6 +49,7 @@ import com.google.gwt.user.client.ui.Fle
 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 +132,55 @@ public class Main implements EntryPoint 
             }
         });
         
+        final ToggleButton associationTypeButton = new ToggleButton("STATIC");
+        m_assocationService.getAssociationType(new AsyncCallback<AssociationType>()
{
+        	public void onSuccess(AssociationType 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.getAssociationType(new AsyncCallback<AssociationType>()
{
+		        	public void onSuccess(AssociationType result) {
+		        		switch (result) {
+		        			case STATIC:
+		        				m_assocationService.setAssociationType(DYNAMIC, null);
+		        				associationTypeButton.setText("DYNAMIC");
+		        				break;
+		        			case DYNAMIC:
+		        				m_assocationService.setAssociationType(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 +204,8 @@ public class Main implements EntryPoint 
         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/ace-webui/src/main/java/org/apache/ace/client/services/AssociationService.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationService.java?rev=925476&r1=925475&r2=925476&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationService.java
(original)
+++ incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationService.java
Fri Mar 19 23:15:31 2010
@@ -26,6 +26,10 @@ import com.google.gwt.user.client.rpc.Re
  */
 @RemoteServiceRelativePath("associations")
 public interface AssociationService extends RemoteService {
+	public static enum AssociationType {
+		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 +56,20 @@ public interface AssociationService exte
      * 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 features. 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 setAssociationType(AssociationType type);
+    
+    /**
+     * Returns the association type that is used when creating an association
+     * between an artifact and a feature.
+     */
+    AssociationType getAssociationType();
 }

Modified: incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationServiceAsync.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationServiceAsync.java?rev=925476&r1=925475&r2=925476&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationServiceAsync.java
(original)
+++ incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/client/services/AssociationServiceAsync.java
Fri Mar 19 23:15:31 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.ace.client.services;
 
+import org.apache.ace.client.services.AssociationService.AssociationType;
+
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
 /**
@@ -29,4 +31,6 @@ public interface AssociationServiceAsync
     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 setAssociationType(AssociationType type, AsyncCallback<Void> callback);
+    AssociationType getAssociationType(AsyncCallback<AssociationType> callback);
 }

Modified: incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/server/AssociationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/server/AssociationServiceImpl.java?rev=925476&r1=925475&r2=925476&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/server/AssociationServiceImpl.java
(original)
+++ incubator/ace/trunk/ace-webui/src/main/java/org/apache/ace/server/AssociationServiceImpl.java
Fri Mar 19 23:15:31 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;
@@ -52,6 +55,7 @@ public class AssociationServiceImpl exte
      * Generated serialVersionUID
      */
     private static final long serialVersionUID = 2413722456179463935L;
+    private AssociationType m_associationType = AssociationType.DYNAMIC;
 
     public void link(BundleDescriptor bundle, GroupDescriptor group) throws Exception {
         HttpServletRequest request = getThreadLocalRequest();
@@ -60,7 +64,16 @@ public class AssociationServiceImpl exte
         ArtifactObject a = (ArtifactObject) ObjectMapping.unwrap(request, bundle);
         GroupObject g = (GroupObject) ObjectMapping.unwrap(request, group);
         
-        a2gr.create(a, g);
+        switch (m_associationType) {
+	        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
{
@@ -151,6 +164,14 @@ public class AssociationServiceImpl exte
             throw e;
         }
     }
+    
+    public void setAssociationType(AssociationType type) {
+    	m_associationType = type;
+    }
+    
+    public AssociationType getAssociationType() {
+    	return m_associationType;
+    }
 
     /**
      * Helper method that finds all related {@link RepositoryObject}s for a given one.



Mime
View raw message