Kann Pakete in HSDB anlegen
This commit is contained in:
parent
6abee84d81
commit
39c0c3b8c2
@ -39,7 +39,7 @@ public class Pac extends AbstractEntity implements Serializable {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = SEQUENCE, generator = "PacsSeqGen")
|
@GeneratedValue(strategy = SEQUENCE, generator = "PacsSeqGen")
|
||||||
@Column(name = "packet_id")
|
@Column(name = "packet_id", columnDefinition = "integer")
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@Column(name = "packet_name", unique = true)
|
@Column(name = "packet_name", unique = true)
|
||||||
|
@ -58,8 +58,17 @@ public class PacComponent {
|
|||||||
public PacComponent(BasePac basePac, BaseComponent baseComp, Pac pac,
|
public PacComponent(BasePac basePac, BaseComponent baseComp, Pac pac,
|
||||||
int quantity, Date created, Date cancelled) {
|
int quantity, Date created, Date cancelled) {
|
||||||
this.basePac = basePac;
|
this.basePac = basePac;
|
||||||
|
if (basePac != null) {
|
||||||
|
this.basePacId = basePac.id();
|
||||||
|
}
|
||||||
this.pac = pac;
|
this.pac = pac;
|
||||||
|
if (pac != null) {
|
||||||
|
this.pacId = pac.id();
|
||||||
|
}
|
||||||
this.baseComponent = baseComp;
|
this.baseComponent = baseComp;
|
||||||
|
if (baseComponent != null) {
|
||||||
|
this.baseComponentId = baseComp.id();
|
||||||
|
}
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.created = created;
|
this.created = created;
|
||||||
this.cancelled = cancelled;
|
this.cancelled = cancelled;
|
||||||
@ -71,6 +80,9 @@ public class PacComponent {
|
|||||||
|
|
||||||
public void setbasePac(BasePac basePac) {
|
public void setbasePac(BasePac basePac) {
|
||||||
this.basePac = basePac;
|
this.basePac = basePac;
|
||||||
|
if (basePac != null) {
|
||||||
|
this.basePacId = basePac.id();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent getBaseComponent() {
|
public BaseComponent getBaseComponent() {
|
||||||
@ -79,6 +91,9 @@ public class PacComponent {
|
|||||||
|
|
||||||
public void setBaseComponent(BaseComponent baseComponent) {
|
public void setBaseComponent(BaseComponent baseComponent) {
|
||||||
this.baseComponent = baseComponent;
|
this.baseComponent = baseComponent;
|
||||||
|
if (baseComponent != null) {
|
||||||
|
this.baseComponentId = baseComponent.id();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pac getPac() {
|
public Pac getPac() {
|
||||||
@ -87,6 +102,9 @@ public class PacComponent {
|
|||||||
|
|
||||||
public void setPac(Pac pac) {
|
public void setPac(Pac pac) {
|
||||||
this.pac = pac;
|
this.pac = pac;
|
||||||
|
if (pac != null) {
|
||||||
|
this.pacId = pac.id();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getQuantity() {
|
public int getQuantity() {
|
||||||
|
@ -26,9 +26,10 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||||
Date now = new Date();
|
|
||||||
EntityManager em = getTransaction().getEntityManager();
|
EntityManager em = getTransaction().getEntityManager();
|
||||||
Pac pac = (Pac) newEntity;
|
Pac pac = (Pac) newEntity;
|
||||||
|
Date now = new Date();
|
||||||
|
pac.setCreated(now);
|
||||||
BasePac basepac = pac.getBasepac();
|
BasePac basepac = pac.getBasepac();
|
||||||
if (basepac == null || basepac.getName() == null || basepac.getName().length() == 0) {
|
if (basepac == null || basepac.getName() == null || basepac.getName().length() == 0) {
|
||||||
throw new HSAdminException("basepac required");
|
throw new HSAdminException("basepac required");
|
||||||
@ -38,8 +39,6 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
|||||||
qBasepac.setParameter("valid", Boolean.TRUE);
|
qBasepac.setParameter("valid", Boolean.TRUE);
|
||||||
basepac = (BasePac) qBasepac.getSingleResult();
|
basepac = (BasePac) qBasepac.getSingleResult();
|
||||||
pac.setBasepac(basepac);
|
pac.setBasepac(basepac);
|
||||||
Query qComponents = em.createQuery("SELECT c FROM Components c WHERE c.basePacId = :basepac");
|
|
||||||
qComponents.setParameter("basepac", basepac.id());
|
|
||||||
INetAddress curINetAddr = pac.getCurINetAddr();
|
INetAddress curINetAddr = pac.getCurINetAddr();
|
||||||
if (curINetAddr == null || curINetAddr.getInetAddr() == null || curINetAddr.getInetAddr().length() == 0) {
|
if (curINetAddr == null || curINetAddr.getInetAddr() == null || curINetAddr.getInetAddr().length() == 0) {
|
||||||
throw new HSAdminException("curinetaddr required");
|
throw new HSAdminException("curinetaddr required");
|
||||||
@ -63,7 +62,8 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
|||||||
qHive.setParameter("name", hive.getName());
|
qHive.setParameter("name", hive.getName());
|
||||||
hive = (Hive) qHive.getSingleResult();
|
hive = (Hive) qHive.getSingleResult();
|
||||||
pac.setHive(hive);
|
pac.setHive(hive);
|
||||||
// em.persist(newEntity);
|
Query qComponents = em.createQuery("SELECT c FROM Components c WHERE c.basePacId = :basepac");
|
||||||
|
qComponents.setParameter("basepac", basepac.id());
|
||||||
List<?> componentsList = qComponents.getResultList();
|
List<?> componentsList = qComponents.getResultList();
|
||||||
Set<PacComponent> pacComponents = new HashSet<PacComponent>();
|
Set<PacComponent> pacComponents = new HashSet<PacComponent>();
|
||||||
for (Object cObj : componentsList) {
|
for (Object cObj : componentsList) {
|
||||||
@ -74,7 +74,7 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
|||||||
pacComponent.setCreated(now);
|
pacComponent.setCreated(now);
|
||||||
pacComponent.setPac(pac);
|
pacComponent.setPac(pac);
|
||||||
pacComponent.setQuantity(comp.getDefaultQuantity());
|
pacComponent.setQuantity(comp.getDefaultQuantity());
|
||||||
// em.persist(pacComponent);
|
pacComponents.add(pacComponent);
|
||||||
}
|
}
|
||||||
pac.setPacComponents(pacComponents);
|
pac.setPacComponents(pacComponents);
|
||||||
return super.add(newEntity);
|
return super.add(newEntity);
|
||||||
|
Loading…
Reference in New Issue
Block a user