diff --git a/showcases/data/Function/Activator - Service Jar/code.pure b/showcases/data/Function/Activator - Service Jar/code.pure index 035804728..527abe684 100644 --- a/showcases/data/Function/Activator - Service Jar/code.pure +++ b/showcases/data/Function/Activator - Service Jar/code.pure @@ -91,8 +91,14 @@ Mapping mapping::m2m::Firm_Person domain::Person: Pure { ~src domain::S_Person - firstName: $src.fullName->substring(0, $src.fullName->indexOf(' ')), - lastName: $src.fullName->substring($src.fullName->indexOf(' ') + 1, $src.fullName->length()) + firstName: $src.fullName->substring( + 0, + $src.fullName->indexOf(' ') +), + lastName: $src.fullName->substring( + $src.fullName->indexOf(' ') + 1, + $src.fullName->length() +) } domain::Firm: Pure { @@ -105,7 +111,25 @@ Mapping mapping::m2m::Firm_Person [ test_1 ( - query: |domain::Firm.all()->graphFetch(#{domain::Firm{legalName,employees{firstName}}}#)->serialize(#{domain::Firm{legalName,employees{firstName}}}#); + query: |domain::Firm.all()->graphFetch( + #{ + domain::Firm{ + legalName, + employees{ + firstName + } + } + }# +)->serialize( + #{ + domain::Firm{ + legalName, + employees{ + firstName + } + } + }# +); data: [ @@ -142,7 +166,18 @@ Mapping mapping::relational::Firm_Person [ test_1 ( - query: |domain::Firm.all()->project([x|$x.legalName, x|$x.employees.firstName, x|$x.employees.lastName], ['Legal Name', 'Employees/First Name', 'Employees/Last Name']); + query: |domain::Firm.all()->project( + [ + x: domain::Firm[1]|$x.legalName, + x: domain::Firm[1]|$x.employees.firstName, + x: domain::Firm[1]|$x.employees.lastName + ], + [ + 'Legal Name', + 'Employees/First Name', + 'Employees/Last Name' + ] +); data: [ filter(s|$s.type == _01_basic::ProductSynonymType.CUSIP)->toOne().name}: String[1]; - isin() {$this.synonyms->filter(s|$s.type == _01_basic::ProductSynonymType.ISIN)->toOne().name}: String[1]; - sedol() {$this.synonyms->filter(s|$s.type == _01_basic::ProductSynonymType.SEDOL)->toOne().name}: String[1]; + cusip() {$this.synonyms->filter( + s: _01_basic::Synonym[1]|$s.type == + _01_basic::ProductSynonymType.CUSIP +)->toOne().name}: String[1]; + isin() {$this.synonyms->filter( + s: _01_basic::Synonym[1]|$s.type == + _01_basic::ProductSynonymType.ISIN +)->toOne().name}: String[1]; + sedol() {$this.synonyms->filter( + s: _01_basic::Synonym[1]|$s.type == + _01_basic::ProductSynonymType.SEDOL +)->toOne().name}: String[1]; } Class _01_basic::TradeEvent @@ -235,12 +244,21 @@ Class _01_basic::Trade product: _01_basic::Product[0..1]; account: _01_basic::Account[0..1]; events: _01_basic::TradeEvent[*]; - productIdentifier() {if($this.product->isNotEmpty(), |$this.product->toOne().name, |'Unknown')}: String[1]; - eventsByDate(date: Date[1]) {$this.events->filter(e|$e.eventDate == $date)}: _01_basic::TradeEvent[*]; + productIdentifier() {if( + $this.product->isNotEmpty(), + |$this.product->toOne().name, + |'Unknown' +)}: String[1]; + eventsByDate(date: Date[1]) {$this.events->filter( + e: _01_basic::TradeEvent[1]|$e.eventDate == + $date +)}: _01_basic::TradeEvent[*]; tradeDateEvent() {$this.eventsByDate($this.tradeDate->toOne())->toOne()}: _01_basic::TradeEvent[1]; tradeDataEventType() {$this.tradeDateEvent.eventType}: String[1]; initiator() {$this.tradeDateEvent.initiator}: _01_basic::Trader[0..1]; - latestEventDate() {$this.events->map(e|$e.eventDate)->sort()->reverse()->at(0)}: StrictDate[1]; + latestEventDate() {$this.events->map( + e: _01_basic::TradeEvent[1]|$e.eventDate +)->sort()->reverse()->at(0)}: StrictDate[1]; } Class _01_basic::Account @@ -267,14 +285,36 @@ Class {meta::pure::profiles::doc.doc = 'must pass date for isin/cusip/sedol now. { name: String[1]; classification: _01_basic::ProductClassification[1]; - cusip(businessDate: StrictDate[1]) {$this.synonyms($businessDate)->filter(s|$s.type == _01_basic::ProductSynonymType.CUSIP)->toOne().name}: String[1]; - isin(businessDate: StrictDate[1]) {$this.synonyms($businessDate)->filter(s|$s.type == _01_basic::ProductSynonymType.ISIN)->toOne().name}: String[1]; - sedol(businessDate: StrictDate[1]) {$this.synonyms($businessDate)->filter(s|$s.type == _01_basic::ProductSynonymType.SEDOL)->toOne().name}: String[1]; + cusip(businessDate: StrictDate[1]) {$this.synonyms($businessDate)->filter( + s: _02_advanced::SynonymStereoTyped[1]|$s.type == + _01_basic::ProductSynonymType.CUSIP +)->toOne().name}: String[1]; + isin(businessDate: StrictDate[1]) {$this.synonyms($businessDate)->filter( + s: _02_advanced::SynonymStereoTyped[1]|$s.type == + _01_basic::ProductSynonymType.ISIN +)->toOne().name}: String[1]; + sedol(businessDate: StrictDate[1]) {$this.synonyms($businessDate)->filter( + s: _02_advanced::SynonymStereoTyped[1]|$s.type == + _01_basic::ProductSynonymType.SEDOL +)->toOne().name}: String[1]; } Class {meta::pure::profiles::doc.doc = 'use tags to add metadata.'} _02_advanced::AccountWithConstraints extends _01_basic::Account [ - tradesNotDoubleBooked: $this->project([a|$a.trades.id], ['tradeId'])->groupBy('tradeId', 'count'->agg(x|$x, y|$y->count()))->filter(t|$t.getInteger('count') > 1)->tdsRows()->isEmpty(), + tradesNotDoubleBooked: $this->project( + [ + a: _02_advanced::AccountWithConstraints[1]|$a.trades.id + ], + ['tradeId'] +)->groupBy( + 'tradeId', + 'count'->agg( + x: meta::pure::tds::TDSRow[1]|$x, + y: meta::pure::tds::TDSRow[*]|$y->count() + ) +)->filter( + t: meta::pure::tds::TDSRow[1]|$t.getInteger('count') > 1 +)->tdsRows()->isEmpty(), noTradesAfterCloseDate: true ] { @@ -341,7 +381,35 @@ Mapping _03_modelToModelMapping::simpleModelToModelMapping [ test_1 ( - query: |_01_basic::Product.all()->graphFetchChecked(#{_01_basic::Product{name,classification{description,type},synonyms{type,name}}}#)->serialize(#{_01_basic::Product{name,classification{description,type},synonyms{type,name}}}#); + query: |_01_basic::Product.all()->graphFetchChecked( + #{ + _01_basic::Product{ + name, + classification{ + description, + type + }, + synonyms{ + type, + name + } + } + }# +)->serialize( + #{ + _01_basic::Product{ + name, + classification{ + description, + type + }, + synonyms{ + type, + name + } + } + }# +); data: [ @@ -350,7 +418,35 @@ Mapping _03_modelToModelMapping::simpleModelToModelMapping ), test_2 ( - query: |_01_basic::Product.all()->graphFetchChecked(#{_01_basic::Product{name,classification{type,description},synonyms{name,type}}}#)->serialize(#{_01_basic::Product{name,classification{type,description},synonyms{name,type}}}#); + query: |_01_basic::Product.all()->graphFetchChecked( + #{ + _01_basic::Product{ + name, + classification{ + type, + description + }, + synonyms{ + name, + type + } + } + }# +)->serialize( + #{ + _01_basic::Product{ + name, + classification{ + type, + description + }, + synonyms{ + name, + type + } + } + }# +); data: [ @@ -406,7 +502,35 @@ Mapping _03_modelToModelMapping::unionMapping [ test_1 ( - query: |_01_basic::Product.all()->graphFetchChecked(#{_01_basic::Product{name,synonyms{name,type},classification{type,description}}}#)->serialize(#{_01_basic::Product{name,synonyms{name,type},classification{type,description}}}#); + query: |_01_basic::Product.all()->graphFetchChecked( + #{ + _01_basic::Product{ + name, + synonyms{ + name, + type + }, + classification{ + type, + description + } + } + }# +)->serialize( + #{ + _01_basic::Product{ + name, + synonyms{ + name, + type + }, + classification{ + type, + description + } + } + }# +); data: [ @@ -415,7 +539,35 @@ Mapping _03_modelToModelMapping::unionMapping ), test_2 ( - query: |_01_basic::Product.all()->graphFetchChecked(#{_01_basic::Product{name,classification{type,description},synonyms{name,type}}}#)->serialize(#{_01_basic::Product{name,classification{type,description},synonyms{name,type}}}#); + query: |_01_basic::Product.all()->graphFetchChecked( + #{ + _01_basic::Product{ + name, + classification{ + type, + description + }, + synonyms{ + name, + type + } + } + }# +)->serialize( + #{ + _01_basic::Product{ + name, + classification{ + type, + description + }, + synonyms{ + name, + type + } + } + }# +); data: [ diff --git a/showcases/data/Store/Model Store/Mapping/service/basic/code.pure b/showcases/data/Store/Model Store/Mapping/service/basic/code.pure index 219901386..e336b9946 100644 --- a/showcases/data/Store/Model Store/Mapping/service/basic/code.pure +++ b/showcases/data/Store/Model Store/Mapping/service/basic/code.pure @@ -18,7 +18,27 @@ Service mapping::FirmService autoActivateUpdates: true; execution: Single { - query: |model::target::_Firm.all()->graphFetch(#{model::target::_Firm{myLegalName,name,employees{fullName}}}#)->serialize(#{model::target::_Firm{myLegalName,name,employees{fullName}}}#); + query: |model::target::_Firm.all()->graphFetch( + #{ + model::target::_Firm{ + myLegalName, + name, + employees{ + fullName + } + } + }# + )->serialize( + #{ + model::target::_Firm{ + myLegalName, + name, + employees{ + fullName + } + } + }# + ); mapping: mapping::ModelToModelMapping; runtime: mapping::FirmRuntime; } @@ -120,7 +140,27 @@ Mapping mapping::ModelToModelMapping [ FirmSuite: { - function: |model::target::_Firm.all()->graphFetch(#{model::target::_Firm{employees{fullName},name,myLegalName}}#)->serialize(#{model::target::_Firm{employees{fullName},name,myLegalName}}#); + function: |model::target::_Firm.all()->graphFetch( + #{ + model::target::_Firm{ + employees{ + fullName + }, + name, + myLegalName + } + }# +)->serialize( + #{ + model::target::_Firm{ + employees{ + fullName + }, + name, + myLegalName + } + }# +); tests: [ AppleData: diff --git a/showcases/data/Store/Relational Store/Mapping/Mapping Test/code.pure b/showcases/data/Store/Relational Store/Mapping/Mapping Test/code.pure index 0325ba8e0..f47696c95 100644 --- a/showcases/data/Store/Relational Store/Mapping/Mapping Test/code.pure +++ b/showcases/data/Store/Relational Store/Mapping/Mapping Test/code.pure @@ -179,7 +179,20 @@ Class relationalMapping::Synonym Class {meta::pure::profiles::doc.doc = 'use tags to add metadata.'} relationalMapping::AccountWithConstraints extends relationalMapping::Account [ - tradesNotDoubleBooked: $this->project([a|$a.trades.id], ['tradeId'])->groupBy('tradeId', 'count'->agg(x|$x, y|$y->count()))->filter(t|$t.getInteger('count') > 1)->tdsRows()->isEmpty(), + tradesNotDoubleBooked: $this->project( + [ + a: relationalMapping::AccountWithConstraints[1]|$a.trades.id + ], + ['tradeId'] +)->groupBy( + 'tradeId', + 'count'->agg( + x: meta::pure::tds::TDSRow[1]|$x, + y: meta::pure::tds::TDSRow[*]|$y->count() + ) +)->filter( + t: meta::pure::tds::TDSRow[1]|$t.getInteger('count') > 1 +)->tdsRows()->isEmpty(), noTradesAfterCloseDate: true ] { @@ -217,8 +230,15 @@ Class relationalMapping::Trade product: relationalMapping::Product[0..1]; account: relationalMapping::Account[0..1]; events: relationalMapping::TradeEvent[*]; - productIdentifier() {if($this.product->isNotEmpty(), |$this.product->toOne().name, |'Unknown')}: String[1]; - eventsByDate(date: Date[1]) {$this.events->filter(e|$e.eventDate == $date)}: relationalMapping::TradeEvent[*]; + productIdentifier() {if( + $this.product->isNotEmpty(), + |$this.product->toOne().name, + |'Unknown' +)}: String[1]; + eventsByDate(date: Date[1]) {$this.events->filter( + e: relationalMapping::TradeEvent[1]|$e.eventDate == + $date +)}: relationalMapping::TradeEvent[*]; tradeDateEvent() {$this.eventsByDate($this.tradeDate->toOne())->toOne()}: relationalMapping::TradeEvent[1]; tradeDateEventType() {$this.tradeDateEvent.eventType}: String[1]; initiator() {$this.tradeDateEvent.initiator}: relationalMapping::Trader[0..1]; @@ -228,9 +248,18 @@ Class {meta::pure::profiles::doc.doc = 'must pass date for isin/cusip/sedol now. { name: String[1]; classification: relationalMapping::ProductClassification[1]; - cusip() {$this.synonyms->filter(s|$s.type == relationalMapping::ProductSynonymType.CUSIP)->toOne().name}: String[1]; - isin() {$this.synonyms->filter(s|$s.type == relationalMapping::ProductSynonymType.ISIN)->toOne().name}: String[1]; - sedol() {$this.synonyms->filter(s|$s.type == relationalMapping::ProductSynonymType.SEDOL)->toOne().name}: String[1]; + cusip() {$this.synonyms->filter( + s: relationalMapping::Synonym[1]|$s.type == + relationalMapping::ProductSynonymType.CUSIP +)->toOne().name}: String[1]; + isin() {$this.synonyms->filter( + s: relationalMapping::Synonym[1]|$s.type == + relationalMapping::ProductSynonymType.ISIN +)->toOne().name}: String[1]; + sedol() {$this.synonyms->filter( + s: relationalMapping::Synonym[1]|$s.type == + relationalMapping::ProductSynonymType.SEDOL +)->toOne().name}: String[1]; } Association relationalMapping::ProdSynonym @@ -271,7 +300,23 @@ Mapping relationalMapping::RelationalMappingWithFilters [ test_1 ( - query: |relationalMapping::Account.all()->graphFetch(#{relationalMapping::Account{name,createDate,closeDate}}#)->serialize(#{relationalMapping::Account{name,createDate,closeDate}}#); + query: |relationalMapping::Account.all()->graphFetch( + #{ + relationalMapping::Account{ + name, + createDate, + closeDate + } + }# +)->serialize( + #{ + relationalMapping::Account{ + name, + createDate, + closeDate + } + }# +); data: [ graphFetch(#{relationalMapping::TradeEvent{eventDate,eventType}}#)->serialize(#{relationalMapping::TradeEvent{eventDate,eventType}}#); + query: |relationalMapping::TradeEvent.all()->graphFetch( + #{ + relationalMapping::TradeEvent{ + eventDate, + eventType + } + }# +)->serialize( + #{ + relationalMapping::TradeEvent{ + eventDate, + eventType + } + }# +); data: [ project([x|$x.description, x|$x.type->contains('Type A'), x|$x.type], ['Description', 'Is Type A', 'Type']); + query: |relationalMapping::ProductClassification.all()->project( + [ + x: relationalMapping::ProductClassification[1]|$x.description, + x: relationalMapping::ProductClassification[1]|$x.type->contains('Type A'), + x: relationalMapping::ProductClassification[1]|$x.type + ], + [ + 'Description', + 'Is Type A', + 'Type' + ] +); data: [ filter(x|$x.classification.type == 'Type A')->project([x|$x.name, x|$x.classification.type, x|$x.classification.description, x|$x.synonyms.type, x|$x.synonyms.name], ['Name', 'Classification/Type', 'Classification/Description', 'Synonyms/Type', 'Synonyms/Name']); + query: |relationalMapping::Product.all()->filter( + x: relationalMapping::Product[1]|$x.classification.type == 'Type A' +)->project( + [ + x: relationalMapping::Product[1]|$x.name, + x: relationalMapping::Product[1]|$x.classification.type, + x: relationalMapping::Product[1]|$x.classification.description, + x: relationalMapping::Product[1]|$x.synonyms.type, + x: relationalMapping::Product[1]|$x.synonyms.name + ], + [ + 'Name', + 'Classification/Type', + 'Classification/Description', + 'Synonyms/Type', + 'Synonyms/Name' + ] +); data: [ project([x|$x.name, x|$x.closeDate, x|$x.createDate, x|$x.createDate->monthNumber(), x|$x.createDate->dayOfMonth()], ['Name', 'Close Date', 'Create Date', 'Create Month Number', 'Create dayOfMonth']); + query: |relationalMapping::Account.all()->project( + [ + x: relationalMapping::Account[1]|$x.name, + x: relationalMapping::Account[1]|$x.closeDate, + x: relationalMapping::Account[1]|$x.createDate, + x: relationalMapping::Account[1]|$x.createDate->monthNumber(), + x: relationalMapping::Account[1]|$x.createDate->dayOfMonth() + ], + [ + 'Name', + 'Close Date', + 'Create Date', + 'Create Month Number', + 'Create dayOfMonth' + ] +); data: [ project([x|$x.id, x|$x.quantity, x|$x.settlementDateTime, x|$x.tradeDate, x|$x.account.name, x|$x.product.name, x|$x.tradeDateEvent.eventDate, x|$x.tradeDateEventType, x|$x.initiator.name], ['Id', 'Quantity', 'Settlement Date Time', 'Trade Date', 'Account_Name', 'Product_Name', 'Trade Event Date', 'Trade Date Event Type', 'Initiator']); + query: |relationalMapping::Trade.all()->project( + [ + x: relationalMapping::Trade[1]|$x.id, + x: relationalMapping::Trade[1]|$x.quantity, + x: relationalMapping::Trade[1]|$x.settlementDateTime, + x: relationalMapping::Trade[1]|$x.tradeDate, + x: relationalMapping::Trade[1]|$x.account.name, + x: relationalMapping::Trade[1]|$x.product.name, + x: relationalMapping::Trade[1]|$x.tradeDateEvent.eventDate, + x: relationalMapping::Trade[1]|$x.tradeDateEventType, + x: relationalMapping::Trade[1]|$x.initiator.name + ], + [ + 'Id', + 'Quantity', + 'Settlement Date Time', + 'Trade Date', + 'Account_Name', + 'Product_Name', + 'Trade Event Date', + 'Trade Date Event Type', + 'Initiator' + ] +); data: [ filter(x|$x.id == $id)->graphFetch(#{showcase::northwind::model::Order{id,createdDate,customer{companyName},employee{firstName},lineItems{product{name,category{name}},quantity},shipper{name}}}#)->serialize(#{showcase::northwind::model::Order{id,createdDate,customer{companyName},employee{firstName},lineItems{product{name,category{name}},quantity},shipper{name}}}#); + query: id: Integer[1]|showcase::northwind::model::Order.all()->filter( + x: showcase::northwind::model::Order[1]|$x.id == + $id + )->graphFetch( + #{ + showcase::northwind::model::Order{ + id, + createdDate, + customer{ + companyName + }, + employee{ + firstName + }, + lineItems{ + product{ + name, + category{ + name + } + }, + quantity + }, + shipper{ + name + } + } + }# + )->serialize( + #{ + showcase::northwind::model::Order{ + id, + createdDate, + customer{ + companyName + }, + employee{ + firstName + }, + lineItems{ + product{ + name, + category{ + name + } + }, + quantity + }, + shipper{ + name + } + } + }# + ); mapping: showcase::northwind::mapping::NorthwindMapping; runtime: showcase::northwind::runtime::NorthwindRuntime; } @@ -260,7 +313,27 @@ Service showcase::northwind::services::tds::TopCategories autoActivateUpdates: true; execution: Single { - query: |showcase::northwind::model::Order.all()->groupBy([x|$x.lineItems.product.category.id, x|$x.lineItems.product.category.name], [agg(x|$x.id, x|$x->distinct()->count())], ['Category Id', 'Category Name', 'Order Count'])->sort([desc('Order Count')])->take(5); + query: |showcase::northwind::model::Order.all()->groupBy( + [ + x: showcase::northwind::model::Order[1]|$x.lineItems.product.category.id, + x: showcase::northwind::model::Order[1]|$x.lineItems.product.category.name + ], + [ + agg( + x: showcase::northwind::model::Order[1]|$x.id, + x: Integer[*]|$x->distinct()->count() + ) + ], + [ + 'Category Id', + 'Category Name', + 'Order Count' + ] + )->sort( + [ + desc('Order Count') + ] + )->take(5); mapping: showcase::northwind::mapping::NorthwindMapping; runtime: showcase::northwind::runtime::NorthwindRuntime; } @@ -273,7 +346,29 @@ Service showcase::northwind::services::tds::OrderDetailsByIdTDS autoActivateUpdates: true; execution: Single { - query: orderId: Integer[1]|showcase::northwind::model::Order.all()->filter(x|$x.id == $orderId)->project([x|$x.id, x|$x.customer.companyName, x|$x.employee.firstName, x|$x.lineItems.product.name, x|$x.lineItems.product.category.name, x|$x.lineItems.quantity, x|$x.shipper.name], ['Order Id', 'Customer/Company Name', 'Employee/First Name', 'Order Line Items/Product/Product Name', 'Order Line Items/Product/Category/Category Name', 'Order Line Items/Quantity', 'Shipper/Company Name']); + query: orderId: Integer[1]|showcase::northwind::model::Order.all()->filter( + x: showcase::northwind::model::Order[1]|$x.id == + $orderId + )->project( + [ + x: showcase::northwind::model::Order[1]|$x.id, + x: showcase::northwind::model::Order[1]|$x.customer.companyName, + x: showcase::northwind::model::Order[1]|$x.employee.firstName, + x: showcase::northwind::model::Order[1]|$x.lineItems.product.name, + x: showcase::northwind::model::Order[1]|$x.lineItems.product.category.name, + x: showcase::northwind::model::Order[1]|$x.lineItems.quantity, + x: showcase::northwind::model::Order[1]|$x.shipper.name + ], + [ + 'Order Id', + 'Customer/Company Name', + 'Employee/First Name', + 'Order Line Items/Product/Product Name', + 'Order Line Items/Product/Category/Category Name', + 'Order Line Items/Quantity', + 'Shipper/Company Name' + ] + ); mapping: showcase::northwind::mapping::NorthwindMapping; runtime: showcase::northwind::runtime::NorthwindRuntime; } @@ -286,7 +381,33 @@ Service showcase::northwind::services::tds::ProductRankingWithinCategory autoActivateUpdates: true; execution: Single { - query: |showcase::northwind::model::inventory::ProductCategory.all()->groupBy([x|$x.name, x|$x.products.name], [agg(x|$x.products.orderLineItems.order.id, x|$x->distinct()->count())], ['Category Name', 'Products/Product Name', 'OrderCount'])->olapGroupBy(['Category Name'], desc('OrderCount'), x|$x->rank(), 'Rank Within Category')->sort([asc('Category Name'), asc('Rank Within Category')]); + query: |showcase::northwind::model::inventory::ProductCategory.all()->groupBy( + [ + x: showcase::northwind::model::inventory::ProductCategory[1]|$x.name, + x: showcase::northwind::model::inventory::ProductCategory[1]|$x.products.name + ], + [ + agg( + x: showcase::northwind::model::inventory::ProductCategory[1]|$x.products.orderLineItems.order.id, + x: Integer[*]|$x->distinct()->count() + ) + ], + [ + 'Category Name', + 'Products/Product Name', + 'OrderCount' + ] + )->olapGroupBy( + ['Category Name'], + desc('OrderCount'), + x: meta::pure::tds::TDSRow[*]|$x->rank(), + 'Rank Within Category' + )->sort( + [ + asc('Category Name'), + asc('Rank Within Category') + ] + ); mapping: showcase::northwind::mapping::NorthwindMapping; runtime: showcase::northwind::runtime::NorthwindRuntime; } @@ -299,7 +420,28 @@ Service showcase::northwind::services::tds::Customers autoActivateUpdates: true; execution: Single { - query: |showcase::northwind::model::crm::Customer.all()->project([x|$x.id, x|$x.companyName, x|$x.contactName, x|$x.companyTitle, x|$x.address.country, x|$x.address.address, x|$x.address.city, x|$x.telephoneNumber], ['Customer Id', 'Company Name', 'Contact Name', 'Company Title', 'Country', 'Address', 'City', 'Phone']); + query: |showcase::northwind::model::crm::Customer.all()->project( + [ + x: showcase::northwind::model::crm::Customer[1]|$x.id, + x: showcase::northwind::model::crm::Customer[1]|$x.companyName, + x: showcase::northwind::model::crm::Customer[1]|$x.contactName, + x: showcase::northwind::model::crm::Customer[1]|$x.companyTitle, + x: showcase::northwind::model::crm::Customer[1]|$x.address.country, + x: showcase::northwind::model::crm::Customer[1]|$x.address.address, + x: showcase::northwind::model::crm::Customer[1]|$x.address.city, + x: showcase::northwind::model::crm::Customer[1]|$x.telephoneNumber + ], + [ + 'Customer Id', + 'Company Name', + 'Contact Name', + 'Company Title', + 'Country', + 'Address', + 'City', + 'Phone' + ] + ); mapping: showcase::northwind::mapping::NorthwindMapping; runtime: showcase::northwind::runtime::NorthwindRuntime; } @@ -312,7 +454,21 @@ Service showcase::northwind::services::graph::ShipperValidationDefects autoActivateUpdates: true; execution: Single { - query: |showcase::northwind::model::crm::ShippingCompany.all()->graphFetchChecked(#{showcase::northwind::model::crm::ShippingCompany{id,telephoneNumber}}#)->serialize(#{showcase::northwind::model::crm::ShippingCompany{id,telephoneNumber}}#); + query: |showcase::northwind::model::crm::ShippingCompany.all()->graphFetchChecked( + #{ + showcase::northwind::model::crm::ShippingCompany{ + id, + telephoneNumber + } + }# + )->serialize( + #{ + showcase::northwind::model::crm::ShippingCompany{ + id, + telephoneNumber + } + }# + ); mapping: showcase::northwind::mapping::NorthwindMapping; runtime: showcase::northwind::runtime::NorthwindRuntime; } @@ -505,11 +661,19 @@ Class showcase::northwind::model::geography::Address Class showcase::northwind::model::crm::Employee [ - dateOfBirthNotInTheFuture: $this.dateOfBirth < now(), + dateOfBirthNotInTheFuture: $this.dateOfBirth < + now(), dateOfBirthValid: $this.dateOfBirth > %1900-01-01, - employeeIsOverEighteen: $this.dateOfBirth->dateDiff(today(), meta::pure::functions::date::DurationUnit.YEARS) >= 18, - employeeIsUnderEighty: $this.dateOfBirth->dateDiff(today(), meta::pure::functions::date::DurationUnit.YEARS) < 80, - notDateOfHireNotBeforeDateOfBirth: $this.dateOfHire > $this.dateOfBirth + employeeIsOverEighteen: $this.dateOfBirth->dateDiff( + today(), + meta::pure::functions::date::DurationUnit.YEARS +) >= 18, + employeeIsUnderEighty: $this.dateOfBirth->dateDiff( + today(), + meta::pure::functions::date::DurationUnit.YEARS +) < 80, + notDateOfHireNotBeforeDateOfBirth: $this.dateOfHire > + $this.dateOfBirth ] { id: Integer[1]; @@ -522,13 +686,22 @@ Class showcase::northwind::model::crm::Employee address: showcase::northwind::model::geography::Address[0..1]; homeTelephoneNumber: String[0..1]; extension: String[0..1]; - fullName() {if($this.preferredTitle->isNotEmpty(), |$this.preferredTitle->toOne()->toString() + ' ', |if($this.title->isNotEmpty(), |$this.title->toOne() + ' ', |'')) + $this.firstName + ' ' + $this.lastName}: String[1]; + fullName() {if( + $this.preferredTitle->isNotEmpty(), + |$this.preferredTitle->toOne()->toString() + ' ', + |if( + $this.title->isNotEmpty(), + |$this.title->toOne() + ' ', + |'' + ) +) + $this.firstName + ' ' + $this.lastName}: String[1]; } Class showcase::northwind::model::geography::USState [ idNotNegative: $this.id >= 0, - nameNotBlank: $this.name->isEmpty() || ($this.name->toOne()->length() > 0) + nameNotBlank: $this.name->isEmpty() || + ($this.name->toOne()->length() > 0) ] { id: Integer[1]; @@ -611,7 +784,8 @@ Class showcase::northwind::model::geography::SalesTerritory Class showcase::northwind::model::crm::ShippingCompany [ idNotNegative: $this.id >= 0, - telephoneNumberFormatValid: $this.telephoneNumber->isEmpty() || $this.telephoneNumber->toOne()->matches('(1-)?\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d') + telephoneNumberFormatValid: $this.telephoneNumber->isEmpty() || + $this.telephoneNumber->toOne()->matches('(1-)?\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d') ] { id: Integer[1]; diff --git a/showcases/pom.xml b/showcases/pom.xml index 9b688f181..b1fb5094b 100644 --- a/showcases/pom.xml +++ b/showcases/pom.xml @@ -16,20 +16,16 @@ 1.8 3 data + 4.35.1 + - - org.finos.legend.engine - legend-engine-extensions-collection-execution - 4.30.3 - test - org.finos.legend.engine legend-engine-extensions-collection-generation - 4.30.3 + ${legend.engine.version} test diff --git a/showcases/src/test/java/org/example/ShowcaseCompilerTest.java b/showcases/src/test/java/org/example/ShowcaseCompilerTest.java index 20412a400..2261fc86b 100644 --- a/showcases/src/test/java/org/example/ShowcaseCompilerTest.java +++ b/showcases/src/test/java/org/example/ShowcaseCompilerTest.java @@ -7,6 +7,7 @@ import org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposer; import org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerContext; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; +import org.finos.legend.engine.shared.core.api.grammar.RenderStyle; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; import org.junit.Test; import org.junit.runner.RunWith; @@ -93,11 +94,12 @@ public void processShowcaseFile() throws IOException * - Run all testables within a showcase */ PureModelContextData pureModelContextData = PureGrammarParser.newInstance().parseModel(pureGrammar, "", 0, 0, true); - PureGrammarComposer grammarComposer = PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().build()); + PureGrammarComposer grammarComposer = PureGrammarComposer.newInstance(PureGrammarComposerContext.Builder.newInstance().withRenderStyle(RenderStyle.PRETTY).build()); + + // compile + Compiler.compile(pureModelContextData, DeploymentMode.PROD, Lists.mutable.empty()); // Grammar composer adds a trailing newline assertEquals(pureGrammar + "\n", grammarComposer.renderPureModelContextData(pureModelContextData)); - - Compiler.compile(pureModelContextData, DeploymentMode.PROD, Lists.mutable.empty()); } }