update asset descriptor retrieval and editing for composite assets
All checks were successful
Build / build (push) Successful in 1m28s
All checks were successful
Build / build (push) Successful in 1m28s
This commit is contained in:
@@ -352,7 +352,7 @@ public class WebController {
|
||||
String assetType = asset.getAsset().getType();
|
||||
model.addAttribute(ACTION, "edit");
|
||||
model.addAttribute(ASSET, asset);
|
||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(assetType));
|
||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(asset));
|
||||
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
||||
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
||||
model.addAttribute(BUILDS, buildService.getAllBuilds());
|
||||
@@ -374,7 +374,7 @@ public class WebController {
|
||||
String assetType = asset.getAsset().getType();
|
||||
model.addAttribute(ACTION, "duplicate");
|
||||
model.addAttribute(ASSET, asset);
|
||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(assetType));
|
||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(asset));
|
||||
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
||||
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
||||
return "create_asset";
|
||||
|
||||
@@ -160,10 +160,10 @@ public class AssetService {
|
||||
* Retrieves a tree of asset descriptors for the specified composite.
|
||||
*
|
||||
* @param composite the composite to retrieve descriptors for
|
||||
* @return a list of AssetDescriptors for the composite
|
||||
* @return a set of AssetDescriptors for the composite
|
||||
*/
|
||||
public List<AssetDescriptor> getAssetDescriptorTree(Composite composite) {
|
||||
var tree = new ArrayList<AssetDescriptor>();
|
||||
public Set<AssetDescriptor> getAssetDescriptorTree(Composite composite) {
|
||||
var tree = new TreeSet<>(Comparator.comparing(AssetDescriptor::getDisplayName));
|
||||
tree.add(getAssetDescriptor(GenericAsset.TYPE));
|
||||
for (var asset : composite.getAssets()) {
|
||||
tree.add(getAssetDescriptor(asset));
|
||||
@@ -235,20 +235,21 @@ public class AssetService {
|
||||
*/
|
||||
@Transactional
|
||||
public Asset editAsset(long qr, Map<String, String> formData) {
|
||||
var genericAsset = genericRepository.findByQr(qr);
|
||||
if (genericAsset == null) {
|
||||
var composite = getAssetByQr(qr);
|
||||
if (composite == null) {
|
||||
throw new IllegalArgumentException("No asset found with QR code: " + qr);
|
||||
}
|
||||
|
||||
var assetType = genericAsset.getType();
|
||||
var assetDescriptor = getAssetDescriptor(assetType);
|
||||
var asset = getRepositoryFor(assetType).findByAsset(genericAsset);
|
||||
fillIn(composite.getGenericAsset(), getAssetDescriptor(GenericAsset.TYPE), formData);
|
||||
genericRepository.saveAndFlush(composite.getGenericAsset());
|
||||
|
||||
fillIn(genericAsset, getAssetDescriptor(GenericAsset.TYPE), formData);
|
||||
for (var asset : composite.getAssets()) {
|
||||
var assetDescriptor = getAssetDescriptor(asset);
|
||||
fillIn(asset, assetDescriptor, formData);
|
||||
getRepositoryFor(assetDescriptor.getType()).saveAndFlushAsset(asset);
|
||||
}
|
||||
|
||||
genericRepository.saveAndFlush(genericAsset);
|
||||
return getRepositoryFor(assetType).saveAndFlushAsset(asset);
|
||||
return getAssetByQr(qr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user