Refactor AssertionDescriptor

Description

The use of AssertionDescriptor is inconsistent, and does not fit cleanly into the framework API:

1. The AssertionDescriptor constructor sets the archetype id to be new ArchetypeId("descriptor.assertion.1.0")
however when creating an instance of an assertion, this is overridden. E.g, given:
AssertionDescriptor assertion = (AssertionDescriptor) service.create("assertion.regularExpression");

The returned archetype id is "assertion.regularExpression".

2. Requires special case handling. E.g, see DescriptorHelper.getArchetypeDescriptor():
//TODO This is a work around until we resolve the current
// problem with archetyping and archetype.
if (object instanceof AssertionDescriptor) {
AssertionTypeDescriptor atDesc = service.getAssertionTypeDescriptor(
object.getName());
archId = new ArchetypeId(atDesc.getPropertyArchetype());
}

descriptor = service.getArchetypeDescriptor(archId);
if (descriptor == null) {
descriptor = getArchetypeDescriptor(
object.getArchetypeId().getShortName());
}

3. AssertionTypeDescriptor must be handled differently to other IMObjects.
These must be loaded separately, via an assertionTypes.xml file

Both AssertionDescriptor and AssertionTypeDescriptor should be like any other IMObject.
The following changes should be made:

1. AssertionDescriptor should explicitly reference an AssertionTypeDescriptor.
Currently, the getType() method returns a String representing the AssertionTypeDescriptor's name.
This is passed to the IArchetypeService.getAssertionTypeDescriptor() method
The getType() method should return the AssertionTypeDescriptor directly.

2. AssertionDescriptor.getArchetypeId() should always return the actual archetype id, not descriptor.assertion.1.0

3. assertionTypes.xml should be removed

4. Update database schema, and provide migration strategy

Environment

None

Status

Assignee

Tim Anderson

Reporter

Tim Anderson

Labels

None

Affects versions

1.1-beta-1

Priority

Minor
Configure