summaryrefslogtreecommitdiffstats
path: root/collaboration/GSoC-2011-Nirmal
diff options
context:
space:
mode:
authornirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68>2011-07-03 08:11:18 +0000
committernirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68>2011-07-03 08:11:18 +0000
commita9c20c2a85a0bf6b2b359721b596202754965cf8 (patch)
tree2b8068d37bc43874c81452b5ca16001ce447d01b /collaboration/GSoC-2011-Nirmal
parent1fb59defe41d14db5969726dc9df4c811e715ccc (diff)
add support to wire element
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1142395 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'collaboration/GSoC-2011-Nirmal')
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite1.xml4
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml2
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/CalculatorTest_diagram.svg1
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml7
-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
6 files changed, 126 insertions, 33 deletions
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite1.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite1.xml
index b88a83120e..1964db7fbb 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite1.xml
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite1.xml
@@ -39,7 +39,9 @@
<component name="ShipperComponent">
<implementation.java class="supplychain.ShipperComponentImpl" />
- <reference name="customer" target="CustomerComponent"/>
+ <reference name="customer" />
</component>
+
+ <wire source="ShipperComponent/customer" target="CustomerComponent" />
</composite> \ No newline at end of file
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml
index 7d00becf2d..9997ba42bc 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml
@@ -44,7 +44,7 @@
<component name="DivideServiceComponent">
<implementation.java class="calculator.DivideServiceImpl"/>
- <reference name="dividetestService" target="AddServiceComponent" />
+ <!-- reference name="dividetestService" target="AddServiceComponent" / -->
</component>
</composite> \ No newline at end of file
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/CalculatorTest_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/CalculatorTest_diagram.svg
new file mode 100755
index 0000000000..c029859d70
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/CalculatorTest_diagram.svg
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" contentScriptType="text/ecmascript" zoomAndPan="magnify" contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" version="1.0"><rect x="0" y="0" alignment-baseline="central" fill="#E5E5E5" width="1000" rx="20" ry="20" height="1240" stroke="#919191"/><text x="500" font-size="10" dominant-baseline="mathematical" y="20" text-anchor="middle">CalculatorTest</text><rect x="200" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="250" font-size="10" dominant-baseline="mathematical" y="350" text-anchor="middle">CalculatorServiceComponent</text><polygon fill="#00CD66" points="180,210 210,210 225,225 210,240 180,240 195,225 " stroke="#008B45"/><text x="180" font-size="10" dominant-baseline="mathematical" y="225" text-anchor="middle"></text><polygon fill="#BF3EFF" points="386,210 408,210 419,221 408,232 386,232 397,221 " stroke="#68228B"/><text x="386" font-size="10" dominant-baseline="mathematical" y="221" text-anchor="middle">subtractService</text><polygon fill="#BF3EFF" points="386,242 408,242 419,253 408,264 386,264 397,253 " stroke="#68228B"/><text x="386" font-size="10" dominant-baseline="mathematical" y="253" text-anchor="middle">divideService</text><polygon fill="#BF3EFF" points="386,274 408,274 419,285 408,296 386,296 397,285 " stroke="#68228B"/><text x="386" font-size="10" dominant-baseline="mathematical" y="285" text-anchor="middle">multiplyService</text><polygon fill="#BF3EFF" points="386,306 408,306 419,317 408,328 386,328 397,317 " stroke="#68228B"/><text x="386" font-size="10" dominant-baseline="mathematical" y="317" text-anchor="middle">addService</text><rect x="600" y="980" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="650" font-size="10" dominant-baseline="mathematical" y="1130" text-anchor="middle">AddServiceComponent</text><polygon fill="#00CD66" points="580,990 610,990 625,1005 610,1020 580,1020 595,1005 " stroke="#008B45"/><text x="580" font-size="10" dominant-baseline="mathematical" y="1005" text-anchor="middle"></text><rect x="600" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="650" font-size="10" dominant-baseline="mathematical" y="350" text-anchor="middle">SubtractServiceComponent</text><polygon fill="#00CD66" points="580,210 610,210 625,225 610,240 580,240 595,225 " stroke="#008B45"/><text x="580" font-size="10" dominant-baseline="mathematical" y="225" text-anchor="middle"></text><rect x="600" y="720" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="650" font-size="10" dominant-baseline="mathematical" y="870" text-anchor="middle">MultiplyServiceComponent</text><polygon fill="#00CD66" points="580,730 610,730 625,745 610,760 580,760 595,745 " stroke="#008B45"/><text x="580" font-size="10" dominant-baseline="mathematical" y="745" text-anchor="middle"></text><rect x="600" y="460" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="650" font-size="10" dominant-baseline="mathematical" y="610" text-anchor="middle">DivideServiceComponent</text><polygon fill="#00CD66" points="580,470 610,470 625,485 610,500 580,500 595,485 " stroke="#008B45"/><text x="580" font-size="10" dominant-baseline="mathematical" y="485" text-anchor="middle"></text><polyline stroke-width="2" points="419,317 595,1005" stroke="black"/><polyline stroke-width="2" points="419,253 595,485" stroke="black"/><polyline stroke-width="2" points="419,285 595,745" stroke="black"/><polyline stroke-width="2" points="419,221 595,225" stroke="black"/></svg> \ No newline at end of file
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml
index f7636d210f..64ce98b8e2 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml
@@ -103,7 +103,12 @@
<artifactId>tuscany-base-runtime</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.4.3</version>
+ </dependency>
</dependencies>
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);