Skip to content

Commit

Permalink
Added filepath in entity data map (#732)
Browse files Browse the repository at this point in the history
* Added filepath in entity data map

* added filepath to corresponding entity id while creating files for vscode web

* made filepaths of type Set in Entity Map, and moved setting filepath logic from remotefetchprovider to entityDataMap
  • Loading branch information
ritikramuka authored Oct 18, 2023
1 parent ad8f0be commit d744746
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/web/client/WebExtensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,17 @@ class WebExtensionContext implements IWebExtensionContext {
odataEtag: string,
attributePath: IAttributePath,
attributeContent: string,
mappingEntityId?: string
mappingEntityId?: string,
fileUri?: string
) {
this.entityDataMap.setEntity(
entityId,
entityName,
odataEtag,
attributePath,
attributeContent,
mappingEntityId);
mappingEntityId,
fileUri);
}

public async updateSingleFileUrisInContext(uri: vscode.Uri) {
Expand Down Expand Up @@ -606,7 +608,7 @@ class WebExtensionContext implements IWebExtensionContext {
}

/**
* Store a value maintained in Extension context workspaceState.
* Store a value maintained in Extension context workspaceState.
*
* *Note* that using `undefined` as value removes the key from the underlying
* storage.
Expand Down
9 changes: 8 additions & 1 deletion src/web/client/context/entityData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface IEntityData extends IEntityInfo {
entityEtag: string;
entityColumn: Map<string, string | Uint8Array>;
mappingEntityId?: string;
filePath?: Set<string>
}

export class EntityData implements IEntityData {
Expand All @@ -17,6 +18,7 @@ export class EntityData implements IEntityData {
private _entityEtag!: string;
private _entityColumn!: Map<string, string | Uint8Array>;
private _mappingEntityId?: string;
private _filePath?: Set<string>;

public get entityName(): string {
return this._entityName;
Expand All @@ -33,6 +35,9 @@ export class EntityData implements IEntityData {
public get mappingEntityId(): string | undefined {
return this._mappingEntityId;
}
public get filePath(): Set<string> | undefined {
return this._filePath;
}

// Setters
public set setEntityEtag(value: string) {
Expand All @@ -44,12 +49,14 @@ export class EntityData implements IEntityData {
entityName: string,
entityEtag: string,
entityColumn: Map<string, string | Uint8Array>,
mappingEntityId?: string
mappingEntityId?: string,
filePath?: Set<string>
) {
this._entityId = entityId;
this._entityName = entityName;
this._entityEtag = entityEtag;
this._entityColumn = entityColumn;
this._mappingEntityId = mappingEntityId;
this._filePath = filePath;
}
}
11 changes: 9 additions & 2 deletions src/web/client/context/entityDataMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class EntityDataMap {
odataEtag: string,
attributePath: IAttributePath,
attributeContent: string,
mappingEntityId?: string
mappingEntityId?: string,
fileUri?: string
) {
let entityColumnMap = new Map<string, string | Uint8Array>();
const existingEntity = this.entityMap.get(entityId);
Expand All @@ -44,12 +45,18 @@ export class EntityDataMap {
}
entityColumnMap.set(attributePath.source, attributeContent);

const filePath = this.entityMap.get(entityId)?.filePath ?? new Set();
if (fileUri) {
filePath.add(fileUri);
}

const entityData = new EntityData(
entityId,
entityName,
odataEtag,
entityColumnMap,
mappingEntityId
mappingEntityId,
filePath
);
this.entityMap.set(entityId, entityData);
}
Expand Down
3 changes: 2 additions & 1 deletion src/web/client/dal/remoteFetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ async function createVirtualFile(
odataEtag,
attributePath,
originalAttributeContent,
mappingEntityId
mappingEntityId,
fileUri,
);
}

0 comments on commit d744746

Please sign in to comment.