Slackbot
08/25/2023, 10:03 AMdaniel
09/05/2023, 6:15 PMObjectFactory has factory method to create [Named|Polymorphic]DomainObject(Set|List|Container) (since 5.5/6.1) and ConfigurableFileCollection (since 5.3). That solve the issue around DefaultDomainObjectCollectionFactory and DefaultFileCollectionFactory. However, the code linked shows that you are creating more than just those two object. Essentially, you are building PrebuiltLibrary instances. I would recommend receiving the instance of Repositories via the Software Model so you can create your own PrebuiltLibraries and populate it as you want.
However, I see the issue you are facing. PrebuiltLibraries implements NamedDomainObjectSet which means you need to create your own instance to add them to the set (instead of the container counter part where you can use create). The documentation further mislead because it shows you can create instance of PrebuiltLibrary via the Groovy magic offered by NamedDomainObjectContainer. In Java, you won’t be able to replicate because PrebuiltLibraries is a NamedDomainObjectSet. However the implementation of PrebuiltLibraries extends from NamedDomainObjectContainer. I believe it’s an oversight and you should be able to cast PrebuiltLibraries into NamedDomainObjectContainer<PrebuiltLibrary> without issue. Hence, creating prebuilt libraries would just be a matter of calling create("…") .daniel
09/05/2023, 6:15 PMJan Jörke
09/11/2023, 11:43 AM