NIHVIVO-1370 NIHVIVO-2046 tab editing bugfixes for SDB

This commit is contained in:
bjl23 2011-02-04 21:49:17 +00:00
parent 4157612f57
commit f3e76bfb1a

View file

@ -21,8 +21,10 @@ import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.ObjectProperty; import com.hp.hpl.jena.ontology.ObjectProperty;
import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator; import com.hp.hpl.jena.util.iterator.ClosableIterator;
@ -331,7 +333,7 @@ public class TabDaoJena extends JenaBaseDao implements TabDao {
Individual portalInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"portal"+portalId); Individual portalInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"portal"+portalId);
if (portalInd == null) if (portalInd == null)
return -1; return -1;
Resource rootTabResource = (Resource) portalInd.getProperty(getOntModel().getObjectProperty(VitroVocabulary.PORTAL_ROOTTAB)).getObject(); Resource rootTabResource = (Resource) portalInd.getProperty(PORTAL_ROOTTAB).getObject();
if (rootTabResource == null) if (rootTabResource == null)
return -1; return -1;
String id = rootTabResource.getLocalName().substring(3); String id = rootTabResource.getLocalName().substring(3);
@ -346,7 +348,7 @@ public class TabDaoJena extends JenaBaseDao implements TabDao {
try { try {
Individual primaryTabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+primaryTabId); Individual primaryTabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+primaryTabId);
if (primaryTabInd != null) { if (primaryTabInd != null) {
ObjectProperty subTabOf = getOntModel().getObjectProperty(VitroVocabulary.TAB_SUBTABOF); ObjectProperty subTabOf = TAB_SUBTABOF;
if (subTabOf != null) { if (subTabOf != null) {
List secondaryTabs = new ArrayList(); List secondaryTabs = new ArrayList();
Iterator stmtIt = getOntModel().listStatements(null, subTabOf, primaryTabInd); Iterator stmtIt = getOntModel().listStatements(null, subTabOf, primaryTabInd);
@ -477,7 +479,7 @@ public class TabDaoJena extends JenaBaseDao implements TabDao {
Integer i = null; Integer i = null;
Individual narrowerTab = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tabId); Individual narrowerTab = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tabId);
if (narrowerTab != null) { if (narrowerTab != null) {
ObjectProperty subTabOf = getOntModel().getObjectProperty(VitroVocabulary.TAB_SUBTABOF); ObjectProperty subTabOf = TAB_SUBTABOF;
if (subTabOf != null) { if (subTabOf != null) {
Iterator stmtIt = narrowerTab.listProperties(subTabOf); Iterator stmtIt = narrowerTab.listProperties(subTabOf);
if (stmtIt.hasNext()) { if (stmtIt.hasNext()) {
@ -569,19 +571,19 @@ public class TabDaoJena extends JenaBaseDao implements TabDao {
try { try {
tabInd.setLabel(tab.getTitle(), (String) getDefaultLanguage()); tabInd.setLabel(tab.getTitle(), (String) getDefaultLanguage());
} catch (Exception e) {log.error("error setting label for "+tabInd.getURI());} } catch (Exception e) {log.error("error setting label for "+tabInd.getURI());}
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.DESCRIPTION), tab.getDescription(), ontModel); addPropertyStringValue(tabInd, DESCRIPTION, tab.getDescription(), ontModel);
addPropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_STATUSID), tab.getStatusId(), ontModel); addPropertyNonNegativeIntValue(tabInd, TAB_STATUSID, tab.getStatusId(), ontModel);
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_BODY), tab.getBody(), ontModel); addPropertyStringValue(tabInd, TAB_BODY, tab.getBody(), ontModel);
addPropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.DISPLAY_RANK), tab.getDisplayRank(), ontModel); addPropertyNonNegativeIntValue(tabInd, DISPLAY_RANK, tab.getDisplayRank(), ontModel);
addPropertyIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_DAYLIMIT), tab.getDayLimit(), ontModel); addPropertyIntValue(tabInd, TAB_DAYLIMIT, tab.getDayLimit(), ontModel);
addPropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_GALLERYROWS), tab.getGalleryRows(), ontModel); addPropertyNonNegativeIntValue(tabInd, TAB_GALLERYROWS, tab.getGalleryRows(), ontModel);
addPropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_GALLERYCOLS), tab.getGalleryCols(), ontModel); addPropertyNonNegativeIntValue(tabInd, TAB_GALLERYCOLS, tab.getGalleryCols(), ontModel);
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_MORETAG), tab.getMoreTag(), ontModel); addPropertyStringValue(tabInd, TAB_MORETAG, tab.getMoreTag(), ontModel);
addPropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_IMAGEWIDTH), tab.getImageWidth(), ontModel); addPropertyNonNegativeIntValue(tabInd, TAB_IMAGEWIDTH, tab.getImageWidth(), ontModel);
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_ENTITYSORTFIELD), tab.getEntitySortField(), ontModel); addPropertyStringValue(tabInd, TAB_ENTITYSORTFIELD, tab.getEntitySortField(), ontModel);
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_ENTITYSORTDIRECTION), tab.getEntitySortDirection(), ontModel); addPropertyStringValue(tabInd, TAB_ENTITYSORTDIRECTION, tab.getEntitySortDirection(), ontModel);
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_FLAG2MODE), tab.getFlag2Mode(), ontModel); addPropertyStringValue(tabInd, TAB_FLAG2MODE, tab.getFlag2Mode(), ontModel);
addPropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_FLAG2SET), tab.getFlag2Set(), ontModel); addPropertyStringValue(tabInd, TAB_FLAG2SET, tab.getFlag2Set(), ontModel);
try { try {
Object o = entityLinkMethods.get(tab.getEntityLinkMethod()); Object o = entityLinkMethods.get(tab.getEntityLinkMethod());
if (o instanceof List) { if (o instanceof List) {
@ -622,19 +624,19 @@ public class TabDaoJena extends JenaBaseDao implements TabDao {
try { try {
tabInd.setLabel(tab.getTitle(), (String) getDefaultLanguage()); tabInd.setLabel(tab.getTitle(), (String) getDefaultLanguage());
} catch (Exception e) {log.error("Error updating title for tab "+tab.getTabId());} } catch (Exception e) {log.error("Error updating title for tab "+tab.getTabId());}
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.DESCRIPTION), tab.getDescription(), ontModel); updatePropertyStringValue(tabInd, DESCRIPTION, tab.getDescription(), ontModel);
updatePropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_STATUSID), tab.getStatusId(), ontModel); updatePropertyNonNegativeIntValue(tabInd, TAB_STATUSID, tab.getStatusId(), ontModel);
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_BODY), tab.getBody(), ontModel); updatePropertyStringValue(tabInd, TAB_BODY, tab.getBody(), ontModel);
updatePropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.DISPLAY_RANK), tab.getDisplayRank(), ontModel); updatePropertyNonNegativeIntValue(tabInd, DISPLAY_RANK, tab.getDisplayRank(), ontModel);
updatePropertyIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_DAYLIMIT), tab.getDayLimit(), ontModel); updatePropertyIntValue(tabInd, TAB_DAYLIMIT, tab.getDayLimit(), ontModel);
updatePropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_GALLERYROWS), tab.getGalleryRows(), ontModel); updatePropertyNonNegativeIntValue(tabInd, TAB_GALLERYROWS, tab.getGalleryRows(), ontModel);
updatePropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_GALLERYCOLS), tab.getGalleryCols(), ontModel); updatePropertyNonNegativeIntValue(tabInd, TAB_GALLERYCOLS, tab.getGalleryCols(), ontModel);
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_MORETAG), tab.getMoreTag(), ontModel); updatePropertyStringValue(tabInd, TAB_MORETAG, tab.getMoreTag(), ontModel);
updatePropertyNonNegativeIntValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_IMAGEWIDTH), tab.getImageWidth(), ontModel); updatePropertyNonNegativeIntValue(tabInd, TAB_IMAGEWIDTH, tab.getImageWidth(), ontModel);
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_ENTITYSORTFIELD), tab.getEntitySortField(), ontModel); updatePropertyStringValue(tabInd, TAB_ENTITYSORTFIELD, tab.getEntitySortField(), ontModel);
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_ENTITYSORTDIRECTION), tab.getEntitySortDirection(), ontModel); updatePropertyStringValue(tabInd, TAB_ENTITYSORTDIRECTION, tab.getEntitySortDirection(), ontModel);
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_FLAG2MODE), tab.getFlag2Mode(), ontModel); updatePropertyStringValue(tabInd, TAB_FLAG2MODE, tab.getFlag2Mode(), ontModel);
updatePropertyStringValue(tabInd, ontModel.getDatatypeProperty(VitroVocabulary.TAB_FLAG2SET), tab.getFlag2Set(), ontModel); updatePropertyStringValue(tabInd, TAB_FLAG2SET, tab.getFlag2Set(), ontModel);
Iterator types = tabInd.listRDFTypes(false); Iterator types = tabInd.listRDFTypes(false);
List typesToRemove = new ArrayList(); List typesToRemove = new ArrayList();
while (types.hasNext()) { while (types.hasNext()) {
@ -862,11 +864,7 @@ public class TabDaoJena extends JenaBaseDao implements TabDao {
* look first for heading tabs * look first for heading tabs
*/ */
private void getChildTabs(Tab tab, int auth_level, ApplicationBean appBean){ private void getChildTabs(Tab tab, int auth_level, ApplicationBean appBean){
ObjectProperty subTabOf = getOntModel().getObjectProperty(VitroVocabulary.TAB_SUBTABOF); Property subTabOf = ResourceFactory.createProperty(VitroVocabulary.TAB_SUBTABOF);
if (subTabOf == null) {
log.error("cannot find property "+ VitroVocabulary.TAB_SUBTABOF);
return;
}
Individual parentTabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); Individual parentTabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tab.getTabId());
if (parentTabInd == null) if (parentTabInd == null)
return; return;