forked from RafaelAPB/blockchain-integration-framework
-
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.
feat(bungee): support merging views according to a privacy policy
Signed-off-by: eduv09 <eduardovasques10@tecnico.ulisboa.pt>
- Loading branch information
Showing
6 changed files
with
114 additions
and
3 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
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
16 changes: 16 additions & 0 deletions
16
packages/cactus-plugin-bungee/src/main/typescript/view-merging/extended-state.ts
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { State } from "../view-creation/state"; | ||
|
||
export class ExtendedState { | ||
private states: Map<string, State>; | ||
constructor() { | ||
this.states = new Map<string, State>(); | ||
} | ||
public getState(viewId: string): State | undefined { | ||
return this.states.get(viewId); | ||
} | ||
public setState(viewId: string, state: State) { | ||
if (this.getState(viewId) == undefined) { | ||
this.states.set(viewId, state); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/cactus-plugin-bungee/src/main/typescript/view-merging/integrated-view.ts
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { State } from "../view-creation/state"; | ||
import { ExtendedState } from "./extended-state"; | ||
|
||
export class IntegratedView { | ||
private stateList: Map<string, ExtendedState>; | ||
private tI: string; | ||
private tF: string; | ||
private participants: string[]; | ||
private privacyPolicy: string; | ||
constructor(privacyPolicy: string) { | ||
this.stateList = new Map<string, ExtendedState>(); | ||
this.tI = "999999999999999"; | ||
this.tF = "0"; | ||
this.participants = []; | ||
this.privacyPolicy = privacyPolicy; | ||
} | ||
public getTI(): string { | ||
return this.tI; | ||
} | ||
public setTI(tI: string) { | ||
this.tI = tI; | ||
} | ||
public getTF(): string { | ||
return this.tF; | ||
} | ||
public setTF(TF: string) { | ||
this.tF = TF; | ||
} | ||
public addParticipant(participant: string) { | ||
this.participants.push(participant); | ||
} | ||
public getExtendedState(stateId: string): ExtendedState | undefined { | ||
return this.stateList.get(stateId); | ||
} | ||
|
||
public createExtendedState(stateId: string) { | ||
if (this.getExtendedState(stateId) == undefined) { | ||
this.stateList.set(stateId, new ExtendedState()); | ||
} | ||
} | ||
public addStateInExtendedState( | ||
stateId: string, | ||
viewId: string, | ||
state: State, | ||
) { | ||
const extendedState = this.getExtendedState(stateId); | ||
if (extendedState != undefined) { | ||
extendedState.setState(viewId, state); | ||
} | ||
} | ||
|
||
public getState(stateId: string, viewId: string): State | undefined { | ||
return this.getExtendedState(stateId)?.getState(viewId); | ||
} | ||
} |
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