Skip to content

Commit

Permalink
Fix type clashes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Apr 11, 2024
1 parent 6b617e4 commit 094e528
Show file tree
Hide file tree
Showing 21 changed files with 462 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ public class Process extends BaseTemplateBean {
private List<Map<String, Object>> metadata;

@Transient
private int numberOfMetadata;
private Integer numberOfMetadata;

@Transient
private int numberOfImages;
private Integer numberOfImages;

@Transient
private int numberOfStructures;
private Integer numberOfStructures;

@Transient
private String baseType;
Expand Down Expand Up @@ -606,7 +606,7 @@ public int hashCode() {
*
* @return Amount of structure elements
*/
public int getNumberOfStructures() {
public Integer getNumberOfStructures() {
return numberOfStructures;
}

Expand All @@ -615,7 +615,7 @@ public int getNumberOfStructures() {
*
* @return Amount of meta data elements
*/
public int getNumberOfMetadata() {
public Integer getNumberOfMetadata() {
return numberOfMetadata;
}

Expand All @@ -624,7 +624,7 @@ public int getNumberOfMetadata() {
*
* @param numberOfMetadata Integer value of amount of meta data elements
*/
public void setNumberOfMetadata(int numberOfMetadata) {
public void setNumberOfMetadata(Integer numberOfMetadata) {
this.numberOfMetadata = numberOfMetadata;
}

Expand All @@ -633,7 +633,7 @@ public void setNumberOfMetadata(int numberOfMetadata) {
*
* @return Integer value of amount of images
*/
public int getNumberOfImages() {
public Integer getNumberOfImages() {
return numberOfImages;
}

Expand All @@ -642,7 +642,7 @@ public int getNumberOfImages() {
*
* @param numberOfImages Integer value of amount of images
*/
public void setNumberOfImages(int numberOfImages) {
public void setNumberOfImages(Integer numberOfImages) {
this.numberOfImages = numberOfImages;
}

Expand All @@ -651,7 +651,7 @@ public void setNumberOfImages(int numberOfImages) {
*
* @param numberOfStructures Integer value of amount of structure elements
*/
public void setNumberOfStructures(int numberOfStructures) {
public void setNumberOfStructures(Integer numberOfStructures) {
this.numberOfStructures = numberOfStructures;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@

package org.kitodo.data.interfaces;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
* Meta interface over the data interfaces of this interface.
*/
public interface DataInterface {

static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

/**
* Returns the record number of the object in the database. Can be
* {@code null} if the object has not yet been persisted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

package org.kitodo.data.interfaces;

import java.net.URI;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import org.kitodo.data.database.enums.CorrectionComments;

Expand Down Expand Up @@ -346,8 +348,37 @@ public interface ProcessInterface extends DataInterface {
* the application's processes directory on the file system.
*
* @return the union resource identifier of the process
* @deprecated Use {@link #getProcessBaseUri()}.
*/
String getProcessBaseUri();
@Deprecated
default String getProcessBase() {
URI processBaseUri = getProcessBaseUri();
return Objects.isNull(processBaseUri) ? null : processBaseUri.toString();
}

/**
* Returns a process identifier URI. Internally, this is the record number
* of the process in the processes table of the database, but for external
* data it can also be another identifier that resolves to a directory in
* the application's processes directory on the file system.
*
* @return the union resource identifier of the process
*/
URI getProcessBaseUri();

/**
* Sets the union resource identifier of the process. This should only be
* set manually if the data comes from a third party source, otherwise, this
* is the process record number set by the database.
*
* @param processBaseUri
* the identification URI of the process
* @deprecated Use {@link #setProcessBaseUri(URI)}.
*/
@Deprecated
default void setProcessBase(String processBaseUri) {
setProcessBaseUri(Objects.isNull(processBaseUri) ? null : URI.create(processBaseUri));
}

/**
* Sets the union resource identifier of the process. This should only be
Expand All @@ -357,7 +388,7 @@ public interface ProcessInterface extends DataInterface {
* @param processBaseUri
* the identification URI of the process
*/
void setProcessBaseUri(String processBaseUri);
void setProcessBaseUri(URI processBaseUri);

/**
* Returns all batches to which the process belongs. A comma-space-separated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

package org.kitodo.data.interfaces;

import java.util.List;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;
import java.util.List;
import java.util.Objects;

/**
* An interface to manage digitization projects.
Expand Down Expand Up @@ -45,8 +46,23 @@ public interface ProjectInterface extends DataInterface {
* {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}.
*
* @return the start time
* @deprecated Use {@link #getStartDate()}.
*/
@Deprecated
default String getStartTime() {
Date startDate = getStartDate();
return Objects.nonNull(startDate) ? DATE_FORMAT.format(startDate) : null;
}

/**
* Returns the start time of the project. {@link Date} is a specific instant
* in time, with millisecond precision. It is a freely configurable value,
* not the date the project object was created in the database. This can be,
* for example, the start of the funding period.
*
* @return the start time
*/
String getStartDate();
Date getStartDate();

/**
* Sets the start time of the project. The string must be parsable with
Expand All @@ -56,8 +72,20 @@ public interface ProjectInterface extends DataInterface {
* the start time
* @throws ParseException
* if the time cannot be converted
* @deprecated Use {@link #setStartDate(Date)}.
*/
void setStartDate(String startDate);
@Deprecated
default void setStartTime(String startDate) throws ParseException {
setStartDate(Objects.nonNull(startDate) ? DATE_FORMAT.parse(startDate) : null);
}

/**
* Sets the start time of the project.
*
* @param startDate
* the start time
*/
void setStartDate(Date startDate);

/**
* Returns the project end time. The value is a {@link Date} (a specific
Expand All @@ -72,8 +100,39 @@ public interface ProjectInterface extends DataInterface {
* {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}.
*
* @return the end time
* @deprecated Use {@linkplain #getEndDate()}.
*/
String getEndDate();
@Deprecated
default String getEndTime() {
Date endDate = getEndDate();
return Objects.nonNull(endDate) ? DATE_FORMAT.format(endDate) : null;
}

/**
* Returns the project end time. {@link Date} is a specific instant in time,
* with millisecond precision. This is a freely configurable value,
* regardless of when the project was last actually worked on. For example,
* this can be the time at which the project must be completed in order to
* be billed. The timing can be used to monitor that the project is on time.
*
* @return the end time
*/
Date getEndDate();

/**
* Sets the project end time. The string must be parsable with
* {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}.
*
* @param endDate
* the end time
* @throws ParseException
* if the time cannot be converted
* @deprecated Use {@link #setEndDate(Date)}.
*/
@Deprecated
default void setEndTime(String endDate) throws ParseException {
setEndDate(Objects.nonNull(endDate) ? DATE_FORMAT.parse(endDate) : null);
}

/**
* Sets the project end time. The string must be parsable with
Expand All @@ -84,7 +143,7 @@ public interface ProjectInterface extends DataInterface {
* @throws ParseException
* if the time cannot be converted
*/
void setEndDate(String endDate);
void setEndDate(Date endDate);

/**
* Returned the file format for exporting the project's business objects. In
Expand Down Expand Up @@ -121,6 +180,7 @@ default void setFileFormatDmsExport(String fileFormatDmsExport) {
* @deprecated The less suitable formats are no longer supported since
* version 3.
*/
@Deprecated
default String getFileFormatInternal() {
return "";
}
Expand All @@ -132,7 +192,9 @@ default String getFileFormatInternal() {
* unused
* @deprecated Functionless today.
*/
void setFileFormatInternal(String fileFormatInternal);
@Deprecated
default void setFileFormatInternal(String fileFormatInternal) {
}

/**
* Returns the name of the copyright holder of the business objects. These
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**
* An interface to manage process properties. Properties are key-value pairs
Expand Down Expand Up @@ -55,8 +57,36 @@ public interface PropertyInterface extends DataInterface {
* according to {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}.
*
* @return the creation time
* @deprecated Use {@link #getCreationDate()}.
*/
String getCreationDate();
@Deprecated
default String getCreationTime() {
Date creationDate = getCreationDate();
return Objects.nonNull(creationDate) ? DATE_FORMAT.format(creationDate) : null;
}

/**
* Returns the creation time of the property. {@link Date} is a specific
* instant in time, with millisecond precision.
*
* @return the creation time
*/
Date getCreationDate();

/**
* Sets the creation time of the property. The string must be parsable with
* {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}.
*
* @param creationDate
* creation time to set
* @throws ParseException
* if the time cannot be converted
* @deprecated Use {@link #setCreationDate(Date)}.
*/
@Deprecated
default void setCreationTime(String creationDate) throws ParseException {
setCreationDate(Objects.nonNull(creationDate) ? DATE_FORMAT.parse(creationDate) : null);
}

/**
* Sets the creation time of the property. The string must be parsable with
Expand All @@ -67,5 +97,5 @@ public interface PropertyInterface extends DataInterface {
* @throws ParseException
* if the time cannot be converted
*/
void setCreationDate(String creationDate);
void setCreationDate(Date creationDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public interface RoleInterface extends DataInterface {
* Returns how many users hold this role.
*
* @return how many users hold this role
* @deprecated Use {@link #getUsers()}{@code .size()}.
*/
@Deprecated
default Integer getUsersSize() {
List<? extends UserInterface> users = getUsers();
return Objects.nonNull(users) ? users.size() : null;
Expand All @@ -76,7 +78,9 @@ default Integer getUsersSize() {
* when trying to assign this role to unspecified users
* @throws IndexOutOfBoundsException
* for an illegal endpoint index value
* @deprecated {@link #getUsers()} and edit them consciously.
*/
@Deprecated
default void setUsersSize(Integer size) {
int newSize = Objects.nonNull(size) ? size : 0;
List<? extends UserInterface> users = Optional.of(getUsers()).orElse(Collections.emptyList());
Expand Down
Loading

0 comments on commit 094e528

Please sign in to comment.