Closed mchlrch closed 5 years ago
Could you elaborate a bit on this issue?
If I understand it correctly, eclipse should give an error when logical source or sourcegroup is not defined for example.
Is sourcegroup a custom feature? SourceGroup is not part of the RML or R2RML spec, right?
I didn't move all the examples from the initial project over here and the airport-mapping sample doesn't show that case.
Here's an example that shows the SourceGroup
:
https://github.com/mchlrch/experimental-rmdsl/blob/master/sample-stabs/stabs-sources.xrm
SourceGroup
is the database and LogicalSource
are the tables within. The grammar allows SourceType
on both levels, so it doesn't have to be declared for every table in a database explicitly. By grammar, it's optional in both cases, so we need Custom Validation rules to check that its declared on either of those levels.
Same goes for the source
. In XML case this points to the XML-File on SourceGroup
level, whereas the iterator
would be different in the LogicalSource
s within.
https://github.com/mchlrch/experimental-rmdsl/blob/master/sample-xml/transport-mapping.xrm
The generator uses
com.zazuko.rdfmapping.dsl.generator.ModelAccess.typeResolved(LogicalSource)
to get the type from either LogicalSource
or SourceGroup
ERROR, because type
not defined:
source-group WSD_STABS_SCP_ARCHIV_DBA {
logical-source RECS_rico {
source "WSD_STABS_SCP_ARCHIV_DBA.RECS_rico"
referenceables {
P2 "RIC_P2"
}
}
}
WARNING, because type
shadowed:
source-group WSD_STABS_SCP_ARCHIV_DBA {
type rdb
logical-source RECS_rico {
type xml
source "WSD_STABS_SCP_ARCHIV_DBA.RECS_rico"
referenceables {
P2 "RIC_P2"
}
}
}
The grammer makes defining a type on SourceGroup Manadatory
SourceGroup:
source-group' name=ID '{'
'type' type=[SourceType]
('source' source=STRING)?
(logicalSources+=LogicalSource)*
'}';
This is not the wanted behaviour, right? We should change it to optional to make work the validation rules out.
Got it to work. Created a validation rule. This rule checks every logical source. First it checks whether the logical source is part of a source group. If it is part of a source group it checks whether a type is defined on the source group and than it checks for the logical source. If for neither of them a type is declared it will show an error. If for both of them a type is declared it will show a warning.
I also did this validation rule for "source" since it the construction is the same as for type.
I do not check whether the shadowed type declares the same for instance:
source-group WSD_STABS_SCP_ARCHIV_DBA {
type rdb
logical-source RECS_rico {
type rdb
source "WSD_STABS_SCP_ARCHIV_DBA.RECS_rico"
referenceables {
P2 "RIC_P2"
}
}
}
This could work, but I think it will help the user to create better mappings if they be aware of the shadowed variable.
I also changed the grammer to make the type on the sourceGroup optional. Otherwise the user is not able to define a source group without the type and define them on the child logical sources.
I do not check whether the shadowed type declares the same ... it will help the user to create better mappings if they be aware of the shadowed variable.
I agree.
I also changed the grammer to make the type on the sourceGroup optional. Otherwise the user is not able to define a source group without the type and define them on the child logical sources.
Right, that gives the user more flexibility on how to group sources.
Added unit tests for the validation rules. Wrote the tests for the scenario's discussed for both types and sources.
Could you push the unittests to the branch of https://github.com/zazuko/rdf-mapping-dsl/pull/22? To have the PR cohesive and complete and ready to merge back into master.
Could you push the unittests to the branch of #22? To have the PR cohesive and complete and ready to merge back into master.
Added
Some values can be defined on either
LogicalSource
orSourceGroup
level.ModelAccess: sourceResolved(), typeResolved()