introduce attribute free to pac definition

This commit is contained in:
Peter Hormanns 2013-04-25 13:57:01 +02:00
parent a4afbedeaa
commit 25058b9701
6 changed files with 36 additions and 35 deletions

View File

@ -411,8 +411,7 @@ CREATE TABLE packet (
hive_id integer NOT NULL,
created date NOT NULL,
cancelled date,
order_number character varying(20),
webserver_group character varying(10),
free boolean NOT NULL,
cur_inet_addr_id integer,
old_inet_addr_id integer,
CONSTRAINT ckt_packet CHECK (((cancelled IS NULL) OR (cancelled > created)))

View File

@ -62,7 +62,7 @@ public class ReflectionUtil {
clasz.getMethod(setterName(f), String.class).invoke(entity, valueObject);
} else
if (type.equals(Date.class)) {
clasz.getMethod(setterName(f), Date.class).invoke(entity, TextUtil.parse((String) valueObject));
clasz.getMethod(setterName(f), Date.class).invoke(entity, TextUtil.parseDate((String) valueObject));
} else
if (type.getCanonicalName().equals("long")) {
clasz.getMethod(setterName(f), long.class).invoke(entity, Long.parseLong((String) valueObject));

View File

@ -53,7 +53,7 @@ public class TextUtil {
return df.format(date);
}
public static synchronized Date parse(String dateString) {
public static synchronized Date parseDate(String dateString) {
try {
return df.parse(dateString);
} catch (ParseException e) {
@ -66,4 +66,13 @@ public class TextUtil {
}
}
public static synchronized String format(boolean free) {
return free ? "true" : "false";
}
public static synchronized boolean parseBool(String boolString) {
boolean parsedValue = "T".equals(boolString.toUpperCase()) || "TRUE".equals(boolString.toUpperCase());
return parsedValue;
}
}

View File

@ -68,11 +68,8 @@ public class Pac extends AbstractEntity implements Serializable {
@Temporal(TemporalType.DATE)
private Date cancelled;
@Column(name = "order_number", nullable = true)
private String orderNo;
@Column(name = "webserver_group", nullable = true)
private String webserverGroup;
@Column(name = "free", nullable = false)
private boolean free = false;
@JoinColumn(name = "cur_inet_addr_id", nullable = true)
@ManyToOne(fetch = EAGER)
@ -101,9 +98,7 @@ public class Pac extends AbstractEntity implements Serializable {
this.name = name;
this.customer = cust;
this.hive = hive;
this.created = new Date();
this.webserverGroup = "httpd";
this.curINetAddr = hive.getInetAddr();
initPacComponents(basePac);
}
@ -191,22 +186,6 @@ public class Pac extends AbstractEntity implements Serializable {
this.cancelled = cancelled;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getwebserverGroup() {
return webserverGroup;
}
public void setwebserverGroup(String webserverGroup) {
this.webserverGroup = webserverGroup;
}
public INetAddress getCurINetAddr() {
return curINetAddr;
}
@ -306,4 +285,12 @@ public class Pac extends AbstractEntity implements Serializable {
// pac of packet admin
"obj.name=:loginUserName";
}
public boolean isFree() {
return free;
}
public void setFree(boolean free) {
this.free = free;
}
}

View File

@ -100,11 +100,11 @@ public class CustomerRemote extends AbstractRemote {
}
String memberSince = (String) setParams.get("membersince");
if (assertNotNull(memberSince)) {
cust.setMemberSince(TextUtil.parse(memberSince));
cust.setMemberSince(TextUtil.parseDate(memberSince));
}
String memberUntil = (String) setParams.get("memberuntil");
if (assertNotNull(memberUntil)) {
cust.setMemberUntil(TextUtil.parse(memberUntil));
cust.setMemberUntil(TextUtil.parseDate(memberUntil));
}
String memberRole = (String) setParams.get("memberrole");
if (assertNotNull(memberRole)) {
@ -112,15 +112,15 @@ public class CustomerRemote extends AbstractRemote {
}
String authorContract = (String) setParams.get("authorcontract");
if (assertNotNull(authorContract)) {
cust.setAuthorContract(TextUtil.parse(authorContract));
cust.setAuthorContract(TextUtil.parseDate(authorContract));
}
String nonDiscContract = (String) setParams.get("nondisccontract");
if (assertNotNull(nonDiscContract)) {
cust.setNonDiscContract(TextUtil.parse(nonDiscContract));
cust.setNonDiscContract(TextUtil.parseDate(nonDiscContract));
}
String sharesUpdated = (String) setParams.get("sharesupdated");
if (assertNotNull(sharesUpdated)) {
cust.setSharesUpdated(TextUtil.parse(sharesUpdated));
cust.setSharesUpdated(TextUtil.parseDate(sharesUpdated));
}
String sharesSigned = (String) setParams.get("sharessigned");
if (assertNotNull(sharesSigned)) {

View File

@ -25,6 +25,7 @@ public class PacRemote extends AbstractRemote {
resultMap.put("customer", pac.getCustomer().getName());
resultMap.put("curinetaddr", pac.getCurINetAddr().getInetAddr());
resultMap.put("created", TextUtil.format(pac.getCreated()));
resultMap.put("free", TextUtil.format(pac.isFree()));
Date cancelled = pac.getCancelled();
if (cancelled != null) {
resultMap.put("cancelled", TextUtil.format(cancelled));
@ -58,14 +59,19 @@ public class PacRemote extends AbstractRemote {
}
String createdStr = (String) setParams.get("created");
if (createdStr != null && !createdStr.isEmpty()) {
Date createdDate = TextUtil.parse(createdStr);
Date createdDate = TextUtil.parseDate(createdStr);
pac.setCreated(createdDate);
}
String cancelledStr = (String) setParams.get("cancelled");
if (cancelledStr != null && !cancelledStr.isEmpty()) {
Date cancelledDate = TextUtil.parse(cancelledStr);
Date cancelledDate = TextUtil.parseDate(cancelledStr);
pac.setCancelled(cancelledDate);
}
String isFreeString = (String) setParams.get("free");
if (isFreeString != null && !isFreeString.isEmpty()) {
boolean isFree = TextUtil.parseBool(isFreeString);
pac.setFree(isFree);
}
INetAddress curINetAddr = pac.getCurINetAddr();
String inetAddrString = (String) setParams.get("curinetaddr");
if ((curINetAddr == null || curINetAddr.getInetAddr() == null) && assertNotNull(inetAddrString)) {