Skip to content

Commit

Permalink
NOJIRA - handling migration of values for existing bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
chasegawa committed Sep 26, 2024
1 parent 002234c commit 09afabb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JsonSchemaBuilderService {
List<Object> result = new ArrayList<>()
List<String> resultNames = new ArrayList<>()
attributeBundleService.findAll().forEach({ bundle ->
result.add(bundle.getAttributes())
result.add(bundle.getAttributeNames())
resultNames.add(bundle.getName())
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ void doAttributeBundleMigration() {
attributeBundleRepository.findAll().forEach(attrBundleEntry -> {
try {
Set<String> names = new HashSet<String>();
attrBundleEntry.getAttributes().forEach(value -> {
attrBundleEntry.getAttributeNames().forEach(value -> {
names.add(BundleableAttributeType.values()[Integer.parseInt(value)].label());
});
attrBundleEntry.setAttributes(names);
attrBundleEntry.setAttributeNames(names);
attributeBundleRepository.save(attrBundleEntry);
}
catch (NumberFormatException ignore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ResponseEntity<?> getBundleSchema() {
itemsMap.put("type", "string");
itemsMap.put("enum", getAttributeNames());
attributesMap.put("items", itemsMap);
props.put("attributes", attributesMap);
props.put("attributeNames", attributesMap);
result.put("properties", props);
return ResponseEntity.ok(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class AttributeBundle {
@Column(name="attribute_names", nullable = false)
@ElementCollection
Set<String> attributes = new HashSet<>();
Set<String> attributeNames = new HashSet<>();

@Column(name = "name", nullable = true)
String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public AttributeBundle updateBundle(AttributeBundle bundle) throws PersistentEnt
}
AttributeBundle bundleToUpdate = dbBundle.get();
bundleToUpdate.setName(bundle.getName());
bundleToUpdate.setAttributes(bundle.getAttributes());
bundleToUpdate.setAttributeNames(bundle.getAttributeNames());
return attributeBundleRepository.save(bundleToUpdate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const AttributeBundleDefinition = {
steps: [],
schema: `${BASE_PATH}api/custom/entity/bundles/bundle_schema`,
uiSchema: {
attributes: {
attributeNames: {
'ui:widget': 'AttributeReleaseWidget'
}
},
Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/metadata/view/MetadataAttributeBundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function MetadataAttributeBundles() {
<AttributeBundleApi>
{(load, find, create, update, remove, loading) =>
<AttributeBundleList load={load}>
{(bundles, reload) =>
{(bundles, reload) =>
<div className="container-fluid p-3">
<section className="section">
<div className="section-body border border-top-0 border-primary">
Expand Down Expand Up @@ -49,7 +49,7 @@ export function MetadataAttributeBundles() {
{bundles.map((bundle, i) =>
<tr key={i}>
<td>{ bundle.name }</td>
<td><TruncateText text={ bundle?.attributes?.join(', ') } /></td>
<td><TruncateText text={ bundle?.attributeNames?.join(', ') } /></td>
<td className="text-end">
<Link to={`../bundles/${bundle.resourceId}/edit`} className="btn btn-link text-primary">
<FontAwesomeIcon icon={faEdit} size="lg" />
Expand All @@ -71,12 +71,12 @@ export function MetadataAttributeBundles() {
</div>
</div>
</div>

</section>
</div>
}
</AttributeBundleList>
}
</AttributeBundleApi>
);
}
}

0 comments on commit 09afabb

Please sign in to comment.