Bugfix & minor improvements
This commit is contained in:
@@ -2,7 +2,10 @@ package me.bearns.fias.helpers;
|
||||
|
||||
import me.bearns.fias.domain.AddressObjects;
|
||||
import me.bearns.fias.domain.Addrobj;
|
||||
import me.bearns.fias.domain.House;
|
||||
import me.bearns.fias.domain.Houses;
|
||||
import me.bearns.fias.repository.AddrobjRepository;
|
||||
import me.bearns.fias.repository.HouseRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -15,7 +18,7 @@ public class Catalog {
|
||||
|
||||
private final List<Item> prefixList = new ArrayList<>();
|
||||
|
||||
public Catalog(AddrobjRepository ADDROBJ_REPOSITORY) {
|
||||
public Catalog(AddrobjRepository ADDROBJ_REPOSITORY, HouseRepository HOUSE_REPOSITORY) {
|
||||
prefixList.add(
|
||||
new Item(
|
||||
"AS_ADDROBJ_",
|
||||
@@ -28,10 +31,10 @@ public class Catalog {
|
||||
prefixList.add(
|
||||
new Item(
|
||||
"AS_HOUSE_",
|
||||
null,
|
||||
HOUSE_REPOSITORY,
|
||||
new QName("","House"),
|
||||
null,
|
||||
null
|
||||
House.class,
|
||||
Houses.class
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -46,6 +49,10 @@ public class Catalog {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Item> getAll() {
|
||||
return prefixList;
|
||||
}
|
||||
|
||||
public class Item implements UnmarshallerParameters {
|
||||
private Item(String prefix, JpaRepository repository, QName qName, Class cls, Class parentCls) {
|
||||
this.prefix = prefix;
|
||||
|
||||
@@ -8,6 +8,7 @@ import me.bearns.fias.repository.FiasVersionRepository;
|
||||
import me.bearns.fias.service.Downloader;
|
||||
import me.bearns.fias.service.StreamSaver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -46,8 +47,8 @@ public class UpdaterImpl implements UpdateHelper {
|
||||
public void processUpdates(List<FiasVersion> updates, boolean reloadFlag) throws CommonException {
|
||||
|
||||
if(reloadFlag) {
|
||||
//todo reload flag impl
|
||||
versions.deleteAll();
|
||||
catalog.getAll().stream().map(Catalog.Item::getRepository).forEach(JpaRepository::deleteAll);
|
||||
}
|
||||
|
||||
updates.sort((o1, o2) -> Math.toIntExact(o1.getVersionId() - o2.getVersionId()));
|
||||
|
||||
Reference in New Issue
Block a user