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

[hibernate search] Introduce a common interface for DTO objects and data beans #6032

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
177c25b
Introduce an interface for the DTO objects
matthias-ronge Apr 10, 2024
6b617e4
Use 'extends' in interface lists
matthias-ronge Apr 11, 2024
094e528
Fix type clashes
matthias-ronge Apr 11, 2024
59b47a8
Move image binary getter out of DTO object
matthias-ronge Apr 11, 2024
580f8e1
Fix more type clashes
matthias-ronge Apr 11, 2024
f39dab0
Use the interface in the data beans.
matthias-ronge Apr 12, 2024
d2a4bd1
Fix checkstyle
matthias-ronge Apr 12, 2024
c5cbf18
No longer use SimpleDateFormat from a constant
matthias-ronge Apr 12, 2024
5c00c6e
Fix Exception 'null' when retrieving int value for key numberOfImages
matthias-ronge Apr 15, 2024
e6dc1a5
Undo unnecessary changes
matthias-ronge Apr 15, 2024
35e29c0
Rename active templates property accordingly
matthias-ronge Apr 17, 2024
645277a
Fix enum comparison
matthias-ronge Apr 19, 2024
e793f1e
Fix LazyInitializationException
matthias-ronge Apr 23, 2024
9fccf2c
Fix several occurrences of PropertyNotWritableException
matthias-ronge Apr 23, 2024
f42fa94
Fix Javadoc
matthias-ronge Apr 23, 2024
22e8263
Fix displayed wrong task's processing begin
matthias-ronge Apr 23, 2024
bff6815
No longer import PropertyNotWritableException
matthias-ronge May 21, 2024
2cc1890
Remove an unused import
matthias-ronge May 21, 2024
797f7a4
Use apache.commons.lang3.StringUtils instead of log4j.util.Strings
matthias-ronge May 21, 2024
77ba25a
Use is(Not)Blank instead of is(Not)Empty
matthias-ronge May 21, 2024
14dbdc8
No longer use '...Interface' as part of variable names
matthias-ronge May 21, 2024
290b4c5
Improve reason messages in tests
matthias-ronge May 21, 2024
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 @@ -1206,8 +1206,8 @@ private ComplexMetadataViewInterface getCmvi(
List<MetadataViewWithValuesInterface> metadataViewWithValuesInterfaceList, String keyId) {
return (ComplexMetadataViewInterface) metadataViewWithValuesInterfaceList.stream()
.filter(mvwvi -> mvwvi.getMetadata().isPresent())
.filter(metadataViewWithValuesInterface -> keyId
.equals(metadataViewWithValuesInterface.getMetadata().get().getId()))
.filter(metadataViewWithValues -> keyId
.equals(metadataViewWithValues.getMetadata().get().getId()))
.findAny().get().getMetadata().get();
}

Expand Down Expand Up @@ -1235,8 +1235,8 @@ private List<String> ids(Collection<MetadataViewInterface> mviColl) {
*/
private List<String> ids(List<MetadataViewWithValuesInterface> metadataViewWithValuesInterfaceList) {
return metadataViewWithValuesInterfaceList.stream()
.filter(metadataViewWithValuesInterface -> metadataViewWithValuesInterface.getMetadata().isPresent())
.map(metadataViewWithValuesInterface -> metadataViewWithValuesInterface.getMetadata().get().getId())
.filter(metadataViewWithValues -> metadataViewWithValues.getMetadata().isPresent())
.map(metadataViewWithValues -> metadataViewWithValues.getMetadata().get().getId())
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,25 @@

import org.hibernate.Hibernate;
import org.kitodo.data.database.persistence.BaseDAO;
import org.kitodo.data.interfaces.DataInterface;

/**
* Base bean class.
*/
@MappedSuperclass
public abstract class BaseBean implements Serializable {
public abstract class BaseBean implements DataInterface, Serializable {

@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Integer id;

@Override
public Integer getId() {
return id;
}

@Override
public void setId(Integer id) {
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import org.kitodo.data.database.enums.BatchType;
import org.kitodo.data.database.persistence.BatchDAO;
import org.kitodo.data.interfaces.BatchInterface;
import org.kitodo.data.interfaces.ProcessInterface;

/**
* A user-definable, unordered collection of processes whose batch-type tasks
Expand All @@ -39,7 +41,7 @@
*/
@Entity
@Table(name = "batch")
public class Batch extends BaseIndexedBean {
public class Batch extends BaseIndexedBean implements BatchInterface {

/**
* The batch title. Using titles for batches is optional, the field may be
Expand Down Expand Up @@ -105,22 +107,12 @@ public Batch(String title, Collection<? extends Process> processes) {
this.processes = new ArrayList<>(processes);
}

/**
* Returns the batch title. Using titles for batches is optional, the field
* may be {@code null}. If so, the function returns null.
*
* @return the batch title
*/
@Override
public String getTitle() {
return title;
}

/**
* Sets a batch title.
*
* @param title
* title of the batch
*/
@Override
public void setTitle(String title) {
this.title = title;
}
Expand All @@ -134,11 +126,7 @@ public BatchType getType() {
return type;
}

/**
* Return the processes that belong to the batch.
*
* @return the processes of the batch
*/
@Override
public List<Process> getProcesses() {
initialize(new BatchDAO(), this.processes);
if (Objects.isNull(this.processes)) {
Expand All @@ -147,18 +135,14 @@ public List<Process> getProcesses() {
return this.processes;
}

/**
* Sets the processes that belong to the batch.
*
* @param processes
* processes of the batch
*/
public void setProcesses(List<Process> processes) {
@Override
@SuppressWarnings("unchecked")
public void setProcesses(List<? extends ProcessInterface> processes) {
if (this.processes == null) {
this.processes = processes;
this.processes = (List<Process>) processes;
} else {
this.processes.clear();
this.processes.addAll(processes);
this.processes.addAll((List<? extends Process>) processes);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.kitodo.data.database.persistence.ClientDAO;
import org.kitodo.data.interfaces.ClientInterface;
import org.kitodo.data.interfaces.ProjectInterface;
import org.kitodo.data.interfaces.UserInterface;

@Entity
@Table(name = "client")
public class Client extends BaseBean {
public class Client extends BaseBean implements ClientInterface {

@Column(name = "name")
private String name;
Expand All @@ -40,21 +44,18 @@ public class Client extends BaseBean {
foreignKey = @ForeignKey(name = "FK_column_id"))})
private List<ListColumn> listColumns;

/**
* Gets name.
*
* @return The name.
*/
@ManyToMany(mappedBy = "clients", cascade = CascadeType.PERSIST)
private List<User> users;

@OneToMany(mappedBy = "client", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Project> projects;

@Override
public String getName() {
return name;
}

/**
* Sets name.
*
* @param name
* The name.
*/
@Override
public void setName(String name) {
this.name = name;
}
Expand Down Expand Up @@ -99,4 +100,26 @@ public List<ListColumn> getListColumns() {
public void setListColumns(List<ListColumn> columns) {
this.listColumns = columns;
}

@Override
public List<User> getUsers() {
return users;
}

@Override
@SuppressWarnings("unchecked")
public void setUsers(List<? extends UserInterface> users) {
this.users = (List<User>) users;
}

@Override
public List<Project> getProjects() {
return projects;
}

@Override
@SuppressWarnings("unchecked")
public void setProjects(List<? extends ProjectInterface> projects) {
this.projects = (List<Project>) projects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.kitodo.data.interfaces.ClientInterface;
import org.kitodo.data.interfaces.DocketInterface;

@Entity
@Table(name = "docket")
public class Docket extends BaseIndexedBean {
public class Docket extends BaseIndexedBean implements DocketInterface {

@Column(name = "title")
private String title;
Expand All @@ -37,18 +40,22 @@ public class Docket extends BaseIndexedBean {
@JoinColumn(name = "client_id", foreignKey = @ForeignKey(name = "FK_docket_client_id"))
private Client client;

@Override
public String getTitle() {
return title;
}

@Override
public void setTitle(String title) {
this.title = title;
}

@Override
public String getFile() {
return file;
}

@Override
public void setFile(String file) {
this.file = file;
}
Expand All @@ -74,23 +81,14 @@ public void setActive(boolean active) {
this.active = active;
}

/**
* Get client.
*
* @return Client object
*/
@Override
public Client getClient() {
return this.client;
}

/**
* Set client.
*
* @param client
* as Client object
*/
public void setClient(Client client) {
this.client = client;
@Override
public void setClient(ClientInterface client) {
this.client = (Client) client;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.kitodo.data.interfaces.FilterInterface;

/**
* Filter bean.
*/
@Entity
@Table(name = "filter")
public class Filter extends BaseIndexedBean {
public class Filter extends BaseIndexedBean implements FilterInterface {

@Column(name = "value", columnDefinition = "longtext")
private String value;
Expand All @@ -38,21 +40,12 @@ public class Filter extends BaseIndexedBean {
@JoinColumn(name = "user_id", foreignKey = @ForeignKey(name = "FK_filter_user_id"))
private User user;

/**
* Get filter value.
*
* @return filter value
*/
@Override
public String getValue() {
return value;
}

/**
* Set filter value.
*
* @param value
* filter
*/
@Override
public void setValue(String value) {
this.value = value;
}
Expand Down
Loading