Create a new formatter
Objectives
- oversee groovy formatter mechnism
- understand handlers, matchers concepts
- create a small formatter
Exercices
- Add a new formatter that display all text information of the metadata in basic layout.
- Update previous formatter to display labels of the text fields.
- Use formatter templating system to render the handler's view
- Add styling to your formatter view.
- Create a tree for rendering elements
- Use translation of iso elements
- Use default tree styling
- Use all default view formatter elements
- Customise default formatter view
- Overload handlers methods
Corrections
Go to https://github.com/fgravin/core-geonetwork/commits/foss4g
-
Create a new formatter
-
create a new folder named 'foss4g" in /schemas/iso19139/src/main/plugin/iso19139/formatter
-
create a new groovy file in this new folder
-
text information are stored in
gco:CharacterString
-
-
Add a matcher and play with
name
andtext
properties. -
Use
handlers.fileResult
function-
view.groovy
-
elem.html
-
-
Add a custom less file in wro4j inspected folders and link it to your formatter
-
formatter.less
dt { width: 230px; font-weight: normal; font-style: italic; color: #555555; clear: none; padding-left: 15px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; float: left; } dd { margin-left: 250px; border-left: 1px solid #999999; padding-left: 1em; background: #eeeeee; }
-
view.groovy
-
-
Use
fmt-repeat-only-children
in template andprent()
function.-
view.groovy
-
elem.html
-
-
See
nodeLabel
function-
view.groovy
-
-
Add
gn-metadata-view
class to your container update your handler.-
view.groovy
handlers.start { '''<div class="gn-metadata-view container">''' } handlers.end { '</div>' } def isoHandlers = new iso19139.Handlers(handlers, f, env) handlers.add select: isoHandlers.matchers.isTextEl, isoHandlers.isoTextEl handlers.add name: 'Container Elements', select: isoHandlers.matchers.isContainerEl, priority: -1, isoHandlers.commonHandlers.entryEl(f.&nodeLabel, isoHandlers.addPackageViewClass) isoHandlers.addExtentHandlers()
-
-
See
SummaryFactory
class.-
view.groovy
-
-
Add custom option to the
SummaryFactory
-
view.groovy
import iso19139.SummaryFactory def isoHandlers = new iso19139.Handlers(handlers, f, env) def factory = new SummaryFactory(isoHandlers, {summary -> summary.title = "My Title" summary.addCompleteNavItem = false summary.addOverviewNavItem = false summary.associated.clear() }) handlers.add name: "Summary Handler", select: {it.parent() is it.parent()}, {factory.create(it).getResult()} isoHandlers.addDefaultHandlers()
-
-
Add custom behavior to
iso19139.Handlers
constructor-
view.groovy
-