Class MenuImportExportService
- java.lang.Object
-
- com.netgrif.application.engine.workflow.service.MenuImportExportService
-
- All Implemented Interfaces:
IMenuImportExportService
@Service public class MenuImportExportService extends java.lang.Object implements IMenuImportExportService
-
-
Constructor Summary
Constructors Constructor Description MenuImportExportService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,I18nString>
addSelectedEntriesToExport(MultichoiceMapField availableEntries, EnumerationMapField menusForExport, java.lang.String menuIdentifier)
java.util.Map<java.lang.String,I18nString>
createAvailableEntriesChoices(java.util.List<Case> menuItemCases)
java.lang.String
createMenuItemCase(java.lang.StringBuilder resultMessage, MenuEntry item, java.lang.String menuIdentifier, java.lang.String parentId, java.lang.String filterTaskId)
Method which creates new Preference filter item case from imported menuEntry class.protected FileFieldValue
createXML(MenuAndFilters menuAndFilters, java.lang.String parentId, FileField fileField)
FileFieldValue
exportMenu(EnumerationMapField menusForExport, java.lang.String groupId, FileField fileField)
Method which performs export of selected menu entries with their filters into xml file.java.util.List<java.lang.String>
importMenu(java.util.List<Case> menuItemCases, FileFieldValue ffv, java.lang.String parentId)
Method which performs import of menus from uploaded xml file.protected MenuAndFilters
loadFromXML(FileFieldValue ffv)
-
-
-
Method Detail
-
exportMenu
public FileFieldValue exportMenu(EnumerationMapField menusForExport, java.lang.String groupId, FileField fileField) throws java.io.IOException
Method which performs export of selected menu entries with their filters into xml file. Method finds all cases by provided ids, transform them into FilterImportExportList object and serialize them into xml file on path: storage/filterExport//filters.xml - Specified by:
exportMenu
in interfaceIMenuImportExportService
- Parameters:
menusForExport
- - EnumerationMapField with Ids (delimited by ",") of menu entries as keys and identifier of menu they belong to as valuegroupId
- case Id of active group- Returns:
- FileFieldValue - file field value of active group file field used to store exported file
- Throws:
java.io.IOException
- - if file which contains exported menus cannot be created
-
importMenu
public java.util.List<java.lang.String> importMenu(java.util.List<Case> menuItemCases, FileFieldValue ffv, java.lang.String parentId) throws java.io.IOException, IllegalMenuFileException, TransitionNotExecutableException
Method which performs import of menus from uploaded xml file. Method firstly loads xml file from file field and validates it against xml schema for menusWithFilters located on path: menu_export_schema.xml. Then it calls import of filters provided in uploaded xml file. Method then deletes any Preference filter item cases of active group case with same menu identifier as any of the menus imported. If the file is correct, method creates new instance of Preference filter item cases for each menu entry by calling method "createMenuItemCase".- Specified by:
importMenu
in interfaceIMenuImportExportService
- Parameters:
menuItemCases
- - list of Preference filter item cases in active groupffv
- - file field from active group case containing uploaded xml file.parentId
- - id of active group case- Returns:
- List
- list of values delimited by "," containing preferenceItem case Id, filter case Id, boolean value determining if Icon should be displayed - Throws:
java.io.IOException
- - if imported file is not foundIllegalMenuFileException
- - if uploaded xml is not in correct xml format and invalidate against schemaTransitionNotExecutableException
-
createMenuItemCase
public java.lang.String createMenuItemCase(java.lang.StringBuilder resultMessage, MenuEntry item, java.lang.String menuIdentifier, java.lang.String parentId, java.lang.String filterTaskId)
Method which creates new Preference filter item case from imported menuEntry class. Before case creation method prepares allowed and banned roles data for the entry while performing checks for imported filter and role nets in engine.- Specified by:
createMenuItemCase
in interfaceIMenuImportExportService
- Parameters:
item
- - imported MenuEntry itemmenuIdentifier
- - Identifier of new imported menu.parentId
- - id of active group casefilterTaskId
- - task id of imported filter belonging to men item case being created- Returns:
- String - values delimited by "," containing case Id of newly created Preference filter item case, Id of its filter case, boolean value determining if Preference filter item case should display icon.
-
loadFromXML
@Transactional protected MenuAndFilters loadFromXML(FileFieldValue ffv) throws java.io.IOException, IllegalMenuFileException
- Throws:
java.io.IOException
IllegalMenuFileException
-
createXML
@Transactional protected FileFieldValue createXML(MenuAndFilters menuAndFilters, java.lang.String parentId, FileField fileField) throws java.io.IOException
- Throws:
java.io.IOException
-
createAvailableEntriesChoices
public java.util.Map<java.lang.String,I18nString> createAvailableEntriesChoices(java.util.List<Case> menuItemCases)
- Specified by:
createAvailableEntriesChoices
in interfaceIMenuImportExportService
-
addSelectedEntriesToExport
public java.util.Map<java.lang.String,I18nString> addSelectedEntriesToExport(MultichoiceMapField availableEntries, EnumerationMapField menusForExport, java.lang.String menuIdentifier)
- Specified by:
addSelectedEntriesToExport
in interfaceIMenuImportExportService
-
-