Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Use files from commit 6afeb23 to fix merge errors, then reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Oct 1, 2013
1 parent 34c5b84 commit 96a52f0
Show file tree
Hide file tree
Showing 33 changed files with 1,832 additions and 1,867 deletions.
17 changes: 8 additions & 9 deletions zanata-model/src/main/java/org/zanata/model/AccountKeyBase.java
Expand Up @@ -38,14 +38,13 @@
@Setter
@Getter
@Access(AccessType.FIELD)
public class AccountKeyBase
{
@NotEmpty
@Size(min = 32, max = 32)
@Id
private String keyHash;
public class AccountKeyBase {
@NotEmpty
@Size(min = 32, max = 32)
@Id
private String keyHash;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "accountId")
private HAccount account;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "accountId")
private HAccount account;
}
115 changes: 59 additions & 56 deletions zanata-model/src/main/java/org/zanata/model/HAccount.java
Expand Up @@ -77,60 +77,63 @@
@Getter
@Access(AccessType.FIELD)
@ToString(callSuper = true, of = "username")
@EqualsAndHashCode(callSuper = true, of = {"enabled", "passwordHash", "username", "apiKey"})
public class HAccount extends ModelEntityBase implements Serializable
{
private static final long serialVersionUID = 1L;

@NaturalId
@UserPrincipal
@Field()
private String username;

@UserPassword(hash = PasswordHash.ALGORITHM_MD5)
private String passwordHash;

@UserEnabled
private boolean enabled;

@UserApiKey
@Size(min = 32, max = 32)
private String apiKey;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(mappedBy = "account", cascade = CascadeType.ALL)
private HPerson person;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@UserRoles
@ManyToMany(targetEntity = HAccountRole.class)
@JoinTable(name = "HAccountMembership", joinColumns = @JoinColumn(name = "accountId"), inverseJoinColumns = @JoinColumn(name = "memberOf"))
private Set<HAccountRole> roles = Sets.newHashSet();

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, mappedBy = "account")
private HAccountActivationKey accountActivationKey;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, mappedBy = "account")
private HAccountResetPasswordKey accountResetPasswordKey;

@OneToMany(mappedBy = "account", cascade = {CascadeType.ALL})
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Set<HCredentials> credentials = Sets.newHashSet();

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mergedInto")
private HAccount mergedInto;

@OneToMany(mappedBy = "account", cascade = {CascadeType.ALL})
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@MapKey(name = "name")
private Map<String, HAccountOption> editorOptions = Maps.newHashMap();

@Transient
public boolean isPersonAccount()
{
return person != null;
}
@EqualsAndHashCode(callSuper = true, of = { "enabled", "passwordHash",
"username", "apiKey" })
public class HAccount extends ModelEntityBase implements Serializable {
private static final long serialVersionUID = 1L;

@NaturalId
@UserPrincipal
@Field()
private String username;

@UserPassword(hash = PasswordHash.ALGORITHM_MD5)
private String passwordHash;

@UserEnabled
private boolean enabled;

@UserApiKey
@Size(min = 32, max = 32)
private String apiKey;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(mappedBy = "account", cascade = CascadeType.ALL)
private HPerson person;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@UserRoles
@ManyToMany(targetEntity = HAccountRole.class)
@JoinTable(name = "HAccountMembership", joinColumns = @JoinColumn(
name = "accountId"), inverseJoinColumns = @JoinColumn(
name = "memberOf"))
private Set<HAccountRole> roles = Sets.newHashSet();

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY,
mappedBy = "account")
private HAccountActivationKey accountActivationKey;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY,
mappedBy = "account")
private HAccountResetPasswordKey accountResetPasswordKey;

@OneToMany(mappedBy = "account", cascade = { CascadeType.ALL })
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Set<HCredentials> credentials = Sets.newHashSet();

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mergedInto")
private HAccount mergedInto;

@OneToMany(mappedBy = "account", cascade = { CascadeType.ALL })
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@MapKey(name = "name")
private Map<String, HAccountOption> editorOptions = Maps.newHashMap();

@Transient
public boolean isPersonAccount() {
return person != null;
}
}
Expand Up @@ -42,19 +42,18 @@
@Access(AccessType.FIELD)
@ToString
@NoArgsConstructor
public class HAccountActivationKey extends AccountKeyBase implements Serializable
{
private static final long serialVersionUID = 1L;
public class HAccountActivationKey extends AccountKeyBase implements
Serializable {
private static final long serialVersionUID = 1L;

@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
private Date creationDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
private Date creationDate;

@SuppressWarnings("unused")
@PrePersist
private void onPersist()
{
creationDate = new Date();
}
@SuppressWarnings("unused")
@PrePersist
private void onPersist() {
creationDate = new Date();
}

}
17 changes: 6 additions & 11 deletions zanata-model/src/main/java/org/zanata/model/HAccountOption.java
Expand Up @@ -49,25 +49,20 @@ public class HAccountOption extends ModelEntityBase {

private String value;

@ManyToOne(optional = false)
@JoinColumn(name = "account_id")
private HAccount account;
@ManyToOne(optional = false)
@JoinColumn(name = "account_id")
private HAccount account;

public HAccountOption(String name, String value) {
this.name = name;
this.value = value;
}

public String getName() {
return name;
@Transient
public Boolean getValueAsBoolean() {
return Boolean.parseBoolean(getValue());
}

@Transient
public Boolean getValueAsBoolean()
{
return Boolean.parseBoolean(getValue());
}

@Transient
public Integer getValueAsInt() {
return Integer.parseInt(getValue());
Expand Down
56 changes: 26 additions & 30 deletions zanata-model/src/main/java/org/zanata/model/HAccountRole.java
Expand Up @@ -50,44 +50,40 @@
@Getter
@Access(AccessType.FIELD)
@TypeDef(name = "roleType", typeClass = RoleTypeType.class)
public class HAccountRole implements Serializable
{
private static final long serialVersionUID = 9177366120789064801L;
public class HAccountRole implements Serializable {
private static final long serialVersionUID = 9177366120789064801L;

@Id
@GeneratedValue
private Integer id;
@Id
@GeneratedValue
private Integer id;

// TODO PERF @NaturalId(mutable=false) for better criteria caching
@RoleName
private String name;
// TODO PERF @NaturalId(mutable=false) for better criteria caching
@RoleName
private String name;

@RoleConditional
private boolean conditional;
@RoleConditional
private boolean conditional;

@Type(type = "roleType")
@NotNull
private RoleType roleType = RoleType.MANUAL;
@Type(type = "roleType")
@NotNull
private RoleType roleType = RoleType.MANUAL;

@RoleGroups
@ManyToMany(targetEntity = HAccountRole.class)
@JoinTable(name = "HAccountRoleGroup", joinColumns = @JoinColumn(name = "roleId"), inverseJoinColumns = @JoinColumn(name = "memberOf"))
private Set<HAccountRole> groups = Sets.newHashSet();
@RoleGroups
@ManyToMany(targetEntity = HAccountRole.class)
@JoinTable(name = "HAccountRoleGroup", joinColumns = @JoinColumn(
name = "roleId"), inverseJoinColumns = @JoinColumn(
name = "memberOf"))
private Set<HAccountRole> groups = Sets.newHashSet();

public enum RoleType
{
AUTO,
MANUAL;
public enum RoleType {
AUTO, MANUAL;

public char getInitial()
{
return name().charAt(0);
}
public char getInitial() {
return name().charAt(0);
}

public static RoleType valueOf(char initial)
{
switch (initial)
{
public static RoleType valueOf(char initial) {
switch (initial) {
case 'A':
return AUTO;
case 'M':
Expand Down
Expand Up @@ -58,15 +58,15 @@ public class HApplicationConfiguration extends ModelEntityBase {
public static String KEY_PIWIK_IDSITE = "piwik.idSite";
private static final long serialVersionUID = 8652817113098817448L;

// TODO PERF @NaturalId(mutable=false) for better criteria caching
@NaturalId
@NotEmpty
@Size(max = 255)
@Column(name = "config_key", nullable = false)
private String key;
// TODO PERF @NaturalId(mutable=false) for better criteria caching
@NaturalId
@NotEmpty
@Size(max = 255)
@Column(name = "config_key", nullable = false)
private String key;

@NotNull
@Type(type = "text")
@Column(name = "config_value", nullable = false)
private String value;
@NotNull
@Type(type = "text")
@Column(name = "config_value", nullable = false)
private String value;
}
29 changes: 16 additions & 13 deletions zanata-model/src/main/java/org/zanata/model/HCopyTransOptions.java
Expand Up @@ -87,20 +87,23 @@ public static ConditionRuleAction valueOf(char initial) {
case 'I':
return IGNORE;
default:
throw new IllegalArgumentException(String.valueOf(initial));
}
}
}
throw new IllegalArgumentException(String.valueOf(initial));
}
}
}

@Type(type = "conditionRuleAction")
@NotNull
private ConditionRuleAction contextMismatchAction = ConditionRuleAction.REJECT;
@Type(type = "conditionRuleAction")
@NotNull
private ConditionRuleAction contextMismatchAction =
ConditionRuleAction.REJECT;

@Type(type = "conditionRuleAction")
@NotNull
private ConditionRuleAction docIdMismatchAction = ConditionRuleAction.REJECT;
@Type(type = "conditionRuleAction")
@NotNull
private ConditionRuleAction docIdMismatchAction =
ConditionRuleAction.REJECT;

@Type(type = "conditionRuleAction")
@NotNull
private ConditionRuleAction projectMismatchAction = ConditionRuleAction.REJECT;
@Type(type = "conditionRuleAction")
@NotNull
private ConditionRuleAction projectMismatchAction =
ConditionRuleAction.REJECT;
}

0 comments on commit 96a52f0

Please sign in to comment.