From f1095b954136718f9b8929c4ed19c64a6feed4b9 Mon Sep 17 00:00:00 2001 From: Stefan de Konink Date: Wed, 29 Jul 2020 15:32:00 +0200 Subject: [PATCH] Added AgencyID, AgencyName, ListID. --- .../main/MainCreateEnumsGenericode21.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ph-ubl21-codelists/src/test/java/com/helger/ubl21/main/MainCreateEnumsGenericode21.java b/ph-ubl21-codelists/src/test/java/com/helger/ubl21/main/MainCreateEnumsGenericode21.java index 6bf734a3..ecc9d1be 100644 --- a/ph-ubl21-codelists/src/test/java/com/helger/ubl21/main/MainCreateEnumsGenericode21.java +++ b/ph-ubl21-codelists/src/test/java/com/helger/ubl21/main/MainCreateEnumsGenericode21.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.IOException; import java.util.Locale; +import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; @@ -41,8 +42,10 @@ import com.helger.commons.string.StringHelper; import com.helger.genericode.Genericode10CodeListMarshaller; import com.helger.genericode.Genericode10Helper; +import com.helger.genericode.v10.Agency; import com.helger.genericode.v10.CodeListDocument; import com.helger.genericode.v10.Column; +import com.helger.genericode.v10.LongName; import com.helger.genericode.v10.Row; import com.helger.genericode.v10.SimpleCodeList; import com.helger.jcodemodel.AbstractJClass; @@ -156,6 +159,21 @@ private static void _createEnum10 (final File aFile, jEnum.javadoc ().add ("It contains a total of " + aCodeList10.getSimpleCodeList ().getRow ().size () + " entries!\n"); jEnum.javadoc ().add ("@author " + MainCreateEnumsGenericode21.class.getName ()); + Agency agency = aCodeList10.getIdentification().getAgency(); + if (agency != null) { + String agencyID = agency.getIdentifier().get(0).getValue(); + String agencyName = agency.getLongName().get(0).getValue(); + + jEnum.field(JMod.PUBLIC_STATIC_FINAL, String.class, "agencyID", JExpr.lit(agencyID)); + jEnum.field(JMod.PUBLIC_STATIC_FINAL, String.class, "agencyName", JExpr.lit(agencyName)); + } + + Optional listId = aCodeList10.getIdentification().getLongName().stream() + .filter(e -> e.getIdentifier() != null && e.getIdentifier().equals("listID")).findAny(); + if (listId.isPresent()) { + jEnum.field(JMod.PUBLIC_STATIC_FINAL, String.class, "listID", JExpr.lit(listId.get().getValue())); + } + final ICommonsSet aUsedIdentifier = new CommonsHashSet <> (); boolean bHasEmptyID = false; for (final Row aRow : aCodeList10.getSimpleCodeList ().getRow ())