Skip to content

Commit

Permalink
Add tool - version 1.2
Browse files Browse the repository at this point in the history
Add getParameters.. (),
  • Loading branch information
pierre-yves-monnet committed Jul 7, 2019
1 parent ea49a21 commit 610b618
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>com.bonitasoft.log.event</groupId>
<artifactId>bonita-event</artifactId>
<version>1.1.0</version>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>
52 changes: 52 additions & 0 deletions src/main/java/org/bonitasoft/command/BonitaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,48 @@ public static class ExecuteParameters {
*/
public String verb;
public Map<String, Serializable> parametersCommand;
/** to avoid the cast, return as String parameters. If the parameter is not a String, return null */
public String getParametersString( String name )
{
if (parametersCommand.get(name) == null)
return null;
if (parametersCommand.get( name ) instanceof String)
return (String) parametersCommand.get( name );
return null;
}
/** to avoid the cast, return as Long parameters. If the parameter is not a Long, return null */
public Long getParametersLong( String name )
{
if (parametersCommand.get(name) == null)
return null;
if (parametersCommand.get( name ) instanceof Long)
return (Long) parametersCommand.get( name );
return null;
}
/** to avoid the cast, return as String parameters. If the parameter is not a String, return null */
@SuppressWarnings("unchecked")
public Map<String, Object> getParametersMap( String name )
{
if (parametersCommand.get(name) == null)
return null;
if (parametersCommand.get( name ) instanceof Map<?,?> )
return ( Map<String, Object> ) parametersCommand.get( name );
return null;
}
public Boolean getParametersBoolean( String name )
{
if (parametersCommand.get(name) == null)
return null;
if (parametersCommand.get( name ) instanceof Boolean)
return (Boolean) parametersCommand.get( name );
return null;
}
/**
* the original parameters
*/
public Map<String, Serializable> parameters;


/**
* tenant Id
*/
Expand Down Expand Up @@ -124,6 +162,19 @@ public static class ExecuteAnswer {
*/
public abstract ExecuteAnswer executeCommand(ExecuteParameters executeParameters, TenantServiceAccessor serviceAccessor);


@SuppressWarnings("unchecked")
public ExecuteAnswer executeCommandVerbe(String verb, Map<String,Serializable> parameters, TenantServiceAccessor serviceAccessor)
{
ExecuteParameters executeParameters= new ExecuteParameters();
executeParameters.parameters = parameters;
executeParameters.verb = (String) parameters.get(cstVerb);
executeParameters.setTenantId( (Long) parameters.get(cstTenantId));
executeParameters.parametersCommand = (Map<String,Serializable>) parameters.get(BonitaCommand.cstParametersCommand);

return executeCommand( executeParameters, serviceAccessor);
}

/**
* the command may return any help and instruction to the developper
*
Expand Down Expand Up @@ -163,6 +214,7 @@ public Serializable execute(Map<String, Serializable> parameters, TenantServiceA
* @throws SCommandParameterizationException
* @throws SCommandExecutionException
*/
@SuppressWarnings("unchecked")
private Serializable executeSingleton(Map<String, Serializable> parameters, TenantServiceAccessor serviceAccessor)
throws SCommandParameterizationException, SCommandExecutionException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class BonitaCommandDeployment {

public static String BonitaCommandDeploymentJarName = "bonita-commanddeployment-1.0.0.jar";
public static String BonitaCommandDeploymentJarName = "bonita-commanddeployment-1.2.jar";

static Logger logger = Logger.getLogger(BonitaCommandDeployment.class.getName());

Expand Down

0 comments on commit 610b618

Please sign in to comment.