Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OParl: Add a links to originator in paper object. #161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions protected/components/OParl10Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,33 @@ private static function paper($id) {
$antrag = Antrag::model()->findByPk($id);

$data = [
'id' => OParl10Controller::getOparlObjectUrl('paper', $antrag->id),
'type' => self::TYPE_PAPER,
'body' => OParl10Controller::getOparlObjectUrl('body', ($antrag->ba_nr != null ? $antrag->ba_nr : 0)),
'name' => $antrag->getName(),
'reference' => $antrag->antrags_nr,
'paperType' => $antrag->getTypName(),
'auxiliaryFile' => [],
'underDirectionOf' => [OParl10Controller::getOparlObjectUrl('organization', $antrag->referat_id, 'referat')],
'keyword' => [],
'web' => SITE_BASE_URL . $antrag->getLink(),
'created' => OParl10Controller::mysqlToOparlDateTime($antrag->created),
'modified' => OParl10Controller::mysqlToOparlDateTime($antrag->modified),
'id' => OParl10Controller::getOparlObjectUrl('paper', $antrag->id),
'type' => self::TYPE_PAPER,
'body' => OParl10Controller::getOparlObjectUrl('body', ($antrag->ba_nr != null ? $antrag->ba_nr : 0)),
'name' => $antrag->getName(),
'reference' => $antrag->antrags_nr,
'paperType' => $antrag->getTypName(),
'auxiliaryFile' => [],
'originatorPerson' => [],
'originatorOrganization' => [],
'underDirectionOf' => [OParl10Controller::getOparlObjectUrl('organization', $antrag->referat_id, 'referat')],
'keyword' => [],
'web' => SITE_BASE_URL . $antrag->getLink(),
'created' => OParl10Controller::mysqlToOparlDateTime($antrag->created),
'modified' => OParl10Controller::mysqlToOparlDateTime($antrag->modified),
];

foreach ($antrag->antraegePersonen as $ap) {
if ($ap->typ == AntragPerson::$TYP_GESTELLT_VON) {
$organization = Gremium::model()->findByName($ap->person->name);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a findByName() method exist in the model?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that might be rather ->findByAttributes(["name" => ...]). Though sure you want to find a "Gremium" by a person's name? Which information (in the UI) do you actually want to retrieve?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the UI (e.g. here) the field "Gestellt von" which seems to be rendered by

zeile_anzeigen($personen[AntragPerson::$TYP_GESTELLT_VON], "Gestellt von:", "gestellt_von", function ($person) use ($antrag) {
/** @var Person $person */
if ($person->stadtraetIn) {
echo CHtml::link($person->stadtraetIn->name, $person->stadtraetIn->getLink());
echo " (" . CHtml::encode($person->ratePartei($antrag->gestellt_am)) . ")";
} else {
echo CHtml::encode($person->name);
}
});

If you could fix the data model / parser, this would of course be preferable.

if ($organization) {
$data['originatorOrganization'][] = OParl10Controller::getOparlObjectUrl('organization', $organization->id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind the trailing semicolon at the end of the line is (unfortunately) not optional here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CatoTH Also I missed the necessary sub-id fraktion for organizations.

}
} else if ($ap->typ == AntragPerson::$TYP_INITIATORIN) {
$data['originatorPerson'][] = OParl10Controller::getOparlObjectUrl('person', $ap->person->id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is $ap->person-id the right property or do we want to use $ap->person->stadtraetIn->id?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter is probably more relevant, as that is the ID used by the original RIS (the number in the URL https://www.muenchen-transparent.de/personen/5963817_Andreas+Schuster)

}
}

foreach ($antrag->dokumente as $dokument)
$data['auxiliaryFile'][] = self::file($dokument->id);

Expand Down