Friday, February 26, 2021

FileNet API - Creating a new Document Class using Java CE API

    Creating a new Class

       This code will create a Document sub Class in a Class, The class which we give in                        fetchInstance will become a super class for the newly created class

    Connection connection = // get the connection object from here

            Subject subject = UserContext.createSubject(connection, "******", "******", null);

            UserContext.get().pushSubject(subject);

            Domain domain = Factory.Domain.fetchInstance(connection, null, null);

            ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "your domain name", null);

            String className = "your new class name";

            ClassDefinition cd = Factory.ClassDefinition.fetchInstance(os, "your main class name",null);

            //com.filenet.api.admin.ClassDefinition

            System.out.println(cd.get_DisplayName());

            ClassDefinition subClassDef =  cd.createSubclass();

            LocalizedString localstr = Factory.LocalizedString.createInstance();

            localstr.set_LocalizedText(className);

            localstr.set_LocaleName(os.get_LocaleName());

            subClassDef.set_DisplayNames(Factory.LocalizedString.createList());

            subClassDef.get_DisplayNames().add(localstr);

            subClassDef.set_SymbolicName("symbolicname_"+ className.replace(" ", ""));

            subClassDef.set_DescriptiveTexts(Factory.LocalizedString.createList());

            subClassDef.get_DescriptiveTexts().add(localstr);

            subClassDef.save(RefreshMode.REFRESH);

No comments:

Post a Comment