TSK-1090 Refactored AttachmentImpl

This commit is contained in:
Sofie Hofmann 2020-02-07 12:40:21 +01:00
parent 2924eda82e
commit 1ecb613526
3 changed files with 40 additions and 192 deletions

View File

@ -6,56 +6,7 @@ import java.util.Map;
import pro.taskana.classification.api.ClassificationSummary;
/** Attachment-Interface to specify Attachment Attributes. */
public interface Attachment {
/**
* Returns the current id of the attachment.
*
* @return ID of attachment
*/
String getId();
/**
* Returns the id of the associated task.
*
* @return taskId
*/
String getTaskId();
/**
* Returns the time when the attachment was created.
*
* @return the created time as {@link Instant}
*/
Instant getCreated();
/**
* Returns the time when the attachment was last modified.
*
* @return modified {@link Instant} of the attachment
*/
Instant getModified();
/**
* Returns the classification summary of the attachment.
*
* @return the {@link ClassificationSummary} of this attachment
*/
ClassificationSummary getClassificationSummary();
/**
* Set the classification summary for this attachment.
*
* @param classificationSummary the {@link ClassificationSummary} for this attachment
*/
void setClassificationSummary(ClassificationSummary classificationSummary);
/**
* Returns the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @return {@link ObjectReference primaryObjectReference} of the attachment
*/
ObjectReference getObjectReference();
public interface Attachment extends AttachmentSummary {
/**
* Sets the {@link ObjectReference primaryObjectReference} of the attachment.
@ -65,25 +16,11 @@ public interface Attachment {
void setObjectReference(ObjectReference objectReference);
/**
* Returns the Channel on which the attachment was received.
* Set the classification summary for this attachment.
*
* @return the Channel on which the attachment was received.
* @param classificationSummary the {@link ClassificationSummary} for this attachment
*/
String getChannel();
/**
* Sets the Channel on which the attachment was received.
*
* @param channel the channel on which the attachment was received
*/
void setChannel(String channel);
/**
* Returns the time when this attachment was received.
*
* @return received time as exact {@link Instant}
*/
Instant getReceived();
void setClassificationSummary(ClassificationSummary classificationSummary);
/**
* Sets the time when the attachment was received.
@ -92,6 +29,13 @@ public interface Attachment {
*/
void setReceived(Instant received);
/**
* Sets the Channel on which the attachment was received.
*
* @param channel the channel on which the attachment was received
*/
void setChannel(String channel);
/**
* Returns the custom attributes of this attachment.
*

View File

@ -1,111 +1,23 @@
package pro.taskana.task.internal;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import pro.taskana.classification.api.ClassificationSummary;
import pro.taskana.classification.internal.ClassificationSummaryImpl;
import pro.taskana.task.api.Attachment;
import pro.taskana.task.api.AttachmentSummary;
import pro.taskana.task.api.ObjectReference;
/**
* Attachment entity.
*
* @author bbr
*/
public class AttachmentImpl implements Attachment {
public class AttachmentImpl extends AttachmentSummaryImpl implements Attachment {
private String id;
private String taskId;
private Instant created;
private Instant modified;
private ClassificationSummary classificationSummary;
private ObjectReference objectReference;
private String channel;
private Instant received;
private Map<String, String> customAttributes = new HashMap<String, String>();
private Map<String, String> customAttributes = new HashMap<>();
public AttachmentImpl() {}
@Override
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
@Override
public Instant getCreated() {
return created;
}
public void setCreated(Instant created) {
this.created = created;
}
@Override
public Instant getModified() {
return modified;
}
public void setModified(Instant modified) {
this.modified = modified;
}
@Override
public ClassificationSummary getClassificationSummary() {
return classificationSummary;
}
@Override
public void setClassificationSummary(ClassificationSummary classificationSummary) {
this.classificationSummary = classificationSummary;
}
@Override
public ObjectReference getObjectReference() {
return objectReference;
}
@Override
public void setObjectReference(ObjectReference objectReference) {
this.objectReference = objectReference;
}
@Override
public String getChannel() {
return channel;
}
@Override
public void setChannel(String channel) {
this.channel = channel;
}
@Override
public Instant getReceived() {
return received;
}
@Override
public void setReceived(Instant received) {
this.received = received;
}
@Override
public Map<String, String> getCustomAttributes() {
if (customAttributes == null) {
@ -133,28 +45,13 @@ public class AttachmentImpl implements Attachment {
return summary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
this.classificationSummary = classificationSummary;
protected boolean canEqual(Object other) {
return (!(other instanceof AttachmentImpl));
}
@Override
public int hashCode() {
return Objects.hash(
id,
taskId,
created,
modified,
classificationSummary,
objectReference,
channel,
received,
customAttributes);
return Objects.hash(super.hashCode(), customAttributes);
}
@Override
@ -165,16 +62,14 @@ public class AttachmentImpl implements Attachment {
if (!(obj instanceof AttachmentImpl)) {
return false;
}
if (!super.equals(obj)) {
return false;
}
AttachmentImpl other = (AttachmentImpl) obj;
return Objects.equals(id, other.id)
&& Objects.equals(taskId, other.taskId)
&& Objects.equals(created, other.created)
&& Objects.equals(modified, other.modified)
&& Objects.equals(classificationSummary, other.classificationSummary)
&& Objects.equals(objectReference, other.objectReference)
&& Objects.equals(channel, other.channel)
&& Objects.equals(received, other.received)
&& Objects.equals(customAttributes, other.customAttributes);
if (other.canEqual(this)) {
return false;
}
return Objects.equals(customAttributes, other.customAttributes);
}
@Override

View File

@ -11,14 +11,14 @@ import pro.taskana.task.api.ObjectReference;
/** The most important fields of the Attachment entity. */
public class AttachmentSummaryImpl implements AttachmentSummary {
private String id;
private String taskId;
private Instant created;
private Instant modified;
private ClassificationSummary classificationSummary;
private ObjectReference objectReference;
private String channel;
private Instant received;
protected String id;
protected String taskId;
protected Instant created;
protected Instant modified;
protected ClassificationSummary classificationSummary;
protected ObjectReference objectReference;
protected String channel;
protected Instant received;
AttachmentSummaryImpl() {}
@ -127,15 +127,21 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
}
// auxiliary method to enable MyBatis access to classificationSummary
@SuppressWarnings("unused")
public ClassificationSummaryImpl getClassificationSummaryImpl() {
return (ClassificationSummaryImpl) classificationSummary;
}
// auxiliary method to enable MyBatis access to classificationSummary
@SuppressWarnings("unused")
public void setClassificationSummaryImpl(ClassificationSummaryImpl classificationSummary) {
this.classificationSummary = classificationSummary;
}
protected boolean canEqual(Object other) {
return (!(other instanceof AttachmentSummaryImpl));
}
@Override
public int hashCode() {
return Objects.hash(
@ -151,6 +157,9 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
return false;
}
AttachmentSummaryImpl other = (AttachmentSummaryImpl) obj;
if (other.canEqual(this)) {
return false;
}
return Objects.equals(id, other.id)
&& Objects.equals(taskId, other.taskId)
&& Objects.equals(created, other.created)