-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,715 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
interfaces/src/main/java/be/vlaanderen/vip/magda/client/AbstractConnectorMagdaClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package be.vlaanderen.vip.magda.client; | ||
|
||
import be.vlaanderen.vip.magda.exception.ServerException; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class AbstractConnectorMagdaClient implements MagdaClient { | ||
|
||
private final MagdaConnector connector; | ||
|
||
protected AbstractConnectorMagdaClient( | ||
MagdaConnector connector) { | ||
this.connector = connector; | ||
} | ||
|
||
@Override | ||
public MagdaResponseWrapper send(MagdaRequest request) throws MagdaClientException { | ||
return send(request, UUID.randomUUID()); | ||
} | ||
|
||
@Override | ||
public MagdaResponseWrapper send(MagdaRequest request, UUID requestId) throws MagdaClientException { | ||
try { | ||
var response = connector.send(request, requestId); | ||
|
||
validateMagdaResponse(response, request); | ||
|
||
return new MagdaResponseWrapper(response); | ||
} | ||
catch (ServerException e) { | ||
throw new MagdaClientException("Error occurred while sending magda request", e); | ||
} | ||
} | ||
|
||
protected abstract void validateMagdaResponse(MagdaResponse response, MagdaRequest request) throws MagdaClientException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
interfaces/src/main/java/be/vlaanderen/vip/magda/client/LenientConnectorMagdaClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package be.vlaanderen.vip.magda.client; | ||
|
||
import be.vlaanderen.vip.magda.exception.UitzonderingenSectionInResponseException; | ||
|
||
/** | ||
* A MagdaConnector-based client which handles level 2 uitzondingen in the response. | ||
*/ | ||
public class LenientConnectorMagdaClient extends AbstractConnectorMagdaClient { | ||
|
||
public LenientConnectorMagdaClient(MagdaConnector connector) { | ||
super(connector); | ||
} | ||
|
||
@Override | ||
protected void validateMagdaResponse(MagdaResponse response, MagdaRequest request) throws MagdaClientException { | ||
if(!response.getUitzonderingEntries().isEmpty()) { | ||
throw new MagdaClientException("Level 2 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getUitzonderingEntries(), request.getCorrelationId(), response.getRequestId())); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...aces/src/main/java/be/vlaanderen/vip/magda/client/diensten/EducationEnrollmentSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package be.vlaanderen.vip.magda.client.diensten; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum EducationEnrollmentSource { | ||
HO("HO"), | ||
INT("INT"), | ||
LP("LP"), | ||
VWO("VWO"); | ||
|
||
private final String value; | ||
|
||
EducationEnrollmentSource(String value) { | ||
this.value = value; | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...c/main/java/be/vlaanderen/vip/magda/client/diensten/GeefHistoriekInschrijvingRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package be.vlaanderen.vip.magda.client.diensten; | ||
|
||
import be.vlaanderen.vip.magda.client.MagdaDocument; | ||
import be.vlaanderen.vip.magda.client.MagdaServiceIdentification; | ||
import be.vlaanderen.vip.magda.client.diensten.subject.INSZNumber; | ||
import be.vlaanderen.vip.magda.client.domeinservice.MagdaRegistrationInfo; | ||
import jakarta.annotation.Nullable; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE; | ||
|
||
/** | ||
* A request to the "Onderwijs.GeefHistoriekInschrijving" MAGDA service, which provides education enrollment histories for a person. | ||
* Adds the following fields to the {@link PersonMagdaRequest}: | ||
* <ul> | ||
* <li>startDate: the start date of the period</li> | ||
* <li>endDate: the end date of the period</li> | ||
* <li>sources: the sources to be consulted (optional)</li> | ||
* </ul> | ||
* | ||
* @see <a href="file:resources/templates/Onderwijs.GeefHistoriekInschrijvingDienst/02.01.0000/template.xml">XML template for this request type</a> | ||
*/ | ||
@Getter | ||
@ToString | ||
@EqualsAndHashCode(callSuper = true) | ||
public class GeefHistoriekInschrijvingRequest extends PersonMagdaRequest { | ||
|
||
public static class Builder extends PersonMagdaRequest.Builder<Builder> { | ||
|
||
@Getter(AccessLevel.PROTECTED) | ||
private LocalDate startDate; | ||
@Getter(AccessLevel.PROTECTED) | ||
private LocalDate endDate; | ||
@Getter(AccessLevel.PROTECTED) | ||
private Set<EducationEnrollmentSource> sources; | ||
|
||
public Builder startDate(LocalDate startDate) { | ||
this.startDate = startDate; | ||
return this; | ||
} | ||
|
||
public Builder endDate(LocalDate endDate) { | ||
this.endDate = endDate; | ||
return this; | ||
} | ||
|
||
public Builder sources(Set<EducationEnrollmentSource> sources) { | ||
this.sources = sources; | ||
return this; | ||
} | ||
|
||
public GeefHistoriekInschrijvingRequest build() { | ||
if(getInsz() == null) { throw new IllegalStateException("INSZ number must be given"); } | ||
if(getStartDate() == null) { throw new IllegalStateException("Start date must be given"); } | ||
if(getEndDate() == null) { throw new IllegalStateException("End date must be given"); } | ||
|
||
return new GeefHistoriekInschrijvingRequest( | ||
getInsz(), | ||
getRegistration(), | ||
getStartDate(), | ||
getEndDate(), | ||
getSources() | ||
); | ||
} | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
@NotNull | ||
private final LocalDate startDate; | ||
@NotNull | ||
private final LocalDate endDate; | ||
@Nullable | ||
private final Set<EducationEnrollmentSource> sources; | ||
|
||
private GeefHistoriekInschrijvingRequest( | ||
@NotNull INSZNumber insz, | ||
@NotNull String registratie, | ||
@NotNull LocalDate startDate, | ||
@NotNull LocalDate endDate, | ||
@Nullable Set<EducationEnrollmentSource> sources) { | ||
super(insz, registratie); | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
this.sources = sources; | ||
} | ||
|
||
@Override | ||
public MagdaServiceIdentification magdaServiceIdentification() { | ||
return new MagdaServiceIdentification("Onderwijs.GeefHistoriekInschrijving", "02.01.0000"); | ||
} | ||
|
||
@Override | ||
protected void fillIn(MagdaDocument request, UUID requestId, MagdaRegistrationInfo magdaRegistrationInfo) { | ||
fillInCommonFields(request, requestId, magdaRegistrationInfo); | ||
|
||
request.setValue("//Criteria/Periode/Begin", startDate.format(ISO_LOCAL_DATE)); | ||
request.setValue("//Criteria/Periode/Einde", endDate.format(ISO_LOCAL_DATE)); | ||
if(sources != null) { | ||
sources.forEach(source -> request.createTextNode("//Criteria/Bronnen", "Bron", source.getValue())); | ||
} else { | ||
request.removeNode("//Criteria/Bronnen"); | ||
} | ||
} | ||
} |
Oops, something went wrong.