ee.datel.client.kr.MuudatusedService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xtee6-client-kr Show documentation
Show all versions of xtee6-client-kr Show documentation
Library for XROAD KR service clints
The newest version!
package ee.datel.client.kr;
/*-
* ==========================LICENSE_START===================================
* ee.datel.xtee6:xtee6-client-kr
*
* Copyright (C) 2018 - 2024 AS Datel
*
* Redistribution and use in binary form, without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 2. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ===========================LICENSE_END====================================
*/
import ee.datel.client.utils.ServiceUtils;
import ee.datel.xtee.fault.ServiceFaultException;
import ee.xtee6.kr.dm.ArrayOfKinnistuMuudatused;
import ee.xtee6.kr.dm.Client;
import ee.xtee6.kr.dm.IKr;
import ee.xtee6.kr.dm.KinnistuMuudatused;
import ee.xtee6.kr.dm.KinnistusraamatuMuudatusedRequest;
import ee.xtee6.kr.dm.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jakarta.xml.ws.Holder;
import jakarta.xml.ws.WebServiceException;
/**
*
* muudatuste_valik:
136 – koosseis
139 - omand
277 – hoonestusõigus
278 kande kustutamine
280 – korterihoonestusõigus
281 – Ro sulgemine
353 – kustutamine
354 – RO lõpetamine
481 - reaalservituut
520 –lõpetamise eelmärge
590 – RO ühendamine
638 – isiklik kasutusõigus
639 – kasutusvaldus
685 – reaalkoormatis
686 – ostueesõigus
687 – hüpoteek
...
*
*/
public class MuudatusedService extends DetailandmedService {
private static final int STEP = -30; // minutes
private static final int PAGE = 50; // items
private MuudatusedService() {}
protected static Service getServiceIdentifier(String xroadInstance) {
return getServiceIdentifier(xroadInstance, memberClass, serviceCode, subsystemCode,
"Kinnistusraamatu_Muudatused", null);
}
public static List getKrMuudatusteLogi(MuudatusedXRoadParams params, String userid,
LocalDateTime alates, LocalDateTime kuni) throws ServiceFaultException {
var request = new KinnistusraamatuMuudatusedRequest();
request.setMuudatusteValik("136,139,277,280,281,353,354,481,590,638,639,685,686,687");
return stepDate(params, userid, request, alates, kuni);
}
public static List getKr12JaguMuudatusteLogi(MuudatusedXRoadParams params, String userid,
LocalDateTime alates, LocalDateTime kuni) throws ServiceFaultException {
var request = new KinnistusraamatuMuudatusedRequest();
request.setJaoNumber("0,1,2");
request.setMuudatusteValik("136,139,277,280,281,353,354,590");
return stepDate(params, userid, request, alates, kuni);
}
/**
* JaoNumber="3", muudatusteValik="639"
*
* @param params parameetrid
* @param userid kasutaja isikukood
* @param alates alates
* @param kuni kuni
* @return nimekiri
* @throws ServiceFaultException teenuse viga
*/
public static List getKr3JaguMuudatusteLogi(MuudatusedXRoadParams params, String userid,
LocalDateTime alates, LocalDateTime kuni) throws ServiceFaultException {
var request = new KinnistusraamatuMuudatusedRequest();
request.setJaoNumber("3");
request.setMuudatusteValik("639");
return stepDate(params, userid, request, alates, kuni);
}
public static List getKr34JaguMuudatusteLogi(MuudatusedXRoadParams params, String userid,
LocalDateTime alates, LocalDateTime kuni) throws ServiceFaultException {
var request = new KinnistusraamatuMuudatusedRequest();
request.setJaoNumber("3,4");
request.setMuudatusteValik("353,481,638,639,685,686,687");
return stepDate(params, userid, request, alates, kuni);
}
public static List stepDate(MuudatusedXRoadParams params, String userid,
KinnistusraamatuMuudatusedRequest request, LocalDateTime alates, LocalDateTime kuni)
throws ServiceFaultException {
request.setKinnistuteArvLehel(PAGE);
if (!alates.isBefore(kuni)) {
return Collections.emptyList();
}
List kinnistuMuudatused = new ArrayList<>();
LocalDateTime begin = alates;
LocalDateTime end = request.getRegistriosaNr() == null ? alates.minusMinutes(STEP) : kuni;
while (!end.isAfter(kuni)) {
requestDateStep(params, userid, request, begin, end, kinnistuMuudatused);
begin = end;
end = begin.minusMinutes(STEP);
}
if (begin.isBefore(kuni)) {
requestDateStep(params, userid, request, begin, kuni, kinnistuMuudatused);
}
return kinnistuMuudatused;
}
private static void requestDateStep(MuudatusedXRoadParams params, String userid,
KinnistusraamatuMuudatusedRequest request, LocalDateTime alates, LocalDateTime kuni,
List kinnistuMuudatused) throws ServiceFaultException {
request.setKuupaevAlgus(alates);
request.setKuupaevLopp(kuni);
requestPageStep(params, userid, request, kinnistuMuudatused, 1);
}
private static void requestPageStep(MuudatusedXRoadParams params, String userid,
KinnistusraamatuMuudatusedRequest request, List kinnistuMuudatused, int pageNr)
throws ServiceFaultException {
request.setLehekyljeNr(pageNr);
Holder kirjeteArvKokku = new Holder<>();
Holder kirjeteArvParingus = new Holder<>();
Holder lehekyljeNr = new Holder<>();
Holder registriosad = new Holder<>();
Holder kood = new Holder<>();
Holder teade = new Holder<>();
var id = ServiceUtils.getRequestId();
try {
params.getPort().kinnistusraamatuMuudatused(request, kirjeteArvKokku, kirjeteArvParingus, kood, lehekyljeNr,
registriosad, teade, params.getClient(), params.getService(), userid, id,
ServiceUtils.getProtocolVersion());
} catch (WebServiceException ex) {
throw new ServiceFaultException(ex.getClass().getSimpleName(), ex.getMessage(), id);
}
if (kood.value != 0 && kood.value != 1) {
throw new ServiceFaultException(kood.value.toString(), teade.value, id);
}
if (registriosad.value == null) {
throw new ServiceFaultException("NULL", "Teenus tagastas tühja vastuse", id);
}
kinnistuMuudatused.addAll(registriosad.value.getKinnistuMuudatuseds());
while (kinnistuMuudatused.size() < kirjeteArvKokku.value) {
requestPageStep(params, userid, request, kinnistuMuudatused, pageNr + 1);
}
}
public static class MuudatusedXRoadParams {
private IKr port;
private Client client;
private Service service;
public MuudatusedXRoadParams(String serverUrl, String xRoadInstance, String memberClass, String memberCode,
String subsystemCode) {
port = getServicePort(serverUrl);
client = getClientIdentifier(xRoadInstance, memberClass, memberCode, subsystemCode);
service = getServiceIdentifier(xRoadInstance);
}
public Service getService() {
return service;
}
public Client getClient() {
return client;
}
public IKr getPort() {
return port;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy