Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-server
Commits
e655cb44
Commit
e655cb44
authored
Mar 17, 2020
by
François Agneray
Browse files
#42
=> done
parent
5be0dc78
Pipeline
#2157
passed with stages
in 3 minutes and 31 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Entity/Dataset.php
View file @
e655cb44
...
...
@@ -93,9 +93,9 @@ class Dataset implements \JsonSerializable
protected
$project
;
/**
* @var Anis\Entity\
Project
* @var Anis\Entity\
DatasetFamily
*
* @ManyToOne(targetEntity="DatasetFamily")
* @ManyToOne(targetEntity="DatasetFamily"
, inversedBy="datasets"
)
* @JoinColumn(name="id_dataset_family", referencedColumnName="id", nullable=false)
*/
protected
$datasetFamily
;
...
...
src/Entity/DatasetFamily.php
View file @
e655cb44
...
...
@@ -46,15 +46,21 @@ class DatasetFamily implements \JsonSerializable
/**
* @var Anis\Entity\Instance
*
* @ManyToOne(targetEntity="Instance")
* @ManyToOne(targetEntity="Instance"
, inversedBy="datasetFamilies"
)
* @JoinColumn(name="instance_name", referencedColumnName="name", nullable=false)
*/
protected
$instance
;
/**
* @var Anis\Entity\Dataset[]
*
* @OneToMany(targetEntity="Dataset", mappedBy="datasetFamily", cascade={"remove"})
*/
protected
$datasets
;
public
function
__construct
(
Instance
$instance
)
{
$this
->
instance
=
$instance
;
$this
->
datasets
=
new
ArrayCollection
();
}
public
function
getId
():
int
...
...
@@ -82,6 +88,11 @@ class DatasetFamily implements \JsonSerializable
$this
->
display
=
$display
;
}
public
function
getDatasets
()
{
return
$this
->
datasets
;
}
public
function
jsonSerialize
()
{
return
[
...
...
src/Entity/Instance.php
View file @
e655cb44
...
...
@@ -12,6 +12,8 @@ declare(strict_types=1);
namespace
App\Entity
;
use
Doctrine\Common\Collections\ArrayCollection
;
/**
* @Entity
* @Table(name="instance")
...
...
@@ -40,10 +42,18 @@ class Instance implements \JsonSerializable
*/
protected
$clientUrl
;
/**
* @var Anis\Entity\DatasetFamily[]
*
* @OneToMany(targetEntity="DatasetFamily", mappedBy="instance", cascade={"remove"})
*/
protected
$datasetFamilies
;
public
function
__construct
(
string
$name
,
string
$label
)
{
$this
->
name
=
$name
;
$this
->
label
=
$label
;
$this
->
datasetFamilies
=
new
ArrayCollection
();
}
public
function
getName
()
...
...
@@ -71,12 +81,28 @@ class Instance implements \JsonSerializable
$this
->
clientUrl
=
$clientUrl
;
}
public
function
getDatasetFamilies
()
{
return
$this
->
datasetFamilies
;
}
public
function
getNbDatasets
()
{
$nbDatasets
=
0
;
foreach
(
$this
->
datasetFamilies
as
$family
)
{
$nbDatasets
+=
$family
->
getDatasets
()
->
count
();
}
return
$nbDatasets
;
}
public
function
jsonSerialize
()
{
return
[
'name'
=>
$this
->
getName
(),
'label'
=>
$this
->
getLabel
(),
'client_url'
=>
$this
->
getClientUrl
()
'client_url'
=>
$this
->
getClientUrl
(),
'nb_dataset_families'
=>
$this
->
getDatasetFamilies
()
->
count
(),
'nb_datasets'
=>
$this
->
getNbDatasets
()
];
}
}
tests/Action/InstanceActionTest.php
View file @
e655cb44
...
...
@@ -69,7 +69,9 @@ final class InstanceActionTest extends TestCase
{
$fields
=
array
(
'label'
=>
'AspiC'
,
'client_url'
=>
'http://aspic.lam.fr'
'client_url'
=>
'http://aspic.lam.fr'
,
'nb_dataset_families'
=>
0
,
'nb_datasets'
=>
0
);
$this
->
addAnInstance
();
$request
=
$this
->
getRequest
(
'PUT'
)
->
withParsedBody
(
$fields
);
...
...
tests/Action/InstanceListActionTest.php
View file @
e655cb44
...
...
@@ -62,7 +62,9 @@ final class InstanceListActionTest extends TestCase
$fields
=
array
(
'name'
=>
'aspic'
,
'label'
=>
'Aspic'
,
'client_url'
=>
'http://cesam.lam.fr/aspic'
'client_url'
=>
'http://cesam.lam.fr/aspic'
,
'nb_dataset_families'
=>
0
,
'nb_datasets'
=>
0
);
$request
=
$this
->
getRequest
(
'POST'
)
->
withParsedBody
(
$fields
);
$response
=
(
$this
->
action
)(
$request
,
new
Response
(),
array
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment