Commit 5cc7bbe635bc63012adbaae3de3e227f5be007f2

Authored by Andrii Shvaika
1 parent 21fa66c6

Added ADDITIONAL INFO

@@ -189,6 +189,22 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { @@ -189,6 +189,22 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository {
189 " WHEN entity.entity_type = 'ENTITY_VIEW'" + 189 " WHEN entity.entity_type = 'ENTITY_VIEW'" +
190 " THEN (select name from entity_view where id = entity_id)" + 190 " THEN (select name from entity_view where id = entity_id)" +
191 " END as label"; 191 " END as label";
  192 + private static final String SELECT_ADDITIONAL_INFO = " CASE" +
  193 + " WHEN entity.entity_type = 'TENANT'" +
  194 + " THEN (select additional_info from tenant where id = entity_id)" +
  195 + " WHEN entity.entity_type = 'CUSTOMER' " +
  196 + " THEN (select additional_info from customer where id = entity_id)" +
  197 + " WHEN entity.entity_type = 'USER'" +
  198 + " THEN (select additional_info from tb_user where id = entity_id)" +
  199 + " WHEN entity.entity_type = 'DASHBOARD'" +
  200 + " THEN (select '' from dashboard where id = entity_id)" +
  201 + " WHEN entity.entity_type = 'ASSET'" +
  202 + " THEN (select additional_info from asset where id = entity_id)" +
  203 + " WHEN entity.entity_type = 'DEVICE'" +
  204 + " THEN (select additional_info from device where id = entity_id)" +
  205 + " WHEN entity.entity_type = 'ENTITY_VIEW'" +
  206 + " THEN (select additional_info from entity_view where id = entity_id)" +
  207 + " END as label";
192 208
193 static { 209 static {
194 entityTableMap.put(EntityType.ASSET, "asset"); 210 entityTableMap.put(EntityType.ASSET, "asset");
@@ -470,7 +486,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { @@ -470,7 +486,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository {
470 + SELECT_TYPE + ", " + SELECT_NAME + ", " + SELECT_LABEL + ", " + 486 + SELECT_TYPE + ", " + SELECT_NAME + ", " + SELECT_LABEL + ", " +
471 SELECT_FIRST_NAME + ", " + SELECT_LAST_NAME + ", " + SELECT_EMAIL + ", " + SELECT_REGION + ", " + 487 SELECT_FIRST_NAME + ", " + SELECT_LAST_NAME + ", " + SELECT_EMAIL + ", " + SELECT_REGION + ", " +
472 SELECT_TITLE + ", " + SELECT_COUNTRY + ", " + SELECT_STATE + ", " + SELECT_CITY + ", " + 488 SELECT_TITLE + ", " + SELECT_COUNTRY + ", " + SELECT_STATE + ", " + SELECT_CITY + ", " +
473 - SELECT_ADDRESS + ", " + SELECT_ADDRESS_2 + ", " + SELECT_ZIP + ", " + SELECT_PHONE + 489 + SELECT_ADDRESS + ", " + SELECT_ADDRESS_2 + ", " + SELECT_ZIP + ", " + SELECT_PHONE + ", " + SELECT_ADDITIONAL_INFO +
474 ", entity.entity_type as entity_type"; 490 ", entity.entity_type as entity_type";
475 String from = getQueryTemplate(entityFilter.getDirection()); 491 String from = getQueryTemplate(entityFilter.getDirection());
476 ctx.addUuidParameter("relation_root_id", rootId.getId()); 492 ctx.addUuidParameter("relation_root_id", rootId.getId());
@@ -557,7 +573,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { @@ -557,7 +573,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository {
557 if (!StringUtils.isEmpty(searchText) && !selectionMapping.isEmpty()) { 573 if (!StringUtils.isEmpty(searchText) && !selectionMapping.isEmpty()) {
558 String lowerSearchText = "%" + searchText.toLowerCase() + "%"; 574 String lowerSearchText = "%" + searchText.toLowerCase() + "%";
559 ctx.addStringParameter("lowerSearchTextParam", lowerSearchText); 575 ctx.addStringParameter("lowerSearchTextParam", lowerSearchText);
560 - List<String> searchAliases = selectionMapping.stream().map(EntityKeyMapping::getValueAlias).collect(Collectors.toList()); 576 + List<String> searchAliases = selectionMapping.stream().filter(EntityKeyMapping::isSearchable).map(EntityKeyMapping::getValueAlias).collect(Collectors.toList());
561 String searchAliasesExpression; 577 String searchAliasesExpression;
562 if (searchAliases.size() > 1) { 578 if (searchAliases.size() > 1) {
563 searchAliasesExpression = "CONCAT(" + String.join(" , ", searchAliases) + ")"; 579 searchAliasesExpression = "CONCAT(" + String.join(" , ", searchAliases) + ")";
@@ -71,15 +71,17 @@ public class EntityKeyMapping { @@ -71,15 +71,17 @@ public class EntityKeyMapping {
71 private static final String ADDRESS_2 = "address2"; 71 private static final String ADDRESS_2 = "address2";
72 private static final String ZIP = "zip"; 72 private static final String ZIP = "zip";
73 private static final String PHONE = "phone"; 73 private static final String PHONE = "phone";
  74 + private static final String ADDITIONAL_INFO = "additionalInfo";
74 75
75 - public static final List<String> typedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE);  
76 - public static final List<String> commonEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME); 76 + public static final List<String> typedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, ADDITIONAL_INFO);
  77 + public static final List<String> widgetEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME);
  78 + public static final List<String> commonEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, ADDITIONAL_INFO);
77 public static final List<String> dashboardEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, TITLE); 79 public static final List<String> dashboardEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, TITLE);
78 - public static final List<String> labeledEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL);  
79 - public static final List<String> contactBasedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, EMAIL, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE); 80 + public static final List<String> labeledEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL, ADDITIONAL_INFO);
  81 + public static final List<String> contactBasedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, EMAIL, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE, ADDITIONAL_INFO);
80 82
81 public static final Set<String> commonEntityFieldsSet = new HashSet<>(commonEntityFields); 83 public static final Set<String> commonEntityFieldsSet = new HashSet<>(commonEntityFields);
82 - public static final Set<String> relationQueryEntityFieldsSet = new HashSet<>(Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL, FIRST_NAME, LAST_NAME, EMAIL, REGION, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE)); 84 + public static final Set<String> relationQueryEntityFieldsSet = new HashSet<>(Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL, FIRST_NAME, LAST_NAME, EMAIL, REGION, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE, ADDITIONAL_INFO));
83 85
84 static { 86 static {
85 allowedEntityFieldMap.put(EntityType.DEVICE, new HashSet<>(labeledEntityFields)); 87 allowedEntityFieldMap.put(EntityType.DEVICE, new HashSet<>(labeledEntityFields));
@@ -90,13 +92,13 @@ public class EntityKeyMapping { @@ -90,13 +92,13 @@ public class EntityKeyMapping {
90 allowedEntityFieldMap.get(EntityType.TENANT).add(REGION); 92 allowedEntityFieldMap.get(EntityType.TENANT).add(REGION);
91 allowedEntityFieldMap.put(EntityType.CUSTOMER, new HashSet<>(contactBasedEntityFields)); 93 allowedEntityFieldMap.put(EntityType.CUSTOMER, new HashSet<>(contactBasedEntityFields));
92 94
93 - allowedEntityFieldMap.put(EntityType.USER, new HashSet<>(Arrays.asList(CREATED_TIME, FIRST_NAME, LAST_NAME, EMAIL))); 95 + allowedEntityFieldMap.put(EntityType.USER, new HashSet<>(Arrays.asList(CREATED_TIME, FIRST_NAME, LAST_NAME, EMAIL, ADDITIONAL_INFO)));
94 96
95 allowedEntityFieldMap.put(EntityType.DASHBOARD, new HashSet<>(dashboardEntityFields)); 97 allowedEntityFieldMap.put(EntityType.DASHBOARD, new HashSet<>(dashboardEntityFields));
96 allowedEntityFieldMap.put(EntityType.RULE_CHAIN, new HashSet<>(commonEntityFields)); 98 allowedEntityFieldMap.put(EntityType.RULE_CHAIN, new HashSet<>(commonEntityFields));
97 allowedEntityFieldMap.put(EntityType.RULE_NODE, new HashSet<>(commonEntityFields)); 99 allowedEntityFieldMap.put(EntityType.RULE_NODE, new HashSet<>(commonEntityFields));
98 - allowedEntityFieldMap.put(EntityType.WIDGET_TYPE, new HashSet<>(commonEntityFields));  
99 - allowedEntityFieldMap.put(EntityType.WIDGETS_BUNDLE, new HashSet<>(commonEntityFields)); 100 + allowedEntityFieldMap.put(EntityType.WIDGET_TYPE, new HashSet<>(widgetEntityFields));
  101 + allowedEntityFieldMap.put(EntityType.WIDGETS_BUNDLE, new HashSet<>(widgetEntityFields));
100 102
101 entityFieldColumnMap.put(CREATED_TIME, ModelConstants.CREATED_TIME_PROPERTY); 103 entityFieldColumnMap.put(CREATED_TIME, ModelConstants.CREATED_TIME_PROPERTY);
102 entityFieldColumnMap.put(ENTITY_TYPE, ModelConstants.ENTITY_TYPE_PROPERTY); 104 entityFieldColumnMap.put(ENTITY_TYPE, ModelConstants.ENTITY_TYPE_PROPERTY);
@@ -115,6 +117,7 @@ public class EntityKeyMapping { @@ -115,6 +117,7 @@ public class EntityKeyMapping {
115 entityFieldColumnMap.put(ADDRESS_2, ModelConstants.ADDRESS2_PROPERTY); 117 entityFieldColumnMap.put(ADDRESS_2, ModelConstants.ADDRESS2_PROPERTY);
116 entityFieldColumnMap.put(ZIP, ModelConstants.ZIP_PROPERTY); 118 entityFieldColumnMap.put(ZIP, ModelConstants.ZIP_PROPERTY);
117 entityFieldColumnMap.put(PHONE, ModelConstants.PHONE_PROPERTY); 119 entityFieldColumnMap.put(PHONE, ModelConstants.PHONE_PROPERTY);
  120 + entityFieldColumnMap.put(ADDITIONAL_INFO, ModelConstants.ADDITIONAL_INFO_PROPERTY);
118 121
119 Map<String, String> contactBasedAliases = new HashMap<>(); 122 Map<String, String> contactBasedAliases = new HashMap<>();
120 contactBasedAliases.put(NAME, TITLE); 123 contactBasedAliases.put(NAME, TITLE);
@@ -140,6 +143,7 @@ public class EntityKeyMapping { @@ -140,6 +143,7 @@ public class EntityKeyMapping {
140 private String alias; 143 private String alias;
141 private boolean isLatest; 144 private boolean isLatest;
142 private boolean isSelection; 145 private boolean isSelection;
  146 + private boolean isSearchable;
143 private boolean isSortOrder; 147 private boolean isSortOrder;
144 private boolean ignore = false; 148 private boolean ignore = false;
145 private List<KeyFilter> keyFilters; 149 private List<KeyFilter> keyFilters;
@@ -304,6 +308,7 @@ public class EntityKeyMapping { @@ -304,6 +308,7 @@ public class EntityKeyMapping {
304 EntityKeyMapping mapping = new EntityKeyMapping(); 308 EntityKeyMapping mapping = new EntityKeyMapping();
305 mapping.setLatest(false); 309 mapping.setLatest(false);
306 mapping.setSelection(true); 310 mapping.setSelection(true);
  311 + mapping.setSearchable(!key.getKey().equals(ADDITIONAL_INFO));
307 mapping.setEntityKey(key); 312 mapping.setEntityKey(key);
308 return mapping; 313 return mapping;
309 } 314 }
@@ -312,6 +317,7 @@ public class EntityKeyMapping { @@ -312,6 +317,7 @@ public class EntityKeyMapping {
312 key -> { 317 key -> {
313 EntityKeyMapping mapping = new EntityKeyMapping(); 318 EntityKeyMapping mapping = new EntityKeyMapping();
314 mapping.setLatest(true); 319 mapping.setLatest(true);
  320 + mapping.setSearchable(true);
315 mapping.setSelection(true); 321 mapping.setSelection(true);
316 mapping.setEntityKey(key); 322 mapping.setEntityKey(key);
317 return mapping; 323 return mapping;