|
|
@ -1,31 +1,31 @@ |
|
|
|
package me.bearns.fias.util; |
|
|
|
package me.bearns.fias.util; |
|
|
|
|
|
|
|
|
|
|
|
import me.bearns.fias.repository.FiasVersionRepository; |
|
|
|
import me.bearns.fias.repository.FiasVersionRepository; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.data.jpa.repository.JpaRepository; |
|
|
|
import org.springframework.data.jpa.repository.JpaRepository; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
import javax.xml.namespace.QName; |
|
|
|
import javax.xml.namespace.QName; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
@Component |
|
|
|
public class Catalog { |
|
|
|
public class Catalog { |
|
|
|
|
|
|
|
|
|
|
|
private final HashMap<String,Item> prefixMap = new HashMap<>(); |
|
|
|
private final List<Item> prefixList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
public Catalog(FiasVersionRepository FIASJPA_REPOSITORY) { |
|
|
|
public Catalog(FiasVersionRepository FIASJPA_REPOSITORY) { |
|
|
|
prefixMap.put( |
|
|
|
prefixList.add( |
|
|
|
"AS_ADDROBJ_", |
|
|
|
|
|
|
|
new Item( |
|
|
|
new Item( |
|
|
|
|
|
|
|
"AS_ADDROBJ_", |
|
|
|
null, |
|
|
|
null, |
|
|
|
new QName("","Object"), |
|
|
|
new QName("","Object"), |
|
|
|
null, |
|
|
|
null, |
|
|
|
null |
|
|
|
null |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
prefixMap.put( |
|
|
|
prefixList.add( |
|
|
|
"AS_HOUSE_", |
|
|
|
|
|
|
|
new Item( |
|
|
|
new Item( |
|
|
|
|
|
|
|
"AS_HOUSE_", |
|
|
|
null, |
|
|
|
null, |
|
|
|
new QName("","House"), |
|
|
|
new QName("","House"), |
|
|
|
null, |
|
|
|
null, |
|
|
@ -35,17 +35,24 @@ public class Catalog { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Item getByPrefix(String s){ |
|
|
|
public Item getByPrefix(String s){ |
|
|
|
return prefixMap.get(s); |
|
|
|
if(s!=null) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Item item : prefixList) { |
|
|
|
|
|
|
|
if (s.startsWith(item.prefix)) return item; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class Item implements CatalogItem{ |
|
|
|
public class Item implements UnmarshallerParameters { |
|
|
|
private Item(JpaRepository repository, QName qName, Class cls, Class parentCls) { |
|
|
|
private Item(String prefix, JpaRepository repository, QName qName, Class cls, Class parentCls) { |
|
|
|
|
|
|
|
this.prefix = prefix; |
|
|
|
this.repository = repository; |
|
|
|
this.repository = repository; |
|
|
|
this.qName = qName; |
|
|
|
this.qName = qName; |
|
|
|
this.cls = cls; |
|
|
|
this.cls = cls; |
|
|
|
this.parentCls = parentCls; |
|
|
|
this.parentCls = parentCls; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private final String prefix; |
|
|
|
private final JpaRepository repository; |
|
|
|
private final JpaRepository repository; |
|
|
|
private final QName qName; |
|
|
|
private final QName qName; |
|
|
|
private final Class cls; |
|
|
|
private final Class cls; |
|
|
|