Skip to content

Commit beff346

Browse files
author
pcampalani
committed
Merge branch 'feature/stac_results'
2 parents f3d1d22 + 6b99766 commit beff346

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4189
-1534
lines changed

.classpath

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,16 @@
3636
</attributes>
3737
</classpathentry>
3838
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
39+
<classpathentry kind="src" path=".apt_generated">
40+
<attributes>
41+
<attribute name="optional" value="true"/>
42+
</attributes>
43+
</classpathentry>
44+
<classpathentry kind="src" output="target/test-classes" path=".apt_generated_tests">
45+
<attributes>
46+
<attribute name="optional" value="true"/>
47+
<attribute name="test" value="true"/>
48+
</attributes>
49+
</classpathentry>
3950
<classpathentry kind="output" path="target/classes"/>
4051
</classpath>

src/main/java/org/openeo/spring/api/CollectionsApiController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.openeo.spring.loaders.STACFileCollectionsLoader;
4242
import org.openeo.spring.loaders.WCSCollectionsLoader;
4343
import org.openeo.spring.model.Asset;
44+
import org.openeo.spring.model.AssetType;
4445
import org.openeo.spring.model.BatchJobResult;
4546
import org.openeo.spring.model.Collection;
4647
import org.openeo.spring.model.Collections;
@@ -654,7 +655,7 @@ else if (headerValue.contains(TIFF)) {
654655
process.setProcessGraph(loadSaveProcessGraph);
655656

656657
Job job = new Job();
657-
BatchJobResult jobResult = new BatchJobResult();
658+
BatchJobResult jobResult = BatchJobResult.ofType(AssetType.FEATURE);
658659
job.setProcess(process);
659660
job.setTitle(String.format("OGC-Coverage-%s-%s", fileFormat, OffsetDateTime.now()));
660661
ResponseEntity<?> response = jobsApiController.createJob(job, principal);

src/main/java/org/openeo/spring/api/JobsApiController.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.net.ssl.SSLSession;
3535
import javax.net.ssl.TrustManagerFactory;
3636
import javax.swing.event.EventListenerList;
37+
import javax.transaction.Transactional;
3738
import javax.validation.Valid;
3839
import javax.validation.constraints.Min;
3940
import javax.validation.constraints.Pattern;
@@ -48,7 +49,9 @@
4849
import org.openeo.spring.bearer.ITokenService;
4950
import org.openeo.spring.bearer.TokenUtil;
5051
import org.openeo.spring.components.JobScheduler;
52+
import org.openeo.spring.dao.BatchJobResultCollectionDAO;
5153
import org.openeo.spring.dao.BatchJobResultDAO;
54+
import org.openeo.spring.dao.BatchJobResultFeatureDAO;
5255
import org.openeo.spring.dao.JobDAO;
5356
import org.openeo.spring.keycloak.legacy.AuthzService;
5457
import org.openeo.spring.model.BatchJobEstimate;
@@ -159,18 +162,22 @@ public class JobsApiController implements JobsApi {
159162

160163
JobDAO jobDAO;
161164

162-
BatchJobResultDAO resultDAO;
165+
BatchJobResultDAO<? extends BatchJobResult> resultDAO;
163166

164167
@Autowired
165-
public void setDao(JobDAO injectedJObDAO, BatchJobResultDAO injectResultDao) {
166-
jobDAO = injectedJObDAO;
167-
resultDAO = injectResultDao;
168+
public void setDaoFeature(JobDAO injectedJObDAO, BatchJobResultFeatureDAO injectResultDao) {
169+
jobDAO = injectedJObDAO;
170+
resultDAO = injectResultDao;
168171
}
169-
172+
@Autowired
173+
public void setDaoCollection(JobDAO injectedJObDAO, BatchJobResultCollectionDAO injectResultDao) {
174+
jobDAO = injectedJObDAO;
175+
resultDAO = injectResultDao;
176+
}
177+
170178
@org.springframework.beans.factory.annotation.Autowired
171179
public JobsApiController(NativeWebRequest request) {
172180
this.request = request;
173-
174181
}
175182

176183
@PostConstruct
@@ -236,7 +243,9 @@ public ResponseEntity<?> createJob(@Parameter(description = "", required = true)
236243

237244
//TODO add validity check of the job using ValidationApiController
238245
// UUID jobID = UUID.randomUUID();
239-
// job.setId(jobID);
246+
// job.setId(jobID.toString());
247+
// job.setId("06959adcd2a447c58c74374993a3eee9"); TEST
248+
// -> Job::@Generated will generate one
240249

241250
ResponseEntity<?> response = null;
242251
String warningMessage = null;
@@ -668,7 +677,7 @@ public ResponseEntity<?> deleteJob(
668677
@Pattern(regexp = "^[\\w\\-\\.~]+$") @Parameter(description = "Unique job identifier.", required = true) @PathVariable("job_id") String jobId) {
669678
Job job = jobDAO.findOne(UUID.fromString(jobId));
670679
if (job != null) {
671-
BatchJobResult jobResult = resultDAO.findOne(UUID.fromString(jobId));
680+
BatchJobResult jobResult = resultDAO.findOne(jobId);
672681
if(jobResult != null) {
673682
log.debug("The job result {} was detected.", jobId);
674683
File jobResults = new File(tmpDir + jobId);
@@ -681,7 +690,7 @@ public ResponseEntity<?> deleteJob(
681690
jobResults.delete();
682691
log.debug("All persistent files have been successfully deleted for job with id: " + jobId);
683692
}
684-
resultDAO.delete(jobResult);
693+
resultDAO.deleteById(jobResult.getId());
685694
log.debug("The job result {} was successfully deleted.", jobId);
686695
}
687696
jobDAO.delete(job);
@@ -956,15 +965,16 @@ public ResponseEntity<?> listJobs(
956965
@ApiResponse(responseCode = "500", description = "The request can't be fulfilled due to an error at the back-end. The error is never the client’s fault and therefore it is reasonable for the client to retry the exact same request that triggered this response. The response body SHOULD contain a JSON error object. MUST be any HTTP status code specified in [RFC 7231](https://tools.ietf.org/html/rfc7231#section-6.6). See also: * [Error Handling](#section/API-Principles/Error-Handling) in the API in general. * [Common Error Codes](errors.json)") })
957966
@RequestMapping(value = "/jobs/{job_id}/results", produces = { "application/json",
958967
"application/geo+json" }, method = RequestMethod.GET)
968+
@Transactional
959969
public ResponseEntity<?> listResults(
960970
@Pattern(regexp = "^[\\w\\-\\.~]+$") @Parameter(description = "Unique job identifier.", required = true) @PathVariable("job_id") String jobId) {
961-
BatchJobResult result = resultDAO.findOne(UUID.fromString(jobId));
971+
BatchJobResult result = resultDAO.findOne(jobId);
962972
if (result != null) {
963-
log.trace(result.toString());
973+
log.debug(result.toString());
964974
return new ResponseEntity<BatchJobResult>(result, HttpStatus.OK);
965975
} else {
966976
ResponseEntity<Error> response = ApiUtil.errorResponse(HttpStatus.BAD_REQUEST,
967-
String.format("The requested job %s could not be found.", jobId));
977+
String.format("The result for job %s could not be found.", jobId));
968978
return response;
969979
}
970980
}
@@ -1149,7 +1159,8 @@ public ResponseEntity<?> startJob(
11491159
public ResponseEntity<?> stopJob(
11501160
@Pattern(regexp = "^[\\w\\-\\.~]+$") @Parameter(description = "Unique job identifier.", required = true) @PathVariable("job_id") String jobId) {
11511161
ThreadContext.put("jobid", jobId);
1152-
Job job = jobDAO.findOne(UUID.fromString(jobId));
1162+
UUID jobUUID = UUID.fromString(jobId);
1163+
Job job = jobDAO.findOne(jobUUID);
11531164
if (job != null) {
11541165
if(job.getEngine()==EngineTypes.WCPS){
11551166
ResponseEntity<Error> response = ApiUtil.errorResponse(HttpStatus.NOT_IMPLEMENTED,
@@ -1162,15 +1173,15 @@ else if(job.getEngine()==EngineTypes.ODC_DASK) {
11621173
job.setStatus(JobStates.CANCELED);
11631174
job.setUpdated(OffsetDateTime.now());
11641175
jobDAO.update(job);
1165-
this.fireJobStoppedEvent(job.getId());
1176+
this.fireJobStoppedEvent(jobUUID);
11661177
ThreadContext.clearMap();
11671178
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
11681179
}
11691180
else if(job.getStatus()==JobStates.QUEUED) {
11701181
job.setStatus(JobStates.CREATED);
11711182
job.setUpdated(OffsetDateTime.now());
11721183
jobDAO.update(job);
1173-
this.fireJobStoppedEvent(job.getId());
1184+
this.fireJobStoppedEvent(jobUUID);
11741185
ThreadContext.clearMap();
11751186
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
11761187
}

0 commit comments

Comments
 (0)