refactoring: commit4
This commit is contained in:
		
							parent
							
								
									eceec2af0c
								
							
						
					
					
						commit
						835e8d5d1e
					
				@ -147,7 +147,7 @@ public class AlarmController extends BaseController {
 | 
			
		||||
        try {
 | 
			
		||||
            AlarmId alarmId = new AlarmId(toUUID(strAlarmId));
 | 
			
		||||
            Alarm alarm = checkAlarmId(alarmId, Operation.WRITE);
 | 
			
		||||
            return tbAlarmService.delete(alarm, getCurrentUser().getCustomerId(), getCurrentUser());
 | 
			
		||||
            return tbAlarmService.delete(alarm, getCurrentUser());
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw handleException(e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -52,7 +52,6 @@ import org.thingsboard.server.service.gateway_device.GatewayNotificationsService
 | 
			
		||||
import org.thingsboard.server.service.security.model.SecurityUser;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Locale;
 | 
			
		||||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Service
 | 
			
		||||
@ -337,6 +336,27 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static EdgeEventActionType edgeTypeByActionType(ActionType actionType) {
 | 
			
		||||
        return EdgeEventActionType.valueOf(actionType.toString().toUpperCase(Locale.ENGLISH));
 | 
			
		||||
        switch (actionType) {
 | 
			
		||||
            case ADDED:
 | 
			
		||||
                return EdgeEventActionType.ADDED;
 | 
			
		||||
            case UPDATED:
 | 
			
		||||
                return EdgeEventActionType.UPDATED;
 | 
			
		||||
            case ALARM_ACK:
 | 
			
		||||
                return EdgeEventActionType.ALARM_ACK;
 | 
			
		||||
            case ALARM_CLEAR:
 | 
			
		||||
                return EdgeEventActionType.ALARM_CLEAR;
 | 
			
		||||
            case DELETED:
 | 
			
		||||
                return EdgeEventActionType.DELETED;
 | 
			
		||||
            case RELATION_ADD_OR_UPDATE:
 | 
			
		||||
                return EdgeEventActionType.RELATION_ADD_OR_UPDATE;
 | 
			
		||||
            case RELATION_DELETED:
 | 
			
		||||
                return EdgeEventActionType.RELATION_DELETED;
 | 
			
		||||
            case ASSIGNED_TO_EDGE:
 | 
			
		||||
                return EdgeEventActionType.ASSIGNED_TO_EDGE;
 | 
			
		||||
            case UNASSIGNED_FROM_EDGE:
 | 
			
		||||
                return EdgeEventActionType.UNASSIGNED_FROM_EDGE;
 | 
			
		||||
            default:
 | 
			
		||||
                return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,6 @@ import org.thingsboard.server.common.data.alarm.Alarm;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.AlarmStatus;
 | 
			
		||||
import org.thingsboard.server.common.data.audit.ActionType;
 | 
			
		||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
 | 
			
		||||
import org.thingsboard.server.common.data.id.CustomerId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.EdgeId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
			
		||||
import org.thingsboard.server.queue.util.TbCoreComponent;
 | 
			
		||||
@ -78,13 +77,12 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean delete(Alarm alarm, CustomerId customerId, SecurityUser user) throws ThingsboardException {
 | 
			
		||||
        TenantId tenantId = alarm.getTenantId();
 | 
			
		||||
    public Boolean delete(Alarm alarm, SecurityUser user) throws ThingsboardException {
 | 
			
		||||
        try {
 | 
			
		||||
            List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(tenantId, alarm.getOriginator());
 | 
			
		||||
            notificationEntityService.notifyDeleteAlarm(tenantId, alarm, alarm.getOriginator(), customerId,
 | 
			
		||||
            List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(user.getTenantId(), alarm.getOriginator());
 | 
			
		||||
            notificationEntityService.notifyDeleteAlarm(user.getTenantId(), alarm, alarm.getOriginator(), user.getCustomerId(),
 | 
			
		||||
                    relatedEdgeIds, user, JacksonUtil.OBJECT_MAPPER.writeValueAsString(alarm));
 | 
			
		||||
            return alarmService.deleteAlarm(tenantId, alarm.getId()).isSuccessful();
 | 
			
		||||
            return alarmService.deleteAlarm(user.getTenantId(), alarm.getId()).isSuccessful();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw handleException(e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,6 @@ package org.thingsboard.server.service.entitiy.alarm;
 | 
			
		||||
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.Alarm;
 | 
			
		||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
 | 
			
		||||
import org.thingsboard.server.common.data.id.CustomerId;
 | 
			
		||||
import org.thingsboard.server.service.security.model.SecurityUser;
 | 
			
		||||
 | 
			
		||||
public interface TbAlarmService {
 | 
			
		||||
@ -28,5 +27,5 @@ public interface TbAlarmService {
 | 
			
		||||
 | 
			
		||||
    void clear(Alarm alarm, SecurityUser user) throws ThingsboardException;
 | 
			
		||||
 | 
			
		||||
    Boolean delete(Alarm alarm, CustomerId customerId, SecurityUser user) throws ThingsboardException;
 | 
			
		||||
    Boolean delete(Alarm alarm, SecurityUser user) throws ThingsboardException;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user