Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ See [keep a changelog] for information about writing changes to this log.

## [Unreleased]

* [PR-39](https://github.com/itk-dev/sysstatus/pull/39)
Prevented duplicating inactive reports and systems
* [PR-38](https://github.com/itk-dev/sysstatus/pull/38)
* Update importers
* Add example data
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Make sure you have a set of JSON files for testing import Commands.
### Start Docker containers

```shell
docker compose up -d
docker compose up --detach
docker compose exec phpfpm composer install
docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction
```

### Create a super admin user

```sh
docker compose exec phpfpm bin/console SuperUser
docker compose exec phpfpm bin/console app:user:create admin@example.com --password password --role=ROLE_SUPER_ADMIN
```

### Access the site
Expand Down Expand Up @@ -88,7 +88,7 @@ flowchart TD
Theme[Theme]
ThemeCategory[ThemeCategory]
User[User]

fos_user_user_group{{JoinTable: fos_user_user_group }}
group_system_themes{{JoinTable: group_system_themes }}
group_report_themes{{JoinTable: group_report_themes }}
Expand All @@ -111,7 +111,7 @@ flowchart TD
System --- |ManyToMany| SelServiceAFI

Theme --- |ManyToOne| ThemeCategory

Answers --- |ManyToOne| Question
Question -- JoinCollum Answers and Question --o Answers

Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dotenv: ['.env.local', '.env']

vars:
# https://taskfile.dev/reference/templating/
BASE_URL: '{{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default "https://hoeringsportal.local.itkdev.dk"}}'
BASE_URL: '{{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default "https://itstyr.local.itkdev.dk"}}'
DOCKER_COMPOSE: '{{.TASK_DOCKER_COMPOSE | default "docker compose"}}'

tasks:
Expand Down
17 changes: 14 additions & 3 deletions src/Service/BaseImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Repository\ReportRepository;
use App\Repository\SystemRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

abstract class BaseImporter implements ImportInterface
Expand All @@ -22,6 +23,16 @@ public function __construct(
$this->url = $this->params->get('system_url') ?? '';
}

public function import(string $src, ?ProgressBar $progressBar = null): void
{
// We need to be able to find all entities during import.
$this->entityManager->getFilters()->disable('entity_active');

$this->doImport($src, $progressBar);
}

abstract protected function doImport(string $src, ?ProgressBar $progressBar): void;

protected function sanitizeText(string $str): ?string
{
$str = strip_tags($str, '<p><div><strong><a><ul><li><span><br><br/>');
Expand Down Expand Up @@ -63,9 +74,9 @@ protected function convertLink(?object $obj): ?string
/**
* @throws \Exception
*/
protected function convertDate(string $date): \DateTime
protected function convertDate(string $date): ?\DateTimeInterface
{
return new \DateTime($date);
return empty($date) ? null : new \DateTimeImmutable($date);
}

/**
Expand All @@ -76,7 +87,7 @@ protected function convertDate(string $date): \DateTime
protected function convertSystemOwner(array $systemOwner): string
{
if (empty($systemOwner)) {
return '';
return '';
}

return $systemOwner[0]->LookupValue ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Service/ReportImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ReportImporter extends BaseImporter
{
public function import(string $src, ?ProgressBar $progressBar = null): void
public function doImport(string $src, ?ProgressBar $progressBar = null): void
{
$json = file_get_contents($src);
$entries = json_decode($json);
Expand Down
2 changes: 1 addition & 1 deletion src/Service/SystemImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(
parent::__construct($reportRepository, $systemRepository, $groupRepository, $entityManager, $params);
}

public function import(string $src, ?ProgressBar $progressBar = null): void
public function doImport(string $src, ?ProgressBar $progressBar = null): void
{
$json = file_get_contents($src);
$entries = json_decode($json);
Expand Down
Loading