use of com.webstart.model.Users in project FarmCloud by vratsasg.
the class HomeController method getObsProperties.
@RequestMapping(value = "/observableproperties", method = RequestMethod.GET)
public ResponseEntity<String> getObsProperties(HttpServletRequest request) {
JSONObject obj = new JSONObject();
Users users = (Users) request.getSession().getAttribute("current_user");
if (users == null) {
return new ResponseEntity(HttpStatus.UNAUTHORIZED);
}
obj = observationProperyService.getAllObsPropeties();
return new ResponseEntity<String>(obj.toJSONString(), HttpStatus.CREATED);
}
use of com.webstart.model.Users in project FarmCloud by vratsasg.
the class HomeController method getProfile.
@RequestMapping(value = "/features/profile", method = RequestMethod.GET)
public ResponseEntity<String> getProfile(HttpServletRequest request) {
Users users = (Users) request.getSession().getAttribute("current_user");
if (users == null) {
return new ResponseEntity(HttpStatus.UNAUTHORIZED);
}
JSONObject obj = featureofInterestService.findCropInfo(users.getUser_id());
return new ResponseEntity<String>(obj.toJSONString(), HttpStatus.OK);
}
use of com.webstart.model.Users in project FarmCloud by vratsasg.
the class HomeController method setIrrigationDates.
@RequestMapping(value = "/{mydevice}/irrigation/times", params = { "dtfrom", "dtto" }, method = RequestMethod.POST)
public ResponseEntity<?> setIrrigationDates(@PathVariable("mydevice") String mydevice, @RequestParam("dtfrom") String datefrom, @RequestParam("dtto") String dateto, HttpServletRequest request) {
Users users = (Users) request.getSession().getAttribute("current_user");
try {
AutomaticWater automaticWater = new AutomaticWater(datefrom, dateto, new BigDecimal(0), mydevice);
boolean sentData = featureofInterestService.setDeviceIrrigaDate(users.getUser_id(), mydevice, datefrom, dateto);
Featureofinterest featureofinterest = this.featureofInterestService.getFeatureofinterestByIdentifier(mydevice);
usersService.createNewNotification(users.getUser_id(), String.format("New irrigation event from: %1$s until %2$s for end device %3$s ", automaticWater.getFromtime(), automaticWater.getUntiltime(), featureofinterest.getName()), NotificationTypeEnum.IRRIGATION.getValue());
if (!sentData)
return new ResponseEntity(HttpStatus.BAD_REQUEST);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity(HttpStatus.BAD_REQUEST);
}
return new ResponseEntity(HttpStatus.OK);
}
use of com.webstart.model.Users in project FarmCloud by vratsasg.
the class HomeController method getStationCoords.
@RequestMapping(value = "/station/coords", method = RequestMethod.GET)
public ResponseEntity<String> getStationCoords(HttpServletRequest request) {
String jsonresult = null;
try {
Users users = (Users) request.getSession().getAttribute("current_user");
List<FeatureidIdentifier> results = featureofInterestService.findByUserAndType(users.getUser_id(), FeatureTypeEnum.STATION.getValue());
jsonresult = featureofInterestService.findByFeatureofinterestid(results.get(0).getFeatureinterestid());
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<String>(jsonresult, HttpStatus.OK);
}
use of com.webstart.model.Users in project FarmCloud by vratsasg.
the class HomeController method getMeasuresByObsProperty.
@RequestMapping(value = "/measures/lastdate", method = RequestMethod.GET)
public ResponseEntity<String> getMeasuresByObsProperty(HttpServletRequest request) {
JSONArray obj = new JSONArray();
Users users = (Users) request.getSession().getAttribute("current_user");
String sentData = null;
try {
sentData = observationProperyService.getLastObservationsDate(users.getUser_id());
} catch (Exception e) {
e.printStackTrace();
return null;
}
return new ResponseEntity<String>(sentData, HttpStatus.OK);
}
Aggregations