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

prerna.engine.impl.model.inferencetracking.GetAllEngineUsageReactor Maven / Gradle / Ivy

The newest version!
package prerna.engine.impl.model.inferencetracking;

import java.util.List;
import java.util.Map;

import prerna.auth.User;
import prerna.auth.utils.SecurityEngineUtils;
import prerna.auth.utils.SecurityQueryUtils;
import prerna.reactor.AbstractReactor;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.ReactorKeysEnum;
import prerna.sablecc2.om.nounmeta.NounMetadata;

public class GetAllEngineUsageReactor extends AbstractReactor {
	
	public GetAllEngineUsageReactor() {
		this.keysToGet = new String[]{ReactorKeysEnum.ENGINE.getKey(), ReactorKeysEnum.LIMIT.getKey(), ReactorKeysEnum.OFFSET.getKey(), ReactorKeysEnum.START_DATE.getKey(), ReactorKeysEnum.END_DATE.getKey()};
	}

	@Override
	public NounMetadata execute() {
		User user = this.insight.getUser();
		organizeKeys();
		String engineId = this.keyValue.get(this.keysToGet[0]);
		if(engineId == null || engineId.isEmpty()) {
			throw new IllegalArgumentException("Must input an engine id");
		}
		engineId = SecurityQueryUtils.testUserEngineIdForAlias(user, engineId);
		if(!SecurityEngineUtils.userIsOwner(user, engineId)) {
			throw new IllegalArgumentException("Engine does not exist or user is not an owner of Engine");
		}
		
		
		String limit = this.keyValue.get(this.keysToGet[1]);
		String offset = this.keyValue.get(this.keysToGet[2]);
		String startDate = this.keyValue.get(ReactorKeysEnum.START_DATE.getKey());
		String endDate = this.keyValue.get(ReactorKeysEnum.END_DATE.getKey());
		
		List> overAllInfoForEngineList = ModelInferenceLogsUtils.getOverAllEngineUsageFromModelInferenceLogs(engineId, limit, offset, startDate, endDate);

		return new NounMetadata(overAllInfoForEngineList, PixelDataType.FORMATTED_DATA_SET);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy