All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.ird.observe.spi.module.BusinessModule Maven / Gradle / Ivy

package fr.ird.observe.spi.module;

/*-
 * #%L
 * ObServe Toolkit :: Dto
 * %%
 * Copyright (C) 2017 - 2021 Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import fr.ird.observe.dto.BusinessDto;
import fr.ird.observe.dto.data.ContainerChildDto;
import fr.ird.observe.dto.data.ContainerDto;
import fr.ird.observe.dto.data.DataDto;
import fr.ird.observe.dto.data.EditableDto;
import fr.ird.observe.dto.data.OpenableDto;
import fr.ird.observe.dto.data.SimpleDto;
import fr.ird.observe.dto.referential.ReferentialDto;
import io.ultreia.java4all.i18n.I18n;

import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Describes a business module.
 * 

* Created on 03/10/2020. * * @author Tony Chemit - [email protected] * @since 8.0.1 */ public abstract class BusinessModule { private final String name; private final List subModules; public BusinessModule(String name, List subModules) { this.name = Objects.requireNonNull(name); this.subModules = Objects.requireNonNull(subModules); } public int getSubModulePriority(BusinessSubModule subModule) { return subModules.indexOf(subModule); } public String getName() { return name; } public List getSubModules() { return subModules; } public abstract String getLabelKey(); public abstract String getShortLabelKey(); public final String getLabel(Locale l) { return I18n.l(l, getLabelKey() ); } public final String getLabel() { return I18n.t(getLabelKey() ); } public final String getShortLabel(Locale l) { return I18n.l(l, getShortLabelKey() ); } public final String getShortLabel() { return I18n.t(getShortLabelKey() ); } public Set> getTypes() { return subModules.stream().flatMap(m -> m.getTypes().stream()).collect(Collectors.toSet()); } public Set> getReferentialTypes() { return subModules.stream().flatMap(m -> m.getReferentialTypes().stream()).collect(Collectors.toSet()); } public Set> getDataTypes() { return subModules.stream().flatMap(m -> m.getDataTypes().stream()).collect(Collectors.toSet()); } public Set> getSimpleDataTypes() { return subModules.stream().flatMap(m -> m.getSimpleDataTypes().stream()).collect(Collectors.toSet()); } public Set>> getContainerDataTypes() { return subModules.stream().flatMap(m -> m.getContainerDataTypes().stream()).collect(Collectors.toSet()); } public Set> getContainerChildDataTypes() { return subModules.stream().flatMap(m -> m.getContainerChildDataTypes().stream()).collect(Collectors.toSet()); } public Set> getOpenableDataTypes() { return subModules.stream().flatMap(m -> m.getOpenableDataTypes().stream()).collect(Collectors.toSet()); } public Set> getEditableDataTypes() { return subModules.stream().flatMap(m -> m.getEditableDataTypes().stream()).collect(Collectors.toSet()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy