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

Add missing quantitykind constants #103

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Add quantitykind constants for those quantitykinds that are defined in the currency file in QUDT.

## [6.8.0] - 2024-12-11

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ConstantsGenerator {
// input data
private static final String DATA_UNITS = "qudtlib/qudt-units.ttl";
private static final String DATA_QUANTITYKINDS = "qudtlib/qudt-quantitykinds.ttl";
private static final String DATA_CURRENCY = "qudtlib/qudt-currency.ttl";
private static final String DATA_PREFIXES = "qudtlib/qudt-prefixes.ttl";
private static final String DATA_SYSTEMS_OF_UNITS = "qudtlib/qudt-systems-of-units.ttl";
private static final String DATA_PHYSICAL_CONSTANTS = "qudtlib/qudt-constants.ttl";
Expand Down Expand Up @@ -109,12 +110,15 @@ private void generatePhysicalConstantConstants(Configuration config)
generateJavaFile(config, templateVars, "PhysicalConstant", "PhysicalConstants");
}

private Map<String, Object> getConstantNamesByQuery(String queryFile, String dataFile) {
private Map<String, Object> getConstantNamesByQuery(String queryFile, String... dataFiles) {
String queryStr = RdfOps.loadQuery(queryFile);
Repository repo = new SailRepository(new MemoryStore());
Map<String, Object> templateVars = new HashMap<>();
try (RepositoryConnection con = repo.getConnection()) {
RdfOps.addStatementsFromFile(con, dataFile);
for (int i = 0; i < dataFiles.length; i++) {
String dataFile = dataFiles[i];
RdfOps.addStatementsFromFile(con, dataFile);
}
TupleQuery query;
try {
query = con.prepareTupleQuery(queryStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class DataGenerator {
private static final String IS_SCALING_OF_QUERY = "isScalingOf.rq";
private static final String MISSING_UNITS_QUERY = "missing-units.rq";
private static final String DELETE_KILOGM_SCALINGS_QUERY = "delete-kiloGM-scalings.rq";
private static final String DELETE_UNITS_QUERY = "delete-units.rq";

private static final String DELETE_FROM_UNITS_BY_QUERY_PATTERN =
"delete-from-units-by-query[N].rq";
Expand Down Expand Up @@ -136,6 +137,8 @@ private void processQuantityKinds() {
Repository outputRepo = new SailRepository(new MemoryStore());
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
RdfOps.addStatementsFromFile(outputCon, QUANTITYKINDS_FILE);
RdfOps.addStatementsFromFile(outputCon, CURRENCIES_FILE);
RdfOps.updateDataUsingQuery(outputCon, DELETE_UNITS_QUERY);
// remove unwanted individual triples
RdfOps.updateDataUsingNQueries(
outputCon, DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
Expand Down
17 changes: 17 additions & 0 deletions qudtlib-data-gen/src/main/resources/delete-units.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX unit: <http://qudt.org/vocab/unit/>
PREFIX prefix: <http://qudt.org/vocab/prefix/>
PREFIX kind: <http://qudt.org/vocab/quantitykind/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

DELETE {
?unit ?p ?o.
}
where
{
?unit a qudt:Unit;
?p ?o .
}



4 changes: 4 additions & 0 deletions qudtlib-js-gen/src/main/resources/template/units.ts.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ for (const unit of config.units.values()){
for (const x of config.systemsOfUnits.values()) {
Object.freeze(x);
}
config.indexUnitsByDimensionVector();
for (const x of config.unitsByDimensionVector.values()) {
Object.freeze(x);
}
Object.freeze(Units);
Object.freeze(QuantityKinds);
Object.freeze(Prefixes);
Expand Down
Loading