1. In Temporal vis developed vis drilling up from lower level. (see http://issues.library.cornell.edu/browse/NIHVIVO-1800)
2. Refactored client-side code for temporal vis.
This commit is contained in:
parent
82c4d1faa7
commit
ae43216396
19 changed files with 449 additions and 78 deletions
|
@ -93,6 +93,12 @@ public class QueryFieldLabels {
|
|||
public static final String SUBORGANIZATION_URL = "subOrganizationLit";
|
||||
public static final String SUBORGANIZATION_LABEL = "subOrganizationLabelLit";
|
||||
|
||||
/*
|
||||
* Parent Organization related field labels
|
||||
*/
|
||||
public static final String PARENT_ORGANIZATION_URL = "parentOrganizationLit";
|
||||
public static final String PARENT_ORGANIZATION_LABEL = "parentOrganizationLabelLit";
|
||||
|
||||
/*
|
||||
* Sub Organization related field labels
|
||||
*/
|
||||
|
|
|
@ -172,11 +172,23 @@ public class EntityComparisonUtilityFunctions {
|
|||
|
||||
if (StringUtils.equalsIgnoreCase(entityA.getEntityURI(), entityB.getEntityURI())) {
|
||||
|
||||
Entity mergedEntity = new Entity(entityA.getEntityURI(), entityA.getEntityLabel());
|
||||
Entity mergedEntity = new Entity(entityA.getEntityURI());
|
||||
|
||||
if (StringUtils.isNotBlank(entityA.getEntityLabel())) {
|
||||
|
||||
mergedEntity.setEntityLabel(entityA.getEntityLabel());
|
||||
|
||||
} else if (StringUtils.isNotBlank(entityB.getEntityLabel())) {
|
||||
|
||||
mergedEntity.setEntityLabel(entityB.getEntityLabel());
|
||||
}
|
||||
|
||||
mergedEntity.addSubEntitities(entityA.getSubEntities());
|
||||
mergedEntity.addSubEntitities(entityB.getSubEntities());
|
||||
|
||||
mergedEntity.addParents(entityA.getParents());
|
||||
mergedEntity.addParents(entityB.getParents());
|
||||
|
||||
return mergedEntity;
|
||||
|
||||
} else {
|
||||
|
|
|
@ -31,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Co
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubjectEntityJSON;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.SelectOnModelUtilities;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||
|
@ -221,7 +222,7 @@ public class TemporalGrantVisualizationRequestHandler implements
|
|||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
writeGrantsOverTimeJSON(vitroRequest,
|
||||
entity.getSubEntities()));
|
||||
entity));
|
||||
return fileData;
|
||||
}
|
||||
|
||||
|
@ -285,12 +286,12 @@ public class TemporalGrantVisualizationRequestHandler implements
|
|||
* @param subOrganizationTypesResult
|
||||
*/
|
||||
private String writeGrantsOverTimeJSON(VitroRequest vreq,
|
||||
Set<SubEntity> subentities) {
|
||||
Entity subjectEntity) {
|
||||
|
||||
Gson json = new Gson();
|
||||
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
|
||||
Set jsonifiedResponse = new HashSet();
|
||||
|
||||
for (SubEntity subentity : subentities) {
|
||||
for (SubEntity subentity : subjectEntity.getSubEntities()) {
|
||||
JsonObject entityJson = new JsonObject(
|
||||
subentity.getIndividualLabel());
|
||||
|
||||
|
@ -326,10 +327,17 @@ public class TemporalGrantVisualizationRequestHandler implements
|
|||
entityJson.setVisMode("ORGANIZATION");
|
||||
}
|
||||
|
||||
subEntitiesJson.add(entityJson);
|
||||
jsonifiedResponse.add(entityJson);
|
||||
}
|
||||
|
||||
return json.toJson(subEntitiesJson);
|
||||
|
||||
SubjectEntityJSON subjectEntityJSON = new SubjectEntityJSON(subjectEntity.getEntityLabel(),
|
||||
subjectEntity.getEntityURI(),
|
||||
subjectEntity.getParents());
|
||||
|
||||
jsonifiedResponse.add(subjectEntityJSON);
|
||||
|
||||
return json.toJson(jsonifiedResponse);
|
||||
}
|
||||
|
||||
private String getEntityGrantsPerYearCSVContent(Entity entity) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Ac
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubjectEntityJSON;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.SelectOnModelUtilities;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||
|
@ -88,7 +89,6 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
|||
|
||||
Entity organizationWithAssociatedPeople = SelectOnModelUtilities
|
||||
.getSubjectOrganizationAssociatedPeople(dataset, subjectEntityURI);
|
||||
|
||||
|
||||
if (organizationWithAssociatedPeople.getSubEntities() != null) {
|
||||
|
||||
|
@ -247,7 +247,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
|||
"application/octet-stream");
|
||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||
writePublicationsOverTimeJSON(vitroRequest,
|
||||
entity.getSubEntities()));
|
||||
entity));
|
||||
return fileData;
|
||||
}
|
||||
|
||||
|
@ -277,12 +277,12 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
|||
* @param subOrganizationTypesResult
|
||||
*/
|
||||
private String writePublicationsOverTimeJSON(VitroRequest vreq,
|
||||
Set<SubEntity> subentities) {
|
||||
Entity subjectEntity) {
|
||||
|
||||
Gson json = new Gson();
|
||||
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
|
||||
Set subEntitiesJson = new HashSet();
|
||||
|
||||
for (SubEntity subentity : subentities) {
|
||||
for (SubEntity subentity : subjectEntity.getSubEntities()) {
|
||||
|
||||
JsonObject entityJson = new JsonObject(
|
||||
subentity.getIndividualLabel());
|
||||
|
@ -320,6 +320,13 @@ public class TemporalPublicationVisualizationRequestHandler implements
|
|||
|
||||
subEntitiesJson.add(entityJson);
|
||||
}
|
||||
|
||||
SubjectEntityJSON subjectEntityJSON = new SubjectEntityJSON(subjectEntity.getEntityLabel(),
|
||||
subjectEntity.getEntityURI(),
|
||||
subjectEntity.getParents());
|
||||
|
||||
subEntitiesJson.add(subjectEntityJSON);
|
||||
|
||||
return json.toJson(subEntitiesJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructo
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PeopleToPublicationsFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PersonToGrantsFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.PersonToPublicationsFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory.SubOrganizationWithinModelFactory;
|
||||
|
||||
public class ModelConstructorUtilities {
|
||||
|
||||
|
@ -30,6 +31,7 @@ public class ModelConstructorUtilities {
|
|||
put(OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, new OrganizationToGrantsForSubOrganizationsFactory());
|
||||
put(OrganizationAssociatedPeopleModelWithTypesConstructor.MODEL_TYPE, new OrganizationAssociatedPeopleModelWithTypesFactory());
|
||||
put(OrganizationModelWithTypesConstructor.MODEL_TYPE, new OrganizationModelWithTypesFactory());
|
||||
put(SubOrganizationWithinModelConstructor.MODEL_TYPE, new SubOrganizationWithinModelFactory());
|
||||
}};
|
||||
|
||||
public static Model getOrConstructModel(String uri, String modelType, Dataset dataset)
|
||||
|
|
|
@ -70,8 +70,6 @@ public class OrganizationModelWithTypesConstructor implements ModelConstructor {
|
|||
|
||||
private Model executeQuery(String constructQuery) {
|
||||
|
||||
System.out.println("in constructed model fior organization");
|
||||
|
||||
Model constructedModel = ModelFactory.createDefaultModel();
|
||||
|
||||
before = System.currentTimeMillis();
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||
|
||||
public class SubOrganizationWithinModelConstructor implements ModelConstructor {
|
||||
|
||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||
|
||||
public static final String MODEL_TYPE = "SUBORGANIZATION_WITHIN_HIERARCHY_MODEL";
|
||||
|
||||
private Dataset dataset;
|
||||
|
||||
private Model constructedModel;
|
||||
|
||||
private Log log = LogFactory.getLog(SubOrganizationWithinModelConstructor.class.getName());
|
||||
|
||||
private long before, after;
|
||||
|
||||
public SubOrganizationWithinModelConstructor(Dataset dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is present so that we can abstract out the model construction process.
|
||||
* @param uri
|
||||
* @param dataset
|
||||
*/
|
||||
public SubOrganizationWithinModelConstructor(String uri, Dataset dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
private String constructAllSubOrganizationsWithinQuery() {
|
||||
return ""
|
||||
+ " CONSTRUCT { "
|
||||
+ " ?organization rdf:type foaf:Organization . "
|
||||
+ " ?organization rdfs:label ?organizationLabel . "
|
||||
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
|
||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
||||
+ " } "
|
||||
+ " WHERE { "
|
||||
+ " ?organization rdf:type foaf:Organization . "
|
||||
+ " ?organization rdfs:label ?organizationLabel . "
|
||||
+ " "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
|
||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
||||
+ " } "
|
||||
+ " } ";
|
||||
|
||||
}
|
||||
|
||||
private Model executeQuery(String constructQuery) {
|
||||
|
||||
Model constructedModel = ModelFactory.createDefaultModel();
|
||||
|
||||
before = System.currentTimeMillis();
|
||||
log.debug("CONSTRUCT query string : " + constructQuery);
|
||||
|
||||
Query query = null;
|
||||
|
||||
try {
|
||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery()
|
||||
+ constructQuery, SYNTAX);
|
||||
} catch (Throwable th) {
|
||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||
+ "string. " + th.getMessage());
|
||||
log.error(constructQuery);
|
||||
}
|
||||
|
||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
||||
|
||||
try {
|
||||
qe.execConstruct(constructedModel);
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
|
||||
after = System.currentTimeMillis();
|
||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
||||
+ (after - before));
|
||||
|
||||
return constructedModel;
|
||||
}
|
||||
|
||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
||||
|
||||
if (constructedModel != null && !constructedModel.isEmpty()) {
|
||||
return constructedModel;
|
||||
} else {
|
||||
constructedModel = executeQuery(constructAllSubOrganizationsWithinQuery());
|
||||
return constructedModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.factory;
|
||||
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.SubOrganizationWithinModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.ConstructedModelTracker;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||
|
||||
public class SubOrganizationWithinModelFactory implements ModelFactoryInterface {
|
||||
|
||||
@Override
|
||||
public Model getOrCreateModel(String uri, Dataset dataset) throws MalformedQueryParametersException {
|
||||
|
||||
Model candidateModel = ConstructedModelTracker.getModel(
|
||||
ConstructedModelTracker
|
||||
.generateModelIdentifier(
|
||||
null,
|
||||
SubOrganizationWithinModelConstructor.MODEL_TYPE));
|
||||
|
||||
if (candidateModel != null) {
|
||||
|
||||
return candidateModel;
|
||||
|
||||
} else {
|
||||
|
||||
ModelConstructor model = new SubOrganizationWithinModelConstructor(dataset);
|
||||
Model constructedModel = model.getConstructedModel();
|
||||
|
||||
ConstructedModelTracker.trackModel(
|
||||
ConstructedModelTracker
|
||||
.generateModelIdentifier(
|
||||
null,
|
||||
SubOrganizationWithinModelConstructor.MODEL_TYPE),
|
||||
constructedModel);
|
||||
|
||||
return constructedModel;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import java.util.Set;
|
|||
*/
|
||||
public class Entity extends Individual {
|
||||
|
||||
private Set<Individual> parents = new LinkedHashSet<Individual>();
|
||||
private Set<SubEntity> children = new LinkedHashSet<SubEntity>();
|
||||
|
||||
public Entity(String entityURI, String entityLabel) {
|
||||
|
@ -28,10 +29,18 @@ public class Entity extends Individual {
|
|||
public String getEntityLabel() {
|
||||
return this.getIndividualLabel();
|
||||
}
|
||||
|
||||
public void setEntityLabel(String label) {
|
||||
this.setIndividualLabel(label);
|
||||
}
|
||||
|
||||
public Set<SubEntity> getSubEntities() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public Set<Individual> getParents() {
|
||||
return parents;
|
||||
}
|
||||
|
||||
public void addSubEntity(SubEntity subEntity) {
|
||||
this.children.add(subEntity);
|
||||
|
@ -40,5 +49,9 @@ public class Entity extends Individual {
|
|||
public void addSubEntitities(Collection<SubEntity> subEntities) {
|
||||
this.children.addAll(subEntities);
|
||||
}
|
||||
|
||||
|
||||
public void addParents(Collection<Individual> parents) {
|
||||
this.parents.addAll(parents);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SubjectEntityJSON {
|
||||
|
||||
private String subjectEntityLabel;
|
||||
private String subjectEntityURI;
|
||||
private Map<String, String> parentURIToLabel = new HashMap<String, String>();
|
||||
|
||||
public SubjectEntityJSON(String subjectEntityURI, String label,
|
||||
Set<Individual> parentOrganizations) {
|
||||
this.subjectEntityURI = subjectEntityURI;
|
||||
this.subjectEntityLabel = label;
|
||||
|
||||
this.setParentURIToLabel(parentOrganizations);
|
||||
}
|
||||
|
||||
public String getSubjectEntityURI() {
|
||||
return subjectEntityURI;
|
||||
}
|
||||
|
||||
public void setSubjectEntityURI(String subjectEntityURI) {
|
||||
this.subjectEntityURI = subjectEntityURI;
|
||||
}
|
||||
|
||||
public String getSubjectEntityLabel() {
|
||||
return subjectEntityLabel;
|
||||
}
|
||||
|
||||
public void setSubjectEntityLabel(String label) {
|
||||
this.subjectEntityLabel = label;
|
||||
}
|
||||
|
||||
public Map<String, String> getParentURIToLabel() {
|
||||
return parentURIToLabel;
|
||||
}
|
||||
|
||||
public void setParentURIToLabel(Set<Individual> parentOrganizations) {
|
||||
for (Individual parentOrganization : parentOrganizations) {
|
||||
this.parentURIToLabel.put(parentOrganization.getIndividualURI(), parentOrganization.getIndividualLabel());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,8 +25,10 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructo
|
|||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.OrganizationToPublicationsForSubOrganizationsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PeopleToGrantsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.PeopleToPublicationsModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.modelconstructor.SubOrganizationWithinModelConstructor;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||
|
||||
public class SelectOnModelUtilities {
|
||||
|
@ -59,8 +61,82 @@ public class SelectOnModelUtilities {
|
|||
"",
|
||||
organizationModel);
|
||||
|
||||
return getEntityWithSubOrganizations(subjectEntityURI,
|
||||
Entity entityWithSubOrganizations = getEntityWithSubOrganizations(subjectEntityURI,
|
||||
subOrganizationsWithTypesQuery.getQueryResult());
|
||||
|
||||
Entity entityWithParentOrganizations = getAllParentOrganizations(dataset, subjectEntityURI);
|
||||
|
||||
entityWithSubOrganizations.addParents(entityWithParentOrganizations.getParents());
|
||||
|
||||
return entityWithSubOrganizations;
|
||||
}
|
||||
|
||||
public static Entity getAllParentOrganizations(Dataset dataset,
|
||||
String subjectEntityURI) throws MalformedQueryParametersException {
|
||||
Model organizationModel = ModelConstructorUtilities
|
||||
.getOrConstructModel(
|
||||
null,
|
||||
SubOrganizationWithinModelConstructor.MODEL_TYPE,
|
||||
dataset);
|
||||
|
||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
|
||||
fieldLabelToOutputFieldLabel.put("parentOrganization", QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
||||
fieldLabelToOutputFieldLabel.put("parentOrganizationLabel", QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
||||
|
||||
String whereClause = ""
|
||||
+ " <" + subjectEntityURI + "> rdfs:label ?organizationLabel . "
|
||||
+ " <" + subjectEntityURI + "> core:subOrganizationWithin ?parentOrganization . "
|
||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . ";
|
||||
|
||||
QueryRunner<ResultSet> parentOrganizationsQuery =
|
||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||
"",
|
||||
whereClause,
|
||||
"",
|
||||
organizationModel);
|
||||
|
||||
return getEntityWithParentOrganizations(subjectEntityURI,
|
||||
parentOrganizationsQuery.getQueryResult());
|
||||
}
|
||||
|
||||
private static Entity getEntityWithParentOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
||||
|
||||
Entity entity = new Entity(subjectEntityURI);
|
||||
Map<String, Individual> parentOrganizationURIToVO = new HashMap<String, Individual>();
|
||||
|
||||
while (queryResult.hasNext()) {
|
||||
|
||||
QuerySolution solution = queryResult.nextSolution();
|
||||
|
||||
if (StringUtils.isEmpty(entity.getEntityLabel())) {
|
||||
|
||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
||||
if (organizationLabelNode != null) {
|
||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
RDFNode parentOrganizationNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_URL);
|
||||
|
||||
Individual parent;
|
||||
|
||||
if (!parentOrganizationURIToVO.containsKey(parentOrganizationNode.toString())) {
|
||||
|
||||
parent = new Individual(parentOrganizationNode.toString());
|
||||
|
||||
parentOrganizationURIToVO.put(parentOrganizationNode.toString(), parent);
|
||||
|
||||
RDFNode parentOrganizationLabelNode = solution.get(QueryFieldLabels.PARENT_ORGANIZATION_LABEL);
|
||||
if (parentOrganizationLabelNode != null) {
|
||||
parent.setIndividualLabel(parentOrganizationLabelNode.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity.addParents(parentOrganizationURIToVO.values());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static Entity getEntityWithSubOrganizations(String subjectEntityURI, ResultSet queryResult) {
|
||||
|
@ -76,7 +152,8 @@ public class SelectOnModelUtilities {
|
|||
|
||||
RDFNode organizationLabelNode = solution.get(QueryFieldLabels.ORGANIZATION_LABEL);
|
||||
if (organizationLabelNode != null) {
|
||||
entity.setIndividualLabel(organizationLabelNode.toString());
|
||||
|
||||
entity.setEntityLabel(organizationLabelNode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue