Skip to content

Commit

Permalink
Merge pull request #11 from culturecreates/feature/recon
Browse files Browse the repository at this point in the history
Feature/recon
  • Loading branch information
sahalali authored Apr 15, 2024
2 parents 87a05b7 + 8f2b179 commit 27ec95e
Show file tree
Hide file tree
Showing 29 changed files with 358 additions and 53 deletions.
86 changes: 75 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.3.1",
"axios": "^1.6.8",
"dotenv": "^16.4.5",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
Expand Down
19 changes: 15 additions & 4 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { Module } from "@nestjs/common";
import { AppController } from "./controller/app.controller";
import { AppService } from "./service/app.service";
import { ManifestController, ReconciliationController } from "./controller";
import { ManifestService, ReconciliationService } from "./service";
import { ArtsdataService } from "./service/artsdata";
import { HttpService } from "./service/http";

@Module({
imports: [],
controllers: [AppController],
providers: [AppService]
controllers: [
ManifestController,
ReconciliationController
],
providers: [
ManifestService,
ReconciliationService,
ArtsdataService,
HttpService

]
})
export class AppModule {
}
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './system.config';
8 changes: 8 additions & 0 deletions src/config/system.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as dotenv from "dotenv";

dotenv.config();
const { env } = process;

export const ARTSDATA: { ENDPOINT: string } = {
ENDPOINT: env.ARTSDATA_ENDPOINT || "https://db.artsdata.ca/"
};
42 changes: 42 additions & 0 deletions src/constant/recon-queries.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export const QUERIES = {

RECONCILITAION_QUERY:`
PREFIX luc: <http://www.ontotext.com/owlim/lucene#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
SELECT
?originalUri
?score (sample(?names) as ?name)
(sample(?disambiguatingDescriptions) as ?disambiguatingDescription)
?type
?typeLabel
WHERE {
values ?query { "QUERY_PLACE_HOLDER" }
values ?type { TYPE_PLACE_HOLDER }
?originalUri a ?type ;
luc:Name ?query;
rdfs:label ?names ;
luc:score ?score .
FILTER (STRSTARTS(STR(?originalUri),"http://kg.artsdata.ca/resource/K" ))
OPTIONAL {
?originalUri schema:disambiguatingDescription ?disambiguatingDescriptions .
}
OPTIONAL {
?type rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "")
}
OPTIONAL {
?type rdfs:label ?type_label_en filter(lang(?type_label_en) = "en")
}
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?typeLabel)
} GROUP BY ?originalUri ?score ?type ?typeLabel
`



};
23 changes: 0 additions & 23 deletions src/controller/app.controller.spec.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/controller/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./manifest"
export * from "./recon"
1 change: 1 addition & 0 deletions src/controller/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./manifest.controller"
23 changes: 23 additions & 0 deletions src/controller/manifest/manifest.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Test, TestingModule } from "@nestjs/testing";
import { ManifestController } from "./manifest.controller";
import * as MANIFEST from "../../constant/manifest.constant.json";
import { ManifestService } from "../../service";

describe('ManifestController', () => {
let manifestController: ManifestController;

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [ManifestController],
providers: [ManifestService]
}).compile();

manifestController = app.get<ManifestController>(ManifestController);
});

describe("manifest", () => {
it("should return Service Manifest", () => {
expect(manifestController.getServiceManifest()).toBe(MANIFEST);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Controller, Get } from "@nestjs/common";
import { AppService } from "../service/app.service";
import { ManifestService } from "../../service/manifest/manifest.service";
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
import { ServiceManifestResponse } from "../dto/manifest.dto";
import { ServiceManifestResponse } from "../../dto/manifest.dto";

@Controller()
@ApiTags("APIs")
export class AppController {
constructor(private readonly appService: AppService) {
export class ManifestController {
constructor(private readonly appService: ManifestService) {
}

@Get()
Expand Down
1 change: 1 addition & 0 deletions src/controller/recon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./recon.controller"
37 changes: 37 additions & 0 deletions src/controller/recon/recon.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Controller, Get, Query } from "@nestjs/common";
import { ApiOperation, ApiQuery, ApiResponse, ApiTags } from "@nestjs/swagger";
import { ReconciliationResponse } from "../../dto";
import { ReconciliationService } from "../../service";
import { ReconciliationTypesEnum } from "../../enum";

@Controller()
@ApiTags("APIs")
export class ReconciliationController {
constructor(private readonly _reconciliationService: ReconciliationService) {
}

@Get("/recon")
@ApiOperation({ summary: "Reconcile" })
@ApiResponse({ status: 200, type: ReconciliationResponse, isArray: true, description: "Reconciliation response" })
@ApiResponse({ status: 500, description: "Internal server error" })
@ApiQuery({
name: "name",
description: "Name of the entity to reconcile",
required: true,
explode: false,
type: String
})
@ApiQuery({
name: "type",
description: "Type of the entity to reconcile",
required: true,
explode: false,
enum: Object.values(ReconciliationTypesEnum)
})
async reconcile(
@Query("name") name: string,
@Query("type") type: string
): Promise<ReconciliationResponse[]> {
return await this._reconciliationService.reconcile(name, type);
}
}
3 changes: 3 additions & 0 deletions src/dto/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./manifest.dto";
export * from "./recon.dto";

Loading

0 comments on commit 27ec95e

Please sign in to comment.