Android Open Source - ItopMobile Itop Utils






From Project

Back to project page ItopMobile.

License

The source code is released under:

GNU General Public License

If you think the Android project ItopMobile listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// Copyright (C) 2011-2013 ITOMIG GmbH
////w w w .  jav  a  2  s  .  c o m
//   This file is part of iTopMobile.
//
//   iTopMobile is free software; you can redistribute it and/or modify  
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
//
//   iTopMobile is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with iTopMobile. If not, see <http://www.gnu.org/licenses/>

package de.itomig.itoplib;

import java.util.ArrayList;
import de.itomig.itoplib.cmdb.ItopTicket;

public class ItopUtils {

  static ArrayList<ItopTicket> stored = new ArrayList<ItopTicket>();
  
  /**
   * removes repeating ItopTickets from a list (defined by same "ref" and same
   * "lastUpdate" string as the last from the last call)
   * not persistent over restart of service ! TODO                 
   *                    
   * @param in
   * @return
   */
  protected static ArrayList<ItopTicket> removeRepeatingTickets(ArrayList<ItopTicket> in) {
    ArrayList<ItopTicket> out = new ArrayList<ItopTicket>();
    boolean foundDuplicate =false;
         
    if (in.isEmpty()) {
      // nothing to do in this case
      stored.clear();
      return in;
    }
    
    if (stored.isEmpty()) {
      // out = in
      // store in ->stored for later use
      for (int i=0; i<in.size(); i++) {
        stored.add(in.get(i));   // copy out list entries into stored list
      }
      return in;
    }
    
    // else: check for duplicates ( in(i)==stored(j) ) and remove them from out list
    for (int i=0; i<in.size(); i++) {
      // check for identical entries in stored -> then remove
      foundDuplicate = false;
      for (int j=0; j<stored.size(); j++)  {
        if ( in.get(i).getRef().equals(stored.get(j).getRef()) 
             && in.get(i).getLastUpdate().equals(stored.get(j).getLastUpdate())  ){
          // duplicate found, do not add to out list
          foundDuplicate = true;
          break;
        }
      }
      if (!foundDuplicate) {
        out.add(in.get(i));
      }
    }
    // out -> stored
    for (int i=0; i<out.size(); i++) {
      stored.add(out.get(i));   // copy out list entries into stored list
    }
    return out;

  }
  
}




Java Source Code List

de.itomig.itoplib.AboutActivity.java
de.itomig.itoplib.AddTaskActivity.java
de.itomig.itoplib.AlarmReceiver.java
de.itomig.itoplib.BackgroundCheck.java
de.itomig.itoplib.BootReceiver.java
de.itomig.itoplib.Cache.java
de.itomig.itoplib.DataConnection.java
de.itomig.itoplib.GetItopData.java
de.itomig.itoplib.GetItopJSON.java
de.itomig.itoplib.HelpdeskActivity.java
de.itomig.itoplib.IncidentActivity.java
de.itomig.itoplib.InternalTaskActivity.java
de.itomig.itoplib.ItopConfig.java
de.itomig.itoplib.ItopUtils.java
de.itomig.itoplib.MainActivity.java
de.itomig.itoplib.MyActivity.java
de.itomig.itoplib.PersonAndOrgsLookup.java
de.itomig.itoplib.Preferences.java
de.itomig.itoplib.SearchActivity.java
de.itomig.itoplib.TaskAdapter.java
de.itomig.itoplib.TaskDetailActivity.java
de.itomig.itoplib.TicketAdapter.java
de.itomig.itoplib.TicketDetailActivity.java
de.itomig.itoplib.cmdb.CMDBObject.java
de.itomig.itoplib.cmdb.InternalTask.java
de.itomig.itoplib.cmdb.ItopTicket.java
de.itomig.itoplib.cmdb.Organization.java
de.itomig.itoplib.cmdb.Person.java
de.itomig.itoplib.cmdb.XmlResult.java
de.itomig.itopmobile.ItopApplication.java
de.itomig.itopmobile.ItopMobileActivity.java