Java Reference
In-Depth Information
having it implemented in our model makes the script cleaner and eliminates the
need to repeat the code here, in code generation templates, and so on. The root
Topic
elements are each mapped to
RequirementGroup
elements using the fol-
lowing
toRequirementGroup()
mapping. From the updated transformation
declaration shown previously, you can see two properties used as counters to
generate group and requirement indexes.
mapping
mindmap::Topic::toRequirementGroup() :
requirements::RequirementGroup {
init
{
result
:=
object
requirements::RequirementGroup {
name :=
self
.name;
id := 'G0' +
this
.grpCtr.toString();
requirements +=
self
.subtopics.
map
toRequirement();
}
}
end
{
this
.grpCtr := grpCtr + 1;
}
}
A straightforward map of the
Topic name
attribute to the
RequirementGroup name
attribute is followed by an invocation of the
toRequirement()
mapping for each of the subtopic references. This is this final
mapping in our transformation:
mapping
mindmap::Topic::toRequirement() : requirements::Requirement {
title :=
self
.name;
children +=
self
.subtopics.
map
toRequirement();
id := 'R0' +
this
.reqCtr.toString();
version :=
object
requirements::Version {
major := 1;
};
dependencies +=
this
.dependencies->
select
(source =
self
).target.
late
resolveIn
(mindmap::Topic::toRequirement,
requirements::Requirement);
end
{
this
.reqCtr := reqCtr + 1;
}
}
The
Topic name
attribute maps to the
Requirement title
, as subtopics are
recursively mapped to child
Requirement
s. The
Requirement dependencies
reference is populated with
Requirement
objects created from
Topic
elements
that are targets of mindmap
DEPENDENCY
relationships collected earlier. We can-
not guarantee that these
Topic
elements have been already mapped to
Search WWH ::
Custom Search