Search in sources :

Example 16 with DefaultTenantProfileConfiguration

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

the class BaseTenantProfileServiceTest method createTenantProfile.

public static TenantProfile createTenantProfile(String name) {
    TenantProfile tenantProfile = new TenantProfile();
    tenantProfile.setName(name);
    tenantProfile.setDescription(name + " Test");
    TenantProfileData profileData = new TenantProfileData();
    profileData.setConfiguration(new DefaultTenantProfileConfiguration());
    tenantProfile.setProfileData(profileData);
    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)

Example 17 with DefaultTenantProfileConfiguration

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

the class DefaultTransportRateLimitService method createRateLimits.

private EntityTransportRateLimits createRateLimits(TenantProfile tenantProfile, boolean tenant) {
    TenantProfileData profileData = tenantProfile.getProfileData();
    DefaultTenantProfileConfiguration profile = (DefaultTenantProfileConfiguration) profileData.getConfiguration();
    if (profile == null) {
        return new EntityTransportRateLimits(ALLOW, ALLOW, ALLOW);
    } else {
        TransportRateLimit regularMsgRateLimit = newLimit(tenant ? profile.getTransportTenantMsgRateLimit() : profile.getTransportDeviceMsgRateLimit());
        TransportRateLimit telemetryMsgRateLimit = newLimit(tenant ? profile.getTransportTenantTelemetryMsgRateLimit() : profile.getTransportDeviceTelemetryMsgRateLimit());
        TransportRateLimit telemetryDpRateLimit = newLimit(tenant ? profile.getTransportTenantTelemetryDataPointsRateLimit() : profile.getTransportTenantTelemetryDataPointsRateLimit());
        return new EntityTransportRateLimits(regularMsgRateLimit, telemetryMsgRateLimit, telemetryDpRateLimit);
    }
}
Also used : TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 18 with DefaultTenantProfileConfiguration

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

the class RuleChainDataValidator method validateCreate.

@Override
protected void validateCreate(TenantId tenantId, RuleChain data) {
    DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
    long maxRuleChains = profileConfiguration.getMaxRuleChains();
    validateNumberOfEntitiesPerTenant(tenantId, ruleChainDao, maxRuleChains, EntityType.RULE_CHAIN);
}
Also used : DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 19 with DefaultTenantProfileConfiguration

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

the class UserDataValidator method validateCreate.

@Override
protected void validateCreate(TenantId tenantId, User user) {
    if (!user.getTenantId().getId().equals(ModelConstants.NULL_UUID)) {
        DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
        long maxUsers = profileConfiguration.getMaxUsers();
        validateNumberOfEntitiesPerTenant(tenantId, userDao, maxUsers, EntityType.USER);
    }
}
Also used : DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 20 with DefaultTenantProfileConfiguration

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

the class CustomerDataValidator method validateCreate.

@Override
protected void validateCreate(TenantId tenantId, Customer customer) {
    DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
    long maxCustomers = profileConfiguration.getMaxCustomers();
    validateNumberOfEntitiesPerTenant(tenantId, customerDao, maxCustomers, EntityType.CUSTOMER);
    customerDao.findCustomersByTenantIdAndTitle(customer.getTenantId().getId(), customer.getTitle()).ifPresent(c -> {
        throw new DataValidationException("Customer with such title already exists!");
    });
}
Also used : DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Aggregations

DefaultTenantProfileConfiguration (org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)22 TenantProfile (org.thingsboard.server.common.data.TenantProfile)8 TenantProfileData (org.thingsboard.server.common.data.tenant.profile.TenantProfileData)7 TenantId (org.thingsboard.server.common.data.id.TenantId)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 PageLink (org.thingsboard.server.common.data.page.PageLink)2 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 JsonParser (com.google.gson.JsonParser)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Arrays (java.util.Arrays)1