Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleIExportDataProvider configuration in appsupportlib.config.xml
<bean id="appSupportLibSettings" class="morphis.foundations.core.appsupportlib.configuration.AppSupportLibSettings" init-method="initialize">
 
    <property name="exportDataProvider">
        <bean class=" com.example.CustomExportDataProvider"/>
    </property>

</bean>

 

Usage Examples

Export items

Example implementation of a generic action in a TaskController that receives from the client the list of items to export from the current block.

E.g. exportItems("Excel", "LASTNAME, JOB, SAL, HIREDATE") will export the specified items unless they have the property Exportable disabled. 

Code Block
titleEXPORT-ITEMS example
@ActionTrigger(action="EXPORT-ITEMS")
public void exportItems(String export, String items)
{
    IBusinessObject model = getCurrentBlockController().getModel();
    List<String> itemNames = Arrays.asList( StringUtils.tokenizeToStringArray(items, ",") );

    Map<String,Object> options = null;
    boolean fullExport = false;
    boolean includeHeaders = true;
    BlockServices.export(model, itemNames, Export.valueOf(export), options, fullExport, includeHeaders);
}

 

Example of an EXPORT-ITEMS action call in Frames. This will export the specified items unless they have the property Exportable disabled. Row identifiers and unknown items are also ignored.

Code Block
titleEXPORT-ITEMS usage example
Frames.Application.execute({
	name: 'EXPORT-ITEMS',
	params: [
		{name: 'export', type: 'string', value: 'Excel'},
		{name: 'columns', type: 'string', value: 'LASTNAME, JOB, SAL, HIREDATE,    F2N_ROWID, ROWID,    __INVALID_ITEM__'}
	]
}, Frames.Application.task, undefined, undefined, undefined, false);

 

Set Exportable Items

Example implementation of a generic action in a TaskController that receives from the client the list of exportable items of the current block.

E.g. setExportableItems("LASTNAME, JOB, SAL") will set the Exportable property enabled (unless it was explicitly disabled in manager configuration) for the specified items and disabled for all other items.
Code Block
titleSET-EXPORTABLE-ITEMS example
@ActionTrigger(action="SET-EXPORTABLE-ITEMS")
public void setExportableItems(String items)
{
    IBusinessObject model = getCurrentBlockController().getModel();
    List<String> itemsToExport = Arrays.asList( StringUtils.tokenizeToStringArray(items, ",") );

    for (IBusinessObjectItem item : model.getItems())
        item.setExportable( itemsToExport.contains(item.getName()) );
}

 

Example implementation of a generic SET-EXPORTABLE-ITEMS action in a TaskController that receives from the client a map of blocks and items to export.

E.g. exportBlocks("Excel", "{
    'DEPT' : ['DEPTNO', 'DNAME', 'RESPONSIBLE'],
    'EMP' : ['LASTNAME', 'JOB', 'SAL', 'HIREDATE']
}") will export the specified blocks and items unless they have the property Exportable disabled.

call in Frames. This will set the Exportable property enabled for the specified items (unless explicitly disabled in manager configuration) and disabled for all other items.

Code Block
titleSET-EXPORTABLE-ITEMS usage example
Frames.Application.execute({
	name: 'SET-EXPORTABLE-ITEMS',
	params: [
		{name: 'columns', type: 'string', value: 'LASTNAME, JOB, SAL'}
	]
}, Frames.Application.task, undefined, undefined, undefined, false);

 

Export blocks

Example implementation of a generic action in a TaskController that receives from the client a map of blocks and items to export.

 

Code Block
titleEXPORT-BLOCKS example
 @ActionTrigger(action="EXPORT-BLOCKS")
public void exportBlocks(String export, String blocks)
{
    @SuppressWarnings("unchecked")
    Map<String,List<String>> blockMap = (Map<String,List<String>>) new Gson().fromJson(blocks, Map.class);
    Map<IBusinessObject,List<String>> modelMap = new LinkedHashMap<>();
    for (String block : blockMap.keySet())
    {
        IBlockController bc = getBlockController(block);
        if (bc != null && bc.getModel() != null)
            modelMap.put(bc.getModel(), blockMap.get(block));
    }

    Map<String,Object> options = null;
    boolean fullExport = false;
    boolean includeHeaders = true;
    BlockServices.export(modelMap, Export.valueOf(export), options, fullExport, includeHeaders);
}

 

Example of an EXPORT-BLOCKS action call in Frames. will export the specified blocks and items unless they have the property Exportable disabled. Row identifiers and unknown items are also ignored.

Code Block
titleEXPORT-BLOCKS usage example
Frames.Application.execute({
	name: 'EXPORT-BLOCKS',
	params: [
		{name: 'export', type: 'string', value: 'Excel'},
		{name: 'models', type: 'string', value: '{ \
			\'DEPT\' : [\'DEPTNO\', \'DNAME\', \'RESPONSIBLE\'], \
			\'EMP\': [\'LASTNAME\', \'JOB\', \'SAL\', \'HIREDATE\']}'
		}
	]
},
Frames.Application.task, undefined, undefined, undefined, false);