Search in sources :

Example 1 with JSONObject

use of org.activiti.engine.impl.util.json.JSONObject in project Activiti by Activiti.

the class TimerActivateProcessDefinitionHandler method execute.

public void execute(JobEntity job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
    JSONObject cfgJson = new JSONObject(configuration);
    String processDefinitionId = job.getProcessDefinitionId();
    boolean activateProcessInstances = getIncludeProcessInstances(cfgJson);
    ActivateProcessDefinitionCmd activateProcessDefinitionCmd = new ActivateProcessDefinitionCmd(processDefinitionId, null, activateProcessInstances, null, job.getTenantId());
    activateProcessDefinitionCmd.execute(commandContext);
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) ActivateProcessDefinitionCmd(org.activiti.engine.impl.cmd.ActivateProcessDefinitionCmd)

Example 2 with JSONObject

use of org.activiti.engine.impl.util.json.JSONObject in project Activiti by Activiti.

the class TimerEventHandler method createConfiguration.

public static String createConfiguration(String id, Expression endDate, Expression calendarName) {
    JSONObject cfgJson = new JSONObject();
    cfgJson.put(PROPERTYNAME_TIMER_ACTIVITY_ID, id);
    if (endDate != null) {
        cfgJson.put(PROPERTYNAME_END_DATE_EXPRESSION, endDate.getExpressionText());
    }
    if (calendarName != null) {
        cfgJson.put(PROPERTYNAME_CALENDAR_NAME_EXPRESSION, calendarName.getExpressionText());
    }
    return cfgJson.toString();
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject)

Example 3 with JSONObject

use of org.activiti.engine.impl.util.json.JSONObject in project Activiti by Activiti.

the class TimerEventHandler method setActivityIdToConfiguration.

public String setActivityIdToConfiguration(String jobHandlerConfiguration, String activityId) {
    try {
        JSONObject cfgJson = new JSONObject(jobHandlerConfiguration);
        cfgJson.put(PROPERTYNAME_TIMER_ACTIVITY_ID, activityId);
        return cfgJson.toString();
    } catch (JSONException ex) {
        return jobHandlerConfiguration;
    }
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) JSONException(org.activiti.engine.impl.util.json.JSONException)

Example 4 with JSONObject

use of org.activiti.engine.impl.util.json.JSONObject in project Activiti by Activiti.

the class TimerEventHandler method hasRealActivityId.

/**
   * Before Activiti 5.21, the jobHandlerConfiguration would have as activityId the process definition key
   * (as only one timer start event was supported). In >= 5.21, this changed and in >= 5.21 the activityId 
   * is the REAL activity id. It can be recognized by having the 'processDefinitionKey' in the configuration.
   * A < 5.21 job would not have that.
   */
public static boolean hasRealActivityId(String jobHandlerConfiguration) {
    try {
        JSONObject cfgJson = new JSONObject(jobHandlerConfiguration);
        Object processDefinitionKey = cfgJson.get(PROPERTYNAME_PROCESS_DEFINITION_KEY);
        if (processDefinitionKey != null) {
            return processDefinitionKey.toString().length() > 0;
        }
    } catch (JSONException ex) {
        return false;
    }
    return false;
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) JSONException(org.activiti.engine.impl.util.json.JSONException) JSONObject(org.activiti.engine.impl.util.json.JSONObject)

Example 5 with JSONObject

use of org.activiti.engine.impl.util.json.JSONObject in project Activiti by Activiti.

the class TimerEventHandler method setProcessDefinitionKeyToConfiguration.

public String setProcessDefinitionKeyToConfiguration(String jobHandlerConfiguration, String activityId) {
    try {
        JSONObject cfgJson = new JSONObject(jobHandlerConfiguration);
        cfgJson.put(PROPERTYNAME_PROCESS_DEFINITION_KEY, activityId);
        return cfgJson.toString();
    } catch (JSONException ex) {
        return jobHandlerConfiguration;
    }
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) JSONException(org.activiti.engine.impl.util.json.JSONException)

Aggregations

JSONObject (org.activiti.engine.impl.util.json.JSONObject)11 JSONException (org.activiti.engine.impl.util.json.JSONException)3 List (java.util.List)1 ProcessEngineInfoImpl (org.activiti.engine.impl.ProcessEngineInfoImpl)1 ActivateProcessDefinitionCmd (org.activiti.engine.impl.cmd.ActivateProcessDefinitionCmd)1 SuspendProcessDefinitionCmd (org.activiti.engine.impl.cmd.SuspendProcessDefinitionCmd)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1