Showing posts with label Choice List. Show all posts
Showing posts with label Choice List. Show all posts

Monday 23 April 2018

Java Code to get choice value from Choice-lists in Object Stores

//Java Code to get choice value from Choice-lists in Object Stores

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ChoiceListSet;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;

public class GetChoiceListValues {
private static Connection conn = null;
public static Connection getCEConn(String ceURI)
{
try {

String userName ="userName";
String password ="password";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}

public static void getChoiceListValues() throws IOException{
String ceURI = null;
try{

    ceURI="http://localhost:9080/wsi/FNCEWS40MTOM/";
      conn = getCEConn(ceURI);
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain,"ObjectStore",null);
ChoiceListSet cls = objStore.get_ChoiceLists();
Iterator it = cls.iterator();
while(it.hasNext()){
com.filenet.api.admin.ChoiceList cl = (com.filenet.api.admin.ChoiceList) it.next();
com.filenet.api.collection.ChoiceList choicelis = cl.get_ChoiceValues();
Iterator choice_it = choicelis.iterator();
System.out.println(cl.get_DisplayName());
while(choice_it.hasNext()){
com.filenet.api.admin.Choice c = (com.filenet.api.admin.Choice) choice_it.next();
System.out.println(c.get_Name());
   
}

}
        System.out.println("Done");
}
    
  catch(Exception e){
e.printStackTrace();
}
}

public static void main(String[] args) throws IOException {
getChoiceListValues();
        }
}