summaryrefslogtreecommitdiffstats
path: root/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java')
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java4
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java141
2 files changed, 115 insertions, 30 deletions
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
index 8c86248663..39addafe40 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
@@ -170,7 +170,7 @@ public class DiagramGenerator {
Entry entry = (Entry) it.next();
String ref = (String)entry.getKey();
String ser = (String)entry.getValue();
-
+ System.out.println("---------"+ref);
int idx= refs.indexOf(ref);
System.out.println("---------"+sers.get(idx));
sers.remove(idx);
@@ -189,7 +189,7 @@ public class DiagramGenerator {
if(s1.equals(s) || s.equals(ent.getComponentName())){
System.err.println("|||||||| "+ sers.size()+ " ||| " + refs.size()+"|| "+orderedRefs.length);
if(orderedRefs[ent.getLevel()] == null){
-// System.err.println("XXXXX "+ sers.get(1)+ " ::::::: "+refs.get(1));
+ System.err.println("XXXXX "+ sers.get(1)+ " ::::::: "+refs.get(1));
// System.err.println("XXXXX "+ sers.get(2)+ " ::::::: "+refs.get(2));
// System.err.println("XXXXX "+ sers.get(3)+ " ::::::: "+refs.get(3));
System.err.println("XXXXX "+ refs.get(sers.indexOf(s))+" ::: "+ent.getLevel()+" ::: "+ent.getComponentName());
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
index 168915f40c..2d753221db 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
@@ -39,6 +39,7 @@ public class EntityBuilder {
private int totalHeight=0;
private Entity startEnt = null;
private String compositeName;
+ Entity[] elts = null;
/**
* Constructor which initiates the DOM document
@@ -76,7 +77,7 @@ public class EntityBuilder {
* @return
*/
public Entity[] buildEntities(){
- Entity[] elts = null;
+
//get the root element
Element docEle = dom.getDocumentElement();
compositeName = docEle.getAttribute("name");
@@ -99,6 +100,44 @@ public class EntityBuilder {
elts[i].propertyLength();
}
}
+ //sec. 5.4 in the spec
+ nl = docEle.getElementsByTagName("wire");
+ System.out.println("^^^^^^^^^ "+nl.getLength());
+ if(nl != null && nl.getLength() > 0 ) {
+ for(int i = 0 ; i < nl.getLength();i++) {
+ Element elt = (Element)nl.item(i);
+ String source = elt.getAttribute("source");
+ String target = elt.getAttribute("target");
+ String service, serviceComp, reference, referenceComp;
+
+ System.out.println("^^^^^^^^^ "+source+" ::: "+target);
+ if(target.contains("/")){
+ String[] arr = target.split("/");
+ serviceComp = arr[0];
+ service = arr[1];
+ }
+ else{
+ serviceComp = target;
+ service = null;
+ }
+
+ if(source.contains("/")){
+ String[] arr = source.split("/");
+ referenceComp = arr[0];
+ reference = arr[1];
+ }
+ else{
+ referenceComp = source;
+ reference = null;
+ }
+
+ Entity e = findEntity(referenceComp);
+ System.out.println("^^^^^^^^^ "+e.getComponentName());
+ if(e != null){
+ createConnection(e, reference, serviceComp, service);
+ }
+ }
+ }
positionEntities(elts);
@@ -108,6 +147,78 @@ public class EntityBuilder {
return elts;
}
+
+ private Entity findEntity(String componentName) {
+
+ for(Entity e: elts){
+ if(e.getComponentName().equals(componentName)){
+ return e;
+ }
+ }
+ return null;
+ }
+
+ private void setReferences(Element nVal, Entity ent) {
+
+ NodeList nl = nVal.getElementsByTagName("reference");
+ if(nl != null && nl.getLength() > 0 ) {
+ for(int i = 0 ; i < nl.getLength();i++) {
+ Element elt = (Element)nl.item(i);
+ String target = elt.getAttribute("target");
+ String ref = elt.getAttribute("name");
+ if(target.contains("/")){
+ String[] arr = target.split("/");
+ createConnection(ent, ref, arr[0], arr[1]);
+// ent.addToRefToSerMap(ref, arr[1]);
+// ent.addAnAdjacentEntity(arr[0]);
+// addToConnectedEntities(ent.getComponentName(), arr[0]);
+// addToConnectedEntities(arr[0], ent.getComponentName());
+ }
+ else if(!target.equals("")){
+ createConnection(ent, ref, target, null);
+// ent.addToRefToSerMap(ref, target);
+// ent.addAnAdjacentEntity(target);
+// addToConnectedEntities(ent.getComponentName(), target);
+// addToConnectedEntities(target, ent.getComponentName());
+ }
+
+ ent.addAReference(ref);
+
+ }
+ }
+ }
+
+ private void createConnection(Entity ent, String reference,
+ String serviceComp, String service) {
+
+ String referenceComp = ent.getComponentName();
+
+ if(reference != null && service != null){
+
+ ent.addToRefToSerMap(reference, service);
+ ent.addAnAdjacentEntity(serviceComp);
+ addToConnectedEntities(referenceComp, serviceComp);
+ addToConnectedEntities(serviceComp, referenceComp);
+ }
+ else if(reference == null && service != null){
+ ent.addToRefToSerMap(referenceComp, 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(Entity[] elts) {
int level=0, lane=0;
@@ -224,33 +335,7 @@ public class EntityBuilder {
return str.split("/");
}
- private void setReferences(Element nVal, Entity ent) {
-
- NodeList nl = nVal.getElementsByTagName("reference");
- if(nl != null && nl.getLength() > 0 ) {
- for(int i = 0 ; i < nl.getLength();i++) {
- Element elt = (Element)nl.item(i);
- String target = elt.getAttribute("target");
- String ref = elt.getAttribute("name");
- if(target.contains("/")){
- ent.addToRefToSerMap(ref, target.split("/")[1]);
- ent.addAnAdjacentEntity(target.split("/")[0]);
- addToConnectedEntities(ent.getComponentName(), target.split("/")[0]);
- addToConnectedEntities(target.split("/")[0], ent.getComponentName());
- }
- else if(!target.equals("")){
-
- ent.addToRefToSerMap(ref, target);
- ent.addAnAdjacentEntity(target);
- addToConnectedEntities(ent.getComponentName(), target);
- addToConnectedEntities(target, ent.getComponentName());
- }
-
- ent.addAReference(ref);
-
- }
- }
- }
+
private void addToConnectedEntities(String ent1, String ent2) {
System.err.println(ent1+" : "+ent2);