@ -15,30 +15,21 @@
* /
* /
package org.thingsboard.server.dao.entityview ;
package org.thingsboard.server.dao.entityview ;
import com.google.common.base.Function ;
import com.google.common.util.concurrent.FutureCallback ;
import com.google.common.util.concurrent.FutureCallback ;
import com.google.common.util.concurrent.Futures ;
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.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
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.CacheManager ;
import org.springframework.cache.annotation.CacheEvict ;
import org.springframework.cache.annotation.CachePut ;
import org.springframework.cache.annotation.Cacheable ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.thingsboard.server.common.data.Customer ;
import org.thingsboard.server.common.data.Customer ;
import org.thingsboard.server.common.data.DataConstants ;
import org.thingsboard.server.common.data.DataConstants ;
import org.thingsboard.server.common.data.Device ;
import org.thingsboard.server.common.data.EntitySubtype ;
import org.thingsboard.server.common.data.EntityType ;
import org.thingsboard.server.common.data.EntityType ;
import org.thingsboard.server.common.data.EntityView ;
import org.thingsboard.server.common.data.EntityView ;
import org.thingsboard.server.common.data.Tenant ;
import org.thingsboard.server.common.data.Tenant ;
import org.thingsboard.server.common.data.device.DeviceSearchQuery ;
import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery ;
import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery ;
import org.thingsboard.server.common.data.id.CustomerId ;
import org.thingsboard.server.common.data.id.CustomerId ;
import org.thingsboard.server.common.data.id.DeviceId ;
import org.thingsboard.server.common.data.id.EntityId ;
import org.thingsboard.server.common.data.id.EntityId ;
import org.thingsboard.server.common.data.id.EntityViewId ;
import org.thingsboard.server.common.data.id.EntityViewId ;
import org.thingsboard.server.common.data.id.TenantId ;
import org.thingsboard.server.common.data.id.TenantId ;
@ -58,13 +49,9 @@ import org.thingsboard.server.dao.tenant.TenantDao;
import javax.annotation.Nullable ;
import javax.annotation.Nullable ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.Collection ;
import java.util.Collections ;
import java.util.Comparator ;
import java.util.List ;
import java.util.List ;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
import static org.thingsboard.server.common.data.CacheConstants.DEVICE_CACHE ;
import static org.thingsboard.server.common.data.CacheConstants.ENTITY_VIEW_CACHE ;
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.validateId ;
import static org.thingsboard.server.dao.service.Validator.validatePageLink ;
import static org.thingsboard.server.dao.service.Validator.validatePageLink ;
@ -135,17 +122,17 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
List < AttributeKvEntry > filteredAttributes =
List < AttributeKvEntry > filteredAttributes =
attributeKvEntries . stream ( )
attributeKvEntries . stream ( )
. filter ( attributeKvEntry - > {
. filter ( attributeKvEntry - > {
if ( entityView . getStartTs ( ) = = 0 & & entityView . getEndTs ( ) = = 0 ) {
if ( entityView . getStartTimeM s ( ) = = 0 & & entityView . getEndTimeM s ( ) = = 0 ) {
return true ;
return true ;
}
}
if ( entityView . getEndTs ( ) = = 0 & & entityView . getStartTs ( ) < attributeKvEntry . getLastUpdateTs ( ) ) {
if ( entityView . getEndTimeM s ( ) = = 0 & & entityView . getStartTimeM s ( ) < attributeKvEntry . getLastUpdateTs ( ) ) {
return true ;
return true ;
}
}
if ( entityView . getStartTs ( ) = = 0 & & entityView . getEndTs ( ) > attributeKvEntry . getLastUpdateTs ( ) ) {
if ( entityView . getStartTimeM s ( ) = = 0 & & entityView . getEndTimeM s ( ) > attributeKvEntry . getLastUpdateTs ( ) ) {
return true ;
return true ;
}
}
return entityView . getStartTs ( ) < attributeKvEntry . getLastUpdateTs ( )
return entityView . getStartTimeM s ( ) < attributeKvEntry . getLastUpdateTs ( )
& & entityView . getEndTs ( ) > attributeKvEntry . getLastUpdateTs ( ) ;
& & entityView . getEndTimeM s ( ) > attributeKvEntry . getLastUpdateTs ( ) ;
} ) . collect ( Collectors . toList ( ) ) ;
} ) . collect ( Collectors . toList ( ) ) ;
attributesService . save ( entityView . getId ( ) , scope , filteredAttributes ) ;
attributesService . save ( entityView . getId ( ) , scope , filteredAttributes ) ;
}
}