Skip to content

Commit

Permalink
Improvements to PyCSW Constraints and Local Mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jun 7, 2018
1 parent 30a7c9b commit e2dc1df
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 27 deletions.
44 changes: 40 additions & 4 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,34 @@ def __unicode__(self):
def get_upload_session(self):
raise NotImplementedError()

@property
def creator(self):
return self.owner.get_full_name() or self.owner.username

@property
def organizationname(self):
return self.owner.organization

@property
def restriction_code(self):
return self.restriction_code_type.gn_description

@property
def publisher(self):
return self.poc.get_full_name() or self.poc.username

@property
def contributor(self):
return self.metadata_author.get_full_name() or self.metadata_author.username

@property
def topiccategory(self):
return self.category.identifier

@property
def csw_crs(self):
return self.srid

@property
def group_name(self):
if self.group:
Expand All @@ -793,11 +821,19 @@ def bbox_string(self):
@property
def geographic_bounding_box(self):
"""BBOX is in the format: [x0,x1,y0,y1]."""
from geonode.utils import bbox_to_projection
llbbox = self.bbox[0:4]
if self.srid and 'EPSG:' in self.srid:
try:
llbbox = bbox_to_projection([float(coord) for coord in llbbox] + [self.srid, ],
target_srid=4326)
except BaseException:
pass
return bbox_to_wkt(
self.bbox_x0,
self.bbox_x1,
self.bbox_y0,
self.bbox_y1,
llbbox[0], # x0
llbbox[2], # x1
llbbox[1], # y0
llbbox[3], # y1
srid=self.srid)

@property
Expand Down
4 changes: 2 additions & 2 deletions geonode/catalogue/backends/pycsw_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
# 'loglevel': 'DEBUG',
# 'logfile': '/tmp/pycsw.log',
# 'federatedcatalogues': 'http://geo.data.gov/geoportal/csw/discovery',
# 'pretty_print': 'true',
# 'domainquerytype': 'range',
'pretty_print': 'true',
'domainquerytype': 'range',
'domaincounts': 'true',
'profiles': 'apiso,ebrim',
},
Expand Down
11 changes: 6 additions & 5 deletions geonode/catalogue/backends/pycsw_local_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@
'pycsw:Modified': 'date',
'pycsw:Type': 'csw_type',
'pycsw:BoundingBox': 'csw_wkt_geometry',
'pycsw:CRS': 'crs',
'pycsw:CRS': 'csw_crs',
'pycsw:AlternateTitle': 'alternate',
'pycsw:RevisionDate': 'date',
'pycsw:CreationDate': 'date',
'pycsw:PublicationDate': 'date',
'pycsw:OrganizationName': 'uuid',
'pycsw:Organization': 'organizationname',
'pycsw:OrganizationName': 'organizationname',
'pycsw:SecurityConstraints': 'securityconstraints',
'pycsw:ParentIdentifier': 'parentidentifier',
'pycsw:TopicCategory': 'topiccategory',
'pycsw:ResourceLanguage': 'resourcelanguage',
'pycsw:ResourceLanguage': 'language',
'pycsw:GeographicDescriptionCode': 'geodescode',
'pycsw:Denominator': 'denominator',
'pycsw:DistanceValue': 'distancevalue',
Expand All @@ -64,8 +65,8 @@
'pycsw:OperatesOnIdentifier': 'operatesonidentifier',
'pycsw:OperatesOnName': 'operatesoname',
'pycsw:Degree': 'degree',
'pycsw:AccessConstraints': 'accessconstraints',
'pycsw:OtherConstraints': 'otherconstraints',
'pycsw:AccessConstraints': 'restriction_code',
'pycsw:OtherConstraints': 'constraints_other',
'pycsw:Classification': 'classification',
'pycsw:ConditionApplyingToAccessAndUse': 'conditionapplyingtoaccessanduse',
'pycsw:Lineage': 'lineage',
Expand Down
8 changes: 4 additions & 4 deletions geonode/catalogue/templates/geonode_metadata_full.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ <h2 class="page-title">{{ resource.title }}</h2>
<dt>Extent</dt>
<dd>
<ul class="nop">
<li>long min: {{resource.bbox_x0}}</li>
<li>long max: {{resource.bbox_x1}}</li>
<li>lat min: {{resource.bbox_y0}}</li>
<li>lat max: {{resource.bbox_y1}}</li>
<li>x0: {{resource.bbox_x0}}</li>
<li>x1: {{resource.bbox_x1}}</li>
<li>y0: {{resource.bbox_y0}}</li>
<li>y1: {{resource.bbox_y1}}</li>
</ul>
</dd>

Expand Down
5 changes: 4 additions & 1 deletion geonode/catalogue/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def csw_global_dispatch(request):
for e in authorized_ids)) + ")"
authorized_layers_filter = "id IN " + authorized_layers
mdict['repository']['filter'] += " AND " + authorized_layers_filter

mdict['repository']['filter'] = "({}) OR ({})".format(mdict['repository']['filter'],
authorized_layers_filter)
else:
authorized_layers_filter = "id = -9999"
mdict['repository']['filter'] += " AND " + authorized_layers_filter
Expand Down Expand Up @@ -124,7 +127,7 @@ def csw_global_dispatch(request):
groups_ids.append(group.id)

public_groups = GroupProfile.objects.exclude(
access="private").exclude(access="public-invite").values('group')
access="private").values('group')
for group in public_groups:
if isinstance(group, dict):
if 'group' in group:
Expand Down
4 changes: 3 additions & 1 deletion geonode/contrib/metadataxsl/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#
#########################################################################

from urlparse import urljoin

from django.conf import settings
from django.core.urlresolvers import reverse
from django.db.models import signals
Expand Down Expand Up @@ -45,7 +47,7 @@ def add_xsl_link(resourcebase):

urlpath = reverse('prefix_xsl_line', args=[resourcebase.id])

url = '{}{}'.format(settings.SITEURL, urlpath)
url = urljoin(settings.SITEURL, urlpath)

link, created = Link.objects.get_or_create(
resource=resourcebase,
Expand Down
3 changes: 2 additions & 1 deletion geonode/contrib/metadataxsl/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ def prefix_xsl_line(req, id):
try:
catalogue = get_catalogue()
record = catalogue.get_record(resource.uuid)
if record:
logger.debug(record.xml)
except Exception as err:
msg = 'Could not connect to catalogue to save information for layer "%s"' % str(resource.title)
logger.warn(msg)
raise err

try:
xml = record.xml
# generate an XML document (GeoNode's default is ISO)
if resource.metadata_uploaded and resource.metadata_uploaded_preserve:
md_doc = etree.tostring(etree.fromstring(resource.metadata_xml))
Expand Down
4 changes: 2 additions & 2 deletions geonode/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ def document_metadata(
try:
all_metadata_author_groups = chain(
request.user.group_list_all(),
GroupProfile.objects.exclude(access="private").exclude(access="public-invite"))
GroupProfile.objects.exclude(access="private"))
except BaseException:
all_metadata_author_groups = GroupProfile.objects.exclude(
access="private").exclude(access="public-invite")
access="private")
[metadata_author_groups.append(item) for item in all_metadata_author_groups
if item not in metadata_author_groups]

Expand Down
4 changes: 2 additions & 2 deletions geonode/layers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,10 +1124,10 @@ def layer_metadata(
try:
all_metadata_author_groups = chain(
request.user.group_list_all().distinct(),
GroupProfile.objects.exclude(access="private").exclude(access="public-invite"))
GroupProfile.objects.exclude(access="private"))
except BaseException:
all_metadata_author_groups = GroupProfile.objects.exclude(
access="private").exclude(access="public-invite")
access="private")
[metadata_author_groups.append(item) for item in all_metadata_author_groups
if item not in metadata_author_groups]

Expand Down
4 changes: 2 additions & 2 deletions geonode/maps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ def map_metadata(
try:
all_metadata_author_groups = chain(
request.user.group_list_all(),
GroupProfile.objects.exclude(access="private").exclude(access="public-invite"))
GroupProfile.objects.exclude(access="private"))
except BaseException:
all_metadata_author_groups = GroupProfile.objects.exclude(
access="private").exclude(access="public-invite")
access="private")
[metadata_author_groups.append(item) for item in all_metadata_author_groups
if item not in metadata_author_groups]

Expand Down
6 changes: 3 additions & 3 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import sys
from datetime import timedelta
from distutils.util import strtobool
from urlparse import urlparse, urlunparse
from urlparse import urlparse, urlunparse, urljoin

import django
import dj_database_url
Expand Down Expand Up @@ -723,7 +723,7 @@
)

GEOSERVER_PUBLIC_LOCATION = os.getenv(
# 'GEOSERVER_PUBLIC_LOCATION', '{}geoserver/'.format(SITEURL)
# 'GEOSERVER_PUBLIC_LOCATION', urljoin(SITEURL, '/geoserver')
'GEOSERVER_PUBLIC_LOCATION', GEOSERVER_LOCATION
)

Expand Down Expand Up @@ -818,7 +818,7 @@
# 'ENGINE': 'geonode.catalogue.backends.generic',

# The FULLY QUALIFIED base url to the CSW instance for this GeoNode
'URL': '%scatalogue/csw' % SITEURL,
'URL': urljoin(SITEURL, '/catalogue/csw'),
# 'URL': 'http://localhost:8080/geonetwork/srv/en/csw',
# 'URL': 'http://localhost:8080/deegree-csw-demo-3.0.4/services',

Expand Down

0 comments on commit e2dc1df

Please sign in to comment.