All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.furms.ui.charts.service.AlarmThresholdSeriesGenerator Maven / Gradle / Ivy

There is a newer version: 4.3.1
Show newest version
/*
 * Copyright (c) 2020 Bixbit s.c. All rights reserved.
 * See LICENSE file for licensing information.
 */

package io.imunity.furms.ui.charts.service;

import io.imunity.furms.domain.alarms.AlarmWithUserEmails;
import io.imunity.furms.domain.project_allocation.ProjectAllocationResolved;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import java.util.stream.IntStream;

import static java.util.stream.Collectors.toList;

@Component
class AlarmThresholdSeriesGenerator {
	double prepareThresholdValue(ProjectAllocationResolved projectAllocation, Optional alarm) {
		double amount = projectAllocation.amount.doubleValue();
		int thresholdPercentage = alarm.map(x -> x.threshold).orElse(0);
		return thresholdPercentage > 0 ? amount * thresholdPercentage / 100 : 0;
	}

	List prepareYValuesForThresholdLine(List xArguments, double thresholdValue) {
		int size = xArguments.size() > 0 ? xArguments.size() + 1 : 0;
		return IntStream.range(0, size)
			.boxed()
			.map(x -> thresholdValue)
			.collect(toList());
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy