private void mergeAttrSchemata(final Map<String, AttrSchema> attrSchemataToMerge) { if (attrSchemataToMerge == null) { return; } attrSchemataToMerge.forEach((schemaName, schemaToMerge) -> { final AttrSchema schema = attrSchemata.get(schemaName); if (schema != null) { // if the schema already exists, copy all groups to the existing schema schema.getGroups().addAll(schemaToMerge.getGroups()); } else { // if the schema does not exist, put it into the map attrSchemata.put(schemaName, schemaToMerge); } }); }
@Override public AttrGroup getAttrGroup(final EntityWithConfigurableAttr entity, final String groupName) { if (attrSchemata == null) { loadAttrSchema(); } final AttrSchema entitySchema = attrSchemata.get(entity.getAttrSchemaName()); return entitySchema .getGroups() .stream() .filter(group -> group.getName().equals(groupName)) .findFirst() .orElse(null); }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithConfigurableAttr & EntityWithTimeableAttr<PK, T> & EntityWithAttributes> void createAttrPanels( final DivPanel divPanel, final U entity, final AbstractEditPage<?, ?, ?> parentPage, final Function<AttrGroup, T> addNewEntryFunction) { addHtmlClass(divPanel); final AttrSchema attrSchema = getAttrSchema(entity.getAttrSchemaName()); if (attrSchema == null) { return; } for (AttrGroup group : attrSchema.getGroups()) { createAttrPanel(divPanel, entity, parentPage, addNewEntryFunction, group); } }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithConfigurableAttr & EntityWithTimeableAttr<PK, T>> void createTimedAttrPanels( final DivPanel divPanel, final U entity, final AbstractEditPage<?, ?, ?> parentPage, final Function<AttrGroup, T> addNewEntryFunction) { addHtmlClass(divPanel); final AttrSchema attrSchema = getAttrSchema(entity.getAttrSchemaName()); if (attrSchema == null) { return; } for (AttrGroup group : attrSchema.getGroups()) { createTimedAttrPanel(divPanel, entity, parentPage, addNewEntryFunction, group); } }
@Override public Map<String, SearchColumnMetadata> getAdditionallySearchFields(EntityMetadata entm, String params) { Map<String, SearchColumnMetadata> ret = new HashMap<>(); AttrSchemaService service = AttrSchemaServiceSpringBeanImpl.get(); AttrSchema schema = service.getAttrSchema(params); if (schema != null) { for (AttrGroup group : schema.getGroups()) { for (AttrDescription ad : group.getDescriptions()) { ColumnMetadata cmd = getColumnMetadataFromColumnDesc(entm, ad); SearchColumnMetadataBean scmd = new SearchColumnMetadataBean(ad.getPropertyName(), cmd); scmd.setIndexType(String.class); scmd.setIndexed(true); ret.put(ad.getPropertyName(), scmd); } } return ret; } else { log.info("Can't get AttrSchema. Continoue without."); return null; } }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithConfigurableAttr & EntityWithTimeableAttr<PK, T> & EntityWithAttributes> void createAttrPanels( final TabPanel tabPanel, final U entity, final AbstractEditPage<?, ?, ?> parentPage, final Function<AttrGroup, T> addNewEntryFunction) { final AttrSchema attrSchema = getAttrSchema(entity.getAttrSchemaName()); if (attrSchema == null) { return; } for (AttrGroup group : attrSchema.getGroups()) { final GridBuilder tabContainer = tabPanel.getOrCreateTab(group.getI18nKeySubmenu()); final DivPanel divPanel = tabContainer.getPanel(); if (!divPanel.hasChilds()) { // this panel is fresh, we have to add our css class addHtmlClass(divPanel); } createAttrPanel(divPanel, entity, parentPage, addNewEntryFunction, group); } }