Sunday, July 11, 2010

Exploring new features in 1.9.0

This post is dedicated for those of you who are already using Sculptor and would like to have a quick overview of some selected features in the release. I will not bring up bug fixes and all improvements. Please refer to the complete list in issue tracker for that.

I have written a separate teaser about the MongoDB and EDA features of the new release.

Generated Documentation

In the model you can write documentation as a quoted string in front of almost every element (attribute, reference, entity, operation, ...). From the model Sculptor generates HTML documentation of all domain objects including their attributes and associations. Documentation of Services are also included. The generated result is located in src/generated/resources/DomainModelDoc.html

Improved Graphviz Visualization

Several diagrams with different focus and level of detail are generated. They are also included in the generated documentation. Samples here. There is a new maven plugin fornax-graphviz-m2-plugin that generates images (.png) from the .dot files.

Syntax Diagrams

We have mainly focused on sample based documentation. Some users have asked for more formal syntax description of the DSL. We have created railroad syntax diagrams.

Aggregate Syntax

Aggregates can now be defined with the new belongsTo keyword. It is more informative than the previous !aggregateRoot.


Entity Cargo {
- TrackingId trackingId key
- Location origin required
- Location destination required
- Itinerary itinerary nullable inverse opposite cargo
}

ValueObject Itinerary {
belongsTo Cargo
not optimisticLocking
not immutable
- Cargo cargo nullable opposite itinerary
- List legs inverse
}

"An itinerary consists of one or more legs."
ValueObject Leg {
belongsTo Cargo
- CarrierMovement carrierMovement;
- Location from;
- Location ^to;
}


Nullable in key

It is now allowed to have some nullable fields as part a composite natural key.


ValueObject HandlingEvent {
- Type type key
- CarrierMovement carrierMovement nullable key
- Location location key
DateTime completionTime key
DateTime registrationTime
- Cargo cargo key opposite events
}


ToStringStyle

We are using commons-lang for toString of domain objects. It has a style parameter, which is now possible to define in sculptor-generator.properties. You can choose between several styles. I like this format:

toStringStyle=SHORT_PREFIX_STYLE


You can also override this for individual DomainObject with hint:

ValueObject Foo {
hint="toStringStyle=MULTI_LINE_STYLE"
String aaa
String bbb
}


databaseJoinTable

It is possible to define many-to-many join table with databaseJoinTable and its columns with databaseColumn at both sides of the bidirectional association:

- Set<@Media> existsInMedia opposite mediaCharacters
databaseJoinTable="MED_CHR" databaseColumn="CHR"


BTW opposite doesn't have to be defined last any more.

Those keywords are also useful for unidirectional to-many associations. Additionally databaseJoinColumn is used, since there is no opposite side to define the column on.

- Set<@Person> playedBy databaseJoinTable="CHR_PERS"
databaseColumn="PERS" databaseJoinColumn="CHR"


Clob/Blob

Clob and Blob are now supported with default java types String and byte[]. They are mapped with JPA @Lob.

GUI with Not Persistent Value Objects

The structure of the persistent domain model might not always match the presentation, for example you might want a dialog for editing several domain objects in one single screen. Then you can create a non-persistent ValueObject with a corresponding Service. The application service handles the transformation between the presentation object and the persistent domain objects. More documentation and sample is available here.

No comments:

Post a Comment