Skip to content

Commit

Permalink
created new settings to control maximum collaborators in co-author ne…
Browse files Browse the repository at this point in the history
…twork and non-vcard collaborators boost
  • Loading branch information
litvinovg committed Oct 14, 2024
1 parent 41f4d25 commit 571c7c8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@

package edu.cornell.mannlib.vitro.webapp.visualization.visutils;

import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.ArrayList;
import java.util.List;

public class CollaborationDataViewHelper {
private static final int MAX_COLLABORATORS = 35;

private static final String DEFAULT_PERSON_COLLABORATORS_BOOST = "0";

private static final String DEFAULT_MAX_COLLABORATORS = "35";

private static final String MAX_COLLABORATORS_PROPERTY = "visualization.coAuthorNetwork.maxCollaborators";

private static final String PERSON_COLLABORATORS_BOOST_PROPERTY = "visualization.coAuthorNetwork.personBoost";

private static Log log = LogFactory.getLog(CollaborationDataViewHelper.class.getName());

private static final int MAX_COLLABORATORS = getPropertyIntValue(MAX_COLLABORATORS_PROPERTY,
DEFAULT_MAX_COLLABORATORS);

private static final int PERSON_COLLABORATORS_BOOST = getPropertyIntValue(PERSON_COLLABORATORS_BOOST_PROPERTY,
DEFAULT_PERSON_COLLABORATORS_BOOST);

private CollaborationData data;

private List<Collaborator> collaborators = null;
Expand All @@ -36,6 +55,21 @@ public List<Collaborator> getCollaborators() {
return collaborators;
}

private static int getPropertyIntValue(String property, String defaultValue) {
ConfigurationProperties props = ConfigurationProperties.getInstance();
String propertyValue = props.getProperty(property, defaultValue);
try {
return Integer.parseInt(propertyValue);
} catch (Exception e) {
log.error(String.format(
"Can't convert %s to integer value. " +
"Property %s should be set to an integer value. " +
"Use fallback to default value %s.",
propertyValue, property, defaultValue));
return Integer.parseInt(defaultValue);
}
}

private synchronized void init(int max) {
if (collaborators != null) {
return;
Expand Down Expand Up @@ -167,7 +201,7 @@ private synchronized void init(int max) {

private int boost(Collaborator collaborator) {
if (!collaborator.getIsVCard()) {
return 10000;
return PERSON_COLLABORATORS_BOOST;
}
return 0;
}
Expand Down
10 changes: 10 additions & 0 deletions home/src/main/resources/config/example.runtime.properties
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ visualization.temporal = enabled
#
visualization.mapOfScience = enabled

#Maximum number of co-authors displayed on co-authors network.
visualization.coAuthorNetwork.maxCollaborators = 35

#Prioritize co-authors stored as Persons in lists with VCard co-authors
#In case you would like to prioritize person co-authors over co-authors stored as VCards
#when there are more than maximum number of collaborators this property can be set to 10000.
#In that case list of coauthors to display limited by maximum number collaborators will be
#first sorted by the type of stored collaborator (Person first, then VCard) and sencond by
#the number of joint publications.
visualization.coAuthorNetwork.personBoost = 0
#
# Types of individual for which we can create proxy editors.
# If this is omitted, defaults to http://www.w3.org/2002/07/owl#Thing
Expand Down

0 comments on commit 571c7c8

Please sign in to comment.