Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions geocatbridge/servers/models/geonetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class GeonetworkAuthError(Exception):
class GeonetworkServer(MetaCatalogServerBase):
profile: GeoNetworkProfiles = GeoNetworkProfiles.DEFAULT
node: str = "srv"
group: str = ""
assignCat: str = ""
transform: str = ""

def __init__(self, name, authid="", url="", **options):
"""
Expand All @@ -57,6 +60,9 @@ def __init__(self, name, authid="", url="", **options):
:param url: GeoNetwork base URL
:param profile: GeoNetwork metadata profile type (optional)
:param node: GeoNetwork node name (default = srv)
:param group: GeoNetwork group id (optional)
:param assignCat: Assign to Current Catalogue (optional)
:param transform: Apply named xslt transformation (optional)
"""

super().__init__(name, authid, url, **options)
Expand Down Expand Up @@ -141,6 +147,9 @@ def publishMetadata(self, metadata):
with open(metadata, "rb") as f:
files = {
'uuidProcessing': (None, 'OVERWRITE', 'text/plain'),
'group': (None, self.group, 'text/plain'),
'assignToCatalog': (None, self.assignCat, 'text/plain'),
'transformWith': (None, self.transform, 'text/plain'),
Comment on lines +150 to +152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ByronCinNZ does this work properly when one or more of these values are an empty string?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works fine

'file': (path.basename(metadata), f, 'application/octet-stream')
}
result = self.sessionRequest(url, "post", files=files, headers=headers)
Expand Down
17 changes: 15 additions & 2 deletions geocatbridge/servers/views/geonetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from geocatbridge.servers.bases import ServerWidgetBase
from geocatbridge.servers.models.gn_profile import GeoNetworkProfiles
from geocatbridge.utils import gui
from PyQt5.QtWidgets import *

WIDGET, BASE = gui.loadUiType(__file__)

Expand All @@ -21,6 +22,9 @@ def __init__(self, parent, server_type):
self.txtGeonetworkName.textChanged.connect(self.setDirty)
self.txtGeonetworkNode.textChanged.connect(self.setDirty)
self.txtGeonetworkUrl.textChanged.connect(self.setDirty)
self.txtGeonetworkGroup.textChanged.connect(self.setDirty)
self.txtGeonetworkAssignToCat.textChanged.connect(self.setDirty)
self.txtGeonetworkTransformWith.textChanged.connect(self.setDirty)

self.populateProfileCombo()
self.comboMetadataProfile.currentIndexChanged.connect(self.setDirty)
Expand All @@ -38,13 +42,15 @@ def createServerInstance(self):
raise RuntimeError(f'missing {self.serverType.getLabel()} name')
if not url:
raise RuntimeError(f'missing {self.serverType.getLabel()} URL')

return self.serverType(
name=name,
authid=self.geonetworkAuth.configId() or None,
url=url,
# profile=self.comboMetadataProfile.currentIndex(),
node=self.txtGeonetworkNode.text().strip() or 'srv'
node=self.txtGeonetworkNode.text().strip() or 'srv',
group=self.txtGeonetworkGroup.text().strip(),
assignCat=self.txtGeonetworkAssignToCat.text().strip(),
transform=self.txtGeonetworkTransformWith.text().strip()
)
except Exception as e:
self.parent.logError(f"Failed to create {self.serverType.getLabel()} instance: {e}")
Expand All @@ -55,6 +61,9 @@ def newFromName(self, name: str):
self.txtGeonetworkName.setText(name)
self.txtGeonetworkUrl.clear()
self.txtGeonetworkNode.clear()
self.txtGeonetworkGroup.clear()
self.txtGeonetworkAssignToCat.clear()
self.txtGeonetworkTransformWith.clear()
self.geonetworkAuth.setConfigId(None)

# Reset profile combobox
Expand All @@ -66,6 +75,10 @@ def loadFromInstance(self, server):
""" Populates the form fields with the values from the given server instance. """
self.txtGeonetworkName.setText(server.serverName)
self.txtGeonetworkUrl.setText(server.baseUrl)
self.txtGeonetworkNode.setText(server.node)
self.txtGeonetworkGroup.setText(server.group)
self.txtGeonetworkAssignToCat.setText(server.assignCat)
self.txtGeonetworkTransformWith.setText(server.transform)
self.geonetworkAuth.setConfigId(server.authId)

# Reset profile combobox
Expand Down
54 changes: 54 additions & 0 deletions geocatbridge/servers/views/geonetwork.ui
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,57 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_33">
<property name="text">
<string>Group</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="txtGeonetworkGroup">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Group Id</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>Assign to current Catalogue</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather long imho. Need to clone your PR and see if the UI still looks okay...
Either way, I'd prefer a lowercase "c" for "catalogue". Also not sure about the British English spelling (consistency)...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, since this is a boolean, we should perhaps turn this into a radio button or something 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

British spelling seems to dominate but not always.

</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="txtGeonetworkAssignToCat">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_37">
<property name="text">
<string>Transform with</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer Transformation as a label here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree - transformation is a better label

</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="txtGeonetworkTransformWith">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking of adding a dropdown here with all the available options for a more user-friendly experience. But this will do for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of a dropdown

<property name="text">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
Expand All @@ -140,6 +191,9 @@
<tabstop>txtGeonetworkName</tabstop>
<tabstop>txtGeonetworkUrl</tabstop>
<tabstop>txtGeonetworkNode</tabstop>
<tabstop>txtGeonetworkGroup</tabstop>
<tabstop>txtGeonetworkAssignToCat</tabstop>
<tabstop>txtGeonetworkTransformWith</tabstop>
<tabstop>geonetworkAuthWidget</tabstop>
<tabstop>comboMetadataProfile</tabstop>
</tabstops>
Expand Down