From 15e5bc9f8d7bcd7941417b9a0da92d478860b32e Mon Sep 17 00:00:00 2001 From: Markus Schwarz Date: Wed, 26 May 2021 09:53:48 +0200 Subject: [PATCH 1/4] Improved documentation of predefined Metatdata-fields --- .../Options/Settings/ReportingSettings.xml | 40 +++++++++++++++++++ documentation/Configuration.md | 1 + 2 files changed, 41 insertions(+) diff --git a/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml b/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml index 374b3d3..fb07698 100644 --- a/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml +++ b/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml @@ -3,6 +3,46 @@ en-US +
+
CLICK ME, to read the list of the default 'cvsHeaders' you can use without a 'csvProperties'-Mapping
+Id                      => Integer.toString(IdHelper.parseContentId(content.getId()))
+Name                    => content.getName()
+Path                    => content.getPath()
+URL                     => linkFormatter.formatLink(contentBean, null, request, response, false)
+Type                    => content.getType().getName()
+CreationDate            => content.getCreationDate()
+CreatedBy               => content.getCreator().getName()
+LastModificationDate    => content.getModificationDate()
+LastModifiedBy          => content.getModifier().getName()
+VersionStatus           => see below
+PublicationDate         => contentRepository.getPublicationService().getPublicationDate(content)
+
+protected String getContentVersionStatusString(Content content) {
+  PublicationService publicationService = contentRepository.getPublicationService();
+  String status = "";
+  if (content.isCheckedOut()) {
+    status = "Checked Out";
+  } else {
+    Version version = content.getWorkingVersion();
+    if (version == null) {
+      version = content.getCheckedInVersion();
+    }
+    if (version != null) {
+      status = "Checked In";
+      if (publicationService.isApproved(version)) {
+        status = "Approved";
+      }
+      if (publicationService.isPublished(version)) {
+        status = "Published";
+      }
+    }
+    if (publicationService.isNew(content)) {
+      status = "Created";
+    }
+  }
+  return status;
+}
+
diff --git a/documentation/Configuration.md b/documentation/Configuration.md index bea540d..e1900c0 100644 --- a/documentation/Configuration.md +++ b/documentation/Configuration.md @@ -10,6 +10,7 @@ See the “default” template for an example of how to format custom templates. To add a column to the CSV exporter output, simply add the desired header to the “csvHeaders” string list in the template. Additionally, the value in this new column will need to be configured. ### Configuring Static Properties (Metadata) Metadata for a content object must be added to a CSV record via the Java code. Each supported metadata value corresponds to a preset header value, such as "Id", "Name", or "URL." See the “populateContentMetadataFields” method in BaseCSVUtil.java for examples of how to include such properties. +For a list of all currently available metadata fields, see 'documentation' in [ReportingSettings.xml](../csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml) ### Configuring Dynamic Properties Content properties may be configured dynamically through the “csvProperties” struct in a template, which maps template headers to content properties. To add a new column, create an entry with the header as the key and the property name as the value. Properties defined in a content’s local settings may be accessed through using the "localSettings" property. This will output the entire localSettings for each content reported in Markup, which gives the flexibility to add, remove, or change localSettings for content in bulk. ### Configuring Custom Values From c462712c05438882eebcc10ec974be69eda37997 Mon Sep 17 00:00:00 2001 From: Markus Schwarz Date: Wed, 26 May 2021 10:09:38 +0200 Subject: [PATCH 2/4] Disable the FolderChooser in UploadDialog, as it is not used and confuses the user --- .../joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as | 1 + 1 file changed, 1 insertion(+) diff --git a/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as b/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as index 199a253..999863d 100644 --- a/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as +++ b/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as @@ -28,6 +28,7 @@ public class CSVImportDialogBase extends UploadDialog { public function CSVImportDialogBase(config:CSVImportDialogBase = null) { super(config); + showFolderChooser = false; // disables the FolderChooser, as it is not used and confuses the user otherwise } /** From 7b3ace513a09168df47c581d775256384af479ba Mon Sep 17 00:00:00 2001 From: Markus Schwarz Date: Wed, 26 May 2021 10:44:51 +0200 Subject: [PATCH 3/4] CSVImportResource (importcsv/uploadfile) + Removed unused HeaderParam's from importCSV() @PostMapping: @HeaderParam("site") String siteId, @HeaderParam("folderUri") String folderUri, + Introduced @RequestParam("template") CSVImportDialogBase + Fetch 'defaultImportTemplate' from /Settings/Options/Settings/ReportingSettings and put is as a request parameter in the call to importcsv/uploadfile ReportingSettings + added the newly introduced property --- .../csv/studio/CSVImportResource.java | 6 ++---- .../csv/studio/importer/CSVImportDialogBase.as | 18 ++++++++++++++---- .../Options/Settings/ReportingSettings.xml | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java b/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java index 471ad85..a7f1eef 100644 --- a/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java +++ b/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java @@ -55,7 +55,7 @@ public class CSVImportResource { /** * Import process logger. */ - private static Logger logger = LoggerFactory.getLogger(CSVImportResource.class); + private static final Logger logger = LoggerFactory.getLogger(CSVImportResource.class); /** * Sets the content repository. @@ -96,8 +96,7 @@ public void setAuthorizedGroups(List authorizedGroups) { @PostMapping(value = "importcsv/uploadfile", produces = "text/json", consumes = "multipart/form-data") - public ResponseEntity importCSV(@HeaderParam("site") String siteId, - @HeaderParam("folderUri") String folderUri, + public ResponseEntity importCSV(@RequestParam("template") String template, @RequestParam("file") MultipartFile file) throws IOException { // Check that the user is a member of the requisite group @@ -106,7 +105,6 @@ public ResponseEntity importCSV(@HeaderParam("site") String siteId, } boolean autoPublish = false; - String template = "default"; BufferedReader reader = new BufferedReader(new InputStreamReader(file.getInputStream())); CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader()); CSVParserHelper handler = new CSVParserHelper(autoPublish, contentRepository, logger); diff --git a/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as b/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as index 999863d..42951fa 100644 --- a/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as +++ b/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as @@ -1,20 +1,18 @@ package com.coremedia.csv.studio.importer { -import com.coremedia.cap.content.Content; import com.coremedia.cms.editor.sdk.upload.FileWrapper; -import com.coremedia.cms.editor.sdk.upload.UploadManager; -import com.coremedia.cms.editor.sdk.upload.UploadSettings; import com.coremedia.cms.editor.sdk.upload.dialog.FileContainer; import com.coremedia.cms.editor.sdk.upload.dialog.FileContainersObservable; import com.coremedia.cms.editor.sdk.upload.dialog.UploadDialog; import com.coremedia.cms.editor.sdk.util.MessageBoxUtil; +import com.coremedia.cms.editor.sdk.util.StudioConfigurationUtil; import com.coremedia.ui.data.ValueExpression; import com.coremedia.ui.data.ValueExpressionFactory; import com.coremedia.ui.data.error.RemoteError; import com.coremedia.ui.data.impl.RemoteService; +import com.coremedia.ui.logging.Logger; import com.coremedia.ui.util.EventUtil; import ext.Ext; - import ext.MessageBox; import ext.container.Container; @@ -22,6 +20,9 @@ import js.XMLHttpRequest; public class CSVImportDialogBase extends UploadDialog { + public static const REPORTING_SETTINGS_NAME:String = "ReportingSettings"; + public static const DEFAULT_TEMPLATE_SETTING:String = "defaultImportTemplate"; + private var fileContainers:FileContainersObservable; private var validationExpression:ValueExpression; private var uploadDropAreaDisabled:Boolean; @@ -31,6 +32,11 @@ public class CSVImportDialogBase extends UploadDialog { showFolderChooser = false; // disables the FolderChooser, as it is not used and confuses the user otherwise } + protected function getDefaultImportTemplate():String { + var configuration:* = StudioConfigurationUtil.getConfiguration(REPORTING_SETTINGS_NAME, DEFAULT_TEMPLATE_SETTING); + return (configuration == null) ? 'default' : configuration; + } + /** * Returns the value expression that enables/disables the upload button. * the status of the buttons depends on if all file panels on this dialog are valid. @@ -166,6 +172,10 @@ public class CSVImportDialogBase extends UploadDialog { formData.append('contentName', contentName); } + var defaultImportTemplate:String = getDefaultImportTemplate(); + Logger.info("Template used for import: " + defaultImportTemplate); + formData.append('template', defaultImportTemplate); + uploadRequest = new XMLHttpRequest(); uploadRequest.open('POST', url, true); diff --git a/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml b/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml index fb07698..b740b7c 100644 --- a/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml +++ b/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml @@ -3,6 +3,7 @@ en-US +default
CLICK ME, to read the list of the default 'cvsHeaders' you can use without a 'csvProperties'-Mapping
 Id                      => Integer.toString(IdHelper.parseContentId(content.getId()))

From 9f82ed64b5e5007e5b0d6d18dcc1771e847dd69a Mon Sep 17 00:00:00 2001
From: Markus Schwarz 
Date: Fri, 28 May 2021 14:10:00 +0200
Subject: [PATCH 4/4] change plugin to append mode instead of replace

---
 .../joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml b/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml
index 1a65fa2..a2c7344 100644
--- a/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml
+++ b/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml
@@ -1,6 +1,7 @@
 
 
@@ -24,7 +25,7 @@
 
     
     
-      
+