Fix string comparisons

This commit is contained in:
Graham Triggs 2017-09-18 18:31:45 +01:00
parent 6b15366c89
commit c52939af35
6 changed files with 11 additions and 10 deletions

View file

@ -18,6 +18,7 @@ import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -296,7 +297,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//for selection when creating a new label //for selection when creating a new label
//The assumption here is we don't want to allow the user to add a new label when a label //The assumption here is we don't want to allow the user to add a new label when a label
//already exists in that language //already exists in that language
if(languageName != "untyped" && !existingLabelsLanguageNames.contains(languageName)) { if(!"untyped".equals(languageName) && !existingLabelsLanguageNames.contains(languageName)) {
availableLocales.add(localeInfo); availableLocales.add(localeInfo);
} }
} }
@ -368,7 +369,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
for(Literal l: labels) { for(Literal l: labels) {
String languageTag = l.getLanguage(); String languageTag = l.getLanguage();
String languageName = ""; String languageName = "";
if(languageTag == "") { if(StringUtils.isEmpty(languageTag)) {
languageName = "untyped"; languageName = "untyped";
} }
else if(localeCodeToNameMap.containsKey(languageTag)) { else if(localeCodeToNameMap.containsKey(languageTag)) {
@ -377,7 +378,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
log.warn("This language tag " + languageTag + " does not have corresponding name in the system and was not processed"); log.warn("This language tag " + languageTag + " does not have corresponding name in the system and was not processed");
} }
if(languageName != "") { if(!StringUtils.isEmpty(languageName)) {
if(!labelsHash.containsKey(languageName)) { if(!labelsHash.containsKey(languageName)) {
labelsHash.put(languageName, new ArrayList<LabelInformation>()); labelsHash.put(languageName, new ArrayList<LabelInformation>());
} }

View file

@ -801,7 +801,7 @@ public class AddAssociatedConceptsPreprocessor extends
//Make or retrieve URI for this label //Make or retrieve URI for this label
//TODO: Do we create this string with empty inputs ? //TODO: Do we create this string with empty inputs ?
String uri = getURIForSemanticTypeLabel(label); String uri = getURIForSemanticTypeLabel(label);
if(uri != "") { if(!StringUtils.isEmpty(uri)) {
//uri var shouldn't be repeated? //uri var shouldn't be repeated?
if(!this.conceptSemanticTypeURIVarToValueMap.containsKey(uriVar)) { if(!this.conceptSemanticTypeURIVarToValueMap.containsKey(uriVar)) {
this.conceptSemanticTypeURIVarToValueMap.put(uriVar, new ArrayList<String>()); this.conceptSemanticTypeURIVarToValueMap.put(uriVar, new ArrayList<String>());

View file

@ -113,7 +113,7 @@ public class CoAuthorshipGraphMLWriter {
Set<Collaboration> edges = coAuthorshipData.getCollaborations(); Set<Collaboration> edges = coAuthorshipData.getCollaborations();
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges); List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
Collections.sort(orderedEdges, new CollaborationComparator()); orderedEdges.sort(new CollaborationComparator());
for (Collaboration currentEdge : orderedEdges) { for (Collaboration currentEdge : orderedEdges) {
/* /*
@ -208,7 +208,7 @@ public class CoAuthorshipGraphMLWriter {
List<Collaborator> orderedAuthorNodes = new ArrayList<Collaborator>(authorNodes); List<Collaborator> orderedAuthorNodes = new ArrayList<Collaborator>(authorNodes);
orderedAuthorNodes.remove(egoNode); orderedAuthorNodes.remove(egoNode);
Collections.sort(orderedAuthorNodes, new CollaboratorComparator()); orderedAuthorNodes.sort(new CollaboratorComparator());
for (Collaborator currNode : orderedAuthorNodes) { for (Collaborator currNode : orderedAuthorNodes) {
/* /*

View file

@ -285,7 +285,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
List<Collaborator> coAuthorNodes = List<Collaborator> coAuthorNodes =
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue()); new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new CollaboratorComparator()); coAuthorNodes.sort(new CollaboratorComparator());
int numOfCoAuthors = coAuthorNodes.size(); int numOfCoAuthors = coAuthorNodes.size();

View file

@ -533,7 +533,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
* */ * */
List<Collaborator> coPINodes = List<Collaborator> coPINodes =
new ArrayList<Collaborator>(currentGrantEntry.getValue()); new ArrayList<Collaborator>(currentGrantEntry.getValue());
Collections.sort(coPINodes, new CollaboratorComparator()); coPINodes.sort(new CollaboratorComparator());
int numOfCoPIs = coPINodes.size(); int numOfCoPIs = coPINodes.size();

View file

@ -116,7 +116,7 @@ public class CoPIGraphMLWriter {
Set<Collaboration> edges = coPIData.getCollaborations(); Set<Collaboration> edges = coPIData.getCollaborations();
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges); List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
Collections.sort(orderedEdges, new CollaborationComparator()); orderedEdges.sort(new CollaborationComparator());
for (Collaboration currentEdge : orderedEdges) { for (Collaboration currentEdge : orderedEdges) {
/* /*
@ -213,7 +213,7 @@ public class CoPIGraphMLWriter {
List<Collaborator> orderedPINodes = new ArrayList<Collaborator>(piNodes); List<Collaborator> orderedPINodes = new ArrayList<Collaborator>(piNodes);
orderedPINodes.remove(egoNode); orderedPINodes.remove(egoNode);
Collections.sort(orderedPINodes, new CollaboratorComparator()); orderedPINodes.sort(new CollaboratorComparator());
for (Collaborator currNode : orderedPINodes) { for (Collaborator currNode : orderedPINodes) {