| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Errors.Specific; |
| | 3 | | using ValidateLib.ErrorsAndWarnings.Errors.ValidationErrors; |
| | 4 | | using ValidateLib.Metadata.Descriptors; |
| | 5 | | using ValidateLib.Metadata.Properties; |
| | 6 | | using ValidateLib.TabularData.AnnotatedTabularDataModel; |
| | 7 | |
|
| | 8 | | namespace ValidateLib.ErrorsAndWarnings.Errors |
| | 9 | | { |
| | 10 | | public class ErrorFactory |
| | 11 | | { |
| | 12 | | public static void ThrowWrongTypeOfTopLevelObjectError(string? additionalInfo = null) |
| | 13 | | { |
| 0 | 14 | | throw new Error() |
| 0 | 15 | | { |
| 0 | 16 | | AdditionalInfo = additionalInfo |
| 0 | 17 | | }; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | public static void ThrowZeroTablesInTablesError(string? additionalInfo = null) |
| | 21 | | { |
| 1 | 22 | | throw new ZeroTablesInTablesError() |
| 1 | 23 | | { |
| 1 | 24 | | AdditionalInfo = additionalInfo |
| 1 | 25 | | }; |
| | 26 | | } |
| | 27 | |
|
| | 28 | | public static void ThrowRequiredPropertyMissingError(string missingPropertyName, string descriptorName, string? |
| | 29 | | { |
| 1 | 30 | | throw new RequiredPropertyMissingError(missingPropertyName, descriptorName) |
| 1 | 31 | | { |
| 1 | 32 | | AdditionalInfo = additionalInfo |
| 1 | 33 | | }; |
| | 34 | | } |
| | 35 | |
|
| | 36 | | public static void ThrowInvalidIDPropertyError(string invalidID, string? additionalInfo = null) |
| | 37 | | { |
| 1 | 38 | | throw new InvalidIDPropertyError(invalidID) |
| 1 | 39 | | { |
| 1 | 40 | | AdditionalInfo = additionalInfo |
| 1 | 41 | | }; |
| | 42 | | } |
| | 43 | | public static void ThrowInvalidTypePropertyError(string InvalidProperty, string expectedType, string? additional |
| | 44 | | { |
| 1 | 45 | | throw new InvalidTypePropertyError(InvalidProperty, expectedType) |
| 1 | 46 | | { |
| 1 | 47 | | AdditionalInfo = additionalInfo |
| 1 | 48 | | }; |
| | 49 | | } |
| | 50 | |
|
| | 51 | | public static void ThrowIdenticalColumnNamesError(string identicalName, string? additionalInfo = null) |
| | 52 | | { |
| 1 | 53 | | throw new IdenticalColumnNamesError(identicalName) |
| 1 | 54 | | { |
| 1 | 55 | | AdditionalInfo = additionalInfo |
| 1 | 56 | | }; |
| | 57 | | } |
| | 58 | |
|
| | 59 | | public static void ThrowVirtualColumnPrecedesNonVirtualError(int index, int indexOfFirstVirtual, string? additio |
| | 60 | | { |
| 1 | 61 | | throw new VirtualColumnPrecedesNonVirtualError(index, indexOfFirstVirtual) |
| 1 | 62 | | { |
| 1 | 63 | | AdditionalInfo = additionalInfo |
| 1 | 64 | | }; |
| | 65 | | } |
| | 66 | |
|
| | 67 | | public static void ThrowResourceAndSchemaReferencePresentError(string? additionalInfo = null) |
| | 68 | | { |
| 0 | 69 | | throw new ResourceAndSchemaReferencePresentError() |
| 0 | 70 | | { |
| 0 | 71 | | AdditionalInfo = additionalInfo |
| 0 | 72 | | }; |
| | 73 | | } |
| | 74 | |
|
| | 75 | | public static void ThrowReferencingColumnDoesNotExistError(TableDescriptor table, ForeignKeyDescriptor fkdesc, s |
| | 76 | | { |
| 1 | 77 | | throw new ReferencingColumnDoesNotExistError(table, fkdesc) |
| 1 | 78 | | { |
| 1 | 79 | | AdditionalInfo = additionalInfo |
| 1 | 80 | | }; |
| | 81 | | } |
| | 82 | |
|
| | 83 | | public static void ThrowTwoSatisfyingReferencedTablesErrorError(TableDescriptor table, ForeignKeyDescriptor fkDe |
| | 84 | | { |
| 0 | 85 | | throw new TwoSatisfyingReferencedTablesError(table, fkDesc) |
| 0 | 86 | | { |
| 0 | 87 | | AdditionalInfo = additionalInfo |
| 0 | 88 | | }; |
| | 89 | | } |
| | 90 | |
|
| | 91 | | public static void ThrowNoSatisfyingReferencedTableError(TableDescriptor table, ForeignKeyDescriptor fkdesc, str |
| | 92 | | { |
| 1 | 93 | | throw new NoSatisfyingReferencedTableError(table, fkdesc) |
| 1 | 94 | | { |
| 1 | 95 | | AdditionalInfo = additionalInfo |
| 1 | 96 | | }; |
| | 97 | | } |
| | 98 | |
|
| | 99 | |
|
| | 100 | |
|
| | 101 | | public static void ThrowReferencedColumnDoesNotExistError(TableDescriptor table, ForeignKeyDescriptor fkdesc, st |
| | 102 | | { |
| 1 | 103 | | throw new ReferencedColumnDoesNotExistError(table, fkdesc) |
| 1 | 104 | | { |
| 1 | 105 | | AdditionalInfo = additionalInfo |
| 1 | 106 | | }; |
| | 107 | | } |
| | 108 | |
|
| | 109 | | public static void ThrowCommonPropertyValueErrorError(CommonProperty commonproperty, string? additionalInfo = nu |
| | 110 | | { |
| 1 | 111 | | throw new CommonPropertyValueError(commonproperty) |
| 1 | 112 | | { |
| 1 | 113 | | AdditionalInfo = additionalInfo |
| 1 | 114 | | }; |
| | 115 | | } |
| | 116 | |
|
| | 117 | | public static void ThrowCommonPropertyValueErrorError(JProperty jprop, string? additionalInfo = null) |
| | 118 | | { |
| 1 | 119 | | throw new CommonPropertyValueError(jprop) |
| 1 | 120 | | { |
| 1 | 121 | | AdditionalInfo = additionalInfo |
| 1 | 122 | | }; |
| | 123 | | } |
| | 124 | |
|
| | 125 | | public static void ThrowCPInvalidValueTypeError(JObject commonPropertyObject) |
| | 126 | | { |
| 0 | 127 | | throw new CPInvalidValueTypeError(commonPropertyObject); |
| | 128 | | } |
| | 129 | | public static void ThrowDatatypeLengthConstraintError(string? additionalInfo = null) |
| | 130 | | { |
| 1 | 131 | | throw new DatatypeLengthConstraintError() |
| 1 | 132 | | { |
| 1 | 133 | | AdditionalInfo = additionalInfo |
| 1 | 134 | | }; |
| | 135 | | } |
| | 136 | | public static void ThrowDatatypeValueConstraintError(string? additionalInfo = null) |
| | 137 | | { |
| 1 | 138 | | throw new DatatypeValueConstraintError() |
| 1 | 139 | | { |
| 1 | 140 | | AdditionalInfo = additionalInfo |
| 1 | 141 | | }; |
| | 142 | | } |
| | 143 | |
|
| | 144 | | public static void ThrowDatatypeValidationError(string? additionalInfo = null) |
| | 145 | | { |
| 1 | 146 | | throw new DatatypeValidationError() |
| 1 | 147 | | { |
| 1 | 148 | | AdditionalInfo = additionalInfo |
| 1 | 149 | | }; |
| | 150 | | } |
| | 151 | |
|
| | 152 | | public static void ThrowInvalidFormatError(string invalidFormat, string? additionalInfo = null) |
| | 153 | | { |
| 1 | 154 | | throw new InvalidFormatError(invalidFormat) |
| 1 | 155 | | { |
| 1 | 156 | | AdditionalInfo = additionalInfo |
| 1 | 157 | | }; |
| | 158 | | } |
| | 159 | | public static void ThrowLengthConstraintOnInvalidDatatypeBaseError(string invalidBase, string? additionalInfo = |
| | 160 | | { |
| 1 | 161 | | throw new LengthConstraintOnInvalidDatatypeBaseError(invalidBase) |
| 1 | 162 | | { |
| 1 | 163 | | AdditionalInfo = additionalInfo |
| 1 | 164 | | }; |
| | 165 | | } |
| | 166 | |
|
| | 167 | |
|
| | 168 | | public static void ThrowValueConstraintOnInvalidDatatypeBaseError(string invalidBase, string? additionalInfo = n |
| | 169 | | { |
| 1 | 170 | | throw new ValueConstraintOnInvalidDatatypeBaseError(invalidBase) |
| 1 | 171 | | { |
| 1 | 172 | | AdditionalInfo = additionalInfo |
| 1 | 173 | | }; |
| | 174 | | } |
| | 175 | |
|
| | 176 | |
|
| | 177 | | public static void ThrowInvalidPropertyOnFKDescriptorError(string invalidProp, string? additionalInfo = null) |
| | 178 | | { |
| 1 | 179 | | throw new InvalidPropertyOnFKDescriptorError(invalidProp) |
| 1 | 180 | | { |
| 1 | 181 | | AdditionalInfo = additionalInfo |
| 1 | 182 | | }; |
| | 183 | | } |
| | 184 | | public static void ThrowInvalidPropertyOnContextDescriptorError(string invalidProperty, string? additionalInfo = |
| | 185 | | { |
| 1 | 186 | | throw new InvalidPropertyOnContextDescriptorError(invalidProperty) |
| 1 | 187 | | { |
| 1 | 188 | | AdditionalInfo = additionalInfo |
| 1 | 189 | | }; |
| | 190 | | } |
| | 191 | |
|
| | 192 | | public static void ThrowMetadataFileCouldNotBeLoadedError(string metadataIRI, string? additionalInfo = null) |
| | 193 | | { |
| 0 | 194 | | throw new MetadataFileCouldNotBeLoadedError(metadataIRI) |
| 0 | 195 | | { |
| 0 | 196 | | AdditionalInfo = additionalInfo |
| 0 | 197 | | }; |
| | 198 | | } |
| | 199 | |
|
| | 200 | | public static MetadataFileCouldNotBeLoadedError GetMetadataFileCouldNotBeLoadedError(string metadataIRI, string? |
| | 201 | | { |
| 1 | 202 | | return new MetadataFileCouldNotBeLoadedError(metadataIRI) |
| 1 | 203 | | { |
| 1 | 204 | | AdditionalInfo = additionalInfo |
| 1 | 205 | | }; |
| | 206 | | } |
| | 207 | |
|
| | 208 | | public static Error GetUnknownError(string? additionalInfo = null) |
| | 209 | | { |
| 1 | 210 | | return new UnknownError() |
| 1 | 211 | | { |
| 1 | 212 | | AdditionalInfo = additionalInfo |
| 1 | 213 | | }; |
| | 214 | | } |
| | 215 | |
|
| | 216 | | public static Error GetUserMetadataTablesIrisMismatchMetdataError(int numberOfIrisUser, int numberOfTables, stri |
| | 217 | | { |
| 0 | 218 | | return new UserMetadataTablesIrisMismatchMetdataError(numberOfIrisUser, numberOfTables) |
| 0 | 219 | | { |
| 0 | 220 | | AdditionalInfo = additionalInfo, |
| 0 | 221 | | }; |
| | 222 | | } |
| | 223 | |
|
| | 224 | | public static void ThrowTitleNotCompatibleWithLangError(string incompatibleTitle) |
| | 225 | | { |
| 1 | 226 | | throw new TitleNotCompatibleWithLangError(incompatibleTitle) |
| 1 | 227 | | { |
| 1 | 228 | |
|
| 1 | 229 | | }; |
| | 230 | | } |
| | 231 | |
|
| | 232 | | public static WrongNumberOfTabularIRIsProvidedError GetWrongNumberOfTabularIRIsProvidedError(int numberOfIRIs) |
| | 233 | | { |
| 0 | 234 | | return new WrongNumberOfTabularIRIsProvidedError(numberOfIRIs); |
| | 235 | | } |
| | 236 | |
|
| | 237 | | public static void ThrowMissingContextError(JToken topLevelObject) |
| | 238 | | { |
| 0 | 239 | | throw new MissingContextError(topLevelObject); |
| | 240 | | } |
| | 241 | |
|
| | 242 | | public static void ThrowInvalidContextValueError(string wrongValue, string detectedDatatype) |
| | 243 | | { |
| 0 | 244 | | throw new InvalidContextValueError(wrongValue, detectedDatatype); |
| | 245 | | } |
| | 246 | |
|
| | 247 | | public static void ThrowRemoteFileResoltuionError(string fileIRI, string additionalInfo) |
| | 248 | | { |
| 1 | 249 | | throw new RemoteFileResoltuionError(fileIRI, additionalInfo); |
| | 250 | | } |
| | 251 | |
|
| | 252 | | public static void ThrowUnsupportedSchemeError(string parameter) |
| | 253 | | { |
| 0 | 254 | | throw new UnsupportedSchemeError(parameter); |
| | 255 | | } |
| | 256 | |
|
| | 257 | | public static ColumnsCountMismatchValidationError GetColumnsCountMismatchValidationError(Row annotatedRow) |
| | 258 | | { |
| 1 | 259 | | return new ColumnsCountMismatchValidationError(annotatedRow); |
| | 260 | | } |
| | 261 | |
|
| | 262 | | public static DuplicateInPKValidationError GetDuplicateInPKValidationError(Row annotatedRow, string PKDuplicate) |
| | 263 | | { |
| 1 | 264 | | return new DuplicateInPKValidationError(annotatedRow, PKDuplicate); |
| | 265 | | } |
| | 266 | |
|
| | 267 | | public static DuplicateInFKReferencedColumnsValidationError GetDuplicateInFKReferencedColumnsValidationError(Tab |
| | 268 | | { |
| 1 | 269 | | return new DuplicateInFKReferencedColumnsValidationError(table, duplicatedValues, rowNumber); |
| | 270 | | } |
| | 271 | |
|
| | 272 | | public static NotAllReferencedValuesExistValidationError GetNotAllReferencedValuesExistValidationError(Table ref |
| | 273 | | { |
| 1 | 274 | | return new NotAllReferencedValuesExistValidationError(referencingTable, referencedTable, referencingValues); |
| | 275 | | } |
| | 276 | |
|
| | 277 | | public static EmptyCellInRequiredColumnVE GetEmptyCellInRequiredColumnVE(Cell annotatedCell) |
| | 278 | | { |
| 1 | 279 | | return new EmptyCellInRequiredColumnVE(annotatedCell); |
| | 280 | | } |
| | 281 | |
|
| | 282 | | public static CouldNotOpenFileVE GetCouldNotOpenFileVE(string fileIRI) |
| | 283 | | { |
| 0 | 284 | | return new CouldNotOpenFileVE(fileIRI); |
| | 285 | | } |
| | 286 | |
|
| | 287 | | public static TableSchemesNotCompatibleError GetTableSchemesNotCompatibleError(string tableUrl, int confilctingN |
| | 288 | | { |
| 1 | 289 | | return new TableSchemesNotCompatibleError(tableUrl, confilctingNumber); |
| | 290 | | } |
| | 291 | |
|
| | 292 | | public static DatatypeLengthConstraintVE GetDatatypeLengthConstraintVE(Cell annoatatedCell) |
| | 293 | | { |
| 1 | 294 | | return new DatatypeLengthConstraintVE(annoatatedCell); |
| | 295 | | } |
| | 296 | |
|
| | 297 | | public static DatatypeValueConstraintVE GetDatatypeValueConstraintVE(Cell annotatedCell) |
| | 298 | | { |
| 1 | 299 | | return new DatatypeValueConstraintVE(annotatedCell); |
| | 300 | | } |
| | 301 | |
|
| | 302 | | public static CharOutsideQuotesVE GetCharOutsideQuotesVE(string? tableIRI, int rowNumber, int columnNumber) |
| | 303 | | { |
| 0 | 304 | | return new CharOutsideQuotesVE(tableIRI, rowNumber, columnNumber); |
| | 305 | | } |
| | 306 | | } |
| | 307 | | } |