@Override protected void processQueryResults(Entity entity, Iterable<Entity> annotationSourceEntities, boolean updateMode) { if (updateMode) { throw new MolgenisDataException("This annotator/filter does not support updating of values"); } List<Entity> refMatches = determineRefMatches(entity, annotationSourceEntities); setGoNLFrequencies(entity, refMatches); } };
@Override public void deleteAll() { throw new MolgenisDataException( "Cannot delete all boostrap themes, at least one theme is needed for the application"); }
private static void checkHyperlink(String value) { try { new URI(value); } catch (URISyntaxException e) { throw new MolgenisDataException("Default value [" + value + "] is not a valid hyperlink."); } }
private static void checkForIllegalCharacters(String name) { if (!name.matches("[a-zA-Z0-9_#]+(-[a-z]{2,3})??$")) // FIXME too restrictive { throw new MolgenisDataException( "Invalid characters in: [" + name + "] Only letters (a-z, A-Z), digits (0-9), underscores(_) and hashes (#) are allowed."); } } }
private static void validateName(String name) { if (Character.isDigit(name.charAt(0))) { throw new MolgenisDataException( "Invalid name: [" + name + "] Names must start with a letter."); } }
private static Object throwExceptionUnexpectedQueryValueType( String attrName, Object actualType, String expectedType) { throw new MolgenisDataException( format( "Attribute [%s] query value is of type [%s] instead of [%s]", attrName, actualType.getClass().getSimpleName(), expectedType)); } }
@Override public Optional<Entity> filterResults(Iterable<Entity> results, Entity annotatedEntity, boolean updateMode) { if (updateMode == true) { throw new MolgenisDataException("This annotator/filter does not support updating of values"); } return FluentIterable.from(results).first(); }
private void checkEmail(String value) { if (!emailValidator.isValid(value, null)) { throw new MolgenisDataException("Default value [" + value + "] is not a valid email address"); } }
private void checkAndUpdateAppSettings(Object id) { if (appSettings.getBootstrapTheme().equals(id)) { throw new MolgenisDataException("Cannot delete the currently selected bootstrap theme"); } } }
public Iterator<Entity> getSnpEffects(Iterable<Entity> source) { try { File inputVcf = getInputVcfFile(source.iterator()); return getSnpEffects(source.iterator(), inputVcf); } catch (IOException e) { throw new MolgenisDataException("Exception making temporary VCF file", e); } }
private static LocalDate convertDate(Attribute attr, String paramValue) { try { return parseLocalDate(paramValue); } catch (DateTimeParseException e) { throw new MolgenisDataException( format(FAILED_TO_PARSE_ATTRIBUTE_AS_DATE_MESSAGE, attr.getName(), paramValue)); } } }
@RequestMapping(value = "/orders/{orderId}/view", method = RequestMethod.GET) public ModelAndView getOrderDetailsForm(@Valid @NotNull @PathVariable Integer orderId) throws UnknownStudyDefinitionException { if (!getEnableOrderAction()) throw new MolgenisDataAccessException("Action not allowed"); StudyDefinition studyDefinition = protocolViewerService.getStudyDefinitionForCurrentUser(orderId); if (studyDefinition == null) throw new MolgenisDataException("invalid order id"); ModelAndView model = new ModelAndView("orderdetails-modal"); model.addObject("order", studyDefinition); model.addObject("i18n", new I18nTools()); return model; }
private static Instant convertDateTime(Attribute attr, String paramValue) { try { return parseInstant(paramValue); } catch (DateTimeParseException e) { throw new MolgenisDataException( format(FAILED_TO_PARSE_ATTRIBUTE_AS_DATETIME_MESSAGE, attr.getName(), paramValue)); } }
@Override @Transactional public void add(MappingProject mappingProject) { if (mappingProject.getIdentifier() != null) { throw new MolgenisDataException("MappingProject already exists"); } dataService.add(MAPPING_PROJECT, toEntity(mappingProject)); }
@Override @Transactional public void add(MappingProject mappingProject) { if (mappingProject.getIdentifier() != null) { throw new MolgenisDataException("MappingProject already exists"); } dataService.add(MAPPING_PROJECT, toEntity(mappingProject)); }
@Override public Stream<Entity> findAll(Query<Entity> q) { if (q.getRules().isEmpty()) return getEntities().stream(); if ((q.getRules().size() != 1) || (q.getRules().get(0).getOperator() != Operator.EQUALS)) { throw new MolgenisDataException("The only query allowed on this Repository is gene EQUALS"); } String geneSymbol = (String) q.getRules().get(0).getValue(); List<Entity> entities = getEntitiesByGeneSymbol().get(geneSymbol); return entities != null ? entities.stream() : Stream.empty(); }
static String getSqlDropCheckConstraint(EntityType entityType, Attribute attr) { if (attr.getDataType() != ENUM) { throw new MolgenisDataException( format("Check constraint only allowed for attribute type [%s]", ENUM.toString())); } return "ALTER TABLE " + getTableName(entityType) + " DROP CONSTRAINT " + getCheckConstraintName(entityType, attr); }
@Override @Transactional public void update(MappingProject mappingProject) { MappingProject existing = getMappingProject(mappingProject.getIdentifier()); if (existing == null) { throw new MolgenisDataException("MappingProject does not exist"); } Entity mappingProjectEntity = toEntity(mappingProject); dataService.update(MAPPING_PROJECT, mappingProjectEntity); }
private static void validateParent(Attribute attr) { if (attr.getParent() != null) { if (attr.getParent().getDataType() != COMPOUND) { throw new MolgenisDataException( format( "Parent attribute [%s] of attribute [%s] is not of type compound", attr.getParent().getName(), attr.getName())); } } }
@Override protected Object getResourceAttributeValue(Attribute attr, Entity sourceEntity) { if (attr.getName().equals(GENERALIZED_INHERITANCE.getAttributeName())) { return getGeneralizedInheritance(sourceEntity); } String sourceName = CGDAttributeName.getCgdName(attr.getName()); if (sourceName == null) throw new MolgenisDataException("Unknown attribute [" + attr.getName() + "]"); return sourceEntity.get(sourceName); }