Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>fr.insee.lunatic</groupId>
<artifactId>lunatic-model</artifactId>
<packaging>jar</packaging>
<version>5.10.1</version>
<version>6.0.0</version>
<name>Lunatic Model</name>
<description>Classes and converters for the Lunatic model</description>
<url>https://inseefr.github.io/Lunatic-Model/</url>
Expand Down
37 changes: 5 additions & 32 deletions src/main/java/fr/insee/lunatic/conversion/JsonDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,18 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.insee.lunatic.exception.SerializationException;
import fr.insee.lunatic.model.flat.Questionnaire;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;

import javax.xml.transform.stream.StreamSource;
import java.io.IOException;
import java.io.InputStream;

@Slf4j
public class JsonDeserializer {

private static final Logger logger = LoggerFactory.getLogger(JsonDeserializer.class);

/**
* Deserializes the file at given relative path to a Lunatic questionnaire object.
* @param fileName Relative file path.
* @return Deserialized Lunatic questionnaire object. null if the input given is null or empty.
* @throws SerializationException if file cannot be found or deserialization fails.
* @deprecated The string file path argument is misleading, this method should be removed.
*/
@Deprecated(since = "3.16.0", forRemoval = true)
public Questionnaire deserialize(String fileName) throws SerializationException {

if ((fileName == null) || (fileName.isEmpty())) return null;

logger.info("Deserializing questionnaire from file {}", fileName);

ObjectMapper mapper = new ObjectMapper();
Questionnaire questionnaire;
try {
questionnaire = mapper.readValue(new StreamSource(fileName).getInputStream(), Questionnaire.class);
} catch (IOException e) {
throw new SerializationException(e.getMessage(), e);
}
logger.info("Questionnaire {} successfully deserialized", questionnaire.getId());
return questionnaire;
}

public Questionnaire deserialize(InputStream jsonQuestionnaire) throws SerializationException {
if (jsonQuestionnaire == null) return null;

logger.debug("Deserializing questionnaire from input stream");
log.debug("Deserializing questionnaire from input stream");

ObjectMapper mapper = new ObjectMapper();
Questionnaire questionnaire;
Expand All @@ -51,7 +23,8 @@ public Questionnaire deserialize(InputStream jsonQuestionnaire) throws Serializa
} catch (IOException e) {
throw new SerializationException(e.getMessage(), e);
}
logger.info("Questionnaire {} successfully deserialized", questionnaire.getId());
log.info("Questionnaire {} successfully deserialized", questionnaire.getId());
return questionnaire;
}

}
42 changes: 0 additions & 42 deletions src/main/java/fr/insee/lunatic/conversion/UnitDeserializer.java

This file was deleted.

46 changes: 0 additions & 46 deletions src/main/java/fr/insee/lunatic/conversion/UnitSerializer.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/fr/insee/lunatic/model/flat/Accordion.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Accordion extends ComponentType {
List<Item> items;

public Accordion() {
super(ComponentTypeEnum.ACCORDION);
super(ComponentTypeName.ACCORDION);
this.items = new ArrayList<>();
}

Expand Down
72 changes: 8 additions & 64 deletions src/main/java/fr/insee/lunatic/model/flat/BodyCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,118 +32,62 @@
"optionResponses",
"bindingDependencies"
})
@Getter @Setter
public class BodyCell {

/** Orientation for radio / checkbox cells. */
@Getter @Setter
protected Orientation orientation;

@Getter @Setter
protected String value;
@Getter @Setter
protected LabelType label;
@Getter @Setter
protected String format;

@Getter @Setter
protected String dateFormat;

/** For input number cells. */
protected InputNumber.Unit unit;
protected LabelType unit;

@Getter @Setter
@JsonInclude(JsonInclude.Include.NON_EMPTY)
protected List<Option> options;
/** For suggester cells: Name of the code list used for auto-completion. */

@Getter @Setter
private String storeName;

/** For component cells: collected response of the cell. */
@Getter @Setter
protected ResponseType response;

/** Collected or external variable names required to evaluate expressions used in the component properties.
* @deprecated Binding dependencies at component level are not used anymore in Lunatic. */
@Getter @Setter
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@Deprecated(since = "3.4.0", forRemoval = true)
protected List<String> bindingDependencies = new ArrayList<>();

@Getter @Setter
protected ComponentTypeEnum componentType;
@Getter @Setter
protected ComponentTypeName componentType;
protected BigInteger maxLength;

@JsonIgnore
private Boundaries boundaries;

@Getter @Setter
protected BigInteger decimals;
@Getter @Setter
protected BigInteger colspan;
@Getter @Setter
protected BigInteger rowspan;

/** For suggester cells: option responses. */
@Getter @Setter
@JsonInclude(JsonInclude.Include.NON_EMPTY)
protected List<Suggester.OptionResponse> optionResponses;

@Getter @Setter
protected ConditionFilterType conditionFilter;

@Getter @Setter
protected LabelType conditionReadOnly;

@Getter @Setter
protected String id;

public BodyCell() {
this.options = new ArrayList<>();
this.optionResponses = new ArrayList<>();
}

@JsonProperty("unit")
public InputNumber.Unit getUnitWrapper() {
return unit;
}

@JsonProperty("unit")
public void setUnit(InputNumber.Unit unit) {
this.unit = unit;
}

/** Legacy unit string property.
* @deprecated Use label unit. */
@JsonIgnore
@Deprecated(since = "3.15.2", forRemoval = true)
public String getUnit() {
if (unit == null)
return null;
return unit.getValue();
}

/**
* @deprecated Use <code>getUnit()</code> method.
*/
@JsonIgnore
@Deprecated(since = "6.0.0")
public LabelType getUnitLabel() {
if (unit == null)
return null;
return unit.getLabel();
}

/** Legacy unit string property.
* @deprecated Use label unit. */
@JsonIgnore
@Deprecated(since = "3.15.2", forRemoval = true)
public void setUnit(String value) {
unit = new InputNumber.Unit();
unit.setValue(value);
}

@JsonIgnore
public void setUnit(LabelType labelType) {
unit = new InputNumber.Unit();
unit.setLabel(labelType);
return unit;
}

@JsonProperty("min")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class CheckboxBoolean extends ComponentType implements ComponentSimpleResponseType, ComponentMandatory {

public CheckboxBoolean() {
super(ComponentTypeEnum.CHECKBOX_BOOLEAN);
super(ComponentTypeName.CHECKBOX_BOOLEAN);
}

@JsonProperty(required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CheckboxGroup extends ComponentType implements ComponentMultipleRes
private Boolean mandatory;

public CheckboxGroup() {
super(ComponentTypeEnum.CHECKBOX_GROUP);
super(ComponentTypeName.CHECKBOX_GROUP);
this.orientation = Orientation.VERTICAL;
this.responses = new ArrayList<>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/insee/lunatic/model/flat/CheckboxOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CheckboxOne extends ComponentType implements ComponentSimpleRespons
private Boolean mandatory;

public CheckboxOne() {
super(ComponentTypeEnum.CHECKBOX_ONE);
super(ComponentTypeName.CHECKBOX_ONE);
this.orientation = Orientation.VERTICAL;
this.options = new ArrayList<>();
}
Expand Down
Loading