Ejemplo n.º 1
0
        /// <summary>
        /// Returns an instance of GetAllInputsModelView representing the Algorithm's required inputs.
        /// </summary>
        /// <param name="restrictionAlgorithm">RestrictionAlgorithm that matches the corresponding Algorithm.</param>
        /// <returns>GetAllInputsModelView representing the Algorithm's required inputs. </returns>
        /// <exception cref="ResourceNotFoundException">Thrown when the Algorithm has no required inputs.</exception>
        public GetAllInputsModelView getAlgorithmRequiredInputs(RestrictionAlgorithm restrictionAlgorithm)
        {
            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm);

            List <Input> requiredInputs = algorithm.getRequiredInputs();

            if (!requiredInputs.Any())
            {
                throw new ResourceNotFoundException(NO_REQUIRED_INPUTS);
            }

            return(InputModelViewService.fromCollection(requiredInputs));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an instance of GetAlgorithm from an instance of Algorithm.
        /// </summary>
        /// <param name="algorithm">Instance of Algorithm being converted.</param>
        /// <returns>Instance of GetAlgorithmModelView with the Algorithm's data.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when the provided instance of Algorithm is null.</exception>
        public static GetAlgorithmModelView fromEntity(Algorithm algorithm)
        {
            if (algorithm == null)
            {
                throw new ArgumentException(NULL_ALGORITHM);
            }

            GetAlgorithmModelView algorithmModelView = new GetAlgorithmModelView();

            algorithmModelView.name        = algorithm.name;
            algorithmModelView.description = algorithm.description;

            IEnumerable <Input> requiredInputs = algorithm.getRequiredInputs();

            if (requiredInputs.Any())
            {
                algorithmModelView.requiredInputs = InputModelViewService.fromCollection(requiredInputs);
            }

            return(algorithmModelView);
        }