diff --git a/hsarback/database/schema.sql b/hsarback/database/schema.sql index 93d89e9..6b2b5f0 100644 --- a/hsarback/database/schema.sql +++ b/hsarback/database/schema.sql @@ -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))) diff --git a/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java b/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java index a91649c..4de2fb6 100644 --- a/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java +++ b/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java @@ -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)); diff --git a/hsarback/src/de/hsadmin/core/util/TextUtil.java b/hsarback/src/de/hsadmin/core/util/TextUtil.java index 07ed03e..f89a137 100644 --- a/hsarback/src/de/hsadmin/core/util/TextUtil.java +++ b/hsarback/src/de/hsadmin/core/util/TextUtil.java @@ -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; + } + } diff --git a/hsarback/src/de/hsadmin/mods/pac/Pac.java b/hsarback/src/de/hsadmin/mods/pac/Pac.java index d6465c7..255b637 100644 --- a/hsarback/src/de/hsadmin/mods/pac/Pac.java +++ b/hsarback/src/de/hsadmin/mods/pac/Pac.java @@ -68,12 +68,9 @@ 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) private INetAddress curINetAddr; @@ -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; + } } diff --git a/hsarback/src/de/hsadmin/remote/CustomerRemote.java b/hsarback/src/de/hsadmin/remote/CustomerRemote.java index 815af20..785ba44 100644 --- a/hsarback/src/de/hsadmin/remote/CustomerRemote.java +++ b/hsarback/src/de/hsadmin/remote/CustomerRemote.java @@ -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)) { diff --git a/hsarback/src/de/hsadmin/remote/PacRemote.java b/hsarback/src/de/hsadmin/remote/PacRemote.java index 566e4a8..3fa9d6a 100644 --- a/hsarback/src/de/hsadmin/remote/PacRemote.java +++ b/hsarback/src/de/hsadmin/remote/PacRemote.java @@ -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)) {