Skip to content
Snippets Groups Projects

Iss #69 - Fixed issue where validation messages could be lost

Merged Iss #69 - Fixed issue where validation messages could be lost
Merged Martin Lowe requested to merge (removed):malowe/master/69 into master
4 files
+ 86
21
Compare changes
  • Side-by-side
  • Inline
Files
4
package org.eclipsefoundation.git.eca.dto;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.persistence.Entity;
@@ -27,7 +31,7 @@ public class CommitValidationMessage extends BareNode {
public static final DtoTable TABLE = new DtoTable(CommitValidationMessage.class, "cvm");
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private CommitValidationStatus commit;
@@ -120,6 +124,47 @@ public class CommitValidationMessage extends BareNode {
this.authorEmail = authorEmail;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(authorEmail, commit, eclipseId, id, providerId, statusCode);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
CommitValidationMessage other = (CommitValidationMessage) obj;
return Objects.equals(authorEmail, other.authorEmail) && Objects.equals(commit, other.commit)
&& Objects.equals(eclipseId, other.eclipseId) && Objects.equals(id, other.id)
&& Objects.equals(providerId, other.providerId) && statusCode == other.statusCode;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("CommitValidationMessage [id=");
builder.append(id);
builder.append(", commit=");
builder.append(commit.getCommitHash());
builder.append(", statusCode=");
builder.append(statusCode);
builder.append(", eclipseId=");
builder.append(eclipseId);
builder.append(", authorEmail=");
builder.append(authorEmail);
builder.append(", providerId=");
builder.append(providerId);
builder.append("]");
return builder.toString();
}
@Singleton
public static class CommitValidationMessageFilter implements DtoFilter<CommitValidationMessage> {
@Inject
@@ -141,6 +186,13 @@ public class CommitValidationMessage extends BareNode {
stmt.addClause(new ParameterizedSQLStatement.Clause(TABLE.getAlias() + ".commitId = ?",
new Object[] { Integer.valueOf(commitId) }));
}
// ids check
List<String> ids = params.get(DefaultUrlParameterNames.IDS.getName());
if (ids != null && !ids.isEmpty()) {
stmt.addClause(new ParameterizedSQLStatement.Clause(TABLE.getAlias() + ".id IN ?",
new Object[] { ids.stream().filter(StringUtils::isNumeric).map(Long::valueOf)
.collect(Collectors.toList()) }));
}
}
return stmt;
}
Loading