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 //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 //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 VIVOCore = "http://vivoweb.org/ontology/core#";
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept"; 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 OntModel toUpdateModel = null;
private DatasetWrapperFactory dwf = null;
//Custom constructor //Custom constructor
public ConceptSparqlUpdatePreprocessor(OntModel updateModel, DatasetWrapperFactory inputDwf) { public ConceptSemanticTypesPreprocessor(OntModel updateModel) {
this.toUpdateModel = updateModel; this.toUpdateModel = updateModel;
this.dwf = inputDwf;
} }
@Override @Override
public void preprocess(Model retractionsModel, Model additionsModel, public void preprocess(Model retractionsModel, Model additionsModel,
HttpServletRequest request) { HttpServletRequest request) {
//Run a construct query against the additions model //Run a construct query against the additions model
String prefixes = "PREFIX RDFS:<" + RDFS.getURI() + "> " + String prefixes = "PREFIX rdfs:<" + RDFS.getURI() + "> " +
"PREFIX OWL:<http://www.w3.org/2002/07/owl#> " + "PREFIX owl:<http://www.w3.org/2002/07/owl#> " +
"PREFIX RDF:<" + RDF.getURI() + ">"; "PREFIX rdf:<" + RDF.getURI() + ">" +
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#>";
String constructQuery = prefixes + " CONSTRUCT { " + String constructQuery = prefixes + " CONSTRUCT { " +
"?semanticType rdf:type OWL:Class. { " + "?semanticType rdf:type owl:Class. " +
"?semanticType rdfs:subClassOf SKOS:Concept . { " + "?semanticType rdfs:subClassOf skos:Concept . " +
"?semanticType rdfs:label ?label. { " + "?semanticType rdfs:label ?label. " +
"} WHERE { " + "} WHERE { " +
"?concept rdf:type ?semanticType. { " + "?concept rdf:type ?semanticType. " +
"?semanticType rdfs:label ?label .{ " + "?semanticType rdfs:label ?label . " +
"?semanticType rdfs:subClassOf SKOS:Concept .{ " + "?semanticType rdfs:subClassOf skos:Concept . " +
"}"; "}";
//Execute construct query //Execute construct query
@ -84,13 +83,11 @@ public class ConceptSparqlUpdatePreprocessor implements ModelChangePreprocessor
DatasetWrapper w = dwf.getDatasetWrapper(); additionsModel.getLock().enterCriticalSection(Lock.READ);
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qe = null; QueryExecution qe = null;
try { try {
qe = QueryExecutionFactory.create( qe = QueryExecutionFactory.create(
query, dataset); query, additionsModel);
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting constructed model for query string " + constructQuery); log.error("Error getting constructed model for query string " + constructQuery);
@ -98,8 +95,7 @@ public class ConceptSparqlUpdatePreprocessor implements ModelChangePreprocessor
if (qe != null) { if (qe != null) {
qe.close(); qe.close();
} }
dataset.getLock().leaveCriticalSection(); additionsModel.getLock().leaveCriticalSection();
w.close();
} }
//Add constructed model to the designated update model //Add constructed model to the designated update model

View file

@ -675,6 +675,7 @@ photo = Photo
no_image = no image no_image = no image
placeholder_image = placeholder image placeholder_image = placeholder image
manage_labels = manage labels manage_labels = manage labels
manage_list_of_labels = manage list of labels
add_label = Add Label add_label = Add Label
add_label_for_language = Language 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. 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_for = Manage Labels for
manage_labels_capitalized = Manage Labels 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 processing_icon = processing
selection_in_process = Your selection is being processed. selection_in_process = Your selection is being processed.

View file

@ -32,20 +32,31 @@ var manageLabels = {
// Initial page setup. Called only at page load. // Initial page setup. Called only at page load.
initPage: function() { initPage: function() {
//disable submit until user selects a language
this.submit.attr('disabled', 'disabled'); var disableSubmit = true;
this.submit.addClass('disabledSubmit');
if(this.submissionErrorsExist == "false") { if(this.submissionErrorsExist == "false") {
//hide the form to add label //hide the form to add label
this.addLabelForm.hide(); this.addLabelForm.hide();
//the cancel in add label can be unbound until the form is visible //If the number of available locales is zero, then hide the ability to show the form as well
//this.addLabelCancel.unbind("click"); if(this.numberAvailableLocales == 0) {
manageLabels.showFormButtonWrapper.hide();
}
} else { } else {
//Display the form //Display the form
this.onShowAddForm(); 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(); 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 //clear the add form
manageLabels.clearAddForm(); manageLabels.clearAddForm();
//hide the add form //hide the add form
manageLabels.onHideAddForm(); 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() { clearAddForm:function() {
@ -179,12 +180,12 @@ var manageLabels = {
var languageName = $(selectedLink).attr("languageName"); var languageName = $(selectedLink).attr("languageName");
$(selectedLink).parent().remove(); $(selectedLink).parent().remove();
//See if there are any other remove link //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 //find if there are any other remove links for the same language
var removeLinks = manageLabels.existingLabelsList.find("a.remove[languageName='" + languageName + "']"); var removeLinks = manageLabels.existingLabelsList.find("a.remove[languageName='" + languageName + "']");
if(removeLinks.length == 0) { if(removeLinks.length == 0) {
//if there aren't any other labels for this language, also remove the heading //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"]; var compB = b["label"];
return compA < compB ? -1 : 1; 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 //Now replace dropdown with this new list
manageLabels.generateLocalesDropdown(availableLocalesList); manageLabels.generateLocalesDropdown(availableLocalesList);

View file

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

View file

@ -214,12 +214,10 @@ name will be used as the label. -->
<#local label = individual.nameStatement> <#local label = individual.nameStatement>
${label.value} ${label.value}
<#if (labelCount > 1) && editable > <#if (labelCount > 1) && editable >
<#-- Changing this so that manage labels now goes to generator --> <#-- Manage labels now goes to generator -->
<span class="inline"> <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}" <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> <img class="add-individual" src="${urls.images}/individual/manage-icon.png" alt="${i18n().manage}" /></a>
</span> </span>
<#else> <#else>