Package java.util

Examples of java.util.TreeMap$DescendingMap


    assertEquals("overwritten", dest.getField1());
  }

  @Test
  public void testTreeMap() {
    TreeMap map = new TreeMap();
    map.put("a", "b");

    TreeMap result = mapper.map(map, TreeMap.class);

    assertNotNull(result);
    assertEquals(1, result.size());
  }
View Full Code Here


        }
    }

    static class TreeEntityMap extends MapIntMap {
        public TreeEntityMap() {
            mapNameToValue = new TreeMap();
            mapValueToName = new TreeMap();
        }
View Full Code Here

    return maxId;
  }//getMaxLineId

  public void sort()
  {
    TreeMap tmp = new TreeMap();
    Set s = this.keySet();
    Iterator itr = s.iterator();
    String sortMember = this.getSortMember();
    AccountingLineElement curr = null;
    while(itr.hasNext())
    {
      try
        {
          curr = (AccountingLineElement)this.get(itr.next());
          String newSortStr = ((ListElementMember)curr.get(sortMember)).getSortString() + curr.getElementId();
          tmp.put(newSortStr,curr);
        }//try
      catch(Exception e)
        {
          System.out.println("AccountingLines:Exception cought in while");
        }//catch
View Full Code Here

      lgmap = CalendarUtil.getCalendarCollection(startTimeUser, endTimeUser, tz, userID, timespan, "", dataSource);
      DL = (CalendarList) lgmap.get("calendarlist");

      unscheduledactivity = (HashMap) lgmap.get("unscheduledactivity");
      scheduledactivity = (HashMap) lgmap.get("scheduledactivity");
      TreeMap allDayActivity = (TreeMap) lgmap.get("allDayActivity");

      Iterator arrIt = lgmap.keySet().iterator();
      while (arrIt.hasNext()) {
        String key = (String) arrIt.next();
        if (key.equals("calendarlist")) {
View Full Code Here

      remoteTicket.setDataSource(dataSource);
      TicketVO tVO = remoteTicket.getTicketBasicRelations(individualID, ticketID);

      // Setting the Custom Fields..
      String customFields = "";
      TreeMap map = new TreeMap();
      map = CustomFieldData.getCustomField("Ticket", ticketID, dataSource);

      Set set = map.keySet();
      Iterator it = set.iterator();
      while (it.hasNext()) {
        String str = (String) it.next();
        CustomFieldVO field = (CustomFieldVO) map.get(str);
        if (field == null) {
          continue;
        }// end if (field == null)

        String fieldType = field.getFieldType();
        String fieldValue = field.getValue();
        String fieldLabel = field.getLabel();

        if (fieldValue == null) {
          fieldValue = "";
        }// end of if (fieldValue == null)
        if (fieldType == null) {
          fieldType = "SCALAR";
        }// end of if (fieldType == null)

        if (fieldType.equals("SCALAR")) {
          customFields += "<TR>\n";
          customFields += "<TD class=\"popupTableText\">" + fieldLabel + "</TD>";
          customFields += "<TD class=\"popupTableText\">" + fieldValue + "</TD>";
          customFields += "</TR>";
        }// end of if (fieldType.equals("SCALAR"))
        else {
          fieldValue = fieldValue.trim();
          if (fieldValue.equals("")) {
            customFields += "<TR>\n";
            customFields += "<TD class=\"popupTableText\">" + fieldLabel + "</TD>";
            customFields += "<TD class=\"popupTableText\">" + fieldValue + "</TD>";
            customFields += "</TR>";
            fieldValue = "0";
          }// end of if(fieldValue.equals(""))

          Vector vec = field.getOptionValues();
          if (vec != null) {
            for (int j = 0; j < vec.size(); j++) {
              DDNameValue ddName = (DDNameValue) vec.get(j);
              int compId = Integer.parseInt(fieldValue);
              if (ddName.getId() == compId) {
                customFields += "<TR>\n";
                customFields += "<TD class=\"popupTableText\">" + fieldLabel + "</TD>";
                customFields += "<TD class=\"popupTableText\">" + ddName.getName() + "</TD>";
                customFields += "</TR>";
              }
            }
          } // end if (vec != null)
        } // end if (fieldType.equals("SCALAR"))
      } // end while (it.hasNext())

      // Setting the Values in the Values Map
      TreeMap Values = new TreeMap();
      Values.put("--TicketNumber--", new Integer(tVO.getId()).toString());

      GlobalMasterLists gml = GlobalMasterLists.getGlobalMasterLists(dataSource);
      Vector statusVec = gml.getAllStatus();
      if (statusVec != null) {
        for (int j = 0; j < statusVec.size(); j++) {
          DDNameValue ddName = (DDNameValue) statusVec.get(j);
          int compId = tVO.getStatusId();
          if (ddName.getId() == compId) {
            Values.put("--Status--", ddName.getName());
          }
        }
      } // end if (vec != null)

      Vector priorityVec = gml.getAllPriorities();
      if (priorityVec != null) {
        for (int j = 0; j < priorityVec.size(); j++) {
          DDNameValue ddName = (DDNameValue) priorityVec.get(j);
          int compId = tVO.getPriorityId();
          if (ddName.getId() == compId) {

            Values.put("--Priority--", ddName.getName());
          }
        }
      } // end if (priorityVec != null)

      Values.put("--Subject--", tVO.getTitle());
      String detail = tVO.getDetail();
      detail = detail.replaceAll("\n", "<br>");
      Values.put("--Details--", detail);
      Values.put("--Contact--", tVO.getRefIndividualName());
      Values.put("--Manager--", tVO.getManagerName());
      Values.put("--AssignedTo--", tVO.getAssignedToName());

      SupportFacadeHome supFacade = (SupportFacadeHome) CVUtility.getHomeObject(
          "com.centraview.support.supportfacade.SupportFacadeHome", "SupportFacade");
      SupportFacade remote = supFacade.create();
      remote.setDataSource(dataSource);

      ThreadList threadList = remote.getThreadList(individualID, tVO.getId());
      String threadValues = this.setLinksfunction(threadList);

      EntityVO entityVO = tVO.getEntityVO();
      if (entityVO != null) {
        String entityName = entityVO.getName();
        Values.put("--Name--", entityName);
        AddressVO primaryAdd = entityVO.getPrimaryAddress();
        String address = "";
        if (primaryAdd != null) {
          if (primaryAdd.getStreet1() != null && !primaryAdd.getStreet1().equals("")) {
            address += primaryAdd.getStreet1();
          }
          if (primaryAdd.getStreet2() != null && !primaryAdd.getStreet2().equals("")) {
            address += ", " + primaryAdd.getStreet2() + "\n";
          } else {
            address += "\n";
          }
          if (primaryAdd.getCity() != null && !primaryAdd.getCity().equals("")) {
            address += primaryAdd.getCity();
          }
          if (primaryAdd.getStateName() != null && !primaryAdd.getStateName().equals("")) {
            address += ", " + primaryAdd.getStateName();
          }
          if (primaryAdd.getZip() != null && !primaryAdd.getZip().equals("")) {
            address += " " + primaryAdd.getZip();
          }
          if (primaryAdd.getCountryName() != null && !primaryAdd.getCountryName().equals("")) {
            address += ", " + primaryAdd.getCountryName();
          }
          address = address.replaceAll("\n", "<br>");
        } // end if (primaryAdd != null)

        Values.put("--Address--", address);
        Collection mocList = entityVO.getMOC();
        Iterator iterator = mocList.iterator();
        String emailAddress = "";
        String phoneNumber = "";
        while (iterator.hasNext()) {
          MethodOfContactVO moc = (MethodOfContactVO) iterator.next();
          if (moc.getMocType() == 1 && moc.getIsPrimary().equalsIgnoreCase("YES")) // this
                                                                                    // is
                                                                                    // for
                                                                                    // email
          {
            emailAddress = moc.getContent();
          } // end of if statement (moc.getMocType() == 1)
          else if (moc.getMocType() == 4) {
            phoneNumber = moc.getContent();
          } // end of else statement (moc.getMocType() == 1)
        }// end of while
        Values.put("--Email--", emailAddress);
        Values.put("--Phone--", phoneNumber);

      }

      PrintTemplateHome PTHome = (PrintTemplateHome) CVUtility.getHomeObject(
          "com.centraview.printtemplate.PrintTemplateHome", "Printtemplate");
      PrintTemplate PTRemote = PTHome.create();
      PTRemote.setDataSource(dataSource);

      PrintTemplateVO ptVO = PTRemote.getPrintTemplate(3);

      String ticketTemplate = ptVO.getPtData();

      Set listkey = Values.keySet();
      Iterator it1 = listkey.iterator();
      while (it1.hasNext()) {
        String str = (String) it1.next();
        String valueString = (String) Values.get(str);
        try {
          ticketTemplate = ticketTemplate.replaceAll(str, valueString);
        } catch (Exception e) {
          logger.error("[execute]: Exception", e);
          StringBuffer tempTicketTemplateErr = new StringBuffer();
View Full Code Here

    if (vistLoginPage == null) {
      vistLoginPage = "";
    }

    TreeMap errorMap = new TreeMap();
    String userType = null;
    UserObject userObject = null;
    HttpSession session = request.getSession();
    ModuleFieldRightMatrix mfrm = null;
    LoginHome lh = (LoginHome)CVUtility.getHomeObject("com.centraview.login.LoginHome","Login");

    try {
      // first, let's get the username and password from the HTML form
      DynaActionForm daf = (DynaActionForm)form;
      formUsername = (String)daf.get("username");
      formPassword = (String) daf.get("password");

      // next, let's check for the existence of the CVRMID cookie.
      boolean rmCookieExists = false;
      Cookie requestCookie = null;
      Cookie cookieList[] = request.getCookies();

      if (cookieList != null) {
        for (int i = 0; i < cookieList.length; i++) {
          Cookie tmpCookie = cookieList[i];
          if (tmpCookie.getName().equals("CVRMID")) {
            rmCookieExists = true;
            requestCookie = tmpCookie;
          }
        }
      }
      String cookieUsername = "";
      String cookiePassword = "";

      boolean useFormValues = false;

      // now, if the cookie exists, then get the content
      if (rmCookieExists) {
        // unencode the content of the cookie
        String unEncodedString = new String(Base64.decode(requestCookie.getValue()));

        // split the parts of the string on the "/" character
        String stringParts[] = unEncodedString.split("/");

        // get the username and password values and save for use
        cookieUsername = stringParts[0];
        cookiePassword = stringParts[1];

        // Note: In login.jsp, we checked to see if the cookie was set. If so, we
        // got the username and password from the cookie; we set the username form
        // value to the username from the cookie, and the password to "CVRMID-xxxxxxxx".
        // Therefore, we will check the form password value here; if it is NOT
        // "CVRMID-xxxxxxxx", the we know the user has manually typed in a different
        // password, and we will use the form password vs. the cookie password.
        if (formPassword != null && ! formPassword.equals("CVRMID-xxxxxxxx")) {
          useFormValues = true;
        }

        if (remember == null || remember.equals("")) {
          // if the user has *UN*-checked the Remember Me
          // checkbox, then get rid of their cookie
          this.forgetMe(response);
        }
      }

      String username = "";
      String password = "";

      if (rmCookieExists) {
        if (cookieUsername.equals(formUsername) && ! useFormValues) {
          // if the userName in the cookie equals the username in the form,
          // then, we'll authenticate on the cookie content
          username = cookieUsername;
          password = cookiePassword;
        } else {
          // if the username in the cookie does not match the username in the form,
          // then, we'll authenticate on the form content
          username = formUsername;
          password = formPassword;
        }
      } else {
        // if the cookie does not exist at all, authenticate on the form values
        username = formUsername;
        password = formPassword;
      }

      if (lh == null) {
        return (mapping.findForward("dataerror"));
      }

      Login remote = lh.create();
      remote.setDataSource(dataSource);
      usrResult = remote.authenticateUser(username, password);
      // Check to make sure the usrResult has all the fields we expect of it.
      // if so then it was a valid login, if not, then we will fail with a general
      // authentication error.
      if (usrResult.containsKey("individualid") && usrResult.containsKey("firstName") && usrResult.containsKey("lastName") && usrResult.containsKey("type")) {
        int individualId = Integer.parseInt((String)usrResult.get("individualid"));
        userType = (String)usrResult.get("type");
        String firstName = (String)usrResult.get("firstName");
        String lastName = (String)usrResult.get("lastName");

        if ((! userType.equalsIgnoreCase((String)daf.get("userType"))) && ! ("EMPLOYEE".equals(daf.get("userType")) && userType.equalsIgnoreCase("ADMINISTRATOR"))) {
          String errorHeader = "Error occurred during login.";
          errorMap.put(new Integer(0), errorHeader);
          String error = "The username or password was incorrect, or the user is disabled.";
          errorMap.put(new Integer(1), error);
          request.setAttribute("error", errorMap);
          FORWARD_final = GLOBAL_FORWARD_failure;
          return (mapping.findForward(FORWARD_final));
        }

        userObject = remote.getUserObject(individualId, firstName, lastName, userType);
        userObject.setLoginName(username);

        // In a certain case we will need a blank rights matrix, so prepare the remote connection now.
        AuthorizationHome ah = (AuthorizationHome)CVUtility.getHomeObject("com.centraview.administration.authorization.AuthorizationHome","Authorization");
        Authorization authorizationRemote = ah.create();
        authorizationRemote.setDataSource(dataSource);

        if (remember.equals("on")) {
          // the "Remember Me" cookie contains the a string in the format
          // "<userName>/<password>". This string is then encrypted.
          // We should probably store the SHA1 of the password, this is a major security risk!!
          // TODO: encode the SHA1 of the password in the cookie content, and not the password itself.
          // and write the corresponding login method to take the SHA1 directly.
          String cookieContent = username + "/" + password;
          String encodedString = Base64.encode(cookieContent.getBytes());
          Cookie rememberMeCookie = new Cookie("CVRMID", encodedString);
          // set the expire time - to the largest int possible
          rememberMeCookie.setMaxAge(2147483647);
          rememberMeCookie.setPath("/");
          response.addCookie(rememberMeCookie);
        }

        // get the real mfrm and put it on the UserObject
        mfrm = authorizationRemote.getUserSecurityProfileMatrix(individualId);
        up = userObject.getUserPref();
        up.setModuleAuthorizationMatrix(mfrm);
        userObject.setUserPref(up);
        session.setAttribute("userobject",userObject);

        // User Email Check - will schedule the recurring check
        // of all the user's email accounts, every x minutes where
        // x is defined by the user's preferences.
        int userInterval = userObject.getUserPref().getEmailCheckInterval();
        if (userInterval > 0) {
          // only start this job if the user wants their mail checked
          // automatically. A value of 0 means do not check mail automatically.

          // minutes to seconds, then seconds to miliseconds...
          Integer interval = new Integer(userInterval * 60 * 1000);
         
          // make sure this job isn't already scheduled for some unknown reason...
          // .. by "make sure", I mean blindly cancel the job registered for this user.
          Timer currentTimer = siteInfo.getUserTimer(individualId);
          if (currentTimer != null) {
            currentTimer.cancel();
          }

          TimerTask currentTask = siteInfo.getUserTask(individualId);
          if (currentTask != null) {
            currentTask.cancel();
          }

          Timer newTimer = new Timer(true);
          TimerTask userEmailCheck = new UserEmailCheck(individualId, session, dataSource, host);
          newTimer.schedule(userEmailCheck, 300000L, interval.longValue());
          siteInfo.setUserTimer(individualId, newTimer, userEmailCheck);
        }

        // code added for concurrent user maintinance
        session.setAttribute(SessionAlive.IS_ALIVE, new SessionAlive());

        if (userType.equalsIgnoreCase("CUSTOMER")) {
          // if this is a customer user, they can only
          // see the customer view. All other users can
          // only see the employee view
          FORWARD_final = ".view.customer.home";
        } else if ((userType.equalsIgnoreCase("ADMINISTRATOR") || userType.equalsIgnoreCase("EMPLOYEE"))) {
          FORWARD_final = FORWARD_login;
        } else {
          FORWARD_final = GLOBAL_FORWARD_failure;
        }

        // Last, set a cookie so the user never sees the EULA again...
        Cookie eulaCookie = new Cookie("CVEULA", "Yes");
        eulaCookie.setMaxAge(2147483647);    // largest int possible, cookie never expires
        eulaCookie.setPath("/");
        response.addCookie(eulaCookie);
        // Don't add more code here. Add any new code above where the
        // agreedTerms cookie is set above.
      } else {
        // the usrResult from the loginEJB isn't All that it can be.
        // Telling the user if it is the wrong username or password
        // is a security risk.  We will just go with the generic logon.invalid error.
        // no need to look at the hashmap.
        String errorHeader = "Error occurred during login.";
        errorMap.put(new Integer(0), errorHeader);
        String error = "The username or password was incorrect, or the user is disabled.";
        errorMap.put(new Integer(1), error);
        request.setAttribute("error", errorMap);
        FORWARD_final = GLOBAL_FORWARD_failure;
        // kill the CVRMID cookie
        this.forgetMe(response);
      }
View Full Code Here

    return maxId;
  }//getMaxLineId

  public void sort()
  {
    TreeMap tmp = new TreeMap();
    Set s = this.keySet();
    Iterator itr = s.iterator();
    String sortMember = this.getSortMember();
    AccountingLineElement curr = null;
    while(itr.hasNext())
    {
      try
        {
          curr = (AccountingLineElement)this.get(itr.next());
          String newSortStr = ((ListElementMember)curr.get(sortMember)).getSortString() + curr.getElementId();
          tmp.put(newSortStr,curr);
        }//try
      catch(Exception e)
        {
          System.out.println("AccountingLines:Exception cought in while");
        }//catch
View Full Code Here

    String forward = ".view.email.folder_list";
    try {
      MailHome home = (MailHome) CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = home.create();
      remote.setDataSource(dataSource);
      TreeMap folderList = new TreeMap();
      ArrayList accountList = remote.getUserAccountList(individualID);
      // also adding delegated accounts
      accountList.addAll(remote.getDelegatedAccountList(individualID));

      for (int i = 0; i < accountList.size(); i++) {
        int accountID = ((Number) accountList.get(i)).intValue();

        MailAccountVO mailAccountVO = remote.getMailAccountVO(accountID);

        if (mailAccountVO != null) {
          String accountName = mailAccountVO.getAccountName();
          ArrayList accountFolderList = remote.getFolderIDs(accountID);
          ArrayList folderVOCollection = new ArrayList();
          for (int j = 0; j < accountFolderList.size(); j++) {
            int folderID = ((Number) accountFolderList.get(j)).intValue();
            MailFolderVO folderVO = remote.getEmailFolder(folderID);
            folderVOCollection.add(folderVO);
          }
          folderList.put(accountID + "*" + accountName, folderVOCollection);
        }
      }
      request.setAttribute("folderList", folderList);
    } catch (Exception e) {
      logger.error("[execute]: Exception", e);
View Full Code Here

        de.load(getClass().getResourceAsStream("messages_de.properties"));


//        Map<String, String> englishMap = FastMap.newInstance();
        Set<String> deKeys = FastSet.newInstance();
        Map<String, String> missingInDE = new TreeMap();
        Set<String> unusedInDE = FastSet.newInstance();

        for (Entry<Object, Object> entry : de.entrySet()) {
            deKeys.add(entry.getKey().toString());
        }

        for (Entry<Object, Object> entry : english.entrySet()) {
            if (!deKeys.contains(entry.getKey().toString()))
                missingInDE.put(entry.getKey().toString(), entry.getValue().toString());
        }

        for (String deKey : deKeys) {
            if (english.get(deKey) == null)
                unusedInDE.add(deKey);
        }

        System.out.println("en:" + english.size());

        System.out.println("de:" + deKeys.size());
        System.out.println("missing in de:" + missingInDE.size());
        System.out.println("unused in de:" + unusedInDE.size());

        System.out.println("\n\n==================\nmissing in de:\n");
        outAsProperties(missingInDE);
View Full Code Here

     * specified newObj if there are setters available
     */
    public static void copyProperties(Object obj, Object newObj) {
        // ensure that always the same order of method calls will be applied
        // => use TreeMap not HashMap
        Map<String, Method> getterMapping = new TreeMap();
        Map<String, Method> setterMapping = new TreeMap();
        fillSettersAndGetters(obj.getClass(), setterMapping, getterMapping);

        getterMapping.keySet().retainAll(setterMapping.keySet());
        for (Entry<String, Method> getter : getterMapping.entrySet()) {
            Method setter = setterMapping.get(getter.getKey());

            // getter object should be castable to setter type:
            if (!setter.getParameterTypes()[0].isAssignableFrom(
                    getter.getValue().getReturnType()))
                continue;
View Full Code Here

TOP

Related Classes of java.util.TreeMap$DescendingMap

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.