Small bug fixes from static analysis

This commit is contained in:
Graham Triggs 2017-10-05 00:04:12 +01:00
parent 38f79971d6
commit d737f86084
8 changed files with 22 additions and 22 deletions

View file

@ -22,18 +22,18 @@ public class Classes2Classes {
public void setSuperclassURI(String in){ superclassURI=in;} public void setSuperclassURI(String in){ superclassURI=in;}
public String getSuperclassNamespace(){ return superclassNamespace; } public String getSuperclassNamespace(){ return superclassNamespace; }
public void setSuperclassNamespace(){ this.superclassNamespace=superclassNamespace;} public void setSuperclassNamespace(String superclassNamespace){ this.superclassNamespace=superclassNamespace;}
public String getSuperclassLocalName(){ return superclassLocalName; } public String getSuperclassLocalName(){ return superclassLocalName; }
public void setSuperclassLocalName(){ this.superclassLocalName=superclassLocalName;} public void setSuperclassLocalName(String superclassLocalName){ this.superclassLocalName=superclassLocalName;}
public String getSubclassURI(){ return subclassURI;} public String getSubclassURI(){ return subclassURI;}
public void setSubclassURI(String in){ subclassURI=in;} public void setSubclassURI(String in){ subclassURI=in;}
public String getSubclassNamespace(){ return subclassNamespace; } public String getSubclassNamespace(){ return subclassNamespace; }
public void setSubclassNamespace(){ this.subclassNamespace=subclassNamespace;} public void setSubclassNamespace(String subclassNamespace){ this.subclassNamespace=subclassNamespace;}
public String getSubclassLocalName(){ return subclassLocalName; } public String getSubclassLocalName(){ return subclassLocalName; }
public void setSubclassLocalName(){ this.subclassLocalName=subclassLocalName;} public void setSubclassLocalName(String subclassLocalName){ this.subclassLocalName=subclassLocalName;}
} }

View file

@ -356,7 +356,7 @@ public class IndividualRdfAssembler {
} }
private Literal createDateLiteral(OntModel o) { private Literal createDateLiteral(OntModel o) {
String date = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss") String date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
.format(new Date()); .format(new Date());
return o.createTypedLiteral(date, XSDDatatype.XSDdateTime); return o.createTypedLiteral(date, XSDDatatype.XSDdateTime);
} }

View file

@ -153,7 +153,7 @@ public class JenaXMLFileUpload extends JenaIngestController {
} catch (Exception e) { } catch (Exception e) {
System.out.println(this.getClass().getName()+" could not forward to view."); System.out.println(this.getClass().getName()+" could not forward to view.");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e.getStackTrace()); e.printStackTrace(System.out);
} }
} }
@ -180,7 +180,7 @@ public class JenaXMLFileUpload extends JenaIngestController {
} catch (Exception e) { } catch (Exception e) {
System.out.println(this.getClass().getName()+" could not forward to view."); System.out.println(this.getClass().getName()+" could not forward to view.");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e.getStackTrace()); e.printStackTrace(System.out);
} }
} }

View file

@ -271,7 +271,7 @@ public class BasicValidationVTwo {
if( unknown.isEmpty() ) if( unknown.isEmpty() )
return ; return ;
throw new Error( "Unknown basic validators: " + unknown.toArray()); throw new Error( "Unknown basic validators: " + Arrays.toString(unknown.toArray()));
} }
private static boolean isEmpty(String value) { private static boolean isEmpty(String value) {

View file

@ -34,14 +34,14 @@ public class IndividualURIQueue<E> implements Queue<E> {
@Override @Override
public boolean contains(Object o) { public boolean contains(Object o) {
return m.contains(o); return m.containsKey(o);
} }
@Override @Override
public boolean containsAll(Collection<?> c) { public boolean containsAll(Collection<?> c) {
boolean contains = true; boolean contains = true;
for(Object e : c) { for(Object e : c) {
contains |= m.contains(e); contains |= m.containsKey(e);
} }
return contains; return contains;
} }

View file

@ -20,6 +20,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec; import org.apache.jena.ontology.OntModelSpec;
import org.apache.jena.rdf.model.AnonId;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.ModelFactory;
@ -72,7 +73,7 @@ public class JenaIngestUtils {
// the dedupUnionModel is so we can guard against reusing a URI in an // the dedupUnionModel is so we can guard against reusing a URI in an
// existing model, as well as in the course of running this process // existing model, as well as in the course of running this process
inModel.enterCriticalSection(Lock.READ); inModel.enterCriticalSection(Lock.READ);
Set<String> doneSet = new HashSet<String>(); Set<AnonId> doneSet = new HashSet<AnonId>();
try { try {
outModel.add(inModel); outModel.add(inModel);
ClosableIterator closeIt = inModel.listSubjects(); ClosableIterator closeIt = inModel.listSubjects();
@ -93,7 +94,7 @@ public class JenaIngestUtils {
if (stmt != null) { if (stmt != null) {
Resource outRes = stmt.getSubject(); Resource outRes = stmt.getSubject();
ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc,dedupUnionModel)); ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc,dedupUnionModel));
doneSet.add(res.getId().toString()); doneSet.add(res.getId());
} }
} }
} }
@ -120,7 +121,7 @@ public class JenaIngestUtils {
if (stmt != null) { if (stmt != null) {
Resource outRes = stmt.getSubject(); Resource outRes = stmt.getSubject();
ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc, dedupUnionModel)); ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc, dedupUnionModel));
doneSet.add(res.getId().toString()); doneSet.add(res.getId());
} }
} }
} }
@ -145,7 +146,7 @@ public class JenaIngestUtils {
// the dedupUnionModel is so we can guard against reusing a URI in an // the dedupUnionModel is so we can guard against reusing a URI in an
// existing model, as well as in the course of running this process // existing model, as well as in the course of running this process
inModel.enterCriticalSection(Lock.READ); inModel.enterCriticalSection(Lock.READ);
Set<String> doneSet = new HashSet<String>(); Set<AnonId> doneSet = new HashSet<AnonId>();
try { try {
outModel.add(inModel); outModel.add(inModel);
@ -173,7 +174,7 @@ public class JenaIngestUtils {
: pattern + value; : pattern + value;
ResourceUtils.renameResource(outRes, namespaceEtc + suffix); ResourceUtils.renameResource(outRes, namespaceEtc + suffix);
} }
doneSet.add(res.getId().toString()); doneSet.add(res.getId());
} }
} }
} }
@ -191,13 +192,13 @@ public class JenaIngestUtils {
public Map<String, LinkedList<String>> generatePropertyMap(List<Model> sourceModels, ModelMaker maker){ public Map<String, LinkedList<String>> generatePropertyMap(List<Model> sourceModels, ModelMaker maker){
Map<String,LinkedList<String>> propertyMap = Collections.synchronizedMap(new HashMap<String, LinkedList<String>>()); Map<String,LinkedList<String>> propertyMap = Collections.synchronizedMap(new HashMap<String, LinkedList<String>>());
Set<String> doneList = new HashSet<String>(); Set<AnonId> doneSet = new HashSet<AnonId>();
for(Model model : sourceModels) { for(Model model : sourceModels) {
ClosableIterator cItr = model.listSubjects(); ClosableIterator cItr = model.listSubjects();
while(cItr.hasNext()){ while(cItr.hasNext()){
Resource res = (Resource) cItr.next(); Resource res = (Resource) cItr.next();
if(res.isAnon() && !doneList.contains(res.getId())){ if(res.isAnon() && !doneSet.contains(res.getId())){
doneList.add(res.getId().toString()); doneSet.add(res.getId());
StmtIterator stmtItr = model.listStatements(res, (Property)null, (RDFNode)null); StmtIterator stmtItr = model.listStatements(res, (Property)null, (RDFNode)null);
while(stmtItr.hasNext()){ while(stmtItr.hasNext()){
Statement stmt = stmtItr.next(); Statement stmt = stmtItr.next();
@ -220,8 +221,8 @@ public class JenaIngestUtils {
RDFNode rdfn = (RDFNode) cItr.next(); RDFNode rdfn = (RDFNode) cItr.next();
if(rdfn.isResource()){ if(rdfn.isResource()){
Resource res = (Resource)rdfn; Resource res = (Resource)rdfn;
if(res.isAnon() && !doneList.contains(res.getId())){ if(res.isAnon() && !doneSet.contains(res.getId())){
doneList.add(res.getId().toString()); doneSet.add(res.getId());
StmtIterator stmtItr = model.listStatements(res, (Property)null, (RDFNode)null); StmtIterator stmtItr = model.listStatements(res, (Property)null, (RDFNode)null);
while(stmtItr.hasNext()){ while(stmtItr.hasNext()){
Statement stmt = stmtItr.next(); Statement stmt = stmtItr.next();

View file

@ -70,7 +70,7 @@ public class VitroBackgroundThread extends Thread {
public void setWorkLevel(WorkLevel level, String... flags) { public void setWorkLevel(WorkLevel level, String... flags) {
log.debug("Set work level on '" + this.getName() + "' to " + level log.debug("Set work level on '" + this.getName() + "' to " + level
+ ", flags=" + flags); + ", flags=" + Arrays.toString(flags));
stamp = new WorkLevelStamp(level, flags); stamp = new WorkLevelStamp(level, flags);
} }

View file

@ -50,7 +50,6 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
propertyUri = property.getURI(); propertyUri = property.getURI();
localName = property.getLocalName(); localName = property.getLocalName();
this.name = name; this.name = name;
this.displayLimit = displayLimit;
addUrl = ""; addUrl = "";
fauxProperty = isFauxProperty(property); fauxProperty = isFauxProperty(property);