Skip to content

Commit

Permalink
Tests and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Jan 9, 2024
1 parent c1d1133 commit c3447a3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/data/src/DataModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class DataModel extends Component {
}
}
}
dataObject = new DataObject(this.data, this, id, dataObjectParams.name, dataObjectParams.description, dataObjectParams.type, propertySets);
dataObject = new DataObject(this.data, this, id, dataObjectParams.originalSystemId, dataObjectParams.name, dataObjectParams.description, dataObjectParams.type, propertySets);
this.objects[id] = dataObject;
this.data.objects[id] = dataObject;
if (!this.data.objectsByType[type]) {
Expand Down Expand Up @@ -549,23 +549,24 @@ export class DataModel extends Component {
dataModelParams.propertySets?.push(propertySetParams);
}
for (let id in this.objects) {
const object = this.objects[id];
const objectParams = <DataObjectParams>{
const dataObject = this.objects[id];
const dataObjectParams = <DataObjectParams>{
id,
type: object.type,
name: object.name,
originalSystemId: dataObject.originalSystemId,
type: dataObject.type,
name: dataObject.name,
propertySetIds: []
};
if (object.description !== undefined) {
objectParams.description = object.description;
if (dataObject.description !== undefined) {
dataObjectParams.description = dataObject.description;
}
if (object.propertySets) {
for (let i = 0, len = object.propertySets.length; i < len; i++) {
const propertySet = object.propertySets[i];
objectParams.propertySetIds?.push(propertySet.id);
if (dataObject.propertySets) {
for (let i = 0, len = dataObject.propertySets.length; i < len; i++) {
const propertySet = dataObject.propertySets[i];
dataObjectParams.propertySetIds?.push(propertySet.id);
}
}
dataModelParams.objects?.push(objectParams);
dataModelParams.objects?.push(dataObjectParams);
}
for (let i = 0, len = this.relationships.length; i < len; i++) {
const relationship = this.relationships[i];
Expand Down
8 changes: 8 additions & 0 deletions packages/data/src/DataObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export class DataObject {
*/
public readonly id: string;

/**
* ID of this DataObject within the originating system, is any. Defaults to the value of
* {@link @xeokit/data!DataObject.id | DataObject.id}.
*/
originalSystemId?: string;

/**
* Human-readable name.
*/
Expand Down Expand Up @@ -75,6 +81,7 @@ export class DataObject {
data: Data,
model: DataModel,
id: string,
originalSysteId: string,
name: string,
description: string | undefined,
type: number,
Expand All @@ -83,6 +90,7 @@ export class DataObject {
this.data = data;
this.models = [model];
this.id = id;
this.originalSystemId = originalSysteId || id;
this.name = name;
this.description = description;
this.type = type;
Expand Down
6 changes: 6 additions & 0 deletions packages/data/src/DataObjectParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export interface DataObjectParams {
*/
id: string;

/**
* ID of this DataObject within the originating system, is any. Defaults to the value of
* {@link @xeokit/data!DataObject.id | DataObject.id}.
*/
originalSystemId?: string;

/**
* The {@link @xeokit/data!DataObject} type.
*/
Expand Down

0 comments on commit c3447a3

Please sign in to comment.