Adding the changes for operation activity id

4.x.x
geethkokila 9 years ago
parent 49513ba79b
commit 6f9851413e

@ -44,6 +44,7 @@ public class Operation implements Serializable {
private boolean isEnabled;
private Object payLoad;
private String operationResponse;
private String activityId;
@Override
public boolean equals(Object o) {
@ -191,6 +192,14 @@ public class Operation implements Serializable {
this.operationResponse = operationResponse;
}
public String getActivityId() {
return activityId;
}
public void setActivityId(String activityId) {
this.activityId = activityId;
}
@Override
public String toString() {
return "Operation{" +

@ -85,4 +85,6 @@ public interface OperationManager {
Operation getOperation(int operationId) throws OperationManagementException;
Operation getOperationByActivityId(String activity) throws OperationManagementException;
}

@ -75,4 +75,9 @@ public final class DeviceManagementConstants {
public static final String DOWNLOAD_URL = "download-url";
}
public static final class OperationAttributes {
private OperationAttributes() {throw new AssertionError(); }
public static final String ACTIVITY = "ACTIVITY_";
}
}

@ -648,6 +648,17 @@ public class OperationManagerImpl implements OperationManager {
return operation;
}
@Override
public Operation getOperationByActivityId(String activity) throws OperationManagementException {
// This parses the operation id from activity id (ex : ACTIVITY_23) and converts to the integer.
int operationId = Integer.parseInt(
activity.replace(DeviceManagementConstants.OperationAttributes.ACTIVITY, ""));
if(operationId == 0){
throw new IllegalArgumentException("Operation ID cannot be null or zero (0).");
}
return this.getOperation(operationId);
}
private OperationDAO lookupOperationDAO(Operation operation) {
if (operation instanceof CommandOperation) {

@ -18,6 +18,7 @@
*/
package org.wso2.carbon.device.mgt.core.operation.mgt.dao.util;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.*;
public class OperationDAOUtil {
@ -94,6 +95,7 @@ public class OperationDAOUtil {
operation.setReceivedTimeStamp(dtoOperation.getReceivedTimeStamp());
operation.setEnabled(dtoOperation.isEnabled());
operation.setProperties(dtoOperation.getProperties());
operation.setActivityId(DeviceManagementConstants.OperationAttributes.ACTIVITY + dtoOperation.getId());
return operation;
}

@ -867,6 +867,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperation(operationId);
}
@Override
public Operation getOperationByActivityId(String activity) throws OperationManagementException {
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByActivityId(activity);
}
@Override
public List<Device> getDevicesOfUser(String username) throws DeviceManagementException {
List<Device> devices = new ArrayList<>();

Loading…
Cancel
Save