2. Basically I forced orders whenever edges & nodes were created using custom comparator & collections.sort
This commit is contained in:
cdtank 2010-07-26 17:45:05 +00:00
parent e02666b8cd
commit 81f0ad89d6
3 changed files with 20 additions and 28 deletions

View file

@ -107,6 +107,11 @@ public class CoAuthorshipGraphMLWriter {
private void getEdgeContent(StringBuilder graphMLContent, Edge currentEdge) { private void getEdgeContent(StringBuilder graphMLContent, Edge currentEdge) {
/*
System.out.print("EDGE_ID:" + currentEdge.getEdgeID() + "|");
System.out.print("EDGE_SOURCE:" + currentEdge.getSourceNode().getNodeURL() + "|");
System.out.println("EDGE_TARGET:" + currentEdge.getTargetNode().getNodeURL());
*/
graphMLContent.append("<edge " graphMLContent.append("<edge "
+ "id=\"" + currentEdge.getEdgeID() + "\" " + "id=\"" + currentEdge.getEdgeID() + "\" "
+ "source=\"" + currentEdge.getSourceNode().getNodeID() + "\" " + "source=\"" + currentEdge.getSourceNode().getNodeID() + "\" "
@ -223,10 +228,11 @@ public class CoAuthorshipGraphMLWriter {
} }
// System.out.print("NODE_ID:" + node.getNodeID() + "|");
graphMLContent.append("<node id=\"" + node.getNodeID() + "\">\n"); graphMLContent.append("<node id=\"" + node.getNodeID() + "\">\n");
graphMLContent.append("\t<data key=\"url\">" + node.getNodeURL() + "</data>\n"); graphMLContent.append("\t<data key=\"url\">" + node.getNodeURL() + "</data>\n");
// graphMLContent.append("\t<data key=\"name\">" + node.getNodeName() + "</data>\n"); // graphMLContent.append("\t<data key=\"name\">" + node.getNodeName() + "</data>\n");
// System.out.println("NODE_NAME:" + node.getNodeURL());
graphMLContent.append("\t<data key=\"label\">" + node.getNodeName() + "</data>\n"); graphMLContent.append("\t<data key=\"label\">" + node.getNodeName() + "</data>\n");
if (profileURL != null) { if (profileURL != null) {

View file

@ -3,6 +3,7 @@
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship; package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -104,6 +105,7 @@ public class QueryHandler {
} }
} }
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL); RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
BiboDocument biboDocument; BiboDocument biboDocument;
@ -144,7 +146,11 @@ public class QueryHandler {
coAuthorNode.setNodeName(coAuthorLabelNode.toString()); coAuthorNode.setNodeName(coAuthorLabelNode.toString());
} }
} }
/*
System.out.print("PERSON_URL:" + egoAuthorURLNode.toString() + "|");
System.out.print("DOCUMENT_URL:" + documentNode.toString() + "|");
System.out.println("CO_AUTHOR_URL:" + coAuthorURLNode.toString());
*/
coAuthorNode.addAuthorDocument(biboDocument); coAuthorNode.addAuthorDocument(biboDocument);
Set<Node> coAuthorsForCurrentBiboDocument; Set<Node> coAuthorsForCurrentBiboDocument;
@ -193,19 +199,13 @@ public class QueryHandler {
edges); edges);
/* System.out.println(collegeURLToVO);
System.out.println("------------------------------------------------------------");
System.out.println(departmentURLToVO);
System.out.println("------------------------------------------------------------");
System.out.println(employeeURLToVO);
System.out.println("------------------------------------------------------------");
*/
return new VisVOContainer(egoNode, nodes, edges); return new VisVOContainer(egoNode, nodes, edges);
} }
private void createCoAuthorEdges( private void createCoAuthorEdges(
Map<String, BiboDocument> biboDocumentURLToVO, Map<String, BiboDocument> biboDocumentURLToVO,
Map<String, Set<Node>> biboDocumentURLToCoAuthors, Set<Edge> edges) { Map<String, Set<Node>> biboDocumentURLToCoAuthors, Set<Edge> edges) {
for (Map.Entry<String, Set<Node>> currentBiboDocumentEntry : biboDocumentURLToCoAuthors.entrySet()) { for (Map.Entry<String, Set<Node>> currentBiboDocumentEntry : biboDocumentURLToCoAuthors.entrySet()) {
/* /*
* If there was only one co-author (other than ego) then we dont have to create any edges. so * If there was only one co-author (other than ego) then we dont have to create any edges. so
@ -214,10 +214,11 @@ public class QueryHandler {
if (currentBiboDocumentEntry.getValue().size() > 1) { if (currentBiboDocumentEntry.getValue().size() > 1) {
/* /*
* In order to leverage the nested "for loop" for making edges between all the co=authors * In order to leverage the nested "for loop" for making edges between all the co-authors
* we need to create a list out of the set first. * we need to create a list out of the set first.
* */ * */
List<Node> coAuthorNodes = new ArrayList<Node>(currentBiboDocumentEntry.getValue()); List<Node> coAuthorNodes = new ArrayList<Node>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new NodeComparator());
int numOfCoAuthors = coAuthorNodes.size(); int numOfCoAuthors = coAuthorNodes.size();
@ -375,10 +376,10 @@ public class QueryHandler {
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . " + "OPTIONAL { ?document vitro:moniker ?documentMoniker } . "
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . " + "OPTIONAL { ?document vitro:blurb ?documentBlurb } . "
+ "OPTIONAL { ?document vitro:description ?documentDescription } " + "OPTIONAL { ?document vitro:description ?documentDescription } "
// + "FILTER (<" + queryURI + "> != ?coAuthorPerson ) . " + "} "
+ "}"; + "ORDER BY ?document ?coAuthorPerson";
// System.out.println(sparqlQuery); System.out.println("COAUTHORSHIP QUERY - " + sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }

View file

@ -196,21 +196,6 @@ public class VisualizationRequestHandler {
} }
} }
/*
private Map<String, Integer> getUniqueCoauthorsCountPerYear(
edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer coAuthorshipVO) {
Map<String, Integer> yearToUniqueCoauthorCount = new TreeMap<String, Integer>();
Map<String, Set<Node>> yearToUniqueCoauthors = getUniqueCoAuthorsPerYear(coAuthorshipVO);
for (Entry<String, Set<Node>> currentEntry : yearToUniqueCoauthors.entrySet()) {
yearToUniqueCoauthorCount.put(currentEntry.getKey(), currentEntry.getValue().size());
}
return yearToUniqueCoauthorCount;
}
*/
private Map<String, Set<Node>> getUniqueCoAuthorsPerYear(edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer authorNodesAndEdges) { private Map<String, Set<Node>> getUniqueCoAuthorsPerYear(edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer authorNodesAndEdges) {