Skip to content

Commit

Permalink
Merge pull request #29 from StichtingOpenGeo/feature_include_agency
Browse files Browse the repository at this point in the history
Added AgencyID, AgencyName, ListID.
  • Loading branch information
phax authored Jul 29, 2020
2 parents 5c8b349 + f1095b9 commit e1318a3
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<LongName> 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 <String> aUsedIdentifier = new CommonsHashSet <> ();
boolean bHasEmptyID = false;
for (final Row aRow : aCodeList10.getSimpleCodeList ().getRow ())
Expand Down

0 comments on commit e1318a3

Please sign in to comment.