-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from DiSSCo/feature/opends-0.3.0
Update to openDS 0.3.0
- Loading branch information
Showing
142 changed files
with
1,339 additions
and
2,460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/eu/dissco/core/translator/configuration/DateSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package eu.dissco.core.translator.configuration; | ||
|
||
import static eu.dissco.core.translator.configuration.ApplicationConfiguration.DATE_STRING; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import java.io.IOException; | ||
import java.time.ZoneOffset; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Date; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class DateSerializer extends JsonSerializer<Date> { | ||
|
||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_STRING).withZone( | ||
ZoneOffset.UTC); | ||
|
||
@Override | ||
public void serialize(Date value, JsonGenerator jsonGenerator, | ||
SerializerProvider serializerProvider) { | ||
try { | ||
jsonGenerator.writeString(formatter.format(value.toInstant())); | ||
} catch (IOException e) { | ||
log.error("An error has occurred serializing a date. More information: {}", e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/eu/dissco/core/translator/maven/MavenRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package eu.dissco.core.translator.maven; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.BufferedWriter; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStreamWriter; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
public class MavenRunner { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(MavenRunner.class); | ||
|
||
public static void main(String[] args) { | ||
LOGGER.info("Starting the MavenRunner to download and parse json schemas"); | ||
for (String schemaUrl : args) { | ||
LOGGER.info("Processing json schema: {}", schemaUrl); | ||
var fileName = schemaUrl.substring(schemaUrl.lastIndexOf('/') + 1); | ||
String outputFilePath = "src/main/resources/json-schema/" + fileName; | ||
try { | ||
String schema = downloadSchema(schemaUrl); | ||
saveSchemaToFile(schema, outputFilePath); | ||
LOGGER.info("JSON schema downloaded and saved to: {} ", outputFilePath); | ||
} catch (IOException e) { | ||
LOGGER.error("Error downloading or saving the JSON schema", e); | ||
} | ||
} | ||
} | ||
|
||
private static String downloadSchema(String schemaUrl) throws IOException { | ||
StringBuilder result = new StringBuilder(); | ||
URL url = new URL(schemaUrl); | ||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||
conn.setRequestMethod(RequestMethod.GET.name()); | ||
try (BufferedReader reader = new BufferedReader( | ||
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) { | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
result.append(line).append("\n"); | ||
} | ||
} | ||
return result.toString(); | ||
} | ||
|
||
private static void saveSchemaToFile(String schema, String filePath) throws IOException { | ||
try (BufferedWriter writer = new BufferedWriter( | ||
new OutputStreamWriter(new FileOutputStream(filePath), StandardCharsets.UTF_8))) { | ||
writer.write(schema); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.