@Override public String toString() { return getName(); }
@Override public List<RecordElement> getAllElements() { if (this.elements == null) { this.elements = collectElements(); } return Collections.unmodifiableList(this.elements); }
@Override public String toString() { StringBuilder result = new StringBuilder(getName()); result.append(" ["); result.append(StringUtils.join(getEnabledElements(), ", ")); result.append(']'); return result.toString(); } }
@Override public RecordConfiguration process(@Nullable final RecordConfiguration config) { if (config == null) { return null; } final List<UIExtension> sectionExtensions = getOrderedSectionUIExtensions(); final List<RecordSection> recordSections = new LinkedList<>(); for (final UIExtension sectionExtension : sectionExtensions) { final RecordSection section = new UIXRecordSection(sectionExtension, this.uixManager, this.orderFilter); recordSections.add(section); } config.setSections(Collections.unmodifiableList(recordSections)); return config; }
@Override public RecordConfiguration getConfiguration(String recordType) { RecordConfiguration config = new DefaultRecordConfiguration(); for (RecordConfigurationModule service : this.modules.get()) { try { if (service.supportsRecordType(recordType)) { config = service.process(config); } } catch (Exception ex) { this.logger.warn("Failed to read the record configuration: {}", ex.getMessage()); } } return config; }
/** * Simple constructor, taking a UI {@code extension} and the parent record {@code section} as parameters. * * @param extension the {@link UIExtension UI extension} object defining this record element * @param section the parent {@link RecordSection section} containing this element * @throws IllegalArgumentException if {@code extension} or {@code section} are null */ public UIXRecordElement(UIExtension extension, RecordSection section) { if (extension == null || section == null) { throw new IllegalArgumentException("DefaultRecordElement constructor parameters must not be null"); } this.extension = extension; this.section = section; this.enabled = !StringUtils.equals(FALSE_LABEL, this.extension.getParameters().get(ENABLED_LABEL)); this.fields = constructFields(); this.name = constructName(); }
@Override public int compare(RecordConfigurationModule o1, RecordConfigurationModule o2) { final int result = o1.getPriority() - o2.getPriority(); if (result == 0) { return o1.getClass().getSimpleName().compareToIgnoreCase(o2.getClass().getSimpleName()); } return result; } }
@Override public List<RecordElement> getEnabledElements() { List<RecordElement> result = new LinkedList<>(); for (RecordElement element : getAllElements()) { if (element.isEnabled()) { result.add(element); } } return Collections.unmodifiableList(result); }
/** * Returns a list of {@link RecordElement} from a list of {@link UIExtension section elements}. * * @return a list of {@link RecordElement} objects */ private List<RecordElement> collectElements() { List<RecordElement> result = new LinkedList<>(); List<UIExtension> fields = this.uixManager.get(this.extension.getId()); fields = this.orderFilter.filter(fields, ORDER_LABEL); for (UIExtension field : fields) { result.add(new UIXRecordElement(field, this)); } return result; }
@Override public RecordConfiguration process(RecordConfiguration config) { if (config == null) { return null; } final List<UIExtension> sectionExtensions = getOrderedSectionUIExtensions(); final List<RecordSection> recordSections = new LinkedList<>(); for (final UIExtension sectionExtension : sectionExtensions) { final RecordSection section = new UIXRecordSection(sectionExtension, this.uixManager, this.orderFilter); recordSections.add(section); } config.setSections(recordSections); DocumentReference mapping = getPhenotypeMapping(); if (mapping != null) { config.setPhenotypeMapping(mapping); } String dobFormat = getDateOfBirthFormat(); if (StringUtils.isNotBlank(dobFormat)) { config.setDateOfBirthFormat(dobFormat); } return config; }