[FIX] variable access

This commit is contained in:
Edouard DUPIN 2024-12-31 10:40:50 +01:00
parent 01560cd285
commit 5f682da13e

View File

@ -35,7 +35,7 @@ public class TestResource {
@GET @GET
@PermitAll @PermitAll
public List<SimpleArchiveTable> gets() throws Exception { public List<SimpleArchiveTable> gets() throws Exception {
return this.data; return TestResource.data;
} }
@GET @GET
@ -43,7 +43,7 @@ public class TestResource {
@PermitAll @PermitAll
public SimpleArchiveTable get(@PathParam("id") final Long id) throws Exception { public SimpleArchiveTable get(@PathParam("id") final Long id) throws Exception {
LOGGER.info("get({})", id); LOGGER.info("get({})", id);
for (final SimpleArchiveTable elem : this.data) { for (final SimpleArchiveTable elem : TestResource.data) {
if (elem.id.equals(id)) { if (elem.id.equals(id)) {
return elem; return elem;
} }
@ -56,8 +56,9 @@ public class TestResource {
@PermitAll @PermitAll
public SimpleArchiveTable archive(@PathParam("id") final Long id) throws Exception { public SimpleArchiveTable archive(@PathParam("id") final Long id) throws Exception {
LOGGER.info("archive({})", id); LOGGER.info("archive({})", id);
for (final SimpleArchiveTable elem : this.data) { for (final SimpleArchiveTable elem : TestResource.data) {
if (elem.id.equals(id)) { if (elem.id.equals(id)) {
elem.updatedAt = new Date();
elem.archive = new Date(); elem.archive = new Date();
return elem; return elem;
} }
@ -70,8 +71,9 @@ public class TestResource {
@PermitAll @PermitAll
public SimpleArchiveTable restore(@PathParam("id") final Long id) throws Exception { public SimpleArchiveTable restore(@PathParam("id") final Long id) throws Exception {
LOGGER.info("restore({})", id); LOGGER.info("restore({})", id);
for (final SimpleArchiveTable elem : this.data) { for (final SimpleArchiveTable elem : TestResource.data) {
if (elem.id.equals(id)) { if (elem.id.equals(id)) {
elem.updatedAt = new Date();
elem.archive = null; elem.archive = null;
return elem; return elem;
} }
@ -84,8 +86,10 @@ public class TestResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public SimpleArchiveTable post(final SimpleArchiveTable data) throws Exception { public SimpleArchiveTable post(final SimpleArchiveTable data) throws Exception {
LOGGER.info("post(...)"); LOGGER.info("post(...)");
data.id = this.uniqueId; data.id = TestResource.uniqueId;
this.uniqueId += 5; TestResource.uniqueId += 5;
data.updatedAt = new Date();
data.createdAt = new Date();
this.data.add(data); this.data.add(data);
return data; return data;
} }
@ -115,7 +119,7 @@ public class TestResource {
@PermitAll @PermitAll
public void remove(@PathParam("id") final Long id) throws Exception { public void remove(@PathParam("id") final Long id) throws Exception {
LOGGER.info("remove({})", id); LOGGER.info("remove({})", id);
this.data.removeIf(e -> e.id.equals(id)); TestResource.data.removeIf(e -> e.id.equals(id));
} }
} }