Iterating thro collection and modifying

Hi,
Let me explain in brief what i'm trying to do.
i'm having a collection which has duplicate records in it.
Based on one of the field say id in each record i need to create a new collection which would have records with distinct id.
so i'm iterarating thro first collection, and creating a temporary List for new set of records. So i need to iterate thro that to check for duplicates.
I think i'm making it more complicated , and the code i have written doesnt work properly.
Can somebody help me in solving this issue. Thanks in advance.

Can you override equals appropriately? Then it's just a matter of:
Set < Record > uniques = new HashSet < Record > (originalCollection);Then again, could you have started with a set?

Similar Messages

  • How to find and modify  item in a nested array collection?

    Hi,
    would anybody know how to find and modify item in a nested
    array collection:
    private var ac:ArrayCollection = new ArrayCollection([
    {id:1,name:"A",children:[{id:4,name:"AA",children:[{id:8,name:"AAA"}]},{id:5,name:"AB"}]} ,
    {id:2,name:"B",children:[{id:6,name:"BA"},{id:7,name:"BB"}]},
    {id:3,name:"C"}
    Let's say I've got object {id:8, name:"X"} , how could I find
    item in a collection with the correspoding id property, get handle
    on it and update the name property of that object?
    I'm trying to use this as a dataprovider for a tree populated
    via CF and remoting....
    Thanks a lot for help!

    Thanks a lot for your help!
    In the meantime I've come up with a recursive version of the
    code.
    This works and replaces the item on any level deep:
    private function findInAC(ac:ArrayCollection):void{
    var iMatchValue:uint=8;
    for(var i:uint=0; i<ac.length; i++){
    if(ac
    .id == iMatchValue){
    ac.name = "NEW NAME";
    break;
    if(ac
    .children !=undefined){
    findInAC( new ArrayCollection(ac.children));
    However, if I use the array collection as a dataprovider for
    a tree and change it, the tree doesn't update, unless I collapse
    and reopen it.
    Any ideas how to fix it ?

  • Delete ContactRel entities of Account and modify Account collection at runtime

    HI Experts ,
    I have requirement to Search Account information and its related Contact relation on based of Email ID .I want to delete entities from Contact relation for particular criteria and modify the Account Entity .
    1. I have search account at IC agent for Email ID
         CALL METHOD fire_query
               EXPORTING
                 it_parameters       = lt_parameters  ----->  "Email = [email protected]"
                 iv_query_service    = query_service
               IMPORTING
                 er_bo_col           = bo_col -------------------> In this Collection -> Am getting One Account and Its 4 Relation Fig 1.1
                 ev_no_exact_matches = lv_no_exact_matches
               CHANGING
                 cv_query_type       = lv_query.
    FIG 1.1                                                                                                                        
    There is 13 Entities for BuilContactPersonRel  Fig 1.2
    Fig 1.2
    So my issue is i have to delete top 10 entities (BuilContactPersonRel) )where Contact Email is not Equal to Account Email ,  And i want to Update bo_col  with 3 remain entities as am passing this to Context node . I am looking for BOL logic to achieve this ...
    I just want to remove entity from bo_col not permanent from database .
    bo_col and ir_bo_col same....
    Regards,
    Rishi verma

    Thanks for replying...
    I want to explain more ..
    1. i want to search account on based of email id and when search done i am getting 13 entities for contact for that account .
    Account email id : [email protected]
    and there are 2 contact as shown below having same email id ..
    So i want to display only two of them contact having same email id as account having.
    2. ir_bo_col contain  account entity and in it relation have contact with its 13 entity , so i want to remove 11 entity from contact relation  and want to show only 2 in contact view ....
    I hope it clear to know more...
    I guess applying filter on ir_bo_col not work becuase it will add filter to Account entity not it relation (Contact) .
    Do have any idea ?
    Regards,
    Rishi

  • 6398 ERRORS Cache cluster is down, restart the cache cluster and Retry. Collection was modified; enumeration operation may not execute.

    Recently started getting these 6398 errors with SharePoint 2013 Single Farm and haven't been able to fix with any google results.  Everything seems to run fine.  They usually appear overnight.  Average 5-9 daily event logs.  See
    Errors below.
    Get-CacheHost
    always reports UP
    Have already tried: 
    -  Upgrading to AppFabric CU5
    -  Restart-Service AppFabricCachingService
    -  Clear Configuration Cache
    - habaneroconsulting Distributed Cache Bug
    - nobadthing Unexpected exception in feedcacheservice
    - mmman itgroove fixing the appfabric cache cluster
    - Microsoft unable to start appfabriccachingservice
    - dhasalprashantsharepoint lets-troubleshoot-sharepoint
    ...and many other readings.  (sorry I cant post links even though I verified my account 100 times)
    Errors:
    The Execute method of job definition Microsoft.Office.Server.UserProfiles.LMTRepopulationJob (ID 414cbbe9-cdb1-4f7a-beed-85fbfd8a10c7) threw an exception. More information is included below.
    Unexpected exception in FeedCacheService.IsRepopulationNeeded: Cache cluster is down, restart the cache cluster and Retry.
    The Execute method of job definition Microsoft.Office.Server.UserProfiles.LMTRepopulationJob (ID 414cbbe9-cdb1-4f7a-beed-85fbfd8a10c7) threw an exception. More information is included below.
    Unexpected exception in FeedCacheService.IsRepopulationNeeded: Connection to the server terminated,check if the cache host(s) is running .
    The Execute method of job definition Microsoft.SharePoint.Administration.SPProductVersionJobDefinition (ID 95aee52d-88a1-4355-b6b6-9d43d753414e) threw an exception. More information is included below.
    Collection was modified; enumeration operation may not execute.

    Hi,
    Please firstly go to Central Administration > Application Management > Manage Services on server, make sure the Distributed Cache service has been started on all servers.
    If you execute Get-CacheHost and Get-Cache in SharePoint 2013 Management Shell, is it return the expected information? If it returns the red error message, please refer to the article below to remove SPDistributedCacheServiceInstance and add SPDistributedCacheServiceInstance.:
    http://blogs.technet.com/b/saantil/archive/2013/03/31/distributed-cache-in-sharepoint-2013-quot-unexpected-exception-in-feedcacheservice-isrepopulationneeded-cache-cluster-is-down-restart-the-cache-cluster-and-retry-quot.aspx
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Search does not crawl new site collection and documents

    We have the following situation. We have two locations with different farms sharing the same databases (using AlwaysOn for the content databases). Everything works fine, the second site is also read-only while having the primary farm online. For existing
    databases the search crawler on the second site is able to crawl existing site collections.
    For new site collections created on the first farm the crawler on the first farm indexes the content proberly. The second farm though is not knowledgable of the content unless you force him to reiterate the content database. After this procedure the sites
    are available on the second site as well (showing them in the web browser), but the search farm still is not able to see the new site collection and data created within.
    Is there any additional iteration we have to go through making the crawler aware of the new structure / content ?
    Thanks in advance, Jens

    Nope.
    Change log wipes are real, that's how incremental crawls work in SharePoint.
    Site A is created and modified. Changes are mirrored to the second AG, content is added, logged in the changes log and then removed as the crawler on the primary farm indexes it.
    This continues until you make farm 2 aware of the changes. At that point farm 2 will look for any changes to the content in the change logs on the newly added sites. Which will be empty, or at least not contain any changes since the primary farm's last crawl.
    That explains why you don't get sites indexed properly when they are added but would explain why some content is indexed afterwards which i believe is the case?
    The second issue you'll find is that the crawls won't synchronise. Assuming continuous crawls kicking off at the same time you'll end up in a race between the two. If the primary farm is quicker then the second farm will continuously fall behind then catch
    up and go ahead of the primary indexing process, but if the secondary farm is faster then it'll race off into the distance and then any changes that occur between the secondary farm indexing a site and the primary indexing the site will be lost on the secondary
    farm.
    You'll have to run full crawls. Unless MS have done a lot of work on the supporting infrastructure incremental or continuous crawls of AOAGs won't work well.

  • Looping through Collection and getting ConcurrentModificationException

    I'm trying to loop through a collection to delete some objects referenced by that collection but keep coming up against a ConcurrentModificationException.
    BwView view = svci.getViewsHandler().find("Lists");
                  Collection<BwSubscription> subarr = new TreeSet<BwSubscription>();
                  subarr = svci.getSubscriptionsHandler().getAll();  
                  if (subarr == null) {
                       logger.info("Its not working");
                  for (BwSubscription sub: subarr) {
                       logger.info("Removing subs " + sub);
                       svci.beginTransaction();
                       svci.getSubscriptionsHandler().delete(sub);
                       logger.info("Deleting calendars :" + sub);
                       svci.endTransaction();
                 The loop is allowing me to delete the first entry but then fails with the exception.
    I have tried with a generic loop but this doesn't initialise the sub entity so the loop fails and is ignored leading to problems later in the code.
    BwView view = svci.getViewsHandler().find("Lists");
                  BwSubscription[] subarr = (BwSubscription[])view.getSubscriptions().toArray(new BwSubscription []{});
                  if (subarr == null) {
                       logger.info("Its not working");
                  for (int i=subarr.length - 1; i>=0; i--) {
                       sub = subarr;
                   logger.info("Removing subs " + sub);
                   svci.beginTransaction();
                   svci.getSubscriptionsHandler().delete(sub);
                   logger.info("Deleting calendars :" + sub);
                   svci.endTransaction();
    Sub is either not initialised or gets initialised as 0 causing an ArrayIndexOutofBoundsException. I'd be grateful for some advice on getting the code to loop correctly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    While iterating over a collection (using its iterator), a ConcurrentModificationException will be thrown if the collection is modified, except if it is modified using the iterator itself.. The enhanched for-loop you're using is iterating over the collection by implicitly using an Iterator. To do what you want, make the Iterator explicit (change the enhanced for-loop to a while loop) and then use iterator.remove().

  • Created By field and Modified By field and People Picker field values are hidden to other Users

    Hi,
    We have a strange permission issue in one of the MOSS-2007 server farm. The users are not able to see each other name in "created by" and "modified by" column value in lists and libraries. For example if "User A" create an item in a list then if "User B" opens that item then he cannot see "created by" and "modified by" column value and vice-versa. But they can see their name in "created by" and "modified by" column but not others. Both the users has contribute access to that list, so both can edit each other data but cannot see each other name.
    This become a bigger issue, if any of tje list has people picker column, then thay cannot see that column value(if that column value does not his/her own name). This means this column value will be always empty for "user A" when that peopel picker value is anything other than "User A". This happens for all the lists and libraries. 
    Even "User A" and "User B" are owner of that site, it behaves the same. But site collection administrator can see  "created by" and "modified by" for all items for all the users.
    It seems very strange for me. any help on this will be appreciated.
    Thanks in advance,
    Sanban

    Hi,
    You can try to create a new standard view, then select “created by” and “modified by” column under columns, next apply this view, finally check the effect.
    Did you customize the permissions of the list or document library? Did you customize the permission of the item? For example, break the permission inheritance form its parents. If so, try to inherit permission from its parents, after that create a new standard view according to the steps above, then check the effect.
    By default, permissions on lists, libraries, folders, items, and documents are inherited from the parent site. However, you can break this inheritance for any securable object at a lower level in the hierarchy by editing the permissions on that securable object (that is, creating a unique permission assignment) . For example, you can edit the permissions for a document library, which breaks the permissions inheritance from the site.
    You can also try to create a new document library, then create a new document with user A, after that log into with user B, check the effect.
    For more information about  SharePoint : page level permissions, please refer to the following article:
    SharePoint : page level permissions
    http://blogs.msdn.com/brettrobinson/archive/2009/04/24/sharepoint-page-level-permissions.aspx
    For more information about control access to sites, please look into the following articles:
    About controlling access to sites and site content
    http://office.microsoft.com/en-us/sharepointtechnology/HA101001441033.aspx
    Permission levels and permissions
    http://office.microsoft.com/en-us/sharepointtechnology/HA101001491033.aspx
    For more information about how to create a view, please refer to the following article:
    Create or change a view
    http://office.microsoft.com/en-us/help/HA100215771033.aspx
    Hope this helps.
    Rock Wang
    Rock Wang– MSFT

  • How to use Bulk Collect and Forall

    Hi all,
    We are on Oracle 10g. I have a requirement to read from table A and then for each record in table A, find matching rows in table B and then write the identified information in table B to the target table (table C). In the past, I had used two ‘cursor for loops’ to achieve that. To make the new procedure, more efficient, I would like to learn to use ‘bulk collect’ and ‘forall’.
    Here is what I have so far:
    DECLARE
    TYPE employee_array IS TABLE OF EMPLOYEES%ROWTYPE;
    employee_data  employee_array;
    TYPE job_history_array IS TABLE OF JOB_HISTORY%ROWTYPE;
    Job_history_data   job_history_array;
    BatchSize CONSTANT POSITIVE := 5;
    -- Read from File A
    CURSOR c_get_employees IS
             SELECT  Employee_id,
                       first_name,
                       last_name,
                       hire_date,
                       job_id
              FROM EMPLOYEES;
    -- Read from File B based on employee ID in File A
    CURSOR c_get_job_history (p_employee_id number) IS
             select start_date,
                      end_date,
                      job_id,
                      department_id
             FROM JOB_HISTORY
             WHERE employee_id = p_employee_id;
    BEGIN
        OPEN c_get_employees;
        LOOP
            FETCH c_get_employees BULK COLLECT INTO employee_data.employee_id.LAST,
                                                                              employee_data.first_name.LAST,
                                                                              employee_data.last_name.LAST,
                                                                              employee_data.hire_date.LAST,
                                                                              employee_data.job_id.LAST
             LIMIT BatchSize;
            FORALL i in 1.. employee_data.COUNT
                    Open c_get_job_history (employee_data(i).employee_id);
                    FETCH c_get_job_history BULKCOLLECT INTO job_history_array LIMIT BatchSize;
                             FORALL k in 1.. Job_history_data.COUNT LOOP
                                            -- insert into FILE C
                                              INSERT INTO MY_TEST(employee_id, first_name, last_name, hire_date, job_id)
                                                                values (job_history_array(k).employee_id, job_history_array(k).first_name,
                                                                          job_history_array(k).last_name, job_history_array(k).hire_date,
                                                                          job_history_array(k).job_id);
                                             EXIT WHEN job_ history_data.count < BatchSize                        
                             END LOOP;                          
                             CLOSE c_get_job_history;                          
                     EXIT WHEN employee_data.COUNT < BatchSize;
           END LOOP;
            COMMIT;
            CLOSE c_get_employees;
    END;
                     When I run this script, I get
    [Error] Execution (47: 17): ORA-06550: line 47, column 17:
    PLS-00103: Encountered the symbol "OPEN" when expecting one of the following:
       . ( * @ % & - + / at mod remainder rem select update with
       <an exponent (**)> delete insert || execute multiset save
       merge
    ORA-06550: line 48, column 17:
    PLS-00103: Encountered the symbol "FETCH" when expecting one of the following:
       begin function package pragma procedure subtype type use
       <an identifier> <a double-quoted delimited-identifier> form
       current cursorWhat is the best way to code this? Once, I learn how to do this, I apply the knowledge to the real application in which file A would have around 200 rows and file B would have hundreds of thousands of rows.
    Thank you for your guidance,
    Seyed

    Hello BlueShadow,
    Following your advice, I modified a stored procedure that initially was using two cursor for loops to read from tables A and B to write to table C to use instead something like your suggestion listed below:
    INSERT INTO tableC
    SELECT …
    FROM tableA JOIN tableB on (join condition).I tried this change on a procedure writing to tableC with keys disabled. I will try this against the real table that has primary key and indexes and report the result later.
    Thank you very much,
    Seyed

  • Sharepoint Site User name,created by and Modified field issue

    I am being admin of sharepoint site . I have added a user to my sharepoint site from people and groups(Site Action-->Site Settings-->Users and Permissions-->People and Groups). So Now "Created by" and "Modified by" field should
    show My login name(display name) in those fields Right ? But In those field it is showing  user name whom I have added to my sharepoint site. I have added user to my site so My display name should be their  in "created by" and "modified
    by" field. Facing this issue on PROD and UAT.

    Hi Rajshekhar,
    Actually, the users have been added to the site groups or granted with permissions in Site Permissions, then the users will be added to the User Information List of the site collection.
    I recommend to check if the users you added have already been listed in the User Information List.
    If yes, then the Created By and Modified By fields have already been filled with other values.
    Created By field will show the user name who is the first one to add the user to the site and the Modified By field will show the last one who edit the My Settings of that user.
    To access the User Information List, you can type the URL like this:
    http://server/_catalogs/users/detail.aspx.
    Best regards,
    Victoria
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Interface suggestion for Collections and Presets windows

    Hi,
    I would like to suggest you an improving of the left part of the main screen. I wish - maybe one day - that you can modify the management of collections, presets, etc...
    When you have a lot of Presets and Collections, and we need to switch between them asap, it's very difficult to scroll all of the list (...the scrollbar is also on the left ! Strange idea...)
    The best idea will be to redraw the actual design : in that case, the title bar and their "contextual menu" still always visible.
    A simple mouse clic would allow to uncollapse Collection or Presets lists very quickly on the top. All titles won't be never hidden.
    Please, take a look at my screen capture (my suggestion) for a better explanation.
    Thanx.

    Hi thanks for help,
    The thing is, I need all the data if the user wants to see Details, then I will need to display all rows. On the other hand, Sybase doesnt have the stdev function, I wrote a query that calculates stdev, but I will need to run the query once for each person, because it looks like this:
    select
    (SQRT((sum((MyFieldName - (select convert(dec(10,2),avg(MyFieldName))
    From MyTableNameWhere
    MyWhereCriteria and
    abs(MyFieldName)>0))*(MyFieldName - (select convert(dec(10,2),avg(MyFieldName))
    From MyTableNameWhere MyWhereCriteria and abs(MyFieldName)>0)))) /(select count(MyFieldName)-1
    from MyTableNamewhere MyWhereCriteria))) 'StDev'
    from MyTableName WHERE MyWhereCriteria
    where MyWhereCriteria would be
    where date = '07/03/2009' and name = 'John'
    so some of the subqueries return multiple rows which is a problem..
    I got error saing:
    [Error] Script lines: 13-30 ------------------------
    Subquery returned more than 1 value. This is illegal when the subquery follows =, !=, <, <= , >, >=, or when the subquery is used as an expression.
    Msg: 512, Level: 16, State: 1

  • Empty Collections and Empty Tags

    It seems that empty collections from a cast or cursor result in an empty tag. For example, the following sql:select work.work_id medlineid,
    cursor(
    select
    databankname,
    db.accessionnumberlist_ref.accessionnumberlist accessionnumberlist
    from table(dbl.databanks) db
    order by databankname) databanklist,
    cast( multiset (
    select chemical_t(
    wrkchm.cas_registry_number,
    wrkchm.term)
    from work_chemicals wrkchm
    where wrkchm.work_id=work.work_id
    order by wrkchm.term) as chemicals_t) chemicallist
    from
    works work,
    databanklist_t_v dbl
    where
    work.work_id = 96264942
    and work.work_id = dbl.work_id(+)results in the following XML:<medlinecitationset>
    <medlinecitation num="1">
    <medlineid>96264942</medlineid>
    <databanklist/>
    <chemicallist/>
    </medlinecitation>
    </medlinecitationset>Is there a way to not have these empty tags appear?
    Thanks! -- John.
    null

    David, this is about understanding the use of, and differencies between tags and collections. This is a bit hard for many new users.
    First of all searching for collections and tags can *not* be done simultaneously. You can either work with one collection only, or you can search for pictures with one or more tags.
    Next collections should be used as either temporary work sets or for special occasions like specific vacations, trips or birthdays, e.g. "Anna 5 years". You say you have a collection named "Churches". I think would have made a TAG called "Churches" instead, because a tag is for general searches that can be combined. On the other hand I might have made a collection called "Church visits July 2005" or "Summer vacation 2005" or the like.
    Another difference is that pictures in a collection can be sorted manually by drag & drop, while pictures found via tags always are shown in the order chosen in the Photo Browser Arrangement box shown bottom left in the Organizer.

  • How to open and modify a internet service.

    I want to modify Internet Service PZ02. I checked in SICf, it is listed under bc/gui/sap/its and is also activated.
    But when i go to SE80 and search for it in Internet Service, i get a message saying "Service PZ18 does not exist, create object? "
    How do i open, get access to code of pz18 and modify it
    Thanks
    Sharath

    Chris-
    Thanks for the reply.
    How do i create the ITS service (service file, template, theme etc..) out of the dynamically generated HR service PZ02.
    Pleae let me know if the following steps are correct
    1. In SE80, Choose Internet service and enter a name like zpz02.
    2. In the pop-up for transaction code enter pz02. Check the box for ITS mixed mode
    3. Then Right click in zpz02, select create->template->
    assign theme=99,
    program number-SAPMPZ02
    screen number=1000
    generating style=webgui
    ( The above informtaion was found out in the following way: go to se93 -> enter pz02 as the transaction code ->
    click display.
    When i did that it displayed the following info
    program : SAPMPZ02
    selection screen: 1000 )
    When i click on save it says that the screen 1000 does not exist in the program SAPMPZ02.
    But from the info that i got from the SE93 it looks like the screen number is 1000??
    What is the mistake ?? Is the approach wrong
    Help will be really appreciated
    Sharath

  • Issue with the functions "add matching sets" and "modify matching sets"

    Hi,
    Though 'None' access permission is set for the functions 'Add Matching Sets' and 'Modify Matching Sets', they are accessible.
    Is this a bug with the tool? or am I missing something?
    Thanks in advance,
    Madan

    sorry, missed the version details.
    I'm using MDM 5.5 SP6.

  • How do I import collections and previous editing into a new copy of Lightroom 5?

    I've recently installed Lightroom 5 on a new computer.  I chose not to install my old Lightroom 3.6 on the new computer, but imported the catalog and photo folders from external drives into Lightroom.  My collections and editing did not appear to have been imported along with the catalog and photos.  What to do??

    In LR5, File->Open Catalog and then point to the location of your LR 3.6 catalog

  • I have made a burn folder with photos exported from I-photo.  It now shows in information, that the date is created and modified is different from the original digitized date.  How can I get the original date to show in the info from Finder?

    I have made a burn folder with photos exported from I-photo.  It now shows in information, that the date  created and modified is different from the original digitized date.  How can I get the original date to show in the info from Finder?

    The Finder reports File information. The date and time of the photo are in the Photo's Exif metadata. The Finder has no awareness of this. All photos apps on any system do.
    Regards
    TD

Maybe you are looking for