Search in sources :

Example 1 with TenantProfileData

use of org.thingsboard.server.common.data.tenant.profile.TenantProfileData in project thingsboard by thingsboard.

the class TenantProfileServiceImpl method findOrCreateDefaultTenantProfile.

@Override
public TenantProfile findOrCreateDefaultTenantProfile(TenantId tenantId) {
    log.trace("Executing findOrCreateDefaultTenantProfile");
    TenantProfile defaultTenantProfile = findDefaultTenantProfile(tenantId);
    if (defaultTenantProfile == null) {
        defaultTenantProfile = new TenantProfile();
        defaultTenantProfile.setDefault(true);
        defaultTenantProfile.setName("Default");
        TenantProfileData profileData = new TenantProfileData();
        profileData.setConfiguration(new DefaultTenantProfileConfiguration());
        defaultTenantProfile.setProfileData(profileData);
        defaultTenantProfile.setDescription("Default tenant profile");
        defaultTenantProfile.setIsolatedTbCore(false);
        defaultTenantProfile.setIsolatedTbRuleEngine(false);
        defaultTenantProfile = saveTenantProfile(tenantId, defaultTenantProfile);
    }
    return defaultTenantProfile;
}
Also used : TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) TenantProfile(org.thingsboard.server.common.data.TenantProfile) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 2 with TenantProfileData

use of org.thingsboard.server.common.data.tenant.profile.TenantProfileData in project thingsboard by thingsboard.

the class DefaultSystemDataLoaderService method createDefaultTenantProfiles.

@Override
public void createDefaultTenantProfiles() throws Exception {
    tenantProfileService.findOrCreateDefaultTenantProfile(TenantId.SYS_TENANT_ID);
    TenantProfileData tenantProfileData = new TenantProfileData();
    tenantProfileData.setConfiguration(new DefaultTenantProfileConfiguration());
    TenantProfile isolatedTbCoreProfile = new TenantProfile();
    isolatedTbCoreProfile.setDefault(false);
    isolatedTbCoreProfile.setName("Isolated TB Core");
    isolatedTbCoreProfile.setDescription("Isolated TB Core tenant profile");
    isolatedTbCoreProfile.setIsolatedTbCore(true);
    isolatedTbCoreProfile.setIsolatedTbRuleEngine(false);
    isolatedTbCoreProfile.setProfileData(tenantProfileData);
    try {
        tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, isolatedTbCoreProfile);
    } catch (DataValidationException e) {
        log.warn(e.getMessage());
    }
    TenantProfile isolatedTbRuleEngineProfile = new TenantProfile();
    isolatedTbRuleEngineProfile.setDefault(false);
    isolatedTbRuleEngineProfile.setName("Isolated TB Rule Engine");
    isolatedTbRuleEngineProfile.setDescription("Isolated TB Rule Engine tenant profile");
    isolatedTbRuleEngineProfile.setIsolatedTbCore(false);
    isolatedTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
    isolatedTbRuleEngineProfile.setProfileData(tenantProfileData);
    try {
        tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, isolatedTbRuleEngineProfile);
    } catch (DataValidationException e) {
        log.warn(e.getMessage());
    }
    TenantProfile isolatedTbCoreAndTbRuleEngineProfile = new TenantProfile();
    isolatedTbCoreAndTbRuleEngineProfile.setDefault(false);
    isolatedTbCoreAndTbRuleEngineProfile.setName("Isolated TB Core and TB Rule Engine");
    isolatedTbCoreAndTbRuleEngineProfile.setDescription("Isolated TB Core and TB Rule Engine tenant profile");
    isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbCore(true);
    isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
    isolatedTbCoreAndTbRuleEngineProfile.setProfileData(tenantProfileData);
    try {
        tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, isolatedTbCoreAndTbRuleEngineProfile);
    } catch (DataValidationException e) {
        log.warn(e.getMessage());
    }
}
Also used : DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) TenantProfile(org.thingsboard.server.common.data.TenantProfile) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 3 with TenantProfileData

use of org.thingsboard.server.common.data.tenant.profile.TenantProfileData in project thingsboard by thingsboard.

the class DefaultTbApiUsageStateService method updateTenantState.

private void updateTenantState(TenantApiUsageState state, TenantProfile profile) {
    TenantProfileData oldProfileData = state.getTenantProfileData();
    state.setTenantProfileId(profile.getId());
    state.setTenantProfileData(profile.getProfileData());
    Map<ApiFeature, ApiUsageStateValue> result = state.checkStateUpdatedDueToThresholds();
    if (!result.isEmpty()) {
        persistAndNotify(state, result);
    }
    updateProfileThresholds(state.getTenantId(), state.getApiUsageState().getId(), oldProfileData.getConfiguration(), profile.getProfileData().getConfiguration());
}
Also used : ApiFeature(org.thingsboard.server.common.data.ApiFeature) TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) ApiUsageStateValue(org.thingsboard.server.common.data.ApiUsageStateValue)

Example 4 with TenantProfileData

use of org.thingsboard.server.common.data.tenant.profile.TenantProfileData in project thingsboard by thingsboard.

the class TenantProfile method createDefaultTenantProfileData.

public TenantProfileData createDefaultTenantProfileData() {
    TenantProfileData tpd = new TenantProfileData();
    tpd.setConfiguration(new DefaultTenantProfileConfiguration());
    return tpd;
}
Also used : TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 5 with TenantProfileData

use of org.thingsboard.server.common.data.tenant.profile.TenantProfileData in project thingsboard by thingsboard.

the class BaseTenantProfileControllerTest method createTenantProfile.

private TenantProfile createTenantProfile(String name) {
    TenantProfile tenantProfile = new TenantProfile();
    tenantProfile.setName(name);
    tenantProfile.setDescription(name + " Test");
    TenantProfileData tenantProfileData = new TenantProfileData();
    tenantProfileData.setConfiguration(new DefaultTenantProfileConfiguration());
    tenantProfile.setProfileData(tenantProfileData);
    tenantProfile.setDefault(false);
    tenantProfile.setIsolatedTbCore(false);
    tenantProfile.setIsolatedTbRuleEngine(false);
    return tenantProfile;
}
Also used : TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) TenantProfile(org.thingsboard.server.common.data.TenantProfile) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Aggregations

TenantProfileData (org.thingsboard.server.common.data.tenant.profile.TenantProfileData)8 DefaultTenantProfileConfiguration (org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)7 TenantProfile (org.thingsboard.server.common.data.TenantProfile)5 Test (org.junit.Test)1 ApiFeature (org.thingsboard.server.common.data.ApiFeature)1 ApiUsageStateValue (org.thingsboard.server.common.data.ApiUsageStateValue)1 Tenant (org.thingsboard.server.common.data.Tenant)1 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)1