raviaaaa 0 Newbie Poster
 HI All 
 my requiurement is:
I am getting list, list consists of follwing

id assetid name assstatusid seriescode matchedstring
10 1 ab 3 34 match1
11 2 some 3 67 mat
12 3 name 3 678 matchstring
12 3 name 3 678 matchstringone
12 3 name 3 678 matchstri
12 3 name 3 678 sonemat

in the above code i want to display in such way that
here id 12 is repeating but matchedstring column having different values i want to display in
o/p:
12 3 name 3 678 matchstring, matchstringone, matchstri, sonemat

can you please let me know how to solve this based on above code iam using JDK 14 and Tomcat 4

line no  33 i am getting list 
line no 94 i am getting one record  
line no 68 and 121 i am checking whether id is already in assetclassmap and inforassetmap
if id already in map than i want to take previous values with  id stroed in map and 
previous matchedstring + current matchedstring 
ex: like this matchstring, matchstringone, matchstri, sonemat
please provide me the solution 

Regards
ravi



 public void parseDtoCollection(Collection dtos) { 



        for (Iterator i = dtos.iterator(); i.hasNext();) { 

            AssetDTO dto = (AssetDTO) i.next();


            AssetClass assetClass = findAssetClass(dto.assetClassId);


            AssetClassVersion assetClassVersion = createNewAssetClassVersion(dto);

            assetClass.addVersion(assetClassVersion);


            if (dto.id > 0) {

                InformationAsset infoAsset =
                        findInformationAsset(dto.id, assetClass);
                InformationAssetVersion infoAssetVersion =
                        createInfoAssetVersion(dto);
                infoAsset.setBusinessArea(createBusinessArea(dto));
                infoAsset.addVersion(infoAssetVersion);
                infoAsset.setAssetClass(assetClass);




            }
        }
    }


    private AssetClass findAssetClass(int id) { 
        Integer oid = new Integer(id);


        AssetClass assetClass = (AssetClass) assetClassMap.get(oid);
        if(assetClassMap.containsKey(oid)){
            assetClassMap.put(oid, assetClass);

        }

        if (null == assetClass) {
            assetClass = getOJBFactory().getAssetClass();  
            assetClass.setOid(oid);

            assetClassMap.put(oid, assetClass);

            AssetClassAssets aca = getOJBFactory().getAssetClassAssets();
            aca.setAssetClass(assetClass);
            assetHolder.put(oid,  aca);

        }

        return assetClass;      
    }


    private AssetClassVersion createNewAssetClassVersion(AssetDTO dto) {




        AssetClassVersion ac = new AssetClassVersion();


        ac.setVersion(new Integer(dto.assetClassVersion));  

        ac.setName(dto.assetClassName);

        ac.setDescription(dto.assetClassDescription);
        ac.setStatus(Status.findById(dto.assetClassStatusId));
        ac.setModifyDate(dto.assetClassModifyDate);
        ac.setEffectiveDate(dto.assetClassEffectiveDate);
        ac.setSeriesCode(dto.seriesCode);  

        ac.setMatchedString(dto.matchedString);



        return ac;

    }   


    private InformationAsset findInformationAsset(int id, AssetClass assetClass) {
        Integer oid = new Integer(id);
        InformationAsset infoAsset = (InformationAsset)infoAssetMap.get(oid);


        if (null == infoAsset) {
            infoAsset = getOJBFactory().getInformationAsset();
            infoAsset.setOid(oid);
            infoAsset.setAssetClass(assetClass); 
            infoAssetMap.put(oid, infoAsset);
        }

        return infoAsset;       
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.