Minor code improvements

This commit is contained in:
Graham Triggs 2017-09-18 12:20:01 +01:00
parent d97544b991
commit 751d50f93a
44 changed files with 476 additions and 625 deletions

View file

@ -178,18 +178,15 @@ public class BaseEditController extends VitroHttpServlet {
List<String> bodyVal = new ArrayList<String>(); List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>(); List<Option> options = new ArrayList<Option>();
Iterator<Option> itr = optionList.iterator(); for (Option option : optionList) {
while(itr.hasNext()){ hashMap.put(option.getBody(), option);
Option option = itr.next();
hashMap.put(option.getBody(),option);
bodyVal.add(option.getBody()); bodyVal.add(option.getBody());
} }
Collections.sort(bodyVal, new ListComparator(vreq.getCollator())); Collections.sort(bodyVal, new ListComparator(vreq.getCollator()));
ListIterator<String> itrStr = bodyVal.listIterator(); for (String aBodyVal : bodyVal) {
while(itrStr.hasNext()){ options.add(hashMap.get(aBodyVal));
options.add(hashMap.get(itrStr.next()));
} }
return options; return options;
} }

View file

@ -162,27 +162,26 @@ public class DynamicFieldsTag extends EditTag {
out.print(preWithVars); out.print(preWithVars);
Iterator<DynamicFieldRow> rowIt = dynf.getRowList().iterator(); for (DynamicFieldRow dynamicFieldRow : dynf.getRowList()) {
while (rowIt.hasNext()) {
++i; ++i;
DynamicFieldRow row = rowIt.next(); DynamicFieldRow row = dynamicFieldRow;
if (row.getValue()==null) if (row.getValue() == null)
row.setValue(""); row.setValue("");
if (row.getValue().length()>0) { if (row.getValue().length() > 0) {
StringBuilder taName = new StringBuilder().append("_").append(dynf.getTable()).append("_"); StringBuilder taName = new StringBuilder().append("_").append(dynf.getTable()).append("_");
taName.append(row.getId()).append("_"); taName.append(row.getId()).append("_");
Iterator paramIt = row.getParameterMap().keySet().iterator(); Iterator paramIt = row.getParameterMap().keySet().iterator();
while(paramIt.hasNext()) { while (paramIt.hasNext()) {
String key = (String) paramIt.next(); String key = (String) paramIt.next();
String value = (String) row.getParameterMap().get(key); String value = (String) row.getParameterMap().get(key);
byte[] valueInBase64 = Base64.encodeBase64(value.getBytes()); byte[] valueInBase64 = Base64.encodeBase64(value.getBytes());
taName.append(key).append(":").append(new String(valueInBase64)).append(";"); taName.append(key).append(":").append(new String(valueInBase64)).append(";");
} }
if (row.getValue().length()>0) { if (row.getValue().length() > 0) {
String templateWithVars = templateMarkup; String templateWithVars = templateMarkup;
templateWithVars = strReplace(templateWithVars,type+"NN",Integer.toString(i)); templateWithVars = strReplace(templateWithVars, type + "NN", Integer.toString(i));
templateWithVars = strReplace(templateWithVars,"\\$taName",taName.toString()); templateWithVars = strReplace(templateWithVars, "\\$taName", taName.toString());
templateWithVars = strReplace(templateWithVars,"\\$\\$",row.getValue()); templateWithVars = strReplace(templateWithVars, "\\$\\$", row.getValue());
out.print(templateWithVars); out.print(templateWithVars);
} }
} }

View file

@ -301,10 +301,8 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
protected void sortEnts2EntsForDisplay(){ protected void sortEnts2EntsForDisplay(){
if( getObjectPropertyList() == null ) return; if( getObjectPropertyList() == null ) return;
Iterator it = getObjectPropertyList().iterator(); for (ObjectProperty prop : getObjectPropertyList()) {
while(it.hasNext()){ prop.sortObjectPropertyStatementsForDisplay(prop, prop.getObjectPropertyStatements());
ObjectProperty prop = (ObjectProperty)it.next();
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
} }
} }

View file

@ -144,9 +144,7 @@ public class EntityEditController extends BaseEditController {
try { try {
List<Option> externalIdOptionList = new LinkedList<Option>(); List<Option> externalIdOptionList = new LinkedList<Option>();
if (ent.getExternalIds() != null) { if (ent.getExternalIds() != null) {
Iterator<DataPropertyStatement> externalIdIt = ent.getExternalIds().iterator(); for (DataPropertyStatement eid : ent.getExternalIds()) {
while (externalIdIt.hasNext()) {
DataPropertyStatement eid = externalIdIt.next();
String multiplexedString = "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())); externalIdOptionList.add(new Option(multiplexedString, eid.getData()));
} }
@ -169,11 +167,9 @@ public class EntityEditController extends BaseEditController {
try { try {
List epiOptionList = new LinkedList(); List epiOptionList = new LinkedList();
Collection<PropertyInstance> epiColl = piDao.getExistingProperties(ent.getURI(),null); Collection<PropertyInstance> epiColl = piDao.getExistingProperties(ent.getURI(),null);
Iterator<PropertyInstance> epiIt = epiColl.iterator(); for (PropertyInstance pi : epiColl) {
while (epiIt.hasNext()) {
PropertyInstance pi = epiIt.next();
String multiplexedString = "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())); epiOptionList.add(new Option(multiplexedString, pi.getDomainPublic() + " " + pi.getObjectName()));
} }
OptionMap.put("ExistingPropertyInstances", epiOptionList); OptionMap.put("ExistingPropertyInstances", epiOptionList);
} catch (Exception e) { } catch (Exception e) {

View file

@ -211,24 +211,20 @@ public class EntityRetryController extends BaseEditController {
Collections.sort(allApplicableDataprops); Collections.sort(allApplicableDataprops);
if (allApplicableDataprops != null) { if (allApplicableDataprops != null) {
Iterator<DataProperty> datapropsIt = allApplicableDataprops.iterator();
while (datapropsIt.hasNext()){ for (DataProperty d : allApplicableDataprops) {
DataProperty d = datapropsIt.next();
if (!dpMap.containsKey(d.getURI())) { if (!dpMap.containsKey(d.getURI())) {
dpMap.put(d.getURI(),d); dpMap.put(d.getURI(), d);
} }
} }
if (individualForEditing.getDataPropertyList() != null) { if (individualForEditing.getDataPropertyList() != null) {
Iterator<DataProperty> existingDps = individualForEditing.getDataPropertyList().iterator(); for (DataProperty existingDp : individualForEditing.getDataPropertyList()) {
while (existingDps.hasNext()) {
DataProperty existingDp = existingDps.next();
// Since the edit form begins with a "name" field, which gets saved as the rdfs:label, // Since the edit form begins with a "name" field, which gets saved as the rdfs:label,
// do not want to include the label as well. // do not want to include the label as well.
if ( !existingDp.getPublicName().equals("label") ) { if (!existingDp.getPublicName().equals("label")) {
dpMap.put(existingDp.getURI(),existingDp); dpMap.put(existingDp.getURI(), existingDp);
} }
} }
} }
@ -249,9 +245,7 @@ public class EntityRetryController extends BaseEditController {
rowTemplate.setParameterMap(parameterMap); rowTemplate.setParameterMap(parameterMap);
dynamo.setRowTemplate(rowTemplate); dynamo.setRowTemplate(rowTemplate);
try { try {
Iterator<DataPropertyStatement> existingValues = dp.getDataPropertyStatements().iterator(); for (DataPropertyStatement existingValue : dp.getDataPropertyStatements()) {
while (existingValues.hasNext()) {
DataPropertyStatement existingValue = existingValues.next();
DynamicFieldRow row = new DynamicFieldRow(); DynamicFieldRow row = new DynamicFieldRow();
//TODO: UGH //TODO: UGH
//row.setId(existingValue.getId()); //row.setId(existingValue.getId());

View file

@ -122,9 +122,7 @@ public class ObjectPropertyStatementRetryController extends BaseEditController {
indList.addAll(possIndSet); indList.addAll(possIndSet);
sortForPickList(indList, vreq); sortForPickList(indList, vreq);
List objectEntOptionList = new LinkedList(); List objectEntOptionList = new LinkedList();
Iterator<Individual> indIt = indList.iterator(); for (Individual objInd : indList) {
while (indIt.hasNext()) {
Individual objInd = indIt.next();
Option objIndOpt = new Option(objInd.getURI(), objInd.getName()); Option objIndOpt = new Option(objInd.getURI(), objInd.getName());
if (objectForEditing.getObjectEntURI() != null && objectForEditing.getObjectEntURI().equals(objInd.getURI())) { if (objectForEditing.getObjectEntURI() != null && objectForEditing.getObjectEntURI().equals(objInd.getURI())) {
objIndOpt.setSelected(true); objIndOpt.setSelected(true);

View file

@ -203,9 +203,7 @@ public class VclassEditController extends BaseEditController {
private List<VClass> getVClassesForURIList(List<String> vclassURIs, VClassDao vcDao) { private List<VClass> getVClassesForURIList(List<String> vclassURIs, VClassDao vcDao) {
List<VClass> vclasses = new ArrayList<VClass>(); List<VClass> vclasses = new ArrayList<VClass>();
Iterator<String> urIt = vclassURIs.iterator(); for (String vclassURI : vclassURIs) {
while (urIt.hasNext()) {
String vclassURI = urIt.next();
VClass vclass = vcDao.getVClassByURI(vclassURI); VClass vclass = vcDao.getVClassByURI(vclassURI);
if (vclass != null) { if (vclass != null) {
vclasses.add(vclass); vclasses.add(vclass);

View file

@ -55,7 +55,7 @@ public class IndividualsListingController extends BaseEditController {
String vclassURI = request.getParameter("VClassURI"); String vclassURI = request.getParameter("VClassURI");
VClass vc = vcDao.getVClassByURI(vclassURI); VClass vc = vcDao.getVClassByURI(vclassURI);
List inds = dao.getIndividualsByVClassURI(vclassURI); List<Individual> inds = dao.getIndividualsByVClassURI(vclassURI);
//List inds = dao.getIndividualsByVClassURI(vclassURI,1,MAX_INDIVIDUALS); //List inds = dao.getIndividualsByVClassURI(vclassURI,1,MAX_INDIVIDUALS);
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
@ -64,16 +64,13 @@ public class IndividualsListingController extends BaseEditController {
results.add("class"); results.add("class");
if (inds != null && inds.size()>0) { if (inds != null && inds.size()>0) {
Iterator indsIt = inds.iterator(); for (Individual ind : inds) {
while (indsIt.hasNext()) {
Individual ind = (Individual) indsIt.next();
results.add("XX"); results.add("XX");
if (ind.getName() != null) { if (ind.getName() != null) {
try { try {
String individualName = (ind.getName()==null || ind.getName().length()==0) ? ind.getURI() : ind.getName(); String individualName = (ind.getName() == null || ind.getName().length() == 0) ? ind.getURI() : ind.getName();
results.add("<a href=\"./entityEdit?uri="+URLEncoder.encode(ind.getURI(),"UTF-8")+"\">"+individualName+"</a>"); results.add("<a href=\"./entityEdit?uri=" + URLEncoder.encode(ind.getURI(), "UTF-8") + "\">" + individualName + "</a>");
} catch (Exception e) { } catch (Exception e) {
results.add(ind.getName()); results.add(ind.getName());
} }
@ -84,8 +81,8 @@ public class IndividualsListingController extends BaseEditController {
if (vc != null) { if (vc != null) {
try { try {
String vclassName = (vc.getName()==null || vc.getName().length()==0) ? vc.getURI() : vc.getName(); String vclassName = (vc.getName() == null || vc.getName().length() == 0) ? vc.getURI() : vc.getName();
results.add("<a href=\"./vclassEdit?uri="+URLEncoder.encode(vc.getURI(),"UTF-8")+"\">"+vclassName+"</a>"); results.add("<a href=\"./vclassEdit?uri=" + URLEncoder.encode(vc.getURI(), "UTF-8") + "\">" + vclassName + "</a>");
} catch (Exception e) { } catch (Exception e) {
results.add(vc.getName()); results.add(vc.getName());
} }

View file

@ -146,12 +146,11 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
if (props.size()==0) { if (props.size()==0) {
json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }"); json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }");
} else { } else {
Iterator<ObjectProperty> propsIt = props.iterator(); for (ObjectProperty prop1 : props) {
while (propsIt.hasNext()) { if (counter > 0) {
if ( counter > 0 ) {
json.append(", "); json.append(", ");
} }
ObjectProperty prop = propsIt.next(); ObjectProperty prop = prop1;
String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop); String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);
@ -165,7 +164,7 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
json.append("\"data\": { \"internalName\": ").append(JacksonUtils.quote(prop.getLocalNameWithPrefix())).append(", "); json.append("\"data\": { \"internalName\": ").append(JacksonUtils.quote(prop.getLocalNameWithPrefix())).append(", ");
ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI()); ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI());
if(opLangNeut == null) { if (opLangNeut == null) {
opLangNeut = prop; opLangNeut = prop;
} }
String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut); String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);

View file

@ -83,13 +83,12 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
if (classes != null) { if (classes != null) {
sortForPickList(classes, vreq); sortForPickList(classes, vreq);
Iterator<VClass> classesIt = classes.iterator(); for (VClass aClass : classes) {
while (classesIt.hasNext()) { if (counter > 0) {
if ( counter > 0 ) {
json.append(", "); json.append(", ");
} }
VClass cls = (VClass) classesIt.next(); VClass cls = aClass;
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) { if ((ontologyURI == null) || ((ontologyURI != null) && (cls.getNamespace() != null) && (ontologyURI.equals(cls.getNamespace())))) {
if (cls.getName() != null) if (cls.getName() != null)
try { try {
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./vclassEdit?uri=" + URLEncoder.encode(cls.getURI(), "UTF-8") + "'>" + cls.getPickListName() + "</a>")).append(", "); json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./vclassEdit?uri=" + URLEncoder.encode(cls.getURI(), "UTF-8") + "'>" + cls.getPickListName() + "</a>")).append(", ");
@ -104,13 +103,13 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
// get group name // get group name
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory(); WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
VClassGroupDao groupDao= wadf.getVClassGroupDao(); VClassGroupDao groupDao = wadf.getVClassGroupDao();
String groupURI = cls.getGroupURI(); String groupURI = cls.getGroupURI();
String groupName = ""; String groupName = "";
VClassGroup classGroup = null; VClassGroup classGroup = null;
if(groupURI != null) { if (groupURI != null) {
classGroup = groupDao.getGroupByURI(groupURI); classGroup = groupDao.getGroupByURI(groupURI);
if (classGroup!=null) { if (classGroup != null) {
groupName = classGroup.getPublicName(); groupName = classGroup.getPublicName();
} }
} }

View file

@ -134,15 +134,14 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI()); List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI());
if ((childURIstrs.size()>0) && position<MAXDEPTH) { if ((childURIstrs.size()>0) && position<MAXDEPTH) {
List<VClass> childClasses = new ArrayList<VClass>(); List<VClass> childClasses = new ArrayList<VClass>();
Iterator<String> childURIstrIt = childURIstrs.iterator(); for (String URIstr : childURIstrs) {
while (childURIstrIt.hasNext()) {
String URIstr = childURIstrIt.next();
try { try {
VClass child = vcDao.getVClassByURI(URIstr); VClass child = vcDao.getVClassByURI(URIstr);
if (!child.getURI().equals(OWL.Nothing.getURI())) { if (!child.getURI().equals(OWL.Nothing.getURI())) {
childClasses.add(child); childClasses.add(child);
} }
} catch (Exception e) {} } catch (Exception e) {
}
} }
sortForPickList(childClasses, vreq); sortForPickList(childClasses, vreq);
Iterator<VClass> childClassIt = childClasses.iterator(); Iterator<VClass> childClassIt = childClasses.iterator();

View file

@ -147,9 +147,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI()); List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) { if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
List<DataProperty> childProps = new ArrayList<DataProperty>(); List<DataProperty> childProps = new ArrayList<DataProperty>();
Iterator<String> childURIstrIt = childURIstrs.iterator(); for (String URIstr : childURIstrs) {
while (childURIstrIt.hasNext()) {
String URIstr = childURIstrIt.next();
DataProperty child = dpDao.getDataPropertyByURI(URIstr); DataProperty child = dpDao.getDataPropertyByURI(URIstr);
childProps.add(child); childProps.add(child);
} }

View file

@ -151,9 +151,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI()); List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) { if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
List<ObjectProperty> childProps = new ArrayList<ObjectProperty>(); List<ObjectProperty> childProps = new ArrayList<ObjectProperty>();
Iterator<String> childURIstrIt = childURIstrs.iterator(); for (String URIstr : childURIstrs) {
while (childURIstrIt.hasNext()) {
String URIstr = childURIstrIt.next();
ObjectProperty child = opDao.getObjectPropertyByURI(URIstr); ObjectProperty child = opDao.getObjectPropertyByURI(URIstr);
childProps.add(child); childProps.add(child);
} }

View file

@ -203,9 +203,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
List<DataProperty> props = new ArrayList<DataProperty>(); List<DataProperty> props = new ArrayList<DataProperty>();
VClass topVc = vcDao.getVClassByURI(uri); VClass topVc = vcDao.getVClassByURI(uri);
Collection <DataProperty> dataProps = dao.getDataPropertiesForVClass(uri); Collection <DataProperty> dataProps = dao.getDataPropertiesForVClass(uri);
Iterator<DataProperty> dataPropIt = dataProps.iterator(); for (DataProperty dp : dataProps) {
while (dataPropIt.hasNext()) {
DataProperty dp = dataPropIt.next();
if (!(propURIs.contains(dp.getURI()))) { if (!(propURIs.contains(dp.getURI()))) {
propURIs.add(dp.getURI()); propURIs.add(dp.getURI());
DataProperty prop = dao.getDataPropertyByURI(dp.getURI()); DataProperty prop = dao.getDataPropertyByURI(dp.getURI());
@ -256,20 +254,19 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
List childURIstrs = vcDao.getSubClassURIs(parent.getURI()); List childURIstrs = vcDao.getSubClassURIs(parent.getURI());
if ((childURIstrs.size()>0) && position<MAXDEPTH) { if ((childURIstrs.size()>0) && position<MAXDEPTH) {
List childClasses = new ArrayList(); List childClasses = new ArrayList();
Iterator childURIstrIt = childURIstrs.iterator(); for (Object childURIstr : childURIstrs) {
while (childURIstrIt.hasNext()) { String URIstr = (String) childURIstr;
String URIstr = (String) childURIstrIt.next();
try { try {
VClass child = (VClass) vcDao.getVClassByURI(URIstr); VClass child = (VClass) vcDao.getVClassByURI(URIstr);
if (!child.getURI().equals(OWL.Nothing.getURI())) { if (!child.getURI().equals(OWL.Nothing.getURI())) {
childClasses.add(child); childClasses.add(child);
} }
} catch (Exception e) {} } catch (Exception e) {
}
} }
Collections.sort(childClasses); Collections.sort(childClasses);
Iterator childClassIt = childClasses.iterator(); for (Object childClass : childClasses) {
while (childClassIt.hasNext()) { VClass child = (VClass) childClass;
VClass child = (VClass) childClassIt.next();
addChildren(vcDao, wadf, child, list, position + childShift, ontologyUri); addChildren(vcDao, wadf, child, list, position + childShift, ontologyUri);
} }

View file

@ -403,9 +403,7 @@ public class JSONReconcileServlet extends VitroHttpServlet {
query.addFields(VitroSearchTermNames.NAME_RAW, VitroSearchTermNames.URI, "*", "score"); // fields to retrieve query.addFields(VitroSearchTermNames.NAME_RAW, VitroSearchTermNames.URI, "*", "score"); // fields to retrieve
// if propertiesList has elements, add extra queries to query // if propertiesList has elements, add extra queries to query
Iterator<String[]> it = propertiesList.iterator(); for (String[] pvPair : propertiesList) {
while (it.hasNext()) {
String[] pvPair = it.next();
query.addFilterQueries(tokenizeNameQuery(pvPair[1]), VitroSearchTermNames.RDFTYPE + ":\"" + pvPair[0] + "\""); query.addFilterQueries(tokenizeNameQuery(pvPair[1]), VitroSearchTermNames.RDFTYPE + ":\"" + pvPair[0] + "\"");
} }

View file

@ -500,9 +500,7 @@ public class JenaIngestController extends BaseEditController {
List<Ontology> ontologiesObj = daoObj.getAllOntologies(); List<Ontology> ontologiesObj = daoObj.getAllOntologies();
List<String> prefixList = new ArrayList<>(); List<String> prefixList = new ArrayList<>();
if(ontologiesObj !=null && ontologiesObj.size()>0){ if(ontologiesObj !=null && ontologiesObj.size()>0){
Iterator<Ontology> ontItr = ontologiesObj.iterator(); for (Ontology ont : ontologiesObj) {
while(ontItr.hasNext()){
Ontology ont = ontItr.next();
prefixList.add(ont.getPrefix() == null ? "(not yet specified)" : ont.getPrefix()); prefixList.add(ont.getPrefix() == null ? "(not yet specified)" : ont.getPrefix());
prefixList.add(ont.getURI() == null ? "" : ont.getURI()); prefixList.add(ont.getURI() == null ? "" : ont.getURI());
} }

View file

@ -190,11 +190,9 @@ public class VClassDaoFiltering extends BaseFiltering implements VClassDao{
} }
} }
public void addVClassesToGroups(List groups) { public void addVClassesToGroups(List<VClassGroup> groups) {
if ((groups != null) && (groups.size()>0)) { if ((groups != null) && (groups.size()>0)) {
Iterator groupIt = groups.iterator(); for (VClassGroup g : groups) {
while (groupIt.hasNext()) {
VClassGroup g = (VClassGroup) groupIt.next();
this.addVClassesToGroup(g); this.addVClassesToGroup(g);
} }
} else { } else {

View file

@ -633,10 +633,8 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
isRoot = true; isRoot = true;
} else { } else {
isRoot = true; isRoot = true;
Iterator<Property> pit = parentList.iterator(); for (Property pt : parentList) {
while (pit.hasNext()) { if ((!pt.equals(op)) && (!(ontModel.contains(op, OWL.equivalentProperty, pt)) || (ontModel.contains(pt, OWL.equivalentProperty, op)))) {
Property pt = pit.next();
if ( (!pt.equals(op)) && (!(ontModel.contains(op,OWL.equivalentProperty,pt)) || (ontModel.contains(pt,OWL.equivalentProperty,op))) ) {
isRoot = false; isRoot = false;
} }
} }

View file

@ -66,10 +66,8 @@ public class DependentResourceDeleteJena {
ListIterator <Statement>removed = removedStmts.listIterator(); ListIterator <Statement>removed = removedStmts.listIterator();
while( removed.hasNext()){ while( removed.hasNext()){
Statement removedStmt = removed.next(); Statement removedStmt = removed.next();
ListIterator <Statement>changed = changedStmts.listIterator(); for (Statement changedStmt : changedStmts) {
while( changed.hasNext()){ if (removedStmt.equals(changedStmt)) {
Statement changedStmt = changed.next();
if( removedStmt.equals(changedStmt) ){
removed.remove(); removed.remove();
} }
} }

View file

@ -69,9 +69,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
HashSet<String> nonExternalIdPropURISet = new HashSet<String>(); HashSet<String> nonExternalIdPropURISet = new HashSet<String>();
if (ind != null) { if (ind != null) {
Collection<DataPropertyStatement> dpsColl = getWebappDaoFactory().getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(ind, dataPropertyURI); Collection<DataPropertyStatement> dpsColl = getWebappDaoFactory().getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(ind, dataPropertyURI);
Iterator<DataPropertyStatement> dpsIt = dpsColl.iterator(); for (DataPropertyStatement dps : dpsColl) {
while (dpsIt.hasNext()) {
DataPropertyStatement dps = dpsIt.next();
if (externalIdPropURISet.contains(dps.getDatapropURI())) { if (externalIdPropURISet.contains(dps.getDatapropURI())) {
externalIdStatements.add(dps); externalIdStatements.add(dps);
} else if (!nonExternalIdPropURISet.contains(dps.getDatapropURI())) { } else if (!nonExternalIdPropURISet.contains(dps.getDatapropURI())) {
@ -79,7 +77,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
tboxOntModel.enterCriticalSection(Lock.READ); tboxOntModel.enterCriticalSection(Lock.READ);
try { try {
Resource dataprop = tboxOntModel.getResource(dps.getDatapropURI()); Resource dataprop = tboxOntModel.getResource(dps.getDatapropURI());
if (dataprop != null && (tboxOntModel.contains(dataprop, DATAPROPERTY_ISEXTERNALID, ResourceFactory.createTypedLiteral(true)) || tboxOntModel.contains(dataprop, DATAPROPERTY_ISEXTERNALID, "TRUE") )) { if (dataprop != null && (tboxOntModel.contains(dataprop, DATAPROPERTY_ISEXTERNALID, ResourceFactory.createTypedLiteral(true)) || tboxOntModel.contains(dataprop, DATAPROPERTY_ISEXTERNALID, "TRUE"))) {
externalIdPropURISet.add(dps.getDatapropURI()); externalIdPropURISet.add(dps.getDatapropURI());
externalIdStatements.add(dps); externalIdStatements.add(dps);
} else { } else {

View file

@ -311,10 +311,7 @@ public class IndividualDaoSDB extends IndividualDaoJena {
private void fillIndividualsForObjectPropertyStatements(Individual entity){ private void fillIndividualsForObjectPropertyStatements(Individual entity){
getOntModel().enterCriticalSection(Lock.READ); getOntModel().enterCriticalSection(Lock.READ);
try { try {
Iterator e2eIt = entity.getObjectPropertyStatements().iterator(); for (ObjectPropertyStatement e2e : entity.getObjectPropertyStatements()) {
while (e2eIt.hasNext()) {
ObjectPropertyStatement e2e =
(ObjectPropertyStatement) e2eIt.next();
e2e.setSubject(makeIndividual(e2e.getSubjectURI())); e2e.setSubject(makeIndividual(e2e.getSubjectURI()));
e2e.setObject(makeIndividual(e2e.getObjectURI())); e2e.setObject(makeIndividual(e2e.getObjectURI()));
} }

View file

@ -517,13 +517,11 @@ public class IndividualJena extends IndividualImpl implements Individual {
protected void sortEnts2EntsForDisplay(){ protected void sortEnts2EntsForDisplay(){
if( getObjectPropertyList() == null ) return; if( getObjectPropertyList() == null ) return;
Iterator it = getObjectPropertyList().iterator(); for (ObjectProperty prop : getObjectPropertyList()) {
while(it.hasNext()){
ObjectProperty prop = (ObjectProperty)it.next();
/* if (prop.getObjectIndividualSortPropertyURI()==null) { /* if (prop.getObjectIndividualSortPropertyURI()==null) {
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements()); prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
} else {*/ } else {*/
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements()); prop.sortObjectPropertyStatementsForDisplay(prop, prop.getObjectPropertyStatements());
/* }*/ /* }*/
} }
} }

View file

@ -953,13 +953,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
protected void sortEnts2EntsForDisplay(){ protected void sortEnts2EntsForDisplay(){
if( getObjectPropertyList() == null ) return; if( getObjectPropertyList() == null ) return;
Iterator it = getObjectPropertyList().iterator(); for (ObjectProperty prop : getObjectPropertyList()) {
while(it.hasNext()){
ObjectProperty prop = (ObjectProperty)it.next();
/* if (prop.getObjectIndividualSortPropertyURI()==null) { /* if (prop.getObjectIndividualSortPropertyURI()==null) {
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements()); prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
} else {*/ } else {*/
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements()); prop.sortObjectPropertyStatementsForDisplay(prop, prop.getObjectPropertyStatements());
/* }*/ /* }*/
} }
} }

View file

@ -771,16 +771,14 @@ public class JenaBaseDao extends JenaBaseDaoCon {
} }
private Literal getLabel(String lang, List<RDFNode>labelList) { private Literal getLabel(String lang, List<RDFNode>labelList) {
Iterator<RDFNode> labelIt = labelList.iterator(); for (RDFNode label : labelList) {
while (labelIt.hasNext()) {
RDFNode label = labelIt.next();
if (label.isLiteral()) { if (label.isLiteral()) {
Literal labelLit = ((Literal)label); Literal labelLit = ((Literal) label);
String labelLanguage = labelLit.getLanguage(); String labelLanguage = labelLit.getLanguage();
if ( (labelLanguage == null) && (lang == null || lang.isEmpty()) ) { if ((labelLanguage == null) && (lang == null || lang.isEmpty())) {
return labelLit; return labelLit;
} }
if ( (lang != null) && (lang.equals(labelLanguage)) ) { if ((lang != null) && (lang.equals(labelLanguage))) {
return labelLit; return labelLit;
} }
} }
@ -1019,10 +1017,8 @@ public class JenaBaseDao extends JenaBaseDaoCon {
} }
// Now for each value, work backwards and see if it has an alternate path to the original resource. // Now for each value, work backwards and see if it has an alternate path to the original resource.
// If not, add it to the list of direct values. // If not, add it to the list of direct values.
Iterator<Resource> possibleValueIt = possibleValueSet.iterator(); for (Resource possibleRes : possibleValueSet) {
while (possibleValueIt.hasNext()) { StmtIterator pStmtIt = getOntModel().listStatements((Resource) null, prop, possibleRes);
Resource possibleRes = possibleValueIt.next();
StmtIterator pStmtIt = getOntModel().listStatements((Resource)null, prop, possibleRes);
boolean hasAlternatePath = false; boolean hasAlternatePath = false;
while (stmtIt.hasNext()) { while (stmtIt.hasNext()) {
Statement stmt = stmtIt.nextStatement(); Statement stmt = stmtIt.nextStatement();
@ -1048,10 +1044,8 @@ public class JenaBaseDao extends JenaBaseDaoCon {
possibleSubjectSet.add(stmt.getSubject()); possibleSubjectSet.add(stmt.getSubject());
} }
Iterator<Resource> possibleSubjectIt = possibleSubjectSet.iterator(); for (Resource possibleRes : possibleSubjectSet) {
while (possibleSubjectIt.hasNext()) { StmtIterator pStmtIt = getOntModel().listStatements(possibleRes, prop, (RDFNode) null);
Resource possibleRes = possibleSubjectIt.next();
StmtIterator pStmtIt = getOntModel().listStatements(possibleRes, prop, (RDFNode)null);
boolean hasAlternatePath = false; boolean hasAlternatePath = false;
while (stmtIt.hasNext()) { while (stmtIt.hasNext()) {
Statement stmt = stmtIt.nextStatement(); Statement stmt = stmtIt.nextStatement();

View file

@ -497,9 +497,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
} }
List<ObjectProperty> props = new ArrayList<ObjectProperty>(); List<ObjectProperty> props = new ArrayList<ObjectProperty>();
Iterator<String> keyIt = hash.keySet().iterator(); for (String key : hash.keySet()) {
while (keyIt.hasNext()) {
Object key = keyIt.next();
props.add(hash.get(key)); props.add(hash.get(key));
} }
return props; return props;

View file

@ -163,12 +163,10 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
private void getAllSubPropertyURIs(String propertyURI, HashSet<String> subtree){ private void getAllSubPropertyURIs(String propertyURI, HashSet<String> subtree){
List<String> directSubproperties = getSubPropertyURIs(propertyURI); List<String> directSubproperties = getSubPropertyURIs(propertyURI);
Iterator<String> it=directSubproperties.iterator(); for (String uri : directSubproperties) {
while(it.hasNext()){
String uri = it.next();
if (!subtree.contains(uri)) { if (!subtree.contains(uri)) {
subtree.add(uri); subtree.add(uri);
getAllSubPropertyURIs(uri,subtree); getAllSubPropertyURIs(uri, subtree);
} }
} }
} }
@ -206,12 +204,10 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
private void getAllSuperPropertyURIs(String propertyURI, HashSet<String> subtree){ private void getAllSuperPropertyURIs(String propertyURI, HashSet<String> subtree){
List<String> directSuperproperties = getSuperPropertyURIs(propertyURI,true); List<String> directSuperproperties = getSuperPropertyURIs(propertyURI,true);
Iterator<String> it=directSuperproperties.iterator(); for (String uri : directSuperproperties) {
while(it.hasNext()){
String uri = it.next();
if (!subtree.contains(uri)) { if (!subtree.contains(uri)) {
subtree.add(uri); subtree.add(uri);
getAllSuperPropertyURIs(uri,subtree); getAllSuperPropertyURIs(uri, subtree);
} }
} }
} }
@ -421,11 +417,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
List<OntClass> classList = ontClass.listEquivalentClasses().toList(); List<OntClass> classList = ontClass.listEquivalentClasses().toList();
classList.addAll(ontClass.listSubClasses().toList()); classList.addAll(ontClass.listSubClasses().toList());
Iterator<OntClass> it = classList.iterator(); for (OntClass oc : classList) {
while (it.hasNext()) {
OntClass oc = it.next();
if (!oc.isAnon()) { if (!oc.isAnon()) {
classSet.add(oc.getURI()); classSet.add(oc.getURI());
} else { } else {

View file

@ -148,13 +148,9 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
List existingPropertyInstances = new ArrayList(); List existingPropertyInstances = new ArrayList();
if (ent.getObjectPropertyList()==null) if (ent.getObjectPropertyList()==null)
return existingPropertyInstances; return existingPropertyInstances;
Iterator objPropertyIter = ent.getObjectPropertyList().iterator(); for (edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty op : ent.getObjectPropertyList()) {
while (objPropertyIter.hasNext()) { for (ObjectPropertyStatement objPropertyStmt : op.getObjectPropertyStatements()) {
edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty op = (edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty) objPropertyIter.next(); if (propertyURI == null || objPropertyStmt.getPropertyURI().equals(propertyURI)) {
Iterator objPropertyStmtIter = op.getObjectPropertyStatements().iterator();
while (objPropertyStmtIter.hasNext()) {
ObjectPropertyStatement objPropertyStmt = (ObjectPropertyStatement) objPropertyStmtIter.next();
if (propertyURI==null || objPropertyStmt.getPropertyURI().equals(propertyURI)) {
PropertyInstance pi = new PropertyInstance(); PropertyInstance pi = new PropertyInstance();
pi.setSubjectSide(true); pi.setSubjectSide(true);
pi.setSubjectEntURI(ent.getURI()); pi.setSubjectEntURI(ent.getURI());
@ -166,7 +162,7 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
pi.setObjectEntURI(objPropertyStmt.getObjectURI()); pi.setObjectEntURI(objPropertyStmt.getObjectURI());
pi.setPropertyURI(objPropertyStmt.getPropertyURI()); pi.setPropertyURI(objPropertyStmt.getPropertyURI());
if (objPropertyStmt.getProperty() != null) { if (objPropertyStmt.getProperty() != null) {
pi.setDomainPublic( (objPropertyStmt.getProperty().getDomainPublic()!=null) ? objPropertyStmt.getProperty().getDomainPublic() : objPropertyStmt.getProperty().getLocalName() ); pi.setDomainPublic((objPropertyStmt.getProperty().getDomainPublic() != null) ? objPropertyStmt.getProperty().getDomainPublic() : objPropertyStmt.getProperty().getLocalName());
} else { } else {
pi.setDomainPublic(objPropertyStmt.getPropertyURI()); pi.setDomainPublic(objPropertyStmt.getPropertyURI());
} }

View file

@ -411,12 +411,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
public void getAllSubClassURIs(String classURI, HashSet<String> subtree){ public void getAllSubClassURIs(String classURI, HashSet<String> subtree){
List<String> directSubclasses = getSubClassURIs(classURI); List<String> directSubclasses = getSubClassURIs(classURI);
Iterator<String> it=directSubclasses.iterator(); for (String uri : directSubclasses) {
while(it.hasNext()){
String uri = it.next();
if (!subtree.contains(uri)) { if (!subtree.contains(uri)) {
subtree.add(uri); subtree.add(uri);
getAllSubClassURIs(uri,subtree); getAllSubClassURIs(uri, subtree);
} }
} }
} }
@ -450,12 +448,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
public void getAllSuperClassURIs(String classURI, HashSet<String> subtree){ public void getAllSuperClassURIs(String classURI, HashSet<String> subtree){
List<String> directSuperclasses = getSuperClassURIs(classURI, true); List<String> directSuperclasses = getSuperClassURIs(classURI, true);
Iterator<String> it=directSuperclasses.iterator(); for (String uri : directSuperclasses) {
while(it.hasNext()){
String uri = it.next();
if (!subtree.contains(uri)) { if (!subtree.contains(uri)) {
subtree.add(uri); subtree.add(uri);
getAllSuperClassURIs(uri,subtree); getAllSuperClassURIs(uri, subtree);
} }
} }
} }
@ -787,9 +783,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
// if this model infers types based on the taxonomy, adding the subclasses will only // if this model infers types based on the taxonomy, adding the subclasses will only
// waste time for no benefit // waste time for no benefit
if (!isUnderlyingStoreReasoned()) { if (!isUnderlyingStoreReasoned()) {
Iterator classURIs = getAllSubClassURIs(getClassURIStr(superclass)).iterator(); for (String classURI : getAllSubClassURIs(getClassURIStr(superclass))) {
while (classURIs.hasNext()) {
String classURI = (String) classURIs.next();
VClass vClass = getVClassByURI(classURI); VClass vClass = getVClassByURI(classURI);
if (vClass != null) if (vClass != null)
vClasses.add(vClass); vClasses.add(vClass);
@ -919,9 +913,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
getOntModel().enterCriticalSection(Lock.READ); getOntModel().enterCriticalSection(Lock.READ);
try { try {
if (groups != null) { if (groups != null) {
Iterator groupIt = groups.iterator(); for (VClassGroup g : groups) {
while (groupIt.hasNext()) {
VClassGroup g = (VClassGroup) groupIt.next();
addVClassesToGroup(g); addVClassesToGroup(g);
} }
} }

View file

@ -87,9 +87,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
groupIt.close(); groupIt.close();
} }
Collections.sort(groups); Collections.sort(groups);
Iterator<VClassGroup> groupsIt = groups.iterator(); for (VClassGroup group : groups) {
while (groupsIt.hasNext()) {
VClassGroup group = groupsIt.next();
map.put(group.getPublicName(), group); map.put(group.getPublicName(), group);
} }
return map; return map;

View file

@ -39,12 +39,10 @@ public class IndividualDataPropertyStatementProcessor implements ChangeListener
private void processDataprops (EditProcessObject epo) { private void processDataprops (EditProcessObject epo) {
HashSet<String> deletedDataPropertyURIs = new HashSet<String>(); HashSet<String> deletedDataPropertyURIs = new HashSet<String>();
Map dpm = datapropParameterMap(epo.getRequestParameterMap()); Map<String, String[]> dpm = datapropParameterMap(epo.getRequestParameterMap());
DataPropertyStatementDao dataPropertyStatementDao = (DataPropertyStatementDao)epo.getAdditionalDaoMap().get("DataPropertyStatement"); DataPropertyStatementDao dataPropertyStatementDao = (DataPropertyStatementDao)epo.getAdditionalDaoMap().get("DataPropertyStatement");
Iterator dpmIt = dpm.keySet().iterator(); for (String key : dpm.keySet()) {
while (dpmIt.hasNext()) { String[] data = (String[]) dpm.get(key);
String key = (String) dpmIt.next();
String[] data = (String[])dpm.get(key);
for (String aData : data) { for (String aData : data) {
String[] keyArg = key.split("_"); String[] keyArg = key.split("_");
String rowId = keyArg[2]; String rowId = keyArg[2];
@ -105,13 +103,11 @@ public class IndividualDataPropertyStatementProcessor implements ChangeListener
} }
// might want to roll this into the other thing // might want to roll this into the other thing
private HashMap datapropParameterMap(Map requestParameterMap) { private Map<String, String[]> datapropParameterMap(Map<String, String[]> requestParameterMap) {
HashMap dpm = new HashMap(); Map<String, String[]> dpm = new HashMap<String, String[]>();
Iterator paramIt = requestParameterMap.keySet().iterator(); for (String key : requestParameterMap.keySet()) {
while (paramIt.hasNext()) {
String key = (String) paramIt.next();
if (key.startsWith("_DataPropertyStatement")) { if (key.startsWith("_DataPropertyStatement")) {
dpm.put(key,requestParameterMap.get(key)); dpm.put(key, requestParameterMap.get(key));
} }
} }
return dpm; return dpm;

View file

@ -463,10 +463,8 @@ public class ProcessRdfForm {
Map<String, List<String>> newUris = new HashMap<String, List<String>>(); Map<String, List<String>> newUris = new HashMap<String, List<String>>();
//Check if any values from the submission have the "force new uri" value //Check if any values from the submission have the "force new uri" value
//TODO: Check how to handle multiple new resource values //TODO: Check how to handle multiple new resource values
Iterator<String> keyIterator = urisFromForm.keySet().iterator(); for (String key : urisFromForm.keySet()) {
while(keyIterator.hasNext()) { if (urisFromForm.get(key).contains(EditConfigurationConstants.NEW_URI_SENTINEL)) {
String key = keyIterator.next();
if(urisFromForm.get(key).contains(EditConfigurationConstants.NEW_URI_SENTINEL)) {
String newUri = urisForNewResources.get(key); String newUri = urisForNewResources.get(key);
List<String> newUrisForKey = new ArrayList<String>(); List<String> newUrisForKey = new ArrayList<String>();
newUrisForKey.add(newUri); newUrisForKey.add(newUri);

View file

@ -91,12 +91,8 @@ public class ABoxUpdater {
*/ */
public void processClassChanges(List<AtomicOntologyChange> changes) throws IOException { public void processClassChanges(List<AtomicOntologyChange> changes) throws IOException {
Iterator<AtomicOntologyChange> iter = changes.iterator(); for (AtomicOntologyChange change : changes) {
switch (change.getAtomicChangeType()) {
while (iter.hasNext()) {
AtomicOntologyChange change = iter.next();
switch (change.getAtomicChangeType()){
case ADD: case ADD:
addClass(change); addClass(change);
break; break;
@ -236,17 +232,13 @@ public class ABoxUpdater {
namedClassList.add(OWL_THING); namedClassList.add(OWL_THING);
} }
Iterator<OntClass> classIter = namedClassList.iterator(); for (OntClass parentOfAddedClass : namedClassList) {
while (classIter.hasNext()) {
OntClass parentOfAddedClass = classIter.next();
if (!parentOfAddedClass.equals(OWL.Thing)) { if (!parentOfAddedClass.equals(OWL.Thing)) {
Iterator<String> graphIt = dataset.listNames(); Iterator<String> graphIt = dataset.listNames();
while(graphIt.hasNext()) { while (graphIt.hasNext()) {
String graph = graphIt.next(); String graph = graphIt.next();
if(!KnowledgeBaseUpdater.isUpdatableABoxGraph(graph)){ if (!KnowledgeBaseUpdater.isUpdatableABoxGraph(graph)) {
continue; continue;
} }
Model aboxModel = dataset.getNamedModel(graph); Model aboxModel = dataset.getNamedModel(graph);
@ -259,7 +251,7 @@ public class ABoxUpdater {
//TODO - take out the detailed logging after our internal testing is completed. //TODO - take out the detailed logging after our internal testing is completed.
logger.log("There " + ((count > 1) ? "are" : "is") + " " + count + " individual" + ((count > 1) ? "s" : "") + " in the model that " + ((count > 1) ? "are" : "is") + " of type " + parentOfAddedClass.getURI() + "," + logger.log("There " + ((count > 1) ? "are" : "is") + " " + count + " individual" + ((count > 1) ? "s" : "") + " in the model that " + ((count > 1) ? "are" : "is") + " of type " + parentOfAddedClass.getURI() + "," +
" and a new subclass of that class has been added: " + addedClass.getURI() + ". " + " and a new subclass of that class has been added: " + addedClass.getURI() + ". " +
"Please review " + ((count > 1) ? "these" : "this") + " individual" + ((count > 1) ? "s" : "") + " to see whether " + ((count > 1) ? "they" : "it") + " should be of type: " + addedClass.getURI() ); "Please review " + ((count > 1) ? "these" : "this") + " individual" + ((count > 1) ? "s" : "") + " to see whether " + ((count > 1) ? "they" : "it") + " should be of type: " + addedClass.getURI());
} }
} }
@ -415,16 +407,14 @@ public class ABoxUpdater {
public void processPropertyChanges(List<AtomicOntologyChange> changes) throws IOException { public void processPropertyChanges(List<AtomicOntologyChange> changes) throws IOException {
Iterator<AtomicOntologyChange> propItr = changes.iterator(); for (AtomicOntologyChange propChangeObj : changes) {
while(propItr.hasNext()){
AtomicOntologyChange propChangeObj = propItr.next();
log.debug("processing " + propChangeObj); log.debug("processing " + propChangeObj);
try { try {
if (propChangeObj.getAtomicChangeType() == null) { if (propChangeObj.getAtomicChangeType() == null) {
log.error("Missing change type; skipping " + propChangeObj); log.error("Missing change type; skipping " + propChangeObj);
continue; continue;
} }
switch (propChangeObj.getAtomicChangeType()){ switch (propChangeObj.getAtomicChangeType()) {
case ADD: case ADD:
log.debug("add"); log.debug("add");
addProperty(propChangeObj); addProperty(propChangeObj);
@ -443,7 +433,7 @@ public class ABoxUpdater {
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e,e); log.error(e, e);
} }
} }
} }

View file

@ -419,13 +419,10 @@ public class KnowledgeBaseUpdater {
List<AtomicOntologyChange> changeList, OntModel newTboxModel, List<AtomicOntologyChange> changeList, OntModel newTboxModel,
OntModel oldTboxModel) throws IOException { OntModel oldTboxModel) throws IOException {
Iterator<AtomicOntologyChange> listItr = changeList.iterator(); for (AtomicOntologyChange changeObj : changeList) {
if (changeObj.getSourceURI() != null) {
while(listItr.hasNext()) {
AtomicOntologyChange changeObj = listItr.next();
if (changeObj.getSourceURI() != null){
log.debug("triaging " + changeObj); log.debug("triaging " + changeObj);
if (oldTboxModel.getOntProperty(changeObj.getSourceURI()) != null){ if (oldTboxModel.getOntProperty(changeObj.getSourceURI()) != null) {
atomicPropertyChanges.add(changeObj); atomicPropertyChanges.add(changeObj);
log.debug("added to property changes"); log.debug("added to property changes");
} else if (oldTboxModel.getOntClass(changeObj.getSourceURI()) != null) { } else if (oldTboxModel.getOntClass(changeObj.getSourceURI()) != null) {
@ -435,24 +432,24 @@ public class KnowledgeBaseUpdater {
atomicPropertyChanges.add(changeObj); atomicPropertyChanges.add(changeObj);
} else if ("Class".equals(changeObj.getNotes())) { } else if ("Class".equals(changeObj.getNotes())) {
atomicClassChanges.add(changeObj); atomicClassChanges.add(changeObj);
} else{ } else {
logger.log("WARNING: Source URI is neither a Property" + logger.log("WARNING: Source URI is neither a Property" +
" nor a Class. " + "Change Object skipped for sourceURI: " + changeObj.getSourceURI()); " nor a Class. " + "Change Object skipped for sourceURI: " + changeObj.getSourceURI());
} }
} else if(changeObj.getDestinationURI() != null){ } else if (changeObj.getDestinationURI() != null) {
if (newTboxModel.getOntProperty(changeObj.getDestinationURI()) != null) { if (newTboxModel.getOntProperty(changeObj.getDestinationURI()) != null) {
atomicPropertyChanges.add(changeObj); atomicPropertyChanges.add(changeObj);
} else if(newTboxModel.getOntClass(changeObj. } else if (newTboxModel.getOntClass(changeObj.
getDestinationURI()) != null) { getDestinationURI()) != null) {
atomicClassChanges.add(changeObj); atomicClassChanges.add(changeObj);
} else{ } else {
logger.log("WARNING: Destination URI is neither a Property" + logger.log("WARNING: Destination URI is neither a Property" +
" nor a Class. " + "Change Object skipped for destinationURI: " + changeObj.getDestinationURI()); " nor a Class. " + "Change Object skipped for destinationURI: " + changeObj.getDestinationURI());
} }
} else{ } else {
logger.log("WARNING: Source and Destination URI can't be null. " + "Change Object skipped" ); logger.log("WARNING: Source and Destination URI can't be null. " + "Change Object skipped");
} }
} }
//logger.log("Property and Class change Object lists have been created"); //logger.log("Property and Class change Object lists have been created");

View file

@ -171,10 +171,8 @@ public class LanguageFilteringRDFService implements RDFService {
s.sparqlSelectQuery(query, RDFService.ResultFormat.JSON)); s.sparqlSelectQuery(query, RDFService.ResultFormat.JSON));
List<QuerySolution> solnList = getSolutionList(resultSet); List<QuerySolution> solnList = getSolutionList(resultSet);
List<String> vars = resultSet.getResultVars(); List<String> vars = resultSet.getResultVars();
Iterator<String> varIt = vars.iterator(); for (String var : vars) {
while (varIt.hasNext()) { for (int i = 0; i < solnList.size(); i++) {
String var = varIt.next();
for (int i = 0 ; i < solnList.size(); i ++ ) {
QuerySolution s = solnList.get(i); QuerySolution s = solnList.get(i);
if (s == null) { if (s == null) {
continue; continue;
@ -186,7 +184,7 @@ public class LanguageFilteringRDFService implements RDFService {
List<RowIndexedLiteral> candidatesForRemoval = List<RowIndexedLiteral> candidatesForRemoval =
new ArrayList<RowIndexedLiteral>(); new ArrayList<RowIndexedLiteral>();
candidatesForRemoval.add(new RowIndexedLiteral(node.asLiteral(), i)); candidatesForRemoval.add(new RowIndexedLiteral(node.asLiteral(), i));
for (int j = i + 1; j < solnList.size(); j ++) { for (int j = i + 1; j < solnList.size(); j++) {
QuerySolution t = solnList.get(j); QuerySolution t = solnList.get(j);
if (t == null) { if (t == null) {
continue; continue;
@ -204,7 +202,7 @@ public class LanguageFilteringRDFService implements RDFService {
Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator(); Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator();
String langRegister = null; String langRegister = null;
boolean chuckRemaining = false; boolean chuckRemaining = false;
while(candIt.hasNext()) { while (candIt.hasNext()) {
RowIndexedLiteral rlit = candIt.next(); RowIndexedLiteral rlit = candIt.next();
if (chuckRemaining) { if (chuckRemaining) {
solnList.set(rlit.getIndex(), null); solnList.set(rlit.getIndex(), null);
@ -218,9 +216,7 @@ public class LanguageFilteringRDFService implements RDFService {
} }
} }
List<QuerySolution> compactedList = new ArrayList<QuerySolution>(); List<QuerySolution> compactedList = new ArrayList<QuerySolution>();
Iterator<QuerySolution> solIt = solnList.iterator(); for (QuerySolution soln : solnList) {
while(solIt.hasNext()) {
QuerySolution soln = solIt.next();
if (soln != null) { if (soln != null) {
compactedList.add(soln); compactedList.add(soln);
} }
@ -268,10 +264,8 @@ public class LanguageFilteringRDFService implements RDFService {
protected void endProcessing() { protected void endProcessing() {
chainStartProcessing(); chainStartProcessing();
Iterator<String> varIt = vars.iterator(); for (String var : vars) {
while (varIt.hasNext()) { for (int i = 0; i < solnList.size(); i++) {
String var = varIt.next();
for (int i = 0 ; i < solnList.size(); i ++ ) {
QuerySolution s = solnList.get(i); QuerySolution s = solnList.get(i);
if (s == null) { if (s == null) {
continue; continue;
@ -283,7 +277,7 @@ public class LanguageFilteringRDFService implements RDFService {
List<RowIndexedLiteral> candidatesForRemoval = List<RowIndexedLiteral> candidatesForRemoval =
new ArrayList<RowIndexedLiteral>(); new ArrayList<RowIndexedLiteral>();
candidatesForRemoval.add(new RowIndexedLiteral(node.asLiteral(), i)); candidatesForRemoval.add(new RowIndexedLiteral(node.asLiteral(), i));
for (int j = i + 1; j < solnList.size(); j ++) { for (int j = i + 1; j < solnList.size(); j++) {
QuerySolution t = solnList.get(j); QuerySolution t = solnList.get(j);
if (t == null) { if (t == null) {
continue; continue;
@ -301,7 +295,7 @@ public class LanguageFilteringRDFService implements RDFService {
Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator(); Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator();
String langRegister = null; String langRegister = null;
boolean chuckRemaining = false; boolean chuckRemaining = false;
while(candIt.hasNext()) { while (candIt.hasNext()) {
RowIndexedLiteral rlit = candIt.next(); RowIndexedLiteral rlit = candIt.next();
if (chuckRemaining) { if (chuckRemaining) {
solnList.set(rlit.getIndex(), null); solnList.set(rlit.getIndex(), null);
@ -315,9 +309,7 @@ public class LanguageFilteringRDFService implements RDFService {
} }
} }
Iterator<QuerySolution> solIt = solnList.iterator(); for (QuerySolution soln : solnList) {
while(solIt.hasNext()) {
QuerySolution soln = solIt.next();
if (soln != null) { if (soln != null) {
chainProcessQuerySolution(soln); chainProcessQuerySolution(soln);
} }

View file

@ -142,9 +142,7 @@ public abstract class RDFServiceImpl implements RDFService {
protected void notifyListeners(ModelChange modelChange) throws IOException { protected void notifyListeners(ModelChange modelChange) throws IOException {
modelChange.getSerializedModel().reset(); modelChange.getSerializedModel().reset();
Iterator<ChangeListener> iter = registeredListeners.iterator(); for (ChangeListener listener : registeredListeners) {
while (iter.hasNext()) {
ChangeListener listener = iter.next();
listener.notifyModelChange(modelChange); listener.notifyModelChange(modelChange);
} }
log.debug(registeredJenaListeners.size() + " registered Jena listeners"); log.debug(registeredJenaListeners.size() + " registered Jena listeners");
@ -174,15 +172,11 @@ public abstract class RDFServiceImpl implements RDFService {
} }
public void notifyListenersOfEvent(Object event) { public void notifyListenersOfEvent(Object event) {
Iterator<ChangeListener> iter = registeredListeners.iterator(); for (ChangeListener listener : registeredListeners) {
while (iter.hasNext()) {
ChangeListener listener = iter.next();
// TODO what is the graphURI parameter for? // TODO what is the graphURI parameter for?
listener.notifyEvent(null, event); listener.notifyEvent(null, event);
} }
Iterator<ModelChangedListener> jenaIter = registeredJenaListeners.iterator(); for (ModelChangedListener listener : registeredJenaListeners) {
while (jenaIter.hasNext()) {
ModelChangedListener listener = jenaIter.next();
listener.notifyEvent(null, event); listener.notifyEvent(null, event);
} }
} }

View file

@ -79,9 +79,7 @@ public class RDFServiceModel extends RDFServiceJena implements RDFService {
this.notifyListenersOfEvent(o); this.notifyListenersOfEvent(o);
} }
Iterator<ModelChange> csIt = changeSet.getModelChanges().iterator(); for (ModelChange modelChange : changeSet.getModelChanges()) {
while (csIt.hasNext()) {
ModelChange modelChange = csIt.next();
if (!modelChange.getSerializedModel().markSupported()) { if (!modelChange.getSerializedModel().markSupported()) {
byte[] bytes = IOUtils.toByteArray(modelChange.getSerializedModel()); byte[] bytes = IOUtils.toByteArray(modelChange.getSerializedModel());
modelChange.setSerializedModel(new ByteArrayInputStream(bytes)); modelChange.setSerializedModel(new ByteArrayInputStream(bytes));

View file

@ -178,9 +178,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
this.notifyListenersOfEvent(o); this.notifyListenersOfEvent(o);
} }
Iterator<ModelChange> csIt = changeSet.getModelChanges().iterator(); for (ModelChange modelChange : changeSet.getModelChanges()) {
while (csIt.hasNext()) {
ModelChange modelChange = csIt.next();
if (!modelChange.getSerializedModel().markSupported()) { if (!modelChange.getSerializedModel().markSupported()) {
byte[] bytes = IOUtils.toByteArray(modelChange.getSerializedModel()); byte[] bytes = IOUtils.toByteArray(modelChange.getSerializedModel());
modelChange.setSerializedModel(new ByteArrayInputStream(bytes)); modelChange.setSerializedModel(new ByteArrayInputStream(bytes));

View file

@ -73,10 +73,8 @@ public class IndividualURIQueue<E> implements Queue<E> {
@Override @Override
public synchronized boolean retainAll(Collection<?> c) { public synchronized boolean retainAll(Collection<?> c) {
boolean changed = false; boolean changed = false;
Iterator<E> it = m.keySet().iterator(); for (E e : m.keySet()) {
while(it.hasNext()) { if (!c.contains(e)) {
E e = it.next();
if(!c.contains(e)) {
m.remove(e); m.remove(e);
q.remove(e); q.remove(e);
changed = true; changed = true;

View file

@ -563,9 +563,7 @@ public class SimpleReasoner extends StatementListener
aboxModel.enterCriticalSection(Lock.READ); aboxModel.enterCriticalSection(Lock.READ);
try { try {
Iterator<Resource> sameIter = sameIndividuals.iterator(); for (Resource res : sameIndividuals) {
while (sameIter.hasNext()) {
Resource res = sameIter.next();
StmtIterator typeIt = aboxModel.listStatements(res, RDF.type, (RDFNode) null); StmtIterator typeIt = aboxModel.listStatements(res, RDF.type, (RDFNode) null);
while (typeIt.hasNext()) { while (typeIt.hasNext()) {
Statement stmt = typeIt.nextStatement(); Statement stmt = typeIt.nextStatement();
@ -802,12 +800,9 @@ public class SimpleReasoner extends StatementListener
if (handleSameAs) { if (handleSameAs) {
List<Resource> sameIndividuals = List<Resource> sameIndividuals =
getSameIndividuals(infStmt.getSubject().asResource(), inferenceModel); getSameIndividuals(infStmt.getSubject().asResource(), inferenceModel);
Iterator<Resource> sameIter = sameIndividuals.iterator(); for (Resource subject : sameIndividuals) {
while (sameIter.hasNext()) {
Resource subject = sameIter.next();
Statement sameStmt = Statement sameStmt =
ResourceFactory.createStatement(subject,infStmt.getPredicate(), ResourceFactory.createStatement(subject, infStmt.getPredicate(),
infStmt.getObject()); infStmt.getObject());
if (subject.equals(infStmt.getObject()) if (subject.equals(infStmt.getObject())
&& OWL.sameAs.equals(infStmt.getPredicate())) { && OWL.sameAs.equals(infStmt.getPredicate())) {
@ -860,10 +855,9 @@ public class SimpleReasoner extends StatementListener
List<Resource> sameIndividuals = List<Resource> sameIndividuals =
getSameIndividuals(infStmt.getSubject().asResource(), inferenceModel); getSameIndividuals(infStmt.getSubject().asResource(), inferenceModel);
Iterator<Resource> sameIter = sameIndividuals.iterator(); for (Resource sameIndividual : sameIndividuals) {
while (sameIter.hasNext()) {
Statement infStmtSame = Statement infStmtSame =
ResourceFactory.createStatement(sameIter.next(), ResourceFactory.createStatement(sameIndividual,
infStmt.getPredicate(), infStmt.getObject()); infStmt.getPredicate(), infStmt.getObject());
if ((!checkEntailment if ((!checkEntailment
|| !entailedStatement(infStmtSame)) || !entailedStatement(infStmtSame))
@ -936,16 +930,9 @@ public class SimpleReasoner extends StatementListener
List<OntClass> types2 = new ArrayList<OntClass>(); List<OntClass> types2 = new ArrayList<OntClass>();
types2.addAll(types); types2.addAll(types);
Iterator<OntClass> typeIter = types.iterator(); for (OntClass type : types) {
while (typeIter.hasNext()) {
OntClass type = typeIter.next();
boolean add = true; boolean add = true;
Iterator<OntClass> typeIter2 = types2.iterator(); for (OntClass type2 : types2) {
while (typeIter2.hasNext()) {
OntClass type2 = typeIter2.next();
if (type.equals(type2)) { if (type.equals(type2)) {
continue; continue;
} }
@ -965,16 +952,13 @@ public class SimpleReasoner extends StatementListener
while (iter.hasNext()) { while (iter.hasNext()) {
Statement stmt = iter.next(); Statement stmt = iter.next();
Resource res = stmt.getSubject(); Resource res = stmt.getSubject();
if ((res == null) || res.isAnon() || equivalentClasses.contains(res) ) { if ((res == null) || res.isAnon() || equivalentClasses.contains(res)) {
continue; continue;
} }
equivalentClasses.add(res); equivalentClasses.add(res);
} }
Iterator<Resource> eIter = equivalentClasses.iterator(); for (Resource equivClass : equivalentClasses) {
while (eIter.hasNext()) {
Resource equivClass = eIter.next();
if (equivClass.isAnon()) continue; if (equivClass.isAnon()) continue;
typeURIs.add(equivClass.getURI()); typeURIs.add(equivClass.getURI());
} }
@ -1019,11 +1003,9 @@ public class SimpleReasoner extends StatementListener
removeInference(rIter.next(), inferenceModel, true, false); removeInference(rIter.next(), inferenceModel, true, false);
} }
Iterator<String> typeIter = typeURIs.iterator(); for (String typeURI : typeURIs) {
while (typeIter.hasNext()) { Statement mstStmt = ResourceFactory.createStatement(individual, mostSpecificType, ResourceFactory.createResource(typeURI));
String typeURI = typeIter.next(); addInference(mstStmt, inferenceModel, true);
Statement mstStmt = ResourceFactory.createStatement(individual,mostSpecificType,ResourceFactory.createResource(typeURI));
addInference(mstStmt,inferenceModel,true);
} }
} }

View file

@ -174,10 +174,8 @@ public abstract class SimpleBridgingRule implements ReasonerPlugin {
} else if (stmt.getPredicate().equals(assertedProp2)) { } else if (stmt.getPredicate().equals(assertedProp2)) {
z = stmt.getObject(); z = stmt.getObject();
} }
Iterator<Statement> sit = aboxInferencesModel.listStatements(x, this.inferredProp, z).toList().iterator();
while(sit.hasNext()) { for (Statement s : aboxInferencesModel.listStatements(x, this.inferredProp, z).toList()) {
Statement s = sit.next();
Query ask = createQuery(this.retractionTestString, stmt, s); Query ask = createQuery(this.retractionTestString, stmt, s);
QueryExecution qe = QueryExecutionFactory.create(ask, aboxAssertionsModel); QueryExecution qe = QueryExecutionFactory.create(ask, aboxAssertionsModel);
try { try {
@ -185,7 +183,7 @@ public abstract class SimpleBridgingRule implements ReasonerPlugin {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("==> removing " + s); log.debug("==> removing " + s);
} }
if (simpleReasoner != null) simpleReasoner.removeInference(s,aboxInferencesModel); if (simpleReasoner != null) simpleReasoner.removeInference(s, aboxInferencesModel);
} }
} finally { } finally {
qe.close(); qe.close();

View file

@ -197,18 +197,16 @@ public class PagedSearchController extends FreemarkerHttpServlet {
} }
List<Individual> individuals = new ArrayList<Individual>(docs.size()); List<Individual> individuals = new ArrayList<Individual>(docs.size());
Iterator<SearchResultDocument> docIter = docs.iterator(); for (SearchResultDocument doc : docs) {
while( docIter.hasNext() ){
try { try {
SearchResultDocument doc = docIter.next();
String uri = doc.getStringValue(VitroSearchTermNames.URI); String uri = doc.getStringValue(VitroSearchTermNames.URI);
Individual ind = iDao.getIndividualByURI(uri); Individual ind = iDao.getIndividualByURI(uri);
if(ind != null) { if (ind != null) {
ind.setSearchSnippet( getSnippet(doc, response) ); ind.setSearchSnippet(getSnippet(doc, response));
individuals.add(ind); individuals.add(ind);
} }
} catch(Exception e) { } catch (Exception e) {
log.error("Problem getting usable individuals from search hits. ",e); log.error("Problem getting usable individuals from search hits. ", e);
} }
} }

View file

@ -77,10 +77,8 @@ public class GetAllClasses extends BaseEditController {
while (classGroupIt.hasNext()) { while (classGroupIt.hasNext()) {
VClassGroup group = (VClassGroup) classGroupIt.next(); VClassGroup group = (VClassGroup) classGroupIt.next();
List classes = group.getVitroClassList(); List<VClass> classes = group.getVitroClassList();
Iterator classIt = classes.iterator(); for (VClass clazz : classes) {
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>");
} }
} }

View file

@ -644,9 +644,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
} }
public PropertyGroupTemplateModel pullPropertyGroup(String groupName) { public PropertyGroupTemplateModel pullPropertyGroup(String groupName) {
Iterator<PropertyGroupTemplateModel> groupIt = groups.iterator(); for (PropertyGroupTemplateModel group : groups) {
while (groupIt.hasNext()) {
PropertyGroupTemplateModel group = groupIt.next();
if (groupName.equals(group.getName())) { if (groupName.equals(group.getName())) {
groups.remove(group); groups.remove(group);
return group; return group;

View file

@ -426,16 +426,14 @@ public class VClassJenaTest {
} }
private String getLabel2(String lang, List<RDFNode>labelList) { private String getLabel2(String lang, List<RDFNode>labelList) {
Iterator<RDFNode> labelIt = labelList.iterator(); for (RDFNode label : labelList) {
while (labelIt.hasNext()) {
RDFNode label = labelIt.next();
if (label.isLiteral()) { if (label.isLiteral()) {
Literal labelLit = ((Literal)label); Literal labelLit = ((Literal) label);
String labelLanguage = labelLit.getLanguage(); String labelLanguage = labelLit.getLanguage();
if ( (labelLanguage==null) && (lang==null) ) { if ((labelLanguage == null) && (lang == null)) {
return labelLit.getLexicalForm(); return labelLit.getLexicalForm();
} }
if ( (lang != null) && (lang.equals(labelLanguage)) ) { if ((lang != null) && (lang.equals(labelLanguage))) {
return labelLit.getLexicalForm(); return labelLit.getLexicalForm();
} }
} }