Skip to content

Commit

Permalink
support rr:joinCondition #31
Browse files Browse the repository at this point in the history
  • Loading branch information
mchlrch committed Dec 13, 2023
1 parent bbd733d commit 23dce48
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ TemplateValuedTerm:

ParentTriplesMapTerm:
'parent-map' mapping=[Mapping]
(joinConditions+=ParentTriplesMapJoinCondition)*
;

ParentTriplesMapJoinCondition:
'join' child=[Referenceable] 'with' parent=[Referenceable]
;

QualifiedName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ class RmlDialectGenerator {

def dispatch objectTermMap(ParentTriplesMapTerm it, IJoinContext jc) '''
rr:parentTriplesMap <«mapping.localId»>«jc.acquireMarker»
«FOR join : joinConditions»
rr:joinCondition [
rr:child "«join.child.valueResolved»"«jc.acquireMarker»
rr:parent "«join.parent.valueResolved»"«jc.acquireMarker»
]«jc.acquireMarker»
«ENDFOR»
'''

def termMapAnnex(ReferenceValuedTerm it, IJoinContext jc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import com.zazuko.rdfmapping.dsl.rdfMapping.Mapping;
import com.zazuko.rdfmapping.dsl.rdfMapping.MultiReferenceValuedTerm;
import com.zazuko.rdfmapping.dsl.rdfMapping.ParentTriplesMapJoinCondition;
import com.zazuko.rdfmapping.dsl.rdfMapping.ParentTriplesMapTerm;
import com.zazuko.rdfmapping.dsl.rdfMapping.RdfMappingPackage;
import com.zazuko.rdfmapping.dsl.rdfMapping.ReferenceValuedTerm;
import com.zazuko.rdfmapping.dsl.rdfMapping.TemplateValuedTerm;
Expand Down Expand Up @@ -40,6 +42,16 @@ public IScope getScope(EObject context, EReference reference) {
&& reference == RdfMappingPackage.Literals.TEMPLATE_VALUED_TERM__REFERENCES) {
return scopeForReferenceables(this.rootFinder.findRoot(context, Mapping.class));

} else if (context instanceof ParentTriplesMapJoinCondition
&& reference == RdfMappingPackage.Literals.PARENT_TRIPLES_MAP_JOIN_CONDITION__CHILD) {
return scopeForReferenceables(this.rootFinder.findRoot(context, Mapping.class));

} else if (context instanceof ParentTriplesMapJoinCondition
&& reference == RdfMappingPackage.Literals.PARENT_TRIPLES_MAP_JOIN_CONDITION__PARENT) {
final ParentTriplesMapTerm term = this.rootFinder.findRoot(context, ParentTriplesMapTerm.class);
if (term !=null && term.getMapping() != null && term.getMapping().getSource() != null) {
return scopeForReferenceables(term.getMapping());
}
}
return super.getScope(context, reference);
}
Expand Down
1 change: 1 addition & 0 deletions runtime-EclipseXtext/editor-test/editortest.xrm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ map EmployeeMapping from EMPLOYEE {
// TODO uncomment next line (error is fine), code completion at end of line offers keywords
// thing.size
thing.color parent-map EmployeeMapping2; // ok for rml, r2rml
thing.color parent-map FooMapping join id with id join EMPNO with ^map; // ok for rml, r2rml. multiple joinConditions supported
// TODO 'as' must be offered by code completion (this is r2rml)
keyword.^map template "{0}" with EMPNO as Literal; // ok for rml, r2rml
// TODO uncomment next line --> error
Expand Down
15 changes: 15 additions & 0 deletions runtime-EclipseXtext/editor-test/src-gen/editortest.rml.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ PREFIX thing: <http://foobar.com/things/thing/>
]
];

rr:predicateObjectMap [
rr:predicate thing:color;
rr:objectMap [
rr:parentTriplesMap <#FooMapping>;
rr:joinCondition [
rr:child "id";
rr:parent "id";
];
rr:joinCondition [
rr:child "EMPNO";
rr:parent "map";
]
]
];

rr:predicateObjectMap [
rr:predicate employee:map;
rr:objectMap [
Expand Down

0 comments on commit 23dce48

Please sign in to comment.