updates for page management

This commit is contained in:
hjkhjk54 2012-06-22 17:56:02 +00:00
parent 7808d72eec
commit 9ca30d634a
8 changed files with 114 additions and 58 deletions

View file

@ -40,7 +40,6 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
public List<String> retrieveN3Required(int counter) {
String dataGetterVar = getDataGetterVar(counter);
String n3 = dataGetterVar + " a <" + classType + ">; \n" +
"display:queryModel " + getN3VarName("queryModel", counter) + "; \n" +
"display:saveToVar " + getN3VarName("saveToVar", counter) + "; \n" +
"display:query " + getN3VarName("query", counter) + " .";
List<String> requiredList = new ArrayList<String>();
@ -48,8 +47,13 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
return requiredList;
}
//Query model is optional
public List<String> retrieveN3Optional(int counter) {
return null;
String dataGetterVar = getDataGetterVar(counter);
String n3 = dataGetterVar + " display:queryModel " + getN3VarName("queryModel", counter) + ". ";
List<String> optionalList = new ArrayList<String>();
optionalList.add(getPrefixes() + n3);
return optionalList;
}

View file

@ -142,6 +142,8 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
//put results in page data, what key to use for results?
Map<String, Object> rmap = new HashMap<String,Object>();
//also store the variable name within which results will be returned
rmap.put("variableName", this.saveToVar);
rmap.put(this.saveToVar, results);
//This will be overridden at page level in display model if template specified there
rmap.put("bodyTemplate", defaultTemplate);

View file

@ -27,7 +27,8 @@ display:Home
a display:Page ;
display:title "Home" ;
display:urlMapping "/" ;
display:hasDataGetter display:homeDataGetter .
display:hasDataGetter display:homeDataGetter;
display:cannotDeletePage "true" .
########## Data Getter ############
@ -40,7 +41,8 @@ display:pageListPage
display:title "Pages" ;
display:urlMapping "/pageList" ;
display:requiresBodyTemplate "pageList.ftl" ;
display:hasDataGetter display:pageListData .
display:hasDataGetter display:pageListData;
display:cannotDeletePage "true" .
display:pageListData
a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>;
@ -50,13 +52,14 @@ display:pageListData
display:query """
PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?listedPageUri ?listedPageTitle ?listedPageUrlMapping ?listedPageTemplate ?listedPageMenuItem
SELECT ?listedPageUri ?listedPageTitle ?listedPageUrlMapping ?listedPageTemplate ?listedPageMenuItem ?listedPageCannotDeletePage
WHERE {
?listedPageUri a display:Page .
OPTIONAL{ ?listedPageUri display:urlMapping ?listedPageUrlMapping. }
OPTIONAL{ ?listedPageUri display:title ?listedPageTitle. }
OPTIONAL {?listedPageUri display:requiresBodyTemplate ?listedPageTemplate .}
OPTIONAL {?listedPageMenuItem display:toPage ?listedPageUri .}
OPTIONAL {?listedPageUri display:cannotDeletePage ?listedPageCannotDeletePage .}
} """ .
###Page Management and Data Getters
#Data getter type labels

View file

@ -115,7 +115,10 @@ owl:versionInfo
a owl:DatatypeProperty.
<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#htmlValue>
a owl:DatatypeProperty.
a owl:DatatypeProperty.
<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#cannotDeletePage>
a owl:DatatypeProperty.
######### Object Properties#########
###Basic

View file

@ -116,7 +116,9 @@ var pageManagementUtils = {
this.menuSection = $("section#menu");
this.submitButton = $("input#submit");
this.leftSideDiv = $("div#leftSide");
this.rightSideDiv = $("div#rightSide")
this.rightSideDiv = $("div#rightSide");
//contentDivs container where content added/existing placed
this.savedContentDivs = $("section#contentDivs");
},
initDisplay: function(){
//right side components
@ -191,7 +193,12 @@ var pageManagementUtils = {
pageManagementUtils.resetClassGroupSection();
//Clear all inputs values
pageManagementUtils.clearSourceTemplateValues();
//If adding browse classgroup, need to remove the classgroup option from the dropdown
if(selectedType == "browseClassGroup") {
pageManagementUtils.handleAddBrowseClassGroupPageContent();
}
pageManagementUtils.contentTypeSelect.focus();
});
//replacing with menu management edit version which is extended with some of the logic below
@ -200,49 +207,7 @@ var pageManagementUtils = {
});
this.contentTypeSelect.change( function() {
_this = pageManagementUtils;
pageManagementUtils.clearSourceTemplateValues();
if ( _this.contentTypeSelect.val() == "browseClassGroup" ) {
pageManagementUtils.classGroupSection.show();
pageManagementUtils.fixedHTMLSection.hide();
pageManagementUtils.sparqlQuerySection.hide();
pageManagementUtils.moreContentButton.hide();
pageManagementUtils.headerBar.text("Browse Class Group - ");
pageManagementUtils.headerBar.show();
}
if ( _this.contentTypeSelect.val() == "fixedHtml" || _this.contentTypeSelect.val() == "sparqlQuery" ) {
pageManagementUtils.classGroupSection.hide();
//if fixed html show that, otherwise show sparq
if ( _this.contentTypeSelect.val() == "fixedHtml" ) {
pageManagementUtils.headerBar.text("Fixed HTML - ");
pageManagementUtils.fixedHTMLSection.show();
pageManagementUtils.sparqlQuerySection.hide();
}
else {
pageManagementUtils.headerBar.text("SPARQL Query Results - ");
pageManagementUtils.sparqlQuerySection.show();
pageManagementUtils.fixedHTMLSection.hide();
}
pageManagementUtils.headerBar.show();
//$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
pageManagementUtils.classesForClassGroup.addClass('hidden');
pageManagementUtils.moreContentButton.show();
}
if ( _this.contentTypeSelect.val() == "" ) {
pageManagementUtils.classGroupSection.hide();
pageManagementUtils.fixedHTMLSection.hide();
pageManagementUtils.sparqlQuerySection.hide();
pageManagementUtils.moreContentButton.hide();
//$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
pageManagementUtils.classesForClassGroup.addClass('hidden');
pageManagementUtils.headerBar.hide();
pageManagementUtils.headerBar.text("");
}
pageManagementUtils.adjustSaveButtonHeight();
pageManagementUtils.handleContentTypeSelect();
});
@ -252,21 +217,69 @@ var pageManagementUtils = {
if (validationError == "") {
//Create the appropriate json objects
pageManagementUtils.createPageContentForSubmission();
//return true;
//For testing, not submitting anything
//event.preventDefault();
return true;
} else{
$('#error-alert').removeClass('hidden');
$('#error-alert p').html(validationError);
//TODO: Check why scrolling appears to be a problem
$.scrollTo({ top:0, left:0}, 500)
return false;
}
});
},
//Select content type
handleContentTypeSelect:function() {
_this = pageManagementUtils;
pageManagementUtils.clearSourceTemplateValues();
if ( _this.contentTypeSelect.val() == "browseClassGroup" ) {
pageManagementUtils.classGroupSection.show();
pageManagementUtils.fixedHTMLSection.hide();
pageManagementUtils.sparqlQuerySection.hide();
pageManagementUtils.moreContentButton.hide();
pageManagementUtils.headerBar.text("Browse Class Group - ");
pageManagementUtils.headerBar.show();
}
if ( _this.contentTypeSelect.val() == "fixedHtml" || _this.contentTypeSelect.val() == "sparqlQuery" ) {
pageManagementUtils.classGroupSection.hide();
//if fixed html show that, otherwise show sparql results
if ( _this.contentTypeSelect.val() == "fixedHtml" ) {
pageManagementUtils.headerBar.text("Fixed HTML - ");
pageManagementUtils.fixedHTMLSection.show();
pageManagementUtils.sparqlQuerySection.hide();
}
else {
pageManagementUtils.headerBar.text("SPARQL Query Results - ");
pageManagementUtils.sparqlQuerySection.show();
pageManagementUtils.fixedHTMLSection.hide();
}
pageManagementUtils.headerBar.show();
pageManagementUtils.classesForClassGroup.addClass('hidden');
pageManagementUtils.moreContentButton.show();
}
if ( _this.contentTypeSelect.val() == "" ) {
pageManagementUtils.classGroupSection.hide();
pageManagementUtils.fixedHTMLSection.hide();
pageManagementUtils.sparqlQuerySection.hide();
pageManagementUtils.moreContentButton.hide();
pageManagementUtils.classesForClassGroup.addClass('hidden');
pageManagementUtils.headerBar.hide();
pageManagementUtils.headerBar.text("");
}
//Collapse any divs for existing content if it exists
pageManagementUtils.collapseAllExistingContent();
//adjust save button height
pageManagementUtils.adjustSaveButtonHeight();
},
collapseAllExistingContent:function() {
var $clickableSpan = $newDivContainer.children('span#clickable' + counter);
var $innerDiv = $newDivContainer.children('div#innerContainer' + counter);
var spanArrows = pageManagementUtils.savedContentDivs.find("span.pageContentExpand div.arrow");
spanArrows.removeClass("collapseArrow");
spanArrows.addClass("expandArrow");
pageManagementUtils.savedContentDivs.find("div.pageContentContainer div.pageContentWrapper").slideUp(222);
},
//Clear values in content areas that are cloned to create the page content type specific sections
//i.e. reset sparql query/class group areas
//TODO: Check if reset is more what we need here?
@ -373,9 +386,15 @@ var pageManagementUtils = {
});
//remove button
$newRemoveButton = $innerDiv.find('input#remove' + counter);
// this will have to disable submitted fields as well as hide them.
//remove the content entirely
$newRemoveButton.click(function() {
//$innerDiv.parent("div").css("display","none");
//if content type of what is being deleted is browse class group, then
//add browse classgroup back to set of options
var contentType = $innerDiv.find("section.pageContent").attr("contentType");
if(pageManagementUtils.processDataGetterUtils.isRelatedToBrowseClassGroup(contentType)) {
pageManagementUtils.handleRemoveBrowseClassGroupPageContent();
}
//remove the section
$innerDiv.parent("div").remove();
pageManagementUtils.adjustSaveButtonHeight();
});
@ -625,6 +644,10 @@ var pageManagementUtils = {
dataGetterProcessorObject.populatePageContentSection(JSONContentObject, $newContentObj);
//Also include a hidden input with data getter URI
pageManagementUtils.includeDataGetterURI(JSONContentObject, $newContentObj);
//If content type is browseClassGroup or other 'related types' that are derived from it
if(pageManagementUtils.processDataGetterUtils.isRelatedToBrowseClassGroup(contentType)) {
pageManagementUtils.handleAddBrowseClassGroupPageContent();
}
} else {
//error condition
}
@ -648,6 +671,19 @@ var pageManagementUtils = {
dataGetterProcessor = pageManagementUtils.dataGetterProcessorMap[dataGetterType];
}
return dataGetterProcessor;
},
handleAddBrowseClassGroupPageContent:function() {
//if browse class group content has been added, then remove browse classgroup option from dropdown
if(pageManagementUtils.contentTypeSelect.find("option[value='browseClassGroup']").length > 0) {
pageManagementUtils.contentTypeSelect.find("option[value='browseClassGroup']").remove();
}
},
handleRemoveBrowseClassGroupPageContent:function() {
if(pageManagementUtils.contentTypeSelect.find("option[value='browseClassGroup']").length == 0) {
//if removed, add browse class group back
var classGroupOption = '<option value="browseClassGroup">Browse Class Group</option>';
pageManagementUtils.contentTypeSelect.find('option:eq(0)').after(classGroupGroupOption);
}
}
};

View file

@ -25,5 +25,8 @@ var processDataGetterUtils = {
}
return contentType;
},
isRelatedToBrowseClassGroup:function(contentType) {
return (contentType == "browseClassGroup" || contentType == "individualsForClasses");
}
};

View file

@ -2,8 +2,12 @@
<#--Save to variable is sparqlResults -->
<#assign resultsExist = false/>
<#if sparqlResults?has_content>
<#if variableName?has_content>
<#assign resultsExist = true/>
<#--This will retrieve the results stored in the variable name being returned from the sparql query.
For example, if "results" was specified as the variable storing the sparql results, the value
of "results" will not be assigned to "sparqlResults" below. -->
<#assign sparqlResults = .globals[variableName]/>
</#if>
<h3>Sparql Query Results</h3>

View file

@ -4,7 +4,8 @@
<label id="variableLabel" for="variable">Variable Name<span class="requiredHint"> *</span></label>
<input type="text" name="saveToVar" size="20" value="" id="saveToVar" role="input" />
<label id="queryModelLabel" for="queryModel">Query Model</label>
<input type="text" name="queryModel" size="20" value="" id="queryModel" role="input" />
<#--Hiding query model for now-->
<input type="text" name="queryModel" size="20" value="" id="queryModel" role="input" style="display:none"/>
<label id="queryLabel" for="queryLabel"><span id="querySpan">Enter SPARQL query here</span><span class="requiredHint"> *</span></label>
<textarea id="query" name="query" cols="70" rows="15" style="margin-bottom:7px"></textarea>
</section>