Skip to content

Commit

Permalink
Split materialize diagram method
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Jul 25, 2024
1 parent 27b3c37 commit 5a7cbd4
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions repository/OpenPonk-Core/OPStonDiagramSerializer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ OPStonDiagramSerializer class >> minImportVersion [
^ 1
]

{ #category : 'serialize/materialize' }
OPStonDiagramSerializer >> elementsByIdsOf: aModel [

| innerElements allElements |
innerElements := OPNavigatorAdapters new allChildrenFor: aModel.
allElements := innerElements asArray copyWith: aModel.
^ (allElements collect: [ :each | each uuid -> each ]) asDictionary
]

{ #category : 'accessing' }
OPStonDiagramSerializer >> formatName [
^ 'ston'
Expand All @@ -32,21 +41,9 @@ OPStonDiagramSerializer >> formatName [
{ #category : 'serialize/materialize' }
OPStonDiagramSerializer >> materializeDiagramOf: aModel from: aStream [

| diagram adapters innerElements elementsById |
| diagram |
diagram := STON fromStream: aStream.
adapters := OPNavigatorAdapters new.
innerElements := adapters allChildrenFor: aModel.
elementsById := Dictionary new: innerElements size + 1.
elementsById at: aModel uuid put: aModel.
innerElements do: [ :each |
"elementsById
at: each uuid
ifPresent: [ :existing |
self error:
'There are two elements with same ID ' , each uuid asString
, ': ' , existing asString , ' and: ' , each asString ]
ifAbsentPut: each" ].
diagram resolveAllModelElements: elementsById.
diagram resolveAllModelElements: (self elementsByIdsOf: aModel).
^ diagram
]

Expand Down

0 comments on commit 5a7cbd4

Please sign in to comment.