From 680dbc8bce14bf5557c056ee65cde801f31703df Mon Sep 17 00:00:00 2001 From: Cole Blanchard Date: Tue, 6 Aug 2024 17:30:17 -0400 Subject: [PATCH 1/4] fix update project model name --- .../terarium/hmiserver/service/data/ProjectAssetService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java index 6b26f32050..ba70190be1 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java @@ -107,6 +107,9 @@ public void updateByAsset(final TerariumAsset asset, final Schema.Permission has if (!projectAssets.isEmpty()) { projectAssets.forEach(projectAsset -> { projectAsset.setAssetName(asset.getName()); + if (asset instanceof Model) { + projectAsset.setAssetName(((Model) asset).getHeader().getName()); + } updateProjectAsset(projectAsset, hasWritePermission); }); } else { From ed1a71349dac2770393bf59476698b2f844511df Mon Sep 17 00:00:00 2001 From: Cole Blanchard Date: Mon, 19 Aug 2024 15:02:22 -0400 Subject: [PATCH 2/4] set name on modelservice --- .../terarium/hmiserver/service/data/ModelService.java | 2 ++ .../hmiserver/service/data/ProjectAssetService.java | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java index c933800498..bb25a0ac10 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java @@ -140,6 +140,7 @@ public Model createAsset(final Model asset, final UUID projectId, final Schema.P }); } + asset.setName(asset.getHeader().getName()); final Model created = super.createAsset(asset, projectId, hasWritePermission); if (created.getPublicAsset() && !created.getTemporary()) { @@ -172,6 +173,7 @@ public Optional updateAsset( final UUID projectId, final Schema.Permission hasWritePermission ) throws IOException, IllegalArgumentException { + asset.setName(asset.getHeader().getName()); final Optional updatedOptional = super.updateAsset(asset, projectId, hasWritePermission); if (updatedOptional.isEmpty()) { return Optional.empty(); diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java index ba70190be1..5e9257f37e 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ProjectAssetService.java @@ -79,10 +79,6 @@ public Optional createProjectAsset( projectAsset.setAssetType(assetType); projectAsset.setAssetName(asset.getName()); - if (asset instanceof Model) { - projectAsset.setAssetName(((Model) asset).getHeader().getName()); - } - projectAsset = projectAssetRepository.save(projectAsset); project.getProjectAssets().add(projectAsset); @@ -107,9 +103,6 @@ public void updateByAsset(final TerariumAsset asset, final Schema.Permission has if (!projectAssets.isEmpty()) { projectAssets.forEach(projectAsset -> { projectAsset.setAssetName(asset.getName()); - if (asset instanceof Model) { - projectAsset.setAssetName(((Model) asset).getHeader().getName()); - } updateProjectAsset(projectAsset, hasWritePermission); }); } else { From db7ac0a9d49e51ed599a6dcd16bcd2ad4e192dc8 Mon Sep 17 00:00:00 2001 From: Cole Blanchard Date: Mon, 19 Aug 2024 15:12:37 -0400 Subject: [PATCH 3/4] model service --- .../terarium/hmiserver/service/data/ModelService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java index bb25a0ac10..8c2db42187 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java @@ -140,7 +140,9 @@ public Model createAsset(final Model asset, final UUID projectId, final Schema.P }); } - asset.setName(asset.getHeader().getName()); + if (asset.getHeader().getName() != null) { + asset.setName(asset.getHeader().getName()); + } final Model created = super.createAsset(asset, projectId, hasWritePermission); if (created.getPublicAsset() && !created.getTemporary()) { @@ -173,7 +175,9 @@ public Optional updateAsset( final UUID projectId, final Schema.Permission hasWritePermission ) throws IOException, IllegalArgumentException { - asset.setName(asset.getHeader().getName()); + if (asset.getHeader().getName() != null) { + asset.setName(asset.getHeader().getName()); + } final Optional updatedOptional = super.updateAsset(asset, projectId, hasWritePermission); if (updatedOptional.isEmpty()) { return Optional.empty(); From 8330648ae85c0f5a8a7721ec8f2b2fac8d761bda Mon Sep 17 00:00:00 2001 From: Cole Blanchard Date: Mon, 19 Aug 2024 15:21:35 -0400 Subject: [PATCH 4/4] null checks --- .../terarium/hmiserver/service/data/ModelService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java index 8c2db42187..ebdafe7b98 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/data/ModelService.java @@ -140,7 +140,7 @@ public Model createAsset(final Model asset, final UUID projectId, final Schema.P }); } - if (asset.getHeader().getName() != null) { + if (asset.getHeader() != null && asset.getHeader().getName() != null) { asset.setName(asset.getHeader().getName()); } final Model created = super.createAsset(asset, projectId, hasWritePermission); @@ -175,7 +175,7 @@ public Optional updateAsset( final UUID projectId, final Schema.Permission hasWritePermission ) throws IOException, IllegalArgumentException { - if (asset.getHeader().getName() != null) { + if (asset.getHeader() != null && asset.getHeader().getName() != null) { asset.setName(asset.getHeader().getName()); } final Optional updatedOptional = super.updateAsset(asset, projectId, hasWritePermission);