Package com.centraview.common

Examples of com.centraview.common.UserPrefererences


    // getting user object from session
    HttpSession session = request.getSession();
    UserObject userobjectd = (UserObject)session.getAttribute("userobject");

    // get the user's preference for sync'ing as private or default privileges
    UserPrefererences userPrefs = userobjectd.getUserPref();
    TimeZone tz = TimeZone.getTimeZone(userPrefs.getTimeZone());
    Locale locale = request.getLocale();
    String prefValue = userPrefs.getSyncAsPrivate();
    boolean syncAsPrivate = (prefValue != null && prefValue.equals("YES")) ? true : false;

    // date format for incoming dates: 2004-01-13 15:00:00
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // date format for writing to the form should be in the format based on
View Full Code Here


    try {
      HttpSession session = request.getSession();

      // get the user's sync prefs from the EJB layer
      UserObject userObject = (UserObject)session.getAttribute("userobject");
      UserPrefererences userPrefs = userObject.getUserPref();
      String prefValue = (String)userPrefs.getSyncAsPrivate();
      Boolean syncAsPrivate = (prefValue != null && prefValue.equals("YES")) ? new Boolean(true) : new Boolean(false);

      // populate the syncPreferencesForm bean
      DynaActionForm syncPrefsForm = (DynaActionForm)form;
      syncPrefsForm.set("syncAsPrivate", syncAsPrivate);
View Full Code Here

        Preference prefRemote = prefHome.create();
        prefRemote.setDataSource(dataSource);
       
        prefRemote.updateUserPreference(individualID, prefsVector);
       
        UserPrefererences userPrefs = userObject.getUserPref();
        userPrefs.setEmailCheckInterval(newValue.intValue());
        userObject.setUserPref(userPrefs);
        session.setAttribute("userobject", userObject);
      }
    } catch (Exception e) {
      System.out.println("[Exception][UpdateAutoCheckHandler] Exception thrown in execute(): " + e);
View Full Code Here

public class SelectDateTimeHandler extends org.apache.struts.action.Action {
  private static Logger logger = Logger.getLogger(SelectDateTimeHandler.class);
  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws RuntimeException, Exception {
    HttpSession session = request.getSession(true);
    UserObject user = (UserObject)session.getAttribute("userobject");
    UserPrefererences prefs = user.getUserPref();
    TimeZone tz = TimeZone.getTimeZone(prefs.getTimeZone());
    Locale locale = request.getLocale();
   
    String forward = ".view.calendar.datetime";
    // "dateTimeSelectForm" in mappings/calendar.xml
    DynaActionForm dateForm = (DynaActionForm) form;
View Full Code Here

    this.dataSource = ds;
  }

  public UserObject getUserObject(int individualId, String firstName, String lastName, String userType)
  {
    UserPrefererences up = new UserPrefererences();
    try {
      InitialContext ic = CVUtility.getInitialContext();
      PreferenceLocalHome home = (PreferenceLocalHome) ic.lookup("local/Preference");
      PreferenceLocal remote = home.create();
      remote.setDataSource(this.dataSource);
View Full Code Here

   * @param individualId
   * @return
   * @exception Exception
   */
  public UserPrefererences getUserPreferences(int individualId) {
    UserPrefererences up = new UserPrefererences();
    CVDal cvdl = new CVDal(dataSource);
    try {
      cvdl.setSql("preference.getpreference");
      cvdl.setInt(1, individualId);
      Collection col = cvdl.executeQuery();
      if (col == null) {
        throw new Exception("User preference not found");
      }
      Iterator it = col.iterator();
      while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        String preferencename = (String) hm.get("preference_name");
        if (preferencename != null) {
          if (preferencename.equals("acknowledgeddays")) {
            String strlng = (String) hm.get("preference_value");
            up.setAcknowledgedDays(Integer.parseInt(strlng));
          }
          if (preferencename.equals("acknowledgedvisability")) {
            up.setAcknowledgedVisibility((String) hm.get("preference_value"));
          }
          if (preferencename.equals("activitytype")) {
            String stracttype = (String) hm.get("preference_value");
            up.setActivityPortletAccountType(Integer.parseInt(stracttype));
          }
          if (preferencename.equals("emailvisability")) {
            up.setEmailVisibility((String) hm.get("preference_value"));
          }
          if (preferencename.equals("opportunityvisible")) {
            boolean isVisible = false;
            if (((String) hm.get("preference_value")).equalsIgnoreCase("Yes")) {
              isVisible = true;
            }
            up.setOpportunityVisible(isVisible);
          }
          if (preferencename.equals("taskvisible")) {
            boolean isVisible = false;
            if (((String) hm.get("preference_value")).equalsIgnoreCase("Yes")) {
              isVisible = true;
            }
            up.setTaskVisible(isVisible);
          }
          if (preferencename.equals("supportvisible")) {
            boolean isVisible = false;
            if (((String) hm.get("preference_value")).equalsIgnoreCase("Yes")) {
              isVisible = true;
            }
            up.setSupportVisible(isVisible);
          }

          if (preferencename.equals("emailaccountid")) {
            String strepaid = (String) hm.get("preference_value");
            try {
              up.setEmailPortletAccountID(Integer.parseInt(strepaid));
            } catch (NumberFormatException nfe) {
              // "I get paid, to do the wild thing." -Tone Loc
            }
          }
          if (preferencename.equals("calactivitytype")) {
            String strlngObj = (String) hm.get("preference_value");
            up.setCalenderPortletActivityType(Integer.parseInt(strlngObj));
          }
          if (preferencename.equals("newsdays")) {
            String strnd = (String) hm.get("preference_value");
            up.setNewPortletDays(Integer.parseInt(strnd));
          }

          if (individualId != 0) {
            up.setIndividualID(individualId);
          }

          if (preferencename.equals("caldefaultview")) {
            up.setCalendarDefaultView((String) hm.get("preference_value"));
          }

          if (preferencename.equals("calendarrefreshmin")) {
            up.setCalendarRefreshMin((String) hm.get("preference_value"));
          }

          if (preferencename.equals("calendarrefreshsec")) {
            up.setCalendarRefreshSec((String) hm.get("preference_value"));
          }

          if (preferencename.equals("email")) {
            up.setEmail((String) hm.get("preference_value"));
          }

          if (preferencename.equals("todayscalendar")) {
            up.setTodaysCalendar((String) hm.get("preference_value"));
          }

          if (preferencename.equals("unscheduledactivities")) {
            up.setUnscheduledActivities((String) hm.get("preference_value"));
          }

          if (preferencename.equals("scheduledopportunities")) {
            up.setScheduledOpportunities((String) hm.get("preference_value"));
          }

          if (preferencename.equals("projecttasks")) {
            up.setProjectTasks((String) hm.get("preference_value"));
          }

          if (preferencename.equals("supporttickets")) {
            up.setSupportTickets((String) hm.get("preference_value"));
          }

          if (preferencename.equals("companynews")) {
            up.setCompanyNews((String) hm.get("preference_value"));
          }

          if (preferencename.equals("DEFAULTFOLDERID")) {
            up.setDefaultFolderID(Integer.parseInt((String) hm.get("preference_value")));
          }

          if (preferencename.equals("TIMEZONE")) {
            up.setTimeZone((String) hm.get("preference_value"));
          }

          if (preferencename.equals("DATEFORMAT")) {
            up.setDateFormat((String) hm.get("preference_value"));
          }

          if (preferencename.equals("contenttype")) {
            up.setContentType((String) hm.get("preference_value"));
          }

          if (preferencename.equals("allRecordsPublic")) {
            up.setAllRecordsPublic((String) hm.get("preference_value"));
          }

          if (preferencename.equals("syncAsPrivate")) {
            up.setSyncAsPrivate((String) hm.get("preference_value"));
          }

          if (preferencename.equals("emailCheckInterval")) {
            // default to 10 if no valid value is found
            int interval = 10;
            try {
              interval = Integer.parseInt((String) hm.get("preference_value"));
            } catch (NumberFormatException nfe) { /* default already set */}
            up.setEmailCheckInterval(interval);
          }

          if (preferencename.equals("homesettingrefreshmin")) {
            up.setHomeRefreshMin((String) hm.get("preference_value"));
          }

          if (preferencename.equals("homesettingrefreshsec")) {
            up.setHomeRefreshSec((String) hm.get("preference_value"));
          }
          if (preferencename.equals("showticketcharts")) {
            boolean isVisible = false;
            if (((String) hm.get("preference_value")).equalsIgnoreCase("Yes")) {
              isVisible = true;
            }
            up.setShowTicketCharts(isVisible);
          }
          if (preferencename.equals("showsalescharts")) {
            boolean isVisible = false;
            if (((String) hm.get("preference_value")).equalsIgnoreCase("Yes")) {
              isVisible = true;
            }
            up.setShowSalesCharts(isVisible);
          }

        } // end if (preferencename != null)
      } // end while (it.hasNext())

      // Get all the views.
      ListPreference listPreference = null;
      ListView listView = null;
      // Step One: we will get all the Default Views for the Individual, who is
      // logged in.
      cvdl.setSqlQueryToNull();
      cvdl.setSqlQuery("SELECT listviews.viewid, listviews.listtype, listviews.sorttype, listviews.sortmember AS sortelement, listviews.noofrecords AS recordsperpage, listviews.viewname, listviews.searchid FROM listviews, defaultviews WHERE listviews.listtype = defaultviews.listtype AND listviews.viewid = defaultviews.viewid");
      Collection ownerViewCollection = cvdl.executeQuery();
      Iterator ownerViewIterator = ownerViewCollection.iterator();
      while (ownerViewIterator.hasNext()) {
        HashMap ownerViewHM = (HashMap) ownerViewIterator.next();
        String listType = (String) ownerViewHM.get("listtype");
        int viewId = ((Number) ownerViewHM.get("viewid")).intValue();
        listPreference = new ListPreference(listType);
        // Step Two:
        // We must get all the Views which exist for each ListType from the
        // query for default views.
        cvdl.setSqlQueryToNull();
        cvdl.setSqlQuery("SELECT viewid, viewname, searchid FROM listviews WHERE listtype = ? and ownerid IS NULL UNION SELECT viewid, viewname, searchid FROM listviews WHERE listtype = ? and ownerid = ?");
        cvdl.setString(1, listType);
        cvdl.setString(2, listType);
        cvdl.setInt(3, individualId);
        Collection allViewCollection = cvdl.executeQuery();
        Iterator allViewIterator = allViewCollection.iterator();
        while (allViewIterator.hasNext()) {
          HashMap allViewHM = (HashMap) allViewIterator.next();
          int allViewId = ((Number) allViewHM.get("viewid")).intValue();
          listView = new ListView(allViewId);
          listView.setListType(listType);
          listView.setViewName((String) allViewHM.get("viewname"));
          listView.setViewID(allViewId);
          listView.setSearchID(((Number) allViewHM.get("searchid")).intValue());
          // Get all columns for the View. Which we are processing.
          cvdl.setSqlQueryToNull();
          cvdl.setSql("view.getownerallcolumn");
          cvdl.setInt(1, allViewId);
          cvdl.setString(2, listType);
          Collection viewColumnCollection = cvdl.executeQuery();
          Iterator viewColumnIterator = viewColumnCollection.iterator();
          while (viewColumnIterator.hasNext()) {
            HashMap viewColumnHM = (HashMap) viewColumnIterator.next();
            listView.addColumnName((String) viewColumnHM.get("columnname"));
          }// end of while (viewColumnIterator.hasNext())
          listPreference.addListView(listView);
        }// end of while (allViewIterator.hasNext())
        listPreference.setDefaultView(viewId);
        listPreference.setRecordsPerPage(((Long) ownerViewHM.get("recordsperpage")).intValue());
        listPreference.setSortElement((String) ownerViewHM.get("sortelement"));
        String sortType = (String) ownerViewHM.get("sorttype");
        boolean sortTypeBoolean = true;
        if (sortType.equals("A")) {
          sortTypeBoolean = true;
        } else {
          sortTypeBoolean = false;
        }
        listPreference.setSortOrder(sortTypeBoolean);
        up.addListPreferences(listPreference);
      } // end of while (ownerViewIterator.hasNext())
    } catch (Exception e) {
      logger.error("[getUserPreferences] Exception thrown.", e);
    } finally {
      cvdl.destroy();
View Full Code Here

  InitialContext ic = CVUtility.getInitialContext();
  PreferenceLocalHome home  = (PreferenceLocalHome)ic.lookup("local/Preference");
  PreferenceLocal localPref =  home.create();
  localPref.setDataSource(this.dataSource);

  UserPrefererences userPref = localPref.getUserPreferences(userId);


  if(userPref != null)
  if (userPref.getContentType() != null && userPref.getContentType().equals("PLAIN"))
  {
    messageContext = "text/plain";
  }
  else if ( userPref.getContentType() != null && userPref.getContentType().equals("HTML"))
  {
    messageContext = "text/html";
  }

  if(mailmessage.getContentType() != null && mailmessage.getContentType().equals("HTML") ){
View Full Code Here

TOP

Related Classes of com.centraview.common.UserPrefererences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.