Skip to content

Commit

Permalink
use packageable ptr in persistence context (finos#3713)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauricioUyaguari authored Dec 4, 2024
1 parent af884b4 commit d2ca7d3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changeset/eighty-laws-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@finos/legend-extension-dsl-persistence': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -28,15 +29,15 @@ export class V1_PersistenceContext
extends V1_PackageableElement
implements Hashable
{
persistence!: string;
persistence!: V1_PackageableElementPointer;
platform!: V1_PersistencePlatform;
serviceParameters: V1_ServiceParameter[] = [];
sinkConnection?: V1_Connection;

override get hashCode(): string {
return hashArray([
PERSISTENCE_HASH_STRUCTURE.PERSISTENCE_CONTEXT,
this.persistence,
this.persistence.path,
this.platform,
hashArray(this.serviceParameters),
this.sinkConnection ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const V1_buildPersistenceContext = (
context.currentSubGraph,
);
persistenceContext.persistence = context.resolveElement(
protocol.persistence,
protocol.persistence.path,
false,
) as PackageableElementImplicitReference<Persistence>;
persistenceContext.platform = V1_buildPersistencePlatform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import {
type PureProtocolProcessorPlugin,
V1_deserializeConnectionValue,
V1_deserializeValueSpecification,
V1_packageableElementPointerModelSchema,
V1_serializeConnectionValue,
V1_serializePackageableElementPointer,
V1_serializeValueSpecification,
} from '@finos/legend-graph';
import {
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit d2ca7d3

Please sign in to comment.