Commit d3ba64683c53c81c341976cb993f37e7bf354fd6

Authored by viktorbasanets
1 parent 77de5522

Were added all necessary methods

... ... @@ -67,49 +67,75 @@ public class CassandraEntityViewDao extends CassandraAbstractSearchTextDao<Entit
67 67
68 68 @Override
69 69 public List<EntityView> findEntityViewByTenantId(UUID tenantId, TextPageLink pageLink) {
70   - log.debug("Try to find entity-views by tenantId [{}] and pageLink [{}]", tenantId, pageLink);
  70 + log.debug("Try to find entity views by tenantId [{}] and pageLink [{}]", tenantId, pageLink);
71 71 List<EntityViewEntity> entityViewEntities =
72 72 findPageWithTextSearch(ENTITY_VIEW_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME,
73   - Collections.singletonList(eq(ENTITY_VIEW_TENANT_ID_PROPERTY, tenantId)), pageLink);
74   -
75   - log.trace("Found entity-views [{}] by tenantId [{}] and pageLink [{}]", entityViewEntities, tenantId, pageLink);
  73 + Collections.singletonList(eq(TENANT_ID_PROPERTY, tenantId)), pageLink);
  74 + log.trace("Found entity views [{}] by tenantId [{}] and pageLink [{}]",
  75 + entityViewEntities, tenantId, pageLink);
76 76 return DaoUtil.convertDataList(entityViewEntities);
77 77 }
78 78
79 79 @Override
80   - public Optional<EntityView> findEntityViewByTenantIdAndName(UUID tenantId, String entityViewName) {
81   - return Optional.ofNullable(DaoUtil.getData(
82   - findOneByStatement(select().from(ENTITY_VIEW_TENANT_AND_NAME_VIEW_NAME).where()
83   - .and(eq(ENTITY_VIEW_TENANT_ID_PROPERTY, tenantId))
84   - .and(eq(ENTITY_VIEW_NAME_PROPERTY, entityViewName))))
85   - );
  80 + public Optional<EntityView> findEntityViewByTenantIdAndName(UUID tenantId, String name) {
  81 + Select.Where query = select().from(ENTITY_VIEW_BY_TENANT_AND_NAME).where();
  82 + query.and(eq(ENTITY_VIEW_TENANT_ID_PROPERTY, tenantId));
  83 + query.and(eq(ENTITY_VIEW_NAME_PROPERTY, name));
  84 + return Optional.ofNullable(DaoUtil.getData(findOneByStatement(query)));
86 85 }
87 86
88 87 @Override
89 88 public List<EntityView> findEntityViewByTenantIdAndEntityId(UUID tenantId, UUID entityId, TextPageLink pageLink) {
90   - log.debug("Try to find entity-views by tenantId [{}], entityId[{}] and pageLink [{}]", tenantId, entityId, pageLink);
91   - List<EntityViewEntity> entityViewEntities = findPageWithTextSearch(DEVICE_BY_CUSTOMER_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME,
92   - Arrays.asList(eq(DEVICE_CUSTOMER_ID_PROPERTY, entityId),
93   - eq(DEVICE_TENANT_ID_PROPERTY, tenantId)),
  89 + log.debug("Try to find entity views by tenantId [{}], entityId [{}] and pageLink [{}]",
  90 + tenantId, entityId, pageLink);
  91 + List<EntityViewEntity> entityViewEntities = findPageWithTextSearch(
  92 + ENTITY_VIEW_BY_TENANT_AND_ENTITY_AND_SEARCH_TEXT,
  93 + Arrays.asList(eq(CUSTOMER_ID_PROPERTY, entityId), eq(TENANT_ID_PROPERTY, tenantId)),
94 94 pageLink);
95   -
96   - log.trace("Found entity-views [{}] by tenantId [{}], entityId [{}] and pageLink [{}]", entityViewEntities, tenantId, entityId, pageLink);
  95 + log.trace("Found entity views [{}] by tenantId [{}], entityId [{}] and pageLink [{}]",
  96 + entityViewEntities, tenantId, entityId, pageLink);
97 97 return DaoUtil.convertDataList(entityViewEntities);
98 98 }
99 99
100 100 @Override
101 101 public List<EntityView> findEntityViewsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) {
102   - return null;
  102 + log.debug("Try to find entity views by tenantId [{}], customerId[{}] and pageLink [{}]",
  103 + tenantId, customerId, pageLink);
  104 + List<EntityViewEntity> entityViewEntities = findPageWithTextSearch(
  105 + ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_SEARCH_TEXT,
  106 + Arrays.asList(eq(CUSTOMER_ID_PROPERTY, customerId), eq(TENANT_ID_PROPERTY, tenantId)),
  107 + pageLink);
  108 + log.trace("Found find entity views [{}] by tenantId [{}], customerId [{}] and pageLink [{}]",
  109 + entityViewEntities, tenantId, customerId, pageLink);
  110 + return DaoUtil.convertDataList(entityViewEntities);
103 111 }
104 112
105 113 @Override
106   - public List<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(UUID tenantId, UUID customerId, UUID entityId, TextPageLink pageLink) {
107   - return null;
  114 + public List<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(UUID tenantId,
  115 + UUID customerId,
  116 + UUID entityId,
  117 + TextPageLink pageLink) {
  118 +
  119 + log.debug("Try to find entity views by tenantId [{}], customerId [{}], entityId [{}] and pageLink [{}]",
  120 + tenantId, customerId, entityId, pageLink);
  121 + List<EntityViewEntity> entityViewEntities = findPageWithTextSearch(
  122 + ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_ENTITY_AND_SEARCH_TEXT,
  123 + Arrays.asList(
  124 + eq(TENANT_ID_PROPERTY, tenantId),
  125 + eq(CUSTOMER_ID_PROPERTY, customerId),
  126 + eq(ENTITY_ID_COLUMN, entityId)),
  127 + pageLink);
  128 + log.trace("Found devices [{}] by tenantId [{}], customerId [{}], entityId [{}] and pageLink [{}]",
  129 + entityViewEntities, tenantId, customerId, entityId, pageLink);
  130 + return DaoUtil.convertDataList(entityViewEntities);
108 131 }
109 132
110 133 @Override
111 134 public ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndEntityIdAsync(UUID tenantId, UUID entityId) {
112   - // TODO: implement this
113   - return null;
  135 + log.debug("Try to find entity views by tenantId [{}] and entityId [{}]", tenantId, entityId);
  136 + Select.Where query = select().from(getColumnFamilyName()).where();
  137 + query.and(eq(TENANT_ID_PROPERTY, tenantId));
  138 + query.and(eq(ENTITY_ID_COLUMN, entityId));
  139 + return findListByStatementAsync(query);
114 140 }
115 141 }
... ...
... ... @@ -150,13 +150,15 @@ public class ModelConstants {
150 150 public static final String ENTITY_VIEW_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY;
151 151 public static final String ENTITY_VIEW_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY;
152 152 public static final String ENTITY_VIEW_NAME_PROPERTY = DEVICE_NAME_PROPERTY;
153   - public static final String ENTITY_VIEW_BY_CUSTOMER_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "entity_view_by_customer_and_search_text";
154   - public static final String ENTITY_VIEW_TENANT_AND_NAME_VIEW_NAME = "entity_view_by_tenant_and_name";
  153 + public static final String ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_ENTITY_AND_SEARCH_TEXT = "entity_views_by_tenant_and_customer_and_entity_and_search_text";
  154 + public static final String ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_SEARCH_TEXT = "entity_views_by_tenant_and_customer_and_search_text";
155 155 public static final String ENTITY_VIEW_KEYS_PROPERTY = "keys";
156 156 public static final String ENTITY_VIEW_START_TS_PROPERTY = "start_ts";
157 157 public static final String ENTITY_VIEW_END_TS_PROPERTY = "end_ts";
158 158 public static final String ENTITY_VIEW_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY;
159 159 public static final String ENTITY_VIEW_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "entity_view_by_tenant_and_search_text";
  160 + public static final String ENTITY_VIEW_BY_TENANT_AND_NAME = "entity_views_by_tenant_and_name";
  161 + public static final String ENTITY_VIEW_BY_TENANT_AND_ENTITY_AND_SEARCH_TEXT = "entity_view_by_tenant_and_entity_and_search_text";
160 162
161 163 /**
162 164 * Cassandra audit log constants.
... ...