Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

138 remove jodatime from cube module #140

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.rdf.model.StmtIterator;
import org.apache.jena.vocabulary.RDF;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import zone.cogni.asquare.applicationprofile.model.basic.ApplicationProfile;
Expand All @@ -33,6 +30,9 @@
import zone.cogni.libs.jena.utils.JenaUtils;

import javax.annotation.Nonnull;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -214,7 +214,7 @@ private void processContext(Context context, Model model) {
}

private void reportMissedSubjects(Context context, String root) {
Set<Resource> missedSubjects = context.subjectTypeMap.keySet();
Set<Resource> missedSubjects = new HashSet<>(context.subjectTypeMap.keySet());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: fixes a "counting" bug. this is only logged if reporting of missing data is enabled!

missedSubjects.removeAll(context.alreadyProcessedResources);

if (missedSubjects.size() > 1) {
Expand Down Expand Up @@ -717,19 +717,18 @@ private void addToJsonAsSingle(ObjectNode jsonNode, String attribute, JsonNode v
}

private String literalToDate(Literal literal) {
return date2string(ISODateTimeFormat.dateTimeParser().parseDateTime(literal.getLexicalForm()));
}

private String date2string(DateTime date) {
return date == null ? null : date.toString(ISODateTimeFormat.date());
return LocalDate.parse(literal.getLexicalForm()).toString();
}

/**
* Tested on formats like 2016-01-01T00:00:00Z , 2021-02-11T08:19:21.489344Z and 2022-08-08T08:08:08.888+02:00
*
* @param literal dateTime literal
* @return dateTime string as is but after format validation
*/
private String literalToDateTime(Literal literal) {
natan-cox-cognizone marked this conversation as resolved.
Show resolved Hide resolved
return dateTime2string(ISODateTimeFormat.dateTimeParser().parseDateTime(literal.getLexicalForm()));
}

private String dateTime2string(DateTime dateTime) {
return dateTime == null ? null : dateTime.withZone(DateTimeZone.UTC).toString(ISODateTimeFormat.dateTime());
ZonedDateTime zonedDateTime = ZonedDateTime.parse(literal.getLexicalForm());
return zonedDateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
}

private TextNode getTextNode(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -64,13 +63,13 @@ public static ConversionProfile read(InputStreamSource resource) {
* simple classId lookup
*/
@JsonIgnore
private final Map<String, Type> classIdTypeMap = new HashMap<>();
private final Map<String, Type> classIdTypeMap = new TreeMap<>();

/**
* expanded classId lookup
*/
@JsonIgnore
private final Map<String, Type> expandedClassIdTypeMap = new HashMap<>();
private final Map<String, Type> expandedClassIdTypeMap = new TreeMap<>();


/**
Expand All @@ -84,10 +83,10 @@ public static ConversionProfile read(InputStreamSource resource) {
private final List<Collection<Type>> typesByLevel = new ArrayList<>();

@JsonIgnore
private final Map<String, Type> rdfTypeTypeMap = new HashMap<>();
private final Map<String, Type> rdfTypeTypeMap = new TreeMap<>();

@JsonIgnore
private final Map<String, Type> expandedRdfTypeTypeMap = new HashMap<>();
private final Map<String, Type> expandedRdfTypeTypeMap = new TreeMap<>();

public Context getContext() {
Objects.requireNonNull(context, "context cannot be null");
Expand Down Expand Up @@ -301,10 +300,10 @@ public static class Type {
* all attributes
*/
@JsonIgnore
private final Map<String, Attribute> attributeIdMap = new HashMap<>();
private final Map<String, Attribute> attributeIdMap = new TreeMap<>();

@JsonIgnore
private final Map<String, Attribute> attributeUriMap = new HashMap<>();
private final Map<String, Attribute> attributeUriMap = new TreeMap<>();

public String getRootClassId() {
return rootClassId;
Expand Down