From 8385f8d6bca36e7ffc9769396d42680d8b7070a9 Mon Sep 17 00:00:00 2001 From: Philipp Zehnder Date: Mon, 30 Dec 2024 21:26:56 +0100 Subject: [PATCH] fix(#3388): Remove asset links from adapters when deleted --- pom.xml | 2 +- .../pom.xml | 2 +- .../management/AssetModelHelper.java | 116 ++++++++++++++++++ .../management/AssetModelManagement.java | 0 .../management/AssetModelHelperTest.java | 115 +++++++++++++++++ .../management/AssetModelManagementTest.java | 1 + streampipes-connect-management/pom.xml | 5 + .../management/AdapterMasterManagement.java | 20 ++- .../streampipes/model/assets/AssetLink.java | 9 ++ .../model/assets/AssetLinkType.java | 1 + .../model/assets/AssetLocation.java | 40 ++++++ .../streampipes/model/assets/AssetSite.java | 58 +++++++++ .../streampipes/model/assets/AssetType.java | 9 ++ .../streampipes/model/assets/Isa95Type.java | 54 ++++++++ .../streampipes/model/assets/LatLng.java | 40 ++++++ .../streampipes/model/assets/SpAsset.java | 19 +++ .../model/assets/SpAssetModel.java | 12 +- streampipes-rest/pom.xml | 2 +- ui/cypress/support/utils/asset/AssetUtils.ts | 11 +- 19 files changed, 506 insertions(+), 10 deletions(-) rename {asset-model-management => streampipes-asset-model-management}/pom.xml (97%) create mode 100644 streampipes-asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelHelper.java rename {asset-model-management => streampipes-asset-model-management}/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelManagement.java (100%) create mode 100644 streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelHelperTest.java rename {asset-model-management => streampipes-asset-model-management}/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java (99%) create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLocation.java create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetSite.java create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/assets/Isa95Type.java create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/assets/LatLng.java diff --git a/pom.xml b/pom.xml index b32678f846..01e8114553 100644 --- a/pom.xml +++ b/pom.xml @@ -872,7 +872,7 @@ streampipes-wrapper-kafka-streams streampipes-wrapper-siddhi streampipes-wrapper-standalone - asset-model-management + streampipes-asset-model-management diff --git a/asset-model-management/pom.xml b/streampipes-asset-model-management/pom.xml similarity index 97% rename from asset-model-management/pom.xml rename to streampipes-asset-model-management/pom.xml index 44a9f431c7..162ce38e18 100644 --- a/asset-model-management/pom.xml +++ b/streampipes-asset-model-management/pom.xml @@ -27,7 +27,7 @@ 0.97.0-SNAPSHOT - asset-model-management + streampipes-asset-model-management 17 diff --git a/streampipes-asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelHelper.java b/streampipes-asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelHelper.java new file mode 100644 index 0000000000..267c6edef9 --- /dev/null +++ b/streampipes-asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelHelper.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.streampipes.assetmodel.management; + +import org.apache.streampipes.model.assets.SpAsset; +import org.apache.streampipes.model.assets.SpAssetModel; +import org.apache.streampipes.storage.management.StorageDispatcher; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.List; + +public class AssetModelHelper { + private static final Logger LOG = LoggerFactory.getLogger(AssetModelHelper.class); + + private final AssetModelManagement assetModelManagement; + + public AssetModelHelper(AssetModelManagement assetModelManagement) { + this.assetModelManagement = assetModelManagement; + } + + + public AssetModelHelper() { + var genericStorage = StorageDispatcher.INSTANCE.getNoSqlStore() + .getGenericStorage(); + assetModelManagement = new AssetModelManagement(genericStorage); + } + + /** + * Removes the asset link with the given resource ID from all asset models. + * + * @param resourceId The ID of the resource to be removed from the asset links. + * @throws IOException If an I/O error occurs while fetching or updating asset models. + */ + public void removeAssetLinkFromAllAssets(String resourceId) throws IOException { + var allAssetModels = getAllAssetModelsFromStorage(); + + removeAssetLinksFromAssetModels(resourceId, allAssetModels); + } + + private void removeAssetLinksFromAssetModels(String resourceId, List allAssetModels) + throws IOException { + for (SpAssetModel assetModel : allAssetModels) { + removeAssetLinksFromAssetModelRecursively(assetModel, resourceId); + updateAssetModel(assetModel); + } + } + + private void updateAssetModel(SpAssetModel assetModel) throws IOException { + try { + assetModelManagement.update(assetModel.getId(), assetModel); + } catch (IOException e) { + LOG.error("Could not fetch all asset models from storage", e); + throw new IOException("Could not fetch all asset models from storage", e); + } + } + + private List getAllAssetModelsFromStorage() throws IOException { + try { + return assetModelManagement.findAll(); + } catch (IOException e) { + LOG.error("Could not fetch all asset models from storage", e); + throw new IOException("Could not fetch all asset models from storage", e); + } + } + + /** + * This method removes the asset link from the asset model and recursively from all sub-assets. + */ + private void removeAssetLinksFromAssetModelRecursively(SpAssetModel assetModel, String resourceId) { + removeAssetLinks(assetModel, resourceId); + + assetModel.getAssets() + .forEach(asset -> removeAssetLinksFromAsset(asset, resourceId)); + } + + /** + * Removes the resourceId from the asset links and recursively from all sub-assets. + */ + private void removeAssetLinksFromAsset(SpAsset asset, String resourceId) { + removeAssetLinks(asset, resourceId); + + if (asset.getAssets() != null) { + asset.getAssets() + .forEach(subAsset -> removeAssetLinks(subAsset, resourceId)); + } + } + + /** + * Takes the asset as an input and removes the asset link with the given resource ID. + */ + private void removeAssetLinks(SpAsset asset, String resourceId) { + var assetLinks = asset.getAssetLinks(); + if (assetLinks != null) { + assetLinks.removeIf(link -> resourceId.equals(link.getResourceId())); + } + } +} diff --git a/asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelManagement.java b/streampipes-asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelManagement.java similarity index 100% rename from asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelManagement.java rename to streampipes-asset-model-management/src/main/java/org/apache/streampipes/assetmodel/management/AssetModelManagement.java diff --git a/streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelHelperTest.java b/streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelHelperTest.java new file mode 100644 index 0000000000..ba26834fd0 --- /dev/null +++ b/streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelHelperTest.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.streampipes.assetmodel.management; + +import org.apache.streampipes.model.assets.AssetLink; +import org.apache.streampipes.model.assets.SpAsset; +import org.apache.streampipes.model.assets.SpAssetModel; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class AssetModelHelperTest { + + private static final String RESOURCE_ID_TO_BE_REMOVED = "resourceId"; + + private AssetModelManagement assetModelManagement; + private AssetModelHelper assetModelHelper; + + @BeforeEach + void setUp() { + assetModelManagement = Mockito.mock(AssetModelManagement.class); + assetModelHelper = new AssetModelHelper(assetModelManagement); + } + + @Test + void removeAssetLinkFromAllAssets_FromSpAssetModel() throws IOException { + // Provide a sample asset model that contains the asset link to be removed and mock the asset model management + // findAll + var sampleAssetModel = getSampleAssetModel(); + addAssetLink(sampleAssetModel, RESOURCE_ID_TO_BE_REMOVED); + when(assetModelManagement.findAll()).thenReturn(List.of(sampleAssetModel)); + + assetModelHelper.removeAssetLinkFromAllAssets(RESOURCE_ID_TO_BE_REMOVED); + + // Verify that asset model was updated and does not contain the asset link anymore + verify(assetModelManagement, times(1)).update(sampleAssetModel.getId(), sampleAssetModel); + assertTrue(sampleAssetModel.getAssetLinks().isEmpty()); + } + + @Test + void removeAssetLinkFromAllAssets_FromSpAsset() throws IOException { + // Provide a sample asset model with one asset that contains the asset link to be removed and mock the asset model + // management findAll + var sampleAssetModel = getSampleAssetModel(); + var asset = new SpAsset(); + addAssetLink(asset, RESOURCE_ID_TO_BE_REMOVED); + sampleAssetModel.setAssets(List.of(asset)); + when(assetModelManagement.findAll()).thenReturn(List.of(sampleAssetModel)); + + assetModelHelper.removeAssetLinkFromAllAssets(RESOURCE_ID_TO_BE_REMOVED); + + // Verify that asset was updated and does not contain the asset link anymore + verify(assetModelManagement, times(1)).update(sampleAssetModel.getId(), sampleAssetModel); + assertTrue(sampleAssetModel.getAssets().get(0).getAssetLinks().isEmpty()); + } + + @Test + void removeAssetLinkFromAllAssets_IOExceptionOnReadingAssetModels() throws IOException { + when(assetModelManagement.findAll()).thenThrow(new IOException()); + + assertThrows(IOException.class, () -> assetModelHelper.removeAssetLinkFromAllAssets(RESOURCE_ID_TO_BE_REMOVED)); + } + + @Test + void removeAssetLinkFromAllAssets_IOExceptionWhenUpdatingModel() throws IOException { + var sampleAssetModel = getSampleAssetModel(); + addAssetLink(sampleAssetModel, RESOURCE_ID_TO_BE_REMOVED); + when(assetModelManagement.findAll()).thenReturn(List.of(sampleAssetModel)); + + when(assetModelManagement.update(sampleAssetModel.getId(), sampleAssetModel)).thenThrow(new IOException()); + + assertThrows(IOException.class, () -> assetModelHelper.removeAssetLinkFromAllAssets(RESOURCE_ID_TO_BE_REMOVED)); + } + + + private SpAssetModel getSampleAssetModel() { + var sampleAssetModel = new SpAssetModel(); + sampleAssetModel.setId("1"); + + return sampleAssetModel; + } + + private void addAssetLink(SpAsset asset, String assetLinkResourceId) { + var assetLink = new AssetLink(); + assetLink.setResourceId(assetLinkResourceId); + asset.setAssetLinks(new ArrayList<>(List.of(assetLink))); + } +} \ No newline at end of file diff --git a/asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java b/streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java similarity index 99% rename from asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java rename to streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java index de52be285b..ea24f78643 100644 --- a/asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java +++ b/streampipes-asset-model-management/src/test/java/org/apache/streampipes/assetmodel/management/AssetModelManagementTest.java @@ -205,4 +205,5 @@ void delete_ThrowsIOException() throws IOException { assertThrows(IOException.class, () -> assetModelManagement.delete(SAMPLE_ASSET_MODEL_ID, REV)); } + } \ No newline at end of file diff --git a/streampipes-connect-management/pom.xml b/streampipes-connect-management/pom.xml index 62a449371a..2902a6161c 100644 --- a/streampipes-connect-management/pom.xml +++ b/streampipes-connect-management/pom.xml @@ -29,6 +29,11 @@ + + org.apache.streampipes + streampipes-asset-model-management + 0.97.0-SNAPSHOT + org.apache.streampipes streampipes-connect-shared diff --git a/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java b/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java index 6b84e60847..c98bf7ef6a 100644 --- a/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java +++ b/streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/AdapterMasterManagement.java @@ -18,6 +18,7 @@ package org.apache.streampipes.connect.management.management; +import org.apache.streampipes.assetmodel.management.AssetModelHelper; import org.apache.streampipes.commons.exceptions.NoServiceEndpointsAvailableException; import org.apache.streampipes.commons.exceptions.SepaParseException; import org.apache.streampipes.commons.exceptions.connect.AdapterException; @@ -37,6 +38,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; import java.util.List; import java.util.NoSuchElementException; @@ -50,6 +52,7 @@ public class AdapterMasterManagement { private final IAdapterStorage adapterInstanceStorage; private final AdapterMetrics adapterMetrics; private final AdapterResourceManager adapterResourceManager; + private final AssetModelHelper assetModelHelper; private final DataStreamResourceManager dataStreamResourceManager; @@ -63,6 +66,7 @@ public AdapterMasterManagement( this.adapterMetrics = adapterMetrics; this.adapterResourceManager = adapterResourceManager; this.dataStreamResourceManager = dataStreamResourceManager; + this.assetModelHelper = new AssetModelHelper(); } public void addAdapter( @@ -127,11 +131,13 @@ public void deleteAdapter(String elementId) { stopAdapterWithLogging(elementId); - deleteAdaterFromCouchDbAndFromLoggingService(elementId); + deleteAdaterFromCouchDbLoggingServiceAndAssetLinks(elementId); deleteCorrespondingDataStream(adapterDescription); + } + private void stopAdapterWithLogging(String elementId) { LOG.info("Attempting to stop adapter: {}", elementId); try { @@ -142,15 +148,25 @@ private void stopAdapterWithLogging(String elementId) { } } - private void deleteAdaterFromCouchDbAndFromLoggingService(String elementId) { + private void deleteAdaterFromCouchDbLoggingServiceAndAssetLinks(String elementId) { adapterResourceManager.delete(elementId); ExtensionsLogProvider.INSTANCE.remove(elementId); + removeAdapterFromAllAssetLinks(elementId); LOG.info("Successfully deleted adapter in couchdb: {}", elementId); } + private void removeAdapterFromAllAssetLinks(String elementId) { + try { + assetModelHelper.removeAssetLinkFromAllAssets(elementId); + } catch (IOException e) { + LOG.error("Failed to remove adapter from asset models: {}", elementId, e); + } + } + private void deleteCorrespondingDataStream(AdapterDescription adapterDescription) { var correspondingDataStreamElementId = adapterDescription.getCorrespondingDataStreamElementId(); dataStreamResourceManager.delete(correspondingDataStreamElementId); + removeAdapterFromAllAssetLinks(correspondingDataStreamElementId); LOG.info("Successfully deleted data stream in couchdb: {}", correspondingDataStreamElementId); } diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLink.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLink.java index 3617dc52f9..487022e86e 100644 --- a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLink.java +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLink.java @@ -27,6 +27,7 @@ public class AssetLink { private String linkLabel; private String queryHint; private boolean editingDisabled; + private boolean navigationActive; public AssetLink() { } @@ -71,6 +72,14 @@ public void setQueryHint(String queryHint) { this.queryHint = queryHint; } + public boolean isNavigationActive() { + return navigationActive; + } + + public void setNavigationActive(boolean navigationActive) { + this.navigationActive = navigationActive; + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLinkType.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLinkType.java index 1b34655a1e..070bf24ae2 100644 --- a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLinkType.java +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLinkType.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; + public class AssetLinkType { public final String appDocType = GenericDocTypes.DOC_ASSET_LINK_TYPE; diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLocation.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLocation.java new file mode 100644 index 0000000000..ed50f02d16 --- /dev/null +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetLocation.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.streampipes.model.assets; + +public class AssetLocation { + private LatLng coordinates; + private Integer zoom; + + public LatLng getCoordinates() { + return coordinates; + } + + public void setCoordinates(LatLng coordinates) { + this.coordinates = coordinates; + } + + public Integer getZoom() { + return zoom; + } + + public void setZoom(Integer zoom) { + this.zoom = zoom; + } +} diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetSite.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetSite.java new file mode 100644 index 0000000000..64131cbee8 --- /dev/null +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetSite.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.streampipes.model.assets; + +public class AssetSite { + private String siteId; + private String area; + private boolean hasExactLocation; + private AssetLocation location; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public boolean isHasExactLocation() { + return hasExactLocation; + } + + public void setHasExactLocation(boolean hasExactLocation) { + this.hasExactLocation = hasExactLocation; + } + + public AssetLocation getLocation() { + return location; + } + + public void setLocation(AssetLocation location) { + this.location = location; + } +} diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetType.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetType.java index 45b7151cf9..3394c078e7 100644 --- a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetType.java +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/AssetType.java @@ -24,6 +24,7 @@ public class AssetType { private String assetIconColor; private String assetTypeCategory; private String assetTypeLabel; + private Isa95Type isa95AssetType; public AssetType() { } @@ -59,4 +60,12 @@ public String getAssetTypeLabel() { public void setAssetTypeLabel(String assetTypeLabel) { this.assetTypeLabel = assetTypeLabel; } + + public Isa95Type getIsa95AssetType() { + return isa95AssetType; + } + + public void setIsa95AssetType(Isa95Type isa95AssetType) { + this.isa95AssetType = isa95AssetType; + } } diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/Isa95Type.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/Isa95Type.java new file mode 100644 index 0000000000..2804b989cc --- /dev/null +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/Isa95Type.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.streampipes.model.assets; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum Isa95Type { + PROCESS_CELL("PROCESS_CELL"), + PRODUCTION_UNIT("PRODUCTION_UNIT"), + PRODUCTION_LINE("PRODUCTION_LINE"), + STORAGE_ZONE("STORAGE_ZONE"), + UNIT("UNIT"), + WORK_CELL("WORK_CELL"), + STORAGE_UNIT("STORAGE_UNIT"), + OTHER("OTHER"); + + private final String value; + + Isa95Type(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @JsonCreator + public static Isa95Type fromValue(String value) { + for (Isa95Type type : Isa95Type.values()) { + if (type.value.equalsIgnoreCase(value)) { + return type; + } + } + throw new IllegalArgumentException("Unknown enum type " + value); + } +} diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/LatLng.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/LatLng.java new file mode 100644 index 0000000000..7d67e48922 --- /dev/null +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/LatLng.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.streampipes.model.assets; + +public class LatLng { + private double latitude; + private double longitude; + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } +} diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAsset.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAsset.java index eeee4c670d..951f5edb2f 100644 --- a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAsset.java +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAsset.java @@ -29,6 +29,9 @@ public class SpAsset { private AssetType assetType; private List assetLinks; + private List labelIds; + + private AssetSite assetSite; private List assets; @@ -84,4 +87,20 @@ public List getAssets() { public void setAssets(List assets) { this.assets = assets; } + + public List getLabelIds() { + return labelIds; + } + + public void setLabelIds(List labelIds) { + this.labelIds = labelIds; + } + + public AssetSite getAssetSite() { + return assetSite; + } + + public void setAssetSite(AssetSite assetSite) { + this.assetSite = assetSite; + } } diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAssetModel.java b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAssetModel.java index 8f493efff8..db88d9f696 100644 --- a/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAssetModel.java +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/assets/SpAssetModel.java @@ -20,11 +20,9 @@ import org.apache.streampipes.commons.constants.GenericDocTypes; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; -@JsonIgnoreProperties(ignoreUnknown = true) public class SpAssetModel extends SpAsset { public static final String APP_DOC_TYPE = GenericDocTypes.DOC_ASSET_MANGEMENT; @@ -37,6 +35,8 @@ public class SpAssetModel extends SpAsset { private boolean removable; + private String appDocType; + public SpAssetModel() { super(); } @@ -64,4 +64,12 @@ public void setRev(String rev) { public void setRemovable(boolean removable) { this.removable = removable; } + + public String getAppDocType() { + return appDocType; + } + + public void setAppDocType(String appDocType) { + this.appDocType = appDocType; + } } diff --git a/streampipes-rest/pom.xml b/streampipes-rest/pom.xml index 2cacb72d0b..7b39e8f48d 100644 --- a/streampipes-rest/pom.xml +++ b/streampipes-rest/pom.xml @@ -31,7 +31,7 @@ org.apache.streampipes - asset-model-management + streampipes-asset-model-management 0.97.0-SNAPSHOT diff --git a/ui/cypress/support/utils/asset/AssetUtils.ts b/ui/cypress/support/utils/asset/AssetUtils.ts index deb9f21095..6cbb9e950b 100644 --- a/ui/cypress/support/utils/asset/AssetUtils.ts +++ b/ui/cypress/support/utils/asset/AssetUtils.ts @@ -53,9 +53,14 @@ export class AssetUtils { } public static checkAmountOfLinkedResources(amount: number) { - cy.dataCy('linked-resources-list') - .children() - .should('have.length', amount); + if (amount === 0) { + cy.wait(1000); + cy.dataCy('linked-resources-list').should('not.exist'); + } else { + cy.dataCy('linked-resources-list') + .children() + .should('have.length', amount); + } } public static editAsset(assetName: string) {