From: <pva...@us...> - 2009-03-27 14:29:25
|
Revision: 2714 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=2714&view=rev Author: pvalsecc Date: 2009-03-27 14:29:15 +0000 (Fri, 27 Mar 2009) Log Message: ----------- - merged groups and sources into one field - fixed similarity Modified Paths: -------------- sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/geocat.js sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/searchTools.js sandbox/geocat.ch/trunk/web/geonetwork/xml/csw/filter-to-lucene.xsl sandbox/geocat.ch/trunk/web/geonetwork/xsl/geocat.xsl Modified: sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/geocat.js =================================================================== --- sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/geocat.js 2009-03-27 13:37:21 UTC (rev 2713) +++ sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/geocat.js 2009-03-27 14:29:15 UTC (rev 2714) @@ -700,20 +700,6 @@ width: '100%' },{ xtype: 'combo', - fieldLabel: "Sources", //TODO: translate - name: 'E1.0__source', - store: translate("sources"), - mode: 'local', - displayField: 'label', - valueField: 'name', - emptyText: translate('any'), - typeAhead: true, - forceSelection: true, - triggerAction: 'all', - selectOnFocus: true, - width: 95 - },{ - xtype: 'combo', fieldLabel: "Format", //TODO: translate name: 'E1.0_format', store: translate("formats"), @@ -781,21 +767,7 @@ items: what }]; - var types = [{ - xtype: 'combo', - fieldLabel: translate('group'), - name: 'E__groupOwner', - store: translate("groups"), - mode: 'local', - displayField: 'label', - valueField: 'name', - emptyText: translate('any'), - typeAhead: true, - forceSelection: true, - triggerAction: 'all', - selectOnFocus: true, - width: 95 - }, + var types = [ geocat.getTypeCombo() ]; @@ -830,7 +802,7 @@ content.push({ xtype: 'fieldset', - title: translate('type'), + title: translate('type')+'?', autoHeight: true, defaultType: 'textfield', cls: 'compressedFieldSet', @@ -965,6 +937,32 @@ } }); + content.push({ + xtype: 'fieldset', + title: translate('from')+'?', + autoHeight: true, + defaultType: 'textfield', + cls: 'compressedFieldSet', + layoutConfig: { + labelSeparator: '' + }, + items: [{ + xtype: 'combo', + fieldLabel: translate("from"), + name: 'V_', + store: translate("sources_groups"), + mode: 'local', + displayField: 'label', + valueField: 'name', + emptyText: translate('any'), + typeAhead: true, + forceSelection: true, + triggerAction: 'all', + selectOnFocus: true, + width: 95 + }] + }); + return content; }, Modified: sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/searchTools.js =================================================================== --- sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/searchTools.js 2009-03-27 13:37:21 UTC (rev 2713) +++ sandbox/geocat.ch/trunk/web/geonetwork/scripts/mapfishIntegration/searchTools.js 2009-03-27 14:29:15 UTC (rev 2714) @@ -62,6 +62,7 @@ * T: Equals with words separated by spaces that must be all present * E##: Equals with a specified similarity * G: Geometry by ID + * V: field name specified in the value, separated by a '/' with the value */ buildCSWQueryFromForm: function(method, form, startRecord, sortBy, addFilters) { var values = searchTools.getFormValues(form); @@ -91,55 +92,91 @@ }, addFiltersFromPropertyMap: function(values, filters) { + var defaultSimilarity = 0.8; + if (values['similarity'] !== null) { + defaultSimilarity = values['E_similarity']; + searchTools.addFilter(filters, 'E_similarity', defaultSimilarity, defaultSimilarity); + } + for (var key in values) { var value = values[key]; - if (value != "") { - var field = key.match("^([^_]+)_(.*)$"); - if (field) { - if (field[1] == 'S') { //starts with - filters.push(new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.LIKE, - property: field[2], - value: value + ".*" - })); - } else if (field[1] == 'C') { //contains - filters.push(new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.LIKE, - property: field[2], - value: ".*" + value + ".*" - })); - } else if (field[1].charAt(0) == 'E') { //equals - if( field[1].length > 1 ){// this means that we want to specificy the similarity - filters.push(new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.EQUAL_TO, - property: "similarity", - value: field[1].substring(1) - })); - } - filters.push(new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.EQUAL_TO, - property: field[2], - value: value - })); - } else if (field[1] == 'T') { //equals with words separated by spaces that must be all present - var splitted = value.split(" "); - for (var i=0; i<splitted.length; ++i) { - filters.push(new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.EQUAL_TO, - property: field[2], - value: splitted[i] - })); - } - } else if (field[1] == 'B') { //boolean - filters.push(new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.EQUAL_TO, - property: field[2], - value: value ? 1 : 0 - })); - } else { - alert("Cannot parse " + key); - } + if (value != "" && key != 'E_similarity') { + searchTools.addFilter(filters, key, value, defaultSimilarity); + } + } + }, + + addFilter: function(filters, key, value, defaultSimilarity) { + var field = key.match("^([^_]+)_(.*)$"); + if (field) { + if (field[1] == 'S') { //starts with + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.LIKE, + property: field[2], + value: value + ".*" + })); + } else if (field[1] == 'C') { //contains + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.LIKE, + property: field[2], + value: ".*" + value + ".*" + })); + } else if (field[1].charAt(0) == 'E') { //equals + if (field[1].length > 1) { + // this means that we want to specificy the similarity + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: "similarity", + value: field[1].substring(1) + })); } + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: field[2], + value: value + })); + if (field[1].length > 1) { + //restore to the previous similarity + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: "similarity", + value: defaultSimilarity + })); + } + } else if (field[1] == 'T') { //equals with words separated by spaces that must be all present + var splitted = value.split(" "); + for (var i = 0; i < splitted.length; ++i) { + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: field[2], + value: splitted[i] + })); + } + } else if (field[1] == 'B') { //boolean + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: field[2], + value: value ? 1 : 0 + })); + } else if (field[1] == 'V') { //field name specified in the value, separated by a '/' with the value + var subField = value.match("^([^/]+)/(.*)$"); + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: "similarity", + value: "1.0" + })); + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: subField[1], + value: subField[2] + })); + filters.push(new OpenLayers.Filter.Comparison({ + type: OpenLayers.Filter.Comparison.EQUAL_TO, + property: "similarity", + value: defaultSimilarity + })); + } else { + alert("Cannot parse " + key); } } }, @@ -154,31 +191,31 @@ buildCSWQueryPOST: function(filter, startRecord, sortBy) { - var result = '<?xml version="1.0" encoding="UTF-8"?>\n'+ - '<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" resultType="results_with_summary" startPosition="'+startRecord+'" maxRecords="'+geocat.nbResultPerPage+'">\n'+ - ' <csw:Query>\n'+ + var result = '<?xml version="1.0" encoding="UTF-8"?>\n' + + '<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" resultType="results_with_summary" startPosition="' + startRecord + '" maxRecords="' + geocat.nbResultPerPage + '">\n' + + ' <csw:Query>\n' + ' <csw:ElementSetName>full</csw:ElementSetName>\n'; if (sortBy) { var searchInfo = searchTools.sortByMappings[sortBy]; - result+= ' <ogc:SortBy xmlns:ogc="http://www.opengis.net/ogc">\n'+ - ' <ogc:SortProperty>\n'+ - ' <ogc:PropertyName>'+searchInfo.name+'</ogc:PropertyName>\n'+ - ' <ogc:SortOrder>'+searchInfo.order+'</ogc:SortOrder>\n'+ - ' </ogc:SortProperty>\n'+ - ' </ogc:SortBy>\n'; + result += ' <ogc:SortBy xmlns:ogc="http://www.opengis.net/ogc">\n' + + ' <ogc:SortProperty>\n' + + ' <ogc:PropertyName>' + searchInfo.name + '</ogc:PropertyName>\n' + + ' <ogc:SortOrder>' + searchInfo.order + '</ogc:SortOrder>\n' + + ' </ogc:SortProperty>\n' + + ' </ogc:SortBy>\n'; } if (filter) { var filterXML = new OpenLayers.Format.XML().write( new OpenLayers.Format.Filter().write(filter)); filterXML = filterXML.replace(/^<\?xml[^?]*\?>/, ""); - result+= ' <csw:Constraint version="1.1.0">\n'; - result+=filterXML; - result+= ' </csw:Constraint>\n'; + result += ' <csw:Constraint version="1.1.0">\n'; + result += filterXML; + result += ' </csw:Constraint>\n'; } - result += ' </csw:Query>\n'+ + result += ' </csw:Query>\n' + '</csw:GetRecords>'; return result; @@ -350,7 +387,7 @@ searchTools.prev_geometry = OpenLayers.Format.GML.Base.prototype.writers.feature._geometry; OpenLayers.Format.GML.Base.prototype.writers.feature._geometry = function(geometry) { - if(geometry.CLASS_NAME == "searchTools.MultiPolygonReference") { + if (geometry.CLASS_NAME == "searchTools.MultiPolygonReference") { var gml = this.createElementNS(this.namespaces.gml, "gml:MultiPolygon"); var gmlNode = this.createElementNS(this.namespaces.gml, "gml:MultiPolygon"); gmlNode.setAttribute("gml:id", geometry.id); Modified: sandbox/geocat.ch/trunk/web/geonetwork/xml/csw/filter-to-lucene.xsl =================================================================== --- sandbox/geocat.ch/trunk/web/geonetwork/xml/csw/filter-to-lucene.xsl 2009-03-27 13:37:21 UTC (rev 2713) +++ sandbox/geocat.ch/trunk/web/geonetwork/xml/csw/filter-to-lucene.xsl 2009-03-27 14:29:15 UTC (rev 2714) @@ -12,17 +12,14 @@ <xsl:variable name="sibling" select="preceding-sibling::ogc:PropertyIsEqualTo[ogc:PropertyName='similarity']" /> <xsl:variable name="currentSimilarity"> - <xsl:choose> - <xsl:when test="count($sibling) = 0"> - <xsl:value-of - select="0.8"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of - select="$sibling[count($sibling)]/ogc:Literal"/> + <xsl:choose> + <xsl:when test="count($sibling) = 0"> + <xsl:value-of select="0.8"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$sibling[count($sibling)]/ogc:Literal"/> </xsl:otherwise> - </xsl:choose> - + </xsl:choose> </xsl:variable> <xsl:choose> Modified: sandbox/geocat.ch/trunk/web/geonetwork/xsl/geocat.xsl =================================================================== --- sandbox/geocat.ch/trunk/web/geonetwork/xsl/geocat.xsl 2009-03-27 13:37:21 UTC (rev 2713) +++ sandbox/geocat.ch/trunk/web/geonetwork/xsl/geocat.xsl 2009-03-27 14:29:15 UTC (rev 2714) @@ -19,17 +19,14 @@ <xsl:template match="entry" mode="js-translations-topicCat"> ,['<xsl:value-of select="code"/>', '<xsl:value-of select="label"/>']</xsl:template> - <xsl:template match="record" mode="js-translations-sources"> - ,['<xsl:value-of select="siteid"/>', '<xsl:value-of select="name"/>']</xsl:template> + <xsl:template match="record" mode="js-translations-sources-groups"> + ,['<xsl:choose><xsl:when test="siteid">_source/<xsl:value-of select="siteid"/></xsl:when><xsl:otherwise>_groupOwner/<xsl:value-of select="id"/></xsl:otherwise></xsl:choose>', '<xsl:value-of select="name"/>']</xsl:template> <xsl:template match="record" mode="js-translations-formats"> ,['<xsl:value-of select="name"/>', '<xsl:value-of select="name"/>']</xsl:template> - <xsl:template match="record" mode="js-translations-groups"> - ,['<xsl:value-of select="id"/>', '<xsl:value-of select="name"/>']</xsl:template> + - - <xsl:template match="/"> <html> <head> @@ -51,8 +48,7 @@ 'outputTypes':[<xsl:apply-templates select="/root/gui/strings/outputType" mode="js-translations-combo"/>], 'hitsPerPageChoices':[<xsl:apply-templates select="/root/gui/strings/hitsPerPageChoice" mode="js-translations-combo"/>], 'topicCat': [['', '<xsl:value-of select="/root/gui/strings/any"/>']<xsl:apply-templates select="/root/gui/iso19139/codelist[@name='gmd:MD_TopicCategoryCode']/entry" mode="js-translations-topicCat"/>], - 'sources': [['', '<xsl:value-of select="/root/gui/strings/any"/>']<xsl:apply-templates select="/root/gui/sources/record" mode="js-translations-sources"/>], - 'groups': [['', '<xsl:value-of select="/root/gui/strings/any"/>']<xsl:apply-templates select="/root/gui/groups/record" mode="js-translations-groups"/>], + 'sources_groups': [['', '<xsl:value-of select="/root/gui/strings/any"/>']<xsl:apply-templates select="/root/gui/sources/record|/root/gui/groups/record" mode="js-translations-sources-groups"><xsl:sort select="name"/></xsl:apply-templates>], 'formats': [['', '<xsl:value-of select="/root/gui/strings/any"/>']<xsl:apply-templates select="/root/gui/formats/record" mode="js-translations-formats"/>] }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |