Package org.cyclos.impl.system
Class CustomScriptServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.CRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType>
-
- org.cyclos.impl.system.CustomScriptServiceImpl
-
- All Implemented Interfaces:
CRUDServiceLocal<CustomScript,CustomScriptDTO,CustomScriptData,ScriptType>,CustomScriptServiceLocal,CRUDService<CustomScriptDTO,CustomScriptData,ScriptType>,CRUDWithConfirmationPasswordService<CustomScriptDTO,CustomScriptData,ScriptType>,Service,CustomScriptService
@Service public class CustomScriptServiceImpl extends CRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType> implements CustomScriptServiceLocal
Implementation forCustomScriptService
-
-
Field Summary
Fields Modifier and Type Field Description static StringCODE_SEPARATOR_LINEstatic StringPARAMS_SEPARATOR_LINEstatic StringSCRIPT_LANGUAGE-
Fields inherited from class org.cyclos.impl.CRUDServiceImpl
$, ATTR_CURRENT_COPY, dtoClass, entityClass, extensionPointService, idPath, internalNamePath, namePath, ownerEntityIdPath, ownerEntityPath, ownerEntityPropertyName, passwordHandler, richTextHandler, withConfirmationPassword
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.system.CustomScriptServiceLocal
ATTR_ENTITY_MANAGER, ATTR_FORMATTER, ATTR_SCRIPT_HELPER, ATTR_SCRIPT_PARAMETERS, ATTR_SESSION_DATA
-
-
Constructor Summary
Constructors Constructor Description CustomScriptServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SerializableInputStreamgetCodeForDebug(CustomScriptVO vo)Returns a ZIP file containing the code for debugging the given scriptprotected CustomScriptDatagetData(CustomScript entity)Returns details data for the given entitySet<Long>getReverseDependencyIds(Long id)Returns the identifiers of all scripts which depend, directly or indirectly on the script with the given id.RunScriptDatagetRunData()Returns data to run arbitrary scriptsList<CustomScript>listByType(ScriptType type)Returns a list of scripts by typeCustomScriptAccessornewAccessor(CustomScript script, String scriptParameters)Returns aCustomScriptAccessorwhich can be used to run the given script.CustomScriptnewEntity(ScriptType type)Should be implemented in order to instantiate a new entity based on the given context parametersprotected ObjectonBeforeSave(CustomScript entity, CustomScript currentCopy)May be overridden in order to perform custom logic before saving an entity.protected voidpreProcessCurrentCopy(CustomScriptDTO dto, CustomScript currentCopy)This method is invoked before saving the entity and also, if the log is enabled, before removing.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkPair<String,String>resolveCodeAndParameters(CustomScript script, ScriptFunction function)Returns the final code for the given script function, together with the final parameters, concatenated from all dependencies.protected ValidatorresolveValidator(CustomScriptDTO dto)ScriptResultrun(RunScriptParams params)Runs an arbitrary script, returning the resultvoidrunInlineScriptAsBackgroundTask(String code)Creates aInlineScriptBackgroundTaskwith the given code, and schedules its execution.<T> TrunScript(String code)Runs the given script code directly.Page<CustomScriptVO>search(CustomScriptQuery params)Lists all available custom scripts-
Methods inherited from class org.cyclos.impl.CRUDServiceImpl
addCustomInternalNameValidations, addCustomNameValidations, checkConfirmationPassword, doRemove, find, findAll, from, getConfirmationPasswordInput, getConfirmationPasswordInputForRemove, getData, getDataForNew, getDeviceConfirmationParams, getEntityClass, getEntityInternalNameKey, getExcludedPropertiesToDTO, getExcludedPropertiesToEntity, getNameLabel, getUniqueInternalNameQuery, getUniqueNameQuery, isEntityInternalNameRequired, isNameRequired, load, logEntity, onAfterRemove, onAfterSave, onBeforeRemove, remove, remove, removeAll, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveDTOType, resolveEntityType, resolveExtensionPointAccessor, save, saveOrder, saveSkippingEntityLog, saveWithConfirmationPassword, shouldCheckConfirmationPassword, subClassMappings, toDTO, toEntity, validate
-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.services.CRUDService
getData, getDataForNew, load, remove, removeAll, save
-
Methods inherited from interface org.cyclos.impl.CRUDServiceLocal
find, findAll, getEntityClass, remove, removeAll, saveEntity, saveSkippingEntityLog, toDTO, toEntity, validate
-
-
-
-
Field Detail
-
CODE_SEPARATOR_LINE
public static final String CODE_SEPARATOR_LINE
-
PARAMS_SEPARATOR_LINE
public static final String PARAMS_SEPARATOR_LINE
-
SCRIPT_LANGUAGE
public static final String SCRIPT_LANGUAGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCodeForDebug
public SerializableInputStream getCodeForDebug(CustomScriptVO vo) throws FrameworkException
Description copied from interface:CustomScriptServiceReturns a ZIP file containing the code for debugging the given script- Specified by:
getCodeForDebugin interfaceCustomScriptService- Throws:
FrameworkException
-
getReverseDependencyIds
public Set<Long> getReverseDependencyIds(Long id)
Description copied from interface:CustomScriptServiceLocalReturns the identifiers of all scripts which depend, directly or indirectly on the script with the given id. The purpose of exposing this method in the interface is to test it- Specified by:
getReverseDependencyIdsin interfaceCustomScriptServiceLocal
-
getRunData
public RunScriptData getRunData() throws FrameworkException
Description copied from interface:CustomScriptServiceReturns data to run arbitrary scripts- Specified by:
getRunDatain interfaceCustomScriptService- Throws:
FrameworkException
-
listByType
public List<CustomScript> listByType(ScriptType type) throws FrameworkException
Description copied from interface:CustomScriptServiceLocalReturns a list of scripts by type- Specified by:
listByTypein interfaceCustomScriptServiceLocal- Throws:
FrameworkException
-
newAccessor
public CustomScriptAccessor newAccessor(CustomScript script, String scriptParameters) throws FrameworkException
Description copied from interface:CustomScriptServiceLocalReturns aCustomScriptAccessorwhich can be used to run the given script.- Specified by:
newAccessorin interfaceCustomScriptServiceLocal- Throws:
FrameworkException
-
newEntity
public CustomScript newEntity(ScriptType type)
Description copied from class:CRUDServiceImplShould be implemented in order to instantiate a new entity based on the given context parameters- Specified by:
newEntityin interfaceCRUDServiceLocal<CustomScript,CustomScriptDTO,CustomScriptData,ScriptType>- Specified by:
newEntityin classCRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType>
-
resolveCodeAndParameters
public Pair<String,String> resolveCodeAndParameters(CustomScript script, ScriptFunction function)
Description copied from interface:CustomScriptServiceLocalReturns the final code for the given script function, together with the final parameters, concatenated from all dependencies. The purpose of exposing this method in the interface is to test it- Specified by:
resolveCodeAndParametersin interfaceCustomScriptServiceLocal
-
run
public ScriptResult run(RunScriptParams params) throws FrameworkException
Description copied from interface:CustomScriptServiceRuns an arbitrary script, returning the result- Specified by:
runin interfaceCustomScriptService- Throws:
FrameworkException
-
runInlineScriptAsBackgroundTask
public void runInlineScriptAsBackgroundTask(String code)
Description copied from interface:CustomScriptServiceLocalCreates aInlineScriptBackgroundTaskwith the given code, and schedules its execution. If the code returns a number, it is interpreted as the number of affected records (for logging).- Specified by:
runInlineScriptAsBackgroundTaskin interfaceCustomScriptServiceLocal
-
runScript
public <T> T runScript(String code)
Description copied from interface:CustomScriptServiceLocalRuns the given script code directly. Will run as system, with all default bindings available- Specified by:
runScriptin interfaceCustomScriptServiceLocal
-
search
public Page<CustomScriptVO> search(CustomScriptQuery params) throws FrameworkException
Description copied from interface:CustomScriptServiceLists all available custom scripts- Specified by:
searchin interfaceCustomScriptService- Throws:
FrameworkException
-
getData
protected CustomScriptData getData(CustomScript entity)
Description copied from class:CRUDServiceImplReturns details data for the given entity- Specified by:
getDatain classCRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType>
-
onBeforeSave
protected Object onBeforeSave(CustomScript entity, CustomScript currentCopy)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before saving an entity. Any returned value will be passed to theCRUDServiceImpl.onAfterSave(BaseEntity, BaseEntity, Object)method- Overrides:
onBeforeSavein classCRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType>
-
preProcessCurrentCopy
protected void preProcessCurrentCopy(CustomScriptDTO dto, CustomScript currentCopy)
Description copied from class:CRUDServiceImplThis method is invoked before saving the entity and also, if the log is enabled, before removing. Subclasses can override it to fetch lazy relationships, etc as the current copy will be detached. In case of removing (i.e the log is enabled for this entity) the dto parameter will be null.- Overrides:
preProcessCurrentCopyin classCRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType>
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
resolveValidator
protected Validator resolveValidator(CustomScriptDTO dto)
- Specified by:
resolveValidatorin classCRUDServiceImpl<CustomScript,QCustomScript,CustomScriptDTO,CustomScriptData,ScriptType>
-
-