NIHVIVO-214 fixing bug in previous version of this issue resolution

This commit is contained in:
sjm222 2010-03-26 19:12:54 +00:00
parent 6e4346ea51
commit e5071f8920
2 changed files with 20 additions and 18 deletions

View file

@ -345,7 +345,7 @@ public class JenaBaseDao extends JenaBaseDaoCon {
model.removeAll(res, dataprop, null); model.removeAll(res, dataprop, null);
} else if (existingValue == null ) { } else if (existingValue == null ) {
model.add(res, dataprop, Float.toString(value), XSDDatatype.XSDfloat); model.add(res, dataprop, Float.toString(value), XSDDatatype.XSDfloat);
} else if (existingValue != value) { } else if (existingValue.compareTo(value) != 0) {
model.removeAll(res, dataprop, null); model.removeAll(res, dataprop, null);
model.add(res, dataprop, Float.toString(value), XSDDatatype.XSDfloat); model.add(res, dataprop, Float.toString(value), XSDDatatype.XSDfloat);
} }
@ -487,9 +487,9 @@ public class JenaBaseDao extends JenaBaseDaoCon {
} }
/** /**
* convenience method for use with functional object properties * convenience method for use with functional properties
*/ */
protected void updatePropertyResourceURIValue(Resource res, ObjectProperty prop, String objectURI) { protected void updatePropertyResourceURIValue(Resource res, Property prop, String objectURI) {
Model model = res.getModel(); Model model = res.getModel();
@ -542,7 +542,7 @@ public class JenaBaseDao extends JenaBaseDaoCon {
} }
/** /**
* convenience method for use with functional object properties * convenience method for use with functional properties
*/ */
protected void updatePropertyResourceValue(Resource res, Property prop, Resource objectRes) { protected void updatePropertyResourceValue(Resource res, Property prop, Resource objectRes) {
@ -555,7 +555,7 @@ public class JenaBaseDao extends JenaBaseDaoCon {
} }
/** /**
* convenience method for use with functional object properties * convenience method for use with functional properties
*/ */
protected void updatePropertyResourceValue(Resource res, Property prop, Resource objectRes, Model model) { protected void updatePropertyResourceValue(Resource res, Property prop, Resource objectRes, Model model) {
@ -585,17 +585,17 @@ public class JenaBaseDao extends JenaBaseDaoCon {
/** /**
* convenience method for updating the RDFS label * convenience method for updating the RDFS label
*/ */
protected void updateRDFSLabel(OntClass ontCls, String label) { protected void updateRDFSLabel(OntResource ontRes, String label) {
if (label != null && label.length() > 0) { if (label != null && label.length() > 0) {
String existingValue = ontCls.getLabel((String) getDefaultLanguage()); String existingValue = ontRes.getLabel((String) getDefaultLanguage());
if (existingValue == null || !existingValue.equals(label)) { if (existingValue == null || !existingValue.equals(label)) {
ontCls.setLabel(label, (String) getDefaultLanguage()); ontRes.setLabel(label, (String) getDefaultLanguage());
} }
} else { } else {
ontCls.removeAll(RDFS.label); ontRes.removeAll(RDFS.label);
} }
} }

View file

@ -75,16 +75,17 @@ public class VClassDaoTest {
// Save copies of sub-model and super-model // Save copies of sub-model and super-model
// uncommment the next two lines to debug failures // uncommment the next two lines to debug failures
//System.out.println("**Before updating VClass:"); System.out.println("**Before updating VClass:");
//printModels(superModel, subModel); printModels(superModel, subModel);
superModel.removeSubModel(subModel);
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
origSubModel.add(subModel); origSubModel.add(subModel);
superModel.remove(subModel);
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
origSuperModel.add(superModel); origSuperModel.add(superModel);
superModel.add(subModel);
superModel.addSubModel(subModel);
// Populate the VClass with the data in the sub-model and then update the combined model // Populate the VClass with the data in the sub-model and then update the combined model
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena(superModel); WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena(superModel);
@ -102,10 +103,11 @@ public class VClassDaoTest {
// Verify that the sub-model and super-model are both unchanged // Verify that the sub-model and super-model are both unchanged
// uncommment the next two lines to debug failures // uncommment the next two lines to debug failures
//System.out.println("\n**After updating VClass:"); System.out.println("\n**After updating VClass:");
//printModels(superModel,subModel); printModels(superModel,subModel);
superModel.remove(subModel); superModel.removeSubModel(subModel);
//modtime affects the diff but we don't care about that difference //modtime affects the diff but we don't care about that difference
wipeOutModTime(origSubModel); wipeOutModTime(origSubModel);
wipeOutModTime(origSuperModel); wipeOutModTime(origSuperModel);
@ -123,7 +125,7 @@ public class VClassDaoTest {
// Detach the submodel for printing to get an accurate // Detach the submodel for printing to get an accurate
// account of what is in each. // account of what is in each.
superModel.remove(subModel); superModel.removeSubModel(subModel);
System.out.println("\nThe sub-model has " + subModel.size() + " statements:"); System.out.println("\nThe sub-model has " + subModel.size() + " statements:");
System.out.println("---------------------------------------------------"); System.out.println("---------------------------------------------------");