summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/composite-diagram/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2011-09-22 06:48:25 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2011-09-22 06:48:25 +0000
commit8fba4a1b6f3a3699307fb653e5c7a78135b07208 (patch)
tree4be403d02a4f6e3a095bd29d3c822c0ad56506ac /sca-java-2.x/trunk/modules/composite-diagram/src
parent0524f6a2c2a44d8f63484a1e74c92b0ed823621b (diff)
Add impl info for the node/remove unused code
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1173966 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/composite-diagram/src')
-rwxr-xr-xsca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java135
-rwxr-xr-xsca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java45
2 files changed, 20 insertions, 160 deletions
diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
index 9e70781a08..ed2d8c18c7 100755
--- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
+++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
@@ -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");
diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
index 9f6e7a6bda..c2bee79590 100755
--- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
+++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
@@ -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.CompositeReference;
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 TuscanyCompositeEntityBuilder {
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 TuscanyCompositeEntityBuilder {
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 TuscanyCompositeEntityBuilder {
}
}
- 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++) {