changeset 2297:c8cc875d271c

Import config: Marshalling of so properties got lost somehow.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 18 Feb 2019 11:57:10 +0100
parents da6611071a58
children 6f56a43b3bb2
files pkg/models/importbase.go pkg/models/imports.go
diffstat 2 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/models/importbase.go	Mon Feb 18 11:22:31 2019 +0100
+++ b/pkg/models/importbase.go	Mon Feb 18 11:57:10 2019 +0100
@@ -151,6 +151,29 @@
 	if qct.Due != nil {
 		attrs.SetTime("due", qct.Due.Time)
 	}
+	if qct.Cron != nil {
+		attrs.Set("cron", string(*qct.Cron))
+	}
+	return nil
+}
+
+func (qct *QueueConfigurationType) UnmarshalAttributes(attrs common.Attributes) error {
+	if err := qct.EmailType.UnmarshalAttributes(attrs); err != nil {
+		return err
+	}
+	if trys, found := attrs.Int("trys"); found {
+		qct.Trys = &trys
+	}
+	if duration, found := attrs.Duration("wait-retry"); found {
+		qct.WaitRetry = &ConfigDuration{duration}
+	}
+	if due, found := attrs.Time("due"); found {
+		qct.Due = &ConfigTime{due}
+	}
+	if cron, found := attrs.Get("cron"); found {
+		cs := CronSpec(cron)
+		qct.Cron = &cs
+	}
 	return nil
 }
 
--- a/pkg/models/imports.go	Mon Feb 18 11:22:31 2019 +0100
+++ b/pkg/models/imports.go	Mon Feb 18 11:57:10 2019 +0100
@@ -104,11 +104,17 @@
 )
 
 func (cui *ConfigurableURLImport) MarshalAttributes(attrs common.Attributes) error {
-	return cui.URLType.MarshalAttributes(attrs)
+	if err := cui.URLType.MarshalAttributes(attrs); err != nil {
+		return err
+	}
+	return cui.QueueConfigurationType.MarshalAttributes(attrs)
 }
 
 func (cui *ConfigurableURLImport) UnmarshalAttributes(attrs common.Attributes) error {
-	return cui.URLType.UnmarshalAttributes(attrs)
+	if err := cui.URLType.UnmarshalAttributes(attrs); err != nil {
+		return err
+	}
+	return cui.QueueConfigurationType.UnmarshalAttributes(attrs)
 }
 
 func (wi *WFSImport) MarshalAttributes(attrs common.Attributes) error {