Skip to content

Package: DeviceCommandExecTargetProcessor

DeviceCommandExecTargetProcessor

nameinstructionbranchcomplexitylinemethod
DeviceCommandExecTargetProcessor()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
initProcessing(JobTargetWrapper)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
lambda$processTarget$0(JobTarget, DeviceCommandInput, Long)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
processTarget(JobTarget)
M: 21 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.management.command.job;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.commons.security.KapuaSecurityUtils;
17: import org.eclipse.kapua.job.engine.commons.operation.AbstractDeviceTargetProcessor;
18: import org.eclipse.kapua.job.engine.commons.wrappers.JobTargetWrapper;
19: import org.eclipse.kapua.model.id.KapuaId;
20: import org.eclipse.kapua.service.device.management.command.DeviceCommandInput;
21: import org.eclipse.kapua.service.device.management.command.DeviceCommandManagementService;
22: import org.eclipse.kapua.service.device.management.command.job.definition.DeviceCommandExecPropertyKeys;
23: import org.eclipse.kapua.service.job.operation.TargetProcessor;
24: import org.eclipse.kapua.service.job.targets.JobTarget;
25:
26: import javax.batch.runtime.context.JobContext;
27: import javax.batch.runtime.context.StepContext;
28: import javax.inject.Inject;
29:
30: /**
31: * {@link TargetProcessor} for {@link DeviceCommandManagementService#exec(KapuaId, KapuaId, DeviceCommandInput, Long)}.
32: *
33: * @since 1.0.0
34: */
35: public class DeviceCommandExecTargetProcessor extends AbstractDeviceTargetProcessor implements TargetProcessor {
36: private static final DeviceCommandManagementService COMMAND_MANAGEMENT_SERVICE = LOCATOR.getService(DeviceCommandManagementService.class);
37:
38: @Inject
39: JobContext jobContext;
40:
41: @Inject
42: StepContext stepContext;
43:
44: @Override
45: protected void initProcessing(JobTargetWrapper wrappedJobTarget) {
46: setContext(jobContext, stepContext);
47: }
48:
49: @Override
50: public void processTarget(JobTarget jobTarget) throws KapuaException {
51:
52: DeviceCommandInput commandInput = stepContextWrapper.getStepProperty(DeviceCommandExecPropertyKeys.COMMAND_INPUT, DeviceCommandInput.class);
53: Long timeout = stepContextWrapper.getStepProperty(DeviceCommandExecPropertyKeys.TIMEOUT, Long.class);
54:
55: KapuaSecurityUtils.doPrivileged(() -> COMMAND_MANAGEMENT_SERVICE.exec(jobTarget.getScopeId(), jobTarget.getJobTargetId(), commandInput, timeout));
56: }
57: }