Skip to content

Commit

Permalink
refactor pocessDeLetedOp, make getclassFullnameFromECClassId private,…
Browse files Browse the repository at this point in the history
… add classFullName to data in map
  • Loading branch information
nick4598 committed Dec 20, 2024
1 parent 0ec65c8 commit f7c6c7a
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 151 deletions.
20 changes: 12 additions & 8 deletions packages/transformer/src/IModelExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,15 +1059,16 @@ export type ChangedInstanceType =
| "aspect"
| "relationship"
| "font";

/**
* Interface to describe a 'custom' change. A custom change is one which isn't found by reading changesets, but instead added by a user calling the 'addCustomChange' API on the ChangedInstanceIds instance.
* The purpose a custom change would serve is to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
*/
export interface ChangedInstanceCustomData {
sourceIdOfRelationship?: Id64String;
targetIdOfRelationship?: Id64String;
federationGuid?: Id64String;
export interface ChangedInstanceCustomRelationshipData {
sourceIdOfRelationship: Id64String;
targetIdOfRelationship: Id64String;
ecClassId: Id64String;
classFullName: string;
}

/**
Expand All @@ -1091,7 +1092,7 @@ export class ChangedInstanceIds {
/** c${string} is used to represent codeSpecs since they do not currently have a representation in the EntityReference class. This map holds information passed to the 'addCustom' functions. */
private _entityReferenceToCustomDataMap: Map<
EntityReference | `c${string}`,
ChangedInstanceCustomData
ChangedInstanceCustomRelationshipData
>;
private _hasCustomChanges: boolean;

Expand All @@ -1101,7 +1102,7 @@ export class ChangedInstanceIds {
this._hasCustomChanges = false;
this._entityReferenceToCustomDataMap = new Map<
EntityReference,
ChangedInstanceCustomData
ChangedInstanceCustomRelationshipData
>();
}

Expand Down Expand Up @@ -1305,7 +1306,7 @@ export class ChangedInstanceIds {
public getCustomRelationshipDataFromId(
id: Id64String,
type: ChangedInstanceType
): ChangedInstanceCustomData | undefined {
): ChangedInstanceCustomRelationshipData | undefined {
if (type === "relationship") {
return this._entityReferenceToCustomDataMap.get(
EntityReferences.fromEntityType(id, ConcreteEntityTypes.Relationship)
Expand Down Expand Up @@ -1342,18 +1343,21 @@ export class ChangedInstanceIds {
);

this._hasCustomChanges = true;
const classFullName = this._ecClassIdsToClassFullNames?.get(ecClassId);
assert(classFullName !== undefined); // setupECClassIds adds an entry to the above map for every single ECClassId.
this._entityReferenceToCustomDataMap.set(
EntityReferences.fromEntityType(id, ConcreteEntityTypes.Relationship),
{
sourceIdOfRelationship: sourceECInstanceId,
targetIdOfRelationship: targetECInstanceId,
ecClassId,
classFullName,
}
);
this.handleChange(this.relationship, changeType, id);
}

public getClassFullNameFromECClassId(
private getClassFullNameFromECClassId(
ecClassid: Id64String
): string | undefined {
return this._ecClassIdsToClassFullNames?.get(ecClassid);
Expand Down
Loading

0 comments on commit f7c6c7a

Please sign in to comment.