diff --git a/lib/Db/Catalog.php b/lib/Db/Catalog.php
index 14e50db8..05958101 100644
--- a/lib/Db/Catalog.php
+++ b/lib/Db/Catalog.php
@@ -9,13 +9,15 @@
class Catalog extends Entity implements JsonSerializable
{
- protected ?string $title = null;
- protected ?string $summary = null;
- protected ?string $description = null;
- protected ?string $image = null;
- protected ?string $search = null;
+ protected ?string $title = null;
+ protected ?string $summary = null;
+ protected ?string $description = null;
+ protected ?string $image = null;
+ protected ?string $search = null;
- protected bool $listed = false;
+ protected bool $listed = false;
+ protected ?string $organisation = null;
+ protected ?array $metadata = null;
public function __construct() {
$this->addType(fieldName: 'title', type: 'string');
@@ -24,6 +26,8 @@ public function __construct() {
$this->addType(fieldName: 'image', type: 'string');
$this->addType(fieldName: 'search', type: 'string');
$this->addType(fieldName: 'listed', type: 'boolean');
+ $this->addType(fieldName: 'organisation', type: 'string');
+ $this->addType(fieldName: 'metadata', type: 'json');
}
@@ -38,11 +42,17 @@ public function getJsonFields(): array
public function hydrate(array $object): self
{
+
+
+ if(isset($object['metadata']) === false) {
+ $object['metadata'] = [];
+ }
+
$jsonFields = $this->getJsonFields();
foreach($object as $key => $value) {
if (in_array($key, $jsonFields) === true && $value === []) {
- $value = null;
+ $value = [];
}
$method = 'set'.ucfirst($key);
@@ -67,6 +77,8 @@ public function jsonSerialize(): array
'image' => $this->image,
'search' => $this->search,
'listed' => $this->listed,
+ 'metadata' => $this->metadata,
+ 'organisation'=> $this->organisation,
];
diff --git a/lib/Db/Publication.php b/lib/Db/Publication.php
index 334c1dac..9ea2a93b 100644
--- a/lib/Db/Publication.php
+++ b/lib/Db/Publication.php
@@ -75,6 +75,12 @@ public function hydrate(array $object): self
$this->setAttachments(null);
$this->setOrganization(null);
$this->setData(null);
+ $this->setModified(new DateTime());
+
+
+ if(isset($object['published']) === false) {
+ $object['published'] = null;
+ }
foreach($object as $key => $value) {
if (in_array($key, $jsonFields) === true && $value === []) {
@@ -113,8 +119,8 @@ public function jsonSerialize(): array
'portal' => $this->portal,
'catalogi' => $this->catalogi,
'metaData' => $this->metaData,
- 'published' => $this->published->format('c'),
- 'modified' => $this->modified->format('c'),
+ 'published' => $this->published?->format('c'),
+ 'modified' => $this->modified?->format('c'),
'featured' => $this->featured !== null ? (bool) $this->featured : null,
'organization' => $this->organization,
'data' => $this->data,
diff --git a/lib/Migration/Version6Date20240723125106.php b/lib/Migration/Version6Date20240723125106.php
index 4e18cd45..d12ccc8d 100644
--- a/lib/Migration/Version6Date20240723125106.php
+++ b/lib/Migration/Version6Date20240723125106.php
@@ -81,15 +81,15 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]
);
$table->addColumn(name: 'organization', typeName: TYPES::JSON, options: [
- 'default' => [],
+ 'default' => 'a:0:{}',
'notnull' => false,
]);
$table->addColumn(name: 'data', typeName: TYPES::JSON, options: [
- 'default' => [],
+ 'default' => 'a:0:{}',
'notnull' => false,
]);
$table->addColumn(name: 'attachments', typeName: TYPES::JSON, options: [
- 'default' => [],
+ 'default' => 'a:0:{}',
'notnull' => false,
]);
$table->addColumn(name: 'attachment_count', typeName: TYPES::INTEGER);
diff --git a/lib/Migration/Version6Date20240808085441.php b/lib/Migration/Version6Date20240808085441.php
new file mode 100644
index 00000000..28e43b3a
--- /dev/null
+++ b/lib/Migration/Version6Date20240808085441.php
@@ -0,0 +1,77 @@
+hasTable(tableName: 'catalogi') === true) {
+ $table = $schema->getTable(tableName: 'catalogi');
+
+ if($table->hasColumn(name: 'organization') === false) {
+ $table->addColumn(
+ name: 'organization',
+ typeName: Types::STRING,
+ options: [
+ 'notNull' => false,
+ 'default' => null
+ ]);
+ }
+ if($table->hasColumn(name: 'metadata') === false) {
+ $table->addColumn(
+ name: 'metadata',
+ typeName: Types::JSON,
+ options: [
+ 'notNull' => false,
+ 'default' => 'a:0:{}'
+ ]);
+ }
+
+ }
+
+ return $schema;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure(): ISchemaWrapper $schemaClosure
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ }
+}
diff --git a/lib/Migration/Version6Date20240808092738.php b/lib/Migration/Version6Date20240808092738.php
new file mode 100644
index 00000000..e5babbe7
--- /dev/null
+++ b/lib/Migration/Version6Date20240808092738.php
@@ -0,0 +1,63 @@
+hasTable(tableName: 'publications') === true) {
+ $table = $schema->getTable(tableName: 'publications');
+
+ if($table->hasColumn(name: 'published') === true) {
+ $column = $table->getColumn(name: 'published');
+ $column->setDefault(default: null);
+ }
+
+ }
+
+ return $schema;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure(): ISchemaWrapper $schemaClosure
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ }
+}
diff --git a/lib/Migration/Version6Date20240808093230.php b/lib/Migration/Version6Date20240808093230.php
new file mode 100644
index 00000000..81e9d2bc
--- /dev/null
+++ b/lib/Migration/Version6Date20240808093230.php
@@ -0,0 +1,62 @@
+hasTable(tableName: 'publications') === true) {
+ $table = $schema->getTable(tableName: 'publications');
+
+ if($table->hasColumn(name: 'published') === true) {
+ $column = $table->getColumn(name: 'published');
+ $column->setNotnull(notnull: false);
+ }
+
+ }
+
+ return $schema;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure(): ISchemaWrapper $schemaClosure
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ }
+}
diff --git a/lib/Service/DirectoryService.php b/lib/Service/DirectoryService.php
index 75d994a1..dc47b754 100644
--- a/lib/Service/DirectoryService.php
+++ b/lib/Service/DirectoryService.php
@@ -6,6 +6,7 @@
use GuzzleHttp\Client;
use OCA\OpenCatalogi\Db\Catalog;
use OCA\OpenCatalogi\Db\CatalogMapper;
+use OCA\OpenCatalogi\Db\Listing;
use OCA\OpenCatalogi\Db\ListingMapper;
use OCP\IAppConfig;
use OCP\IURLGenerator;
@@ -52,21 +53,26 @@ public function registerToExternalDirectory (array $newDirectory = [], ?string $
if($this->config->getValueString($this->appName, 'mongoStorage') !== '1') {
- $catalogi = $this->catalogMapper->findAll();
+ $catalogi = $this->listingMapper->findAll();
} else {
$dbConfig['base_uri'] = $this->config->getValueString('opencatalogi', 'mongodbLocation');
$dbConfig['headers']['api-key'] = $this->config->getValueString('opencatalogi', 'mongodbKey');
$dbConfig['mongodbCluster'] = $this->config->getValueString('opencatalogi', 'mongodbCluster');
- $catalogi = $this->objectService->findObjects(filters: ['_schema' => 'catalog'], config: $dbConfig)['documents'];
+ $catalogi = $this->objectService->findObjects(filters: ['_schema' => 'directory'], config: $dbConfig)['documents'];
}
foreach($catalogi as $catalog) {
- if($catalog instanceof Catalog) {
+ if($catalog instanceof Listing) {
$catalog = $catalog->jsonSerialize();
}
- $directory = $this->getDirectoryEntry($catalog['id']);
- $result = $this->client->post(uri: $url, options: ['json' => $directory, 'http_errors' => false]);
+ unset($catalog['_id'], $catalog['id'], $catalog['_schema']);
+
+ if($catalog['directory'] !== $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute(routeName:"opencatalogi.directory.index"))) {
+ continue;
+ }
+
+ $result = $this->client->post(uri: $url, options: ['json' => $catalog, 'http_errors' => false]);
}
$externalDirectories = $this->fetchFromExternalDirectory(url: $url);
@@ -107,8 +113,6 @@ private function createDirectoryFromResult(array $result): ?array
$this->listingMapper->createFromArray($result);
}
- $this->registerToExternalDirectory(newDirectory: $result);
-
return $returnData;
}
diff --git a/src/views/Views.vue b/src/views/Views.vue
index 2a720c4f..4816be36 100644
--- a/src/views/Views.vue
+++ b/src/views/Views.vue
@@ -9,8 +9,7 @@ import { navigationStore, searchStore } from '../store/store.js'
-
-
+
diff --git a/src/views/catalogi/CatalogiList.vue b/src/views/catalogi/CatalogiList.vue
index c741e1c8..3f91eafe 100644
--- a/src/views/catalogi/CatalogiList.vue
+++ b/src/views/catalogi/CatalogiList.vue
@@ -23,7 +23,7 @@ import { catalogiStore, navigationStore } from '../../store/store.js'
Help
-
+
@@ -152,6 +152,10 @@ export default {
this.fetchData()
},
methods: {
+ refresh(e) {
+ e.preventDefault()
+ this.fetchData()
+ },
fetchData(search = null) {
this.loading = true
catalogiStore.refreshCatalogiList(search)
diff --git a/src/views/directory/DirectoryList.vue b/src/views/directory/DirectoryList.vue
index 8716f0eb..017aad2b 100644
--- a/src/views/directory/DirectoryList.vue
+++ b/src/views/directory/DirectoryList.vue
@@ -22,7 +22,7 @@ import { navigationStore, directoryStore } from '../../store/store.js'
Help
-
+
@@ -86,17 +86,15 @@ import { navigationStore, directoryStore } from '../../store/store.js'