com.clickntap.stripecubeui.webapp.bo.Operator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stripecubeui Show documentation
Show all versions of stripecubeui Show documentation
Css / Javascript Merger and Minimizer integrated with Stripecube Web App Development
The newest version!
package com.clickntap.stripecubeui.webapp.bo;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.clickntap.hub.BO;
public class Operator extends BO {
private String displayName;
private String defaultTab;
private Number readOnly;
private String userCode;
private Number browserId;
private Number trusted;
private Number admin;
public Boolean isAdmin() {
return getAdmin() != null && getAdmin().intValue() == 1;
}
public Number getAdmin() {
return admin;
}
public void setAdmin(Number admin) {
this.admin = admin;
}
public Boolean isTrusted() {
return getTrusted() != null && getTrusted().intValue() == 1;
}
public Number getTrusted() {
return trusted;
}
public void setTrusted(Number trusted) {
this.trusted = trusted;
}
public Number getBrowserId() {
return browserId;
}
public void setBrowserId(Number browserId) {
this.browserId = browserId;
}
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public Operator() {
super();
}
public Operator(HttpServletRequest request) throws Exception {
super(request);
}
public void checkUser() throws Exception {
if (getId() != null && getId().intValue() != 0) {
CustomOperator operator = getApp().getBO(CustomOperator.class, getId());
if (operator == null) {
setId(null);
} else {
setUserCode(operator.getUserCode());
}
}
if (getId() == null || getId().intValue() == 0) {
do {
setUserCode(createUserCode());
} while (existsUserCode());
create();
}
}
private static String createUserCode() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 3; i++) {
char d = (char) ('A' + (Math.random() * ((int) 'Z' - (int) 'A')));
int n = (int) (Math.random() * (8)) + 2;
sb.append(d).append(n);
}
return sb.toString();
}
private boolean existsUserCode() throws Exception {
if (getUserCode().contains("O") || getUserCode().contains("I")) {
return true;
}
CustomOperator operator = new CustomOperator();
operator.setApp(getApp());
operator.setUserCode(getUserCode());
operator.read("userCode");
return operator.getId() != null;
}
private Number domainId;
public Number getDomainId() {
return domainId;
}
public void setDomainId(Number domainId) {
this.domainId = domainId;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public List getMediaFiles() throws Exception {
return getApp().getBOListByFilter(CustomMediaFile.class, this, "mediaFiles");
}
public String getDefaultTab() {
return defaultTab;
}
public void setDefaultTab(String defaultTab) {
this.defaultTab = defaultTab;
}
public Number getReadOnly() {
return readOnly;
}
public void setReadOnly(Number readOnly) {
this.readOnly = readOnly;
}
}