Search in sources :

Example 1 with ParentPredicate

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;
}
Also used : ConsoleAsset(org.openremote.model.asset.impl.ConsoleAsset) ParentPredicate(org.openremote.model.query.filter.ParentPredicate) StringPredicate(org.openremote.model.query.filter.StringPredicate) AssetQuery(org.openremote.model.query.AssetQuery) GroupAsset(org.openremote.model.asset.impl.GroupAsset) TenantPredicate(org.openremote.model.query.filter.TenantPredicate) AttributePredicate(org.openremote.model.query.filter.AttributePredicate)

Aggregations

ConsoleAsset (org.openremote.model.asset.impl.ConsoleAsset)1 GroupAsset (org.openremote.model.asset.impl.GroupAsset)1 AssetQuery (org.openremote.model.query.AssetQuery)1 AttributePredicate (org.openremote.model.query.filter.AttributePredicate)1 ParentPredicate (org.openremote.model.query.filter.ParentPredicate)1 StringPredicate (org.openremote.model.query.filter.StringPredicate)1 TenantPredicate (org.openremote.model.query.filter.TenantPredicate)1