0% found this document useful (0 votes)
63 views

DEV1-Ch04-Data Anywhere Architecture

This document discusses the ATG Data Anywhere Architecture and how it provides repositories to connect to various data sources like SQL databases, LDAP directories, and file systems. It describes how repositories are used in ATG applications to store and retrieve items in a data source-independent way. It provides examples of using item lookup droplets and RQL queries to work with repositories in dynamic pages.

Uploaded by

Verma S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

DEV1-Ch04-Data Anywhere Architecture

This document discusses the ATG Data Anywhere Architecture and how it provides repositories to connect to various data sources like SQL databases, LDAP directories, and file systems. It describes how repositories are used in ATG applications to store and retrieve items in a data source-independent way. It provides examples of using item lookup droplets and RQL queries to work with repositories in dynamic pages.

Uploaded by

Verma S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Developing ATG Applications

Part I
Chapter 4 • Data Anywhere Architecture

Using ATG Repositories, Scenario PersonalizationSM


and the Dynamo Application Framework
Objectives
• After completing this chapter, you will be able to
— Understand the Data Anywhere Architecture

— Use an ItemLookupDroplet to retrieve an

item from a Repository


— Use the Repository Query Language to query

a Repository
— Use the ACC to browse and query a

Repository

4-2
ATG Data Anywhere Architecture
Overview

4-3
The Problem

Dynamusic.com

LDAP Employee
Directory newsfeed (XML)

Images
Customer Data
Song Data

4-4
The Solution

Dynamusic.com

ATG Data Anywhere Architecture


Dynamo Repositories

LDAP Employee
Directory Customer Data Song Data Images newsfeed (XML)

4-5
The ATG Data Anywhere Architecture (1)
• The ATG Data Anywhere Architecture provides
Repositories, which connect to various data
sources
— SQL relational database

— LDAP directory

— File system (XML or HTML files)

4-6
The ATG Data Anywhere Architecture (2)
• Includes
— Servlet Beans for displaying data in a page

— Form handlers for modifying data in a page

— Java API for querying, loading and storing

data

4-7
Why the Data Anywhere Architecture?

ATG DAA JDO EJB JDBC


Data Source
Independence √ √ *
Schema Independence √ √ √
Object Mapping √ √ √
No Java Coding √
Application Server
Portability √ √ √ √
Transaction Control √ √
Searching √
Intelligent Caching √ * *
Access Control √ √
4-8
Where are Repositories Used?
• The ATG product suite uses repositories
extensively
• Some out of the box repositories include:
— Profile Repository (SQL or LDAP)

— Content Repositories (SQL or files)

— Commerce Repositories (Product Catalogs,

etc.)

4-9
Repository Architecture

4-10
Dynamusic.com Repositories

/atg
/dynamusic/ /userprofiling/ /dynamusic/
SongsRepository ProfileAdapterRe EventsRepository
pository

Albums
Venues
Users
Artists
Concerts
Songs Playlists

4-11
Repository Items (1)
RepositoryItem
id
title
album

artist
songList
...
Songs
Albums
Reposi
RepositoryItem tory Artists

id
Songs
artist
name
description
photoURL
...
4-12
Repository Items (2)
• Each RepositoryItem has
— a repositoryId property

— zero or more other properties as specified by

the Item Descriptor

Item Descriptor repositoryId


RepositoryItem
implementation type: album id
class properties:
title
=
id (String)
repositoryId

itemDescriptor
+ title (String)
artist (artist)
album artist

songList (song[]) songList

4-13
Item Relationships
RepositoryItem
RepositoryItem
id=200023 id=610153
title=Abbey Road title=Here Comes
songs song the Sun
album

artist downloadURL

coverURL artist

RepositoryItem
id=200194 MP3
name=The Beatles
artist
descr="The 'Fab Four'
started in Liverpool as…"

photoURL

4-14
Demo: Repositories and the ACC

4-15
Using Repositories:
Repository Servlet Beans

4-16
Using Repositories with Dynamic Pages
• The most common use of repositories is to
display and manipulate data in dynamic pages

Web Page Repository Data

• ATG includes tools for using repositories in


pages
— Dynamo Servlet Beans

— Form Handlers

4-17
Repository Servlet Beans
• When you know the item ID and want to display
the item
— ItemLookupDroplet

• When you want to query for items


— RQLQueryForEach

— RQLQueryRange

4-18
Using an Item Lookup Droplet (1)
• Create and configure new component based on
the ItemLookupDroplet class

ConcertLookup
Droplet Events
repository Repository venue

itemDescriptor = "concert" concert

id
name
concert
description
venue
artists
4-19
Using an Item Lookup Droplet (2)
• Call from a page, passing in the id parameter
<dsp:droplet name="/dynamusic/ConcertLookupDroplet">
<dsp:param name="id" param="itemId"/>
<dsp:oparam name="output">
Name: <dsp:valueof param="element.name"/> <br>
Venue: <dsp:valueof param="element.venue.name"/>
<br>
Date: <dsp:valueof param="element.date" date="MMM
dd,yyyy"/> <br>
</dsp:oparam>
<dsp:oparam name="empty">
No such concert found.
</dsp:oparam>
</dsp:droplet>
4-20
Querying a Repository

4-21
Repository Query Servlet Beans
• For cases when the id of the item(s) is unknown, the
Data Anywhere Architecture includes query Servlet
Beans
— RQLQueryForEach – displays each item found by a
query
— RQLQueryRange – displays a subset of result items
• Queries can:
— Match patterns in text
— Query through collections
— Query through complex values
— Specify the order to present the results
4-22
Using RQL Servlet Beans
• Input parameters
— repository – the repository to query

— itemDescriptor – which item type to query for

— queryRQL – a statement written in RQL specifying

the query criteria


• Output parameter
— element – the current item from the result set

• Oparam
— output – rendered once the query has been executed

— empty – rendered if no items were found that

matched

4-23
Repository Query Language (RQL)
• Textual query syntax, similar to SQL
— RQL describes conditions to match items of a

given item type


— Why RQL?

• Not specific to databases, can be used with

any supported data source


• Understands relationships between

repository items
• Higher level than SQL

4-24
RQL Statements
• RQL statements are built using the RQL syntax
around a specified item type descriptor
• Example:
— item type: song
— repository: /dynamusic/SongsRepository
— RQL statement: genre = "jazz"
means "find all song items whose genre property is
jazz"

4-25
RQL Query Conditions
• Return all items: ALL
• Comparison: =, !=, <, <=, >, >=
— Example: age > 18

• Text comparison: starts with, ends with,


contains
— Example: firstName STARTS WITH "H"
• Is Null Queries
— Example: phoneNumber IS NULL

4-26
RQL Queries with Item References
• If a property refers to another repository item,
you can drill down:
— Single value properties
address.zip starts with "02"
— Multi value properties
favoriteArtists INCLUDES ITEM (name
STARTS WITH "B")

4-27
RQL Collection Queries
• INCLUDES ANY
For example:
prefGenres INCLUDES ANY { "jazz", "blues" }
is equivalent to:
(prefGenres INCLUDES "jazz") OR
(prefGenres INCLUDES "blues")

• INCLUDES ALL
For example:
prefGenres INCLUDES ALL { "jazz", "blues" }
is equivalent to:
(prefGenres INCLUDES "jazz") AND
(prefGenres INCLUDES "blues")

4-28
Parameterized RQL Queries
• Queries have access to page parameters
— genre = :paramname
• The parameters you want to use must be in
scope when the Servlet Bean is rendered
• Parameters may be
— passed in from an enclosing page

— defined on this page explicitly

— provided by the user by filling out a form

4-29
Example: RQLQueryRange (1)

4-30
Example: RQLQueryRange (2)
1 <dsp:droplet name="/atg/dynamo/droplet/ForEach">
<dsp:param bean="Profile.prefGenres" name="array"/>
<dsp:oparam name="output">
2 <dsp:setvalue param="prefgenre" paramvalue="element"/>
<h3><dsp:valueof param="prefgenre"/> songs: </h3><ul>
<dsp:droplet name="/atg/dynamo/droplet/RQLQueryRange">
3 <dsp:param name="itemDescriptor" value="song"/>
<dsp:param name="repository"
value="/dynamusic/SongsRepository"/>
<dsp:param name="howMany" value="4"/>
4 <dsp:param name="queryRQL" value="genre = :prefgenre"/>
<dsp:oparam name="output">
<li><dsp:valueof param="element.title"/> (by
<dsp:valueof param="element.artist.name"/>)
</dsp:oparam>
</dsp:droplet>
</ul>
</dsp:oparam> genresongs.jsp
</dsp:droplet>

4-31
RQL Query and Item Lookup Together(1)

… <dsp:oparam name="output">
<li><dsp:a href="song.jsp">
<dsp:param name="itemId" param="element.id"/>
genresongs.jsp <dsp:valueof param="element.title"/> (by
<dsp:valueof param="element.artist.name"/>)
</dsp:a>
</dsp:oparam> …
4-32
RQL Query and Item Lookup Together(2)
song.jsp

<dsp:droplet name="/dynamusic/SongLookupDroplet">
<dsp:param name="id" param="itemId"/>
<dsp:oparam name="output">

Song: <dsp:valueof param="element.title"/>

</dsp:oparam>
</dsp:droplet>

4-33
Dynamic Beans:
The Magic Behind

<dsp:valueof
param="element.property">

4-34
Repository Item Properties
• How can objects of the same class have different
properties?
• The RepositoryItem class uses
— a Map to store values

— get/setPropertyValue(String

propertyName) to get and set values

RepositoryItem title Abbey Road


coverURL /images/abbeyroad.jpg
values
date 9/26/1969
album getPropertyValue() artist The Beatles
setPropertyValue()

4-35
Property Mapping (1)
• ATG normally retrieves/modifies properties by
calling the get/set methods of beans
Page.jsp
<dsp:droplet name="ForEach">
...
mycompany.someClass
<dsp:valueof param="element.someProp"/>
... String getSomeProp()

• This would not work for a RepositoryItem


Page.jsp
<dsp:droplet name="SongLookupDroplet">
atg.repository.RepositoryItem
...
<dsp:valueof param="element.title"/> String getTitle()

4-36
Property Mapping (2)
• Each Dynamic Bean class (such as
RepositoryItem) has an associated Dynamic
Property Mapper object that tells ATG how to get
and set properties
Dynamic
Property
Mapper

Page.jsp RepositoryItem
<dsp:droplet name="Repository">

<dsp:valueof param="element.title"/> getPropertyValue("title")

</dsp:droplet>

4-37
Dynamic Beans and JSTL
• JSTL "dot" notation for accessing JavaBean
properties doesn't work for Dynamic Beans

<c:out value=
"${element.title}"/>

• Use the DSP tomap tag to create a Map object


from a Dynamic Bean

<dspel:tomap var="elementMap" param="${element}"/>


<c:out value="${elementMap.title}"/>

4-38
Summary
In this chapter, you learned that
• The Data Anywhere Architecture frees the

developer from having to know about the details


of a data source; all items are returned as
RepositoryItem objects
• Item Lookup Servlet Beans retrieve items from

the repository by ID
• RQL Servlet Beans query the repository

• The Dynamic Beans facility allows Repository

Items to have variable properties

4-39
For More Information
• Repository Guide
• Page Developer's Guide
— "Dynamo Servlet Beans" appendix

4-40
Exercises
• Use the ACC the browse the Songs Repository
• Create "drill-down pages" to list artists, albums
and songs from the Songs Repository

4-41

You might also like