label management and concept semantic type

This commit is contained in:
hudajkhan 2013-09-04 12:22:46 -04:00
parent 3314e5a4b0
commit 9ec7d11cab
5 changed files with 53 additions and 48 deletions

View file

@ -34,36 +34,35 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.DatasetWrapperFactory;
//We are representing semantic types from the UMLS Semantic Network as OWL Classes
//and this preprocessor will add the appropriate class information to the TBox
public class ConceptSparqlUpdatePreprocessor implements ModelChangePreprocessor {
public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor {
private static String VIVOCore = "http://vivoweb.org/ontology/core#";
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
private Log log = LogFactory.getLog(ConceptSparqlUpdatePreprocessor.class);
private Log log = LogFactory.getLog(ConceptSemanticTypesPreprocessor.class);
private OntModel toUpdateModel = null;
private DatasetWrapperFactory dwf = null;
//Custom constructor
public ConceptSparqlUpdatePreprocessor(OntModel updateModel, DatasetWrapperFactory inputDwf) {
public ConceptSemanticTypesPreprocessor(OntModel updateModel) {
this.toUpdateModel = updateModel;
this.dwf = inputDwf;
}
@Override
public void preprocess(Model retractionsModel, Model additionsModel,
HttpServletRequest request) {
//Run a construct query against the additions model
String prefixes = "PREFIX RDFS:<" + RDFS.getURI() + "> " +
"PREFIX OWL:<http://www.w3.org/2002/07/owl#> " +
"PREFIX RDF:<" + RDF.getURI() + ">";
String prefixes = "PREFIX rdfs:<" + RDFS.getURI() + "> " +
"PREFIX owl:<http://www.w3.org/2002/07/owl#> " +
"PREFIX rdf:<" + RDF.getURI() + ">" +
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#>";
String constructQuery = prefixes + " CONSTRUCT { " +
"?semanticType rdf:type OWL:Class. { " +
"?semanticType rdfs:subClassOf SKOS:Concept . { " +
"?semanticType rdfs:label ?label. { " +
"?semanticType rdf:type owl:Class. " +
"?semanticType rdfs:subClassOf skos:Concept . " +
"?semanticType rdfs:label ?label. " +
"} WHERE { " +
"?concept rdf:type ?semanticType. { " +
"?semanticType rdfs:label ?label .{ " +
"?semanticType rdfs:subClassOf SKOS:Concept .{ " +
"?concept rdf:type ?semanticType. " +
"?semanticType rdfs:label ?label . " +
"?semanticType rdfs:subClassOf skos:Concept . " +
"}";
//Execute construct query
@ -84,13 +83,11 @@ public class ConceptSparqlUpdatePreprocessor implements ModelChangePreprocessor
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
additionsModel.getLock().enterCriticalSection(Lock.READ);
QueryExecution qe = null;
try {
qe = QueryExecutionFactory.create(
query, dataset);
query, additionsModel);
qe.execConstruct(constructedModel);
} catch (Exception e) {
log.error("Error getting constructed model for query string " + constructQuery);
@ -98,8 +95,7 @@ public class ConceptSparqlUpdatePreprocessor implements ModelChangePreprocessor
if (qe != null) {
qe.close();
}
dataset.getLock().leaveCriticalSection();
w.close();
additionsModel.getLock().leaveCriticalSection();
}
//Add constructed model to the designated update model

View file

@ -675,6 +675,7 @@ photo = Photo
no_image = no image
placeholder_image = placeholder image
manage_labels = manage labels
manage_list_of_labels = manage list of labels
add_label = Add Label
add_label_for_language = Language
unsupported_ie_version = This form is not supported in versions of Internet Explorer below version 8. Please upgrade your browser, or switch to another browser, such as FireFox.
@ -858,6 +859,6 @@ subproperty = subproperty
manage_labels_for = Manage Labels for
manage_labels_capitalized = Manage Labels
manage_labels_intro = Multiple labels exist for this profile but there should only be one. Select the label you want displayed on the profile page, and the others will be deleted.
manage_labels_intro = In the case where multiple labels exist in the same language, please use the remove link to delete the labels you do not want displayed on the profile page for a given language.
processing_icon = processing
selection_in_process = Your selection is being processed.

View file

@ -32,20 +32,31 @@ var manageLabels = {
// Initial page setup. Called only at page load.
initPage: function() {
//disable submit until user selects a language
this.submit.attr('disabled', 'disabled');
this.submit.addClass('disabledSubmit');
var disableSubmit = true;
if(this.submissionErrorsExist == "false") {
//hide the form to add label
this.addLabelForm.hide();
//the cancel in add label can be unbound until the form is visible
//this.addLabelCancel.unbind("click");
//If the number of available locales is zero, then hide the ability to show the form as well
if(this.numberAvailableLocales == 0) {
manageLabels.showFormButtonWrapper.hide();
}
} else {
//Display the form
this.onShowAddForm();
//Also make sure the save button is enabled in case there is a value selected for the drop down
if(this.labelLanguage.val() != "") {
disableSubmit = false;
}
}
if(disableSubmit) {
//disable submit until user selects a language
this.submit.attr('disabled', 'disabled');
this.submit.addClass('disabledSubmit');
}
this.bindEventListeners();
@ -88,25 +99,15 @@ var manageLabels = {
});
this.addLabelForm.find("a.cancel").click(function(){
this.addLabelForm.find("a.cancel").click(function(event){
event.preventDefault();
//clear the add form
manageLabels.clearAddForm();
//hide the add form
manageLabels.onHideAddForm();
return false;
});
//TODO: Add method to check that language is selected on submission
/*
$('input#submit').click( function() {
manageLabels.processLabel(manageLabels.selectedRadio);
$('span.or').hide();
$('a.cancel').hide();
$('span#indicator').removeClass('hidden');
$('input.submit').addClass('disabledSubmit');
$('input.submit').attr('disabled', 'disabled');
});*/
},
clearAddForm:function() {
@ -179,12 +180,12 @@ var manageLabels = {
var languageName = $(selectedLink).attr("languageName");
$(selectedLink).parent().remove();
//See if there are any other remove link
if(languageCode != "untyped") {
if(languageName != "untyped") {
//find if there are any other remove links for the same language
var removeLinks = manageLabels.existingLabelsList.find("a.remove[languageName='" + languageName + "']");
if(removeLinks.length == 0) {
//if there aren't any other labels for this language, also remove the heading
manageLabels.existingLabelsList.find("h3[languageName='" + langaugeName + "']").remove();
manageLabels.existingLabelsList.find("h3[languageName='" + languageName + "']").remove();
}
}
@ -223,6 +224,11 @@ var manageLabels = {
var compB = b["label"];
return compA < compB ? -1 : 1;
});
//Re-show the add button and the form if they were hidden before
if(availableLocalesList.length > 0 && manageLabels.showFormButtonWrapper.is(":hidden")) {
manageLabels.showFormButtonWrapper.show();
}
//Now replace dropdown with this new list
manageLabels.generateLocalesDropdown(availableLocalesList);

View file

@ -17,7 +17,10 @@
<#assign submissionErrors = editSubmission.validationErrors/>
<#assign submissionErrorsExist = "true" />
</#if>
<#assign availableLocalesNumber = 0/>
<#if editConfiguration.pageData.selectLocale?has_content>
<#assign availableLocalesNumber = editConfiguration.pageData.selectLocale?size />
</#if>
<#if editConfiguration.pageData.subjectName?? >
<h2>${i18n().manage_labels_for} ${editConfiguration.pageData.subjectName}</h2>
<#else>
@ -83,7 +86,8 @@ var customFormData = {
processingUrl: '${urls.base}/edit/primitiveRdfEdit',
individualUri: '${subjectUri!}',
submissionErrorsExist: '${submissionErrorsExist}',
selectLocalesFullList: selectLocalesFullList
selectLocalesFullList: selectLocalesFullList,
numberAvailableLocales:${availableLocalesNumber}
};
var i18nStrings = {
errorProcessingLabels: '${i18n().error_processing_labels}',

View file

@ -214,12 +214,10 @@ name will be used as the label. -->
<#local label = individual.nameStatement>
${label.value}
<#if (labelCount > 1) && editable >
<#-- Changing this so that manage labels now goes to generator -->
<#-- Manage labels now goes to generator -->
<span class="inline">
<#--Previous link which went to manage labels controller-->
<#--a id="manageLabels" href="${urls.base}/manageLabels?subjectUri=${individual.uri!}"-->
<a class="add-label" href="${urls.base}/editRequestDispatch?subjectUri=${individual.uri!}&editForm=edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageLabelsForIndividualGenerator&predicateUri=${labelPropertyUri}"
title="${i18n().manage_list_of} labels">
title="${i18n().manage_list_of_labels}">
<img class="add-individual" src="${urls.images}/individual/manage-icon.png" alt="${i18n().manage}" /></a>
</span>
<#else>