use of org.nextprot.api.core.domain.DbXref.DbXrefProperty in project nextprot-api by calipho-sib.
the class DbXrefDaoImpl method findDbXrefsProperties.
@Override
public List<DbXrefProperty> findDbXrefsProperties(String entryName, List<Long> resourceIds) {
List<DbXrefProperty> result = new ArrayList<>();
// we must split the query into multiple queries otherwise we get an SQL error:
// the number of parameters (list of resource id) cannot exceed 32767 and miss titin has now 43012 xrefs !
List<List> paramsList = splitList(resourceIds);
for (List l : paramsList) {
Map<String, Object> params = new HashMap<>();
params.put("resourceIds", l);
List<DbXrefProperty> someProps = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-props-by-resource-ids"), params, new DbXrefPropertyRowMapper());
result.addAll(someProps);
params.put("entryName", entryName);
List<DbXrefProperty> someOtherProps = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-entry-link-props-by-entry-and-resource-ids"), params, new DbXrefPropertyRowMapper());
result.addAll(someOtherProps);
}
// System.out.println("AAA final size is " + result.size());
return result;
}
use of org.nextprot.api.core.domain.DbXref.DbXrefProperty in project nextprot-api by calipho-sib.
the class DbXrefServiceImpl method attachPropertiesToXrefs.
private void attachPropertiesToXrefs(List<DbXref> xrefs, String uniqueName, boolean fetchXrefAnnotationMappingProperties) {
List<Long> xrefIds = xrefs.stream().map(DbXref::getDbXrefId).collect(Collectors.toList());
List<DbXrefProperty> shownProperties = dbXRefDao.findDbXrefsProperties(uniqueName, xrefIds).stream().filter(p -> !HIDDEN_PROPERTY_NAME_SET.contains(p.getName())).collect(Collectors.toList());
Multimap<Long, DbXrefProperty> propsMap = Multimaps.index(shownProperties, DbXrefProperty::getDbXrefId);
Map<Long, List<DbXrefProperty>> ensemblPropertiesMap = getDbXrefEnsemblInfos(uniqueName, xrefs);
for (DbXref xref : xrefs) {
if (!fetchXrefAnnotationMappingProperties)
xref.setProperties((!Xref2Annotation.hasName(xref.getDatabaseName())) ? new ArrayList<>(propsMap.get(xref.getDbXrefId())) : new ArrayList<>());
else
xref.setProperties(new ArrayList<>(propsMap.get(xref.getDbXrefId())));
if (ensemblPropertiesMap.containsKey(xref.getDbXrefId())) {
xref.addProperties(ensemblPropertiesMap.get(xref.getDbXrefId()));
}
}
xrefs.addAll(createMissingDbXrefs(xrefs));
}
Aggregations