public Collection<CategoryAttribute> getAttributesForMetaClass(MetaClass metaClass) { MetaClass targetMetaClass = resolveTargetMetaClass(metaClass); Collection<Category> categories = categoriesCache.get(targetMetaClass.getName()); return categories.stream() .flatMap(ca -> ca.getCategoryAttrs().stream()) .filter(a -> StringUtils.isNotBlank(a.getCode())) .collect(Collectors.toList()); }
@Override public boolean apply(@Nullable MetaProperty input) { if (input != null && category != null) { CategoryAttribute categoryAttribute = attributes.get(input.getName()); return category.equals(categoryAttribute.getCategory()); } else { return false; } } });
protected void initIsDefaultCheckbox() { isDefault.setValue(BooleanUtils.isTrue(category.getIsDefault())); isDefault.addValueChangeListener(e -> { if (Boolean.TRUE.equals(e.getValue())) { LoadContext<Category> lc = new LoadContext<>(Category.class) .setView("category.defaultEdit"); lc.setQueryString("select c from sys$Category c where c.entityType = :entityType and not c.id = :id") .setParameter("entityType", category.getEntityType()) .setParameter("id", category.getId()); List<Category> result = dataManager.loadList(lc); for (Category cat : result) { cat.setIsDefault(false); } CommitContext commitCtx = new CommitContext(result); dataManager.commit(commitCtx); category.setIsDefault(true); } else if (Boolean.FALSE.equals(e.getValue())) { category.setIsDefault(false); } }); }
MetaClass metaClass = resolveTargetMetaClass(metadata.getSession().getClass(category.getEntityType())); if (metaClass != null) { categoriesCache.put(metaClass.getName(), category); for (CategoryAttribute categoryAttribute : category.getCategoryAttrs()) { attributes.put(categoryAttribute.getCode(), categoryAttribute); category.getEntityType(), category.getName()));
Category selectedCategory = null; Map<String, Category> categoriesMap = new TreeMap<>(); if (categories.size() == 1 && (catId == null || Objects.equals(catId, categories.iterator().next().getId()))) { Category category = categories.iterator().next(); categoryLookup.setVisible(false); categoryLabel.setVisible(false); attributeLookup.focus(); categoriesMap.put(category.getName(), category); categoryLookup.setOptionsMap(categoriesMap); categoryLookup.setValue(category); categoryLabel.setVisible(true); for (Category category : categories) { categoriesMap.put(category.getName(), category); if (category.getId().equals(catId)) { selectedCategory = category;
protected void initEntityTypeField() { final ExtendedEntities extendedEntities = metadata.getExtendedEntities(); Map<String, MetaClass> options = new TreeMap<>();//the map sorts meta classes by the string key for (MetaClass metaClass : metadata.getTools().getAllPersistentMetaClasses()) { if (metadata.getTools().hasCompositePrimaryKey(metaClass) && !HasUuid.class.isAssignableFrom(metaClass.getJavaClass())) { continue; } options.put(messageTools.getDetailedEntityCaption(metaClass), metaClass); } entityType.setOptionsMap(options); if (category.getEntityType() != null) { entityType.setValue(extendedEntities.getEffectiveMetaClass( extendedEntities.getEffectiveClass(category.getEntityType()))); } entityType.addValueChangeListener(e -> { MetaClass metaClass = (MetaClass) e.getValue(); MetaClass originalClass = extendedEntities.getOriginalMetaClass(metaClass); category.setEntityType(originalClass == null ? metaClass.getName() : originalClass.getName()); }); }
protected void setCategoryEntityType(CategoryAttribute entity) { if (entity.getCategory() != null) { entity.setCategoryEntityType(entity.getCategory().getEntityType()); } } }
protected void fillAttributeCode() { CategoryAttribute attribute = getItem(); if (StringUtils.isBlank(attribute.getCode()) && StringUtils.isNotBlank(attribute.getName())) { String categoryName = StringUtils.EMPTY; if (attribute.getCategory() != null) { categoryName = StringUtils.defaultString(attribute.getCategory().getName()); } attribute.setCode(StringUtils.deleteWhitespace(categoryName + attribute.getName())); } }
@Nullable public Category getDefaultCategory() { MetaClass metaClass = resolveCategorizedEntityClass(); DynamicAttributes dynamicAttributes = AppBeans.get(DynamicAttributes.class); Collection<Category> categoriesForMetaClass = dynamicAttributes.getCategoriesForMetaClass(metaClass); for (Category category : categoriesForMetaClass) { if (Boolean.TRUE.equals(category.getIsDefault())) { return category; } } return null; }
protected void initLocalizedFrame() { if (globalConfig.getAvailableLocales().size() > 1) { localizedGroupBox.setVisible(true); localizedFrame = (LocalizedNameFrame) openFrame(localizedGroupBox, "localizedNameFrame"); localizedFrame.setWidth("100%"); localizedFrame.setHeight(AUTO_SIZE); localizedFrame.setValue(category.getLocaleNames()); } }
condition.setCategoryId(categoryLookup.getValue().getId()); condition.setCategoryAttributeId(attributeLookup.getValue().getId()); condition.setIsCollection(BooleanUtils.isTrue(attributeLookup.getValue().getIsCollection()));
MetaClass categorizedEntityMetaClass = metadata.getClass(attribute.getCategory().getEntityType()); Map<String, String> optionsMap = categorizedEntityMetaClass != null ? new HashMap<>(screensHelper.getAvailableScreens(categorizedEntityMetaClass.getJavaClass())) :
protected void fillAttributeSelect(Category category) { UUID attrId = condition.getCategoryAttributeId(); CategoryAttribute selectedAttribute = null; Map<String, CategoryAttribute> attributesMap = new TreeMap<>(); for (CategoryAttribute attribute : category.getCategoryAttrs()) { attributesMap.put(attribute.getLocaleName(), attribute); if (attribute.getId().equals(attrId)) { selectedAttribute = attribute; } } attributeLookup.setOptionsMap(attributesMap); attributeLookup.setValue(selectedAttribute); }
@Override public void init(Map<String, Object> params) { categoryTable.addAction(new CreateAction()); categoryTable.addAction(new EditAction()); categoryTable.addAction(new RemoveAction(categoryTable)); categoryTable.addAction(new BaseAction("applyChanges") .withCaption(getMessage("categoryTable.applyChanges")) .withHandler(actionPerformedEvent -> { dynamicAttributesCacheService.loadCache(); clientCacheManager.refreshCached(DynamicAttributesCacheStrategy.NAME); permissionConfig.clearConfigCache(); showNotification(getMessage("notification.changesApplied")); })); categoryTable.removeGeneratedColumn("entityType"); categoryTable.addGeneratedColumn("entityType", entity -> { Label dataTypeLabel = componentsFactory.createComponent(Label.class); MetaClass meta = metadata.getSession().getClassNN(entity.getEntityType()); dataTypeLabel.setValue(messageTools.getEntityCaption(meta)); return dataTypeLabel; }); }
if (entityIsCategorized && !categoryAttribute.getCategory().equals(((Categorized) item).getCategory())) {