Minor code improvements
This commit is contained in:
parent
751d50f93a
commit
9e411253c4
8 changed files with 26 additions and 43 deletions
|
@ -136,10 +136,8 @@ public class BaseEditController extends VitroHttpServlet {
|
||||||
String value = "";
|
String value = "";
|
||||||
if (key.equals(MULTIPLEXED_PARAMETER_NAME)) {
|
if (key.equals(MULTIPLEXED_PARAMETER_NAME)) {
|
||||||
String multiplexedStr = request.getParameterValues(key)[0];
|
String multiplexedStr = request.getParameterValues(key)[0];
|
||||||
Map paramMap = FormUtils.beanParamMapFromString(multiplexedStr);
|
Map<String, String> paramMap = FormUtils.beanParamMapFromString(multiplexedStr);
|
||||||
Iterator paramIt = paramMap.keySet().iterator();
|
for (String param : paramMap.keySet()) {
|
||||||
while (paramIt.hasNext()) {
|
|
||||||
String param = (String) paramIt.next();
|
|
||||||
String demultiplexedValue = (String) paramMap.get(param);
|
String demultiplexedValue = (String) paramMap.get(param);
|
||||||
FormUtils.beanSet(bean, param, demultiplexedValue);
|
FormUtils.beanSet(bean, param, demultiplexedValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,12 +205,8 @@ public class OperationController extends BaseEditController {
|
||||||
|
|
||||||
private void runPreprocessors(EditProcessObject epo, Object newObj) {
|
private void runPreprocessors(EditProcessObject epo, Object newObj) {
|
||||||
if (epo.getPreProcessorList() != null && epo.getPreProcessorList().size()>0) {
|
if (epo.getPreProcessorList() != null && epo.getPreProcessorList().size()>0) {
|
||||||
Iterator preIt = epo.getPreProcessorList().iterator();
|
for (EditPreProcessor epp : epo.getPreProcessorList()) {
|
||||||
while (preIt.hasNext()) {
|
|
||||||
try {
|
|
||||||
EditPreProcessor epp = (EditPreProcessor) preIt.next();
|
|
||||||
epp.process(newObj, epo);
|
epp.process(newObj, epo);
|
||||||
} catch (ClassCastException e) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,9 +325,7 @@ public class OperationController extends BaseEditController {
|
||||||
private void notifyChangeListeners(EditProcessObject epo, String action) {
|
private void notifyChangeListeners(EditProcessObject epo, String action) {
|
||||||
List<ChangeListener> changeListeners = epo.getChangeListenerList();
|
List<ChangeListener> changeListeners = epo.getChangeListenerList();
|
||||||
if (changeListeners != null){
|
if (changeListeners != null){
|
||||||
Iterator<ChangeListener> changeIt = changeListeners.iterator();
|
for (ChangeListener cl : changeListeners) {
|
||||||
while (changeIt.hasNext()) {
|
|
||||||
ChangeListener cl = changeIt.next();
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "insert":
|
case "insert":
|
||||||
cl.doInserted(epo.getNewBean(), epo);
|
cl.doInserted(epo.getNewBean(), epo);
|
||||||
|
|
|
@ -267,11 +267,7 @@ public class FormUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(options, new Comparator<Option>() {
|
Collections.sort(options, (o1, o2) -> o1.getBody().compareTo(o2.getBody()));
|
||||||
@Override
|
|
||||||
public int compare(Option o1, Option o2) {
|
|
||||||
return o1.getBody().compareTo(o2.getBody());
|
|
||||||
}});
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
@ -367,9 +363,9 @@ public class FormUtils {
|
||||||
* key:value;key2:value2;key3:value, and puts the keys and values in a Map
|
* key:value;key2:value2;key3:value, and puts the keys and values in a Map
|
||||||
* @param params Parameters
|
* @param params Parameters
|
||||||
*/
|
*/
|
||||||
public static Map beanParamMapFromString(String params) {
|
public static Map<String, String> beanParamMapFromString(String params) {
|
||||||
String[] param = params.split(";");
|
String[] param = params.split(";");
|
||||||
Map beanParamMap = new HashMap();
|
Map<String, String> beanParamMap = new HashMap<String, String>();
|
||||||
for (String aParam : param) {
|
for (String aParam : param) {
|
||||||
String[] p = aParam.split(":");
|
String[] p = aParam.split(":");
|
||||||
beanParamMap.put(p[0], new String(Base64.decodeBase64(p[1].getBytes())));
|
beanParamMap.put(p[0], new String(Base64.decodeBase64(p[1].getBytes())));
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
|
|
||||||
public interface ObjectPropertyDao extends PropertyDao {
|
public interface ObjectPropertyDao extends PropertyDao {
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ public interface ObjectPropertyDao extends PropertyDao {
|
||||||
*/
|
*/
|
||||||
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI, ObjectProperty base);
|
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI, ObjectProperty base);
|
||||||
|
|
||||||
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
|
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List<ObjectPropertyStatement> objectPropertyStatements);
|
||||||
|
|
||||||
public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct);
|
public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
import net.sf.jga.algorithms.Filter;
|
import net.sf.jga.algorithms.Filter;
|
||||||
import net.sf.jga.fn.UnaryFunctor;
|
import net.sf.jga.fn.UnaryFunctor;
|
||||||
import net.sf.jga.fn.adaptor.AndUnary;
|
import net.sf.jga.fn.adaptor.AndUnary;
|
||||||
|
@ -32,7 +33,7 @@ class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectProperty
|
||||||
return filterAndWrap(innerObjectPropertyDao.getAllObjectProperties(), filters);
|
return filterAndWrap(innerObjectPropertyDao.getAllObjectProperties(), filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getObjectPropertiesForObjectPropertyStatements(List objectPropertyStatements) {
|
public List getObjectPropertiesForObjectPropertyStatements(List<ObjectPropertyStatement> objectPropertyStatements) {
|
||||||
//assume that the objPropStmts are already filtered
|
//assume that the objPropStmts are already filtered
|
||||||
List<ObjectProperty> list =
|
List<ObjectProperty> list =
|
||||||
innerObjectPropertyDao
|
innerObjectPropertyDao
|
||||||
|
|
|
@ -474,15 +474,13 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List objPropertyStmts) {
|
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List<ObjectPropertyStatement> objPropertyStmts) {
|
||||||
if( objPropertyStmts == null || objPropertyStmts.size() < 1) return new ArrayList();
|
if( objPropertyStmts == null || objPropertyStmts.size() < 1) return new ArrayList();
|
||||||
HashMap<String,ObjectProperty> hash = new HashMap<String,ObjectProperty>();
|
HashMap<String,ObjectProperty> hash = new HashMap<String,ObjectProperty>();
|
||||||
String uris ="";
|
String uris ="";
|
||||||
getOntModel().enterCriticalSection(Lock.READ);
|
getOntModel().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
Iterator it = objPropertyStmts.iterator();
|
for (ObjectPropertyStatement objPropertyStmt : objPropertyStmts) {
|
||||||
while(it.hasNext()){
|
|
||||||
ObjectPropertyStatement objPropertyStmt = (ObjectPropertyStatement)it.next();
|
|
||||||
if (hash.containsKey(objPropertyStmt.getPropertyURI())) {
|
if (hash.containsKey(objPropertyStmt.getPropertyURI())) {
|
||||||
ObjectProperty p = hash.get(objPropertyStmt.getPropertyURI());
|
ObjectProperty p = hash.get(objPropertyStmt.getPropertyURI());
|
||||||
p.addObjectPropertyStatement(objPropertyStmt);
|
p.addObjectPropertyStatement(objPropertyStmt);
|
||||||
|
@ -873,9 +871,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
isRoot = true;
|
isRoot = true;
|
||||||
} else {
|
} else {
|
||||||
isRoot = true;
|
isRoot = true;
|
||||||
Iterator<? extends Property> pit = parentList.iterator();
|
for (Property pt : parentList) {
|
||||||
while (pit.hasNext()) {
|
|
||||||
Property pt = pit.next();
|
|
||||||
if ((!pt.equals(op)) && (!(getOntModel().contains(op, OWL.equivalentProperty, pt)) || (getOntModel().contains(pt, OWL.equivalentProperty, op)))) {
|
if ((!pt.equals(op)) && (!(getOntModel().contains(op, OWL.equivalentProperty, pt)) || (getOntModel().contains(pt, OWL.equivalentProperty, op)))) {
|
||||||
isRoot = false;
|
isRoot = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,19 +77,15 @@ public class GetObjectClasses extends BaseEditController {
|
||||||
if (vClass != null) {
|
if (vClass != null) {
|
||||||
respo.append("<option>" + "<key>").append(vClass.getPickListName()).append("</key>").append("<value>").append(vClass.getURI()).append("</value>").append("</option>");
|
respo.append("<option>" + "<key>").append(vClass.getPickListName()).append("</key>").append("<value>").append(vClass.getURI()).append("</value>").append("</option>");
|
||||||
} else {
|
} else {
|
||||||
List classGroups = vreq.getUnfilteredWebappDaoFactory()
|
List<VClassGroup> classGroups = vreq.getUnfilteredWebappDaoFactory()
|
||||||
.getVClassGroupDao().getPublicGroupsWithVClasses(true,
|
.getVClassGroupDao().getPublicGroupsWithVClasses(true,
|
||||||
true, false); // order by displayRank, include
|
true, false); // order by displayRank, include
|
||||||
// uninstantiated classes, don't get
|
// uninstantiated classes, don't get
|
||||||
// the counts of individuals
|
// the counts of individuals
|
||||||
|
|
||||||
Iterator classGroupIt = classGroups.iterator();
|
for (VClassGroup group : classGroups) {
|
||||||
while (classGroupIt.hasNext()) {
|
List<VClass> classes = group.getVitroClassList();
|
||||||
VClassGroup group = (VClassGroup) classGroupIt.next();
|
for (VClass clazz : classes) {
|
||||||
List classes = group.getVitroClassList();
|
|
||||||
Iterator classIt = classes.iterator();
|
|
||||||
while (classIt.hasNext()) {
|
|
||||||
VClass clazz = (VClass) classIt.next();
|
|
||||||
respo.append("<option>" + "<key>").append(clazz.getPickListName()).append("</key>").append("<value>").append(clazz.getURI()).append("</value>").append("</option>");
|
respo.append("<option>" + "<key>").append(clazz.getPickListName()).append("</key>").append("<value>").append(clazz.getURI()).append("</value>").append("</option>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.google.common.base.Objects;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
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.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
|
@ -257,7 +258,7 @@ public class ObjectPropertyDaoStub implements ObjectPropertyDao {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(
|
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(
|
||||||
List objectPropertyStatements) {
|
List<ObjectPropertyStatement> objectPropertyStatements) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"ObjectPropertyDaoStub.getObjectPropertiesForObjectPropertyStatements() not implemented.");
|
"ObjectPropertyDaoStub.getObjectPropertiesForObjectPropertyStatements() not implemented.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue