List of usage examples for com.mongodb.client.model Variable getName
public String getName()
From source file:org.opencb.opencga.catalog.db.mongodb.CatalogMongoStudyDBAdaptor.java
License:Apache License
@Override public QueryResult<VariableSet> addFieldToVariableSet(long variableSetId, Variable variable) throws CatalogDBException { long startTime = startQuery(); checkVariableSetExists(variableSetId); checkVariableNotInVariableSet(variableSetId, variable.getName()); Bson bsonQuery = Filters.eq(QueryParams.VARIABLE_SET_ID.key(), variableSetId); Bson update = Updates.push(QueryParams.VARIABLE_SET.key() + ".$." + VariableSetParams.VARIABLE.key(), getMongoDBDocument(variable, "variable")); QueryResult<UpdateResult> queryResult = studyCollection.update(bsonQuery, update, null); if (queryResult.first().getModifiedCount() == 0) { throw CatalogDBException.updateError("VariableSet", variableSetId); }//w w w. j av a 2s . c om if (variable.isRequired()) { dbAdaptorFactory.getCatalogSampleDBAdaptor().addVariableToAnnotations(variableSetId, variable); dbAdaptorFactory.getCatalogCohortDBAdaptor().addVariableToAnnotations(variableSetId, variable); dbAdaptorFactory.getCatalogIndividualDBAdaptor().addVariableToAnnotations(variableSetId, variable); } return endQuery("Add field to variable set", startTime, getVariableSet(variableSetId, null)); }