www.aomodeling.org

Download Report

Transcript www.aomodeling.org

Introducing Asset Oriented
Modeling and KLEEN
bdaum industrial communications
What is AOM?
Advantages of AOM
The KLEEN modeler
Current status and outlook
bdaum industrial communications
Asset Oriented Modeling
Rationale
Concepts that differentiate AOM from ERM
Higher order relationships
Regular sets and regular grammars
Keys
Inheritance
Pluggable Model Components
Namespaces
Summary
bdaum industrial communications
Rationale
Entity-Relationship Modeling is too clumsy for
todays complex data models (XML, SQL1999).
There is always a design dilemma (what is an
entity, what a relationship).
UML leans towards a specific data model (objectoriented) and is far too complex for conceptual
modeling. Okay for OO-implementation models but
lacks essential concepts (keys) for database modeling.
bdaum industrial communications
Binary relationships
Binary relationships are the most common type of
relationship.
orders
Customer
bdaum industrial communications
Product
N-ary relationships
Generally n-ary relationships cannot be replaced
by binary relationships.
Tutor
teaches
Student
bdaum industrial communications
Course
Unary relationships
Unary relationships are usually used to describe a
containment.
Order
Orderline
bdaum industrial communications
0-ary relationships
0-ary relationship = entity
Order
bdaum industrial communications
Assets
Assets are generalized relationships
They serve as both entity and relationship
bdaum industrial communications
Arcs and Clusters
Arcs provide the necessary connectors for
relationship assets.
Clusters describe alternatives
bdaum industrial communications
Level 2 Structures
L2S may be used to group assets
L2S act only as named boundaries
Much weaker construct than assets
Each L2S is identified by a mandatory
identifying asset.
bdaum industrial communications
Applying AOM
Real World
AOM
Scenario
Model
L2S
Business Object
asset
bdaum industrial communications
Asset
AOM Container Hierarchy
Models may include other models
Level2 containers may be nested
Assets cannot be nested
Properties may be nested
Model
Level2
Asset
Property
bdaum industrial communications
The model
bdaum industrial communications
Grammars
Assets, clusters and arcs constitute a grammar
Asset names act as non-terminal symbols
Asset labels act as terminal symbols and
determine the names of asset instances
bdaum industrial communications
Abstract Assets
Assets without label have instances with the same
name as the asset.
Assets with grayed-out labels are abstract and
don't have instances.
• Abstract assets are
typically used for type
declarations or as
super-assets.
bdaum industrial communications
Properties
• Properties can be nested:
name(first,middle?,last)
• Sequences, bags, alternatives
meeting(time&location)
order(product|service)
Repetitions
account*, phone-no[1..4], address+
• Recursions
label{part(id,description,label*)}
bdaum industrial communications
Properties vs. Assets
Assets are first class citizens
Assets may specify a namespace – properties not
Assets may specify keys – properties not
Assets may specify operations – properties not
bdaum industrial communications
Keys
Each asset may have one or several primary keys.
Keys may be named.
Each key is constituted from one or several key
fields.
Simple key fields refer to asset properties.
Delegated key fields refer to key names in related
assets.
bdaum industrial communications
Inheritance
Assets may inherit features (properties, keys,
constraints, operations, annotations) from other
assets.
bdaum industrial communications
Simple types
Pluggable type systems
Multi type system models
Type systems are declared on model level and
identified via a prefix
bdaum industrial communications
Complex types
Assets can serve as type definitions
bdaum industrial communications
Complex type expressions
Complex type expressions:
union, sequence, repetition.
bdaum industrial communications
Constraints
Pluggable constraint languages
Possibility to define abstract constraints
bdaum industrial communications
Operations
Operations are always abstract.
Can be constrained by a user defined vocabulary.
Can be guarded by pre- and postcondititions
(contracts) using a declared constraint language.
bdaum industrial communications
Namespaces
Each model is identified by its default namespace.
Multi-namespace models are possible by
declaring namespace prefixes.
Assets are assigned to namespaces by prefixing
the asset name.
L2S belong to the namespace of their identifying
asset.
Model merging is namespace controlled.
Namespace also identify type systems, constraint
languages, and vocabularies.
bdaum industrial communications
Namespaces and Properties
Properties are namespace neutral. They are
identified via their asset.
Consequence: Inherited properties blend into the
namespace of the inheriting asset (chameleon).
bdaum industrial communications
Implementation notes
Annotations can be used to provide hints for the
implementation of the model.
Annotations can be externalized into a separate
annotation script.
Scripts are connected to models via the models
default namespace.
External scripts allow for implementation neutral
models and for implementation variants.
bdaum industrial communications
Summary
“Everything is a relationship”
Fits tightly with relational model
Flexible models (model evolution)
Grammar based (HRG)
Fits tightly with XML schema languages
Advanced model validation
Model transformation (refactoring)
Powerful inheritance constructs
Compact and consistent models
Genuine key concept
Allows to generate highly efficient access code
Namespaces
Distributed model development, extensions
bdaum industrial communications
KLEEN
Diagram Editor
Validation
Generators
Current status
What next?
bdaum industrial communications
Diagram Editor
bdaum industrial communications
Diagram Editor - Features
Automatic layout and arc routing
Views for item features, inheritance,
dependencies
In-line editors for item features
Syntax checking
Property expressions, constraints, annotations, etc.
Assistance (automatic completion)
Property expressions, constraints, annotations, etc.
Export as PNG and SVG
bdaum industrial communications
Diagram Editor - Transformation
Explode asset
Implode asset
Resolve inheritance
Revert arc
Extract annotation script
Inheritance resolution
bdaum industrial communications
Implosion
Model merging
Composite models include other models
Nesting is possible
Included models are “alive”
bdaum industrial communications
Auditing
Systematic check for
Completeness
Consistency
Redundancy
bdaum industrial communications
Model validation
Detects structural problems
Orphans
Arc and type cycles
Contradicting constraints
Warns on best practice violation
Non PNF key usage
Offers quick fixes
A click on an error marker proposes
a fix for most urgent problem
bdaum industrial communications
Implementation validation
Pluggable validators for different implementation
targets.
Java, XML Schema, UML-XMI
Detects features not supported by the target
environment.
e.g. Type sequences or liberal use of bags for XML Schema
targets.
bdaum industrial communications
XML Schema Generator
Generates standard XML Schema
Code generation can
be controlled
via scripting:
Attribute/Element/
Any/Ignore
Default and fixed values
Mixed content
Documentation
bdaum industrial communications
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://www.corp.com"
xmlns="http://www.corp.com/orders"
xmlns:c="http://www.corp.com"
xmlns:jag="http://www.aomodeling.org/KLEEN/JavaGenerator"
xmlns:uml="http://www.aomodeling.org/KLEEN/XmiGenerator"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsg="http://www.aomodeling.org/KLEEN/XSDgenerator">
<!--Schema created by KLEEN XSD generator version 0.4.0-->
<xs:import namespace="http://www.corp.com/orders"
schemaLocation="www_corp_com_orders_TYPELIB.xsd"/>
<xs:include schemaLocation="www_corp_com_TYPELIB.xsd"/>
<!--Asset c:customer-->
<xs:element name="customer">
<xs:complexType>
<xs:choice>
<xs:sequence>
<xs:element name="name"/>
<xs:element name="customerID" type="xs:NMTOKEN"/>
</xs:sequence>
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element name="first"/>
<xs:element minOccurs="0" name="middle"/>
<xs:element name="last"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="birthDate" type="xs:date"/>
<xs:element name="customerID" type="xs:NMTOKEN"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
<xs:key name="pk__c_customer_customerID">
<xs:selector xpath="."/>
<xs:field xpath="c:customerID"/>
</xs:key>
</xs:element>
</xs:schema>
XMI Generator
Generates standard XMI 1.0
Generated code can be fed into UML modelers.
<Foundation.Core.ModelElement.name>customer</Foundation.Core.ModelElement.name>
<Foundation.Core.ModelElement.visibility xmi.value="public"/>
<Foundation.Core.ModelElement.isSpecification xmi.value="false"/>
<Foundation.Core.GeneralizableElement.isRoot xmi.value="false"/>
<Foundation.Core.GeneralizableElement.isLeaf xmi.value="false"/>
<Foundation.Core.GeneralizableElement.isAbstract xmi.value="false"/>
<Foundation.Core.Namespace.ownedElement>
<Foundation.Core.Class xmi.id="xmi.17" xmi.uuid="uuid-1b8119a-f4c6e35f47-75b2d4280b36b135d9e254f3b2e61b7f">
<Foundation.Core.ModelElement.name>c__customer</Foundation.Core.ModelElement.name>
<Foundation.Core.ModelElement.visibility xmi.value="public"/>
<Foundation.Core.ModelElement.isSpecification xmi.value="false"/>
<Foundation.Core.GeneralizableElement.isRoot xmi.value="false"/>
<Foundation.Core.GeneralizableElement.isLeaf xmi.value="false"/>
<Foundation.Core.GeneralizableElement.isAbstract xmi.value="true"/>
<Foundation.Core.Class.isActive xmi.value="false"/>
<Foundation.Core.ModelElement.namespace>
<Foundation.Core.Namespace xmi.idref="xmi.15"/>
</Foundation.Core.ModelElement.namespace>
<Foundation.Core.Classifier.feature/>
<Foundation.Core.GeneralizableElement.specialization>
<Foundation.Core.Generalization xmi.idref="xmi.21"/>
<Foundation.Core.Generalization xmi.idref="xmi.32"/>
</Foundation.Core.GeneralizableElement.specialization>
</Foundation.Core.Class>
bdaum industrial communications
Java Generator
Generates a class hierarchy mirroring the model
structure.
Produces code for marshalling/unmarshalling
Java objects to/from XML.
Compiles constraint expressions into Java.
Generates a framework for adding business logic
(AOM meets AOP!)
Scripts can control code generation:
Array/List/Map/Set
No events / Simple events / Bubbled events
Accessor methods vs. public fields
Documentation
bdaum industrial communications
Asset code
Classes represent asset types.
Subclasses extend those types and represent
assets (operations, arcs, etc.).
Inner classes implement complex properties.
Interfaces combine asset variants (clustered
inheritance!)
package www.corp.com;
import com.bdaum.aoModeling.runtime.*;
package www.corp.com.customer;
/**
* Generated with KLEEN Java Generator V.0.4.5
*/
import com.bdaum.aoModeling.runtime.*;
public interface C_customer_type extends AomValueChangedNotifier {
/**
* Method setCustomerID. Set value of property customerID
*
* @param value new element value
*/
public void setCustomerID(String _value);
/**
* Method getCustomerID. Get value of property customerID
*
* @return value of field customerID
*/
public String getCustomerID();
/**
* perform constraint validation
*/
public void validate() throws ConstraintException;
import www.corp.com.C_customer_type;
/**
* Generated with KLEEN Java Generator V.0.4.5
*/
public interface C_customer extends C_customer_type {
/**
* perform constraint validation
*/
public void validate() throws ConstraintException;
}
}
bdaum industrial communications
Type checks
Generates code for type checks into access
methods.
/**
* Method setProductNo. Set value of property productNo
*
* @param value new field value
*/
public void setProductNo(String _value) {
if (_value == null)
throw new IllegalArgumentException(
ModelMessages.getString("Argument.not_null", "productNo"));
if (!TypeCheck.isString(_value))
throw new IllegalArgumentException(
ModelMessages.getString("Argument.nonXML_characters","productNo"));
if (!TypeCheck.isNMTOKEN(_value))
throw new IllegalArgumentException(
ModelMessages.getString("Argument.invalid_type_pattern","productNo","NMTOKEN"));
productNo = _value;
}
bdaum industrial communications
Constraints and Contracts
Explicit constraints are checked on demand.
/**
* Constraint validateConstraint1: amount >= 0
* @throws com.bdaum.aoModeling.runtime.ConstraintException
*/
public void validateConstraint1() throws ConstraintException {
if (!(getAmount() >= 0))
throw new ConstraintException(
ModelMessages.getString("Constraint.violated", "amount >= 0"));
}
Contracts are checked before and after operations.
/**
* Operation deliver.
* @param _sender - the sender instance of this message
*/
public void deliver(AomObject _sender) {
assert getClient().getMerchandise().containsKey(getProduct().getProductId()) :
"Product = client/merchandise";
performOperation(OP_deliver, _sender);
}
bdaum industrial communications
Events
Three types of event notification:
none
simple
bubbled
/**
* Method setAmount. Set value of property amount
*
* @param value new field value
*/
public void setAmount(int _value) {
if (_value == amount)
return;
int oldStockedWith_amount = amount;
amount = _value;
fireIfValueChanged(this,oldStockedWith_amount,_value,PackageInterface.StockedWith_amount);
}
bdaum industrial communications
Marshalling
Instances of generated Java classes can be saved
as XML documents.
Documents comply with XSD schemata
generated by the XSD generator.
public void toXML(XmlSerializer out, String encoding, Boolean standalone)
throws IOException, IllegalArgumentException, IllegalStateException {
out.startDocument(encoding, standalone);
out.setPrefix("", PackageInterface._DEFAULT_NAMESPACE);
out.setPrefix("xsi", PackageInterface._XSI_NAMESPACE);
out.startTag(null, "Shop");
out.attribute(PackageInterface._XSI_NAMESPACE, "schemaLocation", PackageInterface._DEFAULT_NAMESPACE + " Shop.xsd");
toXML(out);
out.endTag(null, "Shop");
out.flush();
}
bdaum industrial communications
Unmarshalling
XML documents can be parsed to create new Java
objects.
Pull parser interface allows parsing from
InputStream, DOM-tree, SAX event stream, etc.
Parser resolves links across documents.
public AomObject parseXmlDocument(XmlPullParser xpp) throws XmlPullParserException, IOException {
if (xpp.getEventType() != XmlPullParser.START_DOCUMENT)
throw new XmlPullParserException(ModelMessages.getString(ErrorMessages.START_DOCUMENT_EXPECTED));
xpp.next();
ParserUtilities.verifyStartTag(xpp, "Shop", PackageInterface._DEFAULT_NAMESPACE, true);
Shop instance = new Shop();
this.parser = xpp;
instance.parseAsset(this);
parser = null;
ParserUtilities.consumeEndTag(xpp);
if (xpp.getEventType() != XmlPullParser.END_DOCUMENT)
throw new XmlPullParserException(ModelMessages.getString(ErrorMessages.END_DOCUMENT_EXPECTED, String.valueOf(xpp.getLineNumber())));
return instance;
}
bdaum industrial communications
Instrumentation
Aspects can be dynamically connected to asset
classes.
A Main class with default instrumentation is
generated.
/*--com.bdaum.aoModeling.generator.java/instrumentation operation */
public static void attachMainOperationInstrumentation() {
Aspect _aspect;
/**** Create and register main operation aspects ****/
/*--com.bdaum.aoModeling.generator.java/aspect Shop_mainOperationAspect */
_aspect = new Shop_mainOperationAspect();
//--com.bdaum.aoModeling.generator.java/point OP_$init;
Shop.attachInstrumentation(Shop.OP_$init, _aspect);
//--com.bdaum.aoModeling.generator.java/point OP_processOrders;
Shop.attachInstrumentation(Shop.OP_processOrders, _aspect);
//--com.bdaum.aoModeling.generator.java/point OP_$dispose;
Shop.attachInstrumentation(Shop.OP_$dispose, _aspect);
//--com.bdaum.aoModeling.generator.java/point;
bdaum industrial communications
Aspects
Four types of standard aspects are currently
generated:
Operation (Custom Business logic)
Logging (for debugging purposes)
XML (for xs:any elements)
Constraint (for abstract constraints)
public class Shop_mainOperationAspect extends OperationAspect {
public boolean isStatic() {
return true;
}
public boolean run(int point,int mode,Object extension,AomObject receiver,AomObject sender) {
final Shop aShop = (Shop) receiver;
switch (point) {
//--com.bdaum.aoModeling.generator.java/point OP_$init;
case Shop.OP_$init :
//TODO Implement operation Shop.OP_$init
break;
//--com.bdaum.aoModeling.generator.java/point OP_processOrders;
case Shop.OP_processOrders :
//TODO Implement operation Shop.OP_processOrders
break;
//--com.bdaum.aoModeling.generator.java/point OP_$dispose;
case Shop.OP_$dispose :
//TODO Implement operation Shop.OP_$dispose
break;
//--com.bdaum.aoModeling.generator.java/point;
}
return true;
}
}
bdaum industrial communications
Current status of KLEEN
All essentials of the core diagram editor are
implemented.
Validators for core model, Java, SQL, XML
Schema and XMI.
Generators for Java, SQL, XML Schema and
XMI. Generated applications ready to execute.
XPath constraint language.
Java, XML Schema, SQL type systems – cross
compiled to target environment.
Design patterns, usage and authoring.
bdaum industrial communications
What next?
Generators for JPA, WebServices and GUIs
Other constraint languages
(OCL?, XPath 2.0?)
Better integration into RCP-framework
And then: Process modeling?
bdaum industrial communications
Thank you
www.aoModeling.org
bdaum industrial communications