-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
13 additions
and
9 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/LanguageEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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()); | ||
|
@@ -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())); | ||
|
@@ -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())); | ||
} | ||
|
@@ -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<>(); | ||
|
@@ -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<>(); | ||
|
@@ -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, | ||
|