diff --git a/src/main/java/fr/inra/oresing/checker/DateLineCheckerConfiguration.java b/src/main/java/fr/inra/oresing/checker/DateLineCheckerConfiguration.java index 32d38cfe954a91f2b7807c69266e391f4b8088d4..a110538d74ea869175daa1020d7cc60b120af9e3 100644 --- a/src/main/java/fr/inra/oresing/checker/DateLineCheckerConfiguration.java +++ b/src/main/java/fr/inra/oresing/checker/DateLineCheckerConfiguration.java @@ -1,5 +1,7 @@ package fr.inra.oresing.checker; +import io.swagger.annotations.ApiModelProperty; + /** * Configuration pour un checker de type "Date" */ @@ -13,5 +15,6 @@ public interface DateLineCheckerConfiguration extends LineCheckerConfiguration { /** * La {@link fr.inra.oresing.model.Duration} pour cette donnée. */ + @ApiModelProperty(notes = "the duration of the data value. Use sql pattern duration.", required = true, example = "1 MONTHS") String getDuration(); -} +} \ No newline at end of file diff --git a/src/main/java/fr/inra/oresing/checker/RegularExpressionCheckerConfiguration.java b/src/main/java/fr/inra/oresing/checker/RegularExpressionCheckerConfiguration.java index 064c5e2de8263ac5f54d106ad64bff1f03c8e7ef..faef0da0fa0a781e9fa4c32350ca25f929d6411b 100644 --- a/src/main/java/fr/inra/oresing/checker/RegularExpressionCheckerConfiguration.java +++ b/src/main/java/fr/inra/oresing/checker/RegularExpressionCheckerConfiguration.java @@ -8,5 +8,6 @@ public interface RegularExpressionCheckerConfiguration extends LineCheckerConfig /** * L'expression régulière à laquelle doit être conforme la valeur qui sera vérifiée. */ + String getPattern(); -} +} \ No newline at end of file diff --git a/src/main/java/fr/inra/oresing/model/Configuration.java b/src/main/java/fr/inra/oresing/model/Configuration.java index f332751c1344b02c51f74f706cd61e18b3867d3f..4076aaa8705740740fd7ef68e1ab2b755825b7ac 100644 --- a/src/main/java/fr/inra/oresing/model/Configuration.java +++ b/src/main/java/fr/inra/oresing/model/Configuration.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.MoreCollectors; import fr.inra.oresing.checker.*; import fr.inra.oresing.model.internationalization.*; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -20,14 +21,23 @@ import java.util.*; @Setter @ToString public class Configuration { - private String defaultLanguage; + @ApiModelProperty(notes = "The set of requiredAuthorization of data.authorization section. Fill by aplication", required = false, hidden = true) private List<String> requiredAuthorizationsAttributes; - private InternationalizationMap internationalization; + @ApiModelProperty(notes = "The version number of the yaml schema used to read the deposited yaml",required = true, example = "1") private int version; + @ApiModelProperty(notes = "The internationalization description from other sections. Fill by application", required = false, hidden = true) + private InternationalizationMap internationalization; + @ApiModelProperty(notes = "A comment about this yaml",required = false, example = "Adding sites section") private String comment; + @ApiModelProperty(notes = "An Application description",required = true) private ApplicationDescription application; + @ApiModelProperty(notes = "A list of references indexed by name. A reference is used to describe other references or data..",required = true) private LinkedHashMap<String, ReferenceDescription> references = new LinkedHashMap<>(); - private LinkedHashMap<String, CompositeReferenceDescription> compositeReferences = new LinkedHashMap<>(); + @ApiModelProperty(notes = "A composite reference allows you to link references according to an ''is in'' link. For example between a city and country reference.\n" + + "You can define several composite references, and a composite reference can contain only one reference or contain a recursion.\n" + + "All references used in a datatype.authorization.authorizationscope section must be composite.",required = true) + private LinkedHashMap<String, CompositeReferenceDescription> compositeReferences = new LinkedHashMap<>(); + @ApiModelProperty(notes = "A data type describes a set of data representing a cohesive set of measurements or observations. (values can be stored in one csv file format).",required = false) private LinkedHashMap<String, DataTypeDescription> dataTypes = new LinkedHashMap<>(); public InternationalizationMap getInternationalization() { @@ -97,10 +107,15 @@ public class Configuration { @Setter @ToString public static class ReferenceDescription extends InternationalizationDisplayImpl { + @ApiModelProperty(notes = "The separator in csv files", required = false) private char separator = ';'; + @ApiModelProperty(notes = "The list of columns composing the natural key of a row.", required = true) private List<String> keyColumns = new LinkedList<>(); + @ApiModelProperty(notes = "The list of columns descriptions.", required = true) private LinkedHashMap<String, ReferenceColumnDescription> columns = new LinkedHashMap<>(); + @ApiModelProperty(notes = "The list of dynamic columns descriptions. Dynamic columns names reffers to an other reference.", required = true) private LinkedHashMap<String, ReferenceDynamicColumnDescription> dynamicColumns = new LinkedHashMap<>(); + @ApiModelProperty(notes = "The list of validations to perform on this reference.", required = false) private LinkedHashMap<String, LineValidationRuleDescription> validations = new LinkedHashMap<>(); public static Map<String, InternationalizationReferenceMap> getInternationalization(LinkedHashMap<String, ReferenceDescription> referenceDescriptionMap) { @@ -122,6 +137,7 @@ public class Configuration { @Setter @ToString public static class ReferenceColumnDescription { + @ApiModelProperty(notes = "If the column is or not mandatory", required = true, example = "MANDATORY", allowableValues = "MANDATORY,OPTIONAL") private ColumnPresenceConstraint presenceConstraint = ColumnPresenceConstraint.MANDATORY; } @@ -129,9 +145,13 @@ public class Configuration { @Setter @ToString public static class ReferenceDynamicColumnDescription { + @ApiModelProperty(notes = "The header prefix. All culumnsthat startswith this prefix use this description", example = "rt_", required = true) private String headerPrefix = ""; + @ApiModelProperty(notes = "The reference that contains the column names", required = true, example = "proprietes_taxon") private String reference; + @ApiModelProperty(notes = "The column in this reference that contains the column names", required = true, example = "name") private String referenceColumnToLookForHeader; + @ApiModelProperty(notes = "If the column is or not mandatory", required = true, example = "MANDATORY", allowableValues = "MANDATORY,OPTIONAL") private ColumnPresenceConstraint presenceConstraint = ColumnPresenceConstraint.MANDATORY; } @@ -152,8 +172,11 @@ public class Configuration { @Setter @ToString public static class CompositeReferenceComponentDescription extends InternationalizationImpl { + @ApiModelProperty(notes = "The reference composing the composite reference", required = true, example = "types_sites") String reference; + @ApiModelProperty(notes = "The reference where this reference refers to", required = false, example = "name") String parentKeyColumn; + @ApiModelProperty(notes = "For recursive composite reference : the reference column that's contains parent key", required = false, example = "parent_key") String parentRecursiveKey; } @@ -161,12 +184,19 @@ public class Configuration { @Setter @ToString public static class DataTypeDescription extends InternationalizationMapDisplayImpl { + @ApiModelProperty(notes = "This section describes a binding between a file and the data", required = true) FormatDescription format; + @ApiModelProperty(notes = "This section describes the data model", required = true) LinkedHashMap<String, ColumnDescription> data = new LinkedHashMap<>(); + @ApiModelProperty(notes = "This section validate the data format", required = true) LinkedHashMap<String, LineValidationRuleDescription> validations = new LinkedHashMap<>(); + @ApiModelProperty(notes = "This section defines the natural key of a line", required = false) List<VariableComponentKey> uniqueness = new LinkedList<>(); + @ApiModelProperty(notes = "This section defines how to migrate the data when a new version of yaml is registred", required = false) TreeMap<Integer, List<MigrationDescription>> migrations = new TreeMap<>(); + @ApiModelProperty(notes = "This section defines the autorizations for this dataType", required = true) AuthorizationDescription authorization; + @ApiModelProperty(notes = "If this section existe, the data file will be store on a repository tree", required = false) LinkedHashMap<String, String> repository = null; public static Map<String, InternationalizationDataTypeMap> getInternationalization(LinkedHashMap<String, DataTypeDescription> dataTypeDescriptionMap) { @@ -189,7 +219,9 @@ public class Configuration { @Setter @ToString public static class LineValidationRuleDescription { + @ApiModelProperty(notes = "A description of the validation", required = false) String description; + @ApiModelProperty(notes = "A checker that can validate one or some columns. Can also build new values from other values.", required = true) CheckerDescription checker; } @@ -197,8 +229,11 @@ public class Configuration { @Setter @ToString public static class AuthorizationDescription { + @ApiModelProperty(notes = "The variable component with a checker date that identify the time scope of the line", required = true) VariableComponentKey timeScope; + @ApiModelProperty(notes = "A list of authorization scopes. An authorization scope is for example a an authorization on a location", required = true) LinkedHashMap<String, AuthorizationScopeDescription> authorizationScopes = new LinkedHashMap<>(); + @ApiModelProperty(notes = "A list of datagroups. A line wil be split into as many lines as there are data groups. Datagroups is partition of variables", required = true) LinkedHashMap<String, DataGroupDescription> dataGroups = new LinkedHashMap<>(); public InternationalizationAuthorisationMap getInternationalization() { @@ -225,7 +260,9 @@ public class Configuration { @Setter @ToString public static class AuthorizationScopeDescription extends InternationalizationImpl { + @ApiModelProperty(notes = "The variable name", required = true, example = "temperature") String variable; + @ApiModelProperty(notes = "The component name. A component is an information about a variable", required = true, example = "unit") String component; public VariableComponentKey getVariableComponentKey() { @@ -237,11 +274,17 @@ public class Configuration { @Setter @ToString public static class FormatDescription { + @ApiModelProperty(notes = "The line with columns names", required = true, example = "1") private int headerLine = 1; + @ApiModelProperty(notes = "The first line with data", required = true, example = "2") private int firstRowLine = 2; + @ApiModelProperty(notes = "The csv separator", required = false, example = ";") private char separator = ';'; + @ApiModelProperty(notes = "The description for binding columns content to variable component", required = true) private List<ColumnBindingDescription> columns = new LinkedList<>(); + @ApiModelProperty(notes = "The description for binding repeated columns content to variable component", required = false) private List<RepeatedColumnBindingDescription> repeatedColumns = new LinkedList<>(); + @ApiModelProperty(notes = "The description of some values in header to bind to variable component", required = false) private List<HeaderConstantDescription> constants = new LinkedList<>(); } @@ -249,10 +292,15 @@ public class Configuration { @Setter @ToString public static class HeaderConstantDescription { + @ApiModelProperty(notes = "The row where is the constant value", required = true, example = "1") int rowNumber; + @ApiModelProperty(notes = "The column where is the constant value. Id empty headerName is required", required = false, example = "2") int columnNumber; + @ApiModelProperty(notes = "The header column name of column where is the constant value. Id empty columnNumber is required", required = false, example = "CO2") String headerName; + @ApiModelProperty(notes = "The variable component to bound to", required = true) VariableComponentKey boundTo; + @ApiModelProperty(notes = "The export header name", required = true, example = "CO2_unit") String exportHeader; public int getColumnNumber(ImmutableList<String> headerRows) { @@ -268,7 +316,9 @@ public class Configuration { @Setter @ToString public static class ColumnBindingDescription { + @ApiModelProperty(notes = "The header name of column that contains the value to bind", required = true, example = "CO2") String header; + @ApiModelProperty(notes = "The variable component to bind to", required = true) VariableComponentKey boundTo; } @@ -276,9 +326,13 @@ public class Configuration { @Setter @ToString public static class RepeatedColumnBindingDescription { + @ApiModelProperty(notes = "The regexp pattern to find repeated columns to bind", required = true, example = "(.*)_([0-9]*)_([0-9]*)") String headerPattern; + @ApiModelProperty(notes = "The export header (for value) of these columns", required = true, example = "SMP") String exportHeader; + @ApiModelProperty(notes = "How bind the result of regexp parenthesis. $1 to first pattern, $2 is the second ...", required = false) List<HeaderPatternToken> tokens = new LinkedList<>(); + @ApiModelProperty(notes = "How bind the value column", required = true) VariableComponentKey boundTo; } @@ -286,7 +340,9 @@ public class Configuration { @Setter @ToString public static class HeaderPatternToken { + @ApiModelProperty(notes = "The variable component to bind to", required = true) VariableComponentKey boundTo; + @ApiModelProperty(notes = "The export header(for pattern) name", required = true, example = "profondeur") String exportHeader; } @@ -294,7 +350,9 @@ public class Configuration { @Setter @ToString public static class ColumnDescription { + @ApiModelProperty(notes = "A description to create disponibility charts", required = false) Chart chartDescription; + @ApiModelProperty(notes = "A list of variable component", required = true) LinkedHashMap<String, VariableComponentDescription> components = new LinkedHashMap<>(); } @@ -342,9 +400,12 @@ public class Configuration { @Setter @ToString public static class VariableComponentDescription { + @ApiModelProperty(notes = "A checker description", required = false) CheckerDescription checker; @Nullable + @ApiModelProperty(notes = "A default value if ciolumn is empty. This is a groovy expression", required = false, example = "-9999") String defaultValue; + @ApiModelProperty(notes = "The params of the checker. Required for some checkers. params depends of checker name", required = false) VariableComponentDescriptionConfiguration params; } @@ -352,8 +413,11 @@ public class Configuration { @Setter @ToString public static class VariableComponentDescriptionConfiguration implements GroovyDataInjectionConfiguration { + @ApiModelProperty(notes = "The list of references values in database to add in groovy context", required = false) Set<String> references = new LinkedHashSet<>(); + @ApiModelProperty(notes = "The list of datatypes values in database to add in groovy context", required = false) Set<String> datatypes = new LinkedHashSet<>(); + @ApiModelProperty(notes = "If true the result of grrovy expression replace the value of the column", required = false, example = "true", allowableValues = "true,false") boolean replace; } @@ -361,7 +425,9 @@ public class Configuration { @Setter @ToString public static class CheckerDescription { + @ApiModelProperty(notes = "The name of the checker that must be used", required = true, allowableValues = "RegularExpression,Reference,Float,Integer,Date,GroovyExpression") String name; + @ApiModelProperty(notes = "The params of the checker to configure it. Required for some checkers", required = false) CheckerConfigurationDescription params; } @@ -375,14 +441,22 @@ public class Configuration { DateLineCheckerConfiguration, ReferenceLineCheckerConfiguration, GroovyLineCheckerConfiguration { + @ApiModelProperty(notes = "The pattern of a regular expression for RegularExpression checker\nthe pattern of a date for Date checker", required = false, example = "dd/MM/yyyy") String pattern; + @ApiModelProperty(notes = "the name of the reference for Reference checker", required = false, example = "units") String refType; + @ApiModelProperty(notes = "A groovy expression for Reference checker, GroovyChecker", required = false) GroovyConfiguration groovy; + @ApiModelProperty(notes = "The list of columns to build natural key of reference for Reference checker", required = false) String columns; + @ApiModelProperty(notes = "the variable component key for this checkern filled by application", required = false, hidden = true) String variableComponentKey; String duration; + @ApiModelProperty(notes = "If true codifies the column value", required = false, example = "true", allowableValues = "true,false") boolean codify; + @ApiModelProperty(notes = "If true the value can't be null", required = false, example = "true", allowableValues = "true,false") boolean required; + @ApiModelProperty(notes = "If MANY the value is a list of references for Reference checker", required = false, example ="MANY", allowableValues = "MANY,ONE") Multiplicity multiplicity = Multiplicity.ONE; public ImmutableSet<String> doGetColumnsAsCollection() { @@ -397,8 +471,16 @@ public class Configuration { @Setter @ToString public static class GroovyConfiguration implements fr.inra.oresing.checker.GroovyConfiguration { + @ApiModelProperty(notes = "A groovy expression", required = false, example = ">\n" + + " String dataType = Arrays.stream(datum.dataType)\n" + + " .split(\"_\"))\n" + + " .collect{it.substring(0, 1)}\n" + + " .join(); " + + " return application.dataType.contains(dataType);") String expression; + @ApiModelProperty(notes = "The list of references values in database to add to groovy context", required = false) Set<String> references = new LinkedHashSet<>(); + @ApiModelProperty(notes = "The list of datatypes values in database to add to groovy context", required = false) Set<String> datatypes = new LinkedHashSet<>(); } @@ -406,8 +488,11 @@ public class Configuration { @Setter @ToString public static class DataGroupDescription extends InternationalizationImpl { + @ApiModelProperty(notes = "The description of internationalization of the datagroup", required = false) Internationalization internationalizationName; + @ApiModelProperty(notes = "The name of the datagroup", required = true, example = "localizations") String label; + @ApiModelProperty(notes = "The list of variable in this datagroup", required = true) Set<String> data = new LinkedHashSet<>(); } @@ -415,8 +500,11 @@ public class Configuration { @Setter @ToString public static class ApplicationDescription extends InternationalizationImpl { + @ApiModelProperty(notes = "The unique name of the application",required = true, example = "ACBB") String name; + @ApiModelProperty(notes = "The version incremental version number of this yaml description of this application",required = true, example = "1") int version; + @ApiModelProperty(notes = "The default language if none is provided",required = false, example = "fr") Locale defaultLanguage; public InternationalizationApplicationMap getInternationalization() { @@ -430,9 +518,13 @@ public class Configuration { @Setter @ToString public static class MigrationDescription { + @ApiModelProperty(notes = "The migration strategy", required = true, example = "ADD_VARIABLE", allowableValues = "ADD_VARIABLE") MigrationStrategy strategy; + @ApiModelProperty(notes = "A datagroup name", required = true, example = "variables") String dataGroup; + @ApiModelProperty(notes = "A variable in this datagroup", required = true, example = "CO2") String variable; + @ApiModelProperty(notes = "A list of component migration description for this variable", required = true) Map<String, AddVariableMigrationDescription> components = new LinkedHashMap<>(); } @@ -440,6 +532,7 @@ public class Configuration { @Setter @ToString public static class AddVariableMigrationDescription { + @ApiModelProperty(notes = "The value by default if the variable component is empty after migration", required = true, example = "-9999") String defaultValue; } diff --git a/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationDisplay.java b/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationDisplay.java index 9668e5e4a1e7898c4b1a1dab9dab5faf5514e06c..aea9a487fc89a0734b6693130da7e665f1b990ec 100644 --- a/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationDisplay.java +++ b/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationDisplay.java @@ -4,6 +4,7 @@ import fr.inra.oresing.model.ReferenceColumn; import fr.inra.oresing.model.ReferenceColumnSingleValue; import fr.inra.oresing.model.ReferenceDatum; import fr.inra.oresing.rest.ReferenceImporterContext; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import org.assertj.core.util.Strings; @@ -18,6 +19,7 @@ import java.util.stream.Stream; @Getter @Setter public class InternationalizationDisplay { + @ApiModelProperty(notes = "pattern in differents locales, used to display a reference when referred to",required = false) Map<Locale, String> pattern; public static ReferenceDatum getDisplays(ReferenceImporterContext referenceImporterContext, ReferenceDatum refValues) { diff --git a/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationImpl.java b/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationImpl.java index c7fda5bb463c1c6a08ad6de99d27a5a1f4de541f..cc107ac8adc1f84d10e94b512937c55adb487a59 100644 --- a/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationImpl.java +++ b/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationImpl.java @@ -1,5 +1,6 @@ package fr.inra.oresing.model.internationalization; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -10,6 +11,8 @@ import java.util.Map; @Setter @ToString public class InternationalizationImpl { + @ApiModelProperty(notes = "How to translate this name in differents locales",required = false) Internationalization internationalizationName; + @ApiModelProperty(notes = "Some columns used as key and the reference to translation in other columns",required = false) Map<String, Internationalization> internationalizedColumns; } \ No newline at end of file diff --git a/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationMap.java b/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationMap.java index cb7da1069328095d51483fb831d1b7409b582c5b..e84d43651695c93ff9dc4292b6d157dd7ec0b238 100644 --- a/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationMap.java +++ b/src/main/java/fr/inra/oresing/model/internationalization/InternationalizationMap.java @@ -1,5 +1,6 @@ package fr.inra.oresing.model.internationalization; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -12,10 +13,13 @@ import java.util.Map; @ToString public class InternationalizationMap { @Nullable + @ApiModelProperty(notes = "The internationalization description from section Application", required = false) InternationalizationApplicationMap application; @Nullable + @ApiModelProperty(notes = "The internationalization description from section references", required = false) Map<String, InternationalizationReferenceMap> references; @Nullable + @ApiModelProperty(notes = "The internationalization description from section dataTypes", required = false) Map<String, InternationalizationDataTypeMap> dataTypes; } \ No newline at end of file