tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1173966 - in /tuscany/sca-java-2.x/trunk/modules/composite-diagram: pom.xml src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
Date Thu, 22 Sep 2011 06:48:25 GMT
Author: rfeng
Date: Thu Sep 22 06:48:25 2011
New Revision: 1173966

URL: http://svn.apache.org/viewvc?rev=1173966&view=rev
Log:
Add impl info for the node/remove unused code

Modified:
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/pom.xml
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/pom.xml?rev=1173966&r1=1173965&r2=1173966&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/pom.xml Thu Sep 22 06:48:25 2011
@@ -100,6 +100,12 @@
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-implementation-java-runtime</artifactId>
             <version>2.0-SNAPSHOT</version>
             <scope>runtime</scope>

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java?rev=1173966&r1=1173965&r2=1173966&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
Thu Sep 22 06:48:25 2011
@@ -19,9 +19,6 @@
 
 package org.apache.tuscany.sca.diagram.layout;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-
 import org.apache.tuscany.sca.diagram.artifacts.Constant;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -31,12 +28,10 @@ public class EntityBuilder {
 
     private Document dom;
 
-    //components connected to each other are tracked using following map
-    private HashMap<String, ArrayList<String>> connectedEntities = new HashMap<String,
ArrayList<String>>();
     private int totalWidth = 0;
     private int totalHeight = 0;
 
-    CompositeEntity composite = null;
+    private CompositeEntity composite = null;
 
     /**
      * Constructor which initiates the DOM document
@@ -430,46 +425,18 @@ public class EntityBuilder {
 
             ent.addToRefToSerMap(reference, serviceComp + "/" + service);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         } else if (reference == null && service != null) {
             ent.addToRefToSerMap(referenceComp, serviceComp + "/" + service);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         } else if (reference != null && service == null) {
             ent.addToRefToSerMap(reference, serviceComp);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         } else {
             ent.addToRefToSerMap(referenceComp, serviceComp);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         }
     }
 
-    //	private void calculateProperties(ComponentEntity[] elts) {
-    //		int level=0, lane=0;
-    //
-    //		for(ComponentEntity ent: elts){
-    //			level = max(level, ent.getLevel());
-    //			lane = max(lane, ent.getLane());
-    //
-    //		}
-    //		totalHeight += spaceY*(level+1) + initPoint;
-    //		totalWidth += spaceX*(lane+1) + initPoint;
-    //		
-    //		System.err.println(totalHeight + " :: "+totalWidth);
-    //	}
-
-    //	private int max(int a, int b){
-    //		if(a>=b)
-    //			return a;
-    //		return b;
-    //	}
-
     @SuppressWarnings("unused")
     private void print(ComponentEntity[] elts) {
 
@@ -485,106 +452,6 @@ public class EntityBuilder {
         }
     }
 
-    //	private void positionEntities(ComponentEntity[] ents){
-    //		
-    //		for(ComponentEntity ent: ents){
-    //			if(ent.getAdjacentEntities().size() != 0 || ents.length==1){
-    //				setPosition(ent, initPoint, initPoint, 0, 0);
-    //				levelCount.add(0, 1);
-    //				startEnt = ent;
-    //				System.err.println(ent.getName());
-    //				break;
-    //			}
-    //		}
-    //		
-    //
-    //		if(startEnt != null)
-    //			assignPositions(ents, startEnt);
-    //
-    //	}
-    //
-    //	private void assignPositions(ComponentEntity[] ents, ComponentEntity ent){
-    //		int i=0;
-    //		if(ent.getAdjacentEntities().size()>0){
-    //			
-    //			System.out.println(ent.getName());
-    //			for(String name: ent.getAdjacentEntities()){
-    //				//System.out.println("eee "+name);
-    //				for(ComponentEntity aEnt: ents){
-    //					i++;
-    //					if(name.equalsIgnoreCase(aEnt.getName())){
-    //						int lane = ent.getLane()+1;
-    //						if(levelCount.size()<= lane){
-    //							levelCount.add(lane, 1);
-    //							setPosition(aEnt, ent.getX()+spaceX, ent.getY(), 0, lane);
-    //						}
-    //						else{
-    //							int level = levelCount.get(lane);
-    //							levelCount.add(lane, level+1);
-    //							setPosition(aEnt, ent.getX()+spaceX, ent.getY()+spaceY*level, level, lane);
-    //						}
-    //						if(i<ents.length)
-    //							assignPositions(ents, aEnt);
-    ////						else
-    ////							System.out.println(i+ " <<<<< "+ents.length);
-    //						break;
-    //					}
-    //
-    //				}
-    //			}
-    //		}
-    //
-    //
-    //		else{
-    //			ArrayList<String> conns = connectedEntities.get(ent.getName());
-    //			System.err.println(conns.size());
-    //			if(conns.size()>0){
-    //
-    //				for(String conn: conns){
-    //					System.err.println("conn "+conn +" : "+ent.getName());
-    //					for(ComponentEntity e: ents){
-    //						if(e.getLane() == -1 && e.getName().equals(conn)){
-    //
-    //							int lane = ent.getLane()-1;
-    //							System.err.println(lane);
-    //							int level = levelCount.get(lane);
-    //							levelCount.add(lane, level+1);
-    //							setPosition(e, ent.getX()-spaceX, ent.getY()+spaceY*level, level, lane);
-    //
-    //							break;
-    //						}
-    //					}
-    //				}
-    //			}
-    //		}
-    //	}
-    //
-    //	private void setPosition(ComponentEntity ent, int x, int y, int level, int lane){
-    //		ent.setX(x);
-    //		ent.setY(y);
-    //		ent.setLevel(level);
-    //		ent.setLane(lane);
-    //	}
-    //
-    //
-    //	private String[] splitValues(String str){
-    //		return str.split("/");
-    //	}
-
-    private void addToConnectedEntities(String ent1, String ent2) {
-        //System.err.println(ent1+" : "+ent2);
-        ArrayList<String> list;
-        if (connectedEntities.containsKey(ent1)) {
-            list = connectedEntities.get(ent1);
-
-        } else {
-            list = new ArrayList<String>();
-
-        }
-        list.add(ent2);
-        connectedEntities.put(ent1, list);
-    }
-
     private void setServices(Element nVal, ComponentEntity ent) {
 
         NodeList nl = nVal.getElementsByTagName("service");

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java?rev=1173966&r1=1173965&r2=1173966&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
Thu Sep 22 06:48:25 2011
@@ -19,10 +19,10 @@
 
 package org.apache.tuscany.sca.diagram.layout;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.sca.assembly.Component;
 import org.apache.tuscany.sca.assembly.ComponentProperty;
 import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -32,18 +32,19 @@ import org.apache.tuscany.sca.assembly.C
 import org.apache.tuscany.sca.assembly.CompositeService;
 import org.apache.tuscany.sca.assembly.Endpoint;
 import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
 import org.apache.tuscany.sca.assembly.Property;
 import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.Service;
 import org.apache.tuscany.sca.assembly.Wire;
 import org.apache.tuscany.sca.diagram.artifacts.Artifact;
 import org.apache.tuscany.sca.diagram.artifacts.Constant;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
 
 public class TuscanyCompositeEntityBuilder {
 
     private Composite tuscanyComp;
-    //components connected to each other are tracked using following map
-    private HashMap<String, ArrayList<String>> connectedEntities = new HashMap<String,
ArrayList<String>>();
+
     private int totalWidth = 0;
     private int totalHeight = 0;
 
@@ -228,6 +229,20 @@ public class TuscanyCompositeEntityBuild
             elts[i].setId(i);
             elts[i].setName(aComp.getName());
 
+            Implementation implementation = aComp.getImplementation();
+            if (implementation != null) {
+                String impl = "";
+                QName type = implementation.getType();
+                if (JavaImplementation.TYPE.equals(type)) {
+                    impl = "java:" + ((JavaImplementation)implementation).getJavaClass().getSimpleName();
+                } else if (implementation instanceof Composite) {
+                    impl = "composite:" + ((Composite)implementation).getName().getLocalPart();
+                } else {
+                    impl = type.getLocalPart();
+                }
+                elts[i].setImplementation(impl);
+            }
+
             setServices(aComp.getServices(), elts[i]);
             setReferences(aComp.getReferences(), elts[i]);
             setProperties(aComp.getProperties(), elts[i]);
@@ -305,23 +320,15 @@ public class TuscanyCompositeEntityBuild
 
             ent.addToRefToSerMap(reference, serviceComp + "/" + service);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         } else if (reference == null && service != null) {
             ent.addToRefToSerMap(referenceComp, serviceComp + "/" + service);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         } else if (reference != null && service == null) {
             ent.addToRefToSerMap(reference, serviceComp);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         } else {
             ent.addToRefToSerMap(referenceComp, serviceComp);
             ent.addAnAdjacentEntity(serviceComp);
-            addToConnectedEntities(referenceComp, serviceComp);
-            addToConnectedEntities(serviceComp, referenceComp);
         }
     }
 
@@ -340,20 +347,6 @@ public class TuscanyCompositeEntityBuild
         }
     }
 
-    private void addToConnectedEntities(String ent1, String ent2) {
-        // System.err.println(ent1 + " : " + ent2);
-        ArrayList<String> list;
-        if (connectedEntities.containsKey(ent1)) {
-            list = connectedEntities.get(ent1);
-
-        } else {
-            list = new ArrayList<String>();
-
-        }
-        list.add(ent2);
-        connectedEntities.put(ent1, list);
-    }
-
     private void setServices(List<ComponentService> sers, ComponentEntity ent) {
 
         for (int i = 0; i < sers.size(); i++) {



Mime
View raw message