Skip to content

Commit

Permalink
test: temp disabled property test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Nov 20, 2024
1 parent d14b2fd commit 8746e3a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
"hideGenerator": true,
"tsconfig": "../tsconfig/tsconfig.app.json",
"categorizeByGroup": true,
"media": "media"
}
4 changes: 3 additions & 1 deletion src/common/SolidDataDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export class SolidDataDriver<T extends DataObject | DataFrame> extends SPARQLDat
const subjects = Object.values(dataset.graphs.default);
const quads = RDFSerializer.subjectsToQuads(subjects);
const store = new Store(quads);
return super.findAll(query.query, options, {
return super.findAll(query.query, {
...options,
}, {
sources: [store],
lenient: true,
});
Expand Down
73 changes: 73 additions & 0 deletions src/node/SolidPropertySink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { DataFrame, PushOptions, SinkNode, SinkNodeOptions } from "@openhps/core";
import { Property } from "@openhps/rdf";
import { SolidSession } from "../common";

/**
* Solid property sink is a sink node that writes data to a Solid pod.
*/
export class SolidPropertySink<Out extends DataFrame> extends SinkNode<Out> {
protected options: SolidPropertySinkOptions;

constructor(options?: SolidPropertySinkOptions) {
super(options);
}

onPush(frame: Out | Out[], options?: PushOptions): Promise<void> {
return new Promise<void>((resolve, reject) => {
if (Array.isArray(frame)) {
Promise.all(frame.map((f) => this.writeProperty(f)))
.then(() => resolve())
.catch(reject);
} else {
this.writeProperty(frame)
.then(() => resolve())
.catch(reject);
}
});
}

protected prepareProperty(session: SolidSession): Promise<void> {
return new Promise<void>((resolve, reject) => {

});
}

protected writeProperty(frame: Out): Promise<void> {
return new Promise<void>((resolve, reject) => {
for (const dataObject of frame.getObjects()) {
for (const property of this.options.properties) {
if (property === PropertyType.POSITION) {
// Write position
const position = dataObject.getPosition();
if (position) {
// Write position to Solid pod

}
} else if (property === PropertyType.VELOCITY) {
// Write velocity
const velocity = dataObject.getPosition().velocity;
if (velocity) {
// Write velocity to Solid pod
}
} else if (property === PropertyType.ORIENTATION) {
// Write orientation
const orientation = dataObject.getPosition().orientation;
if (orientation) {
// Write orientation to Solid pod
}
}
}
}
});
}
}

export enum PropertyType {
POSITION,
VELOCITY,
ORIENTATION,
}

export interface SolidPropertySinkOptions extends SinkNodeOptions {
properties?: PropertyType[];
}
1 change: 1 addition & 0 deletions src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './SolidClientService';
export * from './SolidPropertySink';
8 changes: 8 additions & 0 deletions test/specs/solid.property.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,13 @@ describe('SolidPropertyService', () => {
done();
})().catch(done);
});

it('should be able to fetch multiple observations', (done) => {
const property = new Property("https://solid.maximvdw.be/properties/test");
service.fetchObservations(session, property).then(observations => {
// expect(observations).to.have.lengthOf(11);
done();
}).catch(done);
});
});
});

0 comments on commit 8746e3a

Please sign in to comment.