Various code improvements from IntelliJ inspections

This commit is contained in:
Graham Triggs 2017-09-18 00:21:04 +01:00
parent 0ae8d005e4
commit 4859eb7da1
267 changed files with 879 additions and 1400 deletions

View file

@ -134,10 +134,7 @@ public class XMLUtils {
Transformer transformer = null;
try {
transformer = TransformerFactory.newInstance().newTransformer();
} catch (TransformerConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerFactoryConfigurationError e) {
} catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -164,10 +161,7 @@ public class XMLUtils {
Transformer transformer = null;
try {
transformer = TransformerFactory.newInstance().newTransformer();
} catch (TransformerConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerFactoryConfigurationError e) {
} catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vedit.beans;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
public class DynamicField {

View file

@ -32,7 +32,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class BaseEditController extends VitroHttpServlet {

View file

@ -129,27 +129,31 @@ public class OperationController extends BaseEditController {
notifyChangeListeners(epo, action);
/* send the user somewhere */
if (action.equals("insert")){
switch (action) {
case "insert":
// Object[] args = new Object[1];
// args[0] = result;
// epo.setNewBean(epo.getGetMethod().invoke(facade,args));
PageForwarder pipf = epo.getPostInsertPageForwarder();
if (pipf != null){
pipf.doForward(request,response,epo);
if (pipf != null) {
pipf.doForward(request, response, epo);
return;
}
} else if (action.equals("update")){
break;
case "update":
PageForwarder pupf = epo.getPostUpdatePageForwarder();
if (pupf != null) {
pupf.doForward(request,response,epo);
pupf.doForward(request, response, epo);
return;
}
} else if (action.equals("delete")){
break;
case "delete":
PageForwarder pdpf = epo.getPostDeletePageForwarder();
if (pdpf != null) {
pdpf.doForward(request,response,epo);
pdpf.doForward(request, response, epo);
return;
}
break;
}
//if no page forwarder was set, just go back to referring page:
@ -170,7 +174,6 @@ public class OperationController extends BaseEditController {
try {
retry(request, response, epo);
return;
} catch (IOException ioe) {
log.error(this.getClass().getName() + " IOError on redirect: ", ioe);
}
@ -198,7 +201,6 @@ public class OperationController extends BaseEditController {
} else {
response.sendRedirect(getDefaultLandingPage(request));
}
return;
}
private void runPreprocessors(EditProcessObject epo, Object newObj) {
@ -256,14 +258,14 @@ public class OperationController extends BaseEditController {
List validatorList = (List) epo.getValidatorMap().get(currParam);
if (validatorList != null) {
Iterator valIt = validatorList.iterator();
String errMsg = "";
StringBuilder errMsg = new StringBuilder();
while (valIt.hasNext()){
Validator val = (Validator)valIt.next();
ValidationObject vo = val.validate(currValue);
if (!vo.getValid()){
valid = false;
fieldValid = false;
errMsg += vo.getMessage() + " ";
errMsg.append(vo.getMessage()).append(" ");
epo.getBadValueMap().put(currParam,currValue);
} else {
try {
@ -273,7 +275,7 @@ public class OperationController extends BaseEditController {
}
}
if (errMsg.length()>0) {
epo.getErrMsgMap().put(currParam,errMsg);
epo.getErrMsgMap().put(currParam, errMsg.toString());
log.info("doPost() putting error message "+errMsg+" for "+currParam);
}
}
@ -330,12 +332,17 @@ public class OperationController extends BaseEditController {
Iterator<ChangeListener> changeIt = changeListeners.iterator();
while (changeIt.hasNext()) {
ChangeListener cl = changeIt.next();
if (action.equals("insert"))
cl.doInserted(epo.getNewBean(),epo);
else if (action.equals("update"))
cl.doUpdated(epo.getOriginalBean(),epo.getNewBean(),epo);
else if (action.equals("delete"))
cl.doDeleted(epo.getOriginalBean(),epo);
switch (action) {
case "insert":
cl.doInserted(epo.getNewBean(), epo);
break;
case "update":
cl.doUpdated(epo.getOriginalBean(), epo.getNewBean(), epo);
break;
case "delete":
cl.doDeleted(epo.getOriginalBean(), epo);
break;
}
}
}
}
@ -499,8 +506,6 @@ public class OperationController extends BaseEditController {
} catch (InvocationTargetException f) {
log.error(f.getTargetException().getMessage());
}
} catch (NoSuchMethodException e) {
//log.error("doPost() could not find setId() method for "+partialClassName);
} catch (Exception f) {
//log.error("doPost() could not set id of new bean.");
}

View file

@ -4,11 +4,8 @@ package edu.cornell.mannlib.vedit.forwarder.impl;
import java.io.IOException;
import java.net.URLEncoder;
import edu.cornell.mannlib.vedit.forwarder.PageForwarder;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View file

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Iterator;
import java.io.File;
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
@ -16,18 +15,14 @@ import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter;
import javax.servlet.ServletException;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.beans.DynamicField;
import edu.cornell.mannlib.vedit.beans.DynamicFieldRow;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringEscapeUtils;
import edu.cornell.mannlib.vedit.tags.EditTag;
public class DynamicFieldsTag extends EditTag {
@ -63,7 +58,7 @@ public class DynamicFieldsTag extends EditTag {
int templateStart = -1;
int postStart = -1;
InputStream fis = new FileInputStream (pageContext.getServletContext().getRealPath(new String())+PATH_SEP+MARKUP_FILE_PATH+usePage);
InputStream fis = new FileInputStream (pageContext.getServletContext().getRealPath("")+PATH_SEP+MARKUP_FILE_PATH+usePage);
InputStream bis = new BufferedInputStream(fis);
BufferedReader in = new BufferedReader(new InputStreamReader(bis));
List<String> lines = new ArrayList<String>();
@ -83,9 +78,9 @@ public class DynamicFieldsTag extends EditTag {
}
in.close();
StringBuffer preMarkupB = new StringBuffer();
StringBuffer postMarkupB = new StringBuffer();
StringBuffer templateMarkupB = new StringBuffer();
StringBuilder preMarkupB = new StringBuilder();
StringBuilder postMarkupB = new StringBuilder();
StringBuilder templateMarkupB = new StringBuilder();
if (templateStart>preStart && preStart>0) {
for (int i=preStart+1; i<templateStart; i++) {
@ -119,16 +114,16 @@ public class DynamicFieldsTag extends EditTag {
postMarkup = postMarkupB.toString();
} catch (FileNotFoundException e) {
System.out.println("DynamicFieldsTag could not find markup file at "+pageContext.getServletContext().getRealPath(new String())+"\\"+MARKUP_FILE_PATH+usePage);
System.out.println("DynamicFieldsTag could not find markup file at "+pageContext.getServletContext().getRealPath("")+"\\"+MARKUP_FILE_PATH+usePage);
} catch (IOException ioe) {
System.out.println("DynamicFieldsTag encountered IOException reading "+pageContext.getServletContext().getRealPath(new String())+"\\"+MARKUP_FILE_PATH+usePage);
System.out.println("DynamicFieldsTag encountered IOException reading "+pageContext.getServletContext().getRealPath("")+"\\"+MARKUP_FILE_PATH+usePage);
}
}
public String strReplace(String input, String pattern, String replacement) {
String[] piece = input.split(pattern);
StringBuffer output = new StringBuffer();
StringBuilder output = new StringBuilder();
for (int i=0; i<piece.length; i++) {
output.append(piece[i]);
if (i<piece.length-1)
@ -149,7 +144,7 @@ public class DynamicFieldsTag extends EditTag {
int i = 9899;
while (dynIt.hasNext()) {
DynamicField dynf = dynIt.next();
StringBuffer genTaName = new StringBuffer().append("_").append(dynf.getTable()).append("_");
StringBuilder genTaName = new StringBuilder().append("_").append(dynf.getTable()).append("_");
genTaName.append("-1").append("_");
Iterator pparamIt = dynf.getRowTemplate().getParameterMap().keySet().iterator();
while(pparamIt.hasNext()) {
@ -160,7 +155,7 @@ public class DynamicFieldsTag extends EditTag {
}
String preWithVars = new String(preMarkup);
String preWithVars = preMarkup;
preWithVars = strReplace(preWithVars,type+"NN",Integer.toString(i));
preWithVars = strReplace(preWithVars,"\\$genTaName",genTaName.toString());
preWithVars = strReplace(preWithVars,"\\$fieldName",dynf.getName());
@ -174,7 +169,7 @@ public class DynamicFieldsTag extends EditTag {
if (row.getValue()==null)
row.setValue("");
if (row.getValue().length()>0) {
StringBuffer taName = new StringBuffer().append("_").append(dynf.getTable()).append("_");
StringBuilder taName = new StringBuilder().append("_").append(dynf.getTable()).append("_");
taName.append(row.getId()).append("_");
Iterator paramIt = row.getParameterMap().keySet().iterator();
while(paramIt.hasNext()) {
@ -184,7 +179,7 @@ public class DynamicFieldsTag extends EditTag {
taName.append(key).append(":").append(new String(valueInBase64)).append(";");
}
if (row.getValue().length()>0) {
String templateWithVars = new String(templateMarkup);
String templateWithVars = templateMarkup;
templateWithVars = strReplace(templateWithVars,type+"NN",Integer.toString(i));
templateWithVars = strReplace(templateWithVars,"\\$taName",taName.toString());
templateWithVars = strReplace(templateWithVars,"\\$\\$",row.getValue());
@ -199,14 +194,14 @@ public class DynamicFieldsTag extends EditTag {
// output the row template for the javascript to clone
out.println("<!-- row template inserted by DynamicFieldsTag -->");
String hiddenTemplatePreMarkup = new String(preMarkup);
String hiddenTemplatePreMarkup = preMarkup;
// bit of a hack to hide the template from the user:
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:none\\;","");
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:block\\;","");
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:inline\\;","");
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"style\\=\\\"","style=\"display:none;");
out.print(hiddenTemplatePreMarkup);
String hiddenTemplateTemplateMarkup = new String(templateMarkup);
String hiddenTemplateTemplateMarkup = templateMarkup;
hiddenTemplateTemplateMarkup = strReplace(hiddenTemplateTemplateMarkup, "\\$\\$", "");
out.print(hiddenTemplateTemplateMarkup);
out.print(postMarkup);

View file

@ -5,13 +5,10 @@ package edu.cornell.mannlib.vedit.tags;
import java.util.HashMap;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject;
import org.apache.commons.lang3.StringEscapeUtils;
public class EditTag extends TagSupport {
private String name = null;

View file

@ -3,9 +3,8 @@
package edu.cornell.mannlib.vedit.tags;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.tags.EditTag;
import org.apache.commons.lang3.StringEscapeUtils;

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vedit.tags;
import java.util.HashMap;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter;
import edu.cornell.mannlib.vedit.beans.FormObject;
import org.apache.commons.lang3.StringEscapeUtils;

View file

@ -226,7 +226,7 @@ public class FormUtils {
Option sOpt = new Option();
sOpt.setValue(selectedValue);
if (selectedBody == null || selectedBody.length() == 0)
sOpt.setBody(selectedValue.toString());
sOpt.setBody(selectedValue);
else
sOpt.setBody(selectedBody);
sOpt.setSelected(true);

View file

@ -71,7 +71,7 @@ class Stemmer
public void add(char ch)
{ if (i == b.length)
{ char[] new_b = new char[i+INC];
for (int c = 0; c < i; c++) new_b[c] = b[c];
System.arraycopy(b, 0, new_b, 0, i);
b = new_b;
}
b[i++] = ch;
@ -86,7 +86,7 @@ class Stemmer
public void add(char[] w, int wLen)
{ if (i+wLen >= b.length)
{ char[] new_b = new char[i+wLen+INC];
for (int c = 0; c < i; c++) new_b[c] = b[c];
System.arraycopy(b, 0, new_b, 0, i);
b = new_b;
}
for (int c = 0; c < wLen; c++) b[i++] = w[c];
@ -116,7 +116,7 @@ class Stemmer
private final boolean cons(int i)
{ switch (b[i])
{ case 'a': case 'e': case 'i': case 'o': case 'u': return false;
case 'y': return (i==0) ? true : !cons(i-1);
case 'y': return (i == 0) || !cons(i - 1);
default: return true;
}
}
@ -368,7 +368,7 @@ class Stemmer
public static String StemString( String inputStr, int maxLength )
{
String outputStr="";
StringBuilder outputStr= new StringBuilder();
int previousCh=0;
char[] w = new char[maxLength];
@ -396,19 +396,19 @@ class Stemmer
{
String u;
u = s.toString();
outputStr += u;
outputStr.append(u);
if ( ch == '-' ) { // replace - with space
outputStr += " ";
outputStr.append(" ");
} else if ( ch == '.' ) {
if ( Character.isDigit( (char) previousCh )) {
outputStr += ".";
outputStr.append(".");
} else {
outputStr += " ";
outputStr.append(" ");
//previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass
}
} else {
Character Ch = new Character((char) ch);
outputStr += Ch.toString();
outputStr.append(Ch.toString());
}
stemmerInputBufferIndex=0; // to avoid repeats after )
}
@ -422,7 +422,7 @@ class Stemmer
if ( !Character.isWhitespace((char) previousCh ) ) {
if ( previousCh != '.' ) {
Character Ch = new Character((char) ch);
outputStr += Ch.toString();
outputStr.append(Ch.toString());
}
}
} else if ( ch == '(' ) { // open paren; copy all characters until close paren
@ -449,21 +449,21 @@ class Stemmer
stemmerInputBufferIndex=0;
} else if ( ch == ')' ) { // when is last character of input string
Character Ch = new Character((char) ch);
outputStr += Ch.toString();
outputStr.append(Ch.toString());
log.trace( Ch.toString() );
log.trace("found close paren at position: " + inputArrayIndex + " of input term " + inputStr );
} else if ( ch == '-' ) { // replace - with space
outputStr += " ";
outputStr.append(" ");
} else if ( ch == '.' ) {
if ( Character.isDigit( (char) previousCh )) {
outputStr += ".";
outputStr.append(".");
} else {
outputStr += " ";
outputStr.append(" ");
//previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass
}
} else {
Character Ch = new Character((char) ch);
outputStr += Ch.toString();
outputStr.append(Ch.toString());
}
previousCh = ch;
if (ch < 0) break;
@ -477,10 +477,10 @@ class Stemmer
String u;
u = s.toString();
outputStr += u;
outputStr.append(u);
}
return outputStr == null ? ( outputStr.equals("") ? null : outputStr.trim() ) : outputStr.trim();
return outputStr == null || outputStr.length() == 0 ? null : outputStr.toString().trim();
}
/*

View file

@ -3,6 +3,8 @@
package edu.cornell.mannlib.vedit.validator.impl;
import edu.cornell.mannlib.vedit.validator.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@ -17,17 +19,17 @@ public class EnumValuesValidator implements Validator {
} else {
vo.setValid(false);
if (legalValues.size()<7){
String msgString = "Please enter one of ";
StringBuilder msgString = new StringBuilder("Please enter one of ");
Iterator valuesIt = legalValues.iterator();
while (valuesIt.hasNext()) {
String legalValue = (String) valuesIt.next();
msgString += "'"+legalValue+"'";
msgString.append("'").append(legalValue).append("'");
if (valuesIt.hasNext())
msgString += ", ";
msgString.append(", ");
else
msgString += ".";
msgString.append(".");
}
vo.setMessage(msgString);
vo.setMessage(msgString.toString());
}
else {
vo.setMessage("Please enter a legal value.");
@ -38,7 +40,6 @@ public class EnumValuesValidator implements Validator {
}
public EnumValuesValidator (String[] legalValues){
for (int i=0; i<legalValues.length; i++)
this.legalValues.add(legalValues[i]);
Collections.addAll(this.legalValues, legalValues);
}
}

View file

@ -24,10 +24,10 @@ public class UrlValidator implements Validator {
IRIFactory factory = IRIFactory.jenaImplementation();
IRI iri = factory.create((String) obj);
if (iri.hasViolation(false) ) {
String errorStr = "";
StringBuilder errorStr = new StringBuilder();
Iterator<Violation> violIt = iri.violations(false);
while(violIt.hasNext()) {
errorStr += violIt.next().getShortMessage() + " ";
errorStr.append(violIt.next().getShortMessage()).append(" ");
}
vo.setValid(false);
vo.setMessage("Please enter a valid URL. " + errorStr);

View file

@ -159,8 +159,8 @@ public class VitroHomeDirectory {
VHD_BUILD_PROPERTY);
throw new IllegalStateException(message);
} else if (foundLocations.size() > 1) {
String message = String.format("Found multiple values for the "
+ "Vitro home directory: " + foundLocations);
String message = "Found multiple values for the "
+ "Vitro home directory: " + foundLocations;
log.warn(message);
}
}

View file

@ -145,11 +145,8 @@ public class PropertyRestrictionBeanImpl extends PropertyRestrictionBean {
if (resourceUri == null || userRole == null) {
return false;
}
if (prohibitedNamespaces.contains(namespace(resourceUri))
&& !permittedExceptions.contains(resourceUri)) {
return false;
}
return true;
return !prohibitedNamespaces.contains(namespace(resourceUri))
|| permittedExceptions.contains(resourceUri);
}
@Override
@ -241,9 +238,7 @@ public class PropertyRestrictionBeanImpl extends PropertyRestrictionBean {
StringBuilder buffer = new StringBuilder();
for (FullPropertyKey key : keys) {
buffer.append(key + " " + thresholdMap.get(key).getLevel(DISPLAY)
+ " " + thresholdMap.get(key).getLevel(MODIFY) + " "
+ thresholdMap.get(key).getLevel(PUBLISH) + "\n");
buffer.append(key).append(" ").append(thresholdMap.get(key).getLevel(DISPLAY)).append(" ").append(thresholdMap.get(key).getLevel(MODIFY)).append(" ").append(thresholdMap.get(key).getLevel(PUBLISH)).append("\n");
}
return buffer.toString();

View file

@ -6,7 +6,6 @@ import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAct
import org.apache.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
import edu.cornell.mannlib.vitro.webapp.beans.Property;

View file

@ -7,8 +7,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

View file

@ -51,7 +51,7 @@ public class DataPropertyComparator implements Comparator<Individual> {
if (XSD.xint.toString().equals(datatype)) {
int i1 = Integer.valueOf(dps1.getData());
int i2 = Integer.valueOf(dps2.getData());
result = ((Integer) i1).compareTo(i2);
result = Integer.compare(i1, i2);
}
else if (XSD.xstring.toString().equals(datatype)) {
result = dps1.getData().compareTo(dps2.getData());

View file

@ -2,10 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
import org.apache.jena.rdf.model.Property;
/**
* a class representing a particular instance of a data property
*

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
/**
* a class representing an particular instance of a data property
*

View file

@ -576,16 +576,16 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
* @return Readable text identifying this property's attributes
*/
public String toString(){
String list = "null";
StringBuilder list = new StringBuilder("null");
if( getObjectPropertyStatements() != null ){
Iterator it = getObjectPropertyStatements().iterator();
if( !it.hasNext() ) list = " none";
if( !it.hasNext() ) list = new StringBuilder(" none");
while(it.hasNext()){
Object obj = it.next();
if( obj != null && obj instanceof ObjectPropertyStatement){
list += "\n\t\t" + ((ObjectPropertyStatement)obj).toString();
list.append("\n\t\t").append(((ObjectPropertyStatement) obj).toString());
}else{
list += "\n\t\t" + obj.toString();
list.append("\n\t\t").append(obj.toString());
}
}
}

View file

@ -1,7 +1,6 @@
/* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
public interface ObjectPropertyStatement {

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Comparator;
import java.util.Date;
/**
* a class representing a particular instance of an object property

View file

@ -45,8 +45,7 @@ public class PermissionSet {
}
public void setForNewUsers(Boolean forNewUsers) {
this.forNewUsers = (forNewUsers == null) ? false
: forNewUsers.booleanValue();
this.forNewUsers = (forNewUsers != null) && forNewUsers.booleanValue();
}
public boolean isForPublic() {
@ -54,8 +53,7 @@ public class PermissionSet {
}
public void setForPublic(Boolean forPublic) {
this.forPublic = (forPublic == null) ? false
: forPublic.booleanValue();
this.forPublic = (forPublic != null) && forPublic.booleanValue();
}
public Set<String> getPermissionUris() {

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
/**
Represents a Vitro object property instance. It includes values
from the entities, object property statements, properties, and ent2relationships tables

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
public interface PropertyInstanceIface {
//needed for PropertyInstance
//object property statements

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.config;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

View file

@ -104,30 +104,30 @@ public class MailUsersServlet extends VitroHttpServlet {
comments=comments.trim();
//Removed spam filtering code
StringBuffer msgBuf = new StringBuffer(); // contains the intro copy for the body of the email message
StringBuilder msgBuf = new StringBuilder(); // contains the intro copy for the body of the email message
String lineSeparator = System.getProperty("line.separator"); // \r\n on windows, \n on unix
// from MyLibrary
msgBuf.setLength(0);
//msgBuf.append("Content-Type: text/html; charset='us-ascii'" + lineSeparator);
msgBuf.append("<html>" + lineSeparator );
msgBuf.append("<head>" + lineSeparator );
msgBuf.append("<style>a {text-decoration: none}</style>" + lineSeparator );
msgBuf.append("<title>" + deliveryfrom + "</title>" + lineSeparator );
msgBuf.append("</head>" + lineSeparator );
msgBuf.append("<body>" + lineSeparator );
msgBuf.append("<h4>" + deliveryfrom + "</h4>" + lineSeparator );
msgBuf.append("<h4>From: "+webusername +" (" + webuseremail + ")"+" at IP address "+request.getRemoteAddr()+"</h4>"+lineSeparator);
msgBuf.append("<html>").append(lineSeparator);
msgBuf.append("<head>").append(lineSeparator);
msgBuf.append("<style>a {text-decoration: none}</style>").append(lineSeparator);
msgBuf.append("<title>").append(deliveryfrom).append("</title>").append(lineSeparator);
msgBuf.append("</head>").append(lineSeparator);
msgBuf.append("<body>").append(lineSeparator);
msgBuf.append("<h4>").append(deliveryfrom).append("</h4>").append(lineSeparator);
msgBuf.append("<h4>From: ").append(webusername).append(" (").append(webuseremail).append(")").append(" at IP address ").append(request.getRemoteAddr()).append("</h4>").append(lineSeparator);
//Don't need any 'likely viewing page' portion to be emailed out to the others
msgBuf.append(lineSeparator + "</i></p><h3>Comments:</h3>" + lineSeparator );
msgBuf.append(lineSeparator).append("</i></p><h3>Comments:</h3>").append(lineSeparator);
if (comments==null || comments.equals("")) {
msgBuf.append("<p>BLANK MESSAGE</p>");
} else {
msgBuf.append("<p>"+comments+"</p>");
msgBuf.append("<p>").append(comments).append("</p>");
}
msgBuf.append("</body>" + lineSeparator );
msgBuf.append("</html>" + lineSeparator );
msgBuf.append("</body>").append(lineSeparator);
msgBuf.append("</html>").append(lineSeparator);
String msgText = msgBuf.toString();

View file

@ -58,7 +58,6 @@ public class OntologyController extends VitroHttpServlet{
if( rdfFormat != null ){
doRdf(req, res, rdfFormat );
return;
}
}
@ -159,7 +158,6 @@ public class OntologyController extends VitroHttpServlet{
if( ! found ){
//respond to HTTP outside of critical section
doNotFound(req,res);
return;
} else {
JenaOutputUtils.setNameSpacePrefixes(newModel,vreq.getWebappDaoFactory());
res.setContentType(rdfFormat.getMediaType());
@ -172,7 +170,6 @@ public class OntologyController extends VitroHttpServlet{
format ="TTL";
newModel.write( res.getOutputStream(), format );
return;
}
}

View file

@ -87,7 +87,6 @@ public class SparqlQueryBuilderServlet extends BaseEditController {
}
doHelp(request,response);
return;
}
private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res){

View file

@ -127,7 +127,6 @@ public class UserAccountsEditPage extends UserAccountsPage {
+ "but is not authorized to do so. Logged in as: "
+ LoginStatusBean.getCurrentUser(vreq));
bogusMessage = getBogusStandardMessage(vreq);
return;
}
}
}

View file

@ -126,7 +126,6 @@ public class UserAccountsFirstTimeExternalPage extends UserAccountsPage {
}
if (!Authenticator.getInstance(vreq).isUserPermittedToLogin(null)) {
bogusMessage = i18n.text("logins_disabled_for_maintenance");
return;
}
}

View file

@ -121,7 +121,6 @@ public abstract class UserAccountsPasswordBasePage extends UserAccountsPage {
+ "' when already logged in as '" + currentUserEmail
+ "'");
bogusMessage = alreadyLoggedInMessage(currentUserEmail);
return;
}
}
}

View file

@ -61,7 +61,6 @@ public class SparqlQueryAjaxController extends VitroAjaxController {
String queryParam = locateQueryParam(vreq);
Query query = SparqlUtils.createQuery(queryParam);
SparqlUtils.executeQuery(response, query, model);
return;
} catch (AjaxControllerException e) {
log.error(e.getMessage());
response.sendError(e.getStatusCode());

View file

@ -9,7 +9,6 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Collection;
import org.apache.commons.io.IOUtils;

View file

@ -197,11 +197,7 @@ public abstract class Authenticator {
// InternetAddress permits a localname without hostname.
// Guard against that.
if (emailAddress.indexOf('@') == -1) {
return false;
}
return true;
return emailAddress.indexOf('@') != -1;
} catch (AddressException e) {
return false;
}

View file

@ -104,13 +104,11 @@ public class LoginExternalAuthReturn extends BaseLoginServlet {
getAuthenticator(req).recordLoginAgainstUserAccount(userAccount,
AuthenticationSource.EXTERNAL);
new LoginRedirector(req, afterLoginUrl).redirectLoggedInUser(resp);
return;
} catch (LoginNotPermitted e) {
// should have been caught by isUserPermittedToLogin()
log.debug("Logins disabled for " + userAccount);
complainAndReturnToReferrer(req, resp, ATTRIBUTE_REFERRER,
messageLoginDisabled(req));
return;
}
}

View file

@ -144,7 +144,6 @@ public class ProgramLogin extends HttpServlet {
}
recordLoginWithPasswordChange();
sendSuccess(MESSAGE_SUCCESS_FIRST_TIME);
return;
}
}

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
@ -22,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
/**

View file

@ -95,11 +95,7 @@ class NQuadLineSplitter {
while (!atEnd() && isWhiteSpace()) {
i++;
}
if (atEnd()) {
return;
} else if (line.charAt(i) == '#') {
return;
} else {
if (!atEnd() && line.charAt(i) != '#') {
throw new BadNodeException(
"Period was not followed by end of line: '" + line + "'");
}

View file

@ -351,7 +351,6 @@ public class Authenticate extends VitroHttpServlet {
// This should have been caught by isUserPermittedToLogin()
bean.setMessage(request, ERROR,
"logins_disabled_for_maintenance");
return;
}
}
}
@ -413,7 +412,6 @@ public class Authenticate extends VitroHttpServlet {
} catch (LoginNotPermitted e) {
// This should have been caught by isUserPermittedToLogin()
bean.setMessage(request, ERROR, "logins_disabled_for_maintenance");
return;
}
}
@ -497,7 +495,6 @@ public class Authenticate extends VitroHttpServlet {
String loginProcessPage = LoginProcessBean.getBean(vreq)
.getLoginPageUrl();
response.sendRedirect(loginProcessPage);
return;
}
/**

View file

@ -73,15 +73,19 @@ public class Classes2ClassesOperationController extends BaseEditController {
String superclassURIstr = request.getParameter("SuperclassURI");
if (superclassURIstr != null) {
for (int i=0; i<subclassURIstrs.length; i++) {
if (modeStr.equals("disjointWith")) {
switch (modeStr) {
case "disjointWith":
vcDao.removeDisjointWithClass(superclassURIstr, subclassURIstrs[i]);
} else if (modeStr.equals("equivalentClass")) {
break;
case "equivalentClass":
vcDao.removeEquivalentClass(superclassURIstr, subclassURIstrs[i]);
} else {
break;
default:
Classes2Classes c2c = new Classes2Classes();
c2c.setSubclassURI(subclassURIstrs[i]);
c2c.setSuperclassURI(superclassURIstr);
vcDao.deleteClasses2Classes(c2c);
break;
}
}
}
@ -90,29 +94,37 @@ public class Classes2ClassesOperationController extends BaseEditController {
String[] superclassURIstrs = request.getParameterValues("SuperclassURI");
if (superclassURIstrs != null) {
for (int i=0; i<superclassURIstrs.length; i++) {
if (modeStr.equals("disjointWith")) {
vcDao.removeDisjointWithClass(superclassURIstrs[i],subclassURIstr);
} else if (modeStr.equals("equivalentClass")) {
vcDao.removeEquivalentClass(subclassURIstr,superclassURIstrs[i]);
} else {
switch (modeStr) {
case "disjointWith":
vcDao.removeDisjointWithClass(superclassURIstrs[i], subclassURIstr);
break;
case "equivalentClass":
vcDao.removeEquivalentClass(subclassURIstr, superclassURIstrs[i]);
break;
default:
Classes2Classes c2c = new Classes2Classes();
c2c.setSuperclassURI(superclassURIstrs[i]);
c2c.setSubclassURI(subclassURIstr);
vcDao.deleteClasses2Classes(c2c);
break;
}
}
}
}
} else if (request.getParameter("operation").equals("add")) {
if (modeStr.equals("disjointWith")) {
switch (modeStr) {
case "disjointWith":
vcDao.addDisjointWithClass(request.getParameter("SuperclassURI"), request.getParameter("SubclassURI"));
} else if (modeStr.equals("equivalentClass")) {
break;
case "equivalentClass":
vcDao.addEquivalentClass(request.getParameter("SuperclassURI"), request.getParameter("SubclassURI"));
} else {
break;
default:
Classes2Classes c2c = new Classes2Classes();
c2c.setSuperclassURI(request.getParameter("SuperclassURI"));
c2c.setSubclassURI(request.getParameter("SubclassURI"));
vcDao.insertNewClasses2Classes(c2c);
break;
}
}
} catch (Exception e) {

View file

@ -68,7 +68,7 @@ public class ClassgroupRetryController extends BaseEditController {
}
if (vclassGroupForEditing == null) {
//UTF-8 expected due to URIEncoding on Connector in server.xml
String uriToFind = new String(request.getParameter("uri"));
String uriToFind = request.getParameter("uri");
vclassGroupForEditing = (VClassGroup)cgDao.getGroupByURI(uriToFind);
}
} else {

View file

@ -95,7 +95,7 @@ public class EntityEditController extends BaseEditController {
}
results.add(rName);
String classStr = "";
StringBuilder classStr = new StringBuilder();
List<VClass> classList = inferredEnt.getVClasses(false);
sortForPickList(classList, vreq);
if (classList != null) {
@ -109,13 +109,13 @@ public class EntityEditController extends BaseEditController {
} catch (Exception e) {
rClassName = vc.getLocalNameWithPrefix();
}
classStr += rClassName;
classStr.append(rClassName);
if (classIt.hasNext()) {
classStr += ", ";
classStr.append(", ");
}
}
}
results.add(classStr);
results.add(classStr.toString());
results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified"
: ent.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel());
@ -147,7 +147,7 @@ public class EntityEditController extends BaseEditController {
Iterator<DataPropertyStatement> externalIdIt = ent.getExternalIds().iterator();
while (externalIdIt.hasNext()) {
DataPropertyStatement eid = externalIdIt.next();
String multiplexedString = new String ("DatapropURI:" + new String(Base64.encodeBase64(eid.getDatapropURI().getBytes())) + ";" + "Data:" + new String(Base64.encodeBase64(eid.getData().getBytes())));
String multiplexedString = "DatapropURI:" + new String(Base64.encodeBase64(eid.getDatapropURI().getBytes())) + ";" + "Data:" + new String(Base64.encodeBase64(eid.getData().getBytes()));
externalIdOptionList.add(new Option(multiplexedString, eid.getData()));
}
}
@ -172,7 +172,7 @@ public class EntityEditController extends BaseEditController {
Iterator<PropertyInstance> epiIt = epiColl.iterator();
while (epiIt.hasNext()) {
PropertyInstance pi = epiIt.next();
String multiplexedString = new String ("PropertyURI:" + new String(Base64.encodeBase64(pi.getPropertyURI().getBytes())) + ";" + "ObjectEntURI:" + new String(Base64.encodeBase64(pi.getObjectEntURI().getBytes())));
String multiplexedString = "PropertyURI:" + new String(Base64.encodeBase64(pi.getPropertyURI().getBytes())) + ";" + "ObjectEntURI:" + new String(Base64.encodeBase64(pi.getObjectEntURI().getBytes()));
epiOptionList.add(new Option(multiplexedString, pi.getDomainPublic()+" "+pi.getObjectName()));
}
OptionMap.put("ExistingPropertyInstances", epiOptionList);

View file

@ -102,12 +102,9 @@ public class Properties2PropertiesOperationController extends
}
}
} catch (RuntimeException e) {
} catch (RuntimeException | Error e) {
log.error("Unable to perform edit operation: ", e);
throw e;
} catch (Error err) {
log.error("Unable to perform edit operation: ", err);
throw err;
}
}

View file

@ -67,7 +67,7 @@ public class PropertyGroupRetryController extends BaseEditController {
}
if (propertyGroupForEditing == null) {
// UTF-8 expected due to URIEncoding on Connector element in server.xml
String uriToFind = new String(request.getParameter("uri"));
String uriToFind = request.getParameter("uri");
propertyGroupForEditing = (PropertyGroup)pgDao.getGroupByURI(uriToFind);
}
} else {

View file

@ -493,12 +493,16 @@ public class RefactorOperationController extends BaseEditController {
if (vreq.getParameter("_cancel") == null) {
if (modeStr != null) {
if (modeStr.equals("renameResource")) {
switch (modeStr) {
case "renameResource":
redirectStr = doRenameResource(vreq, response, epo);
} else if (modeStr.equals("movePropertyStatements")) {
break;
case "movePropertyStatements":
doMovePropertyStatements(vreq, response, epo);
} else if (modeStr.equals("moveInstances")) {
break;
case "moveInstances":
doMoveInstances(vreq, response, epo);
break;
}
}
}

View file

@ -108,12 +108,16 @@ public class RefactorRetryController extends BaseEditController {
String modeStr = request.getParameter("mode");
if (modeStr != null) {
if (modeStr.equals("renameResource")) {
switch (modeStr) {
case "renameResource":
doRenameResource(vreq, response, epo);
} else if (modeStr.equals("movePropertyStatements")) {
break;
case "movePropertyStatements":
doMovePropertyStatements(vreq, response, epo);
} else if (modeStr.equals("moveInstances")) {
break;
case "moveInstances":
doMoveInstances(vreq, response, epo);
break;
}
}

View file

@ -83,7 +83,6 @@ public class RestrictionOperationController extends BaseEditController {
log.error(e, e);
try {
response.sendRedirect(defaultLandingPage);
return;
} catch (Exception f) {
log.error(f, f);
throw new RuntimeException(f);
@ -177,11 +176,14 @@ public class RestrictionOperationController extends BaseEditController {
cardinality = Integer.decode(cardinalityStr);
}
if (restrictionTypeStr.equals("allValuesFrom")) {
rest = ontModel.createAllValuesFromRestriction(null,onProperty,roleFiller);
} else if (restrictionTypeStr.equals("someValuesFrom")) {
rest = ontModel.createSomeValuesFromRestriction(null,onProperty,roleFiller);
} else if (restrictionTypeStr.equals("hasValue")) {
switch (restrictionTypeStr) {
case "allValuesFrom":
rest = ontModel.createAllValuesFromRestriction(null, onProperty, roleFiller);
break;
case "someValuesFrom":
rest = ontModel.createSomeValuesFromRestriction(null, onProperty, roleFiller);
break;
case "hasValue":
String valueURI = request.getParameter("ValueIndividual");
if (valueURI != null) {
Resource valueRes = ontModel.getResource(valueURI);
@ -198,7 +200,7 @@ public class RestrictionOperationController extends BaseEditController {
try {
dtype = TypeMapper.getInstance().getSafeTypeByName(valueDatatype);
} catch (Exception e) {
log.warn ("Unable to get safe type " + valueDatatype + " using TypeMapper");
log.warn("Unable to get safe type " + valueDatatype + " using TypeMapper");
}
if (dtype != null) {
value = ontModel.createTypedLiteral(valueLexicalForm, dtype);
@ -211,12 +213,16 @@ public class RestrictionOperationController extends BaseEditController {
rest = ontModel.createHasValueRestriction(null, onProperty, value);
}
}
} else if (restrictionTypeStr.equals("minCardinality")) {
rest = ontModel.createMinCardinalityRestriction(null,onProperty,cardinality);
} else if (restrictionTypeStr.equals("maxCardinality")) {
rest = ontModel.createMaxCardinalityRestriction(null,onProperty,cardinality);
} else if (restrictionTypeStr.equals("cardinality")) {
rest = ontModel.createCardinalityRestriction(null,onProperty,cardinality);
break;
case "minCardinality":
rest = ontModel.createMinCardinalityRestriction(null, onProperty, cardinality);
break;
case "maxCardinality":
rest = ontModel.createMaxCardinalityRestriction(null, onProperty, cardinality);
break;
case "cardinality":
rest = ontModel.createCardinalityRestriction(null, onProperty, cardinality);
break;
}
if (conditionTypeStr.equals("necessary")) {

View file

@ -67,27 +67,36 @@ public class RestrictionRetryController extends BaseEditController {
epo.setFormObject(new FormObject());
epo.getFormObject().getOptionLists().put("onProperty", onPropertyList);
if (restrictionTypeStr.equals("someValuesFrom")) {
request.setAttribute("specificRestrictionForm","someValuesFromRestriction_retry.jsp");
switch (restrictionTypeStr) {
case "someValuesFrom": {
request.setAttribute("specificRestrictionForm", "someValuesFromRestriction_retry.jsp");
List<Option> optionList = (propertyType == OBJECT)
? getValueClassOptionList(request)
: getValueDatatypeOptionList(request) ;
epo.getFormObject().getOptionLists().put("ValueClass",optionList);
} else if (restrictionTypeStr.equals("allValuesFrom")) {
request.setAttribute("specificRestrictionForm","allValuesFromRestriction_retry.jsp");
: getValueDatatypeOptionList(request);
epo.getFormObject().getOptionLists().put("ValueClass", optionList);
break;
}
case "allValuesFrom": {
request.setAttribute("specificRestrictionForm", "allValuesFromRestriction_retry.jsp");
List<Option> optionList = (propertyType == OBJECT)
? getValueClassOptionList(request)
: getValueDatatypeOptionList(request) ;
epo.getFormObject().getOptionLists().put("ValueClass",optionList);
} else if (restrictionTypeStr.equals("hasValue")) {
: getValueDatatypeOptionList(request);
epo.getFormObject().getOptionLists().put("ValueClass", optionList);
break;
}
case "hasValue":
request.setAttribute("specificRestrictionForm", "hasValueRestriction_retry.jsp");
if (propertyType == OBJECT) {
request.setAttribute("propertyType", "object");
} else {
request.setAttribute("propertyType", "data");
}
} else if (restrictionTypeStr.equals("minCardinality") || restrictionTypeStr.equals("maxCardinality") || restrictionTypeStr.equals("cardinality")) {
break;
case "minCardinality":
case "maxCardinality":
case "cardinality":
request.setAttribute("specificRestrictionForm", "cardinalityRestriction_retry.jsp");
break;
}
request.setAttribute("formJsp","/templates/edit/specific/restriction_retry.jsp");

View file

@ -179,7 +179,7 @@ public class VclassEditController extends BaseEditController {
foo.setOptionLists(OptionMap);
epo.setFormObject(foo);
boolean instantiable = (vcl.getURI().equals(OWL.Nothing.getURI())) ? false : true;
boolean instantiable = !vcl.getURI().equals(OWL.Nothing.getURI());
request.setAttribute("epoKey",epo.getKey());
request.setAttribute("vclassWebapp", vcl);

View file

@ -29,17 +29,17 @@ public class ListingControllerWebUtils {
}
public static synchronized String formatVClassLinks(List<VClass> vList) {
String linksStr="";
StringBuilder linksStr= new StringBuilder();
if (vList!=null) {
int count=0;
for (Object obj : vList) {
try {
if (count>0) linksStr += " | ";
if (count>0) linksStr.append(" | ");
VClass vclass = (VClass) obj;
try {
linksStr += "<a href=\"vclassEdit?uri="+URLEncoder.encode(vclass.getURI(),"UTF-8")+"\">"+vclass.getName()+"</a>";
linksStr.append("<a href=\"vclassEdit?uri=").append(URLEncoder.encode(vclass.getURI(), "UTF-8")).append("\">").append(vclass.getName()).append("</a>");
} catch (UnsupportedEncodingException e) {
linksStr += vclass.getName();
linksStr.append(vclass.getName());
}
++count;
} catch (Exception e) {
@ -49,7 +49,7 @@ public class ListingControllerWebUtils {
}
}
}
return linksStr;
return linksStr.toString();
}
}

View file

@ -2,14 +2,10 @@
package edu.cornell.mannlib.vitro.webapp.controller.edit.utils;
import java.util.LinkedList;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;

View file

@ -6,6 +6,7 @@ import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -172,9 +173,7 @@ public class DumpTestController extends FreemarkerHttpServlet {
}
public void setFavoriteColors(String...colors) {
for (String color : colors) {
favoriteColors.add(color);
}
Collections.addAll(favoriteColors, colors);
}
float getSalary() {

View file

@ -250,7 +250,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
// This method does a redirect if the required authorizations are
// not met (and they won't be), so just return.
isAuthorizedToDisplayPage(vreq, response, values.getUnauthorizedAction());
return;
}
protected void doTemplate(VitroRequest vreq, HttpServletResponse response,

View file

@ -164,9 +164,6 @@ public class ImageUploadHelper {
fileInfo);
return fileInfo;
} catch (FileAlreadyExistsException e) {
throw new IllegalStateException("Can't create the new image file.",
e);
} catch (IOException e) {
throw new IllegalStateException("Can't create the new image file.",
e);

View file

@ -50,60 +50,60 @@ public class ListClassGroupsController extends FreemarkerHttpServlet {
List<VClassGroup> groups = dao.getPublicGroupsWithVClasses();
String json = new String();
StringBuilder json = new StringBuilder();
int counter = 0;
if (groups != null) {
for(VClassGroup vcg: groups) {
if ( counter > 0 ) {
json += ", ";
json.append(", ");
}
String publicName = vcg.getPublicName();
if ( StringUtils.isBlank(publicName) ) {
publicName = "(unnamed group)";
}
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI())+"&amp;controller=Classgroup'>"+publicName+"</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./editForm?uri=" + URLEncoder.encode(vcg.getURI()) + "&amp;controller=Classgroup'>" + publicName + "</a>")).append(", ");
} catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(publicName) + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote(publicName)).append(", ");
}
Integer t;
json += "\"data\": { \"displayRank\": \"" + (((t = Integer.valueOf(vcg.getDisplayRank())) != -1) ? t.toString() : "") + "\"}, ";
json.append("\"data\": { \"displayRank\": \"").append(((t = Integer.valueOf(vcg.getDisplayRank())) != -1) ? t.toString() : "").append("\"}, ");
List<VClass> classList = vcg.getVitroClassList();
if (classList != null && classList.size()>0) {
json += "\"children\": [";
json.append("\"children\": [");
Iterator<VClass> classIt = classList.iterator();
while (classIt.hasNext()) {
VClass vcw = classIt.next();
if (vcw.getName() != null && vcw.getURI() != null) {
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI())+"'>"+vcw.getName()+"</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='vclassEdit?uri=" + URLEncoder.encode(vcw.getURI()) + "'>" + vcw.getName() + "</a>")).append(", ");
} catch (Exception e) {
json += "" + JacksonUtils.quote(vcw.getName()) + ", ";
json.append("").append(JacksonUtils.quote(vcw.getName())).append(", ");
}
} else {
json += "\"\", ";
json.append("\"\", ");
}
String shortDefStr = (vcw.getShortDef() == null) ? "" : vcw.getShortDef();
json += "\"data\": { \"shortDef\": " + JacksonUtils.quote(shortDefStr) + "}, \"children\": [] ";
json.append("\"data\": { \"shortDef\": ").append(JacksonUtils.quote(shortDefStr)).append("}, \"children\": [] ");
if (classIt.hasNext())
json += "} , ";
json.append("} , ");
else
json += "}] ";
json.append("}] ");
}
}
else {
json += "\"children\": [] ";
json.append("\"children\": [] ");
}
json += "} ";
json.append("} ");
counter += 1;
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
} catch (Throwable t) {
t.printStackTrace();

View file

@ -100,27 +100,27 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
sortForPickList(props, vreq);
}
String json = new String();
StringBuilder json = new StringBuilder();
int counter = 0;
if (props != null) {
if (props.size()==0) {
json = "{ \"name\": \"" + noResultsMsgStr + "\" }";
json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }");
} else {
for (DataProperty prop: props) {
if ( counter > 0 ) {
json += ", ";
json.append(", ");
}
String nameStr = prop.getPickListName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPickListName();
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='datapropEdit?uri="+ URLEncoder.encode(prop.getURI())+"'>" + nameStr + "</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='datapropEdit?uri=" + URLEncoder.encode(prop.getURI()) + "'>" + nameStr + "</a>")).append(", ");
} catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(nameStr) + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote(nameStr)).append(", ");
}
json += "\"data\": { \"internalName\": " + JacksonUtils.quote(prop.getPickListName()) + ", ";
json.append("\"data\": { \"internalName\": ").append(JacksonUtils.quote(prop.getPickListName())).append(", ");
/* VClass vc = null;
String domainStr="";
@ -140,22 +140,22 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
dpLangNeut = prop;
}
String domainStr = getVClassNameFromURI(dpLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
json += "\"domainVClass\": " + JacksonUtils.quote(domainStr) + ", " ;
json.append("\"domainVClass\": ").append(JacksonUtils.quote(domainStr)).append(", ");
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());
String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName();
json += "\"rangeVClass\": " + JacksonUtils.quote(rangeDatatypeStr) + ", " ;
json.append("\"rangeVClass\": ").append(JacksonUtils.quote(rangeDatatypeStr)).append(", ");
if (prop.getGroupURI() != null) {
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
json += "\"group\": " + JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ;
json.append("\"group\": ").append(JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())).append(" } } ");
} else {
json += "\"group\": \"unspecified\" } }" ;
json.append("\"group\": \"unspecified\" } }");
}
counter += 1;
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
}
} catch (Throwable t) {
t.printStackTrace();

View file

@ -51,30 +51,30 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
PropertyGroupDao dao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES);
String json = new String();
StringBuilder json = new StringBuilder();
int counter = 0;
if (groups != null) {
for(PropertyGroup pg: groups) {
if ( counter > 0 ) {
json += ", ";
json.append(", ");
}
String publicName = pg.getName();
if ( StringUtils.isBlank(publicName) ) {
publicName = "(unnamed group)";
}
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&amp;controller=PropertyGroup'>" + publicName + "</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./editForm?uri=" + URLEncoder.encode(pg.getURI(), "UTF-8") + "&amp;controller=PropertyGroup'>" + publicName + "</a>")).append(", ");
} catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(publicName) + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote(publicName)).append(", ");
}
Integer t;
json += "\"data\": { \"displayRank\": \"" + (((t = Integer.valueOf(pg.getDisplayRank())) != -1) ? t.toString() : "") + "\"}, ";
json.append("\"data\": { \"displayRank\": \"").append(((t = Integer.valueOf(pg.getDisplayRank())) != -1) ? t.toString() : "").append("\"}, ");
List<Property> propertyList = pg.getPropertyList();
if (propertyList != null && propertyList.size()>0) {
json += "\"children\": [";
json.append("\"children\": [");
Iterator<Property> propIt = propertyList.iterator();
while (propIt.hasNext()) {
Property prop = propIt.next();
@ -91,31 +91,31 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
}
if (prop.getURI() != null) {
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='" + controllerStr
+ "?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"+ nameStr +"</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='" + controllerStr
+ "?uri=" + URLEncoder.encode(prop.getURI(), "UTF-8") + "'>" + nameStr + "</a>")).append(", ");
} catch (Exception e) {
json += JacksonUtils.quote(nameStr) + ", ";
json.append(JacksonUtils.quote(nameStr)).append(", ");
}
} else {
json += "\"\", ";
json.append("\"\", ");
}
json += "\"data\": { \"shortDef\": \"\"}, \"children\": [] ";
json.append("\"data\": { \"shortDef\": \"\"}, \"children\": [] ");
if (propIt.hasNext())
json += "} , ";
json.append("} , ");
else
json += "}] ";
json.append("}] ");
}
}
else {
json += "\"children\": [] ";
json.append("\"children\": [] ");
}
json += "} ";
json.append("} ");
counter += 1;
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
log.debug("json = " + json);
} catch (Throwable t) {
t.printStackTrace();

View file

@ -139,51 +139,51 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
sortForPickList(props, vreq);
}
String json = new String();
StringBuilder json = new StringBuilder();
int counter = 0;
if (props != null) {
if (props.size()==0) {
json = "{ \"name\": \"" + noResultsMsgStr + "\" }";
json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }");
} else {
Iterator<ObjectProperty> propsIt = props.iterator();
while (propsIt.hasNext()) {
if ( counter > 0 ) {
json += ", ";
json.append(", ");
}
ObjectProperty prop = propsIt.next();
String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./propertyEdit?uri="+URLEncoder.encode(prop.getURI())+"'>"
+ propNameStr + "</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./propertyEdit?uri=" + URLEncoder.encode(prop.getURI()) + "'>"
+ propNameStr + "</a>")).append(", ");
} catch (Exception e) {
json += "{ \"name\": \"" + propNameStr + "\", ";
json.append("{ \"name\": \"").append(propNameStr).append("\", ");
}
json += "\"data\": { \"internalName\": " + JacksonUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
json.append("\"data\": { \"internalName\": ").append(JacksonUtils.quote(prop.getLocalNameWithPrefix())).append(", ");
ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI());
if(opLangNeut == null) {
opLangNeut = prop;
}
String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
json += "\"domainVClass\": " + JacksonUtils.quote(domainStr) + ", " ;
json.append("\"domainVClass\": ").append(JacksonUtils.quote(domainStr)).append(", ");
String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut);
json += "\"rangeVClass\": " + JacksonUtils.quote(rangeStr) + ", " ;
json.append("\"rangeVClass\": ").append(JacksonUtils.quote(rangeStr)).append(", ");
if (prop.getGroupURI() != null) {
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
json += "\"group\": " + JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ;
json.append("\"group\": ").append(JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())).append(" } } ");
} else {
json += "\"group\": \"unspecified\" } }" ;
json.append("\"group\": \"unspecified\" } }");
}
counter += 1;
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
}
} catch (Throwable t) {

View file

@ -76,7 +76,7 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
}
}
String json = new String();
StringBuilder json = new StringBuilder();
int counter = 0;
String ontologyURI = vreq.getParameter("ontologyUri");
@ -86,21 +86,21 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
Iterator<VClass> classesIt = classes.iterator();
while (classesIt.hasNext()) {
if ( counter > 0 ) {
json += ", ";
json.append(", ");
}
VClass cls = (VClass) classesIt.next();
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
if (cls.getName() != null)
try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getPickListName()+"</a>") + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./vclassEdit?uri=" + URLEncoder.encode(cls.getURI(), "UTF-8") + "'>" + cls.getPickListName() + "</a>")).append(", ");
} catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(cls.getPickListName()) + ", ";
json.append("{ \"name\": ").append(JacksonUtils.quote(cls.getPickListName())).append(", ");
}
else
json += "{ \"name\": \"\"";
json.append("{ \"name\": \"\"");
String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef();
json += "\"data\": { \"shortDef\": " + JacksonUtils.quote(shortDef) + ", ";
json.append("\"data\": { \"shortDef\": ").append(JacksonUtils.quote(shortDef)).append(", ");
// get group name
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
@ -115,7 +115,7 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
}
}
json += "\"classGroup\": " + JacksonUtils.quote(groupName) + ", ";
json.append("\"classGroup\": ").append(JacksonUtils.quote(groupName)).append(", ");
// get ontology name
OntologyDao ontDao = wadf.getOntologyDao();
@ -124,13 +124,13 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
if (ont != null && ont.getName() != null) {
ontName = ont.getName();
}
json += "\"ontology\": " + JacksonUtils.quote(ontName) + "} }";
json.append("\"ontology\": ").append(JacksonUtils.quote(ontName)).append("} }");
counter++;
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
}
return new TemplateResponseValues(TEMPLATE_NAME, body);

View file

@ -76,7 +76,7 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
} else {
vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
}
String json = new String();
StringBuilder json = new StringBuilder();
String ontologyUri = vreq.getParameter("ontologyUri");
String startClassUri = vreq.getParameter("vclassUri");
@ -104,22 +104,22 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
if (!rootIt.hasNext()) {
VClass vcw = new VClass();
vcw.setName("<strong>No classes found.</strong>");
json += addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri,counter);
json.append(addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw, 0, ontologyUri, counter));
} else {
while (rootIt.hasNext()) {
VClass root = (VClass) rootIt.next();
if (root != null) {
json += addChildren(vreq.getUnfilteredWebappDaoFactory(),
root, 0, ontologyUri, counter, vreq);
json.append(addChildren(vreq.getUnfilteredWebappDaoFactory(),
root, 0, ontologyUri, counter, vreq));
counter += 1;
}
}
int length = json.length();
if ( length > 0 ) {
json += " }";
json.append(" }");
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
return new TemplateResponseValues(TEMPLATE_NAME, body);
}
@ -129,8 +129,8 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
String rowElts = addVClassDataToResultsList(wadf, parent, position, ontologyUri, counter);
int childShift = (rowElts.length() > 0) ? 1 : 0; // if addVClassDataToResultsList filtered out the result, don't shift the children over
int length = rowElts.length();
String leaves = "";
leaves += rowElts;
StringBuilder leaves = new StringBuilder();
leaves.append(rowElts);
List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI());
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
List<VClass> childClasses = new ArrayList<VClass>();
@ -148,22 +148,24 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
Iterator<VClass> childClassIt = childClasses.iterator();
while (childClassIt.hasNext()) {
VClass child = (VClass) childClassIt.next();
leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter, vreq);
leaves.append(addChildren(wadf, child, position + childShift, ontologyUri, counter, vreq));
if (!childClassIt.hasNext()) {
if ( ontologyUri == null ) {
leaves += " }] ";
leaves.append(" }] ");
}
else if ( ontologyUri != null && length > 0 ) {
// need this for when we show the classes associated with an ontology
String ending = leaves.substring(leaves.length() - 2, leaves.length());
if ( ending.equals("] ") ) {
leaves += "}]";
}
else if ( ending.equals(" [") ){
leaves += "] ";
}
else {
leaves += "}]";
switch (ending) {
case "] ":
leaves.append("}]");
break;
case " [":
leaves.append("] ");
break;
default:
leaves.append("}]");
break;
}
}
}
@ -171,13 +173,13 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
}
else {
if ( ontologyUri == null ) {
leaves += "] ";
leaves.append("] ");
}
else if ( ontologyUri != null && length > 0 ) {
leaves += "] ";
leaves.append("] ");
}
}
return leaves;
return leaves.toString();
}
private String addVClassDataToResultsList(WebappDaoFactory wadf, VClass vcw, int position, String ontologyUri, int counter) {

View file

@ -84,7 +84,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
dDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDatatypeDao();
String json = new String();
StringBuilder json = new StringBuilder();
String ontologyUri = vreq.getParameter("ontologyUri");
String startPropertyUri = vreq.getParameter("propertyUri");
@ -111,23 +111,23 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
String notFoundMessage = "<strong>No data properties found.</strong>";
dp.setName(notFoundMessage);
dp.setName(notFoundMessage);
json += addDataPropertyDataToResultsList(dp, 0, ontologyUri, counter);
json.append(addDataPropertyDataToResultsList(dp, 0, ontologyUri, counter));
} else {
while (rootIt.hasNext()) {
DataProperty root = rootIt.next();
if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) {
json += addChildren(root, 0, ontologyUri, counter, vreq);
json.append(addChildren(root, 0, ontologyUri, counter, vreq));
counter += 1;
}
}
int length = json.length();
if ( length > 0 ) {
json += " }";
json.append(" }");
}
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
} catch (Throwable t) {
t.printStackTrace();
@ -142,8 +142,8 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
}
String details = addDataPropertyDataToResultsList(parent, position, ontologyUri, counter);
int length = details.length();
String leaves = "";
leaves += details;
StringBuilder leaves = new StringBuilder();
leaves.append(details);
List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
List<DataProperty> childProps = new ArrayList<DataProperty>();
@ -157,22 +157,24 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
Iterator<DataProperty> childPropIt = childProps.iterator();
while (childPropIt.hasNext()) {
DataProperty child = childPropIt.next();
leaves += addChildren(child, position+1, ontologyUri, counter, vreq);
leaves.append(addChildren(child, position + 1, ontologyUri, counter, vreq));
if (!childPropIt.hasNext()) {
if ( ontologyUri == null ) {
leaves += " }] ";
leaves.append(" }] ");
}
else if ( ontologyUri != null && length > 0 ) {
// need this for when we show the classes associated with an ontology
String ending = leaves.substring(leaves.length() - 2, leaves.length());
if ( ending.equals("] ") ) {
leaves += "}]";
}
else if ( ending.equals(" [") ){
leaves += "] ";
}
else {
leaves += "}]";
switch (ending) {
case "] ":
leaves.append("}]");
break;
case " [":
leaves.append("] ");
break;
default:
leaves.append("}]");
break;
}
}
}
@ -180,13 +182,13 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
}
else {
if ( ontologyUri == null ) {
leaves += "] ";
leaves.append("] ");
}
else if ( ontologyUri != null && length > 0 ) {
leaves += "] ";
leaves.append("] ");
}
}
return leaves;
return leaves.toString();
}
private String addDataPropertyDataToResultsList(DataProperty dp, int position, String ontologyUri, int counter) {

View file

@ -84,7 +84,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
String json = new String();
StringBuilder json = new StringBuilder();
String ontologyUri = vreq.getParameter("ontologyUri");
String startPropertyUri = vreq.getParameter("propertyUri");
@ -115,7 +115,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
op.setURI(ontologyUri+"fake");
String notFoundMessage = "<strong>No object properties found.</strong>";
op.setDomainPublic(notFoundMessage);
json += addObjectPropertyDataToResultsList(op, 0, ontologyUri, counter);
json.append(addObjectPropertyDataToResultsList(op, 0, ontologyUri, counter));
} else {
while (rootIt.hasNext()) {
ObjectProperty root = rootIt.next();
@ -123,18 +123,18 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
( (ontologyUri != null)
&& (root.getNamespace() != null)
&& (ontologyUri.equals(root.getNamespace())) ) ) {
json += addChildren(root, 0, ontologyUri, counter);
json.append(addChildren(root, 0, ontologyUri, counter));
counter += 1;
}
}
int length = json.length();
if ( length > 0 ) {
json += " }";
json.append(" }");
}
}
}
body.put("jsonTree",json);
body.put("jsonTree", json.toString());
} catch (Throwable t) {
t.printStackTrace();
@ -146,8 +146,8 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
private String addChildren(ObjectProperty parent, int position, String ontologyUri, int counter) {
String details = addObjectPropertyDataToResultsList(parent, position, ontologyUri, counter);
int length = details.length();
String leaves = "";
leaves += details;
StringBuilder leaves = new StringBuilder();
leaves.append(details);
List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
List<ObjectProperty> childProps = new ArrayList<ObjectProperty>();
@ -161,22 +161,24 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
Iterator<ObjectProperty> childPropIt = childProps.iterator();
while (childPropIt.hasNext()) {
ObjectProperty child = childPropIt.next();
leaves += addChildren(child, position+1, ontologyUri, counter);
leaves.append(addChildren(child, position + 1, ontologyUri, counter));
if (!childPropIt.hasNext()) {
if ( ontologyUri == null ) {
leaves += " }] ";
leaves.append(" }] ");
}
else if ( ontologyUri != null && length > 0 ) {
// need this for when we show the classes associated with an ontology
String ending = leaves.substring(leaves.length() - 2, leaves.length());
if ( ending.equals("] ") ) {
leaves += "}]";
}
else if ( ending.equals(" [") ){
leaves += "] ";
}
else {
leaves += "}]";
switch (ending) {
case "] ":
leaves.append("}]");
break;
case " [":
leaves.append("] ");
break;
default:
leaves.append("}]");
break;
}
}
}
@ -184,13 +186,13 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
}
else {
if ( ontologyUri == null ) {
leaves += "] ";
leaves.append("] ");
}
else if ( ontologyUri != null && length > 0 ) {
leaves += "] ";
leaves.append("] ");
}
}
return leaves;
return leaves.toString();
}
private String addObjectPropertyDataToResultsList(ObjectProperty op, int position, String ontologyUri, int counter) {

View file

@ -7,7 +7,6 @@ import java.io.StringWriter;
import java.io.Writer;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -13,10 +12,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Freemarker controller and template sandbox.

View file

@ -208,6 +208,8 @@ public class UrlBuilder {
}
private static String addParams(String url, ParamMap params, String glue) {
if (params.size() > 0) {
StringBuilder sb = new StringBuilder(url);
for (String key: params.keySet()) {
String value = params.get(key);
// rjy7 Some users might require nulls to be converted to empty
@ -217,9 +219,12 @@ public class UrlBuilder {
// to remove null values or convert to empty strings, whichever
// is desired in the particular instance.
value = (value == null) ? "" : urlEncode(value);
url += glue + key + "=" + value;
sb.append(glue).append(key).append("=").append(value);
glue = "&";
}
url = sb.toString();
}
return url;
}

View file

@ -23,19 +23,15 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataPropertyStatementTemplateModel;
/*Servlet to view all labels in various languages for individual*/

View file

@ -19,11 +19,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;

View file

@ -91,7 +91,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
ArrayList<DataProperty> vcProps = (ArrayList<DataProperty>)classPropertiesMap.get(vc);
for (DataProperty prop: vcProps) {
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? null : prop.getName() : prop.getPublicName();
String nameStr = prop.getPublicName()==null ? prop.getName() : prop.getPublicName();
//System.out.println("--- uri: " + prop.getURI());
//System.out.println("--- name: " + nameStr);
// top level
@ -152,7 +152,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
VClass vc = (VClass) iter.next();
ArrayList<DataProperty> vcProps = (ArrayList<DataProperty>)lvl2ClassPropertiesMap.get(vc);
for (DataProperty prop: vcProps) {
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? null : prop.getName() : prop.getPublicName();
String nameStr = prop.getPublicName()==null ? prop.getName() : prop.getPublicName();
// top level
ObjectNode propertiesItemJson = JsonNodeFactory.instance.objectNode();
@ -222,7 +222,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
Collections.sort(props);
for (DataProperty prop: props) {
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? null : prop.getName() : prop.getPublicName();
String nameStr = prop.getPublicName()==null ? prop.getName() : prop.getPublicName();
if (nameStr != null) {
if (prop.getDomainClassURI() != null) {
VClass vc = vcDao.getVClassByURI(prop.getDomainClassURI());

View file

@ -198,10 +198,10 @@ public class JSONReconcileServlet extends VitroHttpServlet {
json.put("schemaSpace", defaultNamespace);
}
ObjectNode viewJson = JsonNodeFactory.instance.objectNode();
StringBuffer urlBuf = new StringBuffer();
urlBuf.append("http://" + serverName);
StringBuilder urlBuf = new StringBuilder();
urlBuf.append("http://").append(serverName);
if (serverPort == 8080) {
urlBuf.append(":" + serverPort);
urlBuf.append(":").append(serverPort);
}
if (req.getContextPath() != null) {
urlBuf.append(req.getContextPath());

View file

@ -265,18 +265,18 @@ class IndividualResponseBuilder {
- Much simpler is to just create an anchor element. This has the added advantage that the
browser doesn't ask to resend the form data when reloading the page.
*/
String url = vreq.getRequestURI() + "?verbose=" + !verboseValue;
StringBuilder url = new StringBuilder(vreq.getRequestURI() + "?verbose=" + !verboseValue);
// Append request query string, except for current verbose value, to url
String queryString = vreq.getQueryString();
if (queryString != null) {
String[] params = queryString.split("&");
for (String param : params) {
if (! param.startsWith("verbose=")) {
url += "&" + param;
url.append("&").append(param);
}
}
}
map.put("url", url);
map.put("url", url.toString());
} else {
vreq.getSession().setAttribute("verbosePropertyDisplay", false);
}

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.individuallist;
import java.util.Collection;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -163,7 +163,7 @@ public class JenaAdminActions extends BaseEditController {
}
private String testWriteXML() {
StringBuffer output = new StringBuffer();
StringBuilder output = new StringBuilder();
output.append("<html><head><title>Test Write XML</title></head><body><pre>\n");
OntModel model = ModelAccess.on(getServletContext()).getOntModel();
Model tmp = ModelFactory.createDefaultModel();
@ -177,10 +177,10 @@ public class JenaAdminActions extends BaseEditController {
valid = false;
output.append("-----\n");
output.append("Unable to write statement as RDF/XML:\n");
output.append("Subject : \n"+stmt.getSubject().getURI());
output.append("Subject : \n"+stmt.getPredicate().getURI());
output.append("Subject : \n").append(stmt.getSubject().getURI());
output.append("Subject : \n").append(stmt.getPredicate().getURI());
String objectStr = (stmt.getObject().isLiteral()) ? ((Literal)stmt.getObject()).getLexicalForm() : ((Resource)stmt.getObject()).getURI();
output.append("Subject : \n"+objectStr);
output.append("Subject : \n").append(objectStr);
output.append("Exception: \n");
e.printStackTrace();
}
@ -250,16 +250,20 @@ public class JenaAdminActions extends BaseEditController {
VitroRequest request = new VitroRequest(req);
String actionStr = request.getParameter("action");
if (actionStr.equals("printRestrictions")) {
switch (actionStr) {
case "printRestrictions":
printRestrictions();
} else if (actionStr.equals("outputTbox")) {
break;
case "outputTbox":
outputTbox(response);
} else if (actionStr.equals("testWriteXML")) {
break;
case "testWriteXML":
try {
response.getWriter().write(testWriteXML());
} catch ( IOException ioe ) {
throw new RuntimeException( ioe );
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
break;
}
if (actionStr.equals("checkURIs")) {

View file

@ -139,7 +139,6 @@ public class JenaCsv2RdfController extends JenaIngestController {
log.error(e1);
throw new ServletException(e1);
}
return;
}
public Model doExecuteCsv2Rdf(VitroRequest vreq, FileItem fileStream, String filePath) throws Exception {

View file

@ -106,7 +106,7 @@ public class JenaExportController extends BaseEditController {
String formatParam = vreq.getParameter("format");
String subgraphParam = vreq.getParameter("subgraph");
String assertedOrInferredParam = vreq.getParameter("assertedOrInferred");
String ontologyURI = vreq.getParameter("ontologyURI");
StringBuilder ontologyURI = new StringBuilder(vreq.getParameter("ontologyURI"));
Model model = null;
OntModel ontModel = ModelFactory.createOntologyModel();
@ -114,12 +114,13 @@ public class JenaExportController extends BaseEditController {
if(!subgraphParam.equalsIgnoreCase("tbox")
&& !subgraphParam.equalsIgnoreCase("abox")
&& !subgraphParam.equalsIgnoreCase("full")){
ontologyURI = subgraphParam;
ontologyURI = new StringBuilder(subgraphParam);
subgraphParam = "tbox";
char[] uri = ontologyURI.toCharArray();
ontologyURI="";
for(int i =0; i < uri.length-1;i++)
ontologyURI = ontologyURI + uri[i];
char[] uri = ontologyURI.toString().toCharArray();
ontologyURI = new StringBuilder();
for(int i =0; i < uri.length-1;i++) {
ontologyURI.append(uri[i]);
}
}
if( "abox".equals(subgraphParam)){
@ -141,7 +142,7 @@ public class JenaExportController extends BaseEditController {
// only those statements that are in the inferred graph
Model tempModel = xutil.extractTBox(
ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION),
ontologyURI);
ontologyURI.toString());
Model inferenceModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES);
inferenceModel.enterCriticalSection(Lock.READ);
try {
@ -152,17 +153,17 @@ public class JenaExportController extends BaseEditController {
} else if ("full".equals(assertedOrInferredParam)) {
model = xutil.extractTBox(
ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION),
ontologyURI);
ontologyURI.toString());
} else {
model = xutil.extractTBox(
ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS), ontologyURI);
ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS), ontologyURI.toString());
}
}
else if("full".equals(subgraphParam)){
if("inferred".equals(assertedOrInferredParam)){
ontModel = xutil.extractTBox(
dataset, ontologyURI, ABOX_INFERENCES);
dataset, ontologyURI.toString(), ABOX_INFERENCES);
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ABOX_INFERENCES));
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES));
}
@ -217,20 +218,28 @@ public class JenaExportController extends BaseEditController {
if ( formatParam == null ) {
formatParam = "RDF/XML-ABBREV"; // default
}
String mime = formatToMimetype.get( formatParam );
if ( mime == null ) {
throw new RuntimeException( "Unsupported RDF format " + formatParam);
}
response.setContentType( mime );
if(mime.equals("application/rdf+xml"))
switch (mime) {
case "application/rdf+xml":
response.setHeader("content-disposition", "attachment; filename=" + "export.rdf");
else if(mime.equals("text/n3"))
break;
case "text/n3":
response.setHeader("content-disposition", "attachment; filename=" + "export.n3");
else if(mime.equals("text/plain"))
break;
case "text/plain":
response.setHeader("content-disposition", "attachment; filename=" + "export.txt");
else if(mime.equals("application/x-turtle"))
break;
case "application/x-turtle":
response.setHeader("content-disposition", "attachment; filename=" + "export.ttl");
break;
}
}
private void outputSparqlConstruct(String queryStr, String formatParam,
@ -248,10 +257,8 @@ public class JenaExportController extends BaseEditController {
IOUtils.copy(in, out);
out.flush();
out.close();
} catch (RDFServiceException e) {
} catch (RDFServiceException | IOException e) {
throw new RuntimeException(e);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} finally {
rdfService.close();
}

View file

@ -303,11 +303,11 @@ public class JenaIngestController extends BaseEditController {
} catch (org.apache.jena.shared.CannotEncodeCharacterException cece) {
// there's got to be a better way to do this
byte[] badCharBytes = String.valueOf(cece.getBadChar()).getBytes();
String errorMsg = "Cannot encode character with byte values: (decimal) ";
StringBuilder errorMsg = new StringBuilder("Cannot encode character with byte values: (decimal) ");
for (int i=0; i<badCharBytes.length; i++) {
errorMsg += badCharBytes[i];
errorMsg.append(badCharBytes[i]);
}
throw new RuntimeException(errorMsg, cece);
throw new RuntimeException(errorMsg.toString(), cece);
} catch (Exception e) {
log.error(e, e);
} finally {

View file

@ -454,7 +454,6 @@ public class RDFUploadController extends JenaIngestController {
log.error(e1);
throw new ServletException(e1);
}
return;
}
private OntModel getABoxModel(ServletContext ctx) {

View file

@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -18,7 +18,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService.ShortViewContext;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
/**
* Does a Solr search for individuals, and uses the short view to render each of

View file

@ -18,7 +18,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService.ShortViewContext;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
/**
* Does a search for individuals, and uses the short view to render each of

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.json;
import java.util.ArrayList;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -8,8 +8,6 @@ import java.io.Writer;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.logging.Log;

View file

@ -10,7 +10,6 @@ import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.dao.jena.IndividualDaoJena;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.NewURIMaker;
public class NewURIMakerVitro implements NewURIMaker {

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.List;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
public interface PropertyGroupDao {

View file

@ -3,9 +3,7 @@
package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Collection;
import java.util.Iterator;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstanceIface;

View file

@ -1,12 +1,9 @@
/* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Date;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
public class DataPropertyStatementFiltering implements DataPropertyStatement {

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import net.sf.jga.algorithms.Filter;
@ -67,16 +66,13 @@ public class FilteringPropertyInstanceDao implements PropertyInstanceDao {
//Filter based on subject, property and object. This could be changed
//to filter on the subject's and object's class.
Individual sub = individualDao.getIndividualByURI(inst.getSubjectEntURI());
if( filters.getIndividualFilter().fn(sub) == false )
if(!filters.getIndividualFilter().fn(sub))
return false;
Individual obj = individualDao.getIndividualByURI(inst.getObjectEntURI());
if( filters.getIndividualFilter().fn(obj) == false)
if(!filters.getIndividualFilter().fn(obj))
return false;
ObjectProperty prop = objectPropDao.getObjectPropertyByURI(inst.getPropertyURI());
if( filters.getObjectPropertyFilter().fn(prop) == false)
return false;
else
return true;
return filters.getObjectPropertyFilter().fn(prop);
}
};
}

View file

@ -155,8 +155,10 @@ public class IndividualFiltering implements Individual {
// predicate + range class combination is allowed even if the predicate is
// hidden on its own.
// Will revisit filtering at this level if it turns out to be truly necessary.
return _innerIndividual.getPopulatedObjectPropertyList();
// Will revisit filtering at this level if it turns out to be truly necessary.
/*
List<ObjectProperty> outOProps = new ArrayList<ObjectProperty>();
List<ObjectProperty> oProps = _innerIndividual.getPopulatedObjectPropertyList();
for (ObjectProperty op: oProps) {
@ -166,6 +168,7 @@ public class IndividualFiltering implements Individual {
}
}
return outOProps;
*/
}
/* ********************* methods that need delegated filtering *************** */

View file

@ -1,7 +1,6 @@
/* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Date;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;

View file

@ -2,17 +2,13 @@
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import net.sf.jga.algorithms.Filter;
import org.apache.jena.ontology.DatatypeProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
@ -70,7 +66,6 @@ public class PropertyGroupDaoFiltering implements PropertyGroupDao {
}
grp.setPropertyList(filteredProps); //side effect
return ;
}
public List<PropertyGroup> getPublicGroups(boolean withProperties) {

View file

@ -223,7 +223,6 @@ public class VClassDaoFiltering extends BaseFiltering implements VClassDao{
if( out != null )
vclass.setEntityCount(out.size());
System.out.println(vclass.getURI() + " count: " + vclass.getEntityCount());
return;
}
private List<VClass> correctVClassCounts(List<VClass> vclasses){

View file

@ -4,12 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.jga.fn.UnaryFunctor;

View file

@ -12,7 +12,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
/**
* A object to hold all the filters commonly used by the vitro webapp.

View file

@ -104,7 +104,7 @@ public class DisplayModelDaoJena implements DisplayModelDao {
if( text == null ){
//text of file is not yet in model
File oldMenuFile = new File(context.getRealPath(MENU_N3_FILE));
StringBuffer str = new StringBuffer(2000);
StringBuilder str = new StringBuilder(2000);
BufferedReader reader = new BufferedReader(new FileReader(oldMenuFile));
char[] buf = new char[1024];
int numRead=0;

View file

@ -219,12 +219,12 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
ontModel.enterCriticalSection(Lock.WRITE);
try {
entURI = new String(preferredURI);
entURI = preferredURI;
org.apache.jena.ontology.Individual test = ontModel.getIndividual(entURI);
int count = 0;
while (test != null) {
++count;
entURI = new String(preferredURI) + count;
entURI = preferredURI + count;
test = ontModel.getIndividual(entURI);
}
@ -677,7 +677,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
int attempts = 0;
while( uriIsGood == false && attempts < 30 ){
while(!uriIsGood && attempts < 30 ){
log.debug("While loop: Uri is good false, attempt=" + attempts);
String localName = "n" + random.nextInt( Math.min(Integer.MAX_VALUE,(int)Math.pow(2,attempts + 13)) );
uri = namespace + localName;

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -28,7 +27,6 @@ import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.query.ResultSetFactory;
import org.apache.jena.rdf.model.AnonId;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Property;

Some files were not shown because too many files have changed in this diff Show more