Create a New ChemTerm Field

    import com.im.commons.db.ddl.GenericColumnType
    
    // These imports are not necessary in 5.9 and later
    import com.im.commons.progress.*
    import com.im.df.api.capabilities.*
    import com.im.df.api.util.*;
    import com.im.df.api.ddl.*;
    import com.im.commons.db.ddl.*;
    import com.im.df.api.support.*;
    
    def ety = dataTree.rootVertex.entity
    ety.schema.lockable.withLock('Create a new CT field'){ envRW ->
        // In IJC 5.11 and earlier
        def Class[] req1 = [ DFFieldChemicalTermsCapability.class ]
        def nt = DIFUtilities.findFirstAppropriateNewType(ety.getFields().getNewTypes(), false, req1, new Class[0])
        nt.options.newDFItemNameSafe = "Atom Count"
        nt.options.formulaSync = "atomCount"
        nt.options.genericType = GenericColumnType.INTEGER
        nt.create(envRW)
        // End of 5.11 code
    
        // In IJC 5.12 and later
        // DFFields.createChemTermsField(ety, "atomCount", GenericColumnType.INTEGER, "atomCount()", envRW)
        // End of 5.12+ code
    }