-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,375 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 38 additions & 38 deletions
76
...src/app/aas-provider/aas-index-factory.ts → ...er/src/app/aas-index/aas-index-factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2019-2023 Fraunhofer IOSB-INA Lemgo, | ||
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
* zur Foerderung der angewandten Forschung e.V. | ||
* | ||
*****************************************************************************/ | ||
|
||
import { DependencyContainer } from 'tsyringe'; | ||
import path from 'path'; | ||
import { JSONFile } from 'lowdb/node' | ||
import { Low } from 'lowdb'; | ||
import { AASIndex } from './aas-index.js'; | ||
import { LowDbIndex } from './lowdb/lowdb-index.js'; | ||
import { Variable } from '../variable.js'; | ||
import { LowDbData } from './lowdb/lowdb-types.js'; | ||
import { MySqlIndex } from './mysql/mysql-index.js'; | ||
|
||
export class AASIndexFactory { | ||
constructor( | ||
private readonly container: DependencyContainer | ||
) { } | ||
|
||
public create(): AASIndex { | ||
const variable = this.container.resolve(Variable); | ||
if (variable.AAS_INDEX) { | ||
const url = new URL(variable.AAS_INDEX); | ||
if (url.protocol === 'mysql:') { | ||
return new MySqlIndex(variable); | ||
} | ||
|
||
throw new Error('Not implemented.'); | ||
} | ||
|
||
const dbFile = path.join(variable.CONTENT_ROOT, 'db.json'); | ||
const db = new Low<LowDbData>(new JSONFile(dbFile), { documents: [], endpoints: [], elements: [] }); | ||
return new LowDbIndex(db, variable); | ||
} | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2019-2023 Fraunhofer IOSB-INA Lemgo, | ||
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
* zur Foerderung der angewandten Forschung e.V. | ||
* | ||
*****************************************************************************/ | ||
|
||
import { DependencyContainer } from 'tsyringe'; | ||
import path from 'path'; | ||
import { JSONFile } from 'lowdb/node' | ||
import { Low } from 'lowdb'; | ||
import { AASIndex } from './aas-index.js'; | ||
import { LowDbIndex } from './lowdb/lowdb-index.js'; | ||
import { Variable } from '../variable.js'; | ||
import { LowDbData } from './lowdb/lowdb-types.js'; | ||
import { MySqlIndex } from './mysql/mysql-index.js'; | ||
|
||
export class AASIndexFactory { | ||
constructor( | ||
private readonly container: DependencyContainer | ||
) { } | ||
|
||
public create(): AASIndex { | ||
const variable = this.container.resolve(Variable); | ||
if (variable.AAS_INDEX) { | ||
const url = new URL(variable.AAS_INDEX); | ||
if (url.protocol === 'mysql:') { | ||
return new MySqlIndex(variable); | ||
} | ||
|
||
throw new Error('Not implemented.'); | ||
} | ||
|
||
const dbFile = path.join(variable.CONTENT_ROOT, 'db.json'); | ||
const db = new Low<LowDbData>(new JSONFile(dbFile), { documents: [], endpoints: [], elements: [] }); | ||
return new LowDbIndex(db, variable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2019-2023 Fraunhofer IOSB-INA Lemgo, | ||
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
* zur Foerderung der angewandten Forschung e.V. | ||
* | ||
*****************************************************************************/ | ||
|
||
import { Query, QueryParser } from 'common'; | ||
|
||
export abstract class AASIndexQuery { | ||
protected constructor(query: string, protected readonly language: string) { | ||
this.queryParser = new QueryParser(query, language); | ||
} | ||
|
||
protected readonly queryParser: QueryParser; | ||
|
||
protected isText(value: unknown): value is string { | ||
return typeof value === 'string'; | ||
} | ||
|
||
protected isQuery(value: unknown): value is Query { | ||
return typeof value === 'object' && !Array.isArray(value); | ||
} | ||
} |
Oops, something went wrong.