partOf.setInverseProperty(hasPart);
// now that we have all classes, build a tree, since classes only have the superclasses set
IResourceIterator it = target.getAllClasses();
while(it.hasNext()){
IClass cls = (IClass) it.next();
long time = System.currentTimeMillis();
// now copy equivalent classes classes
IProperty p = target.getProperty(EQUIVALENT_CLASS);
if(p != null){
for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
cls.addEquivalentClass(sibling);
}
// remove temporary property
cls.removePropertyValues(p);
}
// setup direct subclasses and superclasses
p = target.getProperty(SUPER_CLASS);
if(p != null){
for(IClass parent: getClassList(target,cls.getPropertyValues(p))){
if(!cls.hasDirectSuperClass(parent)){
// add string as a true superclass
cls.addSuperClass(parent);
// if superclass is not root, then add this class
// as a child and remove root as parent
if(!parent.equals(target.getRoot())){
parent.addSubClass(cls);
// since everything was added as root, cleanup
cls.removeSuperClass(target.getRoot());
}
}
}
// remove temporary property
cls.removePropertyValues(p);
}
// setup direct subclasses and superclasses
p = target.getProperty(SUB_CLASS);
if(p != null){
for(IClass child: getClassList(target,cls.getPropertyValues(p))){
if(!cls.hasDirectSubClass(child)){
// add string as a true superclass
cls.addSubClass(child);
child.addSuperClass(cls);
// if superclass is not root, then add this class
// as a child and remove root as parent
if(child.hasDirectSuperClass(target.getRoot())){
// since everything was added as root, cleanup
child.removeSuperClass(target.getRoot());
}
}
}
// remove temporary property
cls.removePropertyValues(p);
}
// now copy disjoint classes
p = target.getProperty(DISJOINT_CLASS);
if(p != null){
for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
cls.addDisjointClass(sibling);
}
// remove temporary property
cls.removePropertyValues(p);
}
// now copy other relationships relationships
for(String relation: new String [] {PART_OF, HAS_PART}){
p = target.getProperty("annotation_"+relation);
if(p != null){
for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
IRestriction r = target.createRestriction(IRestriction.SOME_VALUES_FROM);
r.setProperty(target.getProperty(relation));
r.setParameter(sibling.getLogicExpression());
cls.addNecessaryRestriction(r);
}
// remove temporary property
cls.removePropertyValues(p);
}
}