Skip to content

Commit

Permalink
Release final model joins showcase project (#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
haroonsherjan committed Jan 25, 2024
1 parent 4f470cb commit 6f75e6f
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 3 deletions.
77 changes: 77 additions & 0 deletions showcases/data/End-to-end examples/Integrate Mappings/code.pure
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,80 @@ Runtime com::trade::TradeRuntime
]
];
}


###Service
Service com::trade::ServiceSimpleProject
{
pattern: '/trade/simpleJoinProjectService';
owners:
[
'user1',
'user2'
];
documentation: '';
autoActivateUpdates: true;
execution: Single
{
query: |com::trade::Trade.all()->project(
[
x: com::trade::Trade[1]|$x.value,
x: com::trade::Trade[1]|$x.client.name
],
[
'Value',
'Client/Name'
]
);
mapping: com::trade::TradeWithLegalEntityMapping;
runtime: com::trade::TradeRuntime;
}
testSuites:
[
testSuite_1:
{
data:
[
connections:
[
com::trade::TradeConnection:
Relational
#{
Trade.Trade:
'id,value,ENTITY_ID_FK\n'+
'1,100,abc\n'+
'2,200,def\n';
}#,
com::trade::TradeConnection:
Relational
#{
Entity.LegalEntity:
'ENTITY_ID,name\n'+
'abc,Entity1\n'+
'def,Entity2\n';
}#
]
]
tests:
[
test_1:
{
serializationFormat: PURE_TDSOBJECT;
asserts:
[
assertion_1:
EqualToJson
#{
expected:
ExternalFormat
#{
contentType: 'application/json';
data: '[ {\n "Value" : 100,\n "Client/Name" : "Entity1"\n}, {\n "Value" : 200,\n "Client/Name" : "Entity2"\n} ]';
}#;
}#
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: Integrate Mappings
description: How to integrate your mapping with another group's model without tying yourself to their underlying physical implementation or specific mapping.
development: true
---

In this example, the producer of the LegalEntityMapping has released a mapping of LegalEntity. The consumers have created their own mapping (TradeMapping) which they would like to join against the producer mapping. In order to prevent unnecessarily tying their model to the implementation details of the producer's mapping, they include the producer's dataspace in TradeMapping. Including a dataspace rather than a mapping creates a layer of abstraction that protects the consumer and producer from unnecessary difficulty when a producer needs to migrate users onto a new mapping. Instead, the dataspace's underlying default mapping is always included behind-the-scenes by the compiler. The consumer then defines a XStore Association between their trade class and the default class mapping ID of the Legal Entity class (com_entity_LegalEntity), which is derived from the package address of the target class. This cross store join allows the consumer to tie their mapping to the target class without explicitly defining the SQL joins occurring behind the scenes. The TradeDB and EntityDB can exist independently as packageable elements without hard-coded dependencies on one another. The consumer then defines the locality of the stores within the runtime, by co-locating them underneath the same connection. With this language, the compiler can immediately understand whether to treat the XStore Associations between mappings as truly Cross-Store or Local.
2 changes: 1 addition & 1 deletion showcases/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.surefire.thread.count>3</maven.surefire.thread.count>
<showcase.projects.location>data</showcase.projects.location>
<legend.engine.version>4.35.1</legend.engine.version>
<legend.engine.version>4.37.7</legend.engine.version>

</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void runAllTests(PureModel puremodel, PureModelContextData data)
String classifierPath = classifierPathMap.get(packageableElement.getClass());
if(testableClassifiers.contains(classifierPath))
{
TestableRunner runner = new TestableRunner(new ModelManager(DeploymentMode.PROD));
TestableRunner runner = new TestableRunner();
RunTestsTestableInput runTestsTestableInput = new RunTestsTestableInput();
runTestsTestableInput.testable = packageableElement.getPath();
RunTestsResult testsResult = runner.doTests(Collections.singletonList(runTestsTestableInput), puremodel, data);
Expand Down

0 comments on commit 6f75e6f

Please sign in to comment.