From d2ca7d3872b13a30df4ab1cff2de7c1bcf62e5f1 Mon Sep 17 00:00:00 2001 From: Mauricio Uyaguari Date: Tue, 3 Dec 2024 20:03:41 -0500 Subject: [PATCH] use packageable ptr in persistence context (#3713) --- .changeset/eighty-laws-smile.md | 3 +++ .../__tests__/TEST_DATA__DSL_Persistence_Roundtrip.ts | 10 ++++++++-- .../V1_DSL_Persistence_PersistenceContext.ts | 5 +++-- .../from/V1_DSL_Persistence_ContextTransformer.ts | 6 +++++- .../pureGraph/to/V1_DSL_Persistence_ContextBuilder.ts | 2 +- .../V1_DSL_PersistenceContext_ProtocolHelper.ts | 7 ++++++- 6 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 .changeset/eighty-laws-smile.md diff --git a/.changeset/eighty-laws-smile.md b/.changeset/eighty-laws-smile.md new file mode 100644 index 0000000000..5029861c82 --- /dev/null +++ b/.changeset/eighty-laws-smile.md @@ -0,0 +1,3 @@ +--- +'@finos/legend-extension-dsl-persistence': patch +--- diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/__tests__/TEST_DATA__DSL_Persistence_Roundtrip.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/__tests__/TEST_DATA__DSL_Persistence_Roundtrip.ts index fce7bd552b..f007127a64 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/__tests__/TEST_DATA__DSL_Persistence_Roundtrip.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/__tests__/TEST_DATA__DSL_Persistence_Roundtrip.ts @@ -335,7 +335,10 @@ export const TEST_DATA__roundtrip_case1 = [ _type: 'persistenceContext', name: 'ZooPersistenceContext', package: 'org::dxl', - persistence: 'org::dxl::ZooPersistence', + persistence: { + path: 'org::dxl::ZooPersistence', + type: 'PERSISTENCE', + }, platform: { _type: 'default' }, serviceParameters: [ { @@ -1063,7 +1066,10 @@ export const TEST_DATA__cloud__roundtrip = [ _type: 'persistenceContext', name: 'ZooPersistenceContext', package: 'org::dxl', - persistence: 'org::dxl::ZooPersistence', + persistence: { + path: 'org::dxl::ZooPersistence', + type: 'PERSISTENCE', + }, platform: { _type: 'awsGlue', dataProcessingUnits: 10, diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistenceContext.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistenceContext.ts index 350492a0f1..b4c02014fb 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistenceContext.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistenceContext.ts @@ -20,6 +20,7 @@ import type { V1_ServiceParameter } from './V1_DSL_Persistence_ServiceParameter. import { type V1_Connection, V1_PackageableElement, + type V1_PackageableElementPointer, type V1_PackageableElementVisitor, } from '@finos/legend-graph'; import { type Hashable, hashArray } from '@finos/legend-shared'; @@ -28,7 +29,7 @@ export class V1_PersistenceContext extends V1_PackageableElement implements Hashable { - persistence!: string; + persistence!: V1_PackageableElementPointer; platform!: V1_PersistencePlatform; serviceParameters: V1_ServiceParameter[] = []; sinkConnection?: V1_Connection; @@ -36,7 +37,7 @@ export class V1_PersistenceContext override get hashCode(): string { return hashArray([ PERSISTENCE_HASH_STRUCTURE.PERSISTENCE_CONTEXT, - this.persistence, + this.persistence.path, this.platform, hashArray(this.serviceParameters), this.sinkConnection ?? '', diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_ContextTransformer.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_ContextTransformer.ts index 07d2ef9ec4..7031c75801 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_ContextTransformer.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_ContextTransformer.ts @@ -40,6 +40,7 @@ import type { DSL_Persistence_PureProtocolProcessorPlugin_Extension } from '../. import { type V1_GraphTransformerContext, V1_initPackageableElement, + V1_PackageableElementPointer, V1_transformConnection, V1_transformRootValueSpecification, } from '@finos/legend-graph'; @@ -128,7 +129,10 @@ export const V1_transformPersistenceContext = ( ): V1_PersistenceContext => { const protocol = new V1_PersistenceContext(); V1_initPackageableElement(protocol, element); - protocol.persistence = element.persistence.valueForSerialization ?? ''; + protocol.persistence = new V1_PackageableElementPointer( + 'PERSISTENCE', + element.persistence.valueForSerialization ?? '', + ); protocol.platform = V1_transformPersistencePlatform( element.platform, context, diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_ContextBuilder.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_ContextBuilder.ts index 7284ec3738..facd2bc853 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_ContextBuilder.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_ContextBuilder.ts @@ -138,7 +138,7 @@ export const V1_buildPersistenceContext = ( context.currentSubGraph, ); persistenceContext.persistence = context.resolveElement( - protocol.persistence, + protocol.persistence.path, false, ) as PackageableElementImplicitReference; persistenceContext.platform = V1_buildPersistencePlatform( diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_PersistenceContext_ProtocolHelper.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_PersistenceContext_ProtocolHelper.ts index e98ffa6a4e..004b6e18e3 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_PersistenceContext_ProtocolHelper.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_PersistenceContext_ProtocolHelper.ts @@ -30,7 +30,9 @@ import { type PureProtocolProcessorPlugin, V1_deserializeConnectionValue, V1_deserializeValueSpecification, + V1_packageableElementPointerModelSchema, V1_serializeConnectionValue, + V1_serializePackageableElementPointer, V1_serializeValueSpecification, } from '@finos/legend-graph'; import { @@ -215,7 +217,10 @@ export const V1_persistenceContextModelSchema = ( ), name: primitive(), package: primitive(), - persistence: primitive(), + persistence: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => V1_serializePackageableElementPointer(val, 'PERSISTENCE'), + ), platform: custom( (val) => V1_serializePersistencePlatform(val, plugins), (val) => V1_deserializePersistencePlatform(val, plugins),