|
| 1 | +/* |
| 2 | + * This file is part of the Buildings and Habitats object Model (BHoM) |
| 3 | + * Copyright (c) 2015 - 2021, the respective contributors. All rights reserved. |
| 4 | + * |
| 5 | + * Each contributor holds copyright over their respective contributions. |
| 6 | + * The project versioning (Git) records all such contribution source information. |
| 7 | + * |
| 8 | + * |
| 9 | + * The BHoM is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Lesser General Public License as published by |
| 11 | + * the Free Software Foundation, either version 3.0 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * The BHoM is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU Lesser General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Lesser General Public License |
| 20 | + * along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. |
| 21 | + */ |
| 22 | + |
| 23 | +using System.Collections.Generic; |
| 24 | +using BH.oM.Adapters.MidasCivil; |
| 25 | +using MCEngine = BH.Engine.Adapters.MidasCivil; |
| 26 | + |
| 27 | +namespace BH.Adapter.MidasCivil |
| 28 | +{ |
| 29 | + public static partial class Convert |
| 30 | + { |
| 31 | + /***************************************************/ |
| 32 | + /**** Public Methods ****/ |
| 33 | + /***************************************************/ |
| 34 | + |
| 35 | + public static IEnumerable<Metadata> ToMetadata(List<string> data) |
| 36 | + { |
| 37 | + Metadata metadata = new Metadata(); |
| 38 | + List<Review> reviews = new List<Review>(); |
| 39 | + List<string> comments = new List<string>(); |
| 40 | + Review review1 = new Review(); |
| 41 | + Review review2 = new Review(); |
| 42 | + Review review3 = new Review(); |
| 43 | + Review review4 = new Review(); |
| 44 | + |
| 45 | + foreach (string dataItem in data) |
| 46 | + { |
| 47 | + |
| 48 | + if (dataItem.Contains("PROJECT=")) { metadata.ProjectNumber = dataItem.Split('=')[1]; } |
| 49 | + else if (dataItem.Contains("REVISION=")) { metadata.Revision = dataItem.Split('=')[1]; } |
| 50 | + else if (dataItem.Contains("USER=")) { metadata.Author = dataItem.Split('=')[1]; } |
| 51 | + else if (dataItem.Contains("EMAIL=")) { metadata.Email = dataItem.Split('=')[1]; } |
| 52 | + else if (dataItem.Contains("ADDRESS=")) { metadata.Location = dataItem.Split('=')[1]; } |
| 53 | + else if (dataItem.Contains("CLIENT=")) { metadata.Client = dataItem.Split('=')[1]; } |
| 54 | + else if (dataItem.Contains("TITLE=")) { metadata.ProjectName = dataItem.Split('=')[1]; } |
| 55 | + else if (dataItem.Contains("EDATE=")) |
| 56 | + { |
| 57 | + metadata.CreationDate = MCEngine.Convert.Date(dataItem.Split('=')[1]); |
| 58 | + } |
| 59 | + else if (dataItem.Contains(";DESIGNSTAGE=")) { metadata.DesignStage = dataItem.Split('=')[1]; } |
| 60 | + else if (dataItem.Contains(";PROJECTLEAD=")) { metadata.ProjectLead = dataItem.Split('=')[1]; } |
| 61 | + else if (dataItem.Contains(";DESCRIPTION=")) { metadata.Description = dataItem.Split('=')[1]; } |
| 62 | + else if (dataItem.Contains(";DISCIPLINE=")) { metadata.Discipline = dataItem.Split('=')[1]; } |
| 63 | + |
| 64 | + if (dataItem.Contains("CHECK1=")) |
| 65 | + { |
| 66 | + review1.Reviewer = (dataItem.Split('=')[1]); |
| 67 | + reviews.Add(review1); |
| 68 | + } |
| 69 | + else if (dataItem.Contains("CHECK2=")) |
| 70 | + { |
| 71 | + review2.Reviewer = (dataItem.Split('=')[1]); |
| 72 | + reviews.Add(review2); |
| 73 | + } |
| 74 | + else if (dataItem.Contains("CHECK3=")) |
| 75 | + { |
| 76 | + review3.Reviewer = (dataItem.Split('=')[1]); |
| 77 | + reviews.Add(review3); |
| 78 | + } |
| 79 | + else if (dataItem.Contains("APPROVE=")) |
| 80 | + { |
| 81 | + review4.Reviewer = (dataItem.Split('=')[1]); |
| 82 | + reviews.Add(review4); |
| 83 | + review4.Approved = true; |
| 84 | + } |
| 85 | + if (dataItem.Contains("CDATE1=")) { review1.ReviewDate = MCEngine.Convert.Date(dataItem.Split('=')[1]); } |
| 86 | + else if (dataItem.Contains("CDATE2=")) { review2.ReviewDate = MCEngine.Convert.Date(dataItem.Split('=')[1]); } |
| 87 | + else if (dataItem.Contains("CDATE3=")) { review3.ReviewDate = MCEngine.Convert.Date(dataItem.Split('=')[1]); } |
| 88 | + else if (dataItem.Contains("ADATE=")) { review4.ReviewDate = MCEngine.Convert.Date(dataItem.Split('=')[1]); } |
| 89 | + else if (dataItem.Contains("COMMENT=")) |
| 90 | + { |
| 91 | + if (!dataItem.Contains("COMMENT=This Model Was Created Using BHoM Version:")) |
| 92 | + { |
| 93 | + comments.Add(dataItem.Split('=')[1]); |
| 94 | + if (!string.IsNullOrEmpty(review4.Reviewer)) |
| 95 | + { |
| 96 | + review4.Comments = comments; |
| 97 | + } |
| 98 | + else if (!string.IsNullOrEmpty(review3.Reviewer)) |
| 99 | + { |
| 100 | + review3.Comments = comments; |
| 101 | + } |
| 102 | + else if (!string.IsNullOrEmpty(review2.Reviewer)) |
| 103 | + { |
| 104 | + review2.Comments = comments; |
| 105 | + } |
| 106 | + else if (!string.IsNullOrEmpty(review1.Reviewer)) |
| 107 | + { |
| 108 | + review1.Comments = comments; |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | + reviews.Reverse(); |
| 114 | + metadata.Reviews = reviews; |
| 115 | + |
| 116 | + List<Metadata> returnMetadata = new List<Metadata>(1); |
| 117 | + returnMetadata.Add(metadata); |
| 118 | + |
| 119 | + return returnMetadata; |
| 120 | + } |
| 121 | + |
| 122 | + /***************************************************/ |
| 123 | + } |
| 124 | +} |
0 commit comments