mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
Fix bean editor issues.
This commit is contained in:
parent
426b02af5a
commit
a4c7cc6cd5
@ -17,7 +17,7 @@ public class NumericPropertyEditContext extends PropertyEditContext {
|
||||
|
||||
public NumericPropertyEditContext(Serializable bean, String propertyName) {
|
||||
super(bean, propertyName);
|
||||
Integer propertyValue = (Integer) getPropertyValue();
|
||||
Serializable propertyValue = getPropertyValue();
|
||||
if (propertyValue != null)
|
||||
inputModel = new Model<String>(propertyValue.toString());
|
||||
else
|
||||
@ -45,10 +45,15 @@ public class NumericPropertyEditContext extends PropertyEditContext {
|
||||
@Override
|
||||
protected void doValidation() {
|
||||
String input = inputModel.getObject();
|
||||
Integer convertedInput;
|
||||
|
||||
Serializable convertedInput;
|
||||
|
||||
try {
|
||||
if (input != null) {
|
||||
convertedInput = Integer.valueOf(input);
|
||||
if (getPropertyGetter().getReturnType() == int.class || getPropertyGetter().getReturnType() == Integer.class)
|
||||
convertedInput = Integer.valueOf(input);
|
||||
else
|
||||
convertedInput = Long.valueOf(input);
|
||||
} else {
|
||||
convertedInput = null;
|
||||
}
|
||||
|
||||
@ -4,7 +4,10 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public abstract class AbstractGateKeeper implements GateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class AlwaysAccept extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -3,11 +3,16 @@ package com.pmease.gitop.core.gatekeeper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.util.trimmable.AndOrConstruct;
|
||||
import com.pmease.commons.util.trimmable.TrimUtils;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable(name="All sub gate keepers accept")
|
||||
public class AndGateKeeper extends AbstractGateKeeper {
|
||||
|
||||
private List<GateKeeper> gateKeepers = new ArrayList<GateKeeper>();
|
||||
@ -16,6 +21,9 @@ public class AndGateKeeper extends AbstractGateKeeper {
|
||||
this.gateKeepers = gateKeepers;
|
||||
}
|
||||
|
||||
@Editable(name="Sub Gate Keepers")
|
||||
@NotNull
|
||||
@Size(min=1, message="At least one element has to be added.")
|
||||
public List<GateKeeper> getGateKeepers() {
|
||||
return gateKeepers;
|
||||
}
|
||||
|
||||
@ -2,11 +2,13 @@ package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.User;
|
||||
import com.pmease.gitop.core.permission.operation.RepositoryOperation;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class ApprovedByAuthorizedUsers extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class ApprovedByMajoritiesOfSpecifiedTeam extends TeamAwareGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.util.EasySet;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.User;
|
||||
import com.pmease.gitop.core.model.Vote;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class ApprovedByRepositoryOwner extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -5,17 +5,20 @@ import java.util.HashSet;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.TeamMembership;
|
||||
import com.pmease.gitop.core.model.User;
|
||||
import com.pmease.gitop.core.model.Vote;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class ApprovedBySpecifiedTeam extends TeamAwareGateKeeper {
|
||||
|
||||
private int leastApprovals = 1;
|
||||
|
||||
@Min(1)
|
||||
|
||||
@Editable
|
||||
@Min(value=1, message="Least approvals should not be less than 1.")
|
||||
public int getLeastApprovals() {
|
||||
return leastApprovals;
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.loader.AppLoader;
|
||||
import com.pmease.commons.util.EasySet;
|
||||
import com.pmease.gitop.core.manager.UserManager;
|
||||
@ -8,10 +11,13 @@ import com.pmease.gitop.core.model.User;
|
||||
import com.pmease.gitop.core.model.Vote;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class ApprovedBySpecifiedUser extends AbstractGateKeeper {
|
||||
|
||||
private Long userId;
|
||||
|
||||
@Editable
|
||||
@NotNull
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@ -2,9 +2,11 @@ package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.util.trimmable.Trimmable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@Editable
|
||||
public interface GateKeeper extends Trimmable, Serializable {
|
||||
|
||||
CheckResult check(MergeRequest request);
|
||||
|
||||
@ -5,19 +5,22 @@ import java.util.HashSet;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.TeamMembership;
|
||||
import com.pmease.gitop.core.model.User;
|
||||
import com.pmease.gitop.core.model.Vote;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class GetMinScoreFromSpecifiedTeam extends TeamAwareGateKeeper {
|
||||
|
||||
private int minScore = 1;
|
||||
|
||||
private boolean requireVoteOfAllMembers;
|
||||
|
||||
@Min(1)
|
||||
@Editable
|
||||
@Min(value=1, message="Min score should not be less than 1.")
|
||||
public int getMinScore() {
|
||||
return minScore;
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class HasSourceBranch extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -2,15 +2,18 @@ package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class IfThenGateKeeper extends AbstractGateKeeper {
|
||||
|
||||
private GateKeeper ifGate;
|
||||
|
||||
private GateKeeper thenGate;
|
||||
|
||||
@Editable
|
||||
@NotNull
|
||||
public GateKeeper getIfGate() {
|
||||
return ifGate;
|
||||
@ -20,6 +23,7 @@ public class IfThenGateKeeper extends AbstractGateKeeper {
|
||||
this.ifGate = ifGate;
|
||||
}
|
||||
|
||||
@Editable
|
||||
@NotNull
|
||||
public GateKeeper getThenGate() {
|
||||
return thenGate;
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class IsFastForward extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class NeverAccept extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.TeamMembership;
|
||||
import com.pmease.gitop.core.model.Vote;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class NoRejectionBySpecifiedTeam extends TeamAwareGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class NotGateKeeper extends AbstractGateKeeper {
|
||||
|
||||
private GateKeeper gateKeeper;
|
||||
|
||||
@Editable
|
||||
@NotNull
|
||||
public GateKeeper getGateKeeper() {
|
||||
return gateKeeper;
|
||||
}
|
||||
|
||||
@ -3,16 +3,24 @@ package com.pmease.gitop.core.gatekeeper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.util.trimmable.AndOrConstruct;
|
||||
import com.pmease.commons.util.trimmable.TrimUtils;
|
||||
import com.pmease.commons.util.trimmable.Trimmable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable(name="Any sub gate keeper accepts")
|
||||
public class OrGateKeeper extends AbstractGateKeeper {
|
||||
|
||||
private List<GateKeeper> gateKeepers = new ArrayList<GateKeeper>();
|
||||
|
||||
|
||||
@Editable(name="Sub Gate Keepers")
|
||||
@NotNull
|
||||
@Size(min=1, message="At least one element has to be added.")
|
||||
public List<GateKeeper> getGateKeepers() {
|
||||
return gateKeepers;
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.loader.AppLoader;
|
||||
import com.pmease.commons.util.namedentity.EntityLoader;
|
||||
import com.pmease.commons.util.namedentity.EntityMatcher;
|
||||
@ -12,10 +15,13 @@ import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.Repository;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class SubmittedToSpecifiedBranch extends AbstractGateKeeper {
|
||||
|
||||
private String branchPatterns;
|
||||
|
||||
@Editable
|
||||
@NotNull
|
||||
public String getBranchPatterns() {
|
||||
return branchPatterns;
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.model.MergeRequest;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class SubmittedViaPush extends AbstractGateKeeper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.pmease.gitop.core.gatekeeper;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.gitop.core.Gitop;
|
||||
import com.pmease.gitop.core.manager.TeamManager;
|
||||
import com.pmease.gitop.core.model.Team;
|
||||
@ -9,6 +12,8 @@ public abstract class TeamAwareGateKeeper extends AbstractGateKeeper {
|
||||
|
||||
private Long teamId;
|
||||
|
||||
@Editable
|
||||
@NotNull
|
||||
public Long getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.Collection;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.git.FindChangedFilesCommand;
|
||||
import com.pmease.commons.git.Git;
|
||||
import com.pmease.commons.loader.AppLoader;
|
||||
@ -14,10 +15,12 @@ import com.pmease.gitop.core.model.MergeRequest;
|
||||
import com.pmease.gitop.core.model.MergeRequestUpdate;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class TouchSpecifiedFiles extends AbstractGateKeeper {
|
||||
|
||||
private String filePaths;
|
||||
|
||||
@Editable
|
||||
@NotEmpty
|
||||
public String getFilePaths() {
|
||||
return filePaths;
|
||||
|
||||
@ -13,6 +13,7 @@ import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import com.pmease.commons.editable.annotation.Editable;
|
||||
import com.pmease.commons.hibernate.AbstractEntity;
|
||||
import com.pmease.gitop.core.Gitop;
|
||||
import com.pmease.gitop.core.gatekeeper.GateKeeper;
|
||||
@ -27,6 +28,7 @@ import com.pmease.gitop.core.permission.operation.RepositoryOperation;
|
||||
@UniqueConstraint(columnNames={"owner", "name"})
|
||||
})
|
||||
@SuppressWarnings("serial")
|
||||
@Editable
|
||||
public class Repository extends AbstractEntity implements UserBelonging {
|
||||
|
||||
@ManyToOne
|
||||
@ -61,6 +63,7 @@ public class Repository extends AbstractEntity implements UserBelonging {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Editable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -69,6 +72,7 @@ public class Repository extends AbstractEntity implements UserBelonging {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Editable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
@ -77,6 +81,7 @@ public class Repository extends AbstractEntity implements UserBelonging {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Editable
|
||||
public boolean isPubliclyAccessible() {
|
||||
return publiclyAccessible;
|
||||
}
|
||||
@ -94,9 +99,8 @@ public class Repository extends AbstractEntity implements UserBelonging {
|
||||
this.defaultAuthorizedOperation = defaultAuthorizedOperation;
|
||||
}
|
||||
|
||||
@Editable
|
||||
public GateKeeper getGateKeeper() {
|
||||
if (gateKeeper != null)
|
||||
gateKeeper = (GateKeeper) gateKeeper.trim(this);
|
||||
return gateKeeper;
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
<wicket:extend>
|
||||
<h1>Welcome Home!</h1>
|
||||
<div style="padding:100px;">
|
||||
<form wicket:id="form">
|
||||
<div wicket:id="editor"></div>
|
||||
<input type="submit" value="Submit" class="btn btn-primary"></input>
|
||||
</form>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
@ -1,11 +1,38 @@
|
||||
package com.pmease.gitop.web;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
|
||||
import com.pmease.commons.editable.EditContext;
|
||||
import com.pmease.commons.wicket.editable.EditHelper;
|
||||
import com.pmease.gitop.core.model.Repository;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class HomePage extends BasePage {
|
||||
|
||||
private static Repository repository = new Repository();
|
||||
|
||||
@Override
|
||||
protected void onInitialize() {
|
||||
super.onInitialize();
|
||||
|
||||
final Repository cloned = SerializationUtils.clone(repository);
|
||||
final EditContext editContext = EditHelper.getContext(cloned);
|
||||
|
||||
Form<?> form = new Form<Void>("form") {
|
||||
|
||||
@Override
|
||||
protected void onSubmit() {
|
||||
super.onSubmit();
|
||||
editContext.validate();
|
||||
if (!editContext.hasError(true))
|
||||
repository = cloned;
|
||||
}
|
||||
|
||||
};
|
||||
form.add(EditHelper.renderForEdit(editContext, "editor"));
|
||||
|
||||
add(form);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user