Fixed entity save and fixed system widgets retrieve
This commit is contained in:
parent
5f92fd29d2
commit
0ce99115cf
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.thingsboard.server.dao.sql;
|
||||
|
||||
import com.datastax.driver.core.utils.UUIDs;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
@ -61,6 +62,9 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao<
|
||||
((SearchTextEntity) entity).setSearchText(((SearchTextEntity) entity).getSearchTextSource().toLowerCase());
|
||||
}
|
||||
log.debug("Saving entity {}", entity);
|
||||
if (entity.getId() == null) {
|
||||
entity.setId(UUIDs.timeBased());
|
||||
}
|
||||
entity = getCrudRepository().save(entity);
|
||||
return DaoUtil.getData(entity);
|
||||
}
|
||||
|
||||
@ -23,14 +23,13 @@ import org.thingsboard.server.common.data.page.TextPageLink;
|
||||
import org.thingsboard.server.common.data.widget.WidgetsBundle;
|
||||
import org.thingsboard.server.dao.DaoUtil;
|
||||
import org.thingsboard.server.dao.model.sql.WidgetsBundleEntity;
|
||||
import org.thingsboard.server.dao.sql.JpaAbstractDao;
|
||||
import org.thingsboard.server.dao.sql.JpaAbstractSearchTextDao;
|
||||
import org.thingsboard.server.dao.widget.WidgetsBundleDao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.WIDGETS_BUNDLE_COLUMN_FAMILY_NAME;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
|
||||
|
||||
/**
|
||||
* Created by Valerii Sosliuk on 4/23/2017.
|
||||
@ -62,10 +61,10 @@ public class JpaWidgetsBundleDao extends JpaAbstractSearchTextDao<WidgetsBundleE
|
||||
public List<WidgetsBundle> findSystemWidgetsBundles(TextPageLink pageLink) {
|
||||
if (pageLink.getIdOffset() == null) {
|
||||
return DaoUtil.convertDataList(widgetsBundleRepository.findSystemWidgetsBundlesFirstPage(pageLink.getLimit(),
|
||||
pageLink.getTextSearch()));
|
||||
pageLink.getTextSearch(), NULL_UUID));
|
||||
} else {
|
||||
return DaoUtil.convertDataList(widgetsBundleRepository.findSystemWidgetsBundlesNextPage(pageLink.getLimit(),
|
||||
pageLink.getTextSearch(), pageLink.getIdOffset()));
|
||||
pageLink.getTextSearch(), pageLink.getIdOffset(), NULL_UUID));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,15 +31,15 @@ public interface WidgetsBundleRepository extends CrudRepository<WidgetsBundleEnt
|
||||
|
||||
WidgetsBundleEntity findWidgetsBundleByTenantIdAndAlias(UUID tenantId, String alias);
|
||||
|
||||
@Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID IS NULL " +
|
||||
@Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID = ?3 " +
|
||||
"AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?2, '%')) " +
|
||||
"ORDER BY ID LIMIT ?1")
|
||||
List<WidgetsBundleEntity> findSystemWidgetsBundlesFirstPage(Integer limit, String searchText);
|
||||
List<WidgetsBundleEntity> findSystemWidgetsBundlesFirstPage(Integer limit, String searchText, UUID tenantId);
|
||||
|
||||
@Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID IS NULL " +
|
||||
@Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID = ?4 " +
|
||||
"AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?2, '%')) " +
|
||||
"AND ID > ?3 ORDER BY ID LIMIT ?1")
|
||||
List<WidgetsBundleEntity> findSystemWidgetsBundlesNextPage(Integer limit, String searchText, UUID idOffset);
|
||||
List<WidgetsBundleEntity> findSystemWidgetsBundlesNextPage(Integer limit, String searchText, UUID idOffset, UUID tenantId);
|
||||
|
||||
@Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID = ?2 " +
|
||||
"AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?3, '%')) " +
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user