Example #1
0
        public StructuredDataStructurePreviewModel fill(long dataStructureId)
        {
            DataStructureManager dataStructureManager = new DataStructureManager();
            StructuredDataStructure datastructure = dataStructureManager.StructuredDataStructureRepo.Get(dataStructureId);
            VariablePreview variablePreview = new VariablePreview();

            if (datastructure != null)
            {
                foreach (Variable v in DataStructureIO.getOrderedVariables(datastructure))
                {
                    v.Unit = v.Unit ?? new Unit();
                    v.DataAttribute = v.DataAttribute ?? new DataAttribute();
                    v.DataAttribute.DataType = v.DataAttribute.DataType ?? new DataType();

                    variablePreview = new VariablePreview();
                    variablePreview.Id = v.Id;
                    variablePreview.Label = v.Label;
                    variablePreview.Description = v.Description;
                    variablePreview.isOptional = v.IsValueOptional;
                    variablePreview.Unit = v.Unit.Name;
                    variablePreview.DataType = v.DataAttribute.DataType.Name;
                    variablePreview.SystemType = v.DataAttribute.DataType.SystemType;

                    this.VariablePreviews.Add(variablePreview);
                }
                return this;
            }
            else
            {
                return new StructuredDataStructurePreviewModel();
            }
        }