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

Version 3.1.4 Release #69

Merged
merged 3 commits into from
Dec 7, 2023
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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[markdownlint](https://dlaa.me/markdownlint/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.1.4] - 2023-12-07

### Changed in 3.1.4

- Added `com.senzing.sql.SQLUtilities.UTC_CALENDAR` to provide a reusable `Calendar`
instance for working with UTC timestmaps in SQL databases for JDBC `getTimestamp()`
function.
- Added additional constructors for `MissingDependenciesException`.
- Added new functions to `JsonUtilities`:
- `JsonUtilities.add(JsonObjectBuilder,String,JsonObjectBuilder)`
- `JsonUtilities.add(JsonObjectBuilder,String,JsonArrayBuilder)`
- `JsonUtilities.add(JsonObjectBuilder,String,JsonValue)`
- `JsonUtilities.add(JsonArrayBuilder,JsonObjectBuilder)`
- `JsonUtilities.add(JsonArrayBuilder,JsonArrayBuilder)`
- `JsonUtilities.add(JsonArrayBuilder,JsonValue)`
- Changed `sqlite-jdbc` dependency to version `3.42.0.1` to avoid the problematic
version `3.43.x.x` which carelessly breaks backwards compatibility by removing
functionality that has been supported for sixteen (16) years.
- Updated runtime and build dependencies.

## [3.1.3] - 2023-10-16

### Changed in 3.1.3
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.senzing</groupId>
<artifactId>senzing-commons</artifactId>
<packaging>jar</packaging>
<version>3.1.3</version>
<version>3.1.4</version>
<name>Senzing Commons</name>
<description>Utility classes and functions common to multiple Senzing projects.</description>
<url>http://github.com/Senzing/senzing-commons-java</url>
Expand Down Expand Up @@ -71,13 +71,13 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.43.2.2</version>
<version>3.42.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -107,7 +107,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<configuration>
<systemPropertyVariables>
<project.build.directory>${project.build.directory}</project.build.directory>
Expand Down Expand Up @@ -139,7 +139,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,41 @@ public MissingDependenciesException(CommandLineSource source,
Set<CommandLineOption> specifiedOptions)
{
super(source, option, specifier,
buildErrorMessage(source, option, specifier, specifiedOptions));
buildErrorMessage(source,
option,
option.getDependencies(),
specifier,
specifiedOptions));
}

/**
* Constructs with the specified parameters.
*
* @param source The {@link CommandLineSource} describing how the option
* was specified.
* @param option The {@link CommandLineOption} that was missing required
* parameters.
* @param dependencySets The {@link Set} of {@link CommandLineOption}
* {@link Set} values representing the missing
* dependencies to report.
* @param specifier The command-line flag or environment variable used to
* specify the option, or <code>null</code> if specified as a
* default value.
* @param specifiedOptions The {@link Set} of {@link CommandLineOption}
* instances that were specified.
*/
public MissingDependenciesException(CommandLineSource source,
CommandLineOption option,
Set<Set<CommandLineOption>> dependencySets,
String specifier,
Set<CommandLineOption> specifiedOptions)
{
super(source, option, specifier,
buildErrorMessage(source,
option,
dependencySets,
specifier,
specifiedOptions));
}

/**
Expand All @@ -41,6 +75,9 @@ public MissingDependenciesException(CommandLineSource source,
* was specified.
* @param option The {@link CommandLineOption} that was missing required
* parameters.
* @param dependencySets The {@link Set} of {@link CommandLineOption}
* {@link Set} values representing the missing
* dependencies to report.
* @param specifier The command-line flag or environment variable used to
* specify the option, or <code>null</code> if specified as a
* default value.
Expand All @@ -56,10 +93,11 @@ public MissingDependenciesException(CommandLineSource source,
*/
@SuppressWarnings("unchecked")
public static String buildErrorMessage(
CommandLineSource source,
CommandLineOption option,
String specifier,
Set<CommandLineOption> specifiedOptions)
CommandLineSource source,
CommandLineOption option,
Set<Set<CommandLineOption>> dependencySets,
String specifier,
Set<CommandLineOption> specifiedOptions)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Expand All @@ -71,9 +109,8 @@ public static String buildErrorMessage(
+ " are missing.");
pw.println("The " + sourceDescriptor + " also requires:");

Set<Set<CommandLineOption>> dependencies = option.getDependencies();
String prefix = null;
for (Set<CommandLineOption> dependencySet : dependencies) {
for (Set<CommandLineOption> dependencySet : dependencySets) {
boolean conflicting = false;
// ignore dependency sets that conflict with other specified options
for (CommandLineOption specifiedOption: specifiedOptions) {
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/senzing/sql/SQLUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import java.math.BigDecimal;
import java.sql.*;
import java.util.Calendar;

import java.util.TimeZone;
/**
* Utilities for using the JDBC API to work with SQL databases.
*/
public class SQLUtilities {
/**
* A {@link Calendar} that can be used for retrieving timestamps
* from the database.
*/
public static final Calendar UTC_CALENDAR
= Calendar.getInstance(TimeZone.getTimeZone("UTC"));

/**
* Private constructor.
*/
Expand Down
147 changes: 147 additions & 0 deletions src/main/java/com/senzing/util/JsonUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,84 @@ public static JsonObject getJsonObject(JsonArray arr, int index) {
}
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonObjectBuilder}. If the specified value is <code>null</code> then
* {@link JsonObjectBuilder#addNull(String)} is used, otherwise
* {@link JsonObjectBuilder#add(String,JsonObjectBuilder)} is used.
*
* @param job The {@link JsonObjectBuilder} to add the key/value pair to.
*
* @param key The {@link String} key.
*
* @param val The {@link JsonObjectBuilder} value, or <code>null</code>.
*
* @return The first {@link JsonObjectBuilder} that was specified.
*/
public static JsonObjectBuilder add(JsonObjectBuilder job,
String key,
JsonObjectBuilder val)
{
if (val == null) {
job.addNull(key);
} else {
job.add(key, val);
}
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonObjectBuilder}. If the specified value is <code>null</code> then
* {@link JsonObjectBuilder#addNull(String)} is used, otherwise
* {@link JsonObjectBuilder#add(String,JsonArrayBuilder)} is used.
*
* @param job The {@link JsonObjectBuilder} to add the key/value pair to.
*
* @param key The {@link String} key.
*
* @param val The {@link JsonArrayBuilder} value, or <code>null</code>.
*
* @return The {@link JsonObjectBuilder} that was specified.
*/
public static JsonObjectBuilder add(JsonObjectBuilder job,
String key,
JsonArrayBuilder val)
{
if (val == null) {
job.addNull(key);
} else {
job.add(key, val);
}
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonObjectBuilder}. If the specified value is <code>null</code> then
* {@link JsonObjectBuilder#addNull(String)} is used, otherwise
* {@link JsonObjectBuilder#add(String,JsonValue)} is used.
*
* @param job The {@link JsonObjectBuilder} to add the key/value pair to.
*
* @param key The {@link String} key.
*
* @param val The {@link JsonValue} value, or <code>null</code>.
*
* @return The {@link JsonObjectBuilder} that was specified.
*/
public static JsonObjectBuilder add(JsonObjectBuilder job,
String key,
JsonValue val)
{
if (val == null) {
job.addNull(key);
} else {
job.add(key, val);
}
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonObjectBuilder}. If the specified value is <code>null</code> then
Expand Down Expand Up @@ -1206,6 +1284,75 @@ public static JsonObjectBuilder add(JsonObjectBuilder job, String key, Boolean v
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonArrayBuilder}. If the specified value is <code>null</code> then
* {@link JsonArrayBuilder#addNull()} is used, otherwise
* {@link JsonArrayBuilder#add(JsonObjectBuilder)} is used.
*
* @param job The {@link JsonArrayBuilder} to add the key/value pair to.
*
* @param val The {@link JsonObjectBuilder} value, or <code>null</code>.
*
* @return The {@link JsonArrayBuilder} that was specified.
*/
public static JsonArrayBuilder add(JsonArrayBuilder job,
JsonObjectBuilder val)
{
if (val == null) {
job.addNull();
} else {
job.add(val);
}
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonArrayBuilder}. If the specified value is <code>null</code> then
* {@link JsonArrayBuilder#addNull()} is used, otherwise
* {@link JsonArrayBuilder#add(JsonArrayBuilder)} is used.
*
* @param job The {@link JsonArrayBuilder} to add the key/value pair to.
*
* @param val The {@link JsonArrayBuilder} value, or <code>null</code>.
*
* @return The first {@link JsonArrayBuilder} that was specified.
*/
public static JsonArrayBuilder add(JsonArrayBuilder job,
JsonArrayBuilder val)
{
if (val == null) {
job.addNull();
} else {
job.add(val);
}
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonArrayBuilder}. If the specified value is <code>null</code> then
* {@link JsonArrayBuilder#addNull()} is used, otherwise
* {@link JsonArrayBuilder#add(JsonValue)} is used.
*
* @param job The {@link JsonArrayBuilder} to add the key/value pair to.
*
* @param val The {@link JsonValue} value, or <code>null</code>.
*
* @return The {@link JsonArrayBuilder} that was specified.
*/
public static JsonArrayBuilder add(JsonArrayBuilder job,
JsonValue val)
{
if (val == null) {
job.addNull();
} else {
job.add(val);
}
return job;
}

/**
* Adds the specified key/value pair to the specified {@link
* JsonArrayBuilder}. If the specified value is <code>null</code> then
Expand Down