use of edu.harvard.iq.dataverse.DatasetFieldValue in project dataverse by IQSS.
the class JsonParser method parsePrimitiveValue.
public List<DatasetFieldValue> parsePrimitiveValue(JsonObject json) throws JsonParseException {
List<DatasetFieldValue> vals = new LinkedList<>();
if (json.getBoolean("multiple")) {
for (JsonString val : json.getJsonArray("value").getValuesAs(JsonString.class)) {
DatasetFieldValue datasetFieldValue = new DatasetFieldValue();
datasetFieldValue.setDisplayOrder(vals.size() - 1);
datasetFieldValue.setValue(val.getString().trim());
vals.add(datasetFieldValue);
}
} else {
DatasetFieldValue datasetFieldValue = new DatasetFieldValue();
datasetFieldValue.setValue(json.getString("value", "").trim());
vals.add(datasetFieldValue);
}
return vals;
}
use of edu.harvard.iq.dataverse.DatasetFieldValue in project dataverse by IQSS.
the class DatasetFieldWalker method walk.
public void walk(DatasetField fld, SettingsServiceBean settingsService) {
l.startField(fld);
DatasetFieldType datasetFieldType = fld.getDatasetFieldType();
if (datasetFieldType.isControlledVocabulary()) {
for (ControlledVocabularyValue cvv : sort(fld.getControlledVocabularyValues(), ControlledVocabularyValue.DisplayOrder)) {
l.controledVocabularyValue(cvv);
}
} else if (datasetFieldType.isPrimitive()) {
for (DatasetFieldValue pv : sort(fld.getDatasetFieldValues(), DatasetFieldValue.DisplayOrder)) {
if (settingsService != null && settingsService.isTrueForKey(SettingsServiceBean.Key.ExcludeEmailFromExport, false) && DatasetFieldType.FieldType.EMAIL.equals(pv.getDatasetField().getDatasetFieldType().getFieldType())) {
continue;
}
l.primitiveValue(pv);
}
} else if (datasetFieldType.isCompound()) {
for (DatasetFieldCompoundValue dsfcv : sort(fld.getDatasetFieldCompoundValues(), DatasetFieldCompoundValue.DisplayOrder)) {
l.startCompoundValue(dsfcv);
for (DatasetField dsf : sort(dsfcv.getChildDatasetFields(), DatasetField.DisplayOrder)) {
walk(dsf, settingsService);
}
l.endCompoundValue(dsfcv);
}
}
l.endField(fld);
}
Aggregations