Skip to content

Commit

Permalink
[FIX #193] Fix logging of execution in rdf4j repo
Browse files Browse the repository at this point in the history
- add DateUtils to handle conversion of different date classes to java.util.Date.
  • Loading branch information
kostobog committed Aug 17, 2023
1 parent c9d0bba commit 64be8f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cz.cvut.spipes.model.Thing;
import cz.cvut.spipes.model.Transformation;
import cz.cvut.spipes.modules.Module;
import cz.cvut.spipes.util.DateUtils;
import cz.cvut.spipes.util.Rdf4jUtils;
import cz.cvut.spipes.util.TempFileUtils;
import org.apache.jena.rdf.model.Model;
Expand Down Expand Up @@ -182,7 +183,7 @@ private void persistPipelineExecutionFinished(final EntityManager em, final long
em.find(Transformation.class, pipelineExecutionIri, pd);

// new
Date startDate = (Date) getSingletonPropertyValue(pipelineExecution, SPIPES.has_pipeline_execution_start_date);
Date startDate = DateUtils.toDate(getSingletonPropertyValue(pipelineExecution, SPIPES.has_pipeline_execution_start_date));
addProperty(pipelineExecution, SPIPES.has_pipeline_execution_finish_date, finishDate);
addProperty(pipelineExecution, SPIPES.has_pipeline_execution_finish_date_unix, finishDate.getTime());
addProperty(pipelineExecution, SPIPES.has_pipeline_execution_duration, computeDuration(startDate, finishDate));
Expand Down
22 changes: 22 additions & 0 deletions s-pipes-core/src/main/java/cz/cvut/spipes/util/DateUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cz.cvut.spipes.util;

import java.time.OffsetDateTime;
import java.util.Date;
import java.util.Objects;

public class DateUtils {

public static Date toDate(Object objectDate){
Objects.requireNonNull(objectDate);

if(objectDate instanceof OffsetDateTime)
return toDate((OffsetDateTime)objectDate);
return (Date)objectDate;

}

public static Date toDate(OffsetDateTime objectDate) {
Objects.requireNonNull(objectDate);
return Date.from(objectDate.toInstant());
}
}

0 comments on commit 64be8f8

Please sign in to comment.