T11: Organization, Company, link entities + round-trip [checkpoint]
This commit is contained in:
@@ -131,7 +131,8 @@ public class CanonicalWriter {
|
||||
|
||||
CanonicalDataset dataset = new CanonicalDataset(
|
||||
"1.0", voivodeship, LocalDateTime.now(),
|
||||
hospitals, people, affiliations, roles, List.of()
|
||||
hospitals, people, affiliations, roles, List.of(),
|
||||
List.of(), List.of(), List.of(), List.of(), List.of()
|
||||
);
|
||||
|
||||
Path outputFile = canonicalDir.resolve(voivodeship + ".json");
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.developx.szpitale.model.CanonicalDataset;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -50,4 +51,10 @@ public class CanonicalReader {
|
||||
public CanonicalDataset readSingle(Path inputDir, String voivodeship) throws IOException {
|
||||
return readAll(inputDir, voivodeship).stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static CanonicalDataset readDataset(File file) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
return mapper.readValue(file, CanonicalDataset.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,33 @@ public record CanonicalDataset(
|
||||
@JsonProperty("people") List<Person> people,
|
||||
@JsonProperty("affiliations") List<Affiliation> affiliations,
|
||||
@JsonProperty("roles") List<Role> roles,
|
||||
@JsonProperty("mandates") List<Mandate> mandates
|
||||
@JsonProperty("mandates") List<Mandate> mandates,
|
||||
@JsonProperty("organizations") List<Organization> organizations,
|
||||
@JsonProperty("companies") List<Company> companies,
|
||||
@JsonProperty("personOrganizationLinks") List<PersonOrganizationLink> personOrganizationLinks,
|
||||
@JsonProperty("organizationLinks") List<OrganizationLink> organizationLinks,
|
||||
@JsonProperty("personCompanyLinks") List<PersonCompanyLink> personCompanyLinks
|
||||
) {
|
||||
public CanonicalDataset(String schemaVersion, String voivodeship, LocalDateTime generatedAt,
|
||||
List<Hospital> hospitals, List<Person> people,
|
||||
List<Affiliation> affiliations, List<Role> roles,
|
||||
List<Mandate> mandates,
|
||||
List<Organization> organizations, List<Company> companies,
|
||||
List<PersonOrganizationLink> personOrganizationLinks,
|
||||
List<OrganizationLink> organizationLinks,
|
||||
List<PersonCompanyLink> personCompanyLinks) {
|
||||
this.schemaVersion = schemaVersion;
|
||||
this.voivodeship = voivodeship;
|
||||
this.generatedAt = generatedAt;
|
||||
this.hospitals = hospitals != null ? hospitals : List.of();
|
||||
this.people = people != null ? people : List.of();
|
||||
this.affiliations = affiliations != null ? affiliations : List.of();
|
||||
this.roles = roles != null ? roles : List.of();
|
||||
this.mandates = mandates != null ? mandates : List.of();
|
||||
this.organizations = organizations != null ? organizations : List.of();
|
||||
this.companies = companies != null ? companies : List.of();
|
||||
this.personOrganizationLinks = personOrganizationLinks != null ? personOrganizationLinks : List.of();
|
||||
this.organizationLinks = organizationLinks != null ? organizationLinks : List.of();
|
||||
this.personCompanyLinks = personCompanyLinks != null ? personCompanyLinks : List.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.developx.szpitale.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record Company(
|
||||
@JsonProperty("id") String id,
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("krs") String krs,
|
||||
@JsonProperty("nip") String nip,
|
||||
@JsonProperty("ceidgId") String ceidgId,
|
||||
@JsonProperty("sourceUrls") List<String> sourceUrls
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.developx.szpitale.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record Organization(
|
||||
@JsonProperty("id") String id,
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("krs") String krs,
|
||||
@JsonProperty("nip") String nip,
|
||||
@JsonProperty("sourceUrls") List<String> sourceUrls
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.developx.szpitale.model;
|
||||
|
||||
import com.developx.szpitale.model.enums.LinkBasis;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record OrganizationLink(
|
||||
@JsonProperty("fromOrganizationId") String fromOrganizationId,
|
||||
@JsonProperty("toOrganizationId") String toOrganizationId,
|
||||
@JsonProperty("basis") LinkBasis basis,
|
||||
@JsonProperty("note") String note,
|
||||
@JsonProperty("sourceUrls") List<String> sourceUrls
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.developx.szpitale.model;
|
||||
|
||||
import com.developx.szpitale.model.enums.LinkBasis;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record PersonCompanyLink(
|
||||
@JsonProperty("personId") String personId,
|
||||
@JsonProperty("companyId") String companyId,
|
||||
@JsonProperty("roleLabel") String roleLabel,
|
||||
@JsonProperty("basis") LinkBasis basis,
|
||||
@JsonProperty("sourceUrls") List<String> sourceUrls
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.developx.szpitale.model;
|
||||
|
||||
import com.developx.szpitale.model.enums.LinkBasis;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record PersonOrganizationLink(
|
||||
@JsonProperty("personId") String personId,
|
||||
@JsonProperty("organizationId") String organizationId,
|
||||
@JsonProperty("roleLabel") String roleLabel,
|
||||
@JsonProperty("basis") LinkBasis basis,
|
||||
@JsonProperty("sourceUrls") List<String> sourceUrls
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.developx.szpitale.model.enums;
|
||||
|
||||
public enum LinkBasis {
|
||||
KRS,
|
||||
NIP,
|
||||
CEIDG
|
||||
}
|
||||
Reference in New Issue
Block a user