-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* invite attributes stubbed * updated OrganizationModel with getInvitation(id). added get method for invite by id. * working tests for attributes. added attributes to ftl context. * added test for multiple valued attributes * no wildcard imports * adding #158 for resending emails * clean up and set the inviterUrl * fixed test
- Loading branch information
Showing
16 changed files
with
466 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/io/phasetwo/service/model/WithAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.phasetwo.service.model; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
public interface WithAttributes { | ||
Map<String, List<String>> getAttributes(); | ||
|
||
default Stream<String> getAttributesStream(String name) { | ||
List<String> attrs = getAttributes().get(name); | ||
if (attrs != null && attrs.size() > 0) { | ||
return attrs.stream(); | ||
} else { | ||
return Stream.empty(); | ||
} | ||
} | ||
|
||
default String getFirstAttribute(String name) { | ||
List<String> attrs = getAttributes().get(name); | ||
if (attrs != null && attrs.size() > 0) { | ||
return attrs.get(0); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
void removeAttributes(); | ||
|
||
void removeAttribute(String name); | ||
|
||
void setAttribute(String name, List<String> values); | ||
|
||
default void setSingleAttribute(String name, String value) { | ||
setAttribute(name, ImmutableList.of(value)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/main/java/io/phasetwo/service/model/jpa/entity/InvitationAttributeEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package io.phasetwo.service.model.jpa.entity; | ||
|
||
import jakarta.persistence.Access; | ||
import jakarta.persistence.AccessType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.persistence.UniqueConstraint; | ||
import java.util.Objects; | ||
import org.hibernate.annotations.Nationalized; | ||
|
||
/** */ | ||
@Table( | ||
name = "INVITATION_ATTRIBUTE", | ||
uniqueConstraints = {@UniqueConstraint(columnNames = {"INVITATION_ID", "NAME"})}) | ||
@Entity | ||
public class InvitationAttributeEntity { | ||
|
||
@Id | ||
@Column(name = "ID", length = 36) | ||
@Access( | ||
AccessType.PROPERTY) // we do this because relationships often fetch id, but not entity. This | ||
// avoids an extra SQL | ||
protected String id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "INVITATION_ID") | ||
protected InvitationEntity invitation; | ||
|
||
@Column(name = "NAME") | ||
protected String name; | ||
|
||
@Nationalized | ||
@Column(name = "VALUE") | ||
protected String value; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
public InvitationEntity getInvitation() { | ||
return invitation; | ||
} | ||
|
||
public void setInvitation(InvitationEntity invitation) { | ||
this.invitation = invitation; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null) return false; | ||
if (!(o instanceof InvitationAttributeEntity)) return false; | ||
|
||
InvitationAttributeEntity key = (InvitationAttributeEntity) o; | ||
|
||
if (!name.equals(key.name)) return false; | ||
if (!invitation.equals(key.invitation)) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(invitation, name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.