@Override public Collection<CategoryAttribute> getAttributesForMetaClass(MetaClass metaClass) { return cache().getAttributesForMetaClass(metaClass); }
@Override public void receive(ReloadCacheMsg message) { doLoadCache(false, false); } });
protected void handleAttributeValuesForIds(MetaClass metaClass, List<Object> currentIds, Multimap<Object, CategoryAttributeValue> attributeValuesForEntity) { if (CollectionUtils.isNotEmpty(currentIds)) { for (CategoryAttributeValue attributeValue : loadAttributeValues(metaClass, currentIds)) { attributeValuesForEntity.put(attributeValue.getObjectEntityId(), attributeValue); } } }
protected void doFetchDynamicAttributes(MetaClass metaClass, Collection<BaseGenericIdEntity> entities) { Collection<CategoryAttribute> categoryAttributes = getAttributesForMetaClass(metaClass); if (categoryAttributes == null || categoryAttributes.isEmpty()) { for (BaseGenericIdEntity entity : entities) { currentIds.add(id); if (currentIds.size() >= MAX_ENTITIES_FOR_ATTRIBUTE_VALUES_BATCH) { handleAttributeValuesForIds(metaClass, currentIds, allAttributeValues); currentIds = new ArrayList<>(); handleAttributeValuesForIds(metaClass, currentIds, allAttributeValues);
loadEntityValues(cavsOfEntityType); attributeValues.addAll(resultList); } else { List<CategoryAttributeValue> cavsOfCollectionTypeWithChildren = reloadCategoryAttributeValuesWithChildren(cavsOfCollectionType); .forEach(cav -> cavsOfEntityType.addAll(cav.getChildValues())); loadEntityValues(cavsOfEntityType);
&& categoryAttributeValue.getCode() != null) { CategoryAttribute attribute = getAttributeForMetaClass(entity.getMetaClass(), categoryAttributeValue.getCode()); categoryAttributeValue.setCategoryAttribute(attribute); storeCategoryAttributeValueWithCollectionType(mergedCategoryAttributeValue);
@Override public void storeDynamicAttributes(BaseGenericIdEntity entity) { try (Transaction tx = persistence.getTransaction()) { doStoreDynamicAttributes(entity); tx.commit(); } }
entitiesByType.keySet().forEach(entityType -> { MetaClass metaClass = metadata.getExtendedEntities().getOriginalOrThisMetaClass(metadata.getClass(entityType)); doFetchDynamicAttributes(metaClass, entitiesByType.get(entityType)); }); tx.commit();
@Nullable @Override public CategoryAttribute getAttributeForMetaClass(MetaClass metaClass, String code) { return cache().getAttributeForMetaClass(metaClass, code); }
protected DynamicAttributesCache cache() { if (this.dynamicAttributesCache == null) { doLoadCache(true, true); } return this.dynamicAttributesCache; }
@Override public Collection<Category> getCategoriesForMetaClass(MetaClass metaClass) { return cache().getCategoriesForMetaClass(metaClass); }
@Override public void loadCache() { doLoadCache(true, false); }
@Override public DynamicAttributesCache getCacheIfNewer(Date clientCacheDate) { if (clientCacheDate == null || this.dynamicAttributesCache == null || this.dynamicAttributesCache.getCreationDate() == null || clientCacheDate.before(this.dynamicAttributesCache.getCreationDate())) { return cache(); } else { return null; } }