How to create Content Fragments from JSON descriptions? (AEM 6.3) - aem

I am new to AEM and need a high level understanding of this use case before diving deep into the coding specifics.
I want to programmatically create new Content Fragments using data from external authoring systems.
The content will be supplied as a zip containing both a formatted html version and a JSON file describing the structure (no styling info) plus any media assets referenced in the html/JSON.
Desired AEM functionality:
- unpack zip
- ingest assets to DAM
- create new content fragment from predefined content fragment model
- use JSON structure to complete content fragment (data will be consistent and cf model designed to suit) and reference assets in DAM
Stretch goals:
- create new experience fragments based on the new content fragment (using metadata in JSON?)
- create new draft page placing the content or experience fragment into a component
What is the best way to ingest and automate this content? Research so far suggests a workflow. I am keen to understand the more detail on how this is done and any examples available.
I will be starting with 6.3 so there are no legacy issues.

You can use the contentFragmentManager from the API.
Content Fragment Manager API

Related

What's the best way to use CSV source data in a list component?

Disclaimer: I am not an AEM developer, I'm filling in on a project, so forgive me if I am missing the obvious.
I have a page template that will contain a component that will show a list of locations, this template will be used for many city pages.
I'm trying to figure out the best way to get the content into the JCR or read it using a script from a CSV file.
Are there any out-of-the box or open source components out there that can accomplish this?
There are several ways to accomplish your task. The easy part should be rendering the information. You would usually implement a Sling model or a class extending WCMUse, access the repository via the Sling API and render the resources via Adobe HTL. The resources being rendered have to be selected of course: write a Servlet which provides an interface to the resources and use an adequate form element in the component's dialog.
The hard part consists of two parts:
Perhaps just upload the file, process the data and by using the Sling API for resource creation, you can write the data into the repo. You could also utilise the DAM for such tasks and implement a workflow.
Depending on the amount of data, you might want to save the data as JSON string as property of a node.
I hoped that helped a bit.
"Are there any out-of-the box or open source components out there that can accomplish this?"
Simple answer: NO
While there are several libraries that can help you parse CSV files, storing it in JCR depends completely on your project. The structure can be arbitrary or (in a brute force way) you can just store the CSV file as data in your node but that may not be useful.
Depending on how you plan to use the data, it may be useful and optimal to save it in a relevant hierarchy for your project.

Tableau: can a visualization be created via javascript or other language?

I am trying to create a new visualization (sheet) in a tableau online workbook via javascript API or by another language. Not by using Tableau Desktop or "manual" interaction into Tableau Online.
I know that the JS API allows me to control (filter, display, etc.) existing visualizations, and the SDK can extract data and publish, but my need is to "create" a new visualization into an existing workbook.
Is there a way to do this?
The only methods of creating Tableau content that I'm aware of is using Tableau Desktop or Web authoring of something that is already published.
I explain how to do what you're asking on the blog post linked below. You can use Python with Jinja2.
The basics ...
Create a template of your XML.
Put in the necessary Jinja2 templating language code into your template as placeholders for the data and XML that needs to be rendered by Jinja2. You can render data conditionally as well.
Create a CSV file that specifies what the Python program needs to know to create your workbooks.
Run your Python application to generate a TWB file based on your template and input file. You can also easily create TWBX by zipping the TWB and data together.
The link gives code examples and an example CSV file for specifying your input.
https://www.linkedin.com/pulse/create-tableau-visualizations-programmatically-allan-thompson

Add custom metadata fields for DAM assets in a particular folder

I created custom metadata fields for DAM Assets in CQ 5.6.1 using the steps detailed here. However, as described in the document, these changed fields are available for ALL assets in the DAM.
I need these metadata fields to be made available to only a specific folder, say /content/dam/foo instead of every asset.
How can I achieve this?
In my knowledge, there is no straight forward way to achieve this but there is one trick to handle this.
AEM DAM has the notion of meta schema editors. These editors are tied to asset file type, meaning - jpeg, mov, etc. For an asset MIME type, you can define the meta data and its associated form.
AEM 6.0 provides choral UI interface to achieve this --
http://localhost:4502/libs/dam/gui/content/metadataschemaeditor/schemalist.html/dam/content/schemaeditors/forms
Am not aware of any such interface in AEM 5.6.1. The nodes tied to this are at /libs/dam/content/asseteditors/image/jpeg/formitems. You could overlay them at /apps to add the required metadata.
Coming to the question, the trick is to add the file type into your dam content hierarchy. Example - /content/dam/jpeg/foo, /content/dam/png/foo, etc. This way, you would get different metadata for different folders of the dam.
Adobe recommends this approach as AEM 6.0 introduced the concept of processing profiles which you could attach to folders. This way, your different file types could get different treatments.

Editing a PDF with MuPDF

I am using mupdf to render PDFs in my c++ application but I also need to edit PDFs (inserting a picture for example) but I cannot for the life of my figure out how - it's not documented very well. Ghostscript says that there is an API in mupdf to modify PDFs here http://www.ghostscript.com/MuPDF.html.
Ultimately I am hoping to be able to edit PDFs using MuPDF rather than using another library.
Any help would be appreciated, thanks!
The modification API in MuPDF is for editing the structure of a PDF (such as reordering pages, adding or removing annotations, etc) at a fairly low level. The graphics in PDF are based on a "content stream" object containing the commands for drawing a page using a subset of PostScript. There are no functions for editing these graphics content streams in MuPDF.
However, if all you want to do is add an image on top of the page, you can do so by creating an annotation object for the page. You'll need to create the PDF dictionary objects for the annotation, an image object, an appearance stream to draw the image object, and hook them up to the page. You'll need a good understanding of the PDF format to do this though.
You'll want to use the latest git checkout of MuPDF since we've recently (post 1.0 release) added some convenient functions for editing objects and updating streams with new content.

Uploading an image in Zend Framework

I am new in Zend Framework and learning it. I want to upload image into my database and display that image in view page. I search lots of tutorial but no step by step guidance. Want a help. Thanks in advance.
You need to take a look on Zend_Form_Element_File in Zend documentation:
The File form element provides a mechanism for supplying file upload
fields to your form. It utilizes Zend_File_Transfer internally to
provide this functionality, and the FormFile view helper as also the
File decorator to display the form element. By default, it uses the
Http transfer adapter, which introspects the $_FILES array and allows
you to attach validators and filters. Validators and filters attached
to the form element are in turn attached to the transfer adapter.
Database side, you need to use a BLOB type to hold your image (I assume you're using MySQL).
However, note that best practices are to store the image path in the database instead of the image itself.
At last, there are tons of tutorials out there that explains precisely how to do what you're looking for, you just need to look for "file upload using zend element file" and you will find them!