Browse Source

Merge branch 'master' of github.com:thingsboard/thingsboard

pull/992/head
Andrew Shvayka 8 years ago
parent
commit
4d5ad6d882
  1. 2
      application/src/main/java/org/thingsboard/server/actors/ruleChain/RemoteToRuleChainTellNextMsg.java
  2. 4
      application/src/main/java/org/thingsboard/server/actors/ruleChain/RuleNodeToRuleChainTellNextMsg.java
  3. 3
      application/src/main/resources/thingsboard.yml
  4. 1
      common/data/src/main/java/org/thingsboard/server/common/data/CacheConstants.java
  5. 2
      dao/src/main/java/org/thingsboard/server/dao/asset/AssetService.java
  6. 29
      dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java
  7. 3
      dao/src/test/resources/application-test.properties
  8. 86
      ui/src/app/locale/locale.constant-it_IT.json

2
application/src/main/java/org/thingsboard/server/actors/ruleChain/RemoteToRuleChainTellNextMsg.java

@ -28,7 +28,7 @@ import java.io.Serializable;
* Created by ashvayka on 19.03.18. * Created by ashvayka on 19.03.18.
*/ */
@Data @Data
final class RemoteToRuleChainTellNextMsg extends RuleNodeToRuleChainTellNextMsg implements TenantAwareMsg, RuleChainAwareMsg, Serializable { final class RemoteToRuleChainTellNextMsg extends RuleNodeToRuleChainTellNextMsg implements TenantAwareMsg, RuleChainAwareMsg {
private static final long serialVersionUID = 2459605482321657447L; private static final long serialVersionUID = 2459605482321657447L;
private final TenantId tenantId; private final TenantId tenantId;

4
application/src/main/java/org/thingsboard/server/actors/ruleChain/RuleNodeToRuleChainTellNextMsg.java

@ -21,14 +21,16 @@ import org.thingsboard.server.common.msg.MsgType;
import org.thingsboard.server.common.msg.TbActorMsg; import org.thingsboard.server.common.msg.TbActorMsg;
import org.thingsboard.server.common.msg.TbMsg; import org.thingsboard.server.common.msg.TbMsg;
import java.io.Serializable;
import java.util.Set; import java.util.Set;
/** /**
* Created by ashvayka on 19.03.18. * Created by ashvayka on 19.03.18.
*/ */
@Data @Data
class RuleNodeToRuleChainTellNextMsg implements TbActorMsg { class RuleNodeToRuleChainTellNextMsg implements TbActorMsg, Serializable {
private static final long serialVersionUID = 4577026446412871820L;
private final RuleNodeId originator; private final RuleNodeId originator;
private final Set<String> relationTypes; private final Set<String> relationTypes;
private final TbMsg msg; private final TbMsg msg;

3
application/src/main/resources/thingsboard.yml

@ -291,6 +291,9 @@ caffeine:
devices: devices:
timeToLiveInMinutes: 1440 timeToLiveInMinutes: 1440
maxSize: 100000 maxSize: 100000
assets:
timeToLiveInMinutes: 1440
maxSize: 100000
redis: redis:
# standalone or cluster # standalone or cluster

1
common/data/src/main/java/org/thingsboard/server/common/data/CacheConstants.java

@ -19,4 +19,5 @@ public class CacheConstants {
public static final String DEVICE_CREDENTIALS_CACHE = "deviceCredentials"; public static final String DEVICE_CREDENTIALS_CACHE = "deviceCredentials";
public static final String RELATIONS_CACHE = "relations"; public static final String RELATIONS_CACHE = "relations";
public static final String DEVICE_CACHE = "devices"; public static final String DEVICE_CACHE = "devices";
public static final String ASSET_CACHE = "assets";
} }

2
dao/src/main/java/org/thingsboard/server/dao/asset/AssetService.java

@ -34,7 +34,7 @@ public interface AssetService {
ListenableFuture<Asset> findAssetByIdAsync(AssetId assetId); ListenableFuture<Asset> findAssetByIdAsync(AssetId assetId);
Optional<Asset> findAssetByTenantIdAndName(TenantId tenantId, String name); Asset findAssetByTenantIdAndName(TenantId tenantId, String name);
Asset saveAsset(Asset asset); Asset saveAsset(Asset asset);

29
dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java

@ -21,6 +21,10 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.Customer;
@ -48,15 +52,12 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.thingsboard.server.common.data.CacheConstants.ASSET_CACHE;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs; import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
import static org.thingsboard.server.dao.service.Validator.validateId; import static org.thingsboard.server.dao.service.Validator.*;
import static org.thingsboard.server.dao.service.Validator.validateIds;
import static org.thingsboard.server.dao.service.Validator.validatePageLink;
import static org.thingsboard.server.dao.service.Validator.validateString;
@Service @Service
@Slf4j @Slf4j
@ -75,6 +76,9 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
@Autowired @Autowired
private CustomerDao customerDao; private CustomerDao customerDao;
@Autowired
private CacheManager cacheManager;
@Override @Override
public Asset findAssetById(AssetId assetId) { public Asset findAssetById(AssetId assetId) {
log.trace("Executing findAssetById [{}]", assetId); log.trace("Executing findAssetById [{}]", assetId);
@ -89,13 +93,16 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
return assetDao.findByIdAsync(assetId.getId()); return assetDao.findByIdAsync(assetId.getId());
} }
@Cacheable(cacheNames = ASSET_CACHE, key = "{#tenantId, #name}")
@Override @Override
public Optional<Asset> findAssetByTenantIdAndName(TenantId tenantId, String name) { public Asset findAssetByTenantIdAndName(TenantId tenantId, String name) {
log.trace("Executing findAssetByTenantIdAndName [{}][{}]", tenantId, name); log.trace("Executing findAssetByTenantIdAndName [{}][{}]", tenantId, name);
validateId(tenantId, INCORRECT_TENANT_ID + tenantId); validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
return assetDao.findAssetsByTenantIdAndName(tenantId.getId(), name); return assetDao.findAssetsByTenantIdAndName(tenantId.getId(), name)
.orElse(null);
} }
@CacheEvict(cacheNames = ASSET_CACHE, key = "{#asset.tenantId, #asset.name}")
@Override @Override
public Asset saveAsset(Asset asset) { public Asset saveAsset(Asset asset) {
log.trace("Executing saveAsset [{}]", asset); log.trace("Executing saveAsset [{}]", asset);
@ -122,6 +129,14 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
log.trace("Executing deleteAsset [{}]", assetId); log.trace("Executing deleteAsset [{}]", assetId);
validateId(assetId, INCORRECT_ASSET_ID + assetId); validateId(assetId, INCORRECT_ASSET_ID + assetId);
deleteEntityRelations(assetId); deleteEntityRelations(assetId);
Cache cache = cacheManager.getCache(ASSET_CACHE);
Asset asset = assetDao.findById(assetId.getId());
List<Object> list = new ArrayList<>();
list.add(asset.getTenantId());
list.add(asset.getName());
cache.evict(list);
assetDao.removeById(assetId.getId()); assetDao.removeById(assetId.getId());
} }

3
dao/src/test/resources/application-test.properties

@ -21,6 +21,9 @@ caffeine.specs.deviceCredentials.maxSize=100000
caffeine.specs.devices.timeToLiveInMinutes=1440 caffeine.specs.devices.timeToLiveInMinutes=1440
caffeine.specs.devices.maxSize=100000 caffeine.specs.devices.maxSize=100000
caffeine.specs.assets.timeToLiveInMinutes=1440
caffeine.specs.assets.maxSize=100000
caching.specs.devices.timeToLiveInMinutes=1440 caching.specs.devices.timeToLiveInMinutes=1440
caching.specs.devices.maxSize=100000 caching.specs.devices.maxSize=100000

86
ui/src/app/locale/locale.constant-it_IT.json

@ -498,25 +498,25 @@
"public-link": "Link pubblico", "public-link": "Link pubblico",
"copy-public-link": "Copia link pubblico", "copy-public-link": "Copia link pubblico",
"public-link-copied-message": "Link pubblico della dashboard copiato negli appunti", "public-link-copied-message": "Link pubblico della dashboard copiato negli appunti",
"manage-states": "Manage dashboard states", "manage-states": "Gestisci stati dashboard",
"states": "Dashboard states", "states": "Stati dashboard",
"search-states": "Search dashboard states", "search-states": "Ricerca stati dashboard",
"selected-states": "{ count, plural, 1 {1 dashboard state} other {# dashboard states} } selected", "selected-states": "{ count, plural, 1 {1 stato dashboard selezionato} other {# stati dashboard selezionati} }",
"edit-state": "Edit dashboard state", "edit-state": "Modifica stato dashboard",
"delete-state": "Delete dashboard state", "delete-state": "Elimina stato dashboard",
"add-state": "Add dashboard state", "add-state": "Aggiungi stato dashboard",
"state": "Dashboard state", "state": "Stato dashboard",
"state-name": "Nome", "state-name": "Nome",
"state-name-required": "Dashboard state name is required.", "state-name-required": "Nome stato dashboard obbligatorio.",
"state-id": "State Id", "state-id": "Id stato",
"state-id-required": "Dashboard state id is required.", "state-id-required": "Id stato dashboard obbligatorio.",
"state-id-exists": "Dashboard state with the same id is already exists.", "state-id-exists": "Uno stato della dashboard con lo stesso id è già presente.",
"is-root-state": "Root state", "is-root-state": "Stato radice",
"delete-state-title": "Delete dashboard state", "delete-state-title": "Elimina stato dashboard",
"delete-state-text": "Are you sure you want delete dashboard state with name '{{stateName}}'?", "delete-state-text": "Sei sicuro di voler eliminare lo stato della dashboard di nome '{{stateName}}'?",
"show-details": "Mostra dettagli", "show-details": "Mostra dettagli",
"hide-details": "Nascondi dettagli", "hide-details": "Nascondi dettagli",
"select-state": "Select target state", "select-state": "Seleziona stato target",
"state-controller": "Stato controller" "state-controller": "Stato controller"
}, },
"datakey": { "datakey": {
@ -570,7 +570,7 @@
"alias-required": "Alias dispositivo richesto.", "alias-required": "Alias dispositivo richesto.",
"remove-alias": "Rimuovi alias dispositivo", "remove-alias": "Rimuovi alias dispositivo",
"add-alias": "Aggiungi alias dispositivo", "add-alias": "Aggiungi alias dispositivo",
"name-starts-with": "Dispositivo il cui nome comincia per", "name-starts-with": "Dispositivo il cui nome inizia per",
"device-list": "Lista dispositivi", "device-list": "Lista dispositivi",
"use-device-name-filter": "Usa filtro", "use-device-name-filter": "Usa filtro",
"device-list-empty": "Nessun dispositivo selezionato.", "device-list-empty": "Nessun dispositivo selezionato.",
@ -680,7 +680,7 @@
"entity-list-empty": "Nessuna entità selezionata.", "entity-list-empty": "Nessuna entità selezionata.",
"entity-type-list-empty": "Nessun tipo di entità selezionato.", "entity-type-list-empty": "Nessun tipo di entità selezionato.",
"entity-name-filter-required": "Filtro nome entità obbligatorio.", "entity-name-filter-required": "Filtro nome entità obbligatorio.",
"entity-name-filter-no-entity-matched": "No entities starting with '{{entity}}' were found.", "entity-name-filter-no-entity-matched": "Nessuna entità che inizia per '{{entity}}' è stata trovata.",
"all-subtypes": "Tutte", "all-subtypes": "Tutte",
"select-entities": "Seleziona entità", "select-entities": "Seleziona entità",
"no-aliases-found": "Nessun alias trovato.", "no-aliases-found": "Nessun alias trovato.",
@ -733,7 +733,7 @@
"type-rulechains": "Rule chains", "type-rulechains": "Rule chains",
"list-of-rulechains": "{ count, plural, 1 {One rule chain} other {List of # rule chains} }", "list-of-rulechains": "{ count, plural, 1 {One rule chain} other {List of # rule chains} }",
"rulechain-name-starts-with": "Rule chains whose names start with '{{prefix}}'", "rulechain-name-starts-with": "Rule chains whose names start with '{{prefix}}'",
"type-current-customer": "Current Customer", "type-current-customer": "Cliente attuale",
"search": "Ricerca entità", "search": "Ricerca entità",
"selected-entities": "{ count, plural, 1 {1 entità selezionata} other {# entità selezionate} }", "selected-entities": "{ count, plural, 1 {1 entità selezionata} other {# entità selezionate} }",
"entity-name": "Nome entità", "entity-name": "Nome entità",
@ -788,13 +788,13 @@
"delete-extension-text": "Attenzione, dopo la conferma l'estensione e tutti i suoi data non saranno più recuperabili.", "delete-extension-text": "Attenzione, dopo la conferma l'estensione e tutti i suoi data non saranno più recuperabili.",
"delete-extensions-title": "Sei sicuro di voler eliminare { count, plural, 1 {1 estensione} other {# estensioni} }?", "delete-extensions-title": "Sei sicuro di voler eliminare { count, plural, 1 {1 estensione} other {# estensioni} }?",
"delete-extensions-text": "Attenzione, dopo la conferma tutte le estensioni selezionate saranno eliminate.", "delete-extensions-text": "Attenzione, dopo la conferma tutte le estensioni selezionate saranno eliminate.",
"converters": "Converters", "converters": "Convertitori",
"converter-id": "Converter id", "converter-id": "Id convertitore",
"configuration": "Configurazione", "configuration": "Configurazione",
"converter-configurations": "Converter configurations", "converter-configurations": "Configurazioni convertitore",
"token": "Token di sicurezza", "token": "Token di sicurezza",
"add-converter": "Add converter", "add-converter": "Aggiungi convertitore",
"add-config": "Add converter configuration", "add-config": "Aggiungi configurazione convertitore",
"device-name-expression": "Device name expression", "device-name-expression": "Device name expression",
"device-type-expression": "Device type expression", "device-type-expression": "Device type expression",
"custom": "Custom", "custom": "Custom",
@ -828,7 +828,7 @@
"drop-file": "Trascina un file o fai clic per selezionare un file da caricare.", "drop-file": "Trascina un file o fai clic per selezionare un file da caricare.",
"mapping": "Mapping", "mapping": "Mapping",
"topic-filter": "Filtro topic", "topic-filter": "Filtro topic",
"converter-type": "Converter type", "converter-type": "Tipo convertitore",
"converter-json": "Json", "converter-json": "Json",
"json-name-expression": "Device name json expression", "json-name-expression": "Device name json expression",
"topic-name-expression": "Device name topic expression", "topic-name-expression": "Device name topic expression",
@ -847,10 +847,10 @@
"converter-json-required": "Convertitore json obbligatorio.", "converter-json-required": "Convertitore json obbligatorio.",
"converter-json-parse": "Unable to parse converter json.", "converter-json-parse": "Unable to parse converter json.",
"filter-expression": "Filter expression", "filter-expression": "Filter expression",
"connect-requests": "Connect requests", "connect-requests": "Richieste di connessione",
"add-connect-request": "Add connect request", "add-connect-request": "Aggiungi richiesta di connessione",
"disconnect-requests": "Disconnect requests", "disconnect-requests": "Richieste di disconnessione",
"add-disconnect-request": "Add disconnect request", "add-disconnect-request": "Aggiungi richiesta di disconnessione",
"attribute-requests": "Attribute requests", "attribute-requests": "Attribute requests",
"add-attribute-request": "Add attribute request", "add-attribute-request": "Add attribute request",
"attribute-updates": "Attribute updates", "attribute-updates": "Attribute updates",
@ -919,8 +919,8 @@
"not-available": "Non disponibile" "not-available": "Non disponibile"
}, },
"export-extensions-configuration": "Export extensions configuration", "export-extensions-configuration": "Esporta configurazione estensioni",
"import-extensions-configuration": "Import extensions configuration", "import-extensions-configuration": "Importa configurazione estensioni",
"import-extensions": "Importa estensione", "import-extensions": "Importa estensione",
"import-extension": "Importa estensione", "import-extension": "Importa estensione",
"export-extension": "Esporta estensione", "export-extension": "Esporta estensione",
@ -928,7 +928,7 @@
"invalid-file-error": "File estensione non valido" "invalid-file-error": "File estensione non valido"
}, },
"fullscreen": { "fullscreen": {
"expand": "Expand to fullscreen", "expand": "Espandi a tutto schermo",
"exit": "Esci da schermo intero", "exit": "Esci da schermo intero",
"toggle": "Commuta modalità schermo intero", "toggle": "Commuta modalità schermo intero",
"fullscreen": "Schermo intero" "fullscreen": "Schermo intero"
@ -937,16 +937,16 @@
"function": "Funzione" "function": "Funzione"
}, },
"grid": { "grid": {
"delete-item-title": "Are you sure you want to delete this item?", "delete-item-title": "Sei sicuro di voler eliminare questo elemento?",
"delete-item-text": "Be careful, after the confirmation this item and all related data will become unrecoverable.", "delete-item-text": "Attenzione, dopo la conferma questo elemento e tutti i suoi dati non saranno più recuperabili.",
"delete-items-title": "Are you sure you want to delete { count, plural, 1 {1 item} other {# items} }?", "delete-items-title": "Sei sicuro di voler eliminare { count, plural, 1 {1 elemento} other {# elementi} }?",
"delete-items-action-title": "Delete { count, plural, 1 {1 item} other {# items} }", "delete-items-action-title": "Elimina { count, plural, 1 {1 elemento} other {# elementi} }",
"delete-items-text": "Be careful, after the confirmation all selected items will be removed and all related data will become unrecoverable.", "delete-items-text": "Attenzione, dopo la conferma tutti gli elementi selezionati saranno rimossi e i relativi dati non saranno più recuperabili.",
"add-item-text": "Add new item", "add-item-text": "Aggiungi nuovo elemento",
"no-items-text": "No items found", "no-items-text": "Nessun elemento trovato",
"item-details": "Item details", "item-details": "Dettagli elemento",
"delete-item": "Delete Item", "delete-item": "Elimina elemento",
"delete-items": "Delete Items", "delete-items": "Elimina elementi",
"scroll-to-top": "Scroll to top" "scroll-to-top": "Scroll to top"
}, },
"help": { "help": {
@ -985,7 +985,7 @@
"settings": "Impostazioni layout", "settings": "Impostazioni layout",
"color": "Colore", "color": "Colore",
"main": "Main", "main": "Main",
"right": "Right", "right": "Destra",
"select": "Select target layout" "select": "Select target layout"
}, },
"legend": { "legend": {

Loading…
Cancel
Save