@Produces(MediaType.TEXT_PLAIN)
@Path("/occupied/set")
public String setOccupied(@QueryParam("id") String id, @QueryParam("val") String val) {
String result = null;
if (id != null) {
ProgramProfileInfo ppiToPersist = new ProgramProfileInfo();
ppiToPersist.setAgencyKey(Integer.valueOf(id));
ProgramProfileInfo ppiPersisted = ppis.getProgramProfileInfo(Integer.valueOf(id));
int occupiedUnits = ppiPersisted.getUnitsOccupied();
occupiedUnits = Integer.parseInt(val);
ppiToPersist.setUnitsOccupied(occupiedUnits);
// also recalculate available units
int availUnits = ppiPersisted.getUnitsAvailable();
int totalUnits = ppiPersisted.getUnitsTotal();
availUnits = totalUnits - occupiedUnits;
ppiToPersist.setUnitsAvailable(availUnits);
ppiToPersist.setUnitsTotal(totalUnits);
ppis.updateProgramProfileInfo_Occupany(ppiToPersist);
result = String.valueOf(occupiedUnits);