Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple non modifiable subresource with the same primary key #299

Open
deepanjan90 opened this issue Jun 1, 2020 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@deepanjan90
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In some cases there are subresource which are attached to the parent as list, i.e supporting multiple entries. Often times the api of a provider supports duplicate entries of these as they are unmodifiable.

Currently this is not supported by gyro. Results in a exception similar to

Unexpected error: java.lang.IllegalArgumentException: Multiple entries with same key: Optional[]=device  and Optional[]=device 
	at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:190)
	at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:109)
	at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:95)
	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:373)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:503)
	at gyro.core.scope.NodeEvaluator.lambda$copy$37(NodeEvaluator.java:571)
	at java.util.Optional.map(Optional.java:215)
	at gyro.core.scope.NodeEvaluator.copy(NodeEvaluator.java:571)
	at gyro.core.scope.NodeEvaluator.lambda$copy$38(NodeEvaluator.java:574)
	at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at gyro.core.scope.NodeEvaluator.copy(NodeEvaluator.java:574)
	at gyro.core.scope.NodeEvaluator.lambda$copy$38(NodeEvaluator.java:574)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at gyro.core.scope.NodeEvaluator.copy(NodeEvaluator.java:574)
	at gyro.core.scope.NodeEvaluator.lambda$visitResource$35(NodeEvaluator.java:525)
	at java.util.Optional.ifPresent(Optional.java:159)
	at gyro.core.scope.NodeEvaluator.visitResource(NodeEvaluator.java:525)
	at gyro.core.scope.NodeEvaluator.visitResource(NodeEvaluator.java:81)
	at gyro.lang.ast.block.ResourceNode.accept(ResourceNode.java:55)
	at gyro.lang.ast.NodeVisitor.visit(NodeVisitor.java:37)
	at gyro.core.scope.NodeEvaluator.lambda$evaluateBody$31(NodeEvaluator.java:341)
	at gyro.core.scope.Defer.execute(Defer.java:50)
	at gyro.core.scope.NodeEvaluator.evaluateBody(NodeEvaluator.java:341)
	at gyro.core.scope.NodeEvaluator.visitFile(NodeEvaluator.java:424)
	at gyro.core.scope.NodeEvaluator.visitFile(NodeEvaluator.java:81)
	at gyro.lang.ast.block.FileNode.accept(FileNode.java:32)
	at gyro.lang.ast.NodeVisitor.visit(NodeVisitor.java:37)
	at gyro.core.scope.NodeEvaluator.lambda$evaluateBody$31(NodeEvaluator.java:341)
	at gyro.core.scope.Defer.execute(Defer.java:50)
	at gyro.core.scope.NodeEvaluator.evaluateBody(NodeEvaluator.java:341)
	at gyro.core.scope.NodeEvaluator.evaluate(NodeEvaluator.java:325)
	at gyro.core.scope.RootScope.evaluate(RootScope.java:443)
	at gyro.core.command.AbstractConfigCommand.doExecute(AbstractConfigCommand.java:179)
	at gyro.core.command.AbstractCommand.execute(AbstractCommand.java:75)
	at gyro.cli.Gyro.run(Gyro.java:205)
	at gyro.cli.Gyro.main(Gyro.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

Describe the solution you'd like
Gyro should support duplicate primary keys for subresources where subresources are unmodifiable. Have a way to for gyro to know that these subresources are unmodifiable and allow duplicate primary keys for these.

Describe alternatives you've considered

  • Have another abstract class FinalDiffable that extends Diffable. Gyro ignores checking for duplicate keys of instances of FinalDiffable.

  • let gyro go through all the fields in the subresource and find if none of the fields have the @Updatable annotation then consider the subresource as unmodifiable

@deepanjan90 deepanjan90 added the enhancement New feature or request label Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant