Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/FraunhoferIOSB/AASPo…
Browse files Browse the repository at this point in the history
…rtal into development
  • Loading branch information
ralfaron committed Jul 23, 2024
2 parents 0869375 + c0e8fc8 commit ebcae3c
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aas-portal-project",
"version": "3.0.0-development.63",
"version": "3.0.0-development.65",
"description": "Web-based visualization and control of asset administration shells.",
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { encodeBase64Url } from '../../convert.js';
import { AASApiClient } from './aas-api-client.js';
import { Logger } from '../../logging/logger.js';
import { JsonWriter } from '../json-writer.js';
import { JsonWriterV3 } from '../json-writer-v3.js';
import * as aasv2 from '../../types/aas-v2.js';
import { JsonReaderV2 } from '../json-reader-v2.js';

Expand Down Expand Up @@ -201,21 +201,21 @@ export class AASApiClientV1 extends AASApiClient {

private async putShellAsync(shell: aas.AssetAdministrationShell): Promise<string> {
const aasId = encodeBase64Url(shell.id);
return await this.message.put(this.resolve(`shells/${aasId}`), new JsonWriter().convert(shell));
return await this.message.put(this.resolve(`shells/${aasId}`), new JsonWriterV3().convert(shell));
}

private async putSubmodelAsync(aasId: string, submodel: aas.Submodel): Promise<string> {
const smId = encodeBase64Url(submodel.id);
return await this.message.put(
this.resolve(`shells/${aasId}/submodels/${smId}`),
new JsonWriter().convert(submodel),
new JsonWriterV3().convert(submodel),
);
}

private async postSubmodelAsync(aasId: string, submodel: aas.Submodel): Promise<string> {
return await this.message.post(
this.resolve(`submodels?aasIdentifier=${aasId}`),
new JsonWriter().convert(submodel),
new JsonWriterV3().convert(submodel),
);
}

Expand All @@ -231,7 +231,7 @@ export class AASApiClientV1 extends AASApiClient {
const path = getIdShortPath(submodelElement);
return await this.message.put(
this.resolve(`submodels/${smId}/submodel-elements/${path}`),
new JsonWriter().convert(submodelElement),
new JsonWriterV3().convert(submodelElement),
);
}

Expand All @@ -243,7 +243,7 @@ export class AASApiClientV1 extends AASApiClient {
const path = getIdShortPath(submodelElement);
return await this.message.post(
this.resolve(`submodels/${smId}/submodel-elements/${path}`),
new JsonWriter().convert(submodelElement),
new JsonWriterV3().convert(submodelElement),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { createReadStream } from 'fs';
import { encodeBase64Url } from '../../convert.js';
import { AASApiClient } from './aas-api-client.js';
import { Logger } from '../../logging/logger.js';
import { JsonReader } from '../json-reader.js';
import { JsonWriter } from '../json-writer.js';
import { JsonReaderV3 } from '../json-reader-v3.js';
import { JsonWriterV3 } from '../json-writer-v3.js';
import { ERRORS } from '../../errors.js';
import {
aas,
Expand Down Expand Up @@ -104,7 +104,7 @@ export class AASApiClientV3 extends AASApiClient {
conceptDescriptions: pagedResult.result,
};

return new JsonReader(sourceEnv).readEnvironment();
return new JsonReaderV3(sourceEnv).readEnvironment();
}

public override getThumbnailAsync(id: string): Promise<NodeJS.ReadableStream> {
Expand Down Expand Up @@ -240,21 +240,21 @@ export class AASApiClientV3 extends AASApiClient {

private async putShellAsync(shell: aas.AssetAdministrationShell): Promise<string> {
const aasId = encodeBase64Url(shell.id);
return await this.message.put(this.resolve(`shells/${aasId}`), new JsonWriter().convert(shell));
return await this.message.put(this.resolve(`shells/${aasId}`), new JsonWriterV3().convert(shell));
}

private async putSubmodelAsync(aasId: string, submodel: aas.Submodel): Promise<string> {
const smId = encodeBase64Url(submodel.id);
return await this.message.put(
this.resolve(`shells/${aasId}/submodels/${smId}`),
new JsonWriter().convert(submodel),
new JsonWriterV3().convert(submodel),
);
}

private async postSubmodelAsync(aasId: string, submodel: aas.Submodel): Promise<string> {
return await this.message.post(
this.resolve(`submodels?aasIdentifier=${aasId}`),
new JsonWriter().convert(submodel),
new JsonWriterV3().convert(submodel),
);
}

Expand All @@ -270,7 +270,7 @@ export class AASApiClientV3 extends AASApiClient {
const path = getIdShortPath(submodelElement);
return await this.message.put(
this.resolve(`submodels/${smId}/submodel-elements/${path}`),
new JsonWriter().convert(submodelElement),
new JsonWriterV3().convert(submodelElement),
);
}

Expand All @@ -282,7 +282,7 @@ export class AASApiClientV3 extends AASApiClient {
const path = getIdShortPath(submodelElement);
return await this.message.post(
this.resolve(`submodels/${smId}/submodel-elements/${path}`),
new JsonWriter().convert(submodelElement),
new JsonWriterV3().convert(submodelElement),
);
}

Expand Down
6 changes: 3 additions & 3 deletions projects/aas-server/src/app/packages/create-json-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { aas } from 'aas-core';
import { AASReader } from './aas-reader.js';
import { JsonReaderV2 } from './json-reader-v2.js';
import { JsonReader } from './json-reader.js';
import { JsonReaderV3 } from './json-reader-v3.js';
import * as aasV2 from '../types/aas-v2.js';

export function createJsonReader(data: object): AASReader {
Expand All @@ -18,11 +18,11 @@ export function createJsonReader(data: object): AASReader {
}

if (isEnvironment(data)) {
return new JsonReader(data);
return new JsonReaderV3(data);
}

if (isSubmodelElement(data)) {
return new JsonReader();
return new JsonReaderV3();
}

if (isSubmodelElementV2(data)) {
Expand Down
4 changes: 2 additions & 2 deletions projects/aas-server/src/app/packages/create-xml-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AASReader } from './aas-reader.js';
import { HTMLDocumentElement } from '../types/html-document-element.js';
import { XmlReaderV1 } from './xml-reader-v1.js';
import { XmlReaderV2 } from './xml-reader-v2.js';
import { XmlReader } from './xml-reader.js';
import { XmlReaderV3 } from './xml-reader-v3.js';

export function createXmlReader(xml: string): AASReader {
const document = new DOMParser().parseFromString(xml);
Expand All @@ -27,7 +27,7 @@ export function createXmlReader(xml: string): AASReader {
}

if (uri === 'https://admin-shell.io/aas/3/0') {
return new XmlReader(document);
return new XmlReaderV3(document);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { AASReader } from '../aas-reader.js';
import { ImageProcessing } from '../../image-processing.js';
import { createXmlReader } from '../create-xml-reader.js';
import { createJsonReader } from '../create-json-reader.js';
import { XmlWriter } from '../xml-writer.js';
import { XmlWriterV3 } from '../xml-writer-v3.js';

export class AasxPackage extends AASPackage {
private readonly file: string;
Expand Down Expand Up @@ -73,7 +73,7 @@ export class AasxPackage extends AASPackage {
}

public override async setEnvironmentAsync(env: aas.Environment): Promise<string[]> {
const writer = new XmlWriter();
const writer = new XmlWriterV3();
const xml = writer.write(env);
const path = await this.getOriginNameAsync();
(await this.zip).file(path, xml, { compression: 'DEFLATE' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { aas, determineType, extensionToMimeType, isIdentifiable } from 'aas-cor
import cloneDeep from 'lodash-es/cloneDeep.js';
import { encodeBase64Url } from '../convert.js';

export class JsonReader extends AASReader {
export class JsonReaderV3 extends AASReader {
private readonly origin: aas.Environment;

public constructor(origin?: aas.Environment | string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { aas, extensionToMimeType } from 'aas-core';
import { AASWriter } from './aas-writer.js';

/** */
export class JsonWriter extends AASWriter {
export class JsonWriterV3 extends AASWriter {
public override write(env: aas.Environment): string {
const data: aas.Environment = {
assetAdministrationShells: this.writeAssetAdministrationShells(env),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DOMParser } from '@xmldom/xmldom';
import { AASReader } from './aas-reader.js';
import { HTMLDocumentElement } from '../types/html-document-element.js';

export class XmlReader extends AASReader {
export class XmlReaderV3 extends AASReader {
private readonly select: XPathSelect;
private readonly document: Document;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import camelCase from 'lodash-es/camelCase.js';
import { DOMImplementation, XMLSerializer } from '@xmldom/xmldom';
import { AASWriter } from './aas-writer.js';

export class XmlWriter extends AASWriter {
export class XmlWriterV3 extends AASWriter {
private readonly document: Document;

public constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
*****************************************************************************/

import { readFile } from 'fs/promises';
import { JsonReader } from '../../app/packages/json-reader.js';
import { JsonReaderV3 } from '../../app/packages/json-reader-v3.js';
import { resolve } from 'path/posix';
import { describe, beforeEach, it, expect } from '@jest/globals';

describe('JsonReader', function () {
let reader: JsonReader;
describe('JsonReaderV3', function () {
let reader: JsonReaderV3;
let json: string;

beforeEach(async function () {
json = (await readFile(resolve('./src/test/assets/aas-example.json'))).toString();
reader = new JsonReader(json);
reader = new JsonReaderV3(json);
});

it('should be created', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
*
*****************************************************************************/

import { JsonWriter } from '../../app/packages/json-writer.js';
import { JsonWriterV3 } from '../../app/packages/json-writer-v3.js';
import env from '../assets/aas-environment.js';
import { describe, beforeEach, it, expect } from '@jest/globals';

describe('JsonWriter', function () {
describe('writeEnvironment', function () {
let writer: JsonWriter;
let writer: JsonWriterV3;

beforeEach(() => {
writer = new JsonWriter();
writer = new JsonWriterV3();
});

it('writes an AAS environment', () => {
Expand All @@ -24,10 +24,10 @@ describe('JsonWriter', function () {
});

describe('write', () => {
let writer: JsonWriter;
let writer: JsonWriterV3;

beforeEach(() => {
writer = new JsonWriter();
writer = new JsonWriterV3();
});

it('does not support writing an AAS', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import { describe, beforeAll, beforeEach, it, expect } from '@jest/globals';
import { readFile } from 'fs/promises';
import { resolve } from 'path/posix';
import { XmlReader } from '../../app/packages/xml-reader.js';
import { XmlReaderV3 } from '../../app/packages/xml-reader-v3.js';

describe('XmlReader', function () {
let reader: XmlReader;
describe('XmlReaderV3', function () {
let reader: XmlReaderV3;
let xml: string;
let path: string;

Expand All @@ -22,7 +22,7 @@ describe('XmlReader', function () {
});

beforeEach(function () {
reader = new XmlReader(xml);
reader = new XmlReaderV3(xml);
});

it('should be created', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

import { describe, beforeEach, it, expect } from '@jest/globals';
import env from '../assets/aas-environment.js';
import { XmlWriter } from '../../app/packages/xml-writer.js';
import { XmlWriterV3 } from '../../app/packages/xml-writer-v3.js';

describe('XmlWriter', () => {
let writer: XmlWriter;
describe('XmlWriterV3', () => {
let writer: XmlWriterV3;

beforeEach(() => {
writer = new XmlWriter();
writer = new XmlWriterV3();
});

describe('writeEnvironment', () => {
Expand Down

0 comments on commit ebcae3c

Please sign in to comment.