fixed pull request comments
This commit is contained in:
		
							parent
							
								
									ed37dc850a
								
							
						
					
					
						commit
						7203c15dec
					
				@ -118,6 +118,6 @@ public class AlarmCommentController extends BaseController {
 | 
			
		||||
        Alarm alarm = checkAlarmId(alarmId, Operation.WRITE);
 | 
			
		||||
 | 
			
		||||
        PageLink pageLink = createPageLink(pageSize, page, null, sortProperty, sortOrder);
 | 
			
		||||
        return checkNotNull(alarmCommentService.findAlarmComments(alarm.getTenantId(), alarmId, pageLink).get());
 | 
			
		||||
        return checkNotNull(alarmCommentService.findAlarmComments(alarm.getTenantId(), alarmId, pageLink));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -106,6 +106,7 @@ public interface TbNotificationEntityService {
 | 
			
		||||
    void notifyCreateOrUpdateAlarmComment(Alarm alarm, AlarmComment alarmComment, ActionType actionType, User user);
 | 
			
		||||
 | 
			
		||||
    void notifyDeleteAlarmComment(Alarm alarm,  AlarmComment alarmComment, User user);
 | 
			
		||||
 | 
			
		||||
    <E extends HasName, I extends EntityId> void notifyCreateOrUpdateOrDelete(TenantId tenantId, CustomerId customerId,
 | 
			
		||||
                                                                              I entityId, E entity, User user,
 | 
			
		||||
                                                                              ActionType actionType, boolean sendNotifyMsgToEdge,
 | 
			
		||||
 | 
			
		||||
@ -43,6 +43,7 @@ public class DefaultTbAlarmCommentService extends AbstractTbEntityService implem
 | 
			
		||||
            throw e;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean deleteAlarmComment(Alarm alarm, AlarmComment alarmComment, User user) {
 | 
			
		||||
        notificationEntityService.notifyDeleteAlarmComment(alarm, alarmComment, user);
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,6 @@ public class AlarmCommentOperationResult {
 | 
			
		||||
    private final boolean successful;
 | 
			
		||||
    private final boolean created;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public AlarmCommentOperationResult(AlarmComment alarmComment, boolean successful) {
 | 
			
		||||
        this(alarmComment, successful, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,7 @@ public interface AlarmCommentService {
 | 
			
		||||
 | 
			
		||||
    AlarmCommentOperationResult deleteAlarmComment(TenantId tenantId, AlarmCommentId alarmCommentId);
 | 
			
		||||
 | 
			
		||||
    ListenableFuture<PageData<AlarmCommentInfo>> findAlarmComments(TenantId tenantId, AlarmId alarmId, PageLink pageLink);
 | 
			
		||||
    PageData<AlarmCommentInfo>findAlarmComments(TenantId tenantId, AlarmId alarmId, PageLink pageLink);
 | 
			
		||||
 | 
			
		||||
    ListenableFuture<AlarmComment> findAlarmCommentByIdAsync(TenantId tenantId, AlarmCommentId alarmCommentId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,13 +33,13 @@ import org.thingsboard.server.common.data.id.UserId;
 | 
			
		||||
@Builder
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
public class AlarmComment extends BaseData<AlarmCommentId> implements HasName {
 | 
			
		||||
    @ApiModelProperty(position = 2, value = "JSON object with Alarm id.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
 | 
			
		||||
    @ApiModelProperty(position = 3, value = "JSON object with Alarm id.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
 | 
			
		||||
    private EntityId alarmId;
 | 
			
		||||
    @ApiModelProperty(position = 3, value = "JSON object with User id.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
 | 
			
		||||
    @ApiModelProperty(position = 4, value = "JSON object with User id.", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
 | 
			
		||||
    private UserId userId;
 | 
			
		||||
    @ApiModelProperty(position = 4, value = "Defines origination of comment", example = "System/Other", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
 | 
			
		||||
    @ApiModelProperty(position = 5, value = "Defines origination of comment", example = "System/Other", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
 | 
			
		||||
    private String type;
 | 
			
		||||
    @ApiModelProperty(position = 5, value = "JSON object with text of comment.", dataType = "com.fasterxml.jackson.databind.JsonNode")
 | 
			
		||||
    @ApiModelProperty(position = 6, value = "JSON object with text of comment.", dataType = "com.fasterxml.jackson.databind.JsonNode")
 | 
			
		||||
    private transient JsonNode comment;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(position = 1, value = "JSON object with the alarm comment Id. " +
 | 
			
		||||
 | 
			
		||||
@ -72,9 +72,8 @@ public class BaseAlarmCommentService extends AbstractEntityService implements Al
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ListenableFuture<PageData<AlarmCommentInfo>> findAlarmComments(TenantId tenantId, AlarmId alarmId, PageLink pageLink) {
 | 
			
		||||
        PageData<AlarmCommentInfo> alarmComments = alarmCommentDao.findAlarmComments(tenantId, alarmId, pageLink);
 | 
			
		||||
        return fetchAlarmCommentUserNames(tenantId, alarmComments);
 | 
			
		||||
    public PageData<AlarmCommentInfo> findAlarmComments(TenantId tenantId, AlarmId alarmId, PageLink pageLink) {
 | 
			
		||||
        return alarmCommentDao.findAlarmComments(tenantId, alarmId, pageLink);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private ListenableFuture<PageData<AlarmCommentInfo>> fetchAlarmCommentUserNames(TenantId tenantId, PageData<AlarmCommentInfo> alarmComments) {
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,9 @@ import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.AlarmCommentInfo;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
public class AlarmCommentInfoEntity extends AbstractAlarmCommentEntity<AlarmCommentInfo> {
 | 
			
		||||
@ -34,6 +37,12 @@ public class AlarmCommentInfoEntity extends AbstractAlarmCommentEntity<AlarmComm
 | 
			
		||||
        super(alarmCommentEntity);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public AlarmCommentInfoEntity(AlarmCommentEntity alarmCommentEntity, String firstName, String lastName) {
 | 
			
		||||
        super(alarmCommentEntity);
 | 
			
		||||
        this.firstName = firstName;
 | 
			
		||||
        this.lastName = lastName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public AlarmCommentInfo toData() {
 | 
			
		||||
        return new AlarmCommentInfo(super.toAlarmComment(), this.firstName, this.lastName);
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,8 @@ import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public interface AlarmCommentRepository extends JpaRepository<AlarmCommentEntity, UUID> {
 | 
			
		||||
 | 
			
		||||
    @Query(value = "SELECT new org.thingsboard.server.dao.model.sql.AlarmCommentInfoEntity(a) FROM AlarmCommentEntity a " +
 | 
			
		||||
    @Query(value = "SELECT new org.thingsboard.server.dao.model.sql.AlarmCommentInfoEntity(a, u.firstName, u.lastName) FROM AlarmCommentEntity a " +
 | 
			
		||||
            "LEFT JOIN UserEntity u on u.id = a.userId " +
 | 
			
		||||
            "WHERE a.alarmId = :alarmId ",
 | 
			
		||||
            countQuery = "" +
 | 
			
		||||
                    "SELECT count(a) " +
 | 
			
		||||
 | 
			
		||||
@ -55,7 +55,7 @@ public class JpaAlarmCommentDao extends JpaAbstractDao<AlarmCommentEntity, Alarm
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public AlarmComment createAlarmComment(TenantId tenantId, AlarmComment alarmComment){
 | 
			
		||||
        log.debug("Saving entity {}", alarmComment);
 | 
			
		||||
        log.trace("Saving entity {}", alarmComment);
 | 
			
		||||
        partitioningRepository.createPartitionIfNotExists(ALARM_COMMENT_COLUMN_FAMILY_NAME, alarmComment.getCreatedTime(), TimeUnit.HOURS.toMillis(partitionSizeInHours));
 | 
			
		||||
        AlarmCommentEntity saved = alarmCommentRepository.save(new AlarmCommentEntity(alarmComment));
 | 
			
		||||
        return DaoUtil.getData(saved);
 | 
			
		||||
@ -74,7 +74,7 @@ public class JpaAlarmCommentDao extends JpaAbstractDao<AlarmCommentEntity, Alarm
 | 
			
		||||
                alarmCommentRepository.findAllByAlarmId(id.getId(), DaoUtil.toPageable(pageLink)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public AlarmComment findAlarmCommentById(TenantId tenantId, UUID key) {
 | 
			
		||||
        return DaoUtil.getData(alarmCommentRepository.findById(key));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -95,7 +95,7 @@ public abstract class BaseAlarmCommentServiceTest extends AbstractServiceTest {
 | 
			
		||||
        AlarmComment fetched = alarmCommentService.findAlarmCommentByIdAsync(tenantId, createdComment.getId()).get();
 | 
			
		||||
        Assert.assertEquals(createdComment, fetched);
 | 
			
		||||
 | 
			
		||||
        PageData<AlarmCommentInfo> alarmComments = alarmCommentService.findAlarmComments(tenantId, alarm.getId(), new PageLink(10, 0)).get();
 | 
			
		||||
        PageData<AlarmCommentInfo> alarmComments = alarmCommentService.findAlarmComments(tenantId, alarm.getId(), new PageLink(10, 0));
 | 
			
		||||
        Assert.assertNotNull(alarmComments.getData());
 | 
			
		||||
        Assert.assertEquals(1, alarmComments.getData().size());
 | 
			
		||||
        Assert.assertEquals(createdComment, alarmComments.getData().get(0));
 | 
			
		||||
@ -131,7 +131,7 @@ public abstract class BaseAlarmCommentServiceTest extends AbstractServiceTest {
 | 
			
		||||
        AlarmComment fetched = alarmCommentService.findAlarmCommentByIdAsync(tenantId, createdComment.getId()).get();
 | 
			
		||||
        Assert.assertEquals(updatedComment, fetched);
 | 
			
		||||
 | 
			
		||||
        PageData<AlarmCommentInfo> alarmComments = alarmCommentService.findAlarmComments(tenantId, alarm.getId(), new PageLink(10, 0)).get();
 | 
			
		||||
        PageData<AlarmCommentInfo> alarmComments = alarmCommentService.findAlarmComments(tenantId, alarm.getId(), new PageLink(10, 0));
 | 
			
		||||
        Assert.assertNotNull(alarmComments.getData());
 | 
			
		||||
        Assert.assertEquals(1, alarmComments.getData().size());
 | 
			
		||||
        Assert.assertEquals(new AlarmCommentInfo(updatedComment), alarmComments.getData().get(0));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user