Introduce selves Discuss needs for getting external data: Other systems (HR for directory, feeds for news, Twitter for twitterstuff, order system for sales data) Going to discuss Three Approaches: Standard JSP/Servlet Data Module RSS Aggregator
We give our users something very simple…
… and give them a lot in return. Nicely formatted, auto-updates, microformats Explain the basic mechanics.
Code for custom control to display department list The XML-RPC client library expects any parameters to be stored into a Vector object.
Actually display the information
Tell what the data module is, its raison d'etre. "DMS for structured data"
Jan working on Advanced Data Module Example -- ready to go yet? Provide an aside on the scheduler module and how lovely it is.
1. Define new data type for Special events root path: /events Mention Silk project as source for icons 2. Show default dialog definition and dialog that results. Add field for start-date. Show updated dialog. Enter conference data. Enter birthday. Show data in JCR browser.
All ImportTarget does is provide a container for any options you want to specify. It has no logic! ImportHandler *must* be subclassed so that it actually does something.
Discuss what each of the options do cron format: this is the Java version (6 fields), not the Unix-standard version (5 fields). Warning: lockDuringImport -- can leave your database bollixed up and needing a export/import. ImportTarget: name, targetPath SimpleImportTarget: adds FileURL, ZipFileURL
Simply a data structure. This is the *entire* code. If you need to specify options that aren't already there, subclass this and add your own private fields and accessors for them.
This is mandatory for any import job Use the "parent" parameter, rather than target.targetPath(), because we may be importing into a temporary location to be moved on completion. uuids is an empty set to start with.
Be sure to use the name you defined for your data type when using the getChildren() call.
In order to bootstrap data, you must load the data module before you load your own module. Declare this in your pom.xml file.
Tell about our RSS implementation and why the RSS module is better.
Talk about ROME project a bit Mention that the module can also be used to generate RSS feeds, though that's a bit beyond the scope of this presentation.
Go to Data -> RSS Aggregators Create a new aggregator http://feeds.feedburner.com/mcmains/ruminations http://twitter.com/statuses/user_timeline/1809041.rss http://api.flickr.com/services/feeds/photos_public.gne?id=51035705089@N01&lang=en-us&format=rss_200 Use description = ^[^@]*$ to exclude Twitter replies --- Go to RSS Config, trigger fetch Show Data in JCR Browser --- Go to demo-features -> Aggregation Paragraphs -> latest-news Add a paragraph of each type to show how they work
1 Group
Boris Kraft, CTO at Magnolia International Ltd., added this to the group Magnolia
No additional modules needed, aside from whatever you use to actually fetch the data
Uses familiar techniques
Cons:
Page caching issues
Performance
At mercy of connection to data source
You have to write it all yourself!
The Data Module or "How I Learned to Stop Worrying and Love the JCR" Photo Credit: Kjunstorm
The Data Module
Info:
Data Module Docs
Footers Example
Advanced Data Module Example (?)
Requirements:
Magnolia 4.x
Scheduler Module
A Bit of Patience
Creating a New Data Type Demonstration
Import Handlers
Built on scheduler module
Provide an automated means to suck in new data
At /modules/data/config/importers
Using Import Handlers
Configuring an Import Handler
ImportTarget Code public class ImportTarget { protected String name; protected String targetPath; public void setName(String name) { this.name = name; } public void setTargetPath(String targetPath) { this.targetPath = targetPath; } public ImportTarget() { } public String getTargetPath() { return targetPath; } public String getName() { return name; } }
ImportHandler Sample
public class DateTimeImportHandler extends ImportHandler { ... protected Set doImport(ImportTarget target, Content parent, Set uuids) throws ImportException {
... String date = dateFormat.format( new Date() ); String name = "ImportedSampleData" + parent.getChildren("example").size();
// create new data node. // FYI: if the name matches existing node and "deleteExisting" is // set to true, old copy of the node will be automatically deleted. Content child = parent.createContent( name, "example" );
// set properties for newly created node NodeDataUtil.getOrCreate( child, "name").setValue(name); NodeDataUtil.getOrCreate(child, "comment").setValue("Example of data import.
Generated on " + date); NodeDataUtil.getOrCreate(child, "data").setValue(date);
parent.save();
uuids.add(child.getUUID());
... return uuids; } }
JCR Query
XPath or SQL-style
Powerful selection capabilities
Can be complicated
Additional Info:
JSR-170 Spec
Using the Node Object
<jsp:scriptlet>
final String BR = "<br/>"; HierarchyManager dataHierarchyManager =
0 comments
Post a comment