Skip to content
GitLab
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
de89156e
Commit
de89156e
authored
Apr 17, 2021
by
François Agneray
Browse files
Add nb_datasets for project entity
parent
a2da1b6c
Pipeline
#4938
passed with stages
in 2 minutes and 57 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Entity/Attribute.php
View file @
de89156e
...
...
@@ -251,7 +251,7 @@ class Attribute implements \JsonSerializable
* @var App\Entity\CriteriaFamily
*
* @ManyToOne(targetEntity="CriteriaFamily")
* @JoinColumn(name="criteria_family", referencedColumnName="id", nullable=true)
* @JoinColumn(name="criteria_family", referencedColumnName="id", nullable=true
, onDelete="SET NULL"
)
*/
protected
$criteriaFamily
;
...
...
@@ -259,7 +259,7 @@ class Attribute implements \JsonSerializable
* @var App\Entity\OutputCategory
*
* @ManyToOne(targetEntity="OutputCategory")
* @JoinColumn(name="output_category", referencedColumnName="id", nullable=true)
* @JoinColumn(name="output_category", referencedColumnName="id", nullable=true
, onDelete="SET NULL"
)
*/
protected
$outputCategory
;
...
...
src/Entity/Dataset.php
View file @
de89156e
...
...
@@ -94,7 +94,7 @@ class Dataset implements \JsonSerializable
/**
* @var Anis\Entity\Project
*
* @ManyToOne(targetEntity="Project")
* @ManyToOne(targetEntity="Project"
, inversedBy="datasets"
)
* @JoinColumn(name="project_name", referencedColumnName="name", nullable=false)
*/
protected
$project
;
...
...
src/Entity/Project.php
View file @
de89156e
...
...
@@ -62,9 +62,17 @@ class Project implements \JsonSerializable
*/
protected
$database
;
/**
* @var Anis\Entity\Dataset[]
*
* @OneToMany(targetEntity="Dataset", mappedBy="project")
*/
protected
$datasets
;
public
function
__construct
(
string
$name
)
{
$this
->
name
=
$name
;
$this
->
datasets
=
new
\
Doctrine\Common\Collections\ArrayCollection
();
}
public
function
getName
()
...
...
@@ -122,6 +130,11 @@ class Project implements \JsonSerializable
return
$this
->
database
;
}
public
function
getDatasets
()
{
return
$this
->
datasets
;
}
public
function
jsonSerialize
()
{
return
[
...
...
@@ -130,7 +143,8 @@ class Project implements \JsonSerializable
'description'
=>
$this
->
getDescription
(),
'link'
=>
$this
->
getLink
(),
'manager'
=>
$this
->
getManager
(),
'id_database'
=>
$this
->
getDatabase
()
->
getId
()
'id_database'
=>
$this
->
getDatabase
()
->
getId
(),
'nb_datasets'
=>
count
(
$this
->
getDatasets
())
];
}
}
tests/Action/ProjectActionTest.php
View file @
de89156e
...
...
@@ -85,7 +85,7 @@ final class ProjectActionTest extends TestCase
$request
=
$this
->
getRequest
(
'PUT'
)
->
withParsedBody
(
$fields
);
$response
=
(
$this
->
action
)(
$request
,
new
Response
(),
array
(
'name'
=>
'anis_project'
));
$this
->
assertSame
(
json_encode
(
array_merge
([
'name'
=>
'anis_project'
],
$fields
),
JSON_UNESCAPED_SLASHES
),
json_encode
(
array_merge
([
'name'
=>
'anis_project'
],
$fields
,
[
'nb_datasets'
=>
0
]
),
JSON_UNESCAPED_SLASHES
),
(
string
)
$response
->
getBody
()
);
}
...
...
tests/Action/ProjectListActionTest.php
View file @
de89156e
...
...
@@ -71,7 +71,7 @@ final class ProjectListActionTest extends TestCase
public
function
testAddANewProject
():
void
{
$this
->
addDatabase
();
$fields
=
$this
->
getNewProjectFields
();
$fields
=
array_merge
(
$this
->
getNewProjectFields
()
,
[
'nb_datasets'
=>
0
])
;
$request
=
$this
->
getRequest
(
'POST'
)
->
withParsedBody
(
$fields
);
$response
=
(
$this
->
action
)(
$request
,
new
Response
(),
array
());
$this
->
assertSame
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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