public static boolean saveOrUpdate(CategorySurveyProxy proxy) {
   boolean result = false;
   DaoSession session = SageApplication.getInstance().getDaoSession();
   SurveyService surveyService = new SurveyService(session);
   ElementService elementService = new ElementService(session);
   SageApplication.getInstance().getDatabase().beginTransaction();
   try { // main survey must already be saved (this will be the case)
     for (VegetationSurveyProxy survey : proxy.getCanopies()) {
       if (survey.getStationElements() != null && survey.getStationElements().size() > 0) {
         // Save the survey
         survey.setRoot(proxy);
         surveyService.saveOrUpdate(survey);
         // save the elements
         elementService.saveOrUpdate(survey.getStationElements(), survey.getModel());
       } else {
         new ElementService(session).delete(survey.getModel());
       }
     }
     SageApplication.getInstance().getDatabase().setTransactionSuccessful();
     result = true;
   } catch (Exception e) {
     result = false;
   } finally {
     SageApplication.getInstance().getDatabase().endTransaction();
   }
   return result;
 }
 private static VegetationSurveyProxy buildCanopy(String canopy) {
   VegetationSurveyProxy result = new VegetationSurveyProxy();
   result.setModel(new Station());
   result.getModel().setStationType(VegetationGlobals.STATION_TYPE_VEGETATION_CANOPY);
   result.getModel().setName(canopy);
   result.getModel().setRowGuid();
   result.setStationElements(new ArrayList<StationElementProxy>());
   return result;
 }