List of usage examples for org.apache.solr.client.solrj SolrQuery setQuery
public SolrQuery setQuery(String query)
From source file:org.dspace.app.cris.batch.ScriptIndexNetwork.java
private static boolean checkAvailableData(String connection, VisualizationGraphSolrService service) throws SearchServiceException { String query = "type:" + connection; SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(query); solrQuery.setStart(0);//from w ww. ja va 2s . co m solrQuery.setRows(0); QueryResponse rsp = service.search(solrQuery); SolrDocumentList docs = rsp.getResults(); if (docs != null) { if (docs.getNumFound() > 0) { return true; } } return false; }
From source file:org.dspace.app.cris.network.AVisualizationGraph.java
@Override public JsGraph search(String authority, String name, Integer level, boolean showExternal, boolean showSameDept, String dept, Integer modeEntity) throws Exception { SolrQuery solrQuery = new SolrQuery(); String query = buildQuery(authority, name, showSameDept, dept, modeEntity, level); String[] fqs = { "type:" + getConnectionName(), "entity:" + modeEntity }; solrQuery.setQuery(query); solrQuery.addFilterQuery(fqs);//from w ww.j av a 2 s. c om if (!showExternal && authority != null && !authority.isEmpty()) { solrQuery.addFilterQuery(new String[] { "a_auth:rp*", "b_auth:rp*" }); } solrQuery.setFacet(true); solrQuery.addFacetField(FACET_SEARCH); if (modeEntity == ConstantNetwork.ENTITY_RP) { solrQuery.setFacetLimit(getLimitLevel(level)); } else if (modeEntity == ConstantNetwork.ENTITY_DEPT) { solrQuery.setFacetLimit(Integer.MAX_VALUE); } solrQuery.setFacetMinCount(1); solrQuery.setRows(0); QueryResponse rsp = service.search(solrQuery); FacetField facets = rsp.getFacetField(FACET_SEARCH); JsGraph rsGraph = null; String src = null; if (authority != null && !authority.isEmpty()) { src = authority; rsGraph = new JsGraph(); rsGraph.setId(authority); rsGraph.setName(name); JsGraphNodeData dataNode = new JsGraphNodeData(); dataNode.setColor(getNodeCustomColor()); dataNode.setType(getType()); dataNode.setModeStyle("fill"); rsGraph.setData(dataNode); } else { src = name; rsGraph = new JsGraph(); rsGraph.setId(name); rsGraph.setName(name); JsGraphNodeData dataNodeLeaf = new JsGraphNodeData(); dataNodeLeaf.setColor(getNodeLeafCustomColor()); dataNodeLeaf.setType(getType()); dataNodeLeaf.setModeStyle("stroke"); rsGraph.setData(dataNodeLeaf); } if (rsGraph != null) { if (facets != null && facets.getValueCount() > 0) { for (Count facet : facets.getValues()) { if (facet.getCount() > 0) { String node2 = (String) facet.getName(); String split[] = node2.split("\\|\\|\\|"); String srcnode2 = null; String displayValue = ""; String authorityValue = null; boolean isAuthority = false; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); displayValue = splitAuthority[0]; srcnode2 = displayValue; if (splitAuthority.length > 1) { isAuthority = true; authorityValue = splitAuthority[1]; srcnode2 = authorityValue; } } else if (split.length == 1) { displayValue = split[0]; srcnode2 = displayValue; } if (!(src.equals(srcnode2))) { JsGraphAdjacence adjacence = new JsGraphAdjacence(); JsGraphData data = new JsGraphData(); adjacence.setSrc(node2); if (isAuthority) { adjacence.setNodeTo(authorityValue); } else { adjacence.setNodeTo(displayValue); } if (authorityValue != null || showExternal) { data.setColor(getEdgeCustomColor()); data.setLineWidth(getCustomLineWidth((int) facet.getCount())); data.setCount((int) facet.getCount()); data.setType(getType()); adjacence.setData(data); rsGraph.getAdjacencies().add(adjacence); } } } } } } return rsGraph; }
From source file:org.dspace.app.cris.network.AVisualizationGraph.java
public List<ResearcherPage> loadMetrics(List<String[]> discardedNode, Integer importedNodes, Boolean otherError) throws SearchServiceException { // load all publications SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery("type:" + getType() + " AND entity:" + ConstantNetwork.ENTITY_RP); solrQuery.addFacetField(FACET_METRICS); solrQuery.setFacetLimit(Integer.MAX_VALUE); solrQuery.setFacetMinCount(1);//w w w . ja va 2s.c om solrQuery.setRows(0); QueryResponse rsp = getService().search(solrQuery); FacetField facets = rsp.getFacetField(FACET_METRICS); // for each interests get authority's authors List<ResearcherPage> result = new LinkedList<ResearcherPage>(); int counter = 0; external: for (Count facetElement : facets.getValues()) { counter++; log.debug("" + counter + " of " + facets.getValueCount()); ResearcherPage researcher = null; try { String facetValue = facetElement.getName(); Integer realPersistentIdentifier = ResearcherPageUtils.getRealPersistentIdentifier(facetValue, ResearcherPage.class); researcher = applicationService.get(ResearcherPage.class, realPersistentIdentifier); //researcher.getDynamicField().setAnagraficaLazy(applicationService.getAnagraficaByRP(realPersistentIdentifier)); solrQuery = new SolrQuery(); solrQuery.setQuery("type:" + getType() + " AND entity:" + ConstantNetwork.ENTITY_RP + " AND " + FACET_METRICS + ":\"" + facetValue + "\""); solrQuery.addFacetField(FACET_SEARCH); solrQuery.setFacetMinCount(1); solrQuery.setFacetLimit(Integer.MAX_VALUE); solrQuery.setRows(0); rsp = getService().search(solrQuery); FacetField relations = rsp.getFacetField(FACET_SEARCH); int i = 0; int nConnections = 0; int maxStrength = 0; int sumStrength = 0; List<Long> quadraticVarianceArrays = new ArrayList<Long>(); nConnections = Integer.valueOf(relations.getValueCount() - 1); internal: for (Count relation : relations.getValues()) { log.debug("" + counter + " works on " + i + " of " + relations.getValueCount()); if (i == 0) { i++; continue internal; } else { if (i == 1) { // max maxStrength = Integer.valueOf((int) relation.getCount()); } sumStrength += Integer.valueOf((int) relation.getCount()); quadraticVarianceArrays.add(relation.getCount()); } i++; } RPAdditionalFieldStorage anagraficaObject = researcher.getDynamicField(); setMetadata(String.valueOf(nConnections), anagraficaObject, ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_1 + getType()); setMetadata(String.valueOf(maxStrength), anagraficaObject, ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_2 + getType()); double averageStrength = ((double) sumStrength / ((double) nConnections)); setMetadata(String.valueOf(df.format(averageStrength)), anagraficaObject, ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_3 + getType()); double quadraticVariance = 0; double n = quadraticVarianceArrays.size(); for (Long variance : quadraticVarianceArrays) { quadraticVariance += ((variance - averageStrength) * (variance - averageStrength)); } quadraticVariance = Math.sqrt(quadraticVariance / n); setMetadata(String.valueOf(df.format(quadraticVariance)), anagraficaObject, ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_4 + getType()); result.add(researcher); } catch (Exception e) { log.error("Error try to build object to index with ID:" + researcher.getId()); log.error(e.getMessage(), e); otherError = true; continue; } } committnode: for (ResearcherPage node : result) { // try // { applicationService.saveOrUpdate(ResearcherPage.class, node); boolean rr = ((CrisSearchService) getIndexer().getIndexer()).indexCrisObject(node, true); // index node if (rr) { importedNodes++; } else { discardedNode.add(new String[] { getConnectionName() + " - " + node.getId() }); } // } // catch (SolrServerException e) // { // log.error(e.getMessage(), e); // discardedNode.add(new String[] { getConnectionName() + " - " + node.getId()}); // continue committnode; // } // catch (IOException e) // { // log.error(e.getMessage(), e); // discardedNode.add(new String[] { getConnectionName() + " - " + node.getId()}); // continue committnode; // } } log.debug("commit " + getType()); getIndexer().getIndexer().commit(); return result; }
From source file:org.dspace.app.cris.network.AVisualizationGraph.java
protected String getDepartmentFromSOLR(String a_authority) throws SearchServiceException { SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery("search.resourceid:" + ResearcherPageUtils.getRealPersistentIdentifier(a_authority, ResearcherPage.class) + " AND search.resourcetype:" + CrisConstants.RP_TYPE_ID); solrQuery.setFields("rp_dept"); solrQuery.setRows(1);// www. jav a 2 s .c o m QueryResponse rsp = getService().getSearcher().search(solrQuery); SolrDocumentList publications = rsp.getResults(); Iterator<SolrDocument> iter = publications.iterator(); String rp_dept = ""; while (iter.hasNext()) { SolrDocument publication = iter.next(); rp_dept = (String) publication.getFirstValue("rp_dept"); break; } return rp_dept; }
From source file:org.dspace.app.cris.network.AVisualizationGraph.java
protected String getStatusFromSOLR(String a_authority) throws SearchServiceException { SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery("search.resourceid:" + ResearcherPageUtils.getRealPersistentIdentifier(a_authority, ResearcherPage.class) + " AND search.resourcetype:" + CrisConstants.RP_TYPE_ID); solrQuery.setFields("rp_boolean_status"); solrQuery.setRows(1);// w ww . j a v a2s .co m QueryResponse rsp = getService().getSearcher().search(solrQuery); SolrDocumentList publications = rsp.getResults(); Iterator<SolrDocument> iter = publications.iterator(); String rp_status = ""; while (iter.hasNext()) { SolrDocument publication = iter.next(); rp_status = (String) publication.getFirstValue("rp_boolean_status"); break; } return rp_status; }
From source file:org.dspace.app.cris.network.AVisualizationGraphModeFour.java
@Override public List<VisualizationGraphNode> load(List<String[]> discardedNode, Integer importedNodes, Boolean otherError) throws Exception { // load all publications SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(getQuery()); solrQuery.addFacetField(getFacetFieldQuery()); // solrQuery.addFilterQuery("authors_fauthority:rp00001"); solrQuery.setFacetLimit(Integer.MAX_VALUE); solrQuery.setFacetMinCount(1);/*from ww w .j a v a 2 s . c om*/ solrQuery.setRows(0); QueryResponse rsp = getService().getSearcher().search(solrQuery); FacetField facets = rsp.getFacetField(getFacetFieldQuery()); System.out.println(facets.getValueCount()); // for each interests get authority's authors List<VisualizationGraphNode> result = null; int counter = 0; external: for (Count facetElement : facets.getValues()) { counter++; log.debug(getConnectionName() + " - " + counter + " of " + facets.getValueCount()); System.out.println(getConnectionName() + " - " + counter + " of " + facets.getValueCount()); result = new LinkedList<VisualizationGraphNode>(); try { String facetValue = facetElement.getName(); List<String> relations = getValues(facetValue); int i = 0; internal: for (String relation : relations) { log.debug("" + counter + " works on " + i + " of " + relations.size()); System.out.println(getConnectionName() + " - " + counter + " of " + facets.getValueCount() + " works on " + i + " of " + relations.size()); String aaa = relation; String[] split = aaa.split("\\|\\|\\|"); String a = aaa; String a_authority = null; String a_dept = null; String a_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); a_displayValue = splitAuthority[0]; if (splitAuthority.length > 1) { a_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); a_dept = getDepartmentFromSOLR(a_authority); } } internalprivate: for (int j = i; j < relations.size(); j++) { List<String> values = new LinkedList<String>(); values.add(facetValue); String bbb = relations.get(j); split = bbb.split("\\|\\|\\|"); String b = bbb; String b_authority = null; String b_dept = null; String b_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); b_displayValue = splitAuthority[0]; if (splitAuthority.length > 1) { b_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); b_dept = getDepartmentFromSOLR(b_authority); } } if (j == i) { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, buildExtra(facetValue), a_dept, b_dept, ConstantNetwork.ENTITY_PLACEHOLDER_RP); } else { if (!a.equals(b)) { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, buildExtra(facetValue), a_dept, b_dept, ConstantNetwork.ENTITY_RP); } } } i++; } } catch (Exception e) { log.error("Error try to build object to index with ID:" + ""); log.error(e.getMessage(), e); otherError = true; continue; } importedNodes = indexNode(discardedNode, importedNodes, result); } log.debug("commit " + getType()); getIndexer().commit(); return result; }
From source file:org.dspace.app.cris.network.AVisualizationGraphModeOne.java
@Override public List<VisualizationGraphNode> load(List<String[]> discardedNode, Integer importedNodes, Boolean otherError) throws Exception { // load all publications SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery("*:*"); solrQuery.setFields("search.resourceid", "search.resourcetype", "author_filter", "dc.title", "handle"); solrQuery.addFilterQuery("search.resourcetype:[2 TO 4]"); int start = 0; int offset = 100; if (NOT_PAGINATION) { solrQuery.setRows(Integer.MAX_VALUE); } else {/*from w w w . jav a2 s .c o m*/ solrQuery.setStart(start); solrQuery.setRows(offset); } QueryResponse rsp = getService().getSearcher().search(solrQuery); SolrDocumentList publications = rsp.getResults(); System.out.println(publications.getNumFound()); List<VisualizationGraphNode> result = null; boolean endwhile = false; while (((publications.getNumFound() + offset) > start) && endwhile == false) { if (start > 0 && !NOT_PAGINATION) { solrQuery.setStart(start); solrQuery.setRows(offset); rsp = getService().getSearcher().search(solrQuery); publications = rsp.getResults(); } start = (start + 1) + offset; // for each publication get authority's authors facets Iterator<SolrDocument> iter = publications.iterator(); int counter = 0; external: while (iter.hasNext()) { counter++; log.debug("" + (start == 0 ? counter : (start + counter)) + " of " + publications.getNumFound()); System.out.println(getConnectionName() + " - " + counter); result = new ArrayList<VisualizationGraphNode>(); Integer pubId = null; try { SolrDocument publication = iter.next(); pubId = (Integer) publication.getFieldValue("search.resourceid"); Object obj = publication.getFieldValue("dc.title"); String handle = (String) publication.getFieldValue("handle"); Object auth = publication.getFieldValue("author_filter"); List<String> values = new ArrayList<String>(); if (obj instanceof ArrayList) { for (String aaa : (List<String>) obj) { values.add(aaa); } } else { String value = (String) obj; values.add(value); } if (auth instanceof ArrayList) { int i = 0; List<String> authArrays = (List<String>) auth; for (String aaa : authArrays) { String[] split = aaa.split("\\|\\|\\|"); String a = aaa; String a_authority = null; String a_dept = null; String a_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); a_displayValue = splitAuthority[0]; if (splitAuthority.length > 1) { a_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); a_dept = getDepartmentFromSOLR(a_authority); } } for (int j = i; j < authArrays.size(); j++) { String bbb = authArrays.get(j); String extra = handle; split = bbb.split("\\|\\|\\|"); String b = bbb; String b_authority = null; String b_dept = null; String b_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); b_displayValue = splitAuthority[0]; if (splitAuthority.length > 1) { b_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); b_dept = getDepartmentFromSOLR(b_authority); } } if (j == i) { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, extra, a_dept, b_dept, ConstantNetwork.ENTITY_PLACEHOLDER_RP); } else { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, extra, a_dept, b_dept, ConstantNetwork.ENTITY_RP); } } i++; } } else { continue external; } } catch (Exception e) { log.error("Error try to build object to index with publication ID:" + pubId); log.error(e.getMessage(), e); otherError = true; continue; } importedNodes = indexNode(discardedNode, importedNodes, result); } if (NOT_PAGINATION) { endwhile = true; } log.debug("commit " + getType()); getIndexer().commit(); } return result; }
From source file:org.dspace.app.cris.network.AVisualizationGraphModeThree.java
@Override public List<VisualizationGraphNode> load(List<String[]> discardedNode, Integer importedNodes, Boolean otherError) throws Exception { // load all publications SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(getQuery()); solrQuery.setFields(getFields());/* w w w .j a v a 2s . c o m*/ solrQuery.addFilterQuery("search.resourcetype:" + getResourceType()); int start = 0; int offset = 100; if (NOT_PAGINATION) { solrQuery.setRows(Integer.MAX_VALUE); } else { solrQuery.setStart(start); solrQuery.setRows(offset); } QueryResponse rsp = getService().getSearcher().search(solrQuery); SolrDocumentList publications = rsp.getResults(); System.out.println(publications.getNumFound()); List<VisualizationGraphNode> result = null; boolean endwhile = false; while (((publications.getNumFound() + offset) > start) && endwhile == false) { if (start > 0 && !NOT_PAGINATION) { solrQuery.setStart(start); solrQuery.setRows(offset); rsp = getService().getSearcher().search(solrQuery); publications = rsp.getResults(); } start = (start + 1) + offset; // for each publication get authority's authors facets Iterator<SolrDocument> iter = publications.iterator(); int counter = 0; external: while (iter.hasNext()) { counter++; log.debug("" + (start == 0 ? counter : (start + counter)) + " of " + publications.getNumFound()); System.out.println(getConnectionName() + " - " + counter); result = new ArrayList<VisualizationGraphNode>(); Integer pubId = null; try { SolrDocument publication = iter.next(); pubId = (Integer) publication.getFieldValue("search.resourceid"); Object obj = publication.getFieldValue(getNameFieldValueInFields()); String handle = (String) publication.getFirstValue(getNameFieldExtraInFields()); Object auth = publication.getFieldValue(getNameFieldNodeBuilderInFields()); List<String> values = new ArrayList<String>(); if (obj instanceof ArrayList) { for (String aaa : (List<String>) obj) { values.add(aaa); } } else { String value = (String) obj; values.add(value); } if (auth instanceof ArrayList) { int i = 0; List<String> authArrays = (List<String>) auth; for (String aaa : authArrays) { String[] split = aaa.split("\\|\\|\\|"); String a = aaa; String a_authority = null; String a_dept = null; String a_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); a_displayValue = splitAuthority[0]; if (split.length > 1) { a_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); a_dept = getDepartmentFromSOLR(a_authority); } } for (int j = i; j < authArrays.size(); j++) { String bbb = authArrays.get(j); String extra = handle; split = bbb.split("\\|\\|\\|"); String b = bbb; String b_authority = null; String b_dept = null; String b_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); b_displayValue = splitAuthority[0]; if (split.length > 1) { b_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); b_dept = getDepartmentFromSOLR(a_authority); } } if (j == i) { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, extra, a_dept, b_dept, ConstantNetwork.ENTITY_PLACEHOLDER_RP); } else { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, extra, a_dept, b_dept, ConstantNetwork.ENTITY_RP); } } i++; } } else { continue external; } } catch (Exception e) { log.error("Error try to build object to index with publication ID:" + pubId); log.error(e.getMessage(), e); otherError = true; continue; } importedNodes = indexNode(discardedNode, importedNodes, result); } if (NOT_PAGINATION) { endwhile = true; } log.debug("commit " + getType()); getIndexer().commit(); } return result; }
From source file:org.dspace.app.cris.network.AVisualizationGraphModeTwo.java
@Override public List<VisualizationGraphNode> load(List<String[]> discardedNode, Integer importedNodes, Boolean otherError) throws Exception { // load all publications SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(getQuery()); solrQuery.addFacetField(getFacetFieldQuery()); // solrQuery.addFilterQuery("authors_fauthority:rp00001"); solrQuery.setFacetLimit(Integer.MAX_VALUE); solrQuery.setFacetMinCount(1);/*from ww w.j a v a 2s. c o m*/ solrQuery.setRows(0); QueryResponse rsp = getService().getSearcher().search(solrQuery); FacetField facets = rsp.getFacetField(getFacetFieldQuery()); System.out.println(facets.getValueCount()); // for each interests get authority's authors List<VisualizationGraphNode> result = null; int counter = 0; external: for (Count facetElement : facets.getValues()) { counter++; log.debug(getConnectionName() + " - " + counter + " of " + facets.getValueCount()); System.out.println(getConnectionName() + " - " + counter + " of " + facets.getValueCount()); result = new LinkedList<VisualizationGraphNode>(); try { String facetValue = facetElement.getName(); solrQuery = new SolrQuery(); String query = (useJoin() ? getJoin() : "") + getFacetFieldQuery() + ":\"" + ClientUtils.escapeQueryChars(facetValue) + "\""; solrQuery.setQuery(query); solrQuery.addFacetField(getFacet(facetValue)); solrQuery.setFacetMinCount(1); solrQuery.setFacetLimit(getFacetLimit()); solrQuery.setRows(0); rsp = getService().getSearcher().search(solrQuery); FacetField relations = rsp.getFacetField(getFacet(facetValue)); int i = 0; internal: for (Count relation : relations.getValues()) { log.debug("" + counter + " works on " + i + " of " + relations.getValueCount()); System.out.println(getConnectionName() + " - " + counter + " of " + facets.getValueCount() + " works on " + i + " of " + relations.getValueCount()); String aaa = relation.getName(); String[] split = aaa.split("\\|\\|\\|"); String a = aaa; String a_authority = null; String a_dept = null; String a_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); a_displayValue = splitAuthority[0]; if (splitAuthority.length > 1) { a_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); a_dept = getDepartmentFromSOLR(a_authority); } } internalprivate: for (int j = i; j < relations.getValues().size(); j++) { List<String> values = new LinkedList<String>(); values.add(facetValue); String bbb = relations.getValues().get(j).getName(); split = bbb.split("\\|\\|\\|"); String b = bbb; String b_authority = null; String b_dept = null; String b_displayValue = ""; if (split.length > 1) { String[] splitAuthority = split[1].split(splitterAuthority); b_displayValue = splitAuthority[0]; if (splitAuthority.length > 1) { b_authority = splitAuthority[1]; // a_dept = ResearcherPageUtils // .getDepartment(a_authority); b_dept = getDepartmentFromSOLR(b_authority); } } if (j == i) { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, buildExtra(facetValue), a_dept, b_dept, ConstantNetwork.ENTITY_PLACEHOLDER_RP); } else { if (!a.equals(b)) { buildRow(result, a, a_authority, a_displayValue, b, b_authority, b_displayValue, values, buildExtra(facetValue), a_dept, b_dept, ConstantNetwork.ENTITY_RP); } } } i++; } } catch (Exception e) { log.error("Error try to build object to index with ID:" + ""); log.error(e.getMessage(), e); otherError = true; continue; } importedNodes = indexNode(discardedNode, importedNodes, result); } log.debug("commit " + getType()); getIndexer().commit(); return result; }
From source file:org.dspace.app.cris.network.DepartmentNetworkPlugin.java
public List<VisualizationGraphNode> load(List<String[]> discardedNode, Integer importedNodes, Boolean otherError, List<String> connections) throws Exception { for (String connection : connections) { SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery("type:" + connection); solrQuery.addFacetField(FACET);/*from ww w. j a v a2 s . c o m*/ solrQuery.setFacetLimit(Integer.MAX_VALUE); solrQuery.setFacetMinCount(1); solrQuery.setRows(0); QueryResponse rsp = service.search(solrQuery); FacetField facets = rsp.getFacetField(FACET); // for each interests get authority's authors List<VisualizationGraphNode> result = null; int counter = 0; external: for (Count facetElement : facets.getValues()) { counter++; log.debug("" + counter + " of " + facets.getValueCount()); result = new LinkedList<VisualizationGraphNode>(); try { String facetValue = facetElement.getName(); String[] splittedFacetValue = facetValue.split("\\|\\|\\|"); if (!splittedFacetValue[0].equals("null") && splittedFacetValue[0].equals(splittedFacetValue[1])) { SolrQuery solrQuery2 = new SolrQuery(); solrQuery2.setQuery("type:" + connection + " AND " + FACET + ":\"" + ClientUtils.escapeQueryChars(facetValue) + "\" AND a_auth:[* TO *] AND b_auth:[* TO *]"); solrQuery2.addFacetField(FACET_AUTHOR); solrQuery2.setFacetMinCount(1); solrQuery2.setFacetLimit(Integer.MAX_VALUE); solrQuery2.setRows(0); QueryResponse rsp2 = service.search(solrQuery2); FacetField relations = rsp2.getFacetField(FACET_AUTHOR); int i = 0; internal: for (Count relation : relations.getValues()) { log.debug("" + counter + " works on " + i + " of " + relations.getValueCount()); List<String> values = new LinkedList<String>(); values.add(splittedFacetValue[0]); String aaa = relation.getName(); String[] split = aaa.split("\\|\\|\\|"); String a = aaa; String a_authority = null; String a_displayValue = ""; if (split.length > 1) { a_displayValue = split[1]; } if (split.length > 2) { a_authority = split[2]; } buildRow(result, splittedFacetValue[0], null, splittedFacetValue[1], a, a_authority, a_displayValue, values, buildExtra(splittedFacetValue[0]), connection); i++; } importedNodes = importNode(discardedNode, importedNodes, result); log.debug("commit DEPARTMENT " + facetValue); indexer.getSolr().commit(); } } catch (Exception e) { log.error("Error try to build object to index with ID:" + ""); log.error(e.getMessage(), e); otherError = true; continue; } } } return null; }