CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    2

    how to export the data in file using java

    I need to export the values in 4 column.values for 3 columns are populating properly. I am having trouble with 4th column which is organization column.it is multivalued column.i.e.: it has multiple values.

    I have tried to convert from object to String for organization column but didnt help.

    Please see the code below:

    String appname = "abc";
    String path = "//home/exportfile//";
    String filename = path+"ApplicationExport-"+appname+".txt";
    String ret = "false";

    QueryOptions ops = new QueryOptions();
    Filter [] filters = new Filter[1];
    filters[0] = Filter.eq("application.name", appname);
    ops.add(filters);

    List props = new ArrayList();
    props.add("identity.name");

    //Do search
    Iterator it = context.search(Link.class, ops, props);

    //Build file and export header row
    BufferedWriter out = new BufferedWriter(new FileWriter(filename));
    out.write("Name,UserName,WorkforceID,organization");
    out.newLine();

    //Iterate Search Results
    if (it!=null)
    {
    while (it.hasNext()) {

    //Get link and create object
    Object [] record = it.next();
    String identityName = (String) record[0];
    Identity user = (Identity) context.getObject(Identity.class, identityName);

    //Get Identity attributes for export
    String workforceid = (String) user.getAttribute("workforceID");

    //Get application attributes for export
    String userid="";

    List links = user.getLinks();
    if (links!=null)
    {
    Iterator lit = links.iterator();
    while (lit.hasNext())
    {
    Link l = lit.next();
    String lname = l.getApplicationName();
    if (lname.equalsIgnoreCase(appname))
    {
    userid = (String) l.getAttribute("User Name");
    List orgList = l.getAttribute("Organization");

    }
    }
    }

    //Output file
    out.write(identityName+","+userid+","+workforceid+","+org);
    out.newLine();
    out.flush();
    }
    ret="true";
    }
    //Close file and return
    out.close();
    return ret;

    orgList is arraylist.that means..there may be multiple organization value for the same users.
    so,output should be like this,

    Name,UserName,WorkforceID,organization
    thomas,thomas01,123,healthcare
    thomas,thomas01,123,finance

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: how to export the data in file using java

    Please use code tags when posting code

    orgList is arraylist.
    Your code is outputting 'org' not 'orgList'.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured