Minor code improvements
This commit is contained in:
parent
d97544b991
commit
751d50f93a
44 changed files with 476 additions and 625 deletions
|
@ -178,19 +178,16 @@ public class BaseEditController extends VitroHttpServlet {
|
|||
|
||||
List<String> bodyVal = new ArrayList<String>();
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
Iterator<Option> itr = optionList.iterator();
|
||||
while(itr.hasNext()){
|
||||
Option option = itr.next();
|
||||
hashMap.put(option.getBody(),option);
|
||||
bodyVal.add(option.getBody());
|
||||
for (Option option : optionList) {
|
||||
hashMap.put(option.getBody(), option);
|
||||
bodyVal.add(option.getBody());
|
||||
}
|
||||
|
||||
|
||||
Collections.sort(bodyVal, new ListComparator(vreq.getCollator()));
|
||||
ListIterator<String> itrStr = bodyVal.listIterator();
|
||||
while(itrStr.hasNext()){
|
||||
options.add(hashMap.get(itrStr.next()));
|
||||
}
|
||||
for (String aBodyVal : bodyVal) {
|
||||
options.add(hashMap.get(aBodyVal));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,27 +162,26 @@ public class DynamicFieldsTag extends EditTag {
|
|||
|
||||
out.print(preWithVars);
|
||||
|
||||
Iterator<DynamicFieldRow> rowIt = dynf.getRowList().iterator();
|
||||
while (rowIt.hasNext()) {
|
||||
for (DynamicFieldRow dynamicFieldRow : dynf.getRowList()) {
|
||||
++i;
|
||||
DynamicFieldRow row = rowIt.next();
|
||||
if (row.getValue()==null)
|
||||
DynamicFieldRow row = dynamicFieldRow;
|
||||
if (row.getValue() == null)
|
||||
row.setValue("");
|
||||
if (row.getValue().length()>0) {
|
||||
if (row.getValue().length() > 0) {
|
||||
StringBuilder taName = new StringBuilder().append("_").append(dynf.getTable()).append("_");
|
||||
taName.append(row.getId()).append("_");
|
||||
Iterator paramIt = row.getParameterMap().keySet().iterator();
|
||||
while(paramIt.hasNext()) {
|
||||
while (paramIt.hasNext()) {
|
||||
String key = (String) paramIt.next();
|
||||
String value = (String) row.getParameterMap().get(key);
|
||||
byte[] valueInBase64 = Base64.encodeBase64(value.getBytes());
|
||||
taName.append(key).append(":").append(new String(valueInBase64)).append(";");
|
||||
}
|
||||
if (row.getValue().length()>0) {
|
||||
if (row.getValue().length() > 0) {
|
||||
String templateWithVars = templateMarkup;
|
||||
templateWithVars = strReplace(templateWithVars,type+"NN",Integer.toString(i));
|
||||
templateWithVars = strReplace(templateWithVars,"\\$taName",taName.toString());
|
||||
templateWithVars = strReplace(templateWithVars,"\\$\\$",row.getValue());
|
||||
templateWithVars = strReplace(templateWithVars, type + "NN", Integer.toString(i));
|
||||
templateWithVars = strReplace(templateWithVars, "\\$taName", taName.toString());
|
||||
templateWithVars = strReplace(templateWithVars, "\\$\\$", row.getValue());
|
||||
out.print(templateWithVars);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,10 +301,8 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
|
|||
protected void sortEnts2EntsForDisplay(){
|
||||
if( getObjectPropertyList() == null ) return;
|
||||
|
||||
Iterator it = getObjectPropertyList().iterator();
|
||||
while(it.hasNext()){
|
||||
ObjectProperty prop = (ObjectProperty)it.next();
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
|
||||
for (ObjectProperty prop : getObjectPropertyList()) {
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop, prop.getObjectPropertyStatements());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,9 +144,7 @@ public class EntityEditController extends BaseEditController {
|
|||
try {
|
||||
List<Option> externalIdOptionList = new LinkedList<Option>();
|
||||
if (ent.getExternalIds() != null) {
|
||||
Iterator<DataPropertyStatement> externalIdIt = ent.getExternalIds().iterator();
|
||||
while (externalIdIt.hasNext()) {
|
||||
DataPropertyStatement eid = externalIdIt.next();
|
||||
for (DataPropertyStatement eid : ent.getExternalIds()) {
|
||||
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()));
|
||||
}
|
||||
|
@ -169,11 +167,9 @@ public class EntityEditController extends BaseEditController {
|
|||
try {
|
||||
List epiOptionList = new LinkedList();
|
||||
Collection<PropertyInstance> epiColl = piDao.getExistingProperties(ent.getURI(),null);
|
||||
Iterator<PropertyInstance> epiIt = epiColl.iterator();
|
||||
while (epiIt.hasNext()) {
|
||||
PropertyInstance pi = epiIt.next();
|
||||
for (PropertyInstance pi : epiColl) {
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -211,25 +211,21 @@ public class EntityRetryController extends BaseEditController {
|
|||
Collections.sort(allApplicableDataprops);
|
||||
|
||||
if (allApplicableDataprops != null) {
|
||||
Iterator<DataProperty> datapropsIt = allApplicableDataprops.iterator();
|
||||
|
||||
while (datapropsIt.hasNext()){
|
||||
DataProperty d = datapropsIt.next();
|
||||
for (DataProperty d : allApplicableDataprops) {
|
||||
if (!dpMap.containsKey(d.getURI())) {
|
||||
dpMap.put(d.getURI(),d);
|
||||
dpMap.put(d.getURI(), d);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (individualForEditing.getDataPropertyList() != null) {
|
||||
Iterator<DataProperty> existingDps = individualForEditing.getDataPropertyList().iterator();
|
||||
while (existingDps.hasNext()) {
|
||||
DataProperty existingDp = existingDps.next();
|
||||
// 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.
|
||||
if ( !existingDp.getPublicName().equals("label") ) {
|
||||
dpMap.put(existingDp.getURI(),existingDp);
|
||||
}
|
||||
for (DataProperty existingDp : individualForEditing.getDataPropertyList()) {
|
||||
// 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.
|
||||
if (!existingDp.getPublicName().equals("label")) {
|
||||
dpMap.put(existingDp.getURI(), existingDp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,9 +245,7 @@ public class EntityRetryController extends BaseEditController {
|
|||
rowTemplate.setParameterMap(parameterMap);
|
||||
dynamo.setRowTemplate(rowTemplate);
|
||||
try {
|
||||
Iterator<DataPropertyStatement> existingValues = dp.getDataPropertyStatements().iterator();
|
||||
while (existingValues.hasNext()) {
|
||||
DataPropertyStatement existingValue = existingValues.next();
|
||||
for (DataPropertyStatement existingValue : dp.getDataPropertyStatements()) {
|
||||
DynamicFieldRow row = new DynamicFieldRow();
|
||||
//TODO: UGH
|
||||
//row.setId(existingValue.getId());
|
||||
|
|
|
@ -122,9 +122,7 @@ public class ObjectPropertyStatementRetryController extends BaseEditController {
|
|||
indList.addAll(possIndSet);
|
||||
sortForPickList(indList, vreq);
|
||||
List objectEntOptionList = new LinkedList();
|
||||
Iterator<Individual> indIt = indList.iterator();
|
||||
while (indIt.hasNext()) {
|
||||
Individual objInd = indIt.next();
|
||||
for (Individual objInd : indList) {
|
||||
Option objIndOpt = new Option(objInd.getURI(), objInd.getName());
|
||||
if (objectForEditing.getObjectEntURI() != null && objectForEditing.getObjectEntURI().equals(objInd.getURI())) {
|
||||
objIndOpt.setSelected(true);
|
||||
|
|
|
@ -203,9 +203,7 @@ public class VclassEditController extends BaseEditController {
|
|||
|
||||
private List<VClass> getVClassesForURIList(List<String> vclassURIs, VClassDao vcDao) {
|
||||
List<VClass> vclasses = new ArrayList<VClass>();
|
||||
Iterator<String> urIt = vclassURIs.iterator();
|
||||
while (urIt.hasNext()) {
|
||||
String vclassURI = urIt.next();
|
||||
for (String vclassURI : vclassURIs) {
|
||||
VClass vclass = vcDao.getVClassByURI(vclassURI);
|
||||
if (vclass != null) {
|
||||
vclasses.add(vclass);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class IndividualsListingController extends BaseEditController {
|
|||
String vclassURI = request.getParameter("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);
|
||||
|
||||
ArrayList results = new ArrayList();
|
||||
|
@ -64,16 +64,13 @@ public class IndividualsListingController extends BaseEditController {
|
|||
results.add("class");
|
||||
|
||||
if (inds != null && inds.size()>0) {
|
||||
Iterator indsIt = inds.iterator();
|
||||
while (indsIt.hasNext()) {
|
||||
Individual ind = (Individual) indsIt.next();
|
||||
|
||||
for (Individual ind : inds) {
|
||||
results.add("XX");
|
||||
|
||||
if (ind.getName() != null) {
|
||||
try {
|
||||
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>");
|
||||
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>");
|
||||
} catch (Exception e) {
|
||||
results.add(ind.getName());
|
||||
}
|
||||
|
@ -84,8 +81,8 @@ public class IndividualsListingController extends BaseEditController {
|
|||
|
||||
if (vc != null) {
|
||||
try {
|
||||
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>");
|
||||
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>");
|
||||
} catch (Exception e) {
|
||||
results.add(vc.getName());
|
||||
}
|
||||
|
|
|
@ -146,42 +146,41 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
|
|||
if (props.size()==0) {
|
||||
json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }");
|
||||
} else {
|
||||
Iterator<ObjectProperty> propsIt = props.iterator();
|
||||
while (propsIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
for (ObjectProperty prop1 : props) {
|
||||
if (counter > 0) {
|
||||
json.append(", ");
|
||||
}
|
||||
ObjectProperty prop = propsIt.next();
|
||||
|
||||
ObjectProperty prop = prop1;
|
||||
|
||||
String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);
|
||||
|
||||
try {
|
||||
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./propertyEdit?uri=" + URLEncoder.encode(prop.getURI()) + "'>"
|
||||
+ propNameStr + "</a>")).append(", ");
|
||||
} catch (Exception e) {
|
||||
json.append("{ \"name\": \"").append(propNameStr).append("\", ");
|
||||
}
|
||||
|
||||
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.append("\"domainVClass\": ").append(JacksonUtils.quote(domainStr)).append(", ");
|
||||
|
||||
String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut);
|
||||
json.append("\"rangeVClass\": ").append(JacksonUtils.quote(rangeStr)).append(", ");
|
||||
|
||||
if (prop.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
||||
json.append("\"group\": ").append(JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())).append(" } } ");
|
||||
} else {
|
||||
json.append("\"group\": \"unspecified\" } }");
|
||||
}
|
||||
counter += 1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
json.append("{ \"name\": \"").append(propNameStr).append("\", ");
|
||||
}
|
||||
|
||||
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.append("\"domainVClass\": ").append(JacksonUtils.quote(domainStr)).append(", ");
|
||||
|
||||
String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut);
|
||||
json.append("\"rangeVClass\": ").append(JacksonUtils.quote(rangeStr)).append(", ");
|
||||
|
||||
if (prop.getGroupURI() != null) {
|
||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
||||
json.append("\"group\": ").append(JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())).append(" } } ");
|
||||
} else {
|
||||
json.append("\"group\": \"unspecified\" } }");
|
||||
}
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
body.put("jsonTree", json.toString());
|
||||
}
|
||||
|
|
|
@ -83,53 +83,52 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
|
|||
|
||||
if (classes != null) {
|
||||
sortForPickList(classes, vreq);
|
||||
Iterator<VClass> classesIt = classes.iterator();
|
||||
while (classesIt.hasNext()) {
|
||||
if ( counter > 0 ) {
|
||||
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.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./vclassEdit?uri=" + URLEncoder.encode(cls.getURI(), "UTF-8") + "'>" + cls.getPickListName() + "</a>")).append(", ");
|
||||
} catch (Exception e) {
|
||||
json.append("{ \"name\": ").append(JacksonUtils.quote(cls.getPickListName())).append(", ");
|
||||
}
|
||||
else
|
||||
json.append("{ \"name\": \"\"");
|
||||
String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef();
|
||||
|
||||
json.append("\"data\": { \"shortDef\": ").append(JacksonUtils.quote(shortDef)).append(", ");
|
||||
for (VClass aClass : classes) {
|
||||
if (counter > 0) {
|
||||
json.append(", ");
|
||||
}
|
||||
VClass cls = aClass;
|
||||
if ((ontologyURI == null) || ((ontologyURI != null) && (cls.getNamespace() != null) && (ontologyURI.equals(cls.getNamespace())))) {
|
||||
if (cls.getName() != null)
|
||||
try {
|
||||
json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./vclassEdit?uri=" + URLEncoder.encode(cls.getURI(), "UTF-8") + "'>" + cls.getPickListName() + "</a>")).append(", ");
|
||||
} catch (Exception e) {
|
||||
json.append("{ \"name\": ").append(JacksonUtils.quote(cls.getPickListName())).append(", ");
|
||||
}
|
||||
else
|
||||
json.append("{ \"name\": \"\"");
|
||||
String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef();
|
||||
|
||||
// get group name
|
||||
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
|
||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
||||
String groupURI = cls.getGroupURI();
|
||||
String groupName = "";
|
||||
VClassGroup classGroup = null;
|
||||
if(groupURI != null) {
|
||||
classGroup = groupDao.getGroupByURI(groupURI);
|
||||
if (classGroup!=null) {
|
||||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
|
||||
json.append("\"classGroup\": ").append(JacksonUtils.quote(groupName)).append(", ");
|
||||
json.append("\"data\": { \"shortDef\": ").append(JacksonUtils.quote(shortDef)).append(", ");
|
||||
|
||||
// get ontology name
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = cls.getNamespace();
|
||||
Ontology ont = ontDao.getOntologyByURI(ontName);
|
||||
if (ont != null && ont.getName() != null) {
|
||||
ontName = ont.getName();
|
||||
}
|
||||
json.append("\"ontology\": ").append(JacksonUtils.quote(ontName)).append("} }");
|
||||
|
||||
counter++;
|
||||
// get group name
|
||||
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
|
||||
VClassGroupDao groupDao = wadf.getVClassGroupDao();
|
||||
String groupURI = cls.getGroupURI();
|
||||
String groupName = "";
|
||||
VClassGroup classGroup = null;
|
||||
if (groupURI != null) {
|
||||
classGroup = groupDao.getGroupByURI(groupURI);
|
||||
if (classGroup != null) {
|
||||
groupName = classGroup.getPublicName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
json.append("\"classGroup\": ").append(JacksonUtils.quote(groupName)).append(", ");
|
||||
|
||||
// get ontology name
|
||||
OntologyDao ontDao = wadf.getOntologyDao();
|
||||
String ontName = cls.getNamespace();
|
||||
Ontology ont = ontDao.getOntologyByURI(ontName);
|
||||
if (ont != null && ont.getName() != null) {
|
||||
ontName = ont.getName();
|
||||
}
|
||||
json.append("\"ontology\": ").append(JacksonUtils.quote(ontName)).append("} }");
|
||||
|
||||
counter++;
|
||||
|
||||
}
|
||||
}
|
||||
body.put("jsonTree", json.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -134,15 +134,14 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
|
|||
List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List<VClass> childClasses = new ArrayList<VClass>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = childURIstrIt.next();
|
||||
for (String URIstr : childURIstrs) {
|
||||
try {
|
||||
VClass child = vcDao.getVClassByURI(URIstr);
|
||||
if (!child.getURI().equals(OWL.Nothing.getURI())) {
|
||||
childClasses.add(child);
|
||||
childClasses.add(child);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
sortForPickList(childClasses, vreq);
|
||||
Iterator<VClass> childClassIt = childClasses.iterator();
|
||||
|
|
|
@ -147,9 +147,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
|
|||
List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
|
||||
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
|
||||
List<DataProperty> childProps = new ArrayList<DataProperty>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = childURIstrIt.next();
|
||||
for (String URIstr : childURIstrs) {
|
||||
DataProperty child = dpDao.getDataPropertyByURI(URIstr);
|
||||
childProps.add(child);
|
||||
}
|
||||
|
|
|
@ -151,9 +151,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
|
|||
List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
|
||||
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
|
||||
List<ObjectProperty> childProps = new ArrayList<ObjectProperty>();
|
||||
Iterator<String> childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = childURIstrIt.next();
|
||||
for (String URIstr : childURIstrs) {
|
||||
ObjectProperty child = opDao.getObjectPropertyByURI(URIstr);
|
||||
childProps.add(child);
|
||||
}
|
||||
|
|
|
@ -202,18 +202,16 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
|
|||
HashMap<VClass, List<DataProperty>> classPropertiesMap = new HashMap<VClass, List<DataProperty>>();
|
||||
List<DataProperty> props = new ArrayList<DataProperty>();
|
||||
VClass topVc = vcDao.getVClassByURI(uri);
|
||||
Collection <DataProperty> dataProps = dao.getDataPropertiesForVClass(uri);
|
||||
Iterator<DataProperty> dataPropIt = dataProps.iterator();
|
||||
while (dataPropIt.hasNext()) {
|
||||
DataProperty dp = dataPropIt.next();
|
||||
if (!(propURIs.contains(dp.getURI()))) {
|
||||
propURIs.add(dp.getURI());
|
||||
DataProperty prop = dao.getDataPropertyByURI(dp.getURI());
|
||||
if (prop != null) {
|
||||
props.add(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collection <DataProperty> dataProps = dao.getDataPropertiesForVClass(uri);
|
||||
for (DataProperty dp : dataProps) {
|
||||
if (!(propURIs.contains(dp.getURI()))) {
|
||||
propURIs.add(dp.getURI());
|
||||
DataProperty prop = dao.getDataPropertyByURI(dp.getURI());
|
||||
if (prop != null) {
|
||||
props.add(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (props.size() > 0) {
|
||||
|
@ -256,22 +254,21 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
|
|||
List childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
||||
List childClasses = new ArrayList();
|
||||
Iterator childURIstrIt = childURIstrs.iterator();
|
||||
while (childURIstrIt.hasNext()) {
|
||||
String URIstr = (String) childURIstrIt.next();
|
||||
try {
|
||||
VClass child = (VClass) vcDao.getVClassByURI(URIstr);
|
||||
if (!child.getURI().equals(OWL.Nothing.getURI())) {
|
||||
childClasses.add(child);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
for (Object childURIstr : childURIstrs) {
|
||||
String URIstr = (String) childURIstr;
|
||||
try {
|
||||
VClass child = (VClass) vcDao.getVClassByURI(URIstr);
|
||||
if (!child.getURI().equals(OWL.Nothing.getURI())) {
|
||||
childClasses.add(child);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
Collections.sort(childClasses);
|
||||
Iterator childClassIt = childClasses.iterator();
|
||||
while (childClassIt.hasNext()) {
|
||||
VClass child = (VClass) childClassIt.next();
|
||||
addChildren(vcDao, wadf, child, list, position + childShift, ontologyUri);
|
||||
}
|
||||
for (Object childClass : childClasses) {
|
||||
VClass child = (VClass) childClass;
|
||||
addChildren(vcDao, wadf, child, list, position + childShift, ontologyUri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -403,9 +403,7 @@ public class JSONReconcileServlet extends VitroHttpServlet {
|
|||
query.addFields(VitroSearchTermNames.NAME_RAW, VitroSearchTermNames.URI, "*", "score"); // fields to retrieve
|
||||
|
||||
// if propertiesList has elements, add extra queries to query
|
||||
Iterator<String[]> it = propertiesList.iterator();
|
||||
while (it.hasNext()) {
|
||||
String[] pvPair = it.next();
|
||||
for (String[] pvPair : propertiesList) {
|
||||
query.addFilterQueries(tokenizeNameQuery(pvPair[1]), VitroSearchTermNames.RDFTYPE + ":\"" + pvPair[0] + "\"");
|
||||
}
|
||||
|
||||
|
|
|
@ -500,9 +500,7 @@ public class JenaIngestController extends BaseEditController {
|
|||
List<Ontology> ontologiesObj = daoObj.getAllOntologies();
|
||||
List<String> prefixList = new ArrayList<>();
|
||||
if(ontologiesObj !=null && ontologiesObj.size()>0){
|
||||
Iterator<Ontology> ontItr = ontologiesObj.iterator();
|
||||
while(ontItr.hasNext()){
|
||||
Ontology ont = ontItr.next();
|
||||
for (Ontology ont : ontologiesObj) {
|
||||
prefixList.add(ont.getPrefix() == null ? "(not yet specified)" : ont.getPrefix());
|
||||
prefixList.add(ont.getURI() == null ? "" : ont.getURI());
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
Iterator groupIt = groups.iterator();
|
||||
while (groupIt.hasNext()) {
|
||||
VClassGroup g = (VClassGroup) groupIt.next();
|
||||
for (VClassGroup g : groups) {
|
||||
this.addVClassesToGroup(g);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -633,13 +633,11 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
isRoot = true;
|
||||
} else {
|
||||
isRoot = true;
|
||||
Iterator<Property> pit = parentList.iterator();
|
||||
while (pit.hasNext()) {
|
||||
Property pt = pit.next();
|
||||
if ( (!pt.equals(op)) && (!(ontModel.contains(op,OWL.equivalentProperty,pt)) || (ontModel.contains(pt,OWL.equivalentProperty,op))) ) {
|
||||
isRoot = false;
|
||||
}
|
||||
}
|
||||
for (Property pt : parentList) {
|
||||
if ((!pt.equals(op)) && (!(ontModel.contains(op, OWL.equivalentProperty, pt)) || (ontModel.contains(pt, OWL.equivalentProperty, op)))) {
|
||||
isRoot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isRoot = true;
|
||||
|
|
|
@ -66,11 +66,9 @@ public class DependentResourceDeleteJena {
|
|||
ListIterator <Statement>removed = removedStmts.listIterator();
|
||||
while( removed.hasNext()){
|
||||
Statement removedStmt = removed.next();
|
||||
ListIterator <Statement>changed = changedStmts.listIterator();
|
||||
while( changed.hasNext()){
|
||||
Statement changedStmt = changed.next();
|
||||
if( removedStmt.equals(changedStmt) ){
|
||||
removed.remove();
|
||||
for (Statement changedStmt : changedStmts) {
|
||||
if (removedStmt.equals(changedStmt)) {
|
||||
removed.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,17 +69,15 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
|
|||
HashSet<String> nonExternalIdPropURISet = new HashSet<String>();
|
||||
if (ind != null) {
|
||||
Collection<DataPropertyStatement> dpsColl = getWebappDaoFactory().getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(ind, dataPropertyURI);
|
||||
Iterator<DataPropertyStatement> dpsIt = dpsColl.iterator();
|
||||
while (dpsIt.hasNext()) {
|
||||
DataPropertyStatement dps = dpsIt.next();
|
||||
for (DataPropertyStatement dps : dpsColl) {
|
||||
if (externalIdPropURISet.contains(dps.getDatapropURI())) {
|
||||
externalIdStatements.add(dps);
|
||||
} else if (!nonExternalIdPropURISet.contains(dps.getDatapropURI())) {
|
||||
OntModel tboxOntModel = getOntModelSelector().getTBoxModel();
|
||||
OntModel tboxOntModel = getOntModelSelector().getTBoxModel();
|
||||
tboxOntModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
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());
|
||||
externalIdStatements.add(dps);
|
||||
} else {
|
||||
|
|
|
@ -311,12 +311,9 @@ public class IndividualDaoSDB extends IndividualDaoJena {
|
|||
private void fillIndividualsForObjectPropertyStatements(Individual entity){
|
||||
getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
Iterator e2eIt = entity.getObjectPropertyStatements().iterator();
|
||||
while (e2eIt.hasNext()) {
|
||||
ObjectPropertyStatement e2e =
|
||||
(ObjectPropertyStatement) e2eIt.next();
|
||||
for (ObjectPropertyStatement e2e : entity.getObjectPropertyStatements()) {
|
||||
e2e.setSubject(makeIndividual(e2e.getSubjectURI()));
|
||||
e2e.setObject(makeIndividual(e2e.getObjectURI()));
|
||||
e2e.setObject(makeIndividual(e2e.getObjectURI()));
|
||||
}
|
||||
} finally {
|
||||
getOntModel().leaveCriticalSection();
|
||||
|
|
|
@ -517,15 +517,13 @@ public class IndividualJena extends IndividualImpl implements Individual {
|
|||
protected void sortEnts2EntsForDisplay(){
|
||||
if( getObjectPropertyList() == null ) return;
|
||||
|
||||
Iterator it = getObjectPropertyList().iterator();
|
||||
while(it.hasNext()){
|
||||
ObjectProperty prop = (ObjectProperty)it.next();
|
||||
/* if (prop.getObjectIndividualSortPropertyURI()==null) {
|
||||
for (ObjectProperty prop : getObjectPropertyList()) {
|
||||
/* if (prop.getObjectIndividualSortPropertyURI()==null) {
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
|
||||
} else {*/
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop, prop.getObjectPropertyStatements());
|
||||
/* }*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Collator collator = Collator.getInstance();
|
||||
|
|
|
@ -953,15 +953,13 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
protected void sortEnts2EntsForDisplay(){
|
||||
if( getObjectPropertyList() == null ) return;
|
||||
|
||||
Iterator it = getObjectPropertyList().iterator();
|
||||
while(it.hasNext()){
|
||||
ObjectProperty prop = (ObjectProperty)it.next();
|
||||
/* if (prop.getObjectIndividualSortPropertyURI()==null) {
|
||||
for (ObjectProperty prop : getObjectPropertyList()) {
|
||||
/* if (prop.getObjectIndividualSortPropertyURI()==null) {
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
|
||||
} else {*/
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop,prop.getObjectPropertyStatements());
|
||||
prop.sortObjectPropertyStatementsForDisplay(prop, prop.getObjectPropertyStatements());
|
||||
/* }*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Collator collator = Collator.getInstance();
|
||||
|
|
|
@ -771,20 +771,18 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
|||
}
|
||||
|
||||
private Literal getLabel(String lang, List<RDFNode>labelList) {
|
||||
Iterator<RDFNode> labelIt = labelList.iterator();
|
||||
while (labelIt.hasNext()) {
|
||||
RDFNode label = labelIt.next();
|
||||
if (label.isLiteral()) {
|
||||
Literal labelLit = ((Literal)label);
|
||||
String labelLanguage = labelLit.getLanguage();
|
||||
if ( (labelLanguage == null) && (lang == null || lang.isEmpty()) ) {
|
||||
return labelLit;
|
||||
}
|
||||
if ( (lang != null) && (lang.equals(labelLanguage)) ) {
|
||||
return labelLit;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (RDFNode label : labelList) {
|
||||
if (label.isLiteral()) {
|
||||
Literal labelLit = ((Literal) label);
|
||||
String labelLanguage = labelLit.getLanguage();
|
||||
if ((labelLanguage == null) && (lang == null || lang.isEmpty())) {
|
||||
return labelLit;
|
||||
}
|
||||
if ((lang != null) && (lang.equals(labelLanguage))) {
|
||||
return labelLit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1019,22 +1017,20 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
|||
}
|
||||
// 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.
|
||||
Iterator<Resource> possibleValueIt = possibleValueSet.iterator();
|
||||
while (possibleValueIt.hasNext()) {
|
||||
Resource possibleRes = possibleValueIt.next();
|
||||
StmtIterator pStmtIt = getOntModel().listStatements((Resource)null, prop, possibleRes);
|
||||
boolean hasAlternatePath = false;
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement stmt = stmtIt.nextStatement();
|
||||
if (possibleValueSet.contains(stmt.getSubject())) {
|
||||
hasAlternatePath = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAlternatePath) {
|
||||
directValueList.add(possibleRes);
|
||||
}
|
||||
}
|
||||
for (Resource possibleRes : possibleValueSet) {
|
||||
StmtIterator pStmtIt = getOntModel().listStatements((Resource) null, prop, possibleRes);
|
||||
boolean hasAlternatePath = false;
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement stmt = stmtIt.nextStatement();
|
||||
if (possibleValueSet.contains(stmt.getSubject())) {
|
||||
hasAlternatePath = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAlternatePath) {
|
||||
directValueList.add(possibleRes);
|
||||
}
|
||||
}
|
||||
return directValueList;
|
||||
}
|
||||
|
||||
|
@ -1048,22 +1044,20 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
|||
possibleSubjectSet.add(stmt.getSubject());
|
||||
|
||||
}
|
||||
Iterator<Resource> possibleSubjectIt = possibleSubjectSet.iterator();
|
||||
while (possibleSubjectIt.hasNext()) {
|
||||
Resource possibleRes = possibleSubjectIt.next();
|
||||
StmtIterator pStmtIt = getOntModel().listStatements(possibleRes, prop, (RDFNode)null);
|
||||
boolean hasAlternatePath = false;
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement stmt = stmtIt.nextStatement();
|
||||
if (stmt.getObject().isResource() && possibleSubjectSet.contains(stmt.getObject())) {
|
||||
hasAlternatePath = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAlternatePath) {
|
||||
directSubjectList.add(possibleRes);
|
||||
}
|
||||
}
|
||||
for (Resource possibleRes : possibleSubjectSet) {
|
||||
StmtIterator pStmtIt = getOntModel().listStatements(possibleRes, prop, (RDFNode) null);
|
||||
boolean hasAlternatePath = false;
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement stmt = stmtIt.nextStatement();
|
||||
if (stmt.getObject().isResource() && possibleSubjectSet.contains(stmt.getObject())) {
|
||||
hasAlternatePath = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAlternatePath) {
|
||||
directSubjectList.add(possibleRes);
|
||||
}
|
||||
}
|
||||
return directSubjectList;
|
||||
}
|
||||
|
||||
|
|
|
@ -497,9 +497,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
|
||||
List<ObjectProperty> props = new ArrayList<ObjectProperty>();
|
||||
Iterator<String> keyIt = hash.keySet().iterator();
|
||||
while (keyIt.hasNext()) {
|
||||
Object key = keyIt.next();
|
||||
for (String key : hash.keySet()) {
|
||||
props.add(hash.get(key));
|
||||
}
|
||||
return props;
|
||||
|
|
|
@ -162,15 +162,13 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
}
|
||||
|
||||
private void getAllSubPropertyURIs(String propertyURI, HashSet<String> subtree){
|
||||
List<String> directSubproperties = getSubPropertyURIs(propertyURI);
|
||||
Iterator<String> it=directSubproperties.iterator();
|
||||
while(it.hasNext()){
|
||||
String uri = it.next();
|
||||
if (!subtree.contains(uri)) {
|
||||
subtree.add(uri);
|
||||
getAllSubPropertyURIs(uri,subtree);
|
||||
}
|
||||
}
|
||||
List<String> directSubproperties = getSubPropertyURIs(propertyURI);
|
||||
for (String uri : directSubproperties) {
|
||||
if (!subtree.contains(uri)) {
|
||||
subtree.add(uri);
|
||||
getAllSubPropertyURIs(uri, subtree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -205,15 +203,13 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
}
|
||||
|
||||
private void getAllSuperPropertyURIs(String propertyURI, HashSet<String> subtree){
|
||||
List<String> directSuperproperties = getSuperPropertyURIs(propertyURI,true);
|
||||
Iterator<String> it=directSuperproperties.iterator();
|
||||
while(it.hasNext()){
|
||||
String uri = it.next();
|
||||
if (!subtree.contains(uri)) {
|
||||
subtree.add(uri);
|
||||
getAllSuperPropertyURIs(uri,subtree);
|
||||
}
|
||||
}
|
||||
List<String> directSuperproperties = getSuperPropertyURIs(propertyURI,true);
|
||||
for (String uri : directSuperproperties) {
|
||||
if (!subtree.contains(uri)) {
|
||||
subtree.add(uri);
|
||||
getAllSuperPropertyURIs(uri, subtree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -420,18 +416,14 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
|
||||
List<OntClass> classList = ontClass.listEquivalentClasses().toList();
|
||||
classList.addAll(ontClass.listSubClasses().toList());
|
||||
|
||||
Iterator<OntClass> it = classList.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
OntClass oc = it.next();
|
||||
|
||||
if (!oc.isAnon()) {
|
||||
classSet.add(oc.getURI());
|
||||
} else {
|
||||
classSet.addAll(getRestrictedClasses(oc));
|
||||
}
|
||||
}
|
||||
|
||||
for (OntClass oc : classList) {
|
||||
if (!oc.isAnon()) {
|
||||
classSet.add(oc.getURI());
|
||||
} else {
|
||||
classSet.addAll(getRestrictedClasses(oc));
|
||||
}
|
||||
}
|
||||
|
||||
return classSet;
|
||||
}
|
||||
|
|
|
@ -148,13 +148,9 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
|
|||
List existingPropertyInstances = new ArrayList();
|
||||
if (ent.getObjectPropertyList()==null)
|
||||
return existingPropertyInstances;
|
||||
Iterator objPropertyIter = ent.getObjectPropertyList().iterator();
|
||||
while (objPropertyIter.hasNext()) {
|
||||
edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty op = (edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty) objPropertyIter.next();
|
||||
Iterator objPropertyStmtIter = op.getObjectPropertyStatements().iterator();
|
||||
while (objPropertyStmtIter.hasNext()) {
|
||||
ObjectPropertyStatement objPropertyStmt = (ObjectPropertyStatement) objPropertyStmtIter.next();
|
||||
if (propertyURI==null || objPropertyStmt.getPropertyURI().equals(propertyURI)) {
|
||||
for (edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty op : ent.getObjectPropertyList()) {
|
||||
for (ObjectPropertyStatement objPropertyStmt : op.getObjectPropertyStatements()) {
|
||||
if (propertyURI == null || objPropertyStmt.getPropertyURI().equals(propertyURI)) {
|
||||
PropertyInstance pi = new PropertyInstance();
|
||||
pi.setSubjectSide(true);
|
||||
pi.setSubjectEntURI(ent.getURI());
|
||||
|
@ -166,7 +162,7 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
|
|||
pi.setObjectEntURI(objPropertyStmt.getObjectURI());
|
||||
pi.setPropertyURI(objPropertyStmt.getPropertyURI());
|
||||
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 {
|
||||
pi.setDomainPublic(objPropertyStmt.getPropertyURI());
|
||||
}
|
||||
|
|
|
@ -410,13 +410,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
}
|
||||
|
||||
public void getAllSubClassURIs(String classURI, HashSet<String> subtree){
|
||||
List<String> directSubclasses = getSubClassURIs(classURI);
|
||||
Iterator<String> it=directSubclasses.iterator();
|
||||
while(it.hasNext()){
|
||||
String uri = it.next();
|
||||
List<String> directSubclasses = getSubClassURIs(classURI);
|
||||
for (String uri : directSubclasses) {
|
||||
if (!subtree.contains(uri)) {
|
||||
subtree.add(uri);
|
||||
getAllSubClassURIs(uri,subtree);
|
||||
getAllSubClassURIs(uri, subtree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,13 +447,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
}
|
||||
|
||||
public void getAllSuperClassURIs(String classURI, HashSet<String> subtree){
|
||||
List<String> directSuperclasses = getSuperClassURIs(classURI, true);
|
||||
Iterator<String> it=directSuperclasses.iterator();
|
||||
while(it.hasNext()){
|
||||
String uri = it.next();
|
||||
List<String> directSuperclasses = getSuperClassURIs(classURI, true);
|
||||
for (String uri : directSuperclasses) {
|
||||
if (!subtree.contains(uri)) {
|
||||
subtree.add(uri);
|
||||
getAllSuperClassURIs(uri,subtree);
|
||||
getAllSuperClassURIs(uri, subtree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -787,13 +783,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
// if this model infers types based on the taxonomy, adding the subclasses will only
|
||||
// waste time for no benefit
|
||||
if (!isUnderlyingStoreReasoned()) {
|
||||
Iterator classURIs = getAllSubClassURIs(getClassURIStr(superclass)).iterator();
|
||||
while (classURIs.hasNext()) {
|
||||
String classURI = (String) classURIs.next();
|
||||
VClass vClass = getVClassByURI(classURI);
|
||||
if (vClass != null)
|
||||
vClasses.add(vClass);
|
||||
}
|
||||
for (String classURI : getAllSubClassURIs(getClassURIStr(superclass))) {
|
||||
VClass vClass = getVClassByURI(classURI);
|
||||
if (vClass != null)
|
||||
vClasses.add(vClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -919,12 +913,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
if (groups != null) {
|
||||
Iterator groupIt = groups.iterator();
|
||||
while (groupIt.hasNext()) {
|
||||
VClassGroup g = (VClassGroup) groupIt.next();
|
||||
for (VClassGroup g : groups) {
|
||||
addVClassesToGroup(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
getOntModel().leaveCriticalSection();
|
||||
}
|
||||
|
|
|
@ -87,9 +87,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
|||
groupIt.close();
|
||||
}
|
||||
Collections.sort(groups);
|
||||
Iterator<VClassGroup> groupsIt = groups.iterator();
|
||||
while (groupsIt.hasNext()) {
|
||||
VClassGroup group = groupsIt.next();
|
||||
for (VClassGroup group : groups) {
|
||||
map.put(group.getPublicName(), group);
|
||||
}
|
||||
return map;
|
||||
|
|
|
@ -39,12 +39,10 @@ public class IndividualDataPropertyStatementProcessor implements ChangeListener
|
|||
|
||||
private void processDataprops (EditProcessObject epo) {
|
||||
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");
|
||||
Iterator dpmIt = dpm.keySet().iterator();
|
||||
while (dpmIt.hasNext()) {
|
||||
String key = (String) dpmIt.next();
|
||||
String[] data = (String[])dpm.get(key);
|
||||
for (String key : dpm.keySet()) {
|
||||
String[] data = (String[]) dpm.get(key);
|
||||
for (String aData : data) {
|
||||
String[] keyArg = key.split("_");
|
||||
String rowId = keyArg[2];
|
||||
|
@ -105,13 +103,11 @@ public class IndividualDataPropertyStatementProcessor implements ChangeListener
|
|||
}
|
||||
|
||||
// might want to roll this into the other thing
|
||||
private HashMap datapropParameterMap(Map requestParameterMap) {
|
||||
HashMap dpm = new HashMap();
|
||||
Iterator paramIt = requestParameterMap.keySet().iterator();
|
||||
while (paramIt.hasNext()) {
|
||||
String key = (String) paramIt.next();
|
||||
private Map<String, String[]> datapropParameterMap(Map<String, String[]> requestParameterMap) {
|
||||
Map<String, String[]> dpm = new HashMap<String, String[]>();
|
||||
for (String key : requestParameterMap.keySet()) {
|
||||
if (key.startsWith("_DataPropertyStatement")) {
|
||||
dpm.put(key,requestParameterMap.get(key));
|
||||
dpm.put(key, requestParameterMap.get(key));
|
||||
}
|
||||
}
|
||||
return dpm;
|
||||
|
|
|
@ -463,16 +463,14 @@ public class ProcessRdfForm {
|
|||
Map<String, List<String>> newUris = new HashMap<String, List<String>>();
|
||||
//Check if any values from the submission have the "force new uri" value
|
||||
//TODO: Check how to handle multiple new resource values
|
||||
Iterator<String> keyIterator = urisFromForm.keySet().iterator();
|
||||
while(keyIterator.hasNext()) {
|
||||
String key = keyIterator.next();
|
||||
if(urisFromForm.get(key).contains(EditConfigurationConstants.NEW_URI_SENTINEL)) {
|
||||
String newUri = urisForNewResources.get(key);
|
||||
List<String> newUrisForKey = new ArrayList<String>();
|
||||
newUrisForKey.add(newUri);
|
||||
newUris.put(key, newUrisForKey);
|
||||
}
|
||||
}
|
||||
for (String key : urisFromForm.keySet()) {
|
||||
if (urisFromForm.get(key).contains(EditConfigurationConstants.NEW_URI_SENTINEL)) {
|
||||
String newUri = urisForNewResources.get(key);
|
||||
List<String> newUrisForKey = new ArrayList<String>();
|
||||
newUrisForKey.add(newUri);
|
||||
newUris.put(key, newUrisForKey);
|
||||
}
|
||||
}
|
||||
if(newUris.size() > 0) {
|
||||
substituteInMultiURIs(newUris, requiredAsserts, optionalAsserts, uRLToReturnTo);
|
||||
}
|
||||
|
|
|
@ -90,29 +90,25 @@ public class ABoxUpdater {
|
|||
* knowledge base.
|
||||
*/
|
||||
public void processClassChanges(List<AtomicOntologyChange> changes) throws IOException {
|
||||
|
||||
Iterator<AtomicOntologyChange> iter = changes.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
AtomicOntologyChange change = iter.next();
|
||||
|
||||
switch (change.getAtomicChangeType()){
|
||||
case ADD:
|
||||
addClass(change);
|
||||
break;
|
||||
case DELETE:
|
||||
if ("Delete".equals(change.getNotes())) {
|
||||
deleteIndividualsOfType(change);
|
||||
} else {
|
||||
renameClassToParent(change);
|
||||
}
|
||||
break;
|
||||
case RENAME:
|
||||
renameClass(change);
|
||||
break;
|
||||
default:
|
||||
logger.logError("unexpected change type indicator: " + change.getAtomicChangeType());
|
||||
}
|
||||
for (AtomicOntologyChange change : changes) {
|
||||
switch (change.getAtomicChangeType()) {
|
||||
case ADD:
|
||||
addClass(change);
|
||||
break;
|
||||
case DELETE:
|
||||
if ("Delete".equals(change.getNotes())) {
|
||||
deleteIndividualsOfType(change);
|
||||
} else {
|
||||
renameClassToParent(change);
|
||||
}
|
||||
break;
|
||||
case RENAME:
|
||||
renameClass(change);
|
||||
break;
|
||||
default:
|
||||
logger.logError("unexpected change type indicator: " + change.getAtomicChangeType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,35 +231,31 @@ public class ABoxUpdater {
|
|||
if (namedClassList.isEmpty()) {
|
||||
namedClassList.add(OWL_THING);
|
||||
}
|
||||
|
||||
Iterator<OntClass> classIter = namedClassList.iterator();
|
||||
|
||||
while (classIter.hasNext()) {
|
||||
OntClass parentOfAddedClass = classIter.next();
|
||||
|
||||
for (OntClass parentOfAddedClass : namedClassList) {
|
||||
if (!parentOfAddedClass.equals(OWL.Thing)) {
|
||||
|
||||
Iterator<String> graphIt = dataset.listNames();
|
||||
while(graphIt.hasNext()) {
|
||||
String graph = graphIt.next();
|
||||
if(!KnowledgeBaseUpdater.isUpdatableABoxGraph(graph)){
|
||||
continue;
|
||||
}
|
||||
Model aboxModel = dataset.getNamedModel(graph);
|
||||
|
||||
StmtIterator stmtIter = aboxModel.listStatements(null, RDF.type, parentOfAddedClass);
|
||||
|
||||
int count = stmtIter.toList().size();
|
||||
|
||||
|
||||
Iterator<String> graphIt = dataset.listNames();
|
||||
while (graphIt.hasNext()) {
|
||||
String graph = graphIt.next();
|
||||
if (!KnowledgeBaseUpdater.isUpdatableABoxGraph(graph)) {
|
||||
continue;
|
||||
}
|
||||
Model aboxModel = dataset.getNamedModel(graph);
|
||||
|
||||
StmtIterator stmtIter = aboxModel.listStatements(null, RDF.type, parentOfAddedClass);
|
||||
|
||||
int count = stmtIter.toList().size();
|
||||
|
||||
if (count > 0) {
|
||||
//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() + "," +
|
||||
" 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() );
|
||||
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() + ". " +
|
||||
"Please review " + ((count > 1) ? "these" : "this") + " individual" + ((count > 1) ? "s" : "") + " to see whether " + ((count > 1) ? "they" : "it") + " should be of type: " + addedClass.getURI());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,36 +406,34 @@ public class ABoxUpdater {
|
|||
}
|
||||
|
||||
public void processPropertyChanges(List<AtomicOntologyChange> changes) throws IOException {
|
||||
|
||||
Iterator<AtomicOntologyChange> propItr = changes.iterator();
|
||||
while(propItr.hasNext()){
|
||||
AtomicOntologyChange propChangeObj = propItr.next();
|
||||
|
||||
for (AtomicOntologyChange propChangeObj : changes) {
|
||||
log.debug("processing " + propChangeObj);
|
||||
try {
|
||||
if (propChangeObj.getAtomicChangeType() == null) {
|
||||
log.error("Missing change type; skipping " + propChangeObj);
|
||||
continue;
|
||||
}
|
||||
switch (propChangeObj.getAtomicChangeType()){
|
||||
case ADD:
|
||||
log.debug("add");
|
||||
addProperty(propChangeObj);
|
||||
break;
|
||||
case DELETE:
|
||||
log.debug("delete");
|
||||
deleteProperty(propChangeObj);
|
||||
break;
|
||||
case RENAME:
|
||||
log.debug("rename");
|
||||
renameProperty(propChangeObj);
|
||||
break;
|
||||
default:
|
||||
log.debug("unknown");
|
||||
logger.logError("unexpected change type indicator: " + propChangeObj.getAtomicChangeType());
|
||||
break;
|
||||
}
|
||||
if (propChangeObj.getAtomicChangeType() == null) {
|
||||
log.error("Missing change type; skipping " + propChangeObj);
|
||||
continue;
|
||||
}
|
||||
switch (propChangeObj.getAtomicChangeType()) {
|
||||
case ADD:
|
||||
log.debug("add");
|
||||
addProperty(propChangeObj);
|
||||
break;
|
||||
case DELETE:
|
||||
log.debug("delete");
|
||||
deleteProperty(propChangeObj);
|
||||
break;
|
||||
case RENAME:
|
||||
log.debug("rename");
|
||||
renameProperty(propChangeObj);
|
||||
break;
|
||||
default:
|
||||
log.debug("unknown");
|
||||
logger.logError("unexpected change type indicator: " + propChangeObj.getAtomicChangeType());
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e,e);
|
||||
log.error(e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -418,41 +418,38 @@ public class KnowledgeBaseUpdater {
|
|||
public AtomicOntologyChangeLists (
|
||||
List<AtomicOntologyChange> changeList, OntModel newTboxModel,
|
||||
OntModel oldTboxModel) throws IOException {
|
||||
|
||||
Iterator<AtomicOntologyChange> listItr = changeList.iterator();
|
||||
|
||||
while(listItr.hasNext()) {
|
||||
AtomicOntologyChange changeObj = listItr.next();
|
||||
if (changeObj.getSourceURI() != null){
|
||||
log.debug("triaging " + changeObj);
|
||||
if (oldTboxModel.getOntProperty(changeObj.getSourceURI()) != null){
|
||||
atomicPropertyChanges.add(changeObj);
|
||||
log.debug("added to property changes");
|
||||
|
||||
for (AtomicOntologyChange changeObj : changeList) {
|
||||
if (changeObj.getSourceURI() != null) {
|
||||
log.debug("triaging " + changeObj);
|
||||
if (oldTboxModel.getOntProperty(changeObj.getSourceURI()) != null) {
|
||||
atomicPropertyChanges.add(changeObj);
|
||||
log.debug("added to property changes");
|
||||
} else if (oldTboxModel.getOntClass(changeObj.getSourceURI()) != null) {
|
||||
atomicClassChanges.add(changeObj);
|
||||
log.debug("added to class changes");
|
||||
atomicClassChanges.add(changeObj);
|
||||
log.debug("added to class changes");
|
||||
} else if ("Prop".equals(changeObj.getNotes())) {
|
||||
atomicPropertyChanges.add(changeObj);
|
||||
atomicPropertyChanges.add(changeObj);
|
||||
} else if ("Class".equals(changeObj.getNotes())) {
|
||||
atomicClassChanges.add(changeObj);
|
||||
} else{
|
||||
logger.log("WARNING: Source URI is neither a Property" +
|
||||
" nor a Class. " + "Change Object skipped for sourceURI: " + changeObj.getSourceURI());
|
||||
atomicClassChanges.add(changeObj);
|
||||
} else {
|
||||
logger.log("WARNING: Source URI is neither a Property" +
|
||||
" 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) {
|
||||
atomicPropertyChanges.add(changeObj);
|
||||
} else if(newTboxModel.getOntClass(changeObj.
|
||||
getDestinationURI()) != null) {
|
||||
} else if (newTboxModel.getOntClass(changeObj.
|
||||
getDestinationURI()) != null) {
|
||||
atomicClassChanges.add(changeObj);
|
||||
} else{
|
||||
} else {
|
||||
logger.log("WARNING: Destination URI is neither a Property" +
|
||||
" nor a Class. " + "Change Object skipped for destinationURI: " + changeObj.getDestinationURI());
|
||||
}
|
||||
} else{
|
||||
logger.log("WARNING: Source and Destination URI can't be null. " + "Change Object skipped" );
|
||||
} else {
|
||||
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");
|
||||
|
|
|
@ -171,10 +171,8 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
s.sparqlSelectQuery(query, RDFService.ResultFormat.JSON));
|
||||
List<QuerySolution> solnList = getSolutionList(resultSet);
|
||||
List<String> vars = resultSet.getResultVars();
|
||||
Iterator<String> varIt = vars.iterator();
|
||||
while (varIt.hasNext()) {
|
||||
String var = varIt.next();
|
||||
for (int i = 0 ; i < solnList.size(); i ++ ) {
|
||||
for (String var : vars) {
|
||||
for (int i = 0; i < solnList.size(); i++) {
|
||||
QuerySolution s = solnList.get(i);
|
||||
if (s == null) {
|
||||
continue;
|
||||
|
@ -183,10 +181,10 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
if (node == null || !node.isLiteral()) {
|
||||
continue;
|
||||
}
|
||||
List<RowIndexedLiteral> candidatesForRemoval =
|
||||
List<RowIndexedLiteral> candidatesForRemoval =
|
||||
new ArrayList<RowIndexedLiteral>();
|
||||
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);
|
||||
if (t == null) {
|
||||
continue;
|
||||
|
@ -204,7 +202,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator();
|
||||
String langRegister = null;
|
||||
boolean chuckRemaining = false;
|
||||
while(candIt.hasNext()) {
|
||||
while (candIt.hasNext()) {
|
||||
RowIndexedLiteral rlit = candIt.next();
|
||||
if (chuckRemaining) {
|
||||
solnList.set(rlit.getIndex(), null);
|
||||
|
@ -218,9 +216,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
}
|
||||
}
|
||||
List<QuerySolution> compactedList = new ArrayList<QuerySolution>();
|
||||
Iterator<QuerySolution> solIt = solnList.iterator();
|
||||
while(solIt.hasNext()) {
|
||||
QuerySolution soln = solIt.next();
|
||||
for (QuerySolution soln : solnList) {
|
||||
if (soln != null) {
|
||||
compactedList.add(soln);
|
||||
}
|
||||
|
@ -268,10 +264,8 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
protected void endProcessing() {
|
||||
chainStartProcessing();
|
||||
|
||||
Iterator<String> varIt = vars.iterator();
|
||||
while (varIt.hasNext()) {
|
||||
String var = varIt.next();
|
||||
for (int i = 0 ; i < solnList.size(); i ++ ) {
|
||||
for (String var : vars) {
|
||||
for (int i = 0; i < solnList.size(); i++) {
|
||||
QuerySolution s = solnList.get(i);
|
||||
if (s == null) {
|
||||
continue;
|
||||
|
@ -283,7 +277,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
List<RowIndexedLiteral> candidatesForRemoval =
|
||||
new ArrayList<RowIndexedLiteral>();
|
||||
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);
|
||||
if (t == null) {
|
||||
continue;
|
||||
|
@ -301,7 +295,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator();
|
||||
String langRegister = null;
|
||||
boolean chuckRemaining = false;
|
||||
while(candIt.hasNext()) {
|
||||
while (candIt.hasNext()) {
|
||||
RowIndexedLiteral rlit = candIt.next();
|
||||
if (chuckRemaining) {
|
||||
solnList.set(rlit.getIndex(), null);
|
||||
|
@ -315,9 +309,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
}
|
||||
}
|
||||
|
||||
Iterator<QuerySolution> solIt = solnList.iterator();
|
||||
while(solIt.hasNext()) {
|
||||
QuerySolution soln = solIt.next();
|
||||
for (QuerySolution soln : solnList) {
|
||||
if (soln != null) {
|
||||
chainProcessQuerySolution(soln);
|
||||
}
|
||||
|
|
|
@ -142,9 +142,7 @@ public abstract class RDFServiceImpl implements RDFService {
|
|||
|
||||
protected void notifyListeners(ModelChange modelChange) throws IOException {
|
||||
modelChange.getSerializedModel().reset();
|
||||
Iterator<ChangeListener> iter = registeredListeners.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ChangeListener listener = iter.next();
|
||||
for (ChangeListener listener : registeredListeners) {
|
||||
listener.notifyModelChange(modelChange);
|
||||
}
|
||||
log.debug(registeredJenaListeners.size() + " registered Jena listeners");
|
||||
|
@ -173,16 +171,12 @@ public abstract class RDFServiceImpl implements RDFService {
|
|||
}
|
||||
}
|
||||
|
||||
public void notifyListenersOfEvent(Object event) {
|
||||
Iterator<ChangeListener> iter = registeredListeners.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ChangeListener listener = iter.next();
|
||||
public void notifyListenersOfEvent(Object event) {
|
||||
for (ChangeListener listener : registeredListeners) {
|
||||
// TODO what is the graphURI parameter for?
|
||||
listener.notifyEvent(null, event);
|
||||
}
|
||||
Iterator<ModelChangedListener> jenaIter = registeredJenaListeners.iterator();
|
||||
while (jenaIter.hasNext()) {
|
||||
ModelChangedListener listener = jenaIter.next();
|
||||
for (ModelChangedListener listener : registeredJenaListeners) {
|
||||
listener.notifyEvent(null, event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,9 +79,7 @@ public class RDFServiceModel extends RDFServiceJena implements RDFService {
|
|||
this.notifyListenersOfEvent(o);
|
||||
}
|
||||
|
||||
Iterator<ModelChange> csIt = changeSet.getModelChanges().iterator();
|
||||
while (csIt.hasNext()) {
|
||||
ModelChange modelChange = csIt.next();
|
||||
for (ModelChange modelChange : changeSet.getModelChanges()) {
|
||||
if (!modelChange.getSerializedModel().markSupported()) {
|
||||
byte[] bytes = IOUtils.toByteArray(modelChange.getSerializedModel());
|
||||
modelChange.setSerializedModel(new ByteArrayInputStream(bytes));
|
||||
|
@ -95,7 +93,7 @@ public class RDFServiceModel extends RDFServiceJena implements RDFService {
|
|||
} else {
|
||||
m = dataset.getDefaultModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
operateOnModel(m, modelChange, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -178,9 +178,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
|
|||
this.notifyListenersOfEvent(o);
|
||||
}
|
||||
|
||||
Iterator<ModelChange> csIt = changeSet.getModelChanges().iterator();
|
||||
while (csIt.hasNext()) {
|
||||
ModelChange modelChange = csIt.next();
|
||||
for (ModelChange modelChange : changeSet.getModelChanges()) {
|
||||
if (!modelChange.getSerializedModel().markSupported()) {
|
||||
byte[] bytes = IOUtils.toByteArray(modelChange.getSerializedModel());
|
||||
modelChange.setSerializedModel(new ByteArrayInputStream(bytes));
|
||||
|
|
|
@ -73,13 +73,11 @@ public class IndividualURIQueue<E> implements Queue<E> {
|
|||
@Override
|
||||
public synchronized boolean retainAll(Collection<?> c) {
|
||||
boolean changed = false;
|
||||
Iterator<E> it = m.keySet().iterator();
|
||||
while(it.hasNext()) {
|
||||
E e = it.next();
|
||||
if(!c.contains(e)) {
|
||||
m.remove(e);
|
||||
q.remove(e);
|
||||
changed = true;
|
||||
for (E e : m.keySet()) {
|
||||
if (!c.contains(e)) {
|
||||
m.remove(e);
|
||||
q.remove(e);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
|
|
|
@ -562,19 +562,17 @@ public class SimpleReasoner extends StatementListener
|
|||
sameIndividuals.add(resource);
|
||||
|
||||
aboxModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
Iterator<Resource> sameIter = sameIndividuals.iterator();
|
||||
while (sameIter.hasNext()) {
|
||||
Resource res = sameIter.next();
|
||||
StmtIterator typeIt = aboxModel.listStatements(res, RDF.type, (RDFNode) null);
|
||||
while (typeIt.hasNext()) {
|
||||
Statement stmt = typeIt.nextStatement();
|
||||
if (stmt.getObject().isURIResource()) {
|
||||
String typeURI = stmt.getObject().asResource().getURI();
|
||||
typeURIs.add(typeURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
for (Resource res : sameIndividuals) {
|
||||
StmtIterator typeIt = aboxModel.listStatements(res, RDF.type, (RDFNode) null);
|
||||
while (typeIt.hasNext()) {
|
||||
Statement stmt = typeIt.nextStatement();
|
||||
if (stmt.getObject().isURIResource()) {
|
||||
String typeURI = stmt.getObject().asResource().getURI();
|
||||
typeURIs.add(typeURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
|
@ -802,20 +800,17 @@ public class SimpleReasoner extends StatementListener
|
|||
if (handleSameAs) {
|
||||
List<Resource> sameIndividuals =
|
||||
getSameIndividuals(infStmt.getSubject().asResource(), inferenceModel);
|
||||
Iterator<Resource> sameIter = sameIndividuals.iterator();
|
||||
while (sameIter.hasNext()) {
|
||||
Resource subject = sameIter.next();
|
||||
|
||||
Statement sameStmt =
|
||||
ResourceFactory.createStatement(subject,infStmt.getPredicate(),
|
||||
infStmt.getObject());
|
||||
if (subject.equals(infStmt.getObject())
|
||||
&& OWL.sameAs.equals(infStmt.getPredicate())) {
|
||||
for (Resource subject : sameIndividuals) {
|
||||
Statement sameStmt =
|
||||
ResourceFactory.createStatement(subject, infStmt.getPredicate(),
|
||||
infStmt.getObject());
|
||||
if (subject.equals(infStmt.getObject())
|
||||
&& OWL.sameAs.equals(infStmt.getPredicate())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!inferenceModel.contains(sameStmt)
|
||||
&& !aboxModel.contains(sameStmt)) {
|
||||
|
||||
if (!inferenceModel.contains(sameStmt)
|
||||
&& !aboxModel.contains(sameStmt)) {
|
||||
inferenceModel.add(sameStmt);
|
||||
}
|
||||
}
|
||||
|
@ -859,18 +854,17 @@ public class SimpleReasoner extends StatementListener
|
|||
try {
|
||||
List<Resource> sameIndividuals =
|
||||
getSameIndividuals(infStmt.getSubject().asResource(), inferenceModel);
|
||||
|
||||
Iterator<Resource> sameIter = sameIndividuals.iterator();
|
||||
while (sameIter.hasNext()) {
|
||||
Statement infStmtSame =
|
||||
ResourceFactory.createStatement(sameIter.next(),
|
||||
infStmt.getPredicate(), infStmt.getObject());
|
||||
if ((!checkEntailment
|
||||
|| !entailedStatement(infStmtSame))
|
||||
&& inferenceModel.contains(infStmtSame)) {
|
||||
inferenceModel.remove(infStmtSame);
|
||||
}
|
||||
}
|
||||
|
||||
for (Resource sameIndividual : sameIndividuals) {
|
||||
Statement infStmtSame =
|
||||
ResourceFactory.createStatement(sameIndividual,
|
||||
infStmt.getPredicate(), infStmt.getObject());
|
||||
if ((!checkEntailment
|
||||
|| !entailedStatement(infStmtSame))
|
||||
&& inferenceModel.contains(infStmtSame)) {
|
||||
inferenceModel.remove(infStmtSame);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
inferenceModel.leaveCriticalSection();
|
||||
}
|
||||
|
@ -935,50 +929,40 @@ public class SimpleReasoner extends StatementListener
|
|||
|
||||
List<OntClass> types2 = new ArrayList<OntClass>();
|
||||
types2.addAll(types);
|
||||
|
||||
Iterator<OntClass> typeIter = types.iterator();
|
||||
|
||||
while (typeIter.hasNext()) {
|
||||
OntClass type = typeIter.next();
|
||||
|
||||
boolean add = true;
|
||||
Iterator<OntClass> typeIter2 = types2.iterator();
|
||||
while (typeIter2.hasNext()) {
|
||||
OntClass type2 = typeIter2.next();
|
||||
|
||||
if (type.equals(type2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.hasSubClass(type2, false) && !type2.hasSubClass(type, false)) {
|
||||
add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (add) {
|
||||
typeURIs.add(type.getURI());
|
||||
|
||||
ArrayList<Resource> equivalentClasses = new ArrayList<Resource>();
|
||||
|
||||
Iterator<Statement> iter = tboxModel.listStatements((Resource) null, OWL.equivalentClass, type);
|
||||
while (iter.hasNext()) {
|
||||
Statement stmt = iter.next();
|
||||
Resource res = stmt.getSubject();
|
||||
if ((res == null) || res.isAnon() || equivalentClasses.contains(res) ) {
|
||||
continue;
|
||||
}
|
||||
equivalentClasses.add(res);
|
||||
}
|
||||
|
||||
Iterator<Resource> eIter = equivalentClasses.iterator();
|
||||
|
||||
while (eIter.hasNext()) {
|
||||
Resource equivClass = eIter.next();
|
||||
if (equivClass.isAnon()) continue;
|
||||
typeURIs.add(equivClass.getURI());
|
||||
}
|
||||
}
|
||||
|
||||
for (OntClass type : types) {
|
||||
boolean add = true;
|
||||
for (OntClass type2 : types2) {
|
||||
if (type.equals(type2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.hasSubClass(type2, false) && !type2.hasSubClass(type, false)) {
|
||||
add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (add) {
|
||||
typeURIs.add(type.getURI());
|
||||
|
||||
ArrayList<Resource> equivalentClasses = new ArrayList<Resource>();
|
||||
|
||||
Iterator<Statement> iter = tboxModel.listStatements((Resource) null, OWL.equivalentClass, type);
|
||||
while (iter.hasNext()) {
|
||||
Statement stmt = iter.next();
|
||||
Resource res = stmt.getSubject();
|
||||
if ((res == null) || res.isAnon() || equivalentClasses.contains(res)) {
|
||||
continue;
|
||||
}
|
||||
equivalentClasses.add(res);
|
||||
}
|
||||
|
||||
for (Resource equivClass : equivalentClasses) {
|
||||
if (equivClass.isAnon()) continue;
|
||||
typeURIs.add(equivClass.getURI());
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
inferenceModel.leaveCriticalSection();
|
||||
|
@ -1017,13 +1001,11 @@ public class SimpleReasoner extends StatementListener
|
|||
Iterator<Statement> rIter = retractions.listStatements();
|
||||
while (rIter.hasNext()) {
|
||||
removeInference(rIter.next(), inferenceModel, true, false);
|
||||
}
|
||||
|
||||
Iterator<String> typeIter = typeURIs.iterator();
|
||||
while (typeIter.hasNext()) {
|
||||
String typeURI = typeIter.next();
|
||||
Statement mstStmt = ResourceFactory.createStatement(individual,mostSpecificType,ResourceFactory.createResource(typeURI));
|
||||
addInference(mstStmt,inferenceModel,true);
|
||||
}
|
||||
|
||||
for (String typeURI : typeURIs) {
|
||||
Statement mstStmt = ResourceFactory.createStatement(individual, mostSpecificType, ResourceFactory.createResource(typeURI));
|
||||
addInference(mstStmt, inferenceModel, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -174,23 +174,21 @@ public abstract class SimpleBridgingRule implements ReasonerPlugin {
|
|||
} else if (stmt.getPredicate().equals(assertedProp2)) {
|
||||
z = stmt.getObject();
|
||||
}
|
||||
Iterator<Statement> sit = aboxInferencesModel.listStatements(x, this.inferredProp, z).toList().iterator();
|
||||
|
||||
while(sit.hasNext()) {
|
||||
Statement s = sit.next();
|
||||
Query ask = createQuery(this.retractionTestString, stmt, s);
|
||||
QueryExecution qe = QueryExecutionFactory.create(ask, aboxAssertionsModel);
|
||||
try {
|
||||
if (!qe.execAsk()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("==> removing " + s);
|
||||
}
|
||||
if (simpleReasoner != null) simpleReasoner.removeInference(s,aboxInferencesModel);
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
}
|
||||
|
||||
for (Statement s : aboxInferencesModel.listStatements(x, this.inferredProp, z).toList()) {
|
||||
Query ask = createQuery(this.retractionTestString, stmt, s);
|
||||
QueryExecution qe = QueryExecutionFactory.create(ask, aboxAssertionsModel);
|
||||
try {
|
||||
if (!qe.execAsk()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("==> removing " + s);
|
||||
}
|
||||
if (simpleReasoner != null) simpleReasoner.removeInference(s, aboxInferencesModel);
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRelevantPredicate(Statement stmt) {
|
||||
|
|
|
@ -197,18 +197,16 @@ public class PagedSearchController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
List<Individual> individuals = new ArrayList<Individual>(docs.size());
|
||||
Iterator<SearchResultDocument> docIter = docs.iterator();
|
||||
while( docIter.hasNext() ){
|
||||
try {
|
||||
SearchResultDocument doc = docIter.next();
|
||||
String uri = doc.getStringValue(VitroSearchTermNames.URI);
|
||||
for (SearchResultDocument doc : docs) {
|
||||
try {
|
||||
String uri = doc.getStringValue(VitroSearchTermNames.URI);
|
||||
Individual ind = iDao.getIndividualByURI(uri);
|
||||
if(ind != null) {
|
||||
ind.setSearchSnippet( getSnippet(doc, response) );
|
||||
individuals.add(ind);
|
||||
if (ind != null) {
|
||||
ind.setSearchSnippet(getSnippet(doc, response));
|
||||
individuals.add(ind);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
log.error("Problem getting usable individuals from search hits. ",e);
|
||||
} catch (Exception e) {
|
||||
log.error("Problem getting usable individuals from search hits. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,10 +77,8 @@ public class GetAllClasses extends BaseEditController {
|
|||
|
||||
while (classGroupIt.hasNext()) {
|
||||
VClassGroup group = (VClassGroup) classGroupIt.next();
|
||||
List classes = group.getVitroClassList();
|
||||
Iterator classIt = classes.iterator();
|
||||
while (classIt.hasNext()) {
|
||||
VClass clazz = (VClass) classIt.next();
|
||||
List<VClass> classes = group.getVitroClassList();
|
||||
for (VClass clazz : classes) {
|
||||
respo.append("<option>" + "<key>").append(clazz.getPickListName()).append("</key>").append("<value>").append(clazz.getURI()).append("</value>").append("</option>");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -644,9 +644,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
}
|
||||
|
||||
public PropertyGroupTemplateModel pullPropertyGroup(String groupName) {
|
||||
Iterator<PropertyGroupTemplateModel> groupIt = groups.iterator();
|
||||
while (groupIt.hasNext()) {
|
||||
PropertyGroupTemplateModel group = groupIt.next();
|
||||
for (PropertyGroupTemplateModel group : groups) {
|
||||
if (groupName.equals(group.getName())) {
|
||||
groups.remove(group);
|
||||
return group;
|
||||
|
|
|
@ -426,20 +426,18 @@ public class VClassJenaTest {
|
|||
}
|
||||
|
||||
private String getLabel2(String lang, List<RDFNode>labelList) {
|
||||
Iterator<RDFNode> labelIt = labelList.iterator();
|
||||
while (labelIt.hasNext()) {
|
||||
RDFNode label = labelIt.next();
|
||||
if (label.isLiteral()) {
|
||||
Literal labelLit = ((Literal)label);
|
||||
String labelLanguage = labelLit.getLanguage();
|
||||
if ( (labelLanguage==null) && (lang==null) ) {
|
||||
return labelLit.getLexicalForm();
|
||||
}
|
||||
if ( (lang != null) && (lang.equals(labelLanguage)) ) {
|
||||
return labelLit.getLexicalForm();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (RDFNode label : labelList) {
|
||||
if (label.isLiteral()) {
|
||||
Literal labelLit = ((Literal) label);
|
||||
String labelLanguage = labelLit.getLanguage();
|
||||
if ((labelLanguage == null) && (lang == null)) {
|
||||
return labelLit.getLexicalForm();
|
||||
}
|
||||
if ((lang != null) && (lang.equals(labelLanguage))) {
|
||||
return labelLit.getLexicalForm();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue