use of org.openremote.model.query.filter.ParentPredicate in project openremote by openremote.
the class ConsoleResourceImpl method getConsoleParentAsset.
public static Asset<?> getConsoleParentAsset(AssetStorageService assetStorageService, Tenant tenant) {
// Look for a group asset with a child type of console in the realm root
GroupAsset consoleParent = (GroupAsset) assetStorageService.find(new AssetQuery().select(new AssetQuery.Select().excludeAttributes()).names(CONSOLE_PARENT_ASSET_NAME).parents(new ParentPredicate(null)).types(GroupAsset.class).tenant(new TenantPredicate(tenant.getRealm())).attributes(new AttributePredicate("childAssetType", new StringPredicate(ConsoleAsset.DESCRIPTOR.getName()))));
if (consoleParent == null) {
consoleParent = new GroupAsset(CONSOLE_PARENT_ASSET_NAME, ConsoleAsset.class);
consoleParent.setChildAssetType(ConsoleAsset.DESCRIPTOR.getName());
consoleParent.setRealm(tenant.getRealm());
consoleParent = assetStorageService.merge(consoleParent);
}
return consoleParent;
}
Aggregations