use of org.molgenis.data.Fetch in project molgenis by molgenis.
the class AttributeFilterToFetchConverter method createDefaultAttributeFetch.
/**
* Create default fetch for the given attribute. For attributes referencing entities the id and label value are
* fetched. Additionally for file entities the URL is fetched. For other attributes the default fetch is null;
*
* @return default attribute fetch or null
*/
public static Fetch createDefaultAttributeFetch(Attribute attr, String languageCode) {
Fetch fetch;
if (isReferenceType(attr)) {
fetch = new Fetch();
EntityType refEntityType = attr.getRefEntity();
String idAttrName = refEntityType.getIdAttribute().getName();
fetch.field(idAttrName);
String labelAttrName = refEntityType.getLabelAttribute(languageCode).getName();
if (!labelAttrName.equals(idAttrName)) {
fetch.field(labelAttrName);
}
if (attr.getDataType() == FILE) {
fetch.field(FileMetaMetaData.URL);
}
} else {
fetch = null;
}
return fetch;
}
Aggregations