@Override public boolean maintainSectionEquipment(AttraSection attraSection) { if (em.find(AttraSection.class, attraSection.getNum()) != null) { List<Equipment> equipments = (List<Equipment>) attraSection.getEquipments(); for (Equipment e : equipments) { e.setStatus("Inactive"); em.merge(e); } attraSection.setEquipments(equipments); attraSection.setStatus("Inactive"); em.merge(attraSection); return true; } return false; }
@Override public boolean activateEquipment(Equipment equipment) { if (em.find(Equipment.class, equipment.getId()) != null) { equipment.setStatus("Active"); em.merge(equipment); AttraSection attraSection = equipment.getAttraSection(); List<Equipment> equipments = (List<Equipment>) attraSection.getEquipments(); int temp = 1; for (Equipment e : equipments) { if (e.getStatus().equals("Inactive")) { temp = 0; } } if (temp == 1) { attraSection.setStatus("Active"); em.merge(attraSection); } return true; } return false; }