|
13 | 13 | import edu.ie3.datamodel.models.input.UniqueInputEntity;
|
14 | 14 | import edu.ie3.datamodel.models.input.system.*;
|
15 | 15 | import edu.ie3.datamodel.models.input.system.type.*;
|
| 16 | +import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile; |
16 | 17 | import edu.ie3.datamodel.models.profile.LoadProfile;
|
| 18 | +import edu.ie3.datamodel.models.profile.NbwTemperatureDependantLoadProfile; |
17 | 19 | import edu.ie3.datamodel.utils.Try;
|
18 | 20 | import edu.ie3.datamodel.utils.Try.Failure;
|
19 | 21 | import java.util.ArrayList;
|
| 22 | +import java.util.Arrays; |
20 | 23 | import java.util.List;
|
21 | 24 | import javax.measure.Quantity;
|
22 | 25 | import javax.measure.quantity.Dimensionless;
|
@@ -378,28 +381,36 @@ private static List<Try<Void, InvalidEntityException>> checkLoad(LoadInput loadI
|
378 | 381 | new InvalidEntityException(
|
379 | 382 | "No standard load profile defined for load", loadInput)));
|
380 | 383 |
|
381 |
| - String regexPattern = "^(h0|g[0-6]|l[0-2]|ep1|ez2)$"; |
382 |
| - LoadProfile profile = loadInput.getLoadProfile(); |
| 384 | + if (loadInput.getLoadProfile() != null) { |
| 385 | + LoadProfile profile = loadInput.getLoadProfile(); |
383 | 386 |
|
384 |
| - exceptions.add( |
385 |
| - Try.ofVoid( |
386 |
| - profile.equals(LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE) |
387 |
| - || profile.equals(LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE) |
388 |
| - || !profile.toString().matches(regexPattern), |
389 |
| - () -> |
390 |
| - new InvalidEntityException( |
391 |
| - "Load profile must contain at least one valid entry: h0, g[0-6], l[0-3], ep1, ez2 or NO_LOAD_PROFILE", |
392 |
| - loadInput))); |
393 |
| - |
394 |
| - exceptions.addAll( |
395 |
| - Try.ofVoid( |
396 |
| - InvalidEntityException.class, |
397 |
| - () -> |
398 |
| - detectNegativeQuantities( |
399 |
| - new Quantity<?>[] {loadInput.getsRated(), loadInput.geteConsAnnual()}, |
400 |
| - loadInput), |
401 |
| - () -> checkRatedPowerFactor(loadInput, loadInput.getCosPhiRated()))); |
| 387 | + // Validate if the profile is one of the allowed profiles |
| 388 | + exceptions.add( |
| 389 | + Try.ofVoid( |
| 390 | + !(profile.equals(LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE) |
| 391 | + || profile.equals(LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE) |
| 392 | + || Arrays.asList( |
| 393 | + BdewStandardLoadProfile.H0, |
| 394 | + BdewStandardLoadProfile.G0, |
| 395 | + BdewStandardLoadProfile.G1, |
| 396 | + BdewStandardLoadProfile.G2, |
| 397 | + BdewStandardLoadProfile.G3, |
| 398 | + BdewStandardLoadProfile.G4, |
| 399 | + BdewStandardLoadProfile.G5, |
| 400 | + BdewStandardLoadProfile.G6, |
| 401 | + BdewStandardLoadProfile.L0, |
| 402 | + BdewStandardLoadProfile.L1, |
| 403 | + BdewStandardLoadProfile.L2, |
| 404 | + NbwTemperatureDependantLoadProfile.EP1, |
| 405 | + NbwTemperatureDependantLoadProfile.EZ2) |
| 406 | + .contains(profile)), |
| 407 | + () -> |
| 408 | + new InvalidEntityException( |
| 409 | + "Load profile must contain at least one valid entry: h0, g[0-6], l[0-2], ep1, ez2, random, or LoadProfile#NO_LOAD_PROFILE.", |
| 410 | + loadInput))); |
| 411 | + } |
402 | 412 |
|
| 413 | + // Check negative quantities and power factor |
403 | 414 | exceptions.addAll(
|
404 | 415 | Try.ofVoid(
|
405 | 416 | InvalidEntityException.class,
|
|
0 commit comments