generated from 2martens/template-service
150 lines
4.9 KiB
Java
150 lines
4.9 KiB
Java
package de.twomartens.oparlservice.service;
|
|
|
|
import de.twomartens.oparlservice.configs.OParlServiceProperties;
|
|
import de.twomartens.oparlservice.entity.dto.*;
|
|
import de.twomartens.oparlservice.entity.dto.System;
|
|
import de.twomartens.oparlservice.repository.SystemRepository;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.time.ZonedDateTime;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
import java.util.stream.StreamSupport;
|
|
|
|
@Service
|
|
public class OParlService {
|
|
|
|
private final OParlServiceProperties properties;
|
|
private final SystemRepository systemRepository;
|
|
|
|
public OParlService(OParlServiceProperties properties,
|
|
SystemRepository systemRepository) {
|
|
this.properties = properties;
|
|
this.systemRepository = systemRepository;
|
|
}
|
|
|
|
public Optional<ObjectList<AgendaItem>> getAgendaItemsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<AgendaItem> getAgendaItem(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public ObjectList<Body> getBodies() {
|
|
return null;
|
|
}
|
|
|
|
public Optional<Body> getBody(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Consultation>> getConsultationsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Consultation> getConsultation(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<File>> getFilesInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<File> getFile(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<LegislativeTerm>> getLegislativeTermsOfBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<LegislativeTerm> getLegislativeTerm(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Location>> getLocationsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Location> getLocation(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Meeting> getMeeting(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Meeting>> getMeetingsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Meeting>> getMeetingsInOrganization(String organizationID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Membership> getMembership(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Membership>> getMembershipsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Membership>> getMembershipsInOrganization(String organizationID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Organization>> getOrganizationsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Organization> getOrganization(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Paper>> getPapersInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Paper> getPaper(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<ObjectList<Person>> getPersonsInBody(String bodyID, int pageNumber) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public Optional<Person> getPerson(String id) {
|
|
return Optional.empty();
|
|
}
|
|
|
|
public System getSystem() {
|
|
Iterable<de.twomartens.oparlservice.entity.internal.System> systems = systemRepository.findAll();
|
|
de.twomartens.oparlservice.entity.internal.System firstNotDeletedSystem = StreamSupport
|
|
.stream(systems.spliterator(), false)
|
|
.filter(system -> !system.isDeleted())
|
|
.findFirst().orElseThrow();
|
|
|
|
return System.builder()
|
|
.id(String.valueOf(firstNotDeletedSystem.getId()))
|
|
.type("https://schema.oparl.org/1.1/Schema")
|
|
.created(firstNotDeletedSystem.getCreated())
|
|
.modified(firstNotDeletedSystem.getModified())
|
|
.oparlVersion("https://schema.oparl.org/1.1/")
|
|
.body(properties.getUrl() + "/bodies")
|
|
.license(firstNotDeletedSystem.getLicense())
|
|
.name(firstNotDeletedSystem.getName())
|
|
.contactEmail(firstNotDeletedSystem.getContactEmail())
|
|
.contactName(firstNotDeletedSystem.getContactName())
|
|
.deleted(firstNotDeletedSystem.isDeleted())
|
|
.product(firstNotDeletedSystem.getProduct())
|
|
.vendor(firstNotDeletedSystem.getVendor())
|
|
.web(firstNotDeletedSystem.getWeb())
|
|
.website(firstNotDeletedSystem.getWebsite())
|
|
.otherOparlVersions(Collections.emptyList())
|
|
.build();
|
|
}
|
|
}
|