Skip to content

Commit

Permalink
#3304 code style fix part II
Browse files Browse the repository at this point in the history
  • Loading branch information
moellerth committed Sep 23, 2024
1 parent 0b98ec9 commit 5fa605e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook;

/**
* Enum representing available language abbreviations.
*/
public enum LanguageEnum {
de("de"), en("en");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.springframework.stereotype.Service;

/**
* Service for construction DDI codebook metadata for all veriables of a {@link DataPackage}.
* Service for construction DDI codebook metadata for all variables of a {@link DataPackage}.
*
* @author <a href="mailto:[email protected]">Theresa Möller</a>
* @since Sep 2024
Expand Down Expand Up @@ -80,7 +80,7 @@ public ResponseEntity<?> exportDdiVariablesAsXml(String dataPackageId) {
Marshaller mar = context.createMarshaller();
mar.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
mar.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
"http://www.ddialliance.org/Specification/DDI-Codebook/2.5/XMLSchema/codebook.xsd");
"http://www.ddialliance.org/Specification/DDI-Codebook/2.5/XMLSchema/codebook.xsd");
ByteArrayOutputStream res = new ByteArrayOutputStream();
mar.marshal(variableMetadata, res);
ByteArrayResource resource = new ByteArrayResource(res.toByteArray());
Expand Down Expand Up @@ -152,8 +152,6 @@ private CodeBook getDdiVariablesMetadata(String dataPackageId) throws JsonProces
* @return the var element
*/
private Var getDdiVar(VariableSubDocument variableDoc) {
String name = variableDoc.getId();
String files = variableDoc.getDataSetId();
List<TextElement> varLablList = new ArrayList();
varLablList.add(new TextElement(LanguageEnum.de, variableDoc.getLabel().getDe()));
varLablList.add(new TextElement(LanguageEnum.en, variableDoc.getLabel().getEn()));
Expand All @@ -174,7 +172,7 @@ private Var getDdiVar(VariableSubDocument variableDoc) {
}
for (SearchHit hit : hits) {
QuestionSearchDocument relatedQuestion = gson.fromJson(
hit.getSourceAsString(), QuestionSearchDocument.class);
hit.getSourceAsString(), QuestionSearchDocument.class);
if (relatedQuestion.getQuestionText() != null && relatedQuestion.getQuestionText().getDe() != null) {
qstnList.add(new TextElement(LanguageEnum.de, relatedQuestion.getQuestionText().getDe()));
}
Expand Down Expand Up @@ -204,16 +202,16 @@ private Var getDdiVar(VariableSubDocument variableDoc) {
}
for (SearchHit hit : hits) {
VariableSearchDocument varDoc = gson.fromJson(
hit.getSourceAsString(), VariableSearchDocument.class);
hit.getSourceAsString(), VariableSearchDocument.class);
if (varDoc.getAnnotations() != null && varDoc.getAnnotations().getDe() != null) {
txtList.add(new TextElement(LanguageEnum.de, varDoc.getAnnotations().getDe()));
}
if (varDoc.getAnnotations() != null && varDoc.getAnnotations().getEn() != null) {
txtList.add(new TextElement(LanguageEnum.en, varDoc.getAnnotations().getEn()));
}
if ((varDoc.getScaleLevel().equals(ScaleLevels.NOMINAL) || varDoc.getScaleLevel().equals(ScaleLevels.ORDINAL))
&& varDoc.getDistribution() != null
&& varDoc.getDistribution().getValidResponses() != null) {
&& varDoc.getDistribution() != null
&& varDoc.getDistribution().getValidResponses() != null) {
for (ValidResponse validResponse : varDoc.getDistribution().getValidResponses()) {
String catValu = validResponse.getValue();
List<TextElement> catLablList = new ArrayList<>();
Expand All @@ -226,7 +224,7 @@ private Var getDdiVar(VariableSubDocument variableDoc) {
catgryList.add(new Catgry(catValu, catLablList));
}
// missing values
if (varDoc.getDistribution() != null && varDoc.getDistribution().getMissings() != null)
if (varDoc.getDistribution() != null && varDoc.getDistribution().getMissings() != null) {
for (Missing missing : varDoc.getDistribution().getMissings()) {
String catValu = missing.getCode();
List<TextElement> catLablList = new ArrayList<>();
Expand All @@ -238,11 +236,14 @@ private Var getDdiVar(VariableSubDocument variableDoc) {
}
catgryList.add(new Catgry(catValu, catLablList));
}
}
}
}
} catch (IOException e) {
log.error("An exception occurred querying the variables index. ", e);
}
String name = variableDoc.getId();
String files = variableDoc.getDataSetId();
return new Var(name, files, varLablList,
qstnList.size() > 0 ? qstnList : null,
txtList.size() > 0 ? txtList : null,
Expand Down

0 comments on commit 5fa605e

Please sign in to comment.