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

Migration to spring3/jakarta/java17 #139

Merged
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
28 changes: 14 additions & 14 deletions .github/workflows/maven_run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Start environment
run: docker compose up -d --wait
- name: Install BaSyx
run: mvn clean install
- name: Stop environment
if: always()
run: docker compose down
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Start environment
run: docker compose up -d --wait
- name: Install BaSyx
run: mvn clean install
- name: Stop environment
if: always()
run: docker compose down

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ local.properties
**/open-api/Plattform_i40-Registry-and-Discovery.yaml
**/open-api/Plattform_i40-SubmodelRegistry-and-Discovery.yaml
**/open-api/temporary-extensions-result-file.yaml
/.env

**.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -48,11 +49,7 @@
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.aas4j</groupId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*******************************************************************************
* Copyright (C) 2023 the Eclipse BaSyx Authors
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* SPDX-License-Identifier: MIT
******************************************************************************/

Expand All @@ -44,43 +44,49 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import javax.validation.constraints.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2023-10-10T10:16:17.046754509Z[GMT]")
@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2023-10-10T10:16:17.046754509Z[GMT]")
@RestController
public class LookupApiController implements LookupApi {

private final AasDiscoveryService aasDiscoveryService;
private final AasDiscoveryService aasDiscoveryService;

@Autowired
public LookupApiController(AasDiscoveryService aasDiscoveryService) {
this.aasDiscoveryService = aasDiscoveryService;
}
@Autowired
public LookupApiController(AasDiscoveryService aasDiscoveryService) {
this.aasDiscoveryService = aasDiscoveryService;
}

public ResponseEntity<Void> deleteAllAssetLinksById(
@Parameter(in = ParameterIn.PATH, description = "The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)", required = true, schema = @Schema()) @PathVariable("aasIdentifier") Base64UrlEncodedIdentifier aasIdentifier) {
aasDiscoveryService.deleteAllAssetLinksById(aasIdentifier.getIdentifier());

public ResponseEntity<Void> deleteAllAssetLinksById(@Parameter(in = ParameterIn.PATH, description = "The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)", required=true, schema=@Schema()) @PathVariable("aasIdentifier") Base64UrlEncodedIdentifier aasIdentifier) {
aasDiscoveryService.deleteAllAssetLinksById(aasIdentifier.getIdentifier());

return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
}
}

public ResponseEntity<PagedResult> getAllAssetAdministrationShellIdsByAssetLink(@Parameter(in = ParameterIn.QUERY, description = "A list of specific Asset identifiers. Each Asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.1#/components/schemas/SpecificAssetId)" ,schema=@Schema()) @Valid @RequestParam(value = "assetIds", required = false) List<Base64UrlEncodedIdentifier> assetIds,@Min(1)@Parameter(in = ParameterIn.QUERY, description = "The maximum number of elements in the response array" ,schema=@Schema(allowableValues={ "1" }, minimum="1"
)) @Valid @RequestParam(value = "limit", required = false) Integer limit,@Parameter(in = ParameterIn.QUERY, description = "A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue" ,schema=@Schema()) @Valid @RequestParam(value = "cursor", required = false) String cursor) {

if (limit == null)
public ResponseEntity<PagedResult> getAllAssetAdministrationShellIdsByAssetLink(
@Parameter(in = ParameterIn.QUERY, description = "A list of specific Asset identifiers. Each Asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.1#/components/schemas/SpecificAssetId)", schema = @Schema()) @Valid @RequestParam(value = "assetIds", required = false) List<Base64UrlEncodedIdentifier> assetIds,
@Min(1) @Parameter(in = ParameterIn.QUERY, description = "The maximum number of elements in the response array", schema = @Schema(allowableValues = {
"1" }, minimum = "1")) @Valid @RequestParam(value = "limit", required = false) Integer limit,
@Parameter(in = ParameterIn.QUERY, description = "A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue", schema = @Schema()) @Valid @RequestParam(value = "cursor", required = false) String cursor) {

if (limit == null) {
limit = 100;

if (cursor == null)
}

if (cursor == null) {
cursor = "";
}

PaginationInfo pInfo = new PaginationInfo(limit, cursor);

List<String> decodedAssetIds = getDecodedAssetIds(assetIds);

CursorResult<List<String>> filteredResult = aasDiscoveryService.getAllAssetAdministrationShellIdsByAssetLink(pInfo, decodedAssetIds);

InlineResponse200 paginatedAasIds = new InlineResponse200();
Expand All @@ -104,8 +110,9 @@ public ResponseEntity<List<SpecificAssetId>> postAllAssetLinksById(@Parameter(in

private List<String> getDecodedAssetIds(List<Base64UrlEncodedIdentifier> assetIds) {

if (assetIds == null)
if (assetIds == null) {
return new ArrayList<>();
}

return assetIds.stream().map(assetId -> assetId.getIdentifier()).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*******************************************************************************
* Copyright (C) 2023 the Eclipse BaSyx Authors
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* SPDX-License-Identifier: MIT
******************************************************************************/

Expand All @@ -33,15 +33,16 @@

import org.eclipse.digitaltwin.basyx.http.pagination.PagedResult;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import jakarta.validation.Valid;

/**
* InlineResponse200
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2023-10-10T10:16:17.046754509Z[GMT]")
@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2023-10-10T10:16:17.046754509Z[GMT]")

public class InlineResponse200 extends PagedResult {

@JsonProperty("result")
@Valid
private List<String> result = null;
Expand All @@ -61,7 +62,7 @@ public InlineResponse200 addResultItem(String resultItem) {

/**
* Get result
*
*
* @return result
**/
@Schema(description = "")
Expand Down
9 changes: 5 additions & 4 deletions basyx.aasenvironment/basyx.aasenvironment-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -87,8 +88,8 @@
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>

<dependency>
Expand Down Expand Up @@ -132,4 +133,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
/*******************************************************************************
* Copyright (C) 2023 the Eclipse BaSyx Authors
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* SPDX-License-Identifier: MIT
******************************************************************************/
package org.eclipse.digitaltwin.basyx.aasenvironment.base;

import jakarta.validation.Valid;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import javax.validation.Valid;

import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXSerializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.JsonSerializer;
Expand All @@ -54,22 +52,21 @@

/**
* Default implementation of {@link AasEnvironmentSerialization}
*
* @author zhangzai, danish
*
* @author zhangzai, danish
*/
public class DefaultAASEnvironmentSerialization implements AasEnvironmentSerialization {

private static Logger logger = LoggerFactory.getLogger(DefaultAASEnvironmentSerialization.class);

private AasRepository aasRepository;
private SubmodelRepository submodelRepository;
private ConceptDescriptionRepository conceptDescriptionRepository;
private JsonSerializer jsonSerializer = new JsonSerializer();
private XmlSerializer xmlSerializer = new XmlSerializer();
private AASXSerializer aasxSerializer = new AASXSerializer();
private MetamodelCloneCreator cloneCreator = new MetamodelCloneCreator();

public DefaultAASEnvironmentSerialization(AasRepository aasRepository, SubmodelRepository submodelRepository, ConceptDescriptionRepository conceptDescriptionRepository) {
this.aasRepository = aasRepository;
this.submodelRepository = submodelRepository;
Expand Down Expand Up @@ -101,31 +98,33 @@ public byte[] createAASXAASEnvironmentSerialization(@Valid List<String> aasIds,
private Environment createEnvironment(List<String> aasIds, List<String> submodelIds, boolean includeConceptDescriptions) {
List<AssetAdministrationShell> shells = aasIds.stream().map(aasRepository::getAas).collect(Collectors.toList());
List<Submodel> submodels = submodelIds.stream().map(submodelRepository::getSubmodel).collect(Collectors.toList());

Environment aasEnvironment = new DefaultEnvironment();
aasEnvironment.setAssetAdministrationShells(cloneCreator.cloneAssetAdministrationShells(shells));
aasEnvironment.setSubmodels(cloneCreator.cloneSubmodels(submodels));
if (includeConceptDescriptions)

if (includeConceptDescriptions) {
includeConceptDescriptions(aasEnvironment);

}

return aasEnvironment;
}

private void includeConceptDescriptions(Environment aasEnvironment) {
List<ConceptDescription> conceptDescriptions = cloneCreator.cloneConceptDescriptions(getConceptDescriptions(aasEnvironment));
aasEnvironment.setConceptDescriptions(conceptDescriptions);
}

private List<ConceptDescription> getConceptDescriptions(Environment env) {
if (conceptDescriptionRepository == null)
if (conceptDescriptionRepository == null) {
throw new NullPointerException("The parameter includeConceptDescriptions is set to true but ConceptDescriptionRepository is null");

}

Set<String> cdIds = new ConceptDescriptionIdCollector(env).collect();

return cdIds.stream().map(this::fetchConceptDescriptionFromRepo).filter(Objects::nonNull).collect(Collectors.toList());
}

private ConceptDescription fetchConceptDescriptionFromRepo(String conceptDescriptionId) {
try {
return conceptDescriptionRepository.getConceptDescription(conceptDescriptionId);
Expand Down
Loading