JDistil

Models

Models refers to a set of five abstract processor classes in the JDistil framework that support domain specific CRUD based operations. Specifically, these include support for viewing, selecting, deleting, editing and saving domain specific data objects. The following sections document and provide examples of each of these classes.

View Data Objects

The "com.bws.jdistil.core.process.model.ViewDataObjects" class supports viewing multiple instances of a single data object type. This includes support for filtering, sorting, and pagination of data in a data object specific view.
The following documents the two constructors available in the "com.bws.jdistil.core.process.model.ViewDataObjects" class. The first is used when pagination is not needed and the second when pagination is needed.
public ViewDataObjects(Class<? extends IDataManager<I, T>> dataManagerClass, FilterCriteriaDefinition filterCriteriaDefinition, 
        String attributeId, String nextPageId) {

public ViewDataObjects(Class<? extends IDataManager<I, T>> dataManagerClass, FilterCriteriaDefinition filterCriteriaDefinition, 
        String attributeId, String nextPageId, int pageSize, String currentPageNumberFieldId, String selectedPageNumberFieldId, 
        String previousPageActionId, String nextPageActionId, String selectPageActionId, Set<String> retrieveDataActionIds, 
        Set<String> refreshDataActionIds, boolean cachePagingIds) {
				
Parameter Description
dataManagerClass Data manager class supporting the view specific data object type.
filterCriteriaDefinition Filter criteria definition supporting filtering and sorting.
attributeId Unique attribute ID used to store a list of view specific data objects in the request attributes.
nextPageId Unique page ID identifying the view page.
pageSize Number of items to display on each page in the view.
currentPageNumberFieldId Unique field ID used to track the current page number.
selectedPageNumberFieldId Unique field ID used to submit the selected page number.
previousPageActionId Unique action ID identifying the previous page action.
nextPageActionId Unique action ID identifying the next page action.
selectPageActionId Unique action ID identifying the select page action.
retrieveDataActionIds Unique set of action IDs identifying actions requiring the set of viewable data objects to be retrieved.
refreshDataActionIds Unique set of action IDs identifying actions that alter the data in the set of viewable data objects and only require a refresh of the current page.
cachePagingIds Indicates whether or not the set of viewable data object IDs should be cached in the session.

The following is an example implementation extending the "com.bws.jdistil.core.process.model.ViewDataObjects" class.
public class ViewCompanies extends ViewDataObjects<Integer, Company> {

    private static final FilterCriteriaDefinition filterCriteriaDefinition = new FilterCriteriaDefinition(Company.class);

    private static final Set<String> retrieveDataActionIds = new HashSet<String>();
    private static final Set<String> refreshDataActionIds = new HashSet<String>();

    static {
        // Create value criterion definition
        List<ValueCriterionDefinition> valueCriterionDefinitions = new ArrayList<ValueCriterionDefinition>();
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_NAME, FieldIds.COMPANY_NAME_FILTER_OPERATOR, 
                Operators.CONTAINS, FieldIds.COMPANY_NAME_FILTER, null));
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_TYPE, null, 
                Operators.EQUALS, FieldIds.COMPANY_TYPE_FILTER, null));
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_ACTIVE, null, 
                Operators.EQUALS, FieldIds.COMPANY_ACTIVE_FILTER, null));
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_CREATED, FieldIds.COMPANY_CREATED_FILTER_OPERATOR, 
                Operators.EQUALS, FieldIds.COMPANY_CREATED_FILTER, null));

        // Create order criterion definition
        OrderCriterionDefinition orderCriterionDefinition = new OrderCriterionDefinition(FieldIds.COMPANY_SORT_FIELD, 
                FieldIds.COMPANY_SORT_DIRECTION, null);

        // Populate filter criteria definition
        filterCriteriaDefinition.setIsFilterDataRequired(false);
        filterCriteriaDefinition.setValueCriterionDefinitions(valueCriterionDefinitions);
        filterCriteriaDefinition.setOrderCriterionDefinition(orderCriterionDefinition);

        // Populate retrieve data action IDs
        retrieveDataActionIds.add(ActionIds.VIEW_COMPANIES);

        // Populate refresh data action IDs
        refreshDataActionIds.add(ActionIds.DELETE_COMPANY);
        refreshDataActionIds.add(ActionIds.SAVE_COMPANY);
        refreshDataActionIds.add(ActionIds.CANCEL_COMPANY);
    }

    public ViewCompanies() {
        super(CompanyManager.class, filterCriteriaDefinition, AttributeNames.COMPANIES, PageIds.COMPANIES, 
                5, FieldIds.COMPANY_CURRENT_PAGE_NUMBER, FieldIds.COMPANY_SELECTED_PAGE_NUMBER,
                ActionIds.VIEW_COMPANY_PREVIOUS_PAGE, ActionIds.VIEW_COMPANY_NEXT_PAGE, ActionIds.VIEW_COMPANY_SELECT_PAGE,
                retrieveDataActionIds, refreshDataActionIds, false);
    }
}
				

Select Data Objects

The "com.bws.jdistil.core.process.model.SelectDataObjects" class supports the selection of one or more instances of a single data object type. This is used when selecting one or more instances of a specific data object type that has a many-to-many or many-to-one relationship with the primary data object. This supports filtering, sorting, and pagination of data in a associative data object specific view.
The following documents the two constructors available in the "com.bws.jdistil.core.process.model.SelectDataObjects" class. The first is used when pagination is not needed and the second when pagination is needed.
public SelectDataObjects(Class<? extends IDataManager<I, T>> dataManagerClass, FilterCriteriaDefinition filterCriteriaDefinition, 
        String attributeId, String nextPageId, String selectedAssociatesAttributeName, String selectedAssociatesFieldId, 
        String addAssociateActionId, String removeAssociateActionId, String closeActionId) {

public SelectDataObjects(Class<? extends IDataManager<I, T>> dataManagerClass, FilterCriteriaDefinition filterCriteriaDefinition, 
        String attributeId, String nextPageId, int pageSize, String currentPageNumberFieldId, String selectedPageNumberFieldId, 
        String previousPageActionId, String nextPageActionId, String selectPageActionId, Set<String> retrieveDataActionIds, 
        Set<String> refreshDataActionIds, boolean cachePagingIds, String selectedAssociatesAttributeName, String selectedAssociatesFieldId, 
        String addAssociateActionId, String removeAssociateActionId, String closeActionId) {
				
Parameter Description
dataManagerClass Data manager class supporting the view specific data object type.
filterCriteriaDefinition Filter criteria definition supporting filtering and sorting.
attributeId Unique attribute ID used to store a list of view specific data objects in the request attributes.
nextPageId Unique page ID identifying the view page.
pageSize Number of items to display on each page in the view.
currentPageNumberFieldId Unique field ID used to track the current page number.
selectedPageNumberFieldId Unique field ID used to submit the selected page number.
previousPageActionId Unique action ID identifying the previous page action.
nextPageActionId Unique action ID identifying the next page action.
selectPageActionId Unique action ID identifying the select page action.
retrieveDataActionIds Unique set of action IDs identifying actions requiring the set of viewable data objects to be retrieved.
refreshDataActionIds Unique set of action IDs identifying actions that alter the data in the set of viewable data objects and only require a refresh of the current page.
cachePagingIds Indicates whether or not the set of viewable data object IDs should be cached in the session.
selectedAssociatesAttributeName Unique attribute name used to store a the collection of selected data objects in the request attributes.
selectedAssociatesFieldId Unique field ID identifying associates selected on add and remove actions in the selection view.
addAssociateActionId Unique action ID identifying the add selected data objects action.
removeAssociateActionId Unique action ID identifying the remove selected data objects action.
closeActionId Unique action ID identifying close data object selection action.

The following is an example implementation extending the "com.bws.jdistil.core.process.model.SelectDataObjects" class.
public class SelectCompanies extends SelectDataObjects<Integer, Company> {

    private static final FilterCriteriaDefinition filterCriteriaDefinition = new FilterCriteriaDefinition(Company.class);

    private static final Set<String> retrieveDataActionIds = new HashSet<String>();
    private static final Set<String> refreshDataActionIds = new HashSet<String>();

    static {
        // Create value criterion definition
        List<ValueCriterionDefinition> valueCriterionDefinitions = new ArrayList<ValueCriterionDefinition>();
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_NAME, FieldIds.COMPANY_NAME_FILTER_OPERATOR, 
                Operators.CONTAINS, FieldIds.COMPANY_NAME_FILTER, null));
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_TYPE, null, 
                Operators.EQUALS, FieldIds.COMPANY_TYPE_FILTER, null));
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_ACTIVE, null, 
                Operators.EQUALS, FieldIds.COMPANY_ACTIVE_FILTER, null));
        valueCriterionDefinitions.add(new ValueCriterionDefinition(FieldIds.COMPANY_CREATED, FieldIds.COMPANY_CREATED_FILTER_OPERATOR, 
                Operators.EQUALS, FieldIds.COMPANY_CREATED_FILTER, null));

        // Create order criterion definition
        OrderCriterionDefinition orderCriterionDefinition = new OrderCriterionDefinition(FieldIds.COMPANY_SORT_FIELD, 
                FieldIds.COMPANY_SORT_DIRECTION, null);

        // Populate filter criteria definition
        filterCriteriaDefinition.setIsFilterDataRequired(false);
        filterCriteriaDefinition.setValueCriterionDefinitions(valueCriterionDefinitions);
        filterCriteriaDefinition.setOrderCriterionDefinition(orderCriterionDefinition);

        // Populate retrieve data action IDs
        retrieveDataActionIds.add(ActionIds.SELECT_COMPANIES);
    }

    public SelectCompanies() {
        super(CompanyManager.class, filterCriteriaDefinition, AttributeNames.COMPANIES, PageIds.COMPANY_SELECTION, 
                5, FieldIds.COMPANY_CURRENT_PAGE_NUMBER, FieldIds.COMPANY_SELECTED_PAGE_NUMBER,
                ActionIds.SELECT_COMPANY_PREVIOUS_PAGE, ActionIds.SELECT_COMPANY_NEXT_PAGE, ActionIds.SELECT_COMPANY_SELECT_PAGE,
                retrieveDataActionIds, refreshDataActionIds, false, AttributeNames.SELECTED_COMPANIES, FieldIds.COMPANY_ID,
                ActionIds.SELECT_COMPANY_ADD, ActionIds.SELECT_COMPANY_REMOVE, ActionIds.SELECT_COMPANY_CLOSE);
    }
}
				

Delete Data Object

The "com.bws.jdistil.core.process.model.DeleteDataObject" class supports the deletion of a single data object type. This is used when deleting a data object from a view data objects page.
The following documents the constructor available in the "com.bws.jdistil.core.process.model.DeleteDataObject" class.
public DeleteDataObject(Class<? extends IDataManager<I, T>> dataManagerClass, String fieldId, Class<? extends IProcessor> nextProcessorClass) {
				
Parameter Description
dataManagerClass Data manager class supporting the deletion of a specific data object type.
fieldId Field ID used to reference the unique data object ID from the request parameters identifying which data object to delete.
nextProcessorClass Processor class to invoke after processing the delete request.

The following is an example implementation extending the "com.bws.jdistil.core.process.model.DeleteDataObject" class.
public class DeleteCompany extends DeleteDataObject<Integer, Company> {

    public DeleteCompany() {
        super(CompanyManager.class, FieldIds.COMPANY_ID, ViewCompanies.class);
    }
}
				

Edit Data Object

The "com.bws.jdistil.core.process.model.EditDataObject" class supports the creation or modification of a single data object type. This is used when creating a new or editing an existing data object from a view data objects page.
The following documents the constructor available in the "com.bws.jdistil.core.process.model.EditDataObject" class.
public EditDataObject(Class<? extends T> dataObjectClass, Class<? extends IDataManager<I, T>> dataManagerClass, 
        String fieldId, String attributeId, String nextPageId, Class<? extends IProcessor> failureProcessorClass, boolean useSession) {
				
Parameter Description
dataObjectClass Data object class to be created or modified.
dataManagerClass Data manager class supporting the creation or modification of a specific data object type.
fieldId Field ID used to reference the unique data object ID from the request parameters identifying which data object to modify.
attributeId Attribute ID used to store the data object being created or modified in the request attributes and session attributes if useSession is enabled.
nextPageId Page ID identifying the page used to create or modify a specific data object type.
failureProcessorClass Processor class to invoke if the edit process encounters an error.
useSession Indicates the data object being created or modified should be stored in the session. This is useful if state needs to be maintained due to other actions being available from the edit page.

The following is an example implementation extending the "com.bws.jdistil.core.process.model.EditDataObject" class.
public class EditCompany extends EditDataObject<Integer, Company> {

    public EditCompany() {
        super(Company.class, CompanyManager.class, FieldIds.COMPANY_ID, AttributeNames.COMPANY, PageIds.COMPANY, ViewCompanies.class, false);
    }
}
				

Save Data Object

The "com.bws.jdistil.core.process.model.SaveDataObject" class supports saving a single data object type. This is used when saving a new or existing data object from the edit data objects page.
The following documents the constructor available in the "com.bws.jdistil.core.process.model.SaveDataObject" class.
public SaveDataObject(Class<? extends DataObject<I>> dataObjectClass, Class<? extends IDataManager<I, T>> dataManagerClass, 
        String fieldId, String attributeId, boolean doDirtyUpdateCheck, Class<? extends IProcessor> successProcessorClass,
        Class<? extends IProcessor> failureProcessorClass, boolean useSession) {
				
Parameter Description
dataObjectClass Data object class to be saved.
dataManagerClass Data manager class responsible for saving a specific data object type.
fieldId Field ID used to reference the unique data object ID from the request parameters identifying the data object to be saved.
attributeId Attribute ID used to store the data object being saved in the request attributes and session attributes if useSession is enabled.
doDirtyUpdateCheck Indicates the version of the data object being saved should be checked to avoid concurrent update issues.
successProcessorClass Processor class to invoke if the save process is saved successful.
failureProcessorClass Processor class to invoke if the save process encounters an error.
useSession Indicates the data object being saved should be stored in the session. This is useful if state needs to be maintained due to other actions being available from the edit page.

The following is an example implementation extending the "com.bws.jdistil.core.process.model.SaveDataObject" class.
public class SaveCompany extends SaveDataObject<Integer, Company> {

    public SaveCompany() {
        super(Company.class, CompanyManager.class, FieldIds.COMPANY_ID, AttributeNames.COMPANY, true, ViewCompanies.class, EditCompany.class, false);
    }
}