Class EditExtractionClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.plugins.extraction.edition.EditExtractionClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
public class EditExtractionClientSideElement extends StaticClientSideElement
This client site element manages a button to create an extraction definition file
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description private ContentDAO
_contentDAO
private ContentWorkflowHelper
_contentWorkflowHelper
private I18nUtils
_i18nUtils
private SourceResolver
_sourceResolver
private UserHelper
_userHelper
static String
ROLE
The Avalon role name-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description EditExtractionClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addGrantedGroups(Document document, Map<String,Object> arguments)
private void
_addGrantedUsers(Document document, Map<String,Object> arguments)
private void
_changeVisibilityInDocument(Document document, String visibilityStr)
private boolean
_containsGroup(List<Map<String,String>> groups, Element groupElement)
private boolean
_containsUser(List<Map<String,String>> users, Element userElement)
private void
_deleteTemporaryFile(String definitionFileName, Path temporaryFilePath)
private Stream<Element>
_getElements(Element extractionRoot, String nodeTagName)
private String
_getExtractionNameFromFileName(String fileName)
private Optional<Element>
_getFirstElement(Element parent, String nodeTagName)
private Element
_getOrCreateFirstElement(Document document, Element parent, String nodeTagName)
private void
_insertDescriptionInDocument(Document document, String descriptionId)
private <T> Map<String,Object>
_modifyDefinitionFile(String definitionFileName, T dataToModify, BiConsumer<Document,T> modifyingConsumer)
private Document
_parseDefinitionFile(File definitionFile)
private void
_removeAssignement(Document document, Map<String,Object> arguments)
Map<String,Object>
addDescription(String definitionFileName, String descriptionId)
Adds a description to an extraction.Map<String,Object>
addGrantedGroups(String definitionFileName, String profileId, List<Map<String,String>> groups)
Assign rights to the given groups on the given extractionMap<String,Object>
addGrantedUsers(String definitionFileName, String profileId, List<Map<String,String>> users)
Assign rights to the given users on the given extractionMap<String,Object>
changeVisibility(String definitionFileName, String visibilityStr)
Changes the visibility of an extractionMap<String,Object>
createExtraction(String relativeDefinitionFilePath, String language)
Creates an extraction definition file.boolean
deleteExtraction(String definitionFileName)
Deletes an extraction definition file.Map<String,Object>
removeAssignment(String definitionFileName, String profileId, List<Map<String,String>> users, List<Map<String,String>> groups)
Remove rights to the given users on the given queryMap<String,Object>
renameExtraction(String relativeOldFilePath, String newFileName)
Renames an extraction definition file.void
service(ServiceManager serviceManager)
-
Methods inherited from class org.ametys.core.ui.StaticClientSideElement
_configureClass, _configureParameters, _configureScript, configureInitialParameters
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, configure, getDependencies, getId, getPluginName, getRights, getScripts, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_sourceResolver
private SourceResolver _sourceResolver
-
_contentWorkflowHelper
private ContentWorkflowHelper _contentWorkflowHelper
-
_i18nUtils
private I18nUtils _i18nUtils
-
_contentDAO
private ContentDAO _contentDAO
-
_userHelper
private UserHelper _userHelper
-
-
Constructor Detail
-
EditExtractionClientSideElement
public EditExtractionClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classStaticFileImportsClientSideElement
- Throws:
ServiceException
-
createExtraction
public Map<String,Object> createExtraction(String relativeDefinitionFilePath, String language) throws Exception
Creates an extraction definition file.- Parameters:
relativeDefinitionFilePath
- The path of the extraction definition file to create. This path has to be relative to the base definition directory.language
- the language used to create the description- Returns:
- Map containing success boolean and the created extraction informations, or error codes if one occurs
- Throws:
Exception
- if an error occurs
-
_getExtractionNameFromFileName
private String _getExtractionNameFromFileName(String fileName)
-
addDescription
public Map<String,Object> addDescription(String definitionFileName, String descriptionId) throws Exception
Adds a description to an extraction.- Parameters:
definitionFileName
- The extraction definition file namedescriptionId
- the identifier of the description- Returns:
- Map containing success boolean and error codes if one occurs
- Throws:
Exception
- if an error occurs
-
_insertDescriptionInDocument
private void _insertDescriptionInDocument(Document document, String descriptionId)
-
changeVisibility
public Map<String,Object> changeVisibility(String definitionFileName, String visibilityStr) throws Exception
Changes the visibility of an extraction- Parameters:
definitionFileName
- The extraction definition file namevisibilityStr
- The new visibility- Returns:
- Map containing success boolean and error codes if one occurs
- Throws:
Exception
- if an error occurs
-
_changeVisibilityInDocument
private void _changeVisibilityInDocument(Document document, String visibilityStr)
-
addGrantedUsers
public Map<String,Object> addGrantedUsers(String definitionFileName, String profileId, List<Map<String,String>> users) throws Exception
Assign rights to the given users on the given extraction- Parameters:
definitionFileName
- The extraction definition file nameprofileId
- The profile idusers
- The users to grant- Returns:
- A result map
- Throws:
Exception
- if an error occurs
-
_addGrantedUsers
private void _addGrantedUsers(Document document, Map<String,Object> arguments)
-
addGrantedGroups
public Map<String,Object> addGrantedGroups(String definitionFileName, String profileId, List<Map<String,String>> groups) throws Exception
Assign rights to the given groups on the given extraction- Parameters:
definitionFileName
- The extraction definition file nameprofileId
- The profile idgroups
- The groups to grant- Returns:
- A result map
- Throws:
Exception
- if an error occurs
-
_addGrantedGroups
private void _addGrantedGroups(Document document, Map<String,Object> arguments)
-
removeAssignment
public Map<String,Object> removeAssignment(String definitionFileName, String profileId, List<Map<String,String>> users, List<Map<String,String>> groups) throws Exception
Remove rights to the given users on the given query- Parameters:
definitionFileName
- The extraction definition file nameprofileId
- The profile idusers
- The users to removegroups
- The groups to remove- Returns:
- A result map
- Throws:
Exception
- if an error occurs
-
_removeAssignement
private void _removeAssignement(Document document, Map<String,Object> arguments)
-
_containsGroup
private boolean _containsGroup(List<Map<String,String>> groups, Element groupElement)
-
_modifyDefinitionFile
private <T> Map<String,Object> _modifyDefinitionFile(String definitionFileName, T dataToModify, BiConsumer<Document,T> modifyingConsumer) throws Exception
- Throws:
Exception
-
_deleteTemporaryFile
private void _deleteTemporaryFile(String definitionFileName, Path temporaryFilePath)
-
renameExtraction
public Map<String,Object> renameExtraction(String relativeOldFilePath, String newFileName) throws Exception
Renames an extraction definition file.- Parameters:
relativeOldFilePath
- The extraction definition old file path, relative to the base definitions directorynewFileName
- The extraction definition new file name- Returns:
- Map containing success boolean and error codes if one occurs
- Throws:
Exception
- if an error occurs
-
deleteExtraction
public boolean deleteExtraction(String definitionFileName) throws Exception
Deletes an extraction definition file.- Parameters:
definitionFileName
- The extraction definition file to delete- Returns:
true
if extraction deletion succeed,false
otherwise- Throws:
Exception
- if an error occurs
-
_parseDefinitionFile
private Document _parseDefinitionFile(File definitionFile) throws Exception
- Throws:
Exception
-
_getElements
private Stream<Element> _getElements(Element extractionRoot, String nodeTagName)
-
_getOrCreateFirstElement
private Element _getOrCreateFirstElement(Document document, Element parent, String nodeTagName)
-
_getFirstElement
private Optional<Element> _getFirstElement(Element parent, String nodeTagName)
-
-