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, hive_id integer NOT NULL,
created date NOT NULL, created date NOT NULL,
cancelled date, cancelled date,
order_number character varying(20), free boolean NOT NULL,
webserver_group character varying(10),
cur_inet_addr_id integer, cur_inet_addr_id integer,
old_inet_addr_id integer, old_inet_addr_id integer,
CONSTRAINT ckt_packet CHECK (((cancelled IS NULL) OR (cancelled > created))) 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); clasz.getMethod(setterName(f), String.class).invoke(entity, valueObject);
} else } else
if (type.equals(Date.class)) { 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 } else
if (type.getCanonicalName().equals("long")) { if (type.getCanonicalName().equals("long")) {
clasz.getMethod(setterName(f), long.class).invoke(entity, Long.parseLong((String) valueObject)); 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); return df.format(date);
} }
public static synchronized Date parse(String dateString) { public static synchronized Date parseDate(String dateString) {
try { try {
return df.parse(dateString); return df.parse(dateString);
} catch (ParseException e) { } 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,12 +68,9 @@ public class Pac extends AbstractEntity implements Serializable {
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
private Date cancelled; private Date cancelled;
@Column(name = "order_number", nullable = true) @Column(name = "free", nullable = false)
private String orderNo; private boolean free = false;
@Column(name = "webserver_group", nullable = true)
private String webserverGroup;
@JoinColumn(name = "cur_inet_addr_id", nullable = true) @JoinColumn(name = "cur_inet_addr_id", nullable = true)
@ManyToOne(fetch = EAGER) @ManyToOne(fetch = EAGER)
private INetAddress curINetAddr; private INetAddress curINetAddr;
@ -101,9 +98,7 @@ public class Pac extends AbstractEntity implements Serializable {
this.name = name; this.name = name;
this.customer = cust; this.customer = cust;
this.hive = hive; this.hive = hive;
this.created = new Date(); this.created = new Date();
this.webserverGroup = "httpd";
this.curINetAddr = hive.getInetAddr(); this.curINetAddr = hive.getInetAddr();
initPacComponents(basePac); initPacComponents(basePac);
} }
@ -191,22 +186,6 @@ public class Pac extends AbstractEntity implements Serializable {
this.cancelled = cancelled; 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() { public INetAddress getCurINetAddr() {
return curINetAddr; return curINetAddr;
} }
@ -306,4 +285,12 @@ public class Pac extends AbstractEntity implements Serializable {
// pac of packet admin // pac of packet admin
"obj.name=:loginUserName"; "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"); String memberSince = (String) setParams.get("membersince");
if (assertNotNull(memberSince)) { if (assertNotNull(memberSince)) {
cust.setMemberSince(TextUtil.parse(memberSince)); cust.setMemberSince(TextUtil.parseDate(memberSince));
} }
String memberUntil = (String) setParams.get("memberuntil"); String memberUntil = (String) setParams.get("memberuntil");
if (assertNotNull(memberUntil)) { if (assertNotNull(memberUntil)) {
cust.setMemberUntil(TextUtil.parse(memberUntil)); cust.setMemberUntil(TextUtil.parseDate(memberUntil));
} }
String memberRole = (String) setParams.get("memberrole"); String memberRole = (String) setParams.get("memberrole");
if (assertNotNull(memberRole)) { if (assertNotNull(memberRole)) {
@ -112,15 +112,15 @@ public class CustomerRemote extends AbstractRemote {
} }
String authorContract = (String) setParams.get("authorcontract"); String authorContract = (String) setParams.get("authorcontract");
if (assertNotNull(authorContract)) { if (assertNotNull(authorContract)) {
cust.setAuthorContract(TextUtil.parse(authorContract)); cust.setAuthorContract(TextUtil.parseDate(authorContract));
} }
String nonDiscContract = (String) setParams.get("nondisccontract"); String nonDiscContract = (String) setParams.get("nondisccontract");
if (assertNotNull(nonDiscContract)) { if (assertNotNull(nonDiscContract)) {
cust.setNonDiscContract(TextUtil.parse(nonDiscContract)); cust.setNonDiscContract(TextUtil.parseDate(nonDiscContract));
} }
String sharesUpdated = (String) setParams.get("sharesupdated"); String sharesUpdated = (String) setParams.get("sharesupdated");
if (assertNotNull(sharesUpdated)) { if (assertNotNull(sharesUpdated)) {
cust.setSharesUpdated(TextUtil.parse(sharesUpdated)); cust.setSharesUpdated(TextUtil.parseDate(sharesUpdated));
} }
String sharesSigned = (String) setParams.get("sharessigned"); String sharesSigned = (String) setParams.get("sharessigned");
if (assertNotNull(sharesSigned)) { if (assertNotNull(sharesSigned)) {

View File

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