Skip to content

Commit 975e8fc

Browse files
committed
Added aux properties to edge to match those in node
1 parent afbcd7f commit 975e8fc

8 files changed

Lines changed: 411 additions & 201 deletions

File tree

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ src/main/java/edu/uiowa/slis/graphtaglib/CommunityDetection/Network.java -text
2020
src/main/java/edu/uiowa/slis/graphtaglib/CommunityDetection/SmartLocalMovingDetector.java -text
2121
src/main/java/edu/uiowa/slis/graphtaglib/CommunityDetection/SmartLocalMovingWrapper.java -text
2222
src/main/java/edu/uiowa/slis/graphtaglib/Edge.java -text
23+
src/main/java/edu/uiowa/slis/graphtaglib/EdgeAuxDouble.java -text
24+
src/main/java/edu/uiowa/slis/graphtaglib/EdgeAuxInt.java -text
25+
src/main/java/edu/uiowa/slis/graphtaglib/EdgeAuxString.java -text
2326
src/main/java/edu/uiowa/slis/graphtaglib/EdgeIterator.java -text
2427
src/main/java/edu/uiowa/slis/graphtaglib/EdgeSource.java -text
2528
src/main/java/edu/uiowa/slis/graphtaglib/EdgeTarget.java -text

src/main/java/edu/uiowa/slis/graphtaglib/Edge.java

Lines changed: 103 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,111 @@
88
import org.apache.logging.log4j.Logger;
99

1010
public class Edge extends TagSupport {
11-
private static final long serialVersionUID = 1L;
11+
private static final long serialVersionUID = 1L;
1212
static Logger logger = LogManager.getLogger(Edge.class);
1313

14-
GraphNode sourceNode = null;
15-
GraphNode targetNode = null;
16-
GraphEdge currentEdge = null;
17-
String source = null;
18-
String target = null;
19-
double weight = 0.0;
20-
21-
public int doStartTag() throws JspException {
22-
Graph theGraph = (Graph) findAncestorWithClass(this, Graph.class);
23-
EdgeIterator theIterator = (EdgeIterator) findAncestorWithClass(this, EdgeIterator.class);
24-
25-
if (theIterator == null) {
26-
logger.trace("Adding edge source: " + source + "\ttarget: " + target + "\tweight: " + weight);
27-
GraphNode sourceNode = theGraph.getNode(source);
28-
GraphNode targetNode = theGraph.getNode(target);
29-
if (sourceNode == null) {
30-
logger.error("source node missing for edge <" + source + ", " + target + ">");
31-
} else if (targetNode == null) {
32-
logger.error("target node missing for edge <" + source + ", " + target + ">");
33-
} else
34-
theGraph.addEdge(new GraphEdge(sourceNode, targetNode, weight));
35-
return SKIP_BODY;
36-
} else {
37-
currentEdge = theIterator.currentEdge;
38-
sourceNode = theIterator.currentEdge.getSource();
39-
targetNode = theIterator.currentEdge.getTarget();
40-
weight = theIterator.currentEdge.getWeight();
41-
// return EVAL_BODY_INCLUDE;
14+
GraphNode sourceNode = null;
15+
GraphNode targetNode = null;
16+
GraphEdge currentEdge = null;
17+
String source = null;
18+
String target = null;
19+
double weight = 0.0;
20+
int auxInt = 0;
21+
String auxString = null;
22+
double auxDouble = 0.0;
23+
24+
public int doStartTag() throws JspException {
25+
Graph theGraph = (Graph) findAncestorWithClass(this, Graph.class);
26+
EdgeIterator theIterator = (EdgeIterator) findAncestorWithClass(this, EdgeIterator.class);
27+
28+
if (theIterator == null) {
29+
logger.trace("Adding edge source: " + source + "\ttarget: " + target + "\tweight: " + weight);
30+
GraphNode sourceNode = theGraph.getNode(source);
31+
GraphNode targetNode = theGraph.getNode(target);
32+
if (sourceNode == null) {
33+
logger.error("source node missing for edge <" + source + ", " + target + ">");
34+
} else if (targetNode == null) {
35+
logger.error("target node missing for edge <" + source + ", " + target + ">");
36+
} else if (weight == 0) {
37+
logger.error("edge weight cannot be 0");
38+
} else
39+
theGraph.addEdge(new GraphEdge(sourceNode, targetNode, weight, auxInt, auxString, auxDouble));
40+
return SKIP_BODY;
41+
} else {
42+
currentEdge = theIterator.currentEdge;
43+
sourceNode = theIterator.currentEdge.getSource();
44+
targetNode = theIterator.currentEdge.getTarget();
45+
weight = theIterator.currentEdge.getWeight();
46+
auxInt = theIterator.currentEdge.getAuxInt();
47+
auxString = theIterator.currentEdge.getAuxString();
48+
auxDouble = theIterator.currentEdge.getAuxDouble();
49+
// return EVAL_BODY_INCLUDE;
50+
}
51+
52+
// currentEdge = theIterator.currentEdge;
53+
logger.trace("");
54+
return EVAL_BODY_INCLUDE;
55+
}
56+
57+
public int doEndTag() throws JspTagException, JspException {
58+
clearServiceState();
59+
return super.doEndTag();
60+
}
61+
62+
private void clearServiceState() {
63+
sourceNode = null;
64+
targetNode = null;
65+
currentEdge = null;
66+
source = null;
67+
target = null;
68+
weight = 0;
69+
}
70+
71+
public String getSource() {
72+
return source;
73+
}
74+
75+
public void setSource(String source) {
76+
this.source = source;
77+
}
78+
79+
public String getTarget() {
80+
return target;
81+
}
82+
83+
public void setTarget(String target) {
84+
this.target = target;
4285
}
4386

44-
// currentEdge = theIterator.currentEdge;
45-
logger.trace("");
46-
return EVAL_BODY_INCLUDE;
47-
}
48-
49-
public int doEndTag() throws JspTagException, JspException {
50-
clearServiceState();
51-
return super.doEndTag();
52-
}
53-
54-
private void clearServiceState() {
55-
sourceNode = null;
56-
targetNode = null;
57-
currentEdge = null;
58-
source = null;
59-
target = null;
60-
weight = 0;
61-
}
62-
63-
public String getSource() {
64-
return source;
65-
}
66-
67-
public void setSource(String source) {
68-
this.source = source;
69-
}
70-
71-
public String getTarget() {
72-
return target;
73-
}
74-
75-
public void setTarget(String target) {
76-
this.target = target;
77-
}
78-
79-
public double getWeight() {
80-
return weight;
81-
}
82-
83-
public void setWeight(double weight) {
84-
this.weight = weight;
85-
}
87+
public double getWeight() {
88+
return weight;
89+
}
90+
91+
public void setWeight(double weight) {
92+
this.weight = weight;
93+
}
94+
95+
public int getAuxInt() {
96+
return auxInt;
97+
}
98+
99+
public void setAuxInt(int auxInt) {
100+
this.auxInt = auxInt;
101+
}
102+
103+
public String getAuxString() {
104+
return auxString;
105+
}
106+
107+
public void setAuxString(String auxString) {
108+
this.auxString = auxString;
109+
}
110+
111+
public double getAuxDouble() {
112+
return auxDouble;
113+
}
114+
115+
public void setAuxDouble(double auxDouble) {
116+
this.auxDouble = auxDouble;
117+
}
86118
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package edu.uiowa.slis.graphtaglib;
2+
3+
import java.io.IOException;
4+
5+
import javax.servlet.jsp.JspException;
6+
import javax.servlet.jsp.JspTagException;
7+
import javax.servlet.jsp.tagext.TagSupport;
8+
9+
import org.apache.logging.log4j.LogManager;
10+
import org.apache.logging.log4j.Logger;
11+
12+
public class EdgeAuxDouble extends TagSupport {
13+
private static final long serialVersionUID = 1L;
14+
static Logger logger = LogManager.getLogger(EdgeAuxDouble.class);
15+
16+
public int doStartTag() throws JspException {
17+
Edge theEdge = (Edge) findAncestorWithClass(this, Edge.class);
18+
logger.trace("");
19+
try {
20+
pageContext.getOut().print(theEdge.currentEdge.getAuxDouble());
21+
} catch (IOException e) {
22+
e.printStackTrace();
23+
}
24+
return SKIP_BODY;
25+
}
26+
27+
public int doEndTag() throws JspTagException, JspException {
28+
clearServiceState();
29+
return super.doEndTag();
30+
}
31+
32+
private void clearServiceState() {
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package edu.uiowa.slis.graphtaglib;
2+
3+
import java.io.IOException;
4+
5+
import javax.servlet.jsp.JspException;
6+
import javax.servlet.jsp.JspTagException;
7+
import javax.servlet.jsp.tagext.TagSupport;
8+
9+
import org.apache.logging.log4j.LogManager;
10+
import org.apache.logging.log4j.Logger;
11+
12+
public class EdgeAuxInt extends TagSupport {
13+
private static final long serialVersionUID = 1L;
14+
static Logger logger = LogManager.getLogger(EdgeAuxInt.class);
15+
16+
public int doStartTag() throws JspException {
17+
Edge theEdge = (Edge) findAncestorWithClass(this, Edge.class);
18+
logger.trace("");
19+
try {
20+
pageContext.getOut().print(theEdge.currentEdge.getAuxInt());
21+
} catch (IOException e) {
22+
e.printStackTrace();
23+
}
24+
return SKIP_BODY;
25+
}
26+
27+
public int doEndTag() throws JspTagException, JspException {
28+
clearServiceState();
29+
return super.doEndTag();
30+
}
31+
32+
private void clearServiceState() {
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package edu.uiowa.slis.graphtaglib;
2+
3+
import java.io.IOException;
4+
5+
import javax.servlet.jsp.JspException;
6+
import javax.servlet.jsp.JspTagException;
7+
import javax.servlet.jsp.tagext.TagSupport;
8+
9+
import org.apache.logging.log4j.LogManager;
10+
import org.apache.logging.log4j.Logger;
11+
12+
public class EdgeAuxString extends TagSupport {
13+
private static final long serialVersionUID = 1L;
14+
static Logger logger = LogManager.getLogger(EdgeAuxString.class);
15+
16+
public int doStartTag() throws JspException {
17+
Edge theEdge = (Edge) findAncestorWithClass(this, Edge.class);
18+
logger.trace("");
19+
try {
20+
pageContext.getOut().print(theEdge.currentEdge.getAuxString());
21+
} catch (IOException e) {
22+
e.printStackTrace();
23+
}
24+
return SKIP_BODY;
25+
}
26+
27+
public int doEndTag() throws JspTagException, JspException {
28+
clearServiceState();
29+
return super.doEndTag();
30+
}
31+
32+
private void clearServiceState() {
33+
}
34+
}

0 commit comments

Comments
 (0)