1. Refactored code.
2. Removed edges of documents that has more than 100 co-authors.
This commit is contained in:
parent
d7e39e2953
commit
0ba1e950aa
2 changed files with 45 additions and 5 deletions
|
@ -44,7 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator
|
||||||
*/
|
*/
|
||||||
public class CoAuthorshipQueryHandler implements QueryHandler<CoAuthorshipVOContainer> {
|
public class CoAuthorshipQueryHandler implements QueryHandler<CoAuthorshipVOContainer> {
|
||||||
|
|
||||||
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 101;
|
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
@ -108,7 +108,6 @@ public class CoAuthorshipQueryHandler implements QueryHandler<CoAuthorshipVOCont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
||||||
BiboDocument biboDocument;
|
BiboDocument biboDocument;
|
||||||
|
|
||||||
|
@ -191,6 +190,38 @@ public class CoAuthorshipQueryHandler implements QueryHandler<CoAuthorshipVOCont
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This code snippet takes out all the edges belong to documents that have more than
|
||||||
|
* 100 authors. We conjecture that these papers do not provide much insight. However,
|
||||||
|
* we have left the documents be, just the edges are removed.
|
||||||
|
* */
|
||||||
|
for (Map.Entry<String, Set<Node>> currentBiboDocumentEntry
|
||||||
|
: biboDocumentURLToCoAuthors.entrySet()) {
|
||||||
|
|
||||||
|
if (currentBiboDocumentEntry.getValue().size() > MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
||||||
|
|
||||||
|
BiboDocument currentBiboDocument = biboDocumentURLToVO
|
||||||
|
.get(currentBiboDocumentEntry.getKey());
|
||||||
|
|
||||||
|
Set<Edge> edgesToBeRemoved = new HashSet<Edge>();
|
||||||
|
|
||||||
|
for (Edge currentEdge : edges) {
|
||||||
|
Set<BiboDocument> currentCollaboratorDocuments =
|
||||||
|
currentEdge.getCollaboratorDocuments();
|
||||||
|
|
||||||
|
if (currentCollaboratorDocuments.contains(currentBiboDocument)) {
|
||||||
|
currentCollaboratorDocuments.remove(currentBiboDocument);
|
||||||
|
if (currentCollaboratorDocuments.isEmpty()) {
|
||||||
|
edgesToBeRemoved.add(currentEdge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
edges.removeAll(edgesToBeRemoved);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to create edges between 2 co-authors. E.g. On a paper there were 3 authors
|
* We need to create edges between 2 co-authors. E.g. On a paper there were 3 authors
|
||||||
* ego, A & B then we have already created edges like,
|
* ego, A & B then we have already created edges like,
|
||||||
|
@ -230,7 +261,8 @@ public class CoAuthorshipQueryHandler implements QueryHandler<CoAuthorshipVOCont
|
||||||
* & causes unnecessary computations causing the server to time-out.
|
* & causes unnecessary computations causing the server to time-out.
|
||||||
* */
|
* */
|
||||||
if (currentBiboDocumentEntry.getValue().size() > 1
|
if (currentBiboDocumentEntry.getValue().size() > 1
|
||||||
&& currentBiboDocumentEntry.getValue().size() < MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
&& currentBiboDocumentEntry.getValue().size()
|
||||||
|
<= MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
||||||
|
|
||||||
|
|
||||||
Set<Edge> newlyAddedEdges = new HashSet<Edge>();
|
Set<Edge> newlyAddedEdges = new HashSet<Edge>();
|
||||||
|
|
|
@ -92,7 +92,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
try {
|
try {
|
||||||
handleMalformedParameters(e.getMessage(), vitroRequest, request, response, log);
|
handleMalformedParameters(e.getMessage(),
|
||||||
|
vitroRequest,
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
log);
|
||||||
} catch (ServletException e1) {
|
} catch (ServletException e1) {
|
||||||
log.error(e1.getStackTrace());
|
log.error(e1.getStackTrace());
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
@ -141,7 +145,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
try {
|
try {
|
||||||
handleMalformedParameters(e.getMessage(), vitroRequest, request, response, log);
|
handleMalformedParameters(e.getMessage(),
|
||||||
|
vitroRequest,
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
log);
|
||||||
} catch (ServletException e1) {
|
} catch (ServletException e1) {
|
||||||
log.error(e1.getStackTrace());
|
log.error(e1.getStackTrace());
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue