-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to restrict which locales a user can edit
- Loading branch information
Showing
31 changed files
with
654 additions
and
21 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
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
25 changes: 25 additions & 0 deletions
25
restclient/src/main/java/com/box/l10n/mojito/rest/entity/UserLocale.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,25 @@ | ||
package com.box.l10n.mojito.rest.entity; | ||
|
||
import com.fasterxml.jackson.annotation.JsonBackReference; | ||
|
||
public class UserLocale { | ||
@JsonBackReference private User user; | ||
|
||
private Locale locale; | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(User user) { | ||
this.user = user; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
} |
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
66 changes: 66 additions & 0 deletions
66
webapp/src/main/java/com/box/l10n/mojito/entity/security/user/UserLocale.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,66 @@ | ||
package com.box.l10n.mojito.entity.security.user; | ||
|
||
import com.box.l10n.mojito.entity.BaseEntity; | ||
import com.box.l10n.mojito.entity.Locale; | ||
import com.box.l10n.mojito.rest.View; | ||
import com.fasterxml.jackson.annotation.JsonBackReference; | ||
import com.fasterxml.jackson.annotation.JsonView; | ||
import javax.persistence.Entity; | ||
import javax.persistence.ForeignKey; | ||
import javax.persistence.Index; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
import org.hibernate.annotations.BatchSize; | ||
|
||
@Entity | ||
@Table( | ||
name = "user_locale", | ||
indexes = { | ||
@Index( | ||
name = "UK__USER_LOCALE__USER_ID__LOCALE_ID", | ||
columnList = "user_id, locale_id", | ||
unique = true) | ||
}) | ||
@BatchSize(size = 1000) | ||
public class UserLocale extends BaseEntity { | ||
|
||
@ManyToOne | ||
@JsonBackReference | ||
@JoinColumn( | ||
name = "user_id", | ||
foreignKey = @ForeignKey(name = "FK__USER_LOCALE__USER__ID"), | ||
nullable = false) | ||
User user; | ||
|
||
@JsonView(View.LocaleSummary.class) | ||
@ManyToOne | ||
@JoinColumn( | ||
name = "locale_id", | ||
foreignKey = @ForeignKey(name = "FK__USER_LOCALE__LOCALE__ID"), | ||
nullable = false) | ||
Locale locale; | ||
|
||
public UserLocale() {} | ||
|
||
public UserLocale(User user, Locale locale) { | ||
this.user = user; | ||
this.locale = locale; | ||
} | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(User user) { | ||
this.user = user; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
} |
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
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
10 changes: 10 additions & 0 deletions
10
webapp/src/main/java/com/box/l10n/mojito/service/security/user/UserLocaleRepository.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,10 @@ | ||
package com.box.l10n.mojito.service.security.user; | ||
|
||
import com.box.l10n.mojito.entity.security.user.UserLocale; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource(exported = false) | ||
public interface UserLocaleRepository | ||
extends JpaRepository<UserLocale, Long>, JpaSpecificationExecutor<UserLocale> {} |
Oops, something went wrong.