.append(PanelDBAdaptor.UpdateParams.AUTHOR.key(), "author") .append(PanelDBAdaptor.UpdateParams.REGIONS.key(), Collections.singletonList( new ObjectMap("location", "chr1:1-1000") )) .append(PanelDBAdaptor.UpdateParams.PHENOTYPES.key(), Collections.singletonList( new ObjectMap("id", "ontologyTerm") )) .append(PanelDBAdaptor.UpdateParams.VARIANTS.key(), Collections.singletonList( new ObjectMap("id", "variant1") )) .append(PanelDBAdaptor.UpdateParams.GENES.key(), Collections.singletonList( new ObjectMap("id", "BRCA2") ));
private Document parseAndValidateUpdateParams(ObjectMap parameters, Query query) throws CatalogDBException { Document panelParameters = new Document(); final String[] acceptedParams = {UpdateParams.NAME.key(), UpdateParams.DESCRIPTION.key(), UpdateParams.AUTHOR.key()}; filterStringParams(parameters, panelParameters, acceptedParams); final String[] acceptedMapParams = {UpdateParams.ATTRIBUTES.key(), UpdateParams.STATS.key()}; filterMapParams(parameters, panelParameters, acceptedMapParams); String[] acceptedParamsList = { UpdateParams.TAGS.key()}; filterStringListParams(parameters, panelParameters, acceptedParamsList); final String[] acceptedObjectParams = {UpdateParams.VARIANTS.key(), UpdateParams.PHENOTYPES.key(), UpdateParams.REGIONS.key(), UpdateParams.GENES.key(), UpdateParams.SOURCE.key(), UpdateParams.CATEGORIES.key()}; filterObjectParams(parameters, panelParameters, acceptedObjectParams); if (parameters.containsKey(UpdateParams.ID.key())) { throw new CatalogDBException("Update panel: Cannot update " + UpdateParams.ID.key() + " parameter. More than one panel " + "found to be updated."); panelParameters.put(UpdateParams.ID.key(), parameters.get(UpdateParams.ID.key())); if (parameters.containsKey(UpdateParams.STATUS_NAME.key())) { panelParameters.put(UpdateParams.STATUS_NAME.key(), parameters.get(UpdateParams.STATUS_NAME.key())); panelParameters.put(QueryParams.STATUS_DATE.key(), TimeUtils.getTime());
@Override public QueryResult<Panel> update(String studyStr, String panelId, ObjectMap parameters, QueryOptions options, String sessionId) throws CatalogException { ParamUtils.checkObj(parameters, "parameters"); parameters = new ObjectMap(parameters); options = ParamUtils.defaultObject(options, QueryOptions::new); MyResource<Panel> resource = getUid(panelId, studyStr, sessionId); // Check update permissions authorizationManager.checkPanelPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), PanelAclEntry.PanelPermissions.UPDATE); try { ParamUtils.checkAllParametersExist(parameters.keySet().iterator(), (a) -> PanelDBAdaptor.UpdateParams.getParam(a) != null); } catch (CatalogParameterException e) { throw new CatalogException("Could not update: " + e.getMessage(), e); } if (parameters.containsKey(PanelDBAdaptor.UpdateParams.ID.key())) { ParamUtils.checkAlias(parameters.getString(PanelDBAdaptor.UpdateParams.ID.key()), PanelDBAdaptor.UpdateParams.ID.key()); } if (options.getBoolean(Constants.INCREMENT_VERSION)) { // We do need to get the current release to properly create a new version options.put(Constants.CURRENT_RELEASE, studyManager.getCurrentRelease(resource.getStudy(), resource.getUser())); } QueryResult<Panel> queryResult = panelDBAdaptor.update(resource.getResource().getUid(), parameters, options); auditManager.recordUpdate(AuditRecord.Resource.panel, resource.getResource().getUid(), resource.getUser(), parameters, null, null); return queryResult; }