Showing posts with label IBM Case Manager API. Show all posts
Showing posts with label IBM Case Manager API. Show all posts

Thursday, 20 November 2014

Add Case Comments in Case Client (IBM Case Manager API)

//Add Case Comments in Case Client (IBM Case Manager API)

public void addCaseCommentInHistory() throws Exception {
            String caseFolderGUID = //GUID of Case Folder
            String comment = "Hi"
            CaseMgmtContext oldCmc = null;
            log.info("Inside [WorkFlowHoldUnholdServices]addCaseComment():.............");
            ICMManager icmManager=new ICMManager();
            Connection conn=null;
            DomainReference domainRef=null;
            ObjectStoreReference osRef=null;
            Folder folder=null;
            try{
                conn=// Establish Connection

                if(conn!=null){
                    domainRef=ICMManager.getDomainReference(conn);
                    if(domainRef!=null){
                        osRef=ICMManager.getTargetOSReference(domainRef, fnObjectStoreName);
                        if(osRef!=null){
                            // retrieve case folder
                            folder = Factory.Folder.fetchInstance(osRef.getFetchlessCEObject(), caseFolderGUID, null);
                            // retrieve case using GUID
                            Id folderGUID = folder.get_Id();
                            Case cs = Case.getFetchlessInstance(osRef, folderGUID);
                            cs.addCaseComment(CommentContext.CASE, comment);
                            cs.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
                            log.info("History updated in Case");
                           
                        }else{
                            log.info("History Not updated As Target OS Ref is NULL");
                        }
                    }   
                }       
            }catch (Exception e) {
                log.error("addCaseCommentInHistory(String, String) - exception:"+ e,e); //$NON-NLS-1$
                e.printStackTrace();               

            }                    
        }               
             




//for connection please click on below link

IBM Case Manager API (fetch P8Connection, Domain, Target Obbject Store)


  

Thursday, 13 November 2014

IBM Case Manager API (fetch P8Connection, Domain, Target Obbject Store)

//Establish ICM Connection

public static Connection getICMConnection(String uri,String userID,String password){
      
        try{
            //uri = "http://localhost:9080/wsi/FNCEWS40MTOM/";
            P8ConnectionCache connCache = new SimpleP8ConnectionCache();
            conn = connCache.getP8Connection(uri);
            log.info("ICM Connection: "+conn);
          
            Subject subject =   UserContext.createSubject(conn, userID, password, "FileNetP8WSI");
            uc = UserContext.get();
            uc.pushSubject(subject);
          
            origLocale = uc.getLocale();
            uc.setLocale(origLocale);
            origCmctx = CaseMgmtContext.set(new CaseMgmtContext(new SimpleVWSessionCache(), connCache));
        }catch(Exception ex){
            ex.printStackTrace();
            log.error("[ICMManager]getICMConnection():Exception found is :"+ex.getMessage());
        }
      
      
        return conn;
    }



//Domain References

public static DomainReference getDomainReference(Connection conn){
       
       
        try{
            Domain domain=Factory.Domain.fetchInstance(conn, null, null);
            log.info("[ICMManager]getDomainreference():Domain Name: "+domain.get_Name());
           
            domainReference=new DomainReference(domain);
        }catch(Exception ex){
            ex.printStackTrace();
            log.error("[ICMManager]getDomainreference():Exception found: "+ex,ex);
        }
        return domainReference;
       
    }


//Get Target Object Store

public static ObjectStoreReference getTargetOSReference(DomainReference domRef,String osName){
       
        try{
            targetObjectStoreReference=new ObjectStoreReference(domRef, osName);
            log.info("[ICMManager]getTargetOSReference():Target Object Store Reference: "+targetObjectStoreReference.toString());
        }catch(Exception ex){
            ex.printStackTrace();
            log.error("[ICMManager]getTargetOSReference():Exception found: "+ex,ex);
        }
        return targetObjectStoreReference;
       
    }


//Close ICM Connection

public static void closeICMObjects(){
        CaseMgmtContext.set(origCmctx);
        uc.setLocale(origLocale);
        uc.popSubject();
        targetObjectStoreReference=null;
        domainReference=null;
        conn=null;
       
    }