@Override protected void loadData(Map<String, Object> params) { if (instance != null && instanceMetaClass != null && instance.getMetaClass() != null) { data.clear(); compileInfo(); } }
protected void doSort() { @SuppressWarnings("unchecked") List<T> list = new ArrayList<>(data.values()); list.sort(createEntityComparator()); data.clear(); for (T t : list) { data.put(t.getId(), t); } }
@Override protected void loadData(Map<String, Object> params) { if (permissionDs == null) return; if (targets == null) { targets = new ArrayList<>(); PermissionConfig permissionConfig = AppBeans.get(PermissionConfig.class); List<OperationPermissionTarget> entities = permissionConfig.getEntities(userSessionSource.getLocale()); for (OperationPermissionTarget target : entities) { try { OperationPermissionTarget cloneTarget = target.clone(); loadPermissionVariants(cloneTarget); attachListener(cloneTarget); targets.add(cloneTarget); } catch (CloneNotSupportedException e) { throw new RuntimeException("Can't clone permission target", e); } } } data.clear(); targets.stream() .filter(permittedEntityFilter) .filter(t -> permissionsFilter == null || permissionsFilter.test(t)) .forEach(t -> data.put(t.getId(), t)); }
@Override protected void doSort() { if (tree == null) { Logger log = LoggerFactory.getLogger(AbstractTreeDatasource.class); log.warn("AbstractTreeTableDatasource.doSort: Tree is null, exiting"); return; } sort(tree.getRootNodes()); data.clear(); for (Node<T> node : tree.toList()) { T entity = node.getData(); K id = entity.getId(); data.put(id, entity); } }
@Override public void addItemFirst(T item) { checkNotNullArgument(item, "item is null"); internalAddItem(item, () -> { LinkedMap tmpMap = data.clone(); data.clear(); data.put(item.getId(), item); data.putAll(tmpMap); }); }
@Override protected void loadData(Map<String, Object> params) { Collection<T> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (T entity : entities) { data.put(entity.getId(), entity); attachListener(entity); } } } }
@Override protected void loadData(Map<String, Object> params) { Collection<T> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (T entity : entities) { data.put(entity.getId(), entity); attachListener(entity); } } } }
@Override public void clear() { backgroundWorker.checkUIAccess(); // replaced refresh call with state initialization if (state != State.VALID) { invalidate(); State prevState = state; if (prevState != State.VALID) { valid(); fireStateChanged(prevState); } } // Get items List<Object> collectionItems = new ArrayList<>(data.values()); // Clear container data.clear(); // Notify listeners for (Object obj : collectionItems) { T item = (T) obj; detachListener(item); } setItem(null); fireCollectionChanged(Operation.CLEAR, Collections.emptyList()); }
@Override public void includeItemFirst(T item) { checkNotNullArgument(item, "item is null"); internalIncludeItem(item, () -> { LinkedMap tmpMap = data.clone(); data.clear(); data.put(item.getId(), item); data.putAll(tmpMap); }); }
@Override protected void loadData(Map<String, Object> params) { String tag = getLoggingTag("CDS"); StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class)); detachListener(data.values()); data.clear(); for (JmxInstance jmxInstance : jmxControlAPI.getInstances()) { data.put(jmxInstance.getId(), jmxInstance); attachListener(jmxInstance); } sw.stop(); } }
@Override protected void loadData(Map<String, Object> params) { Collection<T> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (T entity : entities) { data.put(entity.getId(), entity); attachListener(entity); } } } }
/** * This method is invoked by {@link #loadData(Map)} method immediately after loading entities from {@code DataSupplier}. * <p>If you override this method, be sure to call {@code super()}. If you process the loaded entities somehow, * call {@code super()} after processing. * * @param params datasource parameters, as described in {@link CollectionDatasource#refresh(java.util.Map)} * @param context {@code LoadContext} which was used for loading data * @param entities loaded entities */ protected void afterLoadData(@SuppressWarnings("unused") Map<String, Object> params, LoadContext context, Collection<T> entities) { detachListener(data.values()); data.clear(); for (T entity : entities) { data.put(entity.getId(), entity); attachListener(entity); } lastQuery = context.getQuery(); }
@Override protected void loadData(Map<String, Object> params) { data.clear(); Datasource mbeanDs = getDsContext().get("mbeanDs"); ManagedBeanInfo mbean = (ManagedBeanInfo) mbeanDs.getItem(); if (mbean != null) { try { jmxControlAPI.loadAttributes(mbean); } catch (JmxControlException e) { log.error("Error loading attributes", e); } if (mbean.getAttributes() != null) { for (ManagedBeanAttribute attr : mbean.getAttributes()) { data.put(attr.getId(), attr); } } } } }
@Override protected void loadData(Map<String, Object> params) { Collection<KeyValueEntity> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (KeyValueEntity entity : entities) { data.put(entity.getId(), entity); attachListener(entity); entity.setMetaClass(metaClass); } } } }
@Override protected void loadData(Map<String, Object> params) { TimeSource timeSource = AppBeans.get(TimeSource.NAME); updateTs = timeSource.currentTimestamp(); data.clear(); if (!AppBeans.get(Security.class).isEntityOpPermitted(UserSessionEntity.class, EntityOp.READ)) return; UserSessionService uss = AppBeans.get(UserSessionService.NAME); Collection<UserSessionEntity> userSessionList = uss.loadUserSessionEntities(createFilter(params)); for (UserSessionEntity entity : userSessionList) { if (!sessionFilter.test(entity)) { continue; } data.put(entity.getId(), entity); } }
@Override protected void loadData(Map<String, Object> params) { Collection<KeyValueEntity> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (KeyValueEntity entity : entities) { data.put(entity.getId(), entity); attachListener(entity); entity.setMetaClass(metaClass); } } } }
@Override protected void loadData(Map<String, Object> params) { Collection<KeyValueEntity> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (KeyValueEntity entity : entities) { data.put(entity.getId(), entity); attachListener(entity); entity.setMetaClass(metaClass); } } } }
protected void afterLoadValues(Map<String, Object> params, ValueLoadContext context, List<KeyValueEntity> entities) { ds.detachListener(ds.data.values()); ds.data.clear(); boolean hasEnumerations = ds.metaClass.getOwnProperties().stream() .anyMatch(p -> p.getRange().isEnum()); if (!hasEnumerations) { for (KeyValueEntity entity : entities) { ds.data.put(entity.getId(), entity); ds.attachListener(entity); entity.setMetaClass(ds.metaClass); } } else { List<MetaProperty> enumProperties = getEnumProperties(ds.metaClass); for (KeyValueEntity entity : entities) { convertEnumValues(entity, enumProperties); ds.data.put(entity.getId(), entity); ds.attachListener(entity); entity.setMetaClass(ds.metaClass); } } }
/** * This method is invoked by {@link #loadData(Map)} method immediately before loading entities from {@code DataSupplier}. * <br>If you override this method, be sure to call {@code super()}. * * @param params datasource parameters, as described in {@link CollectionDatasource#refresh(java.util.Map)} * @return LoadContext which will be used to load data */ protected LoadContext beforeLoadData(Map<String, Object> params) { final LoadContext context = new LoadContext(metaClass); LoadContext.Query q = (LoadContext.Query) createDataQuery(context, params); if (q == null) { detachListener(data.values()); data.clear(); return null; } if (sortInfos != null && sortOnDb) { setSortDirection(q); } if (firstResult > 0) q.setFirstResult(firstResult); if (maxResults > 0) { q.setMaxResults(maxResults); } context.setView(view); context.setSoftDeletion(isSoftDeletion()); prepareLoadContext(context); dataLoadError = null; return context; }
protected ValueLoadContext beforeLoadValues(Map<String, Object> params) { ValueLoadContext context = new ValueLoadContext(); ValueLoadContext.Query q = (ValueLoadContext.Query) ds.createDataQuery(context, params); if (q == null) { ds.detachListener(ds.data.values()); ds.data.clear(); return null; } if (ds.firstResult > 0) q.setFirstResult(ds.firstResult); if (ds.maxResults > 0) { q.setMaxResults(ds.maxResults); } if (storeName != null) context.setStoreName(storeName); context.setSoftDeletion(ds.isSoftDeletion()); context.setIdName(idName); for (MetaProperty property : ds.metaClass.getProperties()) { context.addProperty(property.getName()); } ds.dataLoadError = null; return context; }