Misc fixes
This commit is contained in:
parent
09e90b3089
commit
5dc541eabf
@ -114,8 +114,8 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.startTs = entityView.getStartTs() != 0L ? entityView.getStartTs() : 0L;
|
||||
this.endTs = entityView.getEndTs() != 0L ? entityView.getEndTs() : 0L;
|
||||
this.startTs = entityView.getStartTs();
|
||||
this.endTs = entityView.getEndTs();
|
||||
this.searchText = entityView.getSearchText();
|
||||
this.additionalInfo = entityView.getAdditionalInfo();
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
EntityView entityView = entityViewService.findEntityViewById((EntityViewId) entityId);
|
||||
List<ReadTsKvQuery> filteredQueries =
|
||||
queries.stream()
|
||||
.filter(query -> entityView.getKeys().getTimeseries().contains(query.getKey()))
|
||||
.filter(query -> entityView.getKeys().getTimeseries().isEmpty() || entityView.getKeys().getTimeseries().contains(query.getKey()))
|
||||
.collect(Collectors.toList());
|
||||
return timeseriesDao.findAllAsync(entityView.getEntityId(), updateQueriesForEntityView(entityView, filteredQueries));
|
||||
}
|
||||
@ -79,7 +79,9 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
if (entityId.getEntityType().equals(EntityType.ENTITY_VIEW)) {
|
||||
EntityView entityView = entityViewService.findEntityViewById((EntityViewId) entityId);
|
||||
List<String> filteredKeys = new ArrayList<>(keys);
|
||||
if (!entityView.getKeys().getTimeseries().isEmpty()) {
|
||||
filteredKeys.retainAll(entityView.getKeys().getTimeseries());
|
||||
}
|
||||
List<ReadTsKvQuery> queries =
|
||||
filteredKeys.stream()
|
||||
.map(key -> new BaseReadTsKvQuery(key, entityView.getStartTs(), entityView.getEndTs(), 1, "ASC"))
|
||||
@ -100,11 +102,6 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
@Override
|
||||
public ListenableFuture<List<Void>> save(EntityId entityId, TsKvEntry tsKvEntry) {
|
||||
validate(entityId);
|
||||
try {
|
||||
checkForNonEntityView(entityId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (tsKvEntry == null) {
|
||||
throw new IncorrectParameterException("Key value entry can't be null");
|
||||
}
|
||||
@ -115,11 +112,6 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<Void>> save(EntityId entityId, List<TsKvEntry> tsKvEntries, long ttl) {
|
||||
try {
|
||||
checkForNonEntityView(entityId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<ListenableFuture<Void>> futures = Lists.newArrayListWithExpectedSize(tsKvEntries.size() * INSERTS_PER_ENTRY);
|
||||
for (TsKvEntry tsKvEntry : tsKvEntries) {
|
||||
if (tsKvEntry == null) {
|
||||
@ -131,10 +123,8 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
}
|
||||
|
||||
private void saveAndRegisterFutures(List<ListenableFuture<Void>> futures, EntityId entityId, TsKvEntry tsKvEntry, long ttl) {
|
||||
try {
|
||||
checkForNonEntityView(entityId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (entityId.getEntityType().equals(EntityType.ENTITY_VIEW)) {
|
||||
throw new IncorrectParameterException("Telemetry data can't be stored for entity view. Only read only");
|
||||
}
|
||||
futures.add(timeseriesDao.savePartition(entityId, tsKvEntry.getTs(), tsKvEntry.getKey(), ttl));
|
||||
futures.add(timeseriesDao.saveLatest(entityId, tsKvEntry));
|
||||
@ -145,7 +135,9 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
return queries.stream().map(query -> {
|
||||
long startTs = entityView.getStartTs() == 0 ? query.getStartTs() : entityView.getStartTs();
|
||||
long endTs = entityView.getEndTs() == 0 ? query.getEndTs() : entityView.getEndTs();
|
||||
return updateQuery(startTs, endTs, query);
|
||||
|
||||
return startTs <= query.getStartTs() && endTs >= query.getEndTs() ? query :
|
||||
new BaseReadTsKvQuery(query.getKey(), startTs, endTs, query.getInterval(), query.getLimit(), query.getAggregation());
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -187,15 +179,4 @@ public class BaseTimeseriesService implements TimeseriesService {
|
||||
throw new IncorrectParameterException("Incorrect DeleteTsKvQuery. Key can't be empty");
|
||||
}
|
||||
}
|
||||
|
||||
private ReadTsKvQuery updateQuery(Long startTs, Long endTs, ReadTsKvQuery query) {
|
||||
return startTs <= query.getStartTs() && endTs >= query.getEndTs() ? query :
|
||||
new BaseReadTsKvQuery(query.getKey(), startTs, endTs, query.getInterval(), query.getLimit(), query.getAggregation());
|
||||
}
|
||||
|
||||
private static void checkForNonEntityView(EntityId entityId) throws Exception {
|
||||
if (entityId.getEntityType().equals(EntityType.ENTITY_VIEW)) {
|
||||
throw new Exception("Entity-views were read only");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,11 +85,11 @@ export default function EntityViewDirective($compile, $templateCache, $filter, t
|
||||
|
||||
function updateMinMaxDates() {
|
||||
if (scope.endTs) {
|
||||
scope.maxStartTs = angular.copy(new Date(scope.endTs.getTime() - 1000));
|
||||
scope.maxStartTs = angular.copy(new Date(scope.endTs.getTime()));
|
||||
scope.entityView.endTs = scope.endTs.getTime();
|
||||
}
|
||||
if (scope.startTs) {
|
||||
scope.minEndTs = angular.copy(new Date(scope.startTs.getTime() + 1000));
|
||||
scope.minEndTs = angular.copy(new Date(scope.startTs.getTime()));
|
||||
scope.entityView.startTs = scope.startTs.getTime();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user