Пример #1
0
 // TODO check to see if the part of removing the PhysicalAddress and
 // everything which this module doesn't depend is required
 @Deprecated
 public void delete() {
   Unit unit = this.getUnit();
   setUnit(null);
   setBennu(null);
   unit.delete();
   deleteDomainObject();
 }
Пример #2
0
 /**
  * @param date the date which they should have been active
  * @return a {@link Collection} with the {@link CountrySubdivision} that were active on the given
  *     date and of the
  */
 public Collection<CountrySubdivision> getChildrenValidAt(LocalDate date) {
   Collection<Unit> units = getChildUnits().collect(Collectors.toList());
   Collection<CountrySubdivision> children = new ArrayList<CountrySubdivision>();
   for (Unit unit : units) {
     final AccountabilityType type = getOrCreateAccountabilityType();
     unit.getParentAccountabilityStream()
         .filter(a -> a.getAccountabilityType() == type && a.isActive(date))
         .forEach(a -> children.add((CountrySubdivision) unit.getGeographicLocation()));
   }
   return children;
 }
Пример #3
0
 public CountrySubdivision getChildByCode(String... codes) {
   String code = codes[0];
   for (Unit subdivision : getChildUnits().collect(Collectors.toList())) {
     CountrySubdivision geographicLocation =
         (CountrySubdivision) subdivision.getGeographicLocation();
     if (geographicLocation.getCode().equals(code)) {
       if (codes.length > 1) {
         return geographicLocation.getChildByCode(
             Arrays.asList(codes).subList(1, codes.length).toArray(new String[0]));
       }
       return geographicLocation;
     }
   }
   return null;
 }
Пример #4
0
 public Country(
     Planet parent,
     String iso3166alpha2Code,
     String iso3166alpha3Code,
     Integer iso3166numericCode,
     LocalizedString name,
     LocalizedString nationality,
     Class<AddressPrinter> iAddressPrinter) {
   super();
   setBennu(Bennu.getInstance());
   setUnit(
       Unit.create(
           parent.getUnit(),
           name,
           iso3166alpha3Code,
           getPartyType("País", COUNTRY_PARTYTYPE_NAME),
           getOrCreateAccountabilityType(),
           new LocalDate(),
           null,
           null));
   setIso3166alpha2Code(iso3166alpha2Code);
   setIAddressPrinter(iAddressPrinter);
   setIso3166alpha3Code(iso3166alpha3Code);
   setIso3166numericCode(iso3166numericCode);
   setNationality(nationality);
 }
Пример #5
0
 public void update(
     Planet parent,
     String iso3166alpha2Code,
     String iso3166alpha3Code,
     Integer iso3166numericCode,
     LocalizedString name,
     LocalizedString nationality,
     Class<AddressPrinter> iAddressPrinter) {
   if (!same(getIso3166alpha2Code(), iso3166alpha2Code)
       || !same(getIso3166alpha3Code(), iso3166alpha3Code)
       || !same(getIso3166numericCode(), iso3166numericCode)
       || !same(getName(), name)
       || !same(getNationality(), nationality)
       || !same(getIAddressPrinter(), iAddressPrinter)) {
     final AccountabilityType type = getOrCreateAccountabilityType();
     getUnit()
         .getParentAccountabilityStream()
         .filter(a -> a.getAccountabilityType() == type)
         .forEach(a -> a.editDates(new LocalDate(), null, null));
     setUnit(
         Unit.create(
             parent.getUnit(),
             name,
             iso3166alpha3Code,
             getPartyType("País", COUNTRY_PARTYTYPE_NAME),
             getOrCreateAccountabilityType(),
             new LocalDate(),
             null,
             null));
     setIso3166alpha2Code(iso3166alpha2Code);
     setIAddressPrinter(iAddressPrinter);
     setIso3166alpha3Code(iso3166alpha3Code);
     setIso3166numericCode(iso3166numericCode);
     setNationality(nationality);
   }
 }
Пример #6
0
  public Country(
      Planet parent,
      LocalizedString name,
      String acronym,
      Class iAddressPrinter,
      CountrySubdivisionLevelName... subdivisionNames) {
    super();
    setBennu(Bennu.getInstance());

    setIAddressPrinter(iAddressPrinter);
    setUnit(
        Unit.create(
            parent.getUnit(),
            name,
            acronym,
            getPartyType("País", COUNTRY_PARTYTYPE_NAME),
            getOrCreateAccountabilityType(),
            new LocalDate(),
            null,
            null));
    for (CountrySubdivisionLevelName subdivisionName : subdivisionNames) {
      addLevelName(subdivisionName);
    }
  }