From 0020b31c5e000d299f2154bde82c3c881382dd0d Mon Sep 17 00:00:00 2001 From: TCHERNIATINSKY <philippe.tcherniatinsky@inrae.fr> Date: Mon, 28 Mar 2022 18:48:56 +0200 Subject: [PATCH 1/2] Ajout d'une documentation du model (swagger) --- .../checker/DateLineCheckerConfiguration.java | 5 +- ...RegularExpressionCheckerConfiguration.java | 3 +- .../fr/inra/oresing/model/Configuration.java | 94 ++++++++++++++++++- .../InternationalizationMap.java | 4 + 4 files changed, 101 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/inra/oresing/checker/DateLineCheckerConfiguration.java b/src/main/java/fr/inra/oresing/checker/DateLineCheckerConfiguration.java index 32d38cfe9..a110538d7 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 064c5e2de..faef0da0f 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 f332751c1..1e963048f 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", 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) private int version; + @ApiModelProperty(notes = "The internationalization description from other sections", required = false, hidden = true) + private InternationalizationMap internationalization; + @ApiModelProperty(notes = "a comment about this yaml",required = false) private String comment; + @ApiModelProperty(notes = "The 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. (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.", required = true) private LinkedHashMap<String, ReferenceDynamicColumnDescription> dynamicColumns = new LinkedHashMap<>(); + @ApiModelProperty(notes = "The list des validations à effectuer.", 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", required = true) private String headerPrefix = ""; + @ApiModelProperty(notes = "The reference that contains the column names", required = true) private String reference; + @ApiModelProperty(notes = "The column in this reference that contains the column names", required = true) 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) String reference; + @ApiModelProperty(notes = "the reference where this reference is in", required = false) String parentKeyColumn; + @ApiModelProperty(notes = "for recursive composite reference :the reference where this reference column that's contains parent key", required = false) String parentRecursiveKey; } @@ -161,12 +184,19 @@ public class Configuration { @Setter @ToString public static class DataTypeDescription extends InternationalizationMapDisplayImpl { + @ApiModelProperty(notes = "this section describes the 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 = false) 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 a column", required = true) CheckerDescription checker; } @@ -197,8 +229,11 @@ public class Configuration { @Setter @ToString public static class AuthorizationDescription { + @ApiModelProperty(notes = "The variable component with 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) 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) private int headerLine = 1; + @ApiModelProperty(notes = "The first line withdata", required = true) private int firstRowLine = 2; + @ApiModelProperty(notes = "The csv separator", required = false) 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 varaible 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) int rowNumber; + @ApiModelProperty(notes = "The column where is the constant value. Id empty headerName is required", required = false) int columnNumber; + @ApiModelProperty(notes = "The header column name of column where is the constant value. Id empty columnNumber is required", required = false) String headerName; + @ApiModelProperty(notes = "The variable component to bound to", required = true) VariableComponentKey boundTo; + @ApiModelProperty(notes = "The export header name", required = true) 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) 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) String headerPattern; + @ApiModelProperty(notes = "The export header of these columns", required = true) String exportHeader; + @ApiModelProperty(notes = "How bind the result of regexp parenthesis. $1 to first pattern ...", 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 name", required = true) 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) String defaultValue; + @ApiModelProperty(notes = "the params of the checker. Required for some checkers", 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 to add in groovy context", required = false) Set<String> references = new LinkedHashSet<>(); + @ApiModelProperty(notes = "the list of datatypes values 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) 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) String pattern; + @ApiModelProperty(notes = "the name of the reference for Reference checker", required = false) 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(hidden = true) String variableComponentKey; String duration; + @ApiModelProperty(notes = "If true codifies the column value", required = false) boolean codify; + @ApiModelProperty(notes = "If true the value can't be null", required = 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,11 @@ public class Configuration { @Setter @ToString public static class GroovyConfiguration implements fr.inra.oresing.checker.GroovyConfiguration { + @ApiModelProperty(notes = "a groovy expression", required = false) String expression; + @ApiModelProperty(notes = "the list of references values to add in groovy context", required = false) Set<String> references = new LinkedHashSet<>(); + @ApiModelProperty(notes = "the list of datatypes values to add in groovy context", required = false) Set<String> datatypes = new LinkedHashSet<>(); } @@ -406,8 +483,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) String label; + @ApiModelProperty(notes = "the list of variable in this datagroup", required = true) Set<String> data = new LinkedHashSet<>(); } @@ -415,8 +495,11 @@ public class Configuration { @Setter @ToString public static class ApplicationDescription extends InternationalizationImpl { + @ApiModelProperty(notes = "The unique name of the application",required = true) String name; + @ApiModelProperty(notes = "The version incremental version number of this yaml description of this application",required = true) int version; + @ApiModelProperty(notes = "The default language if none is provided",required = false, example = "fr") Locale defaultLanguage; public InternationalizationApplicationMap getInternationalization() { @@ -430,9 +513,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 nalme", required = true) String dataGroup; + @ApiModelProperty(notes = "a variable in this datagroup", required = true) String variable; + @ApiModelProperty(notes = "a list of component migration description for this variable", required = true) Map<String, AddVariableMigrationDescription> components = new LinkedHashMap<>(); } @@ -440,6 +527,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) String defaultValue; } 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 cb7da1069..e84d43651 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 -- GitLab From c53a84366a4c2a628674b1cf61a24b60b68722da Mon Sep 17 00:00:00 2001 From: TCHERNIATINSKY <philippe.tcherniatinsky@inrae.fr> Date: Tue, 29 Mar 2022 09:58:19 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Ajout=20d'annotations=20swagger=20pour=20d?= =?UTF-8?q?=C3=A9crire=20le=20mod=C3=A8le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quelque champs en doublon ont été supprimés. --- .../fr/inra/oresing/model/Configuration.java | 125 +++++++++--------- .../InternationalizationDisplay.java | 2 + .../InternationalizationImpl.java | 3 + 3 files changed, 70 insertions(+), 60 deletions(-) diff --git a/src/main/java/fr/inra/oresing/model/Configuration.java b/src/main/java/fr/inra/oresing/model/Configuration.java index 1e963048f..4076aaa87 100644 --- a/src/main/java/fr/inra/oresing/model/Configuration.java +++ b/src/main/java/fr/inra/oresing/model/Configuration.java @@ -21,15 +21,15 @@ import java.util.*; @Setter @ToString public class Configuration { - @ApiModelProperty(notes = "the set of requiredAuthorization of data.authorization section", required = false, hidden = true) + @ApiModelProperty(notes = "The set of requiredAuthorization of data.authorization section. Fill by aplication", required = false, hidden = true) private List<String> requiredAuthorizationsAttributes; - @ApiModelProperty(notes = "the version number of the yaml schema used to read the deposited yaml",required = true) + @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", required = false, hidden = true) + @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) + @ApiModelProperty(notes = "A comment about this yaml",required = false, example = "Adding sites section") private String comment; - @ApiModelProperty(notes = "The Application description",required = true) + @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<>(); @@ -37,7 +37,7 @@ public class Configuration { "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. (stored in one csv file format).",required = false) + @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() { @@ -113,9 +113,9 @@ public class Configuration { 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.", required = true) + @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 des validations à effectuer.", required = false) + @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) { @@ -145,11 +145,11 @@ public class Configuration { @Setter @ToString public static class ReferenceDynamicColumnDescription { - @ApiModelProperty(notes = "The header prefix. All culumnsthat startswith this prefix use this description", required = true) + @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) + @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) + @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; @@ -172,11 +172,11 @@ public class Configuration { @Setter @ToString public static class CompositeReferenceComponentDescription extends InternationalizationImpl { - @ApiModelProperty(notes = "the reference composing the composite reference", required = true) + @ApiModelProperty(notes = "The reference composing the composite reference", required = true, example = "types_sites") String reference; - @ApiModelProperty(notes = "the reference where this reference is in", required = false) + @ApiModelProperty(notes = "The reference where this reference refers to", required = false, example = "name") String parentKeyColumn; - @ApiModelProperty(notes = "for recursive composite reference :the reference where this reference column that's contains parent key", required = false) + @ApiModelProperty(notes = "For recursive composite reference : the reference column that's contains parent key", required = false, example = "parent_key") String parentRecursiveKey; } @@ -184,17 +184,17 @@ public class Configuration { @Setter @ToString public static class DataTypeDescription extends InternationalizationMapDisplayImpl { - @ApiModelProperty(notes = "this section describes the binding between a file and the data", required = true) + @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) + @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) + @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) + @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) + @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 = false) + @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; @@ -221,7 +221,7 @@ public class Configuration { public static class LineValidationRuleDescription { @ApiModelProperty(notes = "A description of the validation", required = false) String description; - @ApiModelProperty(notes = "A checker that can validate a column", required = true) + @ApiModelProperty(notes = "A checker that can validate one or some columns. Can also build new values from other values.", required = true) CheckerDescription checker; } @@ -229,7 +229,7 @@ public class Configuration { @Setter @ToString public static class AuthorizationDescription { - @ApiModelProperty(notes = "The variable component with checker date that identify the time scope of the line", required = true) + @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<>(); @@ -260,7 +260,7 @@ public class Configuration { @Setter @ToString public static class AuthorizationScopeDescription extends InternationalizationImpl { - @ApiModelProperty(notes = "The variable name", required = true) + @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; @@ -274,17 +274,17 @@ public class Configuration { @Setter @ToString public static class FormatDescription { - @ApiModelProperty(notes = "The line with columns names", required = true) + @ApiModelProperty(notes = "The line with columns names", required = true, example = "1") private int headerLine = 1; - @ApiModelProperty(notes = "The first line withdata", required = true) + @ApiModelProperty(notes = "The first line with data", required = true, example = "2") private int firstRowLine = 2; - @ApiModelProperty(notes = "The csv separator", required = false) + @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 varaible component", required = false) + @ApiModelProperty(notes = "The description of some values in header to bind to variable component", required = false) private List<HeaderConstantDescription> constants = new LinkedList<>(); } @@ -292,15 +292,15 @@ public class Configuration { @Setter @ToString public static class HeaderConstantDescription { - @ApiModelProperty(notes = "The row where is the constant value", required = true) + @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) + @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) + @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) + @ApiModelProperty(notes = "The export header name", required = true, example = "CO2_unit") String exportHeader; public int getColumnNumber(ImmutableList<String> headerRows) { @@ -316,7 +316,7 @@ public class Configuration { @Setter @ToString public static class ColumnBindingDescription { - @ApiModelProperty(notes = "The header name of column that contains the value to bind", required = true) + @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; @@ -326,11 +326,11 @@ public class Configuration { @Setter @ToString public static class RepeatedColumnBindingDescription { - @ApiModelProperty(notes = "The regexp pattern to find repeated columns to bind", required = true) + @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 of these columns", required = true) + @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 ...", required = false) + @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; @@ -342,7 +342,7 @@ public class Configuration { public static class HeaderPatternToken { @ApiModelProperty(notes = "The variable component to bind to", required = true) VariableComponentKey boundTo; - @ApiModelProperty(notes = "The export header name", required = true) + @ApiModelProperty(notes = "The export header(for pattern) name", required = true, example = "profondeur") String exportHeader; } @@ -403,9 +403,9 @@ public class Configuration { @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) + @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", required = false) + @ApiModelProperty(notes = "The params of the checker. Required for some checkers. params depends of checker name", required = false) VariableComponentDescriptionConfiguration params; } @@ -413,11 +413,11 @@ public class Configuration { @Setter @ToString public static class VariableComponentDescriptionConfiguration implements GroovyDataInjectionConfiguration { - @ApiModelProperty(notes = "the list of references values to add in groovy context", required = false) + @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 to add in groovy context", required = false) + @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) + @ApiModelProperty(notes = "If true the result of grrovy expression replace the value of the column", required = false, example = "true", allowableValues = "true,false") boolean replace; } @@ -427,7 +427,7 @@ public class Configuration { 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) + @ApiModelProperty(notes = "The params of the checker to configure it. Required for some checkers", required = false) CheckerConfigurationDescription params; } @@ -441,20 +441,20 @@ 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) + @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) + @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(hidden = true) + @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) + @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) + @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; @@ -471,11 +471,16 @@ public class Configuration { @Setter @ToString public static class GroovyConfiguration implements fr.inra.oresing.checker.GroovyConfiguration { - @ApiModelProperty(notes = "a groovy expression", required = false) + @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 to add in groovy context", required = false) + @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 to add in groovy context", required = false) + @ApiModelProperty(notes = "The list of datatypes values in database to add to groovy context", required = false) Set<String> datatypes = new LinkedHashSet<>(); } @@ -483,11 +488,11 @@ public class Configuration { @Setter @ToString public static class DataGroupDescription extends InternationalizationImpl { - @ApiModelProperty(notes = "the description of internationalization of the datagroup", required = false) + @ApiModelProperty(notes = "The description of internationalization of the datagroup", required = false) Internationalization internationalizationName; - @ApiModelProperty(notes = "the name of the datagroup", required = true) + @ApiModelProperty(notes = "The name of the datagroup", required = true, example = "localizations") String label; - @ApiModelProperty(notes = "the list of variable in this datagroup", required = true) + @ApiModelProperty(notes = "The list of variable in this datagroup", required = true) Set<String> data = new LinkedHashSet<>(); } @@ -495,9 +500,9 @@ public class Configuration { @Setter @ToString public static class ApplicationDescription extends InternationalizationImpl { - @ApiModelProperty(notes = "The unique name of the application",required = true) + @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) + @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; @@ -513,13 +518,13 @@ public class Configuration { @Setter @ToString public static class MigrationDescription { - @ApiModelProperty(notes = "the migration strategy", required = true, example = "ADD_VARIABLE", allowableValues = "ADD_VARIABLE") + @ApiModelProperty(notes = "The migration strategy", required = true, example = "ADD_VARIABLE", allowableValues = "ADD_VARIABLE") MigrationStrategy strategy; - @ApiModelProperty(notes = "a datagroup nalme", required = true) + @ApiModelProperty(notes = "A datagroup name", required = true, example = "variables") String dataGroup; - @ApiModelProperty(notes = "a variable in this datagroup", required = true) + @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) + @ApiModelProperty(notes = "A list of component migration description for this variable", required = true) Map<String, AddVariableMigrationDescription> components = new LinkedHashMap<>(); } @@ -527,7 +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) + @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 9668e5e4a..aea9a487f 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 c7fda5bb4..cc107ac8a 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 -- GitLab