aikajutukkeita

1 parent 9f1a002e
...@@ -89,6 +89,10 @@ public class FoodWave extends GenericEntity { ...@@ -89,6 +89,10 @@ public class FoodWave extends GenericEntity {
return closed; return closed;
} }
public boolean isClosed() {
return closed;
}
public void setClosed(boolean waveClosed) { public void setClosed(boolean waveClosed) {
this.closed = waveClosed; this.closed = waveClosed;
} }
...@@ -108,5 +112,39 @@ public class FoodWave extends GenericEntity { ...@@ -108,5 +112,39 @@ public class FoodWave extends GenericEntity {
public FoodWaveTemplate getTemplate() { public FoodWaveTemplate getTemplate() {
return template; return template;
} }
public boolean isFull() {
return false;
}
/**
* Check if foodwave is orderable
*
* That means that it's not closed, full and it's in future
* @return
*/
public boolean isOrderable() {
if(isClosed()) {
return false;
}
if(getTime().before(Calendar.getInstance())) {
return false;
}
if(isFull()) {
return false;
}
return true;
}
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
...@@ -100,5 +101,26 @@ public class FoodWaveTemplate extends GenericEntity { ...@@ -100,5 +101,26 @@ public class FoodWaveTemplate extends GenericEntity {
public void setEvent(LanEvent event) { public void setEvent(LanEvent event) {
this.event = event; this.event = event;
} }
public List<FoodWave> getOrderableFoodwaves() {
List<FoodWave> returnList = new ArrayList<FoodWave>();
for(FoodWave wave : getFoodwaves()) {
if(wave.isOrderable()) {
returnList.add(wave);
}
}
return returnList;
}
} }
...@@ -113,7 +113,7 @@ public class FoodWaveView extends GenericCDIView { ...@@ -113,7 +113,7 @@ public class FoodWaveView extends GenericCDIView {
public String selectTemplate() { public String selectTemplate() {
if (templates.isRowAvailable()) { if (templates.isRowAvailable()) {
foodWaves = new ListDataModel<FoodWave>(templates.getRowData() foodWaves = new ListDataModel<FoodWave>(templates.getRowData()
.getFoodwaves()); .getOrderableFoodwaves());
} }
return "/foodwave/list"; return "/foodwave/list";
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!