diff --git a/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/Endpoint.java b/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/Endpoint.java index b41e8247e..020997b0d 100644 --- a/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/Endpoint.java +++ b/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/Endpoint.java @@ -48,7 +48,7 @@ public interface Endpoint extends Configurable { * @param aasId the id of the AAS * @return a list of endpoint information where this AAS can be accessed */ - public default List getAasEndpointInformation(String aasId) { + public default List getAasEndpointInformation(String aasId) { return List.of(); } @@ -60,7 +60,7 @@ public default List getSubmodelEndpointInformation(String submodelId) { + public default List getSubmodelEndpointInformation(String submodelId) { return List.of(); } } diff --git a/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronization.java b/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronization.java index e4067c8c6..46db32c76 100644 --- a/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronization.java +++ b/core/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronization.java @@ -24,10 +24,6 @@ import de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier; import de.fraunhofer.iosb.ilt.faaast.service.model.api.paging.Page; import de.fraunhofer.iosb.ilt.faaast.service.model.api.paging.PagingInfo; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.AssetAdministrationShellDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.SubmodelDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultAssetAdministrationShellDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultSubmodelDescriptor; import de.fraunhofer.iosb.ilt.faaast.service.model.exception.ResourceNotFoundException; import de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionInfo; import de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementChangeEventMessage; @@ -58,10 +54,14 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShellDescriptor; import org.eclipse.digitaltwin.aas4j.v3.model.Key; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.SecurityAttributeObject; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShellDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelDescriptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -406,9 +406,18 @@ private void unregister(List registries, String path, Object payload, St private AssetAdministrationShellDescriptor asDescriptor(AssetAdministrationShell aas) { - return DefaultAssetAdministrationShellDescriptor.builder() - .from(aas) - .submodels(aas.getSubmodels().stream() + return new DefaultAssetAdministrationShellDescriptor.Builder() + .administration(aas.getAdministration()) + .id(aas.getId()) + .idShort(aas.getIdShort()) + .description(aas.getDescription()) + .displayName(aas.getDisplayName()) + .extensions(aas.getExtensions()) + .assetKind(Objects.isNull(aas.getAssetInformation()) ? null : aas.getAssetInformation().getAssetKind()) + .assetType(Objects.isNull(aas.getAssetInformation()) ? null : aas.getAssetInformation().getAssetType()) + .globalAssetId(Objects.isNull(aas.getAssetInformation()) ? null : aas.getAssetInformation().getGlobalAssetId()) + .specificAssetIds(Objects.isNull(aas.getAssetInformation()) ? null : aas.getAssetInformation().getSpecificAssetIds()) + .submodelDescriptors(aas.getSubmodels().stream() .map(x -> ReferenceHelper.findFirstKeyType(x, KeyTypes.SUBMODEL)) .filter(persistence::submodelExists) .map(LambdaExceptionHelper.wrapFunction(x -> persistence.getSubmodel(x, QueryModifier.MINIMAL))) @@ -422,8 +431,15 @@ private AssetAdministrationShellDescriptor asDescriptor(AssetAdministrationShell private SubmodelDescriptor asDescriptor(Submodel submodel) { - return DefaultSubmodelDescriptor.builder() - .from(submodel) + return new DefaultSubmodelDescriptor.Builder() + .administration(submodel.getAdministration()) + .id(submodel.getId()) + .idShort(submodel.getIdShort()) + .description(submodel.getDescription()) + .semanticId(submodel.getSemanticId()) + .supplementalSemanticId(submodel.getSupplementalSemanticIds()) + .displayName(submodel.getDisplayName()) + .extensions(submodel.getExtensions()) .endpoints(endpoints.stream() .flatMap(x -> x.getSubmodelEndpointInformation(submodel.getId()).stream()) .toList()) diff --git a/core/src/test/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronizationTest.java b/core/src/test/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronizationTest.java index 7bc70651a..28b2c19a0 100644 --- a/core/src/test/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronizationTest.java +++ b/core/src/test/java/de/fraunhofer/iosb/ilt/faaast/service/registry/RegistrySynchronizationTest.java @@ -39,10 +39,6 @@ import de.fraunhofer.iosb.ilt.faaast.service.model.AASFull; import de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier; import de.fraunhofer.iosb.ilt.faaast.service.model.api.paging.Page; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.SubmodelDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultAssetAdministrationShellDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultProtocolInformation; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultSubmodelDescriptor; import de.fraunhofer.iosb.ilt.faaast.service.model.exception.ResourceNotFoundException; import de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage; import de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementDeleteEventMessage; @@ -59,7 +55,11 @@ import org.eclipse.digitaltwin.aas4j.v3.model.SecurityAttributeObject; import org.eclipse.digitaltwin.aas4j.v3.model.SecurityTypeEnum; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShellDescriptor; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProtocolInformation; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSecurityAttributeObject; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelDescriptor; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; @@ -210,26 +210,26 @@ private void mockEndpoint() { doAnswer((InvocationOnMock invocation) -> { String aasId = invocation.getArgument(0); return List.of( - de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultEndpoint.builder() + new org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint.Builder() ._interface("AAS-REPOSITORY-3.0") - .protocolInformation(DefaultProtocolInformation.builder() + .protocolInformation(new DefaultProtocolInformation.Builder() .href(serviceUri.toASCIIString()) .endpointProtocol("HTTP") .endpointProtocolVersion("1.1") - .securityAttribute(new DefaultSecurityAttributeObject.Builder() + .securityAttributes(new DefaultSecurityAttributeObject.Builder() .type(SecurityTypeEnum.NONE) .key("") .value("") .build()) .build()) .build(), - de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultEndpoint.builder() + new org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint.Builder() ._interface("AAS-3.0") - .protocolInformation(DefaultProtocolInformation.builder() + .protocolInformation(new DefaultProtocolInformation.Builder() .href(serviceUri.toASCIIString() + "/shells/" + EncodingHelper.base64UrlEncode(aasId)) .endpointProtocol("HTTP") .endpointProtocolVersion("1.1") - .securityAttribute(new DefaultSecurityAttributeObject.Builder() + .securityAttributes(new DefaultSecurityAttributeObject.Builder() .type(SecurityTypeEnum.NONE) .key("") .value("") @@ -241,26 +241,26 @@ private void mockEndpoint() { doAnswer((InvocationOnMock invocation) -> { String submodelId = invocation.getArgument(0); return List.of( - de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultEndpoint.builder() + new org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint.Builder() ._interface("SUBMODEL-REPOSITORY-3.0") - .protocolInformation(DefaultProtocolInformation.builder() + .protocolInformation(new DefaultProtocolInformation.Builder() .href(serviceUri.toASCIIString()) .endpointProtocol("HTTP") .endpointProtocolVersion("1.1") - .securityAttribute(new DefaultSecurityAttributeObject.Builder() + .securityAttributes(new DefaultSecurityAttributeObject.Builder() .type(SecurityTypeEnum.NONE) .key("") .value("") .build()) .build()) .build(), - de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultEndpoint.builder() + new org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint.Builder() ._interface("SUBMODEL-3.0") - .protocolInformation(DefaultProtocolInformation.builder() + .protocolInformation(new DefaultProtocolInformation.Builder() .href(serviceUri.toASCIIString() + "/submodels/" + EncodingHelper.base64UrlEncode(submodelId)) .endpointProtocol("HTTP") .endpointProtocolVersion("1.1") - .securityAttribute(new DefaultSecurityAttributeObject.Builder() + .securityAttributes(new DefaultSecurityAttributeObject.Builder() .type(SecurityTypeEnum.NONE) .key("") .value("") @@ -345,17 +345,32 @@ private void mockPersistence() throws ResourceNotFoundException { private String getAasDescriptorBody(AssetAdministrationShell aas) throws JsonProcessingException { - return mapper.writeValueAsString(DefaultAssetAdministrationShellDescriptor.builder() - .from(aas) + return mapper.writeValueAsString(new DefaultAssetAdministrationShellDescriptor.Builder() + .administration(aas.getAdministration()) + .id(aas.getId()) + .idShort(aas.getIdShort()) + .description(aas.getDescription()) + .globalAssetId(aas.getAssetInformation().getGlobalAssetId()) + .assetType(aas.getAssetInformation().getAssetType()) + .assetKind(aas.getAssetInformation().getAssetKind()) + .displayName(aas.getDisplayName()) + .extensions(aas.getExtensions()) .endpoints(endpoint.getAasEndpointInformation(aas.getId())) - .submodels(getSubmodelDescriptorsFromAas(aas)) + .submodelDescriptors(getSubmodelDescriptorsFromAas(aas)) .build()); } private String getSubmodelDescriptorBody(Submodel submodel) throws JsonProcessingException { - return mapper.writeValueAsString(DefaultSubmodelDescriptor.builder() - .from(submodel) + return mapper.writeValueAsString(new DefaultSubmodelDescriptor.Builder() + .administration(submodel.getAdministration()) + .id(submodel.getId()) + .idShort(submodel.getIdShort()) + .description(submodel.getDescription()) + .semanticId(submodel.getSemanticId()) + .supplementalSemanticId(submodel.getSupplementalSemanticIds()) + .displayName(submodel.getDisplayName()) + .extensions(submodel.getExtensions()) .endpoints(endpoint.getSubmodelEndpointInformation(submodel.getId())) .build()); } @@ -366,8 +381,15 @@ private List getSubmodelDescriptorsFromAas(AssetAdministrati .map(x -> ReferenceHelper.findFirstKeyType(x, KeyTypes.SUBMODEL)) .filter(persistence::submodelExists) .map(LambdaExceptionHelper.wrapFunction(x -> persistence.getSubmodel(x, QueryModifier.MINIMAL))) - .map(x -> DefaultSubmodelDescriptor.builder() - .from(x) + .map(x -> new DefaultSubmodelDescriptor.Builder() + .administration(x.getAdministration()) + .id(x.getId()) + .idShort(x.getIdShort()) + .description(x.getDescription()) + .semanticId(x.getSemanticId()) + .supplementalSemanticId(x.getSupplementalSemanticIds()) + .displayName(x.getDisplayName()) + .extensions(x.getExtensions()) .endpoints(endpoint.getSubmodelEndpointInformation(x.getId())) .build()) .map(SubmodelDescriptor.class::cast) diff --git a/endpoint/http/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/http/HttpEndpoint.java b/endpoint/http/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/http/HttpEndpoint.java index 483526490..b5381cffd 100644 --- a/endpoint/http/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/http/HttpEndpoint.java +++ b/endpoint/http/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/endpoint/http/HttpEndpoint.java @@ -24,7 +24,6 @@ import de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint; import de.fraunhofer.iosb.ilt.faaast.service.exception.EndpointException; import de.fraunhofer.iosb.ilt.faaast.service.model.Version; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultProtocolInformation; import de.fraunhofer.iosb.ilt.faaast.service.util.EncodingHelper; import de.fraunhofer.iosb.ilt.faaast.service.util.Ensure; import java.io.File; @@ -39,6 +38,8 @@ import java.util.List; import java.util.Objects; import org.eclipse.digitaltwin.aas4j.v3.model.SecurityTypeEnum; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEndpoint; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultProtocolInformation; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSecurityAttributeObject; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; @@ -212,7 +213,7 @@ public void stop() { @Override - public List getAasEndpointInformation(String aasId) { + public List getAasEndpointInformation(String aasId) { if (Objects.isNull(server)) { return List.of(); } @@ -223,7 +224,7 @@ public List get @Override - public List getSubmodelEndpointInformation(String submodelId) { + public List getSubmodelEndpointInformation(String submodelId) { if (Objects.isNull(server)) { return List.of(); } @@ -233,14 +234,14 @@ public List get } - private de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.Endpoint endpointFor(String interfaceName, String path) { - return de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl.DefaultEndpoint.builder() + private org.eclipse.digitaltwin.aas4j.v3.model.Endpoint endpointFor(String interfaceName, String path) { + return new DefaultEndpoint.Builder() ._interface(interfaceName) - .protocolInformation(DefaultProtocolInformation.builder() + .protocolInformation(new DefaultProtocolInformation.Builder() .href(getEndpointUri().resolve(getVersionPrefix() + path).toASCIIString()) .endpointProtocol(ENDPOINT_PROTOCOL) .endpointProtocolVersion(ENDPOINT_PROTOCOL_VERSION) - .securityAttribute(new DefaultSecurityAttributeObject.Builder() + .securityAttributes(new DefaultSecurityAttributeObject.Builder() .type(SecurityTypeEnum.NONE) .key("") .value("") diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/AssetAdministrationShellDescriptor.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/AssetAdministrationShellDescriptor.java deleted file mode 100644 index d6b0bf2e6..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/AssetAdministrationShellDescriptor.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor; - -import java.util.List; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; - - -/** - * Registry Descriptor interface for AssetAdministrationShell. - */ -public interface AssetAdministrationShellDescriptor { - - public AdministrativeInformation getAdministration(); - - - public void setAdministration(AdministrativeInformation administration); - - - public AssetKind getAssetKind(); - - - public void setAssetKind(AssetKind assetKind); - - - public String getAssetType(); - - - public void setAssetType(String assetType); - - - public List getEndpoints(); - - - public void setEndpoints(List endpoints); - - - public String getGlobalAssetId(); - - - public void setGlobalAssetId(String globalAssetId); - - - public String getIdShort(); - - - public void setIdShort(String idShort); - - - public String getId(); - - - public void setId(String identification); - - - public List getSpecificAssetIds(); - - - public void setSpecificAssetIds(List specificAssetIds); - - - public List getSubmodels(); - - - public void setSubmodels(List submodels); - - - public List getDescriptions(); - - - public void setDescriptions(List descriptions); - - - public List getDisplayNames(); - - - public void setDisplayNames(List displayNames); - - - public List getExtensions(); - - - public void setExtensions(List extensions); -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/Endpoint.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/Endpoint.java deleted file mode 100644 index b36ac798b..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/Endpoint.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor; - -/** - * Registry Descriptor for Endpoint. - */ -public interface Endpoint { - - public String getInterface(); - - - public void setInterface(String _interface); - - - public ProtocolInformation getProtocolInformation(); - - - public void setProtocolInformation(ProtocolInformation protocolInformation); - -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/ProtocolInformation.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/ProtocolInformation.java deleted file mode 100644 index c247bd5ed..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/ProtocolInformation.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor; - -import java.util.List; -import org.eclipse.digitaltwin.aas4j.v3.model.SecurityAttributeObject; - - -/** - * Registry Descriptor for ProtocolInformation. - */ -public interface ProtocolInformation { - - public String getEndpointProtocol(); - - - public void setEndpointProtocol(String endpointProtocol); - - - public List getEndpointProtocolVersion(); - - - public void setEndpointProtocolVersion(List endpointProtocolVersion); - - - public String getHref(); - - - public void setHref(String href); - - - public List getSecurityAttributes(); - - - public void setSecurityAttributes(List securityAttributes); - - - public String getSubprotocol(); - - - public void setSubprotocol(String subprotocol); - - - public String getSubprotocolBody(); - - - public void setSubprotocolBody(String subprotocolBody); - - - public String getSubprotocolBodyEncoding(); - - - public void setSubprotocolBodyEncoding(String subprotocolBodyEncoding); -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/SubmodelDescriptor.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/SubmodelDescriptor.java deleted file mode 100644 index 194b077f6..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/SubmodelDescriptor.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor; - -import java.util.List; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; - - -/** - * Registry Descriptor interface for Submodel. - */ -public interface SubmodelDescriptor { - - public String getIdShort(); - - - public void setIdShort(String idShort); - - - public List getEndpoints(); - - - public void setEndpoints(List endpoints); - - - public AdministrativeInformation getAdministration(); - - - public void setAdministration(AdministrativeInformation administration); - - - public List getDescriptions(); - - - public void setDescriptions(List descriptions); - - - public List getDisplayNames(); - - - public void setDisplayNames(List displayNames); - - - public String getId(); - - - public void setId(String id); - - - public Reference getSemanticId(); - - - public void setSemanticId(Reference semanticId); - - - public List getSupplementalSemanticIds(); - - - public void setSupplementalSemanticIds(List suplementalSemanticIds); - - - public List getExtensions(); - - - public void setExtensions(List extensions); -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/AbstractIdentifiableDescriptor.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/AbstractIdentifiableDescriptor.java deleted file mode 100644 index 48cb283d1..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/AbstractIdentifiableDescriptor.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl; - -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.Endpoint; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import org.eclipse.digitaltwin.aas4j.v3.model.AdministrativeInformation; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringNameType; -import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType; -import org.eclipse.digitaltwin.aas4j.v3.model.builder.ExtendableBuilder; - - -/** - * Methods for Identifiable. - */ -public abstract class AbstractIdentifiableDescriptor { - - private String idShort; - private List endpoints; - private AdministrativeInformation administration; - private List descriptions; - private List displayNames; - private String id; - - protected AbstractIdentifiableDescriptor() { - idShort = null; - endpoints = new ArrayList<>(); - administration = null; - descriptions = new ArrayList<>(); - displayNames = new ArrayList<>(); - } - - - protected AbstractIdentifiableDescriptor( - String idShort, - List endpoints, - AdministrativeInformation administration, - List descriptions, - String identification) { - this.idShort = idShort; - this.endpoints = endpoints; - this.administration = administration; - this.descriptions = descriptions; - this.id = identification; - } - - - public String getIdShort() { - return idShort; - } - - - public void setIdShort(String idShort) { - this.idShort = idShort; - } - - - public List getEndpoints() { - return endpoints; - } - - - public void setEndpoints(List endpoints) { - this.endpoints = endpoints; - } - - - public AdministrativeInformation getAdministration() { - return administration; - } - - - public void setAdministration(AdministrativeInformation administration) { - this.administration = administration; - } - - - public List getDescriptions() { - return descriptions; - } - - - public void setDescriptions(List descriptions) { - this.descriptions = descriptions; - } - - - public List getDisplayNames() { - return displayNames; - } - - - public void setDisplayNames(List displayNames) { - this.displayNames = displayNames; - } - - - public String getId() { - return id; - } - - - public void setId(String id) { - this.id = id; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AbstractIdentifiableDescriptor that = (AbstractIdentifiableDescriptor) o; - return Objects.equals(idShort, that.idShort) - && Objects.equals(endpoints, that.endpoints) - && Objects.equals(administration, that.administration) - && Objects.equals(descriptions, that.descriptions) - && Objects.equals(displayNames, that.displayNames) - && Objects.equals(id, that.id); - } - - - @Override - public int hashCode() { - return Objects.hash(idShort, endpoints, administration, descriptions, displayNames, id); - } - - public abstract static class AbstractBuilder> extends ExtendableBuilder { - - public B idShort(String value) { - getBuildingInstance().setIdShort(value); - return getSelf(); - } - - - public B endpoints(List value) { - getBuildingInstance().setEndpoints(value); - return getSelf(); - } - - - public B endpoint(Endpoint value) { - getBuildingInstance().getEndpoints().add(value); - return getSelf(); - } - - - public B administration(AdministrativeInformation value) { - getBuildingInstance().setAdministration(value); - return getSelf(); - } - - - public B descriptions(List value) { - getBuildingInstance().setDescriptions(value); - return getSelf(); - } - - - public B description(LangStringTextType value) { - getBuildingInstance().getDescriptions().add(value); - return getSelf(); - } - - - public B displayNames(List value) { - getBuildingInstance().setDisplayNames(value); - return getSelf(); - } - - - public B displayName(LangStringNameType value) { - getBuildingInstance().getDisplayNames().add(value); - return getSelf(); - } - - - public B id(String value) { - getBuildingInstance().setId(value); - return getSelf(); - } - } -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultAssetAdministrationShellDescriptor.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultAssetAdministrationShellDescriptor.java deleted file mode 100644 index de4a732e9..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultAssetAdministrationShellDescriptor.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl; - -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.AssetAdministrationShellDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.SubmodelDescriptor; -import de.fraunhofer.iosb.ilt.faaast.service.util.ReferenceBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; -import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - - -/** - * Registry Descriptor default implementation for AssetAdministrationShell. - */ -public class DefaultAssetAdministrationShellDescriptor extends AbstractIdentifiableDescriptor implements AssetAdministrationShellDescriptor { - - private String globalAssetId; - private List specificAssetIds; - private List submodels; - private List extensions; - private AssetKind assetKind; - private String assetType; - - public DefaultAssetAdministrationShellDescriptor() { - specificAssetIds = new ArrayList<>(); - submodels = new ArrayList<>(); - extensions = new ArrayList<>(); - assetKind = AssetKind.NOT_APPLICABLE; - } - - - @Override - public AssetKind getAssetKind() { - return assetKind; - } - - - @Override - public void setAssetKind(AssetKind assetKind) { - this.assetKind = assetKind; - } - - - @Override - public String getAssetType() { - return assetType; - } - - - @Override - public void setAssetType(String assetType) { - this.assetType = assetType; - } - - - @Override - public List getExtensions() { - return extensions; - } - - - @Override - public void setExtensions(List extensions) { - this.extensions = extensions; - } - - - @Override - public String getGlobalAssetId() { - return globalAssetId; - } - - - @Override - public void setGlobalAssetId(String globalAssetId) { - this.globalAssetId = globalAssetId; - } - - - @Override - public List getSpecificAssetIds() { - return specificAssetIds; - } - - - @Override - public void setSpecificAssetIds(List specificAssetIds) { - this.specificAssetIds = specificAssetIds; - } - - - @Override - public List getSubmodels() { - return submodels; - } - - - @Override - public void setSubmodels(List submodels) { - this.submodels = submodels; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DefaultAssetAdministrationShellDescriptor that = (DefaultAssetAdministrationShellDescriptor) o; - return super.equals(that) - && Objects.equals(globalAssetId, that.globalAssetId) - && Objects.equals(specificAssetIds, that.specificAssetIds) - && Objects.equals(submodels, that.submodels) - && Objects.equals(assetType, that.assetType) - && Objects.equals(extensions, that.extensions) - && assetKind == that.assetKind; - } - - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), globalAssetId, specificAssetIds, submodels, assetKind, assetType, extensions); - } - - - public static Builder builder() { - return new Builder(); - } - - public abstract static class AbstractBuilder> - extends AbstractIdentifiableDescriptor.AbstractBuilder { - - public B globalAssetId(String value) { - getBuildingInstance().setGlobalAssetId(value); - return getSelf(); - } - - - public B specificAssetIds(List value) { - getBuildingInstance().setSpecificAssetIds(value); - return getSelf(); - } - - - public B specificAssetId(SpecificAssetId value) { - getBuildingInstance().getSpecificAssetIds().add(value); - return getSelf(); - } - - - public B submodels(List value) { - getBuildingInstance().setSubmodels(value); - return getSelf(); - } - - - public B submodel(SubmodelDescriptor value) { - getBuildingInstance().getSubmodels().add(value); - return getSelf(); - } - - - public B assetType(String value) { - getBuildingInstance().setAssetType(value); - return getSelf(); - } - - - public B assetKind(AssetKind value) { - getBuildingInstance().setAssetKind(value); - return getSelf(); - } - - - public B extension(Extension value) { - getBuildingInstance().getExtensions().add(value); - return getSelf(); - } - - - public B extensions(List value) { - getBuildingInstance().setExtensions(value); - return getSelf(); - } - - - public B from(AssetAdministrationShellDescriptor other) { - if (Objects.nonNull(other)) { - idShort(other.getIdShort()); - endpoints(other.getEndpoints()); - administration(other.getAdministration()); - descriptions(other.getDescriptions()); - displayNames(other.getDisplayNames()); - id(other.getId()); - globalAssetId(other.getGlobalAssetId()); - specificAssetIds(other.getSpecificAssetIds()); - submodels(other.getSubmodels()); - assetType(other.getAssetType()); - assetKind(other.getAssetKind()); - extensions(other.getExtensions()); - } - return getSelf(); - } - - - public B from(AssetAdministrationShell parent) { - if (parent != null) { - idShort(parent.getIdShort()); - administration(parent.getAdministration()); - descriptions(parent.getDescription()); - displayNames(parent.getDisplayName()); - id(parent.getId()); - if (parent.getAssetInformation() != null) { - globalAssetId(parent.getAssetInformation().getGlobalAssetId()); - specificAssetIds(parent.getAssetInformation().getSpecificAssetIds()); - } - } - return getSelf(); - } - - - public B from(AssetAdministrationShell aas, List submodels) { - if (Objects.isNull(aas)) { - return getSelf(); - } - from(aas); - if (submodels != null) { - List submodelsNotPresentInAAS = submodels.stream() - .filter(x -> !aas.getSubmodels().contains(ReferenceBuilder.forSubmodel(x))) - .collect(Collectors.toList()); - if (!submodelsNotPresentInAAS.isEmpty()) { - throw new IllegalArgumentException(String.format("Submodel(s) not found in AAS (id: %s) ", - submodelsNotPresentInAAS.stream() - .map(x -> x.getId()) - .collect(Collectors.joining(", ")))); - } - submodels(submodels.stream() - .map(x -> DefaultSubmodelDescriptor.builder() - .from(x) - .build()) - .collect(Collectors.toList())); - } - return getSelf(); - } - } - - public static class Builder extends AbstractBuilder { - - @Override - protected Builder getSelf() { - return this; - } - - - @Override - protected DefaultAssetAdministrationShellDescriptor newBuildingInstance() { - return new DefaultAssetAdministrationShellDescriptor(); - } - } -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultEndpoint.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultEndpoint.java deleted file mode 100644 index fdbb88ea5..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultEndpoint.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl; - -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.Endpoint; -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.ProtocolInformation; -import java.util.Objects; -import org.eclipse.digitaltwin.aas4j.v3.model.builder.ExtendableBuilder; - - -/** - * Registry Descriptor default implementation for endpoint. - */ -public class DefaultEndpoint implements Endpoint { - - private String _interface; - private ProtocolInformation protocolInformation; - - public DefaultEndpoint() { - _interface = null; - protocolInformation = null; - } - - - @Override - public String getInterface() { - return _interface; - } - - - @Override - public void setInterface(String _interface) { - this._interface = _interface; - } - - - @Override - public ProtocolInformation getProtocolInformation() { - return protocolInformation; - } - - - @Override - public void setProtocolInformation(ProtocolInformation protocolInformation) { - this.protocolInformation = protocolInformation; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DefaultEndpoint that = (DefaultEndpoint) o; - return Objects.equals(_interface, that._interface) - && Objects.equals(protocolInformation, that.protocolInformation); - } - - - @Override - public int hashCode() { - return Objects.hash(_interface, protocolInformation); - } - - - public static Builder builder() { - return new Builder(); - } - - public abstract static class AbstractBuilder> extends ExtendableBuilder { - - public B from(Endpoint other) { - if (Objects.nonNull(other)) { - _interface(other.getInterface()); - protocolInformation(other.getProtocolInformation()); - } - return getSelf(); - } - - - public B _interface(String value) { - getBuildingInstance().setInterface(value); - return getSelf(); - } - - - public B protocolInformation(ProtocolInformation value) { - getBuildingInstance().setProtocolInformation(value); - return getSelf(); - } - } - - public static class Builder extends AbstractBuilder { - - @Override - protected Builder getSelf() { - return this; - } - - - @Override - protected DefaultEndpoint newBuildingInstance() { - return new DefaultEndpoint(); - } - } -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultProtocolInformation.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultProtocolInformation.java deleted file mode 100644 index e3ac079a8..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultProtocolInformation.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl; - -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.ProtocolInformation; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import org.eclipse.digitaltwin.aas4j.v3.model.SecurityAttributeObject; -import org.eclipse.digitaltwin.aas4j.v3.model.builder.ExtendableBuilder; - - -/** - * Registry Descriptor for ProtocolInformation. - */ -public class DefaultProtocolInformation implements ProtocolInformation { - - private String endpointProtocol; - private List endpointProtocolVersion; - private String href; - private List securityAttributes; - private String subprotocol; - private String subprotocolBody; - private String subprotocolBodyEncoding; - - public DefaultProtocolInformation() { - - endpointProtocol = null; - endpointProtocolVersion = new ArrayList<>(); - href = null; - securityAttributes = new ArrayList<>(); - subprotocol = null; - subprotocolBody = null; - subprotocolBodyEncoding = null; - } - - - @Override - public String getEndpointProtocol() { - return endpointProtocol; - } - - - @Override - public void setEndpointProtocol(String endpointProtocol) { - this.endpointProtocol = endpointProtocol; - } - - - @Override - public List getEndpointProtocolVersion() { - return endpointProtocolVersion; - } - - - @Override - public void setEndpointProtocolVersion(List endpointProtocolVersion) { - this.endpointProtocolVersion = endpointProtocolVersion; - } - - - @Override - public String getHref() { - return href; - } - - - @Override - public void setHref(String href) { - this.href = href; - } - - - @Override - public List getSecurityAttributes() { - return securityAttributes; - } - - - @Override - public void setSecurityAttributes(List securityAttributes) { - this.securityAttributes = securityAttributes; - } - - - @Override - public String getSubprotocol() { - return subprotocol; - } - - - @Override - public void setSubprotocol(String subprotocol) { - this.subprotocol = subprotocol; - } - - - @Override - public String getSubprotocolBody() { - return subprotocolBody; - } - - - @Override - public void setSubprotocolBody(String subprotocolBody) { - this.subprotocolBody = subprotocolBody; - } - - - @Override - public String getSubprotocolBodyEncoding() { - return subprotocolBodyEncoding; - } - - - @Override - public void setSubprotocolBodyEncoding(String subprotocolBodyEncoding) { - this.subprotocolBodyEncoding = subprotocolBodyEncoding; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DefaultProtocolInformation that = (DefaultProtocolInformation) o; - return Objects.equals(endpointProtocol, that.endpointProtocol) - && Objects.equals(endpointProtocolVersion, that.endpointProtocolVersion) - && Objects.equals(href, that.href) - && Objects.equals(securityAttributes, that.securityAttributes) - && Objects.equals(subprotocol, that.subprotocol) - && Objects.equals(subprotocolBody, that.subprotocolBody) - && Objects.equals(subprotocolBodyEncoding, that.subprotocolBodyEncoding); - } - - - @Override - public int hashCode() { - return Objects.hash(endpointProtocol, endpointProtocolVersion, href, securityAttributes, subprotocol, subprotocolBody, subprotocolBodyEncoding); - } - - - public static Builder builder() { - return new Builder(); - } - - public abstract static class AbstractBuilder> extends ExtendableBuilder { - - public B from(ProtocolInformation other) { - if (Objects.nonNull(other)) { - endpointProtocol(other.getEndpointProtocol()); - endpointProtocolVersion(other.getEndpointProtocolVersion()); - href(other.getHref()); - securityAttributes((other.getSecurityAttributes())); - subprotocol(other.getSubprotocol()); - subprotocolBody(other.getSubprotocolBody()); - subprotocolBodyEncoding(other.getSubprotocolBodyEncoding()); - } - return getSelf(); - } - - - public B endpointProtocol(String value) { - getBuildingInstance().setEndpointProtocol(value); - return getSelf(); - } - - - public B endpointProtocolVersion(List value) { - getBuildingInstance().setEndpointProtocolVersion(value); - return getSelf(); - } - - - public B endpointProtocolVersion(String value) { - getBuildingInstance().getEndpointProtocolVersion().add(value); - return getSelf(); - } - - - public B href(String value) { - getBuildingInstance().setHref(value); - return getSelf(); - } - - - public B securityAttribute(SecurityAttributeObject value) { - getBuildingInstance().getSecurityAttributes().add(value); - return getSelf(); - } - - - public B securityAttributes(List value) { - getBuildingInstance().setSecurityAttributes(value); - return getSelf(); - } - - - public B subprotocol(String value) { - getBuildingInstance().setSubprotocol(value); - return getSelf(); - } - - - public B subprotocolBody(String value) { - getBuildingInstance().setSubprotocolBody(value); - return getSelf(); - } - - - public B subprotocolBodyEncoding(String value) { - getBuildingInstance().setSubprotocolBodyEncoding(value); - return getSelf(); - } - } - - public static class Builder extends AbstractBuilder { - - @Override - protected Builder getSelf() { - return this; - } - - - @Override - protected DefaultProtocolInformation newBuildingInstance() { - return new DefaultProtocolInformation(); - } - } -} diff --git a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultSubmodelDescriptor.java b/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultSubmodelDescriptor.java deleted file mode 100644 index f7c31c6f1..000000000 --- a/model/src/main/java/de/fraunhofer/iosb/ilt/faaast/service/model/descriptor/impl/DefaultSubmodelDescriptor.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige - * Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten - * Forschung e.V. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.impl; - -import de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.SubmodelDescriptor; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import org.eclipse.digitaltwin.aas4j.v3.model.Extension; -import org.eclipse.digitaltwin.aas4j.v3.model.Reference; -import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; - - -/** - * Registry Descriptor for default implementation Submodel. - */ -public class DefaultSubmodelDescriptor extends AbstractIdentifiableDescriptor implements SubmodelDescriptor { - - private Reference semanticId; - private List supplementalSemanticIds; - private List extensions; - - public DefaultSubmodelDescriptor() { - semanticId = null; - supplementalSemanticIds = new ArrayList<>(); - extensions = new ArrayList<>(); - } - - - @Override - public Reference getSemanticId() { - return semanticId; - } - - - @Override - public void setSemanticId(Reference semanticId) { - this.semanticId = semanticId; - } - - - @Override - public List getSupplementalSemanticIds() { - return supplementalSemanticIds; - } - - - @Override - public void setSupplementalSemanticIds(List suplementalSemanticIds) { - this.supplementalSemanticIds = suplementalSemanticIds; - } - - - @Override - public List getExtensions() { - return extensions; - } - - - @Override - public void setExtensions(List extensions) { - this.extensions = extensions; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DefaultSubmodelDescriptor that = (DefaultSubmodelDescriptor) o; - return super.equals(that) - && Objects.equals(semanticId, that.semanticId) - && Objects.equals(supplementalSemanticIds, that.supplementalSemanticIds) - && Objects.equals(extensions, that.extensions); - } - - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), semanticId, supplementalSemanticIds, extensions); - } - - - public static Builder builder() { - return new Builder(); - } - - public abstract static class AbstractBuilder> - extends AbstractIdentifiableDescriptor.AbstractBuilder { - - public B semanticId(Reference value) { - getBuildingInstance().setSemanticId(value); - return getSelf(); - } - - - public B supplementalSemanticIds(List value) { - getBuildingInstance().setSupplementalSemanticIds(value); - return getSelf(); - } - - - public B supplementalSemanticId(Reference value) { - getBuildingInstance().getSupplementalSemanticIds().add(value); - return getSelf(); - } - - - public B extension(Extension value) { - getBuildingInstance().getExtensions().add(value); - return getSelf(); - } - - - public B extensions(List value) { - getBuildingInstance().setExtensions(value); - return getSelf(); - } - - - public B from(SubmodelDescriptor other) { - if (Objects.nonNull(other)) { - idShort(other.getIdShort()); - endpoints(other.getEndpoints()); - administration(other.getAdministration()); - descriptions(other.getDescriptions()); - displayNames(other.getDisplayNames()); - id(other.getId()); - semanticId(other.getSemanticId()); - supplementalSemanticIds(other.getSupplementalSemanticIds()); - extensions(other.getExtensions()); - } - return getSelf(); - } - - - public B from(Submodel parent) { - if (parent != null) { - idShort(parent.getIdShort()); - id(parent.getId()); - administration(parent.getAdministration()); - descriptions(parent.getDescription()); - displayNames(parent.getDisplayName()); - semanticId(parent.getSemanticId()); - supplementalSemanticIds(parent.getSupplementalSemanticIds()); - } - return getSelf(); - } - } - - public static class Builder extends AbstractBuilder { - - @Override - protected Builder getSelf() { - return this; - } - - - @Override - protected DefaultSubmodelDescriptor newBuildingInstance() { - return new DefaultSubmodelDescriptor(); - } - } -}