Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Create graph with all change report entities
Browse files Browse the repository at this point in the history
  • Loading branch information
reeckset committed Apr 15, 2021
1 parent e86065b commit e44c28f
Show file tree
Hide file tree
Showing 62 changed files with 19,918 additions and 24,560 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { SerializationClasses } from "../export/serialization-classes";
import { SerializedChangeAnalysisReport } from "../export/serialized-interfaces/serialized-change-analysis-report";
import { Aggregation, aggregationSerializer } from "../aggregations";
import { ComponentOperation, InfraModelDiff } from "../model-diffing";
import * as fn from 'fifinet';
import { ModelEntity } from "../infra-model/model-entity";

export class ChangeAnalysisReport implements JSONSerializable {

Expand Down Expand Up @@ -30,5 +32,15 @@ export class ChangeAnalysisReport implements JSONSerializable {
getSerializationClass(): string {
return SerializationClasses.CHANGE_ANALYSIS_REPORT;
}

generateGraph() {
const entities: ModelEntity[] = [...new Set([
...this.infraModelDiff.componentOperations.flatMap(op => op.explodeNodeReferences()),
...this.infraModelDiff.infraModelTransition.v1?.components.flatMap(op => op.explodeNodeReferences()) ?? [],
...this.infraModelDiff.infraModelTransition.v2?.components.flatMap(op => op.explodeNodeReferences()) ?? []
])];

return new fn.Graph(entities.map(e => e.nodeData), entities.flatMap(e => e.getOutgoingNodeEdges()));
}

}
2 changes: 1 addition & 1 deletion src/change-analysis-models/export/deserializer-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { structuralRelationshipDeserializer } from './deserializers/infra-model/
import { infraModelDeserializer } from './deserializers/infra-model/infra-model-deserializer';
import { componentPropertyArrayDeserializer, componentPropertyEmptyDeserializer, componentPropertyPrimitiveDeserializer, componentPropertyRecordDeserializer } from './deserializers/infra-model/component-property-deserializer';
import { infraModelDiffDeserializer } from './deserializers/infra-model-diff/infra-model-diff-deserializer';
import { transitionDeserializer } from './deserializers/infra-model-diff/transition-deserializer';
import { SerializationID } from './json-serializer';
import { JSONSerializable, Serialized } from './json-serializable';
import { aggregationDeserializer } from './deserializers/aggregations/aggregation-deserializer';
import { transitionDeserializer } from './deserializers/transition-deserializer';
import { changeAnalysisReportDeserializer } from './deserializers/change-analysis-report-deserializer';

type classDeserializer = (obj: Serialized, deserialize: (id: SerializationID) => JSONSerializable) => any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,46 @@
import { Component } from "../../../../infra-model";
import {
InsertComponentOperation,
RemoveComponentOperation,
RenameComponentOperation,
ReplaceComponentOperation,
Transition
} from "../../../../model-diffing/";
import { JSONSerializable, Serialized } from "../../../json-serializable";
import { SerializationID } from "../../../json-serializer";
import { SerializedComponentOperation } from "../../../serialized-interfaces/infra-model-diff/serialized-component-operation";
import { deserializeComponentOperationOptions } from "./utils";
import { deserializeOpNodeData, deserializeOpOutoingNodeReferences } from "./utils";

export function insertComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v2)
throw Error("Insert Component Operation does not have a new Component");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new InsertComponentOperation(componentTransition.v2, options);
return new InsertComponentOperation(
deserializeOpNodeData(serialized),
deserializeOpOutoingNodeReferences(serialized, deserialize),
);
}

export function removeComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v1)
throw Error("Remove Component Operation does not have an old Component");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new RemoveComponentOperation(componentTransition.v1, options);
return new RemoveComponentOperation(
deserializeOpNodeData(serialized),
deserializeOpOutoingNodeReferences(serialized, deserialize),
);
}

export function replaceComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v1 || !componentTransition.v2)
throw Error("Replace Component Operation does not have both Components");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new ReplaceComponentOperation(componentTransition, options);
return new ReplaceComponentOperation(
deserializeOpNodeData(serialized),
deserializeOpOutoingNodeReferences(serialized, deserialize),
);
}

export function renameComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v1 || !componentTransition.v2)
throw Error("Rename Component Operation does not have both Components");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new RenameComponentOperation(componentTransition, options);
return new RenameComponentOperation(
deserializeOpNodeData(serialized),
deserializeOpOutoingNodeReferences(serialized, deserialize),
);
}
Original file line number Diff line number Diff line change
@@ -1,83 +1,45 @@
import { Component, ComponentProperty } from "../../../../infra-model";
import {
InsertPropertyComponentOperation,
MovePropertyComponentOperation,
PropertyComponentOperation,
RemovePropertyComponentOperation,
UpdatePropertyComponentOperation,
Transition
} from "../../../../model-diffing/";
import { JSONSerializable, Serialized } from "../../../json-serializable";
import { SerializationID } from "../../../json-serializer";
import { SerializedPropertyComponentOperation, SerializedUpdatePropertyComponentOperation } from "../../../serialized-interfaces/infra-model-diff/serialized-component-operation";
import { deserializeComponentOperationOptions } from "./utils";
import { SerializedPropertyComponentOperation } from "../../../serialized-interfaces/infra-model-diff/serialized-component-operation";
import { deserializeOpNodeData, deserializePropOpOutoingNodeReferences, deserializeUpdatePropOpOutoingNodeReferences } from "./utils";

export function insertPropertyComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedPropertyComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v2 || !componentTransition.v1)
throw Error("'Insert Property' Component Operation does not have both Component versions");

const pathTransition = serialized.pathTransition;
const propertyTransition = deserialize(serialized.propertyTransition) as Transition<ComponentProperty>;

if(!pathTransition.v2 || !propertyTransition.v2)
throw Error("'Insert Property' Component Operation does not have new property and its path");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new InsertPropertyComponentOperation(pathTransition, propertyTransition, componentTransition, options);
return new InsertPropertyComponentOperation(
deserializeOpNodeData(serialized),
deserializePropOpOutoingNodeReferences(serialized, deserialize),
);
}

export function removePropertyComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedPropertyComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v2 || !componentTransition.v1)
throw Error("'Remove Property' Component Operation does not have both Component versions");

const pathTransition = serialized.pathTransition;
const propertyTransition = deserialize(serialized.propertyTransition) as Transition<ComponentProperty>;
if(!pathTransition.v1 || !propertyTransition.v1)
throw Error("'Remove Property' Component Operation does not have an old property and its path");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new RemovePropertyComponentOperation(pathTransition, propertyTransition, componentTransition, options);
return new RemovePropertyComponentOperation(
deserializeOpNodeData(serialized),
deserializePropOpOutoingNodeReferences(serialized, deserialize),
);
}

export function movePropertyComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedPropertyComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v2 || !componentTransition.v1)
throw Error("'Move Property' Component Operation does not have both Component versions");

const pathTransition = serialized.pathTransition;
const propertyTransition = deserialize(serialized.propertyTransition) as Transition<ComponentProperty>;
if(!pathTransition.v1 || !propertyTransition.v1)
throw Error("'Move Property' Component Operation does not have both property and path versions");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new MovePropertyComponentOperation(pathTransition, propertyTransition, componentTransition, options);
return new MovePropertyComponentOperation(
deserializeOpNodeData(serialized),
deserializePropOpOutoingNodeReferences(serialized, deserialize),
);
}

export function updatePropertyComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedUpdatePropertyComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v2 || !componentTransition.v1)
throw Error("'Update Property' Component Operation does not have both Component versions");

const pathTransition = serialized.pathTransition;
const propertyTransition = deserialize(serialized.propertyTransition) as Transition<ComponentProperty>;
if(!pathTransition.v1 || !propertyTransition.v1)
throw Error("'Update Property' Component Operation does not have both property and path versions");

const options = deserializeComponentOperationOptions(serialized, deserialize);
const innerOperations = serialized.innerOperations ? serialized.innerOperations.map(deserialize) as PropertyComponentOperation[] : undefined;
const serialized = obj as SerializedPropertyComponentOperation;

return new UpdatePropertyComponentOperation(pathTransition, propertyTransition, componentTransition, options, innerOperations);
return new MovePropertyComponentOperation(
deserializeOpNodeData(serialized),
deserializeUpdatePropOpOutoingNodeReferences(serialized, deserialize),
);
}
Original file line number Diff line number Diff line change
@@ -1,60 +1,37 @@
import { Component, Relationship } from "../../../../infra-model";
import {
InsertOutgoingRelationshipComponentOperation,
RemoveOutgoingRelationshipComponentOperation,
UpdateOutgoingRelationshipComponentOperation,
Transition
} from "../../../../model-diffing/";
import { } from "../../../../model-diffing/";
import { JSONSerializable, Serialized } from "../../../json-serializable";
import { SerializationID } from "../../../json-serializer";
import { SerializedOutgoingRelationshipComponentOperation } from "../../../serialized-interfaces/infra-model-diff/serialized-component-operation";
import { deserializeComponentOperationOptions } from "./utils";
import { deserializeOpNodeData, deserializeRelationshipOpOutoingNodeReferences } from "./utils";

export function insertOutgoingRelationshipComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedOutgoingRelationshipComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v1 || !componentTransition.v2)
throw Error("'Insert Outgoing Relationship' Component Operation does not have both Components");

const relationshipTransition = deserialize(serialized.relationshipTransition) as Transition<Relationship>;
if(!relationshipTransition.v2)
throw Error("'Insert Outgoing Relationship' Component Operation does not have new Relationship");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new InsertOutgoingRelationshipComponentOperation(componentTransition, relationshipTransition.v2, options);
return new InsertOutgoingRelationshipComponentOperation(
deserializeOpNodeData(serialized),
deserializeRelationshipOpOutoingNodeReferences(serialized, deserialize),
);
}

export function removeOutgoingRelationshipComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedOutgoingRelationshipComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v1 || !componentTransition.v2)
throw Error("'Remove Outgoing Relationship' Component Operation does not have both Components");

const relationshipTransition = deserialize(serialized.relationshipTransition) as Transition<Relationship>;
if(!relationshipTransition.v1)
throw Error("'Remove Outgoing Relationship' Component Operation does not have new Relationship");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new RemoveOutgoingRelationshipComponentOperation(componentTransition, relationshipTransition.v1, options);
return new RemoveOutgoingRelationshipComponentOperation(
deserializeOpNodeData(serialized),
deserializeRelationshipOpOutoingNodeReferences(serialized, deserialize),
);
}

export function updateOutgoingRelationshipComponentOperationDeserializer(obj: Serialized, deserialize: (obj: SerializationID) => JSONSerializable): JSONSerializable {
const serialized = obj as SerializedOutgoingRelationshipComponentOperation;

const componentTransition = deserialize(serialized.componentTransition) as Transition<Component>;
if(!componentTransition.v1 || !componentTransition.v2)
throw Error("'Update Outgoing Relationship' Component Operation does not have both Components");

const relationshipTransition = deserialize(serialized.relationshipTransition) as Transition<Relationship>;
if(!componentTransition.v1 || !componentTransition.v2)
throw Error("'Update Outgoing Relationship' Component Operation does not have new Relationship");

const options = deserializeComponentOperationOptions(serialized, deserialize);

return new UpdateOutgoingRelationshipComponentOperation(componentTransition, relationshipTransition, options);
return new UpdateOutgoingRelationshipComponentOperation(
deserializeOpNodeData(serialized),
deserializeRelationshipOpOutoingNodeReferences(serialized, deserialize),
);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import { ComponentOperation, ComponentOperationOptions, OperationCertainty } from "../../../../model-diffing/";
import { Component, ComponentProperty, PropertyPath, Relationship } from "../../../../infra-model";
import { ComponentOperation, OperationCertainty, OpNodeData, OpOutgoingNodeReferences, PropertyComponentOperation, PropOpOutgoingNodeReferences, RelationshipOpOutgoingNodeReferences, Transition, UpdatePropOpOutgoingNodeReferences } from "../../../../model-diffing/";
import { JSONSerializable } from "../../../json-serializable";
import { SerializationID } from "../../../json-serializer";
import { SerializedComponentOperation } from "../../../serialized-interfaces/infra-model-diff/serialized-component-operation";
import { SerializedComponentOperation, SerializedOutgoingRelationshipComponentOperation, SerializedPropertyComponentOperation, SerializedUpdatePropertyComponentOperation } from "../../../serialized-interfaces/infra-model-diff/serialized-component-operation";

export function deserializeComponentOperationOptions(serialized: SerializedComponentOperation, deserialize: (obj: SerializationID) => JSONSerializable): ComponentOperationOptions {
export function deserializeOpNodeData(serialized: SerializedComponentOperation): OpNodeData {
return {
cause: serialized.cause ? deserialize(serialized.cause) as ComponentOperation : undefined,
certainty: OperationCertainty[serialized.certainty as keyof typeof OperationCertainty],
};
}

export function deserializeOpOutoingNodeReferences(serialized: SerializedComponentOperation, deserialize: (obj: SerializationID) => JSONSerializable): OpOutgoingNodeReferences {
return {
cause: serialized.cause ? deserialize(serialized.cause) as ComponentOperation : undefined,
componentTransition: deserialize(serialized.componentTransition) as Transition<Component>,
};
}

// OutgoingRelationshipComponentOperations

export function deserializeRelationshipOpOutoingNodeReferences(serialized: SerializedOutgoingRelationshipComponentOperation, deserialize: (obj: SerializationID) => JSONSerializable): RelationshipOpOutgoingNodeReferences {
return {
...deserializeOpOutoingNodeReferences(serialized, deserialize),
relationshipTransition: deserialize(serialized.relationshipTransition) as Transition<Relationship>,
};
}

// PropertyComponentOperations

export function deserializePropOpOutoingNodeReferences(serialized: SerializedPropertyComponentOperation, deserialize: (obj: SerializationID) => JSONSerializable): PropOpOutgoingNodeReferences {
return {
...deserializeOpOutoingNodeReferences(serialized, deserialize),
pathTransition: deserialize(serialized.pathTransition) as Transition<PropertyPath>,
propertyTransition: deserialize(serialized.propertyTransition) as Transition<ComponentProperty>,
};
}

export function deserializeUpdatePropOpOutoingNodeReferences(serialized: SerializedUpdatePropertyComponentOperation, deserialize: (obj: SerializationID) => JSONSerializable): UpdatePropOpOutgoingNodeReferences {
return {
...deserializePropOpOutoingNodeReferences(serialized, deserialize),
innerOperations: serialized.innerOperations ? serialized.innerOperations.map(deserialize) as PropertyComponentOperation[] : undefined,
};
}
Loading

0 comments on commit e44c28f

Please sign in to comment.