-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added availability and influence fields to Stakeholder (#55)
- Loading branch information
Showing
6 changed files
with
158 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import Stakeholder, { StakeholderCategory, StakeholderSegmentation } from '~/domain/Stakeholder.mjs'; | ||
import Stakeholder, { StakeholderSegmentation } from '~/domain/Stakeholder.mjs'; | ||
import EntityToJsonMapper, { type EntityJson } from './EntityToJsonMapper.mjs'; | ||
|
||
export interface StakeholderJson extends EntityJson { | ||
category: string; | ||
description: string; | ||
name: string; | ||
segmentation: string; | ||
influence: number; | ||
availability: number; | ||
} | ||
|
||
export default class StakeholderToJsonMapper extends EntityToJsonMapper { | ||
override mapFrom(target: StakeholderJson): Stakeholder { | ||
return new Stakeholder({ | ||
category: target.category as StakeholderCategory, | ||
description: target.description, | ||
id: target.id, | ||
name: target.name, | ||
segmentation: target.segmentation as StakeholderSegmentation | ||
}); | ||
const version = target.serializationVersion ?? '{undefined}'; | ||
|
||
if (version.startsWith('0.3.')) | ||
return new Stakeholder({ | ||
description: target.description, | ||
id: target.id, | ||
name: target.name, | ||
segmentation: target.segmentation as StakeholderSegmentation, | ||
influence: target.influence ?? 0, | ||
availability: target.availability ?? 0 | ||
}); | ||
|
||
throw new Error(`Unsupported serialization version: ${version}`); | ||
} | ||
|
||
override mapTo(source: Stakeholder): StakeholderJson { | ||
return { | ||
...super.mapTo(source), | ||
category: source.category, | ||
description: source.description, | ||
name: source.name, | ||
segmentation: source.segmentation | ||
segmentation: source.segmentation, | ||
influence: source.influence, | ||
availability: source.availability | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters