using atlassian ual and activeobjects for rapid plugin development - atlascamp 2011
DESCRIPTION
The Atlassian Platform is full of great technologies to make your life easier. Learn how to leverage UAL and ActiveObjects as well as FishEye/Crucible's public SPI, in order to develop awesome plugins such as the new FishEye/Crucible to Bamboo integration plugin.Jason Hinch, FishEye & Crucible DeveloperTRANSCRIPT
Jason HinchDeveloper, Atlassian
Rapid Development with ActiveObjects
2
• FishEye/Crucible front-end team• Java, Python and JavaScript
• 18 months at Atlassian• Previously:
• Confluence Plugins
• Perl Development
About Me
3
• Why ActiveObjects?• What is ActiveObjects?• Getting Started• Defining an Entity• CRUD with ActiveObjects• Upgrade tasks• Testing
Agenda
4
• Bamboo data and actions from FishEye/Crucible• Commit Graph• Changeset• Review• Triggering Builds
The Idea
5
Quick Demo
6
• Fetching data from Bamboo• Dependency on External System• Large amount of data, fast
• Cache data in FishEye• Storage• Backup & Restore
The First Problem
7
• In Memory Cache• Flat Files (Java/XML/JSON serialisation)• SAL property sets• Plugin managed database
Previous Solutions
8
ActiveObjects
9
• Can refer to two different projects• ActiveObjects Library
• Atlassian ActiveObjects Framework
ActiveObjects - What?
10
• Lightweight ORM• Annotation based DDL
• Create/Read/Update/Delete (CRUD)
• Upgrades
• Built on JDK Technologies• Java Dynamic Proxies
• JDBC
ActiveObjects Library
11
• Superset of ActiveObjects Library• Plugin data in the application database• Adds support for Atlassian application lifecycle
• Backup/Restore
• SAL Transactions
• Plugin lifecycle
ActiveObjects Framework
12
• ActiveObjects Library• net.java.ao*
• http://java.net/projects/activeobjects/pages/Home
• ActiveObjects Framework• com.atlassian.activeobjects*
• https://studio.atlassian.com/wiki/display/AO
AO Library vs Framework
13
• FishEye 2.7.0 and above
• Crucible 2.7.0 and above
• JIRA 4.4 and above
Supported Products
14
• Implements Active Record Pattern• Class/Interface maps to a table
• Object instance maps to a row in the table
• Ruby on Rails, Django, CakePHP use this pattern
ActiveObjects Philosophy
15
Getting Started
16
pom.xml
17
atlassian-plugin.xml
18
Defining an Entity
19
• Interface• Extends RawEntity (or subclass)
Defining an Entity
20
Entity interface
21
RawEntity interface
22
Entity -> SQL Table
23
Entity -> SQL Table
24
25
CRUD
Create
DeleteUpdate
Read
Create
26
Read
27
Read
28
Update
29
Delete
30
Transactions
31
• Change Model between versions• Data Migration
• Upgrades already run
The Second Problem
32
• Versioned• Schema Migrations• Data population / manipulation
Upgrade Tasks
33
atlassian-plugin.xml
34
ActiveObjectsUpgradeTask
35
Importing Data
36
• Entity• Add / Remove from ao.migrate call
• Field• Add / Remove from Entity definition
Adding / Deleting
37
Renaming
38
Renaming
39
Renaming
40
Renaming
41
Renaming
42
• Test the code• Multiple Databases• More Power & Trust -> More Responsibility
Third First Problem
43
pom.xml
44
ActiveObjectsJUnitRunner
45
Initialising Data
46
• May have specific requirements
• Target all supported Databases
• Set database via a Java property• -Dao.test.database=oracle
Targeting a Database
47
• Set up ActiveObjects in your plugin• Build & evolve complex data structures• Unit test it against specific databases
Takeaways
48
• http://answers.atlassian.com• Tag with active-objects
• Twitter: @j_hinch• https://studio.atlassian.com/browse/AO
Contact Me
49
Thank you!