fixing initial classgroup

This commit is contained in:
bjl23 2010-03-13 01:01:43 +00:00
parent 5ebd33a6ea
commit e06c6d0cba
5 changed files with 24 additions and 21 deletions

Binary file not shown.

View file

@ -130,10 +130,6 @@ public class JenaModelUtils {
}
} catch (Exception e) {
log.error("Unable to create class groups automatically based on class hierarchy");
Individual thingsClassGroup = tempModel.createIndividual(wadf.getDefaultNamespace()+"vitroClassGroupThings",classGroupClass);
thingsClassGroup.addLabel("Things",null);
thingsClassGroup.addProperty(tempModel.getProperty(VitroVocabulary.DISPLAY_RANK_ANNOT),"50",XSDDatatype.XSDint);
tempModel.add(OWL.Thing, inClassGroupProperty, thingsClassGroup);
}
vitroInternalsSubmodel.enterCriticalSection(Lock.WRITE);
try {

View file

@ -800,22 +800,13 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
public void addVClassesToGroups(List <VClassGroup> groups) {
getOntModel().enterCriticalSection(Lock.READ);
try {
if ((groups != null) && (groups.size()>0)) {
if (groups != null) {
Iterator groupIt = groups.iterator();
while (groupIt.hasNext()) {
VClassGroup g = (VClassGroup) groupIt.next();
addVClassesToGroup(g);
}
} else {
VClassGroup vcg = new VClassGroup();
vcg.setURI("null://null#0");
vcg.setNamespace("null://null#");
vcg.setLocalName("0");
vcg.setPublicName("Browse Categories");
vcg.addAll(getAllVclasses());
java.util.Collections.sort(vcg.getVitroClassList());
groups.add(vcg);
}
}
} finally {
getOntModel().leaveCriticalSection();
}

View file

@ -8,6 +8,7 @@ import javax.servlet.ServletContextEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Literal;
@ -16,6 +17,7 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
@ -79,6 +81,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
if (isEmpty(memModel)) {
loadDataFromFilesystem(memModel, sce.getServletContext());
}
if (userAccountsModel.size() == 0) {
readOntologyFilesInPathSet(AUTHPATH, sce.getServletContext(), userAccountsModel);
if (userAccountsModel.size() == 0) {
@ -145,11 +148,9 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace);
if (essentialInterfaceData.size() == 0) {
essentialInterfaceData = InitialJenaModelUtils.basicPortalAndRootTab(defaultNamespace);
essentialInterfaceData.add(InitialJenaModelUtils.basicClassgroup(wadf.getDefaultNamespace()));
}
//JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData);
if (!essentialInterfaceData.isEmpty()) {
memModel.addSubModel(essentialInterfaceData);
}
memModel.add(essentialInterfaceData);
} else {
//Set the default namespace to the namespace of the first portal object we find.

View file

@ -11,6 +11,7 @@ import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
@ -22,6 +23,7 @@ import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.util.ResourceUtils;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
@ -86,7 +88,6 @@ public class InitialJenaModelUtils {
}
public static Model basicPortalAndRootTab(String defaultNamespace) {
OntModel essentialInterfaceData = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Resource portalClass = essentialInterfaceData.getResource(VitroVocabulary.PORTAL);
Property themeDirProperty = essentialInterfaceData.getProperty(VitroVocabulary.PORTAL_THEMEDIR);
@ -110,8 +111,22 @@ public class InitialJenaModelUtils {
rootTab.addProperty(tabInPortalProperty, portal1);
portal1.addProperty(rootTabProperty, rootTab);
return essentialInterfaceData;
return essentialInterfaceData;
}
public static Model basicClassgroup(String defaultNamespace) {
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Individual thingsClassGroup = m.createIndividual(
defaultNamespace+"vitroClassGroupThings",
m.createResource(VitroVocabulary.CLASSGROUP));
thingsClassGroup.addLabel("Things", null);
thingsClassGroup.addProperty(
m.getProperty(VitroVocabulary.DISPLAY_RANK_ANNOT),
"50", XSDDatatype.XSDint);
m.add(OWL.Thing,
m.getProperty(VitroVocabulary.IN_CLASSGROUP), thingsClassGroup);
return m;
}
}