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();
|
String assetType = asset.getAsset().getType();
|
||||||
model.addAttribute(ACTION, "edit");
|
model.addAttribute(ACTION, "edit");
|
||||||
model.addAttribute(ASSET, asset);
|
model.addAttribute(ASSET, asset);
|
||||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(assetType));
|
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(asset));
|
||||||
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
||||||
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
||||||
model.addAttribute(BUILDS, buildService.getAllBuilds());
|
model.addAttribute(BUILDS, buildService.getAllBuilds());
|
||||||
@@ -374,7 +374,7 @@ public class WebController {
|
|||||||
String assetType = asset.getAsset().getType();
|
String assetType = asset.getAsset().getType();
|
||||||
model.addAttribute(ACTION, "duplicate");
|
model.addAttribute(ACTION, "duplicate");
|
||||||
model.addAttribute(ASSET, asset);
|
model.addAttribute(ASSET, asset);
|
||||||
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(assetType));
|
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(asset));
|
||||||
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(assetType));
|
||||||
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
model.addAttribute(INPUT_LIST, assetService.getInputList(assetType));
|
||||||
return "create_asset";
|
return "create_asset";
|
||||||
|
|||||||
@@ -160,10 +160,10 @@ public class AssetService {
|
|||||||
* Retrieves a tree of asset descriptors for the specified composite.
|
* Retrieves a tree of asset descriptors for the specified composite.
|
||||||
*
|
*
|
||||||
* @param composite the composite to retrieve descriptors for
|
* @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) {
|
public Set<AssetDescriptor> getAssetDescriptorTree(Composite composite) {
|
||||||
var tree = new ArrayList<AssetDescriptor>();
|
var tree = new TreeSet<>(Comparator.comparing(AssetDescriptor::getDisplayName));
|
||||||
tree.add(getAssetDescriptor(GenericAsset.TYPE));
|
tree.add(getAssetDescriptor(GenericAsset.TYPE));
|
||||||
for (var asset : composite.getAssets()) {
|
for (var asset : composite.getAssets()) {
|
||||||
tree.add(getAssetDescriptor(asset));
|
tree.add(getAssetDescriptor(asset));
|
||||||
@@ -235,20 +235,21 @@ public class AssetService {
|
|||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public Asset editAsset(long qr, Map<String, String> formData) {
|
public Asset editAsset(long qr, Map<String, String> formData) {
|
||||||
var genericAsset = genericRepository.findByQr(qr);
|
var composite = getAssetByQr(qr);
|
||||||
if (genericAsset == null) {
|
if (composite == null) {
|
||||||
throw new IllegalArgumentException("No asset found with QR code: " + qr);
|
throw new IllegalArgumentException("No asset found with QR code: " + qr);
|
||||||
}
|
}
|
||||||
|
|
||||||
var assetType = genericAsset.getType();
|
fillIn(composite.getGenericAsset(), getAssetDescriptor(GenericAsset.TYPE), formData);
|
||||||
var assetDescriptor = getAssetDescriptor(assetType);
|
genericRepository.saveAndFlush(composite.getGenericAsset());
|
||||||
var asset = getRepositoryFor(assetType).findByAsset(genericAsset);
|
|
||||||
|
|
||||||
fillIn(genericAsset, getAssetDescriptor(GenericAsset.TYPE), formData);
|
for (var asset : composite.getAssets()) {
|
||||||
fillIn(asset, assetDescriptor, formData);
|
var assetDescriptor = getAssetDescriptor(asset);
|
||||||
|
fillIn(asset, assetDescriptor, formData);
|
||||||
|
getRepositoryFor(assetDescriptor.getType()).saveAndFlushAsset(asset);
|
||||||
|
}
|
||||||
|
|
||||||
genericRepository.saveAndFlush(genericAsset);
|
return getAssetByQr(qr);
|
||||||
return getRepositoryFor(assetType).saveAndFlushAsset(asset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user