Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add occurrences entrance #1578

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions providers/shared/components/shared/setup.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@
/]
[/#macro]

[#-- Default Occurrence State --]
[#macro shared_occurrences_generationcontract occurrence ]
[@addDefaultGenerationContract subsets=[ "state" ] /]
[/#macro]

[#macro shared_occurrences_state occurrence ]
[#local allOccurrences = asFlattenedArray( [ occurrence, occurrence.Occurrences![] ], true )]
[#list allOccurrences as occurrence ]

[#local occurrencestate = {}]
[#list occurrence as k, v ]
[#if k != "Occurrences" ]
[#local occurrencestate = mergeObjects(occurrencestate, { k : v }) ]
[/#if]
[/#list]

[@stateEntry
type="Occurrences"
id=occurrence.Core.TypedFullName
state=occurrencestate
/]
[/#list]
[/#macro]

[#-- Default management contract --]
[#macro shared_unitlist_generationcontract occurrence ]
[@addDefaultGenerationContract subsets=[ "managementcontract" ] /]
Expand Down
72 changes: 72 additions & 0 deletions providers/shared/deploymentframeworks/default/output.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[#assign SCHEMA_DEFAULT_OUTPUT_TYPE = "schema"]
[#assign CONTRACT_DEFAULT_OUTPUT_TYPE = "contract"]
[#assign INFO_DEFAULT_OUTPUT_TYPE = "info" ]
[#assign STATE_OUTPUT_TYPE = "state" ]

[#-- SCRIPT_DEFAULT_OUTPUT_TYPE --]

Expand Down Expand Up @@ -416,6 +417,69 @@
[/#list]
[/#macro]

[#-- Occuurrence State --]
[#macro default_output_state level="" include=""]
[@initialiseJsonOutput name="states" /]

[@processFlows
level=level
framework=DEFAULT_DEPLOYMENT_FRAMEWORK
flows=commandLineOptions.Flow.Names
/]

[#local allStates = {}]

[#if getOutputContent("states")?has_content || logMessages?has_content ]

[#list getOutputContent("states") as type, states ]

[#local typedStates = []]

[#list states?values as state ]

[#local typedStates = combineEntities(
typedStates,
[
state
],
APPEND_COMBINE_BEHAVIOUR
)]
[/#list]

[#local allStates = mergeObjects( allStates, { type : typedStates } )]
[/#list]

[@toJSON
mergeObjects(
{
"Metadata" : {
"Id" : "state",
"Prepared" : .now?iso_utc,
"RunId" : commandLineOptions.Run.Id,
"RequestReference" : commandLineOptions.References.Request,
"ConfigurationReference" : commandLineOptions.References.Configuration
}
},
allStates
) +
attributeIfContent("HamletMessages", logMessages)
/]
[/#if]
[@serialiseOutput name=JSON_DEFAULT_OUTPUT_TYPE /]
[/#macro]

[#macro stateEntry type id state ]
[@mergeWithJsonOutput
name="states"
content={
type : {
id : state
}
}
/]
[/#macro]


[#-- Add Output Step mappings for each output --]
[@addGenerationContractStepOutputMapping
provider=SHARED_PROVIDER
Expand Down Expand Up @@ -513,6 +577,14 @@
outputSuffix="info.json"
/]

[@addGenerationContractStepOutputMapping
provider=SHARED_PROVIDER
subset="state"
outputType=STATE_OUTPUT_TYPE
outputFormat=""
outputSuffix="state.json"
/]


[#------------------------------------------------------------
-- internal support functions for default output processing --
Expand Down
1 change: 1 addition & 0 deletions providers/shared/entrances/entrance.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
[#assign SCHEMASET_ENTRANCE_TYPE = "schemaset" ]
[#assign INFO_ENTRANCE_TYPE = "info" ]
[#assign VALIDATE_ENTRANCE_TYPE = "validate" ]
[#assign OCCURRENCES_ENTRANCE_TYPE = "occurrences" ]
31 changes: 31 additions & 0 deletions providers/shared/entrances/occurrences/entrance.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[#ftl]

[#macro shared_entrance_occurrences ]

[#assign allDeploymentUnits = true]

[#-- override the deployment group to get all deployment groups --]
[@addCommandLineOption
option={
"Deployment" : {
"Group" : {
"Name" : "*"
}
},
"Flow" : {
"Names" : [ "components" ]
}
}
/]

[#if (commandLineOptions.Deployment.Unit.Subset!"") == "generationcontract" ]
[#assign allDeploymentUnits = false]
[/#if]

[@generateOutput
deploymentFramework=commandLineOptions.Deployment.Framework.Name
type=commandLineOptions.Deployment.Output.Type
format=commandLineOptions.Deployment.Output.Format
/]

[/#macro]
18 changes: 18 additions & 0 deletions providers/shared/entrances/occurrences/id.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[#ftl]

[@addEntrance
type=OCCURRENCES_ENTRANCE_TYPE
properties=
[
{
"Type" : "Description",
"Value" : "Provides the state of all occurrences within a district"
RossMurr4y marked this conversation as resolved.
Show resolved Hide resolved
}
]
commandlineoptions=[
{
"Names" : "*",
"Types" : ANY_TYPE
}
]
/]