Search in sources :

Example 1 with ActionTask

use of org.platformlayer.ops.schedule.ActionTask in project platformlayer by platformlayer.

the class JdbcSchedulerRepository method fromDb.

private SchedulerRecord fromDb(SchedulerRecordEntity in) throws OpsException {
    SchedulerRecord out = new SchedulerRecord();
    out.key = in.key;
    out.schedule = new JobSchedule();
    out.schedule.base = in.scheduleBase;
    out.schedule.interval = in.scheduleInterval;
    ActionTask task = new ActionTask();
    out.task = task;
    task.target = PlatformLayerKey.parse(in.taskTarget);
    task.endpoint = new EndpointRecord();
    task.endpoint.url = in.taskEndpointUrl;
    task.endpoint.project = in.taskEndpointProject;
    task.endpoint.secret = fromDb(in.taskEndpointSecret);
    task.endpoint.token = in.taskEndpointToken;
    task.endpoint.trustKeys = in.taskEndpointTrustKeys;
    if (in.taskAction != null) {
        task.action = deserializeAction(in.taskAction);
    }
    return out;
}
Also used : JobSchedule(org.platformlayer.core.model.JobSchedule) ActionTask(org.platformlayer.ops.schedule.ActionTask) EndpointRecord(org.platformlayer.ops.schedule.EndpointRecord) SchedulerRecord(org.platformlayer.ops.schedule.SchedulerRecord)

Example 2 with ActionTask

use of org.platformlayer.ops.schedule.ActionTask in project platformlayer by platformlayer.

the class JdbcSchedulerRepository method toDb.

private SchedulerRecordEntity toDb(SchedulerRecord in) throws OpsException {
    SchedulerRecordEntity out = new SchedulerRecordEntity();
    out.key = in.key;
    if (in.schedule != null) {
        out.scheduleBase = in.schedule.base;
        out.scheduleInterval = in.schedule.interval;
    }
    if (in.task instanceof ActionTask) {
        ActionTask task = (ActionTask) in.task;
        out.taskTarget = task.target.getUrl();
        if (task.endpoint != null) {
            out.taskEndpointUrl = task.endpoint.url;
            out.taskEndpointProject = task.endpoint.project;
            out.taskEndpointSecret = toDb(task.endpoint.secret);
            out.taskEndpointToken = task.endpoint.token;
            out.taskEndpointTrustKeys = task.endpoint.trustKeys;
        }
        if (task.action != null) {
            out.taskAction = serializeAction(task.action);
        }
    } else {
        throw new UnsupportedOperationException();
    }
    return out;
}
Also used : ActionTask(org.platformlayer.ops.schedule.ActionTask)

Aggregations

ActionTask (org.platformlayer.ops.schedule.ActionTask)2 JobSchedule (org.platformlayer.core.model.JobSchedule)1 EndpointRecord (org.platformlayer.ops.schedule.EndpointRecord)1 SchedulerRecord (org.platformlayer.ops.schedule.SchedulerRecord)1