Skip to content

Commit

Permalink
Use the interface in the data beans.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Apr 12, 2024
1 parent 580f8e1 commit f39dab0
Show file tree
Hide file tree
Showing 18 changed files with 684 additions and 616 deletions.
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

0 comments on commit f39dab0

Please sign in to comment.