code
stringlengths
73
34.1k
label
stringclasses
1 value
@PostMapping("/removeMappingProject") public String deleteMappingProject(@RequestParam() String mappingProjectId) { MappingProject project = mappingService.getMappingProject(mappingProjectId); LOG.info("Deleting mappingProject {}", project.getName()); mappingService.deleteMappingProject(mappingProjectId);...
java
@PostMapping("/removeAttributeMapping") public String removeAttributeMapping( @RequestParam() String mappingProjectId, @RequestParam() String target, @RequestParam() String source, @RequestParam() String attribute) { MappingProject project = mappingService.getMappingProject(mappingProjectI...
java
@GetMapping("/mappingproject/{id}") public String viewMappingProject(@PathVariable("id") String identifier, Model model) { MappingProject project = mappingService.getMappingProject(identifier); MappingTarget mappingTarget = project.getMappingTargets().get(0); String target = mappingTarget.getName(); m...
java
void autoGenerateAlgorithms( EntityMapping mapping, EntityType sourceEntityType, EntityType targetEntityType, MappingProject project) { algorithmService.autoGenerateAlgorithm(sourceEntityType, targetEntityType, mapping); mappingService.updateMappingProject(project); }
java
private List<EntityType> getNewSources(MappingTarget target) { return dataService .getEntityTypeIds() .filter(name -> isValidSource(target, name)) .map(dataService::getEntityType) .collect(toList()); }
java
@GetMapping public String init(Model model) { final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().build(); model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml"); model.addAttribute("baseUrl", uriComponents.toUriString()); f...
java
@GetMapping(value = "/swagger.yml", produces = "text/yaml") public String swagger(Model model, HttpServletResponse response) { response.setContentType("text/yaml"); response.setCharacterEncoding("UTF-8"); final UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath().buil...
java
public static String getLanguageCode(String name) { if (!isI18n(name)) return null; return name.substring(name.indexOf('-') + 1, name.length()); }
java
public void executeScript(String pythonScript, PythonOutputHandler outputHandler) { // Check if Python is installed File file = new File(pythonScriptExecutable); if (!file.exists()) { throw new MolgenisPythonException("File [" + pythonScriptExecutable + "] does not exist"); } // Check if Pyth...
java
public Entity toEntity(final EntityType meta, final Map<String, Object> request) { final Entity entity = entityManager.create(meta, POPULATE); for (Attribute attr : meta.getAtomicAttributes()) { if (attr.getExpression() == null) { String paramName = attr.getName(); if (request.containsKey...
java
public Object toEntityValue(Attribute attr, Object paramValue, Object id) { // Treat empty strings as null if ((paramValue instanceof String) && ((String) paramValue).isEmpty()) { paramValue = null; } Object value; AttributeType attrType = attr.getDataType(); switch (attrType) { cas...
java
public Schema loadSchema(String schema) { try { JSONObject rawSchema = new JSONObject(new JSONTokener(schema)); return SchemaLoader.load(rawSchema); } catch (JSONException | SchemaException e) { throw new InvalidJsonSchemaException(e); } }
java
public void validate(String json, String schemaJson) { Schema schema = loadSchema(schemaJson); validate(json, schema); }
java
private QueryBuilder nestedQueryBuilder( List<Attribute> attributePath, QueryBuilder queryBuilder) { if (attributePath.size() == 1) { return queryBuilder; } else if (attributePath.size() == 2) { return QueryBuilders.nestedQuery( getQueryFieldName(attributePath.get(0)), queryBuilder, ...
java
public static String concatAttributeHref( String baseUri, String qualifiedEntityName, Object entityIdValue, String attributeName) { return String.format( "%s/%s/%s/%s", baseUri, encodePathSegment(qualifiedEntityName), encodePathSegment(DataConverter.toString(entityIdValue)), ...
java
public static String concatMetaAttributeHref( String baseUri, String entityParentName, String attributeName) { return String.format( "%s/%s/meta/%s", baseUri, encodePathSegment(entityParentName), encodePathSegment(attributeName)); }
java
public static String concatEntityHref( String baseUri, String qualifiedEntityName, Object entityIdValue) { if (null == qualifiedEntityName) { qualifiedEntityName = ""; } return String.format( "%s/%s/%s", baseUri, encodePathSegment(qualifiedEntityName), encodePath...
java
public static String concatMetaEntityHref(String baseUri, String qualifiedEntityName) { return String.format("%s/%s/meta", baseUri, encodePathSegment(qualifiedEntityName)); }
java
public static String concatEntityCollectionHref( String baseUri, String qualifiedEntityName, String qualifiedIdAttributeName, List<String> entitiesIds) { String ids; ids = entitiesIds.stream().map(Href::encodeIdToRSQL).collect(Collectors.joining(",")); return String.format( "...
java
@Override @Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) public void export( List<EntityType> entityTypes, List<Package> packages, Path downloadFilePath, Progress progress) { requireNonNull(progress); if (!(entityTypes.isEmpty() && packages.isEmpty())) { tr...
java
void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) { LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes); if (!writer.hasSheet(EMX_ENTITIES)) { writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet())); } writer.writeRows(sor...
java
public static Attribute getQueryRuleAttribute(QueryRule queryRule, EntityType entityType) { String queryRuleField = queryRule.getField(); if (queryRuleField == null) { return null; } Attribute attr = null; String[] queryRuleFieldTokens = StringUtils.split(queryRuleField, NESTED_ATTRIBUTE_SEPA...
java
private static Function<EntityTypeNode, Set<EntityTypeNode>> getDependencies() { return entityTypeNode -> { // get referenced entities excluding entities of mappedBy attributes EntityType entityType = entityTypeNode.getEntityType(); Set<EntityTypeNode> refEntityMetaSet = stream(entityTyp...
java
private static Set<EntityTypeNode> expandEntityTypeDependencies(EntityTypeNode entityTypeNode) { if (LOG.isTraceEnabled()) { LOG.trace( "expandEntityTypeDependencies(EntityTypeNode entityTypeNode) --- entity: [{}], skip: [{}]", entityTypeNode.getEntityType().getId(), entityTypeNo...
java
private boolean hasAuthenticatedMolgenisToken() { boolean hasAuthenticatedMolgenisToken = false; Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication instanceof RestAuthenticationToken) { hasAuthenticatedMolgenisToken = authentication.isAuthenticat...
java
public static Map<String, Attribute> deepCopyAttributes( EntityType entityType, EntityType entityTypeCopy, AttributeFactory attrFactory) { Map<String, Attribute> copiedAttributes = new LinkedHashMap<>(); // step #1: deep copy attributes Map<String, Attribute> ownAttrMap = stream(entityType.ge...
java
public String getLabel(String languageCode) { String i18nLabel = getString(getI18nAttributeName(LABEL, languageCode)); return i18nLabel != null ? i18nLabel : getLabel(); }
java
@Nullable @CheckForNull public String getDescription(String languageCode) { String i18nDescription = getString(getI18nAttributeName(DESCRIPTION, languageCode)); return i18nDescription != null ? i18nDescription : getDescription(); }
java
public Attribute getIdAttribute() { Attribute idAttr = getOwnIdAttribute(); if (idAttr == null) { EntityType extend = getExtends(); if (extend != null) { idAttr = extend.getIdAttribute(); } } return idAttr; }
java
public Attribute getLabelAttribute() { Attribute labelAttr = getOwnLabelAttribute(); if (labelAttr == null) { EntityType extend = getExtends(); if (extend != null) { labelAttr = extend.getLabelAttribute(); } } return labelAttr; }
java
public Attribute getLabelAttribute(String langCode) { Attribute labelAttr = getLabelAttribute(); Attribute i18nLabelAttr = labelAttr != null ? getAttribute(labelAttr.getName() + '-' + langCode) : null; return i18nLabelAttr != null ? i18nLabelAttr : labelAttr; }
java
public Attribute getAttribute(String attrName) { Attribute attr = getCachedOwnAttrs().get(attrName); if (attr == null) { // look up attribute in parent entity EntityType extendsEntityType = getExtends(); if (extendsEntityType != null) { attr = extendsEntityType.getAttribute(attrName); ...
java
static void addSequenceNumber(Attribute attr, Iterable<Attribute> attrs) { Integer sequenceNumber = attr.getSequenceNumber(); if (null == sequenceNumber) { int i = stream(attrs) .filter(a -> null != a.getSequenceNumber()) .mapToInt(Attribute::getSequenceNumber) ...
java
public void initialize(ContextRefreshedEvent event) { ApplicationContext ctx = event.getApplicationContext(); Stream<String> languageCodes = LanguageService.getLanguageCodes(); EntityTypeMetadata entityTypeMeta = ctx.getBean(EntityTypeMetadata.class); AttributeMetadata attrMetaMeta = ctx.getBean(Attrib...
java
public void populate(Entity entity) { // auto date generateAutoDateOrDateTime(singletonList(entity), entity.getEntityType().getAttributes()); // auto id Attribute idAttr = entity.getEntityType().getIdAttribute(); if (idAttr != null && idAttr.isAuto() && entity.getIdValue() == null ...
java
public void populateL10nStrings() { AllPropertiesMessageSource allPropertiesMessageSource = new AllPropertiesMessageSource(); String[] namespaces = localizationMessageSources .stream() .map(PropertiesMessageSource::getNamespace) .toArray(String[]::new); allPropert...
java
public void populateLanguages() { dataService.add( LANGUAGE, languageFactory.create( LanguageService.DEFAULT_LANGUAGE_CODE, LanguageService.DEFAULT_LANGUAGE_NAME, true)); dataService.add( LANGUAGE, languageFactory.create("nl", new Locale("nl").getDisplayName(new Local...
java
List<Boolean> resolveBooleanExpressions(List<String> expressions, Entity entity) { if (expressions.isEmpty()) { return Collections.emptyList(); } return jsMagmaScriptEvaluator .eval(expressions, entity) .stream() .map(this::convertToBoolean) .collect(toList()); }
java
@PreAuthorize("hasAnyRole('ROLE_SU')") @PostMapping(value = "/add-bootstrap-theme") public @ResponseBody Style addBootstrapTheme( @RequestParam(value = "bootstrap3-style") MultipartFile bootstrap3Style, @RequestParam(value = "bootstrap4-style", required = false) MultipartFile bootstrap4Style) thro...
java
private static List<File> unzip(File file, NameMapper nameMapper) { try { File parentFile = file.getParentFile(); TrackingNameMapper trackingNameMapper = new TrackingNameMapper(parentFile, nameMapper); ZipUtil.unpack(file, parentFile, trackingNameMapper); return trackingNameMapper.getFiles()...
java
public static Map<String, Integer> createNGrams(String inputQuery, boolean removeStopWords) { List<String> wordsInString = Lists.newArrayList(Stemmer.replaceIllegalCharacter(inputQuery).split(" ")); if (removeStopWords) wordsInString.removeAll(STOPWORDSLIST); List<String> stemmedWordsInString = ...
java
private static double calculateScore( Map<String, Integer> inputStringTokens, Map<String, Integer> ontologyTermTokens) { if (inputStringTokens.size() == 0 || ontologyTermTokens.size() == 0) return (double) 0; int totalToken = getTotalNumTokens(inputStringTokens) + getTotalNumTokens(ontologyTermTokens); ...
java
public void addListener(SettingsEntityListener settingsEntityListener) { RunAsSystemAspect.runAsSystem( () -> entityListenersService.addEntityListener( entityTypeId, new EntityListener() { @Override public void postUpdate(Entity...
java
public void removeListener(SettingsEntityListener settingsEntityListener) { RunAsSystemAspect.runAsSystem( () -> entityListenersService.removeEntityListener( entityTypeId, new EntityListener() { @Override public void postUpdate...
java
@Override public void add(Entity entity) { if (entity == null) throw new IllegalArgumentException("Entity cannot be null"); if (cachedAttributes == null) throw new MolgenisDataException( "The attribute names are not defined, call writeAttributeNames first"); int i = 0; Row poiRow = sh...
java
public void writeAttributeHeaders( Iterable<Attribute> attributes, AttributeWriteMode attributeWriteMode) { if (attributes == null) throw new IllegalArgumentException("Attributes cannot be null"); if (attributeWriteMode == null) throw new IllegalArgumentException("AttributeWriteMode cannot be null")...
java
public Tag getTagEntity(String objectIRI, String label, Relation relation, String codeSystemIRI) { Tag tag = dataService .query(TAG, Tag.class) .eq(OBJECT_IRI, objectIRI) .and() .eq(RELATION_IRI, relation.getIRI()) .and() .eq(CODE_SYSTE...
java
public boolean populate(ContextRefreshedEvent event) { boolean databasePopulated = isDatabasePopulated(); if (!databasePopulated) { LOG.trace("Populating database with I18N strings ..."); i18nPopulator.populateLanguages(); LOG.trace("Populated database with I18N strings"); } LOG.trace...
java
public void validate(Query<? extends Entity> query, EntityType entityType) { query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType)); }
java
public void setValue(Object value) { if (value instanceof Iterable<?>) { this.value = stream((Iterable<?>) value).map(this::toValue).collect(toList()); } else { this.value = toValue(value); } }
java
Set<String> findMatchedWords(Explanation explanation) { Set<String> words = new HashSet<>(); String description = explanation.getDescription(); if (description.startsWith(Options.SUM_OF.toString()) || description.startsWith(Options.PRODUCT_OF.toString())) { if (newArrayList(explanation.getDeta...
java
Map<String, Double> findMatchQueries( String matchedWordsString, Map<String, String> collectExpandedQueryMap) { Map<String, Double> qualifiedQueries = new HashMap<>(); Set<String> matchedWords = splitIntoTerms(matchedWordsString); for (Entry<String, String> entry : collectExpandedQueryMap.entrySet()) ...
java
@Override @GetMapping public String init(final Model model) { super.init(model); model.addAttribute("adminEmails", userService.getSuEmailAddresses()); if (SecurityUtils.currentUserIsAuthenticated()) { User currentUser = userService.getUser(SecurityUtils.getCurrentUsername()); if (currentUser...
java
@SuppressWarnings("squid:S3457") // do not use platform specific line ending private SimpleMailMessage createFeedbackMessage(FeedbackForm form) { SimpleMailMessage message = new SimpleMailMessage(); message.setTo(userService.getSuEmailAddresses().toArray(new String[] {})); if (form.hasEmail()) { mes...
java
private static String getFormattedName(User user) { List<String> parts = new ArrayList<>(); if (user.getTitle() != null) { parts.add(user.getTitle()); } if (user.getFirstName() != null) { parts.add(user.getFirstName()); } if (user.getMiddleNames() != null) { parts.add(user.getM...
java
private byte[] generateRandomBytes(int nBytes, Random random) { byte[] randomBytes = new byte[nBytes]; random.nextBytes(randomBytes); return randomBytes; }
java
synchronized void unschedule(String scheduledJobId) { try { quartzScheduler.deleteJob(new JobKey(scheduledJobId, SCHEDULED_JOB_GROUP)); } catch (SchedulerException e) { String message = format("Error deleting ScheduledJob ''{0}''", scheduledJobId); LOG.error(message, e); throw new Schedu...
java
private static void validateMappedBy(Attribute attr, Attribute mappedByAttr) { if (mappedByAttr != null) { if (!isSingleReferenceType(mappedByAttr)) { throw new MolgenisDataException( format( "Invalid mappedBy attribute [%s] data type [%s].", mappedByAttr.ge...
java
private static void validateOrderBy(Attribute attr, Sort orderBy) { if (orderBy != null) { EntityType refEntity = attr.getRefEntity(); if (refEntity != null) { for (Sort.Order orderClause : orderBy) { String refAttrName = orderClause.getAttr(); if (refEntity.getAttribute(refA...
java
public ImportService getImportService(File file, RepositoryCollection source) { final Map<String, ImportService> importServicesMappedToExtensions = Maps.newHashMap(); importServices .stream() .filter(importService -> importService.canImport(file, source)) .forEach( importServ...
java
public static String cleanStemPhrase(String phrase) { StringBuilder stringBuilder = new StringBuilder(); for (String word : replaceIllegalCharacter(phrase).split(" ")) { String stemmedWord = stem(word); if (StringUtils.isNotEmpty(stemmedWord)) { if (stringBuilder.length() > 0) { st...
java
private String constructNodePath(String parentNodePath, int currentPosition) { StringBuilder nodePathStringBuilder = new StringBuilder(); if (!StringUtils.isEmpty(parentNodePath)) nodePathStringBuilder.append(parentNodePath).append('.'); nodePathStringBuilder .append(currentPosition) ....
java
public static Object getTypedValue(String valueStr, Attribute attr) { // Reference types cannot be processed because we lack an entityManager in this route. if (EntityTypeUtils.isReferenceType(attr)) { throw new MolgenisDataException( "getTypedValue(String, AttributeMetadata) can't be used for a...
java
public static Object getTypedValue(String valueStr, Attribute attr, EntityManager entityManager) { if (valueStr == null) return null; switch (attr.getDataType()) { case BOOL: return Boolean.valueOf(valueStr); case CATEGORICAL: case FILE: case XREF: EntityType xrefEntity =...
java
public static boolean equalsEntities( Iterable<Entity> entityIterable, Iterable<Entity> otherEntityIterable) { List<Entity> attrs = newArrayList(entityIterable); List<Entity> otherAttrs = newArrayList(otherEntityIterable); if (attrs.size() != otherAttrs.size()) return false; for (int i = 0; i < a...
java
public List<String> getEnumOptions() { String enumOptionsStr = getString(ENUM_OPTIONS); return enumOptionsStr != null ? asList(enumOptionsStr.split(",")) : emptyList(); }
java
public Attribute getInversedBy() { // FIXME besides checking mappedBy attr name also check // attr.getRefEntity().getFullyQualifiedName if (hasRefEntity()) { return Streams.stream(getRefEntity().getAtomicAttributes()) .filter(Attribute::isMappedBy) .filter(attr -> getName().equals(...
java
public void grantDefaultPermissions(GroupValue groupValue) { PackageIdentity packageIdentity = new PackageIdentity(groupValue.getRootPackage().getName()); GroupIdentity groupIdentity = new GroupIdentity(groupValue.getName()); aclService.createAcl(groupIdentity); groupValue .getRoles() .f...
java
public Fetch field(String field, Fetch fetch) { attrFetchMap.put(field, fetch); return this; }
java
public List<String> getTracksString(Map<String, GenomeBrowserTrack> entityTracks) { List<String> results = new ArrayList<>(); if (hasPermission()) { Map<String, GenomeBrowserTrack> allTracks = new HashMap<>(entityTracks); for (GenomeBrowserTrack track : entityTracks.values()) { allTracks.put...
java
public Entity get(Repository<Entity> repository, Object id) { LoadingCache<Object, Optional<Map<String, Object>>> cache = getEntityCache(repository); EntityType entityType = repository.getEntityType(); return cache.getUnchecked(id).map(e -> entityHydration.hydrate(e, entityType)).orElse(null); }
java
public List<Entity> getBatch(Repository<Entity> repository, Iterable<Object> ids) { try { return getEntityCache(repository) .getAll(ids) .values() .stream() .filter(Optional::isPresent) .map(Optional::get) .map(e -> entityHydration.hydrate(e, reposit...
java
private LoadingCache<Object, Optional<Map<String, Object>>> createEntityCache( Repository<Entity> repository) { Caffeine<Object, Object> cacheBuilder = Caffeine.newBuilder().recordStats().expireAfterAccess(10, MINUTES); if (!MetaDataService.isMetaEntityType(repository.getEntityType())) { cac...
java
private void removeMappedByAttributes(Map<String, EntityType> resolvedEntityTypes) { resolvedEntityTypes .values() .stream() .flatMap(EntityType::getMappedByAttributes) .filter(attribute -> resolvedEntityTypes.containsKey(attribute.getEntity().getId())) .forEach(attribute -> ...
java
<T> T call(Job<T> job, Progress progress, JobExecutionContext jobExecutionContext) { return runWithContext(jobExecutionContext, () -> tryCall(job, progress)); }
java
private Entity findSynonymWithHighestNgramScore( String ontologyIri, String queryString, Entity ontologyTermEntity) { Iterable<Entity> entities = ontologyTermEntity.getEntities(OntologyTermMetadata.ONTOLOGY_TERM_SYNONYM); if (Iterables.size(entities) > 0) { String cleanedQueryString = remove...
java
private static String generateBase64Authentication(String username, String password) { requireNonNull(username, password); String userPass = username + ":" + password; String userPassBase64 = Base64.getEncoder().encodeToString(userPass.getBytes(UTF_8)); return "Basic " + userPassBase64; }
java
private String executeScriptExecuteRequest(String rScript) throws IOException { URI uri = getScriptExecutionUri(); HttpPost httpPost = new HttpPost(uri); NameValuePair nameValuePair = new BasicNameValuePair("x", rScript); httpPost.setEntity(new UrlEncodedFormEntity(singletonList(nameValuePair))); S...
java
private String executeScriptGetResponseRequest( String openCpuSessionKey, String scriptOutputFilename, String outputPathname) throws IOException { String responseValue; if (scriptOutputFilename != null) { executeScriptGetFileRequest(openCpuSessionKey, scriptOutputFilename, outputPathname); ...
java
private void executeScriptGetFileRequest( String openCpuSessionKey, String scriptOutputFilename, String outputPathname) throws IOException { URI scriptGetValueResponseUri = getScriptGetFileResponseUri(openCpuSessionKey, scriptOutputFilename); HttpGet httpGet = new HttpGet(scriptGetValueRespo...
java
private String executeScriptGetValueRequest(String openCpuSessionKey) throws IOException { URI scriptGetValueResponseUri = getScriptGetValueResponseUri(openCpuSessionKey); HttpGet httpGet = new HttpGet(scriptGetValueResponseUri); String responseValue; try (CloseableHttpResponse response = httpClient.exe...
java
@Bean public ViewResolver viewResolver() { FreeMarkerViewResolver resolver = new FreeMarkerViewResolver(); resolver.setCache(true); resolver.setSuffix(".ftl"); resolver.setContentType("text/html;charset=UTF-8"); return resolver; }
java
@Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer result = new FreeMarkerConfigurer() { @Override protected void postProcessConfiguration(Configuration config) { config.setObjectWrapper(new MolgenisFreemarkerObjectWrapper(VERSION_2_3_23)); ...
java
private String toAttributeName(String vcfInfoFieldKey) { String attrName = infoFieldKeyToAttrNameMap.get(vcfInfoFieldKey); if (attrName == null) { throw new RuntimeException( format("Missing attribute for VCF info field [%s]", vcfInfoFieldKey)); } return attrName; }
java
private static Set<String> determineVcfInfoFlagFields(VcfMeta vcfMeta) { return stream(vcfMeta.getInfoMeta()) .filter(vcfInfoMeta -> vcfInfoMeta.getType().equals(VcfMetaInfo.Type.FLAG)) .map(VcfMetaInfo::getId) .collect(toSet()); }
java
private static Map<String, String> createInfoFieldKeyToAttrNameMap( VcfMeta vcfMeta, String entityTypeId) { Map<String, String> infoFieldIdToAttrNameMap = newHashMapWithExpectedSize(size(vcfMeta.getInfoMeta())); for (VcfMetaInfo info : vcfMeta.getInfoMeta()) { // according to the VCF standar...
java
public Optional<CacheHit<Entity>> get(String entityTypeId, Object id, EntityType entityType) { CombinedEntityCache cache = caches.get(); if (cache == null) { return Optional.empty(); } Optional<CacheHit<Entity>> result = cache.getIfPresent(entityType, id); if (result.isPresent()) { LOG.d...
java
public void put(String entityTypeId, Entity entity) { CombinedEntityCache entityCache = caches.get(); if (entityCache != null) { entityCache.put(entity); LOG.trace( "Added dehydrated row [{}] from entity {} to the L1 cache", entity.getIdValue(), entityTypeId); } }
java
private List<Entity> findAllBatch(List<Object> batch) { String entityId = getEntityType().getId(); EntityType entityType = getEntityType(); List<Object> missingIds = batch .stream() .filter(id -> !l1Cache.get(entityId, id, entityType).isPresent()) .collect(toList(...
java
private void evictBiDiReferencedEntityTypes() { getEntityType().getMappedByAttributes().map(Attribute::getRefEntity).forEach(l1Cache::evictAll); getEntityType() .getInversedByAttributes() .map(Attribute::getRefEntity) .forEach(l1Cache::evictAll); }
java
private void evictBiDiReferencedEntities(Entity entity) { Stream<EntityKey> backreffingEntities = getEntityType() .getMappedByAttributes() .flatMap(mappedByAttr -> Streams.stream(entity.getEntities(mappedByAttr.getName()))) .map(EntityKey::create); Stream<EntityKey> m...
java
public Hits<ExplainedAttribute> findAttributes( EntityType sourceEntityType, Set<String> queryTerms, Collection<OntologyTerm> ontologyTerms) { Iterable<String> attributeIdentifiers = semanticSearchServiceHelper.getAttributeIdentifiers(sourceEntityType); QueryRule disMaxQueryRule = semanti...
java
public Set<String> createLexicalSearchQueryTerms( Attribute targetAttribute, Set<String> searchTerms) { Set<String> queryTerms = new HashSet<>(); if (searchTerms != null && !searchTerms.isEmpty()) { queryTerms.addAll(searchTerms); } if (queryTerms.isEmpty()) { if (StringUtils.isNotBl...
java
public Set<ExplainedQueryString> convertAttributeToExplainedAttribute( Attribute attribute, Map<String, String> collectExpandedQueryMap, Query<Entity> query) { EntityType attributeMetaData = dataService.getEntityType(ATTRIBUTE_META_DATA); String attributeID = attribute.getIdentifier(); Explanation exp...
java
public static List<Entity> resolvePackages(Iterable<Entity> packageRepo) { List<Entity> resolved = new LinkedList<>(); if ((packageRepo == null) || Iterables.isEmpty(packageRepo)) return resolved; List<Entity> unresolved = new ArrayList<>(); Map<String, Entity> resolvedByName = new HashMap<>(); fo...
java
public int getOntologyTermDistance(OntologyTerm ontologyTerm1, OntologyTerm ontologyTerm2) { String nodePath1 = getOntologyTermNodePath(ontologyTerm1); String nodePath2 = getOntologyTermNodePath(ontologyTerm2); if (StringUtils.isEmpty(nodePath1)) { throw new MolgenisDataAccessException( "Th...
java
public List<OntologyTerm> getChildren(OntologyTerm ontologyTerm) { Iterable<org.molgenis.ontology.core.meta.OntologyTerm> ontologyTermEntities = () -> dataService .query(ONTOLOGY_TERM, org.molgenis.ontology.core.meta.OntologyTerm.class) .eq(ONTOLOGY_TERM_IRI, onto...
java
static String toValue(Cell cell, List<CellProcessor> cellProcessors) { String value; switch (cell.getCellTypeEnum()) { case BLANK: value = null; break; case STRING: value = cell.getStringCellValue(); break; case NUMERIC: if (DateUtil.isCellDateFormatted(...
java
private static String formatUTCDateAsLocalDateTime(Date javaDate) { // Now back from start of day in UTC to LocalDateTime to express that we don't know the // timezone. LocalDateTime localDateTime = javaDate.toInstant().atZone(UTC).toLocalDateTime(); // And format to string return localDateTime.toSt...
java
public static String getCurrentUri() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); StringBuilder uri = new StringBuilder(); uri.append(request.getAttribute("javax.servlet.forward.request_uri")); if (StringUtils.isNotBl...
java