@Transactional(rollbackFor={GenieException.class,javax.validation.ConstraintViolationException.class}) public class JpaCommandServiceImpl extends java.lang.Object implements CommandService
Constructor and Description |
---|
JpaCommandServiceImpl(JpaCommandRepository commandRepo,
JpaApplicationRepository appRepo,
JpaClusterRepository clusterRepo)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addApplicationsForCommand(java.lang.String id,
java.util.List<java.lang.String> applicationIds)
Add applications for the command.
|
void |
addConfigsForCommand(java.lang.String id,
java.util.Set<java.lang.String> configs)
Add a configuration files to the command.
|
void |
addTagsForCommand(java.lang.String id,
java.util.Set<java.lang.String> tags)
Add tags to the command.
|
java.lang.String |
createCommand(Command command)
Create new command configuration.
|
void |
deleteAllCommands()
Delete all commands from database.
|
void |
deleteCommand(java.lang.String id)
Delete a command configuration from database.
|
java.util.List<Application> |
getApplicationsForCommand(java.lang.String id)
Get the applications for a given command.
|
java.util.Set<Cluster> |
getClustersForCommand(java.lang.String id,
java.util.Set<ClusterStatus> statuses)
Get all the clusters the command with given id is associated with.
|
Command |
getCommand(java.lang.String id)
Gets command configuration for given id.
|
org.springframework.data.domain.Page<Command> |
getCommands(java.lang.String name,
java.lang.String user,
java.util.Set<CommandStatus> statuses,
java.util.Set<java.lang.String> tags,
org.springframework.data.domain.Pageable page)
Get command configurations for given filter criteria.
|
java.util.Set<java.lang.String> |
getConfigsForCommand(java.lang.String id)
Get the set of configuration files associated with the command with given
id.
|
java.util.Set<java.lang.String> |
getTagsForCommand(java.lang.String id)
Get the set of tags associated with the command with given
id.
|
void |
patchCommand(java.lang.String id,
com.github.fge.jsonpatch.JsonPatch patch)
Patch a command with the given json patch.
|
void |
removeAllConfigsForCommand(java.lang.String id)
Remove all configuration files from the command.
|
void |
removeAllTagsForCommand(java.lang.String id)
Remove all tags from the command.
|
void |
removeApplicationForCommand(java.lang.String id,
java.lang.String appId)
Remove the application from the command.
|
void |
removeApplicationsForCommand(java.lang.String id)
Remove the applications from the command.
|
void |
removeConfigForCommand(java.lang.String id,
java.lang.String config)
Remove a configuration file from the command.
|
void |
removeTagForCommand(java.lang.String id,
java.lang.String tag)
Remove a tag from the command.
|
void |
setApplicationsForCommand(java.lang.String id,
java.util.List<java.lang.String> applicationIds)
Set the applications for the command.
|
void |
updateCommand(java.lang.String id,
Command updateCommand)
Update command configuration.
|
void |
updateConfigsForCommand(java.lang.String id,
java.util.Set<java.lang.String> configs)
Update the set of configuration files associated with the command with
given id.
|
void |
updateTagsForCommand(java.lang.String id,
java.util.Set<java.lang.String> tags)
Update the set of tags associated with the command with
given id.
|
public JpaCommandServiceImpl(JpaCommandRepository commandRepo, JpaApplicationRepository appRepo, JpaClusterRepository clusterRepo)
commandRepo
- the command repository to useappRepo
- the application repository to useclusterRepo
- the cluster repository to usepublic java.lang.String createCommand(@NotNull(message="No command entered. Unable to create.") Command command) throws GenieException
createCommand
in interface CommandService
command
- encapsulates the command configuration information to
create. Not null. Valid.GenieException
- if there is an error@Transactional(readOnly=true) public Command getCommand(@NotBlank(message="No id entered unable to get.") java.lang.String id) throws GenieException
getCommand
in interface CommandService
id
- unique id for command configuration to get. Not null/empty.GenieException
- if there is an error@Transactional(readOnly=true) public org.springframework.data.domain.Page<Command> getCommands(java.lang.String name, java.lang.String user, java.util.Set<CommandStatus> statuses, java.util.Set<java.lang.String> tags, org.springframework.data.domain.Pageable page)
getCommands
in interface CommandService
name
- Name of command configuser
- The name of the user who created the configurationstatuses
- The status of the applications to get. Can be null.tags
- tags allocated to this commandpage
- The page of results to getpublic void updateCommand(@NotBlank(message="No id entered. Unable to update.") java.lang.String id, @NotNull(message="No command information entered. Unable to update.") Command updateCommand) throws GenieException
updateCommand
in interface CommandService
id
- The id of the command configuration to update. Not null or
empty.updateCommand
- contains the information to update the command withGenieException
- if there is an errorpublic void patchCommand(@NotBlank java.lang.String id, @NotNull com.github.fge.jsonpatch.JsonPatch patch) throws GenieException
patchCommand
in interface CommandService
id
- The id of the command to updatepatch
- The json patch to use to update the given commandGenieException
- if there is an errorpublic void deleteAllCommands() throws GenieException
deleteAllCommands
in interface CommandService
GenieException
- if there is an errorpublic void deleteCommand(@NotBlank(message="No id entered. Unable to delete.") java.lang.String id) throws GenieException
deleteCommand
in interface CommandService
id
- unique if of the command configuration to deleteGenieException
- if there is an errorpublic void addConfigsForCommand(@NotBlank(message="No command id entered. Unable to add configurations.") java.lang.String id, @NotEmpty(message="No configuration files entered. Unable to add.") java.util.Set<java.lang.String> configs) throws GenieException
addConfigsForCommand
in interface CommandService
id
- The id of the command to add the configuration file to. Not
null/empty/blank.configs
- The configuration files to add. Not null/empty.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.Set<java.lang.String> getConfigsForCommand(@NotBlank(message="No command id entered. Unable to get configs.") java.lang.String id) throws GenieException
getConfigsForCommand
in interface CommandService
id
- The id of the command to get the configuration files for. Not
null/empty/blank.GenieException
- if there is an errorpublic void updateConfigsForCommand(@NotBlank(message="No command id entered. Unable to update configurations.") java.lang.String id, @NotEmpty(message="No configs entered. Unable to update.") java.util.Set<java.lang.String> configs) throws GenieException
updateConfigsForCommand
in interface CommandService
id
- The id of the command to update the configuration files for.
Not null/empty/blank.configs
- The configuration files to replace existing configurations
with. Not null/empty.GenieException
- if there is an errorpublic void removeAllConfigsForCommand(@NotBlank(message="No command id entered. Unable to remove configs.") java.lang.String id) throws GenieException
removeAllConfigsForCommand
in interface CommandService
id
- The id of the command to remove the configuration file from.
Not null/empty/blank.GenieException
- if there is an errorpublic void removeConfigForCommand(@NotBlank(message="No command id entered. Unable to remove configuration.") java.lang.String id, @NotBlank(message="No config entered. Unable to remove.") java.lang.String config) throws GenieException
removeConfigForCommand
in interface CommandService
id
- The id of the command to remove the configuration file from.
Not null/empty/blank.config
- The configuration file to remove. Not null/empty/blank.GenieException
- if there is an errorpublic void addTagsForCommand(@NotBlank(message="No command id entered. Unable to add tags.") java.lang.String id, @NotEmpty(message="No tags entered. Unable to add.") java.util.Set<java.lang.String> tags) throws GenieException
addTagsForCommand
in interface CommandService
id
- The id of the command to add the tags to. Not
null/empty/blank.tags
- The tags to add. Not null/empty.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.Set<java.lang.String> getTagsForCommand(@NotBlank(message="No command id sent. Cannot retrieve tags.") java.lang.String id) throws GenieException
getTagsForCommand
in interface CommandService
id
- The id of the command to get the tags for. Not
null/empty/blank.GenieException
- if there is an errorpublic void updateTagsForCommand(@NotBlank(message="No command id entered. Unable to update tags.") java.lang.String id, @NotEmpty(message="No tags entered. Unable to update.") java.util.Set<java.lang.String> tags) throws GenieException
updateTagsForCommand
in interface CommandService
id
- The id of the command to update the tags for.
Not null/empty/blank.tags
- The tags to replace existing tags
with. Not null/empty.GenieException
- if there is an errorpublic void removeAllTagsForCommand(@NotBlank(message="No command id entered. Unable to remove tags.") java.lang.String id) throws GenieException
removeAllTagsForCommand
in interface CommandService
id
- The id of the command to remove the tags from.
Not null/empty/blank.GenieException
- if there is an errorpublic void removeTagForCommand(@NotBlank(message="No command id entered. Unable to remove tag.") java.lang.String id, @NotBlank(message="No tag entered. Unable to remove.") java.lang.String tag) throws GenieException
removeTagForCommand
in interface CommandService
id
- The id of the command to remove the tag from. Not
null/empty/blank.tag
- The tag to remove. Not null/empty/blank.GenieException
- if there is an errorpublic void addApplicationsForCommand(@NotBlank(message="No command id entered. Unable to add applications.") java.lang.String id, @NotEmpty(message="No application ids entered. Unable to add applications.") java.util.List<java.lang.String> applicationIds) throws GenieException
addApplicationsForCommand
in interface CommandService
id
- The id of the command to add the application file to. Not
null/empty/blank.applicationIds
- The ids of the applications to add. Not null.GenieException
- if there is an errorpublic void setApplicationsForCommand(@NotBlank(message="No command id entered. Unable to set applications.") java.lang.String id, @NotNull(message="No application ids entered. Unable to set applications.") java.util.List<java.lang.String> applicationIds) throws GenieException
setApplicationsForCommand
in interface CommandService
id
- The id of the command to add the application file to. Not
null/empty/blank.applicationIds
- The ids of the applications to set. Not null.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.List<Application> getApplicationsForCommand(@NotBlank(message="No command id entered. Unable to get applications.") java.lang.String id) throws GenieException
getApplicationsForCommand
in interface CommandService
id
- The id of the command to get the application for. Not
null/empty/blank.GenieException
- if there is an errorpublic void removeApplicationsForCommand(@NotBlank(message="No command id entered. Unable to remove applications.") java.lang.String id) throws GenieException
removeApplicationsForCommand
in interface CommandService
id
- The id of the command to remove the application from. Not
null/empty/blank.GenieException
- if there is an errorpublic void removeApplicationForCommand(@NotBlank(message="No command id entered. Unable to remove application.") java.lang.String id, @NotBlank(message="No application id entered. Unable to remove application.") java.lang.String appId) throws GenieException
removeApplicationForCommand
in interface CommandService
id
- The id of the command to remove the application from. Not null/empty/blank.appId
- The id of the application to remove. Not null/empty/blankGenieException
- if there is an error@Transactional(readOnly=true) public java.util.Set<Cluster> getClustersForCommand(@NotBlank(message="No command id entered. Unable to get clusters.") java.lang.String id, java.util.Set<ClusterStatus> statuses) throws GenieException
getClustersForCommand
in interface CommandService
id
- The id of the command to get the clusters for.statuses
- The status of the clusters returnedGenieException
- if there is an error