Skip to content

Commit

Permalink
Renames Category to Kind (#98)
Browse files Browse the repository at this point in the history
Issues can be either A issues or B issues. This PR changes the name of
this type from Category to Kind
  • Loading branch information
fizk authored Jun 26, 2024
1 parent 4b92f31 commit 596e01d
Show file tree
Hide file tree
Showing 102 changed files with 885 additions and 670 deletions.
4 changes: 2 additions & 2 deletions config/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@
'thingmal' => [
'type' => Segment::class,
'options' => [
'route' => '/thingmal[/:category[/:issue_id]]',
'route' => '/thingmal[/:kind[/:issue_id]]',
'constraints' => [
'issue_id' => '[0-9]+',
'category' => '[abAB]',
'kind' => '[abAB]',
],
'defaults' => [
'controller' => Controller\IssueController::class,
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=${ENV_DB_PASSWORD:-example}
- MYSQL_DATABASE=${ENV_DB_NAME:-althingi}
command: --default-authentication-plugin=mysql_native_password
volumes:
- local-source-db-volume:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password

database-test:
container_name: local-althingi-source-db-test
Expand All @@ -126,7 +126,10 @@ services:
environment:
- MYSQL_DATABASE=althingi
- MYSQL_ROOT_PASSWORD=example
volumes:
- local-source-db-test-volume:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password

volumes:
local-source-db-volume:
local-source-db-test-volume:
27 changes: 27 additions & 0 deletions schema/00005.rename-category.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

ALTER TABLE `Category_has_Issue` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `CommitteeMeetingAgenda` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Congressman_has_Issue` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Document` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Document_has_Congressman` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Document_has_Committee` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Issue` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `PlenaryAgenda` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Speech` RENAME COLUMN `category` TO `kind`;
ALTER TABLE `Vote` RENAME COLUMN `category` TO `kind`;



ALTER TABLE `Category_has_Issue` MODIFY `kind` char(1);
ALTER TABLE `CommitteeMeetingAgenda` MODIFY `kind` char(1);
ALTER TABLE `Congressman_has_Issue` MODIFY `kind` char(1);
ALTER TABLE `Document` MODIFY `kind` char(1);
ALTER TABLE `Document_has_Congressman` MODIFY `kind` char(1);
ALTER TABLE `Document_has_Committee` MODIFY `kind` char(1);
ALTER TABLE `Issue` MODIFY `kind` char(1);
ALTER TABLE `PlenaryAgenda` MODIFY `kind` char(1);
ALTER TABLE `Speech` MODIFY `kind` char(1);
ALTER TABLE `Vote` MODIFY `kind` char(1);

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2 changes: 1 addition & 1 deletion src/Controller/AssemblyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function patch(ServerRequest $request): ResponseInterface
{
if (($assembly = $this->assemblyService->get($request->getAttribute('id'))) != null) {
$form = new Form\Assembly([
...(new \Althingi\Hydrator\Assembly())->extract($assembly),
...$assembly->toArray(),
...$request->getParsedBody(),
'assembly_id' => $request->getAttribute('id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CabinetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function patch(ServerRequest $request): ResponseInterface
{
if (($committee = $this->cabinetService->get($request->getAttribute('id'))) != null) {
$form = new Form\Cabinet([
...(new \Althingi\Hydrator\Cabinet)->extract($committee),
...$committee->toArray(),
...$request->getParsedBody(),
'cabinet_id' => $request->getAttribute('id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function patch(ServerRequest $request): ResponseInterface
{
if (($category = $this->categoryService->get($request->getAttribute('category_id'))) != null) {
$form = new Form\Category([
...(new \Althingi\Hydrator\Category)->extract($category),
...$category->toArray(),
...$request->getParsedBody(),
'super_category_id' => $request->getAttribute('super_category_id'),
'category_id' => $request->getAttribute('category_id')
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CommitteeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function patch(ServerRequest $request): ResponseInterface
{
if (($committee = $this->committeeService->get($request->getAttribute('committee_id'))) != null) {
$form = new Form\Committee([
...(new \Althingi\Hydrator\Committee)->extract($committee),
...$committee->toArray(),
...$request->getParsedBody(),
'assembly_id' => $request->getAttribute('id'),
'committee_id' => $request->getAttribute('committee_id'),
Expand Down
9 changes: 5 additions & 4 deletions src/Controller/CommitteeDocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Althingi\Form;
use Althingi\Service;
use Althingi\Injector\ServiceCommitteeDocumentAwareInterface;
use Althingi\Model\KindEnum;
use Althingi\Router\{
RestControllerInterface,
RestControllerTrait,
Expand Down Expand Up @@ -103,7 +104,7 @@ public function post(ServerRequest $request): ResponseInterface
...$request->getParsedBody(),
'assembly_id' => $assemblyId,
'issue_id' => $issueId,
'category' => 'A',
'kind' => KindEnum::A->value,
'document_id' => $documentId,
]);

Expand All @@ -120,7 +121,7 @@ public function post(ServerRequest $request): ResponseInterface
$committeeDocument->getDocumentId(),
$committeeDocument->getAssemblyId(),
$committeeDocument->getIssueId(),
'A',
KindEnum::A,
$committeeDocument->getCommitteeId(),
$committeeDocument->getPart()
);
Expand All @@ -134,7 +135,7 @@ public function post(ServerRequest $request): ResponseInterface
'Location' => $this->router->assemble([
'id' => $assemblyId,
'issue_id' => $issueId,
'category' => 'a',
'kind' => KindEnum::A->value,
'document_id' => $documentId,
'document_committee_id' => $committeeDocumentId
], ['name' => 'loggjafarthing/thingmal/thingskjal/nefndir'])
Expand All @@ -156,7 +157,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('document_committee_id')
)) != null) {
$form = new Form\CommitteeDocument([
...(new \Althingi\Hydrator\CommitteeDocument)->extract($committeeDocument),
...$committeeDocument->toArray(),
...$request->getParsedBody(),
'document_committee_id' => $request->getAttribute('document_committee_id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CommitteeMeetingAgendaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function patch(ServerRequest $request): ResponseInterface
if (($committeeMeetingAgenda = $this->committeeMeetingAgendaService
->get($committeeMeetingId, $committeeMeetingAgendaId)) != null) {
$form = new Form\CommitteeMeetingAgenda([
...(new \Althingi\Hydrator\CommitteeMeetingAgenda())->extract($committeeMeetingAgenda),
...$committeeMeetingAgenda->toArray(),
...$request->getParsedBody(),
'committee_meeting_id' => $request->getAttribute('committee_meeting_id'),
'committee_meeting_agenda_id' => $request->getAttribute('committee_meeting_agenda_id'),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CommitteeMeetingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function patch(ServerRequest $request): ResponseInterface

if (($committeeMeeting = $this->committeeMeetingService->get($committeeMeetingId)) != null) {
$form = new Form\CommitteeMeeting([
...(new \Althingi\Hydrator\CommitteeMeeting())->extract($committeeMeeting),
...$committeeMeeting->toArray(),
...$request->getParsedBody(),
'committee_meeting_id' => $request->getAttribute('committee_meeting_id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CommitteeSittingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('committee_sitting_id')
)) != null) {
$form = new Form\CommitteeSitting([
...(new \Althingi\Hydrator\CommitteeSitting)->extract($committeeSitting),
...$committeeSitting->toArray(),
...$request->getParsedBody(),
'committee_sitting_id' =>$request->getAttribute('committee_sitting_id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/CongressmanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('congressman_id')
)) != null) {
$form = new Form\Congressman([
...(new \Althingi\Hydrator\Congressman)->extract($congressman),
...$congressman->toArray(),
...$request->getParsedBody(),
'congressman_id' => $request->getAttribute('congressman_id'),
]);
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/CongressmanDocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Althingi\Service;
use Althingi\Utils\ErrorFormResponse;
use Althingi\Injector\ServiceProponentAwareInterface;
use Althingi\Model\KindEnum;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\ServerRequest;
use Althingi\Router\{
Expand Down Expand Up @@ -40,7 +41,7 @@ public function put(ServerRequest $request): ResponseInterface
'issue_id' => $issueId,
'document_id' => $documentId,
'congressman_id' => $congressmanId,
'category' => 'A',
'kind' => KindEnum::A->value,
]);

if ($form->isValid()) {
Expand All @@ -67,7 +68,7 @@ public function patch(ServerRequest $request): ResponseInterface
if (($congressmanDocument = $this->congressmanDocumentService
->get($assemblyId, $issueId, $documentId, $congressmanId)) != null) {
$form = new Form\CongressmanDocument([
...(new \Althingi\Hydrator\CongressmanDocument())->extract($congressmanDocument),
...$congressmanDocument->toArray(),
...$request->getParsedBody(),
'id' => $request->getAttribute('id'),
'issue_id' => $request->getAttribute('issue_id'),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ConstituencyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('id')
)) !== null) {
$form = new Form\Constituency([
...(new \Althingi\Hydrator\Constituency())->extract($constituency),
...$constituency->toArray(),
...$request->getParsedBody(),
'constituency_id' => $request->getAttribute('id')
]);
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Althingi\Service;
use Althingi\Form;
use Althingi\Injector\ServiceDocumentAwareInterface;
use Althingi\Model\KindEnum;
use Althingi\Utils\ErrorFormResponse;
use Althingi\Router\{
RestControllerTrait,
Expand Down Expand Up @@ -71,7 +72,7 @@ public function put(ServerRequest $request): ResponseInterface
'assembly_id' => $assemblyId,
'issue_id' => $issueId,
'document_id' => $documentId,
'category' => 'A',
'kind' => KindEnum::A->value,
]);

if ($form->isValid()) {
Expand All @@ -96,7 +97,7 @@ public function patch(ServerRequest $request): ResponseInterface

if (($document = $this->documentService->get($assemblyId, $issueId, $documentId)) != null) {
$form = new Form\Document([
...(new \Althingi\Hydrator\Document())->extract($document),
...$document->toArray(),
...$request->getParsedBody(),
'id' => $request->getAttribute('id'),
'issue_id' => $request->getAttribute('issue_id'),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/InflationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('id')
)) != null) {
$form = new Form\Inflation([
...(new \Althingi\Hydrator\Inflation())->extract($committee),
...$committee->toArray(),
...$request->getParsedBody(),
'id' => $request->getAttribute('id'),
]);
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/IssueCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ServiceIssueCategoryAwareInterface,
ServiceCategoryAwareInterface
};
use Althingi\Model\KindEnum;
use Althingi\Utils\{
ErrorFormResponse
};
Expand Down Expand Up @@ -82,7 +83,7 @@ public function put(ServerRequest $request): ResponseInterface
'assembly_id' => $assemblyId,
'issue_id' => $issueId,
'category_id' => $categoryId,
'category' => 'A'
'kind' => KindEnum::A->value
]));

if ($form->isValid()) {
Expand All @@ -107,7 +108,7 @@ public function patch(ServerRequest $request): ResponseInterface

if (($issueCategory = $this->issueCategoryService->get($assemblyId, $issueId, $categoryId)) != null) {
$form = new Form\IssueCategory([
...(new \Althingi\Hydrator\IssueCategory())->extract($issueCategory),
...$issueCategory->toArray(),
...$request->getParsedBody(),
'id' => $request->getAttribute('id'),
'issue_id' => $request->getAttribute('issue_id'),
Expand Down
15 changes: 8 additions & 7 deletions src/Controller/IssueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
};
use Althingi\Injector\ServiceIssueAwareInterface;
use Althingi\Form;
use Althingi\Model\KindEnum;
use Althingi\Service;
use Althingi\Router\RestControllerTrait;
use Althingi\Utils\ErrorFormResponse;
Expand All @@ -34,9 +35,9 @@ public function get(ServerRequest $request): ResponseInterface
{
$assemblyId = $request->getAttribute('id', 0);
$issueId = $request->getAttribute('issue_id', 0);
$category = strtoupper($request->getAttribute('category', 'a'));
$kind = KindEnum::fromString($request->getAttribute('kind', 'a'));

$issue = $this->issueService->get($issueId, $assemblyId, $category);
$issue = $this->issueService->get($issueId, $assemblyId, $kind);

return $issue
? new JsonResponse($issue)
Expand Down Expand Up @@ -90,14 +91,14 @@ public function getList(ServerRequest $request): ResponseInterface
public function put(ServerRequest $request): ResponseInterface
{
$assemblyId = $request->getAttribute('id');
$category = strtoupper($request->getAttribute('category', 'a'));
$kind = KindEnum::fromString($request->getAttribute('kind', 'a'));
$issueId = $request->getAttribute('issue_id');

$form = new Form\Issue([
...$request->getParsedBody(),
'assembly_id' => $assemblyId,
'issue_id' => $issueId,
'category' => $category
'kind' => $kind->value,
]);

if ($form->isValid()) {
Expand All @@ -119,19 +120,19 @@ public function put(ServerRequest $request): ResponseInterface
public function patch(ServerRequest $request): ResponseInterface
{
$assemblyId = $request->getAttribute('id');
$category = strtoupper($request->getAttribute('category', 'a'));
$kind = KindEnum::fromString($request->getAttribute('kind', 'a'));
$issue = $this->issueService->get(
$request->getAttribute('issue_id'),
$assemblyId,
$category
$kind,
);

if (! $issue) {
return new EmptyResponse(404);
}

$form = new Form\Issue([
...(new \Althingi\Hydrator\Issue())->extract($issue),
...$issue->toArray(),
...$request->getParsedBody(),
'assembly_id' => $request->getAttribute('id'),
'issue_id' => $request->getAttribute('issue_id'),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/MinisterSittingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('ministry_sitting_id')
)) != null) {
$form = new Form\MinisterSitting([
...(new \Althingi\Hydrator\MinisterSitting())->extract($ministerSitting),
...$ministerSitting->toArray(),
...$request->getParsedBody(),
'ministry_sitting_id' => $request->getAttribute('ministry_sitting_id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/MinistryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('id')
)) !== null) {
$form = new Form\Ministry([
...(new \Althingi\Hydrator\Ministry())->extract($ministry),
...$ministry->toArray(),
...$request->getParsedBody(),
'ministry_id' => $request->getAttribute('id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PartyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('id')
)) !== null) {
$form = new Form\Party([
...(new \Althingi\Hydrator\Party())->extract($party),
...$party->toArray(),
...$request->getParsedBody(),
'party_id' => $request->getAttribute('id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PlenaryAgendaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function put(ServerRequest $request): ResponseInterface
$this->issueService->create((new IssueModel())
->setIssueId($data->getIssueId())
->setAssemblyId($data->getAssemblyId())
->setCategory($data->getCategory())
->setKind($data->getKind())
->setName(null)
->setType(null)
->setTypeName(null));
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PlenaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function patch(ServerRequest $request): ResponseInterface

if (($plenary = $this->plenaryService->get($assemblyId, $plenaryId)) != null) {
$form = new Form\Plenary([
...(new \Althingi\Hydrator\Plenary)->extract($plenary),
...$plenary->toArray(),
...$request->getParsedBody(),
'assembly_id' => $request->getAttribute('id'),
'plenary_id' => $request->getAttribute('plenary_id'),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PresidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('id')
)) != null) {
$form = new Form\President([
...(new \Althingi\Hydrator\President())->extract($president),
...$president->toArray(),
...$request->getParsedBody(),
// 'president_id' => $request->getAttribute('id'),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function patch(ServerRequest $request): ResponseInterface
$request->getAttribute('session_id')
)) !== null) {
$form = new Form\Session([
...(new \Althingi\Hydrator\Session())->extract($session),
...$session->toArray(),
...$request->getParsedBody(),
'session_id' => $request->getAttribute('session_id')
]);
Expand Down
Loading

0 comments on commit 596e01d

Please sign in to comment.