Generate classes

When you create processes or data Universe tables and that you develop in Java on these items, you must manipulate the system name of fields. But what is the system name of these fields and their types?

The principle is to simply generate for each resource model (IResourceDefinition) a classe (wrapper) for the IWorkflowInstances with :

  • Static variables with the system names of all the properties of the model
  • Getters and setters for each model property (with javadoc)
  • For each property that manage a list, you will also find an ENUM with the values of the list (only for internal lists of course)

Generate interfaces

At the top right of the studio home page, you will find a configuration button (gear) with a “Classes generation” menu: Classe generation button Classe generation button

In the screen, it has 2 options :

  • Generate base classes: class that you can simply use (it is forbidden to change them manually)
  • Generate custom classes: class that extends the base class and you can change
Note

Since customizable classes are mandatory, you must generate the two classes the first time.

This will provide you a zip file containing all the classes of your projects.

Info

Only applications with a configured package in the studio (Project -> Properties -> Development -> SDK Development -> Package name : “com.axemble.vdoc.generatesdkresource.myproject”) will be generated.

If a package / class / method name is not suitable, it can be modified by going to the level of the element concerned ( such as a field), in the ‘SDK Development’ section: a field will be present in order to modify the name.

Generated classes details

Package structure

Classes generation is organized into sub-package as follows:

Sub-package Fonction
Customizable classes (you must alter these classes and not the base classes.)
generated The base classes that include all fields with their setter and getter methods (don’t modify these classes)
backend This class has the same role as the BaseResourceDefinition (editable)
frontend This class has the same role as the BaseDocumentExtention (editable)
dynamictables A sub-package for dynamic table classes.

UML Diagram of generated classes

In the diagram MyResource could be a process, a dynamic table or a data universe table.

Package Declaration Classes diagram Package Declaration Classes diagram

Front-end vs Back-end

If the resource is an instance of ProcessResource then a Front-end instance is created else a Back-end instance is created.

public static MyRessource getInstance(IResource resource){
        try{
        if(resource instanceof ProcessResource){
        return MyRessourceFrontend.class.getConstructor(IResource.class ).newInstance(resource);
        }
        return MyRessourceBackend.class.getConstructor(IResource.class ).newInstance(resource);
        }catch(Exception e){
        throw new VDocException("Error running getInstance",e);
        }
        }

Exemple of generated classes

In the figure below, we can see the result of generated classes from an application containing :

  • A group of processes with:
    • A dynamic table: DynTable.
    • Two processes: ProcessX and ProcessY.
  • A data universe with:
    • Two tables: TableX and TableY.

package Zip package Zip

Info

The base classes (in red) are in the generated package and they must not be modified.

Code exemple :

Dossier dossier=Dossier.getInstance(getStorageResource());
        IUser addressee=dossier.getAddressee();
        if(addressee!=null&&addressee.equals(getDirectoryModule().getLoggedOnUser())){
        Dossier parent=dossier.getDossierParent();
        // some code
        }

Alias

If a package / class / method name does not suit you, you can go to the level of concern element to modify its alias.

Alias is available for :

  • Group of processes: Application -> Group of processes -> Properties -> SDK Development -> Alias : mygroupofprocesses.
  • Process: Application -> Group of processes -> Process -> Properties -> SDK Development -> Alias : myprocess.
  • Process field: Application -> Group of processes -> Fields -> Field properties -> SDK Development -> Method alias (simple value) : myfield
  • Dynamic table: Application -> Group of processes -> Dynamic tables -> Properties -> SDK Development -> Alias : mydynamictable.
  • Dynamic table field: Application -> Group of processes -> Dynamic tables -> Columns -> Field properties -> SDK Development -> Method alias (simple value) : mydynamictablefield.
  • Data universe: Application -> Data stockroom -> Properties -> Development -> SDK Development -> Alias : mydatastockroom.
  • Data universe table: Application -> Data stockroom -> Table -> Properties -> SDK Development -> Alias : mytable.
  • Table field: Application -> Data stockroom -> Table -> Columns of the storage table -> Field properties -> SDK Development -> Method alias (simple value) : myfield

For example: to renamed “ProcessX” by “ProcessABC”, you just have to change the alias of that process by following the path describes at point 2 (Process).

Handling generated base classes

Example for a process

Example of a generated process class

package com.axemble.vdoc.generatedsdkresources.myapp.mygroupofprocess.generated;

/**
 * Source generated on 04/11/2014
 * @author vdoc
 * Don't update this auto-generated source !
 */

public abstract class GeneratedMyProcess extends BaseSDKExtension {
    public static final String FIELD_sys_Title = "sys_Title";

    public String getTitle() {
        return (String) workflowInstance.getValue(FIELD_sys_Title);
    }

    public void setTitle(String newValue) {
        workflowInstance.setValue(FIELD_sys_Title, newValue);
    }
}

/****************************************************************************************/

package com.axemble.vdoc.generatedsdkresources.projetdu.mygroupofproccess;

        import com.axemble.vdp.ui.core.document.extensions.IGenerated;
        import com.axemble.vdoc.generatedsdkresources.myapp.mygroupofproccess.MyProcess;
        import com.axemble.vdoc.generatedsdkresources.myapp.mygroupofproccess.generated.GeneratedMyProcess;
        import com.axemble.vdoc.sdk.interfaces.IWorkflowInstance;

/**
 * Source generated on 04/11/2014
 * @author vdoc
 * You can add custom method in this auto-generated source !
 */
public abstract class MyProcess extends GeneratedMyProcess implements IGenerated {
    protected MyProcess(IWorkflowInstance workflowInstance) {
        super(workflowInstance);
    }
}

    public static IProject getProject() {
        return (IProject) ProtocolURIHelper.getResource("uril://vdoc/project/DefaultOrganization/MyApp");
    }

    public static ICatalog getCatalog() {
        return (ICatalog) ProtocolURIHelper.getResource("uril://vdoc/catalog/DefaultOrganization/MyApp/MyGroupofprocess:0");
    }

    public static MyProcess createInstance(IContext iContext, IWorkflow iWorkflow, String reference, String label) throws WorkflowModuleException {
        return getInstance(Modules.getWorkflowModule().createWorkflowInstance(iContext, iWorkflow, reference, label));
    }    

Example of using a generated process class

import com.axemble.vdoc.generatedsdkresources.projetdu.mygroupofprocess.MyProcess;

IProject myProject=MyProcess.getProject();
        IOrganization myOrganization=MyProcess.getProject().getOrganization();
        Collection<?extends IGroup> allgroup=MyProcess.getProject().getOrganization().getGroups();

        ICatalog myCatalog=MyProcess.getCatalog();
        IResourceDefinition myResourceDefinition=MyProcess.getDefinition()

        IWorkflow workflow1=workflowmodule.getWorkflow(sysadminContext,mycatalog,PROCESS_VERSION_NAME);
        MyProcess myresource=MyProcess.createInstance(sysadminContext,workflow1,null,"PROCESS GENERATED");

        myresource.setName("My process name");

        myresource.save(sysadminContext);

Example for a Dynamic table

Example of a generated dynamic table class

package com.axemble.vdoc.generatedsdkresources.myapp.mygroupofprocesses.dynamictables.generated;

public abstract class GeneratedMyDynamicTable extends BaseSDKExtension {
    public static final String FIELD_DTCarModel = "TDCarModel";

    public String getDT_CarModel() {
        return (String) resource.getValue(FIELD_DTCarModel);
    }

    public void setDTCarModel(String newValue) {
        resource.setValue(FIELD_DTCarModel, newValue);
    }
}

/**********************************************************************/

package com.axemble.vdoc.generatedsdkresources.projetdu.mygroupofprocesses.dynamictables;

        import com.axemble.vdoc.sdk.interfaces.IResource;
        import com.axemble.vdp.ui.core.document.extensions.IGenerated;
        import com.axemble.vdoc.generatedsdkresources.projetdu.groupedeprocessusauto.dynamictables.TabDynAuto;
        import com.axemble.vdoc.generatedsdkresources.projetdu.groupedeprocessusauto.dynamictables.generated.GeneratedMyDynamicTable;


/**
 * Source generated on 04/11/2014
 * @author vdoc
 * You can add custom method in this auto-generated source !
 */
public abstract class MyDynamicTable extends GeneratedMyDynamicTable implements IGenerated {

    protected MyDynamicTable(IResource resource) {
        super(resource);
    }
}

Example of using a generated dynamic table class

MyProcess myprocessresource=MyProcess.createInstance(sysadminContext,workflow1,null,"PROCESS GENERATED DYNAMIC TABLE ");
//début gestion du tableau dynamique avec  les classes générée
        MyDynamicTable myLinkedResource=myresource.addNewMyDynamicTable();

        myLinkedResource.setTDDate(new Date());

        myLinkedResource.setTDDonneePrincipale(dossierstorageresource);
        myLinkedResource.setTDElementExterne(velo);
        myLinkedResource.setTDGroupePrincipal(mygroup);
        myLinkedResource.setTDListeAuto("toyota");
        myLinkedResource.setTDLocalisationPrincipale(localisation1);
        myLinkedResource.setTDMonBlob(myBlob);
        myLinkedResource.setTDMonBool(new Boolean(true));
        myLinkedResource.setTDMonEntier(MY_INTEGER);
        myLinkedResource.setTDMonMap(myMap);
        myLinkedResource.setTDMonNombreDoubl(MY_DOUBLE_NUMBER);
        myLinkedResource.setTDNombreDecimal(MY_DECIMAL);
        myLinkedResource.setTDMonDocumentDeProcessus(dummyWorkflowInstance2);
        myLinkedResource.setTDNombreGrdPrecision(MY_BIGDECIMAL);
        myLinkedResource.setTDNomDuTableauDynamique("My dynamic table name");
        myLinkedResource.setTDOrganisationPrincipale(organization2);
        myLinkedResource.setTDPeriodeDuProjet(new Period(new Date(),new Date()));
        myLinkedResource.setTDResponsableProjet(user_mail3);
        myLinkedResource.save(sysadminContext);
        myprocessresource.save(sysadminContext);

Example for a Data universe

Example of a generated data universe class:

package com.axemble.vdoc.generatedsdkresources.myapp.mydatastockroom.generated;

public abstract class GeneratedMyTable extends BaseSDKExtension {

    public static final String FIELD_sys_Title = "sys_Title";
    public static final String FIELD_Name = "Name";

    public String getTitle() {
        return (String) resource.getValue(FIELD_sys_Title);
    }

    public void setTitle(String newValue) {
        resource.setValue(FIELD_sys_Title, newValue);
    }

    public String getName() {
        return (String) resource.getValue(FIELD_Name);
    }

    /**
     * IProperty: Name<br/>
     * - Label : Name<br/>
     * - Description : <br/>
     * - Type param :String<br/>
     */
    public void setName(String newValue) {
        resource.setValue(FIELD_Name, newValue);
    }

    public static IProject getProject() {
        return (IProject) ProtocolURIHelper.getResource("uril://vdoc/project/DefaultOrganization/myApp");
    }

    public static ICatalog getCatalog() {
        return (ICatalog) ProtocolURIHelper.getResource("uril://vdoc/catalog/DefaultOrganization/myApp/MyDataStockroom:4");
    }

    public static IResourceDefinition getDefinition() {
        return (IResourceDefinition) ProtocolURIHelper.getResource("uril://vdoc/resourceDefinition/DefaultOrganization/myApp/MyDataStockroom:4/MyTable");
    }
}
/********************************************************************/
    
package com.axemble.vdoc.generatedsdkresources.myapp.mydatastockroom;

        import com.axemble.vdoc.generatedsdkresources.projetdu.reservoirprojet.generated.GeneratedProject;
        import com.axemble.vdoc.sdk.interfaces.IResource;
        import com.axemble.vdp.ui.core.document.extensions.IGenerated;

/**
 * Source generated on 04/11/20xx
 * @author vdoc
 * You can add custom method in this auto-generated source !
 */
public abstract class MyTable extends GeneratedMyTable implements IGenerated {

    protected MyTable(IResource resource) {
        super(resource);
    }
}    

Example of how to use a generated data universe class

The following example shows an agent manipulating data universe by creating a client record with 3 associated file records on a secondary data universe field and with many manipulations on different field types.

package Data Stock Form package Data Stock Form

package com.axemble.vdoc.generatedsdkresources.agents;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.axemble.vdoc.generatedsdkresources.appdu.mydatastockroom.File;
import com.axemble.vdoc.generatedsdkresources.appdu.mydatastockroom.Client;
import com.axemble.vdoc.sdk.Modules;
import com.axemble.vdoc.sdk.agent.base.BaseAgent;
import com.axemble.vdoc.sdk.exceptions.SDKException;
import com.axemble.vdoc.sdk.interfaces.IContext;
import com.axemble.vdoc.sdk.interfaces.IGroup;
import com.axemble.vdoc.sdk.interfaces.ILocalization;
import com.axemble.vdoc.sdk.interfaces.IOrganization;
import com.axemble.vdoc.sdk.interfaces.IResourceDefinition;
import com.axemble.vdoc.sdk.interfaces.IStorageResource;
import com.axemble.vdoc.sdk.interfaces.IUser;
import com.axemble.vdoc.sdk.interfaces.IViewController;
import com.axemble.vdoc.sdk.modules.IDirectoryModule;
import com.axemble.vdoc.sdk.modules.IWorkflowModule;
import com.axemble.vdoc.sdk.structs.ExternalElement;
import com.axemble.vdoc.sdk.structs.Period;
import com.axemble.vdp.resource.classes.SysColumns;

public class Duagent extends BaseAgent {

    private static final String LOGIN_SYSADMIN = "sysadmin";
    private static final String APPLICATION_NAME = "AppDU";
    private static final String PROJECT_CLIENT_NAME = "Client";
    private static final String PROJECT_ASSOCIATED_FILE_NAME = "AssociatedFile";
    private static final String MYTABLE_CLIENT_NAME = "GENERATED_CLIENT";
    private static final String MYTABLE_ASSOCIATED_FILE_NAME = "GENERATED_ASSOC_FILE";
    private static final String IUSER_PROJECT_RESPONSIBLE = "usermail1";
    private static final String IUSER_MAIL_3 = "usermail3";

    private static final String ORGANIZATION_1 = "Organization_1";
    private static final String ORGANIZATION_2 = "Organization_2";

    private static final String LOCALIZATION_1 = "Localisation_1";
    private static final String LOCALIZATION_2 = "Localisation_2";

    private static final float MY_DECIMAL = 2532456;
    private static final long MY_INTEGER = 999561236;
    private static final double MY_DOUBLE_NUMBER = 333338888;
    private static final BigDecimal MY_BIGDECIMAL = new BigDecimal(MY_DOUBLE_NUMBER);

    @Override
    protected void execute() {
        try {
            Client mystorageresource = null;

            IWorkflowModule workflowmodule = Modules.getWorkflowModule();
            IDirectoryModule directoryModule = Modules.getDirectoryModule();

            IContext sysadminContext = workflowmodule.getContextByLogin(LOGIN_SYSADMIN);

            // Get ResourceDefinition with generated class 
            IResourceDefinition myResourcedef = Client.getDefinition(); // Get Datastockroom table(Client)

            // Get ResourceDefinition without generated classes
            //IProject project = Modules.getProjectModule().getProject( sysadminContext, APPLICATION_NAME, getDefaultOrganization() );
            //ICatalog mycatalog = workflowmodule.getCatalog( sysadminContext, PROJECT_CLIENT_NAME, project );
            //IResourceDefinition myResourcedef = workflowmodule.getResourceDefinition( sysadminContext, mycatalog, PROJECT_CLIENT_NAME );

            //*************************************** Create AssociatedFile ressource *************************************
            Collection<IStorageResource> myAssociatedFiles = new ArrayList<IStorageResource>();

            for (int i = 1; i < 4; i++) { // Create GENERATED_ASSOC_FILE1, GENERATED_ASSOC_FILE2, GENERATED_ASSOC_FILE3
                mystorageresourceAssociateFile = AssociatedFile.createInstance(sysadminContext, null); //use reference generator
                //mystorageresourceAssociateFile = AssociatedFile.createInstance( sysadminContext, MYTABLE_ASSOCIATED_FILE_NAME + i ); //given reference
                mystorageresourceAssociateFile.setTitle(MYTABLE_ASSOCIATED_FILE_NAME + i);
                mystorageresourceAssociateFile.setAssociatedFileName(MYTABLE_ASSOCIATED_FILE_NAME + "_NAME" + i);
                mystorageresourceAssociateFile.save(sysadminContext);

                myAssociatedFiles.add((IStorageResource) mystorageresourceAssociateFile.getResource());
            }

            //*************************************** Create Client ressource *************************************
            mystorageresource = Client.createInstance(sysadminContext, null); //reference automatically generated  e.g: Table-[Chrono] is used

            // Without generated class method
            //IResourceDefinition myResourcedef = workflowmodule.getResourceDefinition( sysadminContext, mycatalog, PROJECT_CLIENT_NAME );
            //IStorageResource mystorageresource = workflowmodule.createStorageResource( sysadminContext, myResourcedef, "TEST AGENT GENERATED SDK" );

            mystorageresource.save(sysadminContext);

            //********************************************************************************
            workflowmodule.beginTransaction();
            //********************************************************************************

            Client mydata = Client.getInstance(mystorageresource.getResource());

            // ********* Clien data edition ***********
            mydata.setTitle(MYTABLE_CLIENT_NAME);
            mydata.setProjectName(MYTABLE_CLIENT_NAME + " NAME");
            mydata.setProjectDate(new Date());
            mydata.setProjectPeriode(new Period(new Date(), new Date()));

            mydata.setMyBool(Boolean.valueOf(true)); //boolean mybool = Boolean.valueOf( true ); //new Boolean( true );
            mydata.setMyInteger(MY_INTEGER);
            mydata.setDecimal(new Float(MY_DECIMAL));
            mydata.setMyDouble(MY_DOUBLE_NUMBER);
            mydata.setMyBigDecimal(MY_BIGDECIMAL);

            mydata.addAllAssociatedFiles(myAssociatedFiles);
            mydata.setMainAssociatedFile(myAssociatedFiles.iterator().next()); // Assign a record randomly

            IOrganization organization1 = directoryModule.getOrganization(sysadminContext, ORGANIZATION_1);
            IOrganization organization2 = directoryModule.getOrganization(sysadminContext, ORGANIZATION_2);

            mydata.setMainOrgarnization(organization1);

            Collection<IOrganization> organizations = new ArrayList<IOrganization>();
            organizations.add(organization1);
            organizations.add(organization2);
            mydata.addAllSecondaryOrganizations(organizations);

            ILocalization localisation1 = directoryModule.getLocalization(sysadminContext, LOCALIZATION_1);
            ILocalization localisation2 = directoryModule.getLocalization(sysadminContext, LOCALIZATION_2);

            Collection<ILocalization> localizations = new ArrayList<ILocalization>();
            localizations.add(localisation1);
            localizations.add(localisation2);

            mydata.setMainLocalization(localisation1);
            mydata.addAllSecondaryLocalizations(localizations);

            IUser user_Resp1 = workflowmodule.getUserByLogin(IUSER_PROJECT_RESPONSIBLE);
            IUser user_Resp2 = workflowmodule.getUserByLogin(IUSER_MAIL_3);

            Collection<IUser> secondaryResp = new ArrayList<IUser>();
            secondaryResp.add(user_Resp1);
            secondaryResp.add(user_Resp2);

            mydata.setProjectResponsible(user_Resp1);
            mydata.addAllSecondaryResponsible(secondaryResp);

            //GroupeMail group retrieving
            IGroup mygroup = null;

            Iterable<? extends IGroup> allgroup = Client.getProject().getOrganization().getGroups();
            for (IGroup iGroup : allgroup) {
                if (iGroup.getName().equalsIgnoreCase("GroupeMail")) {
                    mygroup = iGroup;
                }
            }
            mydata.setMainGroup(mygroup);

            // ************* retrieves a IGroup collection **************
            Collection<IGroup> mygroups = new ArrayList<IGroup>();
            for (IGroup iGroup : allgroup) {
                if (iGroup.getName().equalsIgnoreCase("GroupeMail")) {
                    mygroups.add(iGroup);
                }

                if (iGroup.getName().equalsIgnoreCase("SDK")) {
                    mygroups.add(iGroup);
                }

            }
            mydata.addAllSecondaryGroups(mygroups);

            // ************ Map element ******************

            Map<String, String> myMap = new HashMap<>();
            myMap.put("1", "Fox");
            myMap.put("2", "Weasel");
            mydata.setMap(myMap);
            Map<String, String> myMap2 = new HashMap<>();
            myMap2.put("1", "Sparrow");
            myMap2.put("2", "Woodpecker");

            Collection<Map> myMaps = new ArrayList<Map>();
            myMaps.add(myMap);
            myMaps.add(myMap2);
            mydata.addAllMesMaps(myMaps);

            // *********** External element **************** 
            ExternalElement car = new ExternalElement("1", "Mustang", "carType");
            ExternalElement bike = new ExternalElement("2", "BMX", "bikeType");
            ExternalElement plane = new ExternalElement("3", "Hurricane", "planeType");
            Collection<ExternalElement> externalElements = new ArrayList<ExternalElement>();

            externalElements.add(car);
            externalElements.add(bike);
            externalElements.add(plane);
            mydata.setElementExterne(car);
            //add several external elements  (collection)
            mydata.addAllMyExternalElements(externalElements);

            mydata.save(sysadminContext);
            workflowmodule.commitTransaction();

        } catch (Exception e) {
            workflowmodule.rollbackTransaction();
            throw new SDKException(e);
        } finally {
            if (workflowmodule.isTransactionActive()) {
                workflowmodule.rollbackTransaction();
            }
            Modules.releaseModule(workflowmodule);
            Modules.releaseModule(directoryModule);
        }
    }
}

Example of how to delete generated data stockrooms

The following example shows an agent deleting all data stockrooms created in the preceding example:

public class Duagent extends BaseAgent {

    private static final String LOGIN_SYSADMIN = "sysadmin";
    private static final String APPLICATION_NAME = "AppDU";
    private static final String PROJECT_CLIENT_NAME = "Client";
    private static final String PROJECT_ASSOCIATED_FILE_NAME = "AssociatedFile";
    private static final String MYTABLE_CLIENT_NAME = "GENERATED_CLIENT";
    private static final String MYTABLE_ASSOCIATED_FILE_NAME = "GENERATED_ASSOC_FILE";

    @Override
    protected void execute() {
        try {

            Client mystorageresource = null;

            IWorkflowModule workflowmodule = Modules.getWorkflowModule();
            IDirectoryModule directoryModule = Modules.getDirectoryModule();

            IContext sysadminContext = workflowmodule.getContextByLogin(LOGIN_SYSADMIN);

            // Get ResourceDefinition with generated class 
            IResourceDefinition myResourcedef = Client.getDefinition(); // Get Datastockroom table(Client)

            //****************************** Remove existing Client *********************************************
            Collection<IStorageResource> resources = null;

            IViewController viewController = workflowmodule.getViewController(sysadminContext, IStorageResource.class);
            //*** Get client record where SYS_TITLE = MYTABLE_CLIENT_NAME
            viewController.addEqualsConstraint(SysColumns.SYS_TITLE, MYTABLE_CLIENT_NAME); //Retrieves records with specified title name
            resources = viewController.evaluate(myResourcedef); //Query on the table Client with Constraint

            //********************************************************************************
            workflowmodule.beginTransaction();
            //********************************************************************************

            for (IStorageResource myResource : resources) { //IStorageResource myResource = resources.iterator().next();
                String refName = (String) myResource.getValue(SysColumns.SYS_TITLE);

                mystorageresource = Client.getInstance(myResource);

                //You can not delete table if external elements exist
                mystorageresource.removeAllMyExternalElements(mystorageresource.getMyExternalElements());
                Collection<AssociatedFile> myAssociatedFiles = mystorageresource.getAssociatedFiles();
                for (AssociatedFile myAssociatedFile : myAssociatedFiles) {
                    mystorageresource.removeAssociatedFiles((IStorageResource) myAssociatedFile.getResource());
                }
                mystorageresource.save(sysadminContext);
                mystorageresource.delete(sysadminContext);
            }

            AssociatedFile mystorageresourceAssociateFile = null;
            myResourcedef = AssociatedFile.getDefinition(); // Get Data stockroom table(AssociatedFile)

            // ******************* Remove existing AssociatedFile **************************************
            viewController = workflowmodule.getViewController(sysadminContext, IStorageResource.class); // no removeConstraint method()

            //viewController.addLikeConstraint( AssociatedFile.FIELD_sys_Reference, "%" + MYTABLE_ASSOCIATED_FILE_NAME + "%" ); //Retrieve record with specified name
            viewController.addLikeConstraint(SysColumns.SYS_TITLE, MYTABLE_ASSOCIATED_FILE_NAME + "%"); //Retrieve record with specified name
            resources = viewController.evaluate(myResourcedef); //Query on the table AssociatedFile with Constraint

            //Delete records with MYTABLE_CLIENT_NAME
            for (IStorageResource myResource : resources) { //IStorageResource myResource = resources.iterator().next();
                mystorageresourceAssociateFile = AssociatedFile.getInstance(myResource);
                mystorageresourceAssociateFile.delete(sysadminContext);
            }

            //********************************************************************************
            workflowmodule.commitTransaction();
            //********************************************************************************
        } catch (Exception e) {
            getWorkflowModule().rollbackTransaction();
            throw new SDKException(e);
        } finally {
            if (getWorkflowModule().isTransactionActive()) {
                getWorkflowModule().rollbackTransaction();
            }
            Modules.releaseModule(getWorkflowModule());
            Modules.releaseModule(getDirectoryModule());
        }
    }
}

Source : https://wiki.myvdoc.net/xwiki/bin/view/Dev+Floor/ClasseGeneration