Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate simple SPARQL SELECT queries #6

Open
lecoqlibre opened this issue Mar 15, 2024 · 0 comments
Open

Generate simple SPARQL SELECT queries #6

lecoqlibre opened this issue Mar 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@lecoqlibre
Copy link
Collaborator

lecoqlibre commented Mar 15, 2024

In order to query and find data, we should be able to generate a simple SPARQL SELECT query.

This query should support WHERE parameters constructed from the semantic properties.

To do so, we could define a SparqlQueryParameter interface like:

interface SparqlQueryParameter {
    property: string;
    values: string[] | Semanticable[];
}

Then the method could take the form of a static method getSparqlSelectQuery(parameters?: SparqlQueryParameter[]).

Maybe this should not be part of the SemanticObject class? The Decorator design pattern could also be used.

Note: we don't to generate SPARQL queries in the connector codegen to keep it simple. It's better to have this is Semantizer.

Use object as criteria

In the SemanticObject class we could have a find method:

SemanticObject.find() {
    // 1. Generate the SPARQL from all the semantic properties of the object.
    // 2. Create a cancel-able command containing the SPARQL.
    // 3. Send the command to the query planner.
}

Then we can create semantic objects for finding:

new SemanticObject(params...).find()

--> PB when we want to query several values for a property with only one value allowed.

Use findBy methods

Create findBy... methods like:

public static async Catalog.findByMaintainer(connector: IConnector, maintainer: Semanticable callback: Function): Promise<void> {
    return connector.find(Catalog.TYPE, maintainer, callback);
}

public async Connector.findCatalogByMaintainer(maintainer: Semanticable, callback: Function): Promise<void> {
    return this.getSemantizer().find("dfc-b:Catalog", "dfc-b:maintainedBy", maintainer, callback);
}

// Or with collections:
Connector.catalog.findByMaintainer();
Connector.address.findByCountry();
@lecoqlibre lecoqlibre added the enhancement New feature or request label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant