idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
41,100 | 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 . getEntit... | Creates a new Entity cache | 180 | 6 |
41,101 | private void removeMappedByAttributes ( Map < String , EntityType > resolvedEntityTypes ) { resolvedEntityTypes . values ( ) . stream ( ) . flatMap ( EntityType :: getMappedByAttributes ) . filter ( attribute -> resolvedEntityTypes . containsKey ( attribute . getEntity ( ) . getId ( ) ) ) . forEach ( attribute -> dataS... | Removes the mappedBy attributes of each OneToMany pair in the supplied map of EntityTypes | 95 | 19 |
41,102 | < T > T call ( Job < T > job , Progress progress , JobExecutionContext jobExecutionContext ) { return runWithContext ( jobExecutionContext , ( ) -> tryCall ( job , progress ) ) ; } | Executes a job in the calling thread . | 48 | 9 |
41,103 | 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 ; } | Generate base64 authentication based on username and password . | 78 | 11 |
41,104 | 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 ) )... | Execute R script using OpenCPU | 337 | 7 |
41,105 | private String executeScriptGetResponseRequest ( String openCpuSessionKey , String scriptOutputFilename , String outputPathname ) throws IOException { String responseValue ; if ( scriptOutputFilename != null ) { executeScriptGetFileRequest ( openCpuSessionKey , scriptOutputFilename , outputPathname ) ; responseValue = ... | Retrieve R script response using OpenCPU | 93 | 8 |
41,106 | private void executeScriptGetFileRequest ( String openCpuSessionKey , String scriptOutputFilename , String outputPathname ) throws IOException { URI scriptGetValueResponseUri = getScriptGetFileResponseUri ( openCpuSessionKey , scriptOutputFilename ) ; HttpGet httpGet = new HttpGet ( scriptGetValueResponseUri ) ; try ( ... | Retrieve R script file response using OpenCPU and write to file | 203 | 13 |
41,107 | private String executeScriptGetValueRequest ( String openCpuSessionKey ) throws IOException { URI scriptGetValueResponseUri = getScriptGetValueResponseUri ( openCpuSessionKey ) ; HttpGet httpGet = new HttpGet ( scriptGetValueResponseUri ) ; String responseValue ; try ( CloseableHttpResponse response = httpClient . exec... | Retrieve and return R script STDOUT response using OpenCPU | 188 | 12 |
41,108 | @ Bean public ViewResolver viewResolver ( ) { FreeMarkerViewResolver resolver = new FreeMarkerViewResolver ( ) ; resolver . setCache ( true ) ; resolver . setSuffix ( ".ftl" ) ; resolver . setContentType ( "text/html;charset=UTF-8" ) ; return resolver ; } | Enable spring freemarker viewresolver . All freemarker template names should end with . ftl | 81 | 21 |
41,109 | @ Bean public FreeMarkerConfigurer freeMarkerConfigurer ( ) { FreeMarkerConfigurer result = new FreeMarkerConfigurer ( ) { @ Override protected void postProcessConfiguration ( Configuration config ) { config . setObjectWrapper ( new MolgenisFreemarkerObjectWrapper ( VERSION_2_3_23 ) ) ; } @ Override protected void post... | Configure freemarker . All freemarker templates should be on the classpath in a package called freemarker | 351 | 24 |
41,110 | 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 ; } | Returns the corresponding attribute name for a VCF info field key | 81 | 12 |
41,111 | private static Set < String > determineVcfInfoFlagFields ( VcfMeta vcfMeta ) { return stream ( vcfMeta . getInfoMeta ( ) ) . filter ( vcfInfoMeta -> vcfInfoMeta . getType ( ) . equals ( VcfMetaInfo . Type . FLAG ) ) . map ( VcfMetaInfo :: getId ) . collect ( toSet ( ) ) ; } | Returns a set of all possible VCF info fields of type Flag | 87 | 13 |
41,112 | 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... | Returns a mapping of VCF info field keys to MOLGENIS attribute names | 281 | 16 |
41,113 | 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 ( )... | Retrieves an entity from the L1 cache based on a combination of entity name and entity id . | 151 | 21 |
41,114 | 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 ) ; } } | Puts an entity into the L1 cache if the cache exists for the current thread . | 79 | 18 |
41,115 | 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 ( ) ) ; Map ... | Looks up the Entities for a List of entity IDs . Those present in the cache are returned from cache . The missing ones are retrieved from the decoratedRepository . | 195 | 33 |
41,116 | private void evictBiDiReferencedEntityTypes ( ) { getEntityType ( ) . getMappedByAttributes ( ) . map ( Attribute :: getRefEntity ) . forEach ( l1Cache :: evictAll ) ; getEntityType ( ) . getInversedByAttributes ( ) . map ( Attribute :: getRefEntity ) . forEach ( l1Cache :: evictAll ) ; } | Evict all entries for entity types referred to by this entity type through a bidirectional relation . | 85 | 20 |
41,117 | private void evictBiDiReferencedEntities ( Entity entity ) { Stream < EntityKey > backreffingEntities = getEntityType ( ) . getMappedByAttributes ( ) . flatMap ( mappedByAttr -> Streams . stream ( entity . getEntities ( mappedByAttr . getName ( ) ) ) ) . map ( EntityKey :: create ) ; Stream < EntityKey > manyToOneEntit... | Evict all entity instances referenced by this entity instance through a bidirectional relation . | 178 | 17 |
41,118 | public Hits < ExplainedAttribute > findAttributes ( EntityType sourceEntityType , Set < String > queryTerms , Collection < OntologyTerm > ontologyTerms ) { Iterable < String > attributeIdentifiers = semanticSearchServiceHelper . getAttributeIdentifiers ( sourceEntityType ) ; QueryRule disMaxQueryRule = semanticSearchSe... | public for testability | 546 | 4 |
41,119 | 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 . isNot... | A helper function to create a list of queryTerms based on the information from the targetAttribute as well as user defined searchTerms . If the user defined searchTerms exist the targetAttribute information will not be used . | 168 | 45 |
41,120 | public Set < ExplainedQueryString > convertAttributeToExplainedAttribute ( Attribute attribute , Map < String , String > collectExpandedQueryMap , Query < Entity > query ) { EntityType attributeMetaData = dataService . getEntityType ( ATTRIBUTE_META_DATA ) ; String attributeID = attribute . getIdentifier ( ) ; Explanat... | A helper function to explain each of the matched attributes returned by the explain - API | 121 | 16 |
41,121 | 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 ... | Resolves package fullNames by looping through all the packages and their parents | 355 | 15 |
41,122 | public int getOntologyTermDistance ( OntologyTerm ontologyTerm1 , OntologyTerm ontologyTerm2 ) { String nodePath1 = getOntologyTermNodePath ( ontologyTerm1 ) ; String nodePath2 = getOntologyTermNodePath ( ontologyTerm2 ) ; if ( StringUtils . isEmpty ( nodePath1 ) ) { throw new MolgenisDataAccessException ( "The nodePat... | Calculate the distance between any two ontology terms in the ontology tree structure by calculating the difference in nodePaths . | 169 | 26 |
41,123 | 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 , ontologyTerm . getI... | Retrieve all descendant ontology terms | 238 | 7 |
41,124 | 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 ( cell ) ) { try { // Excel dates are ... | Gets a cell value as String and process the value with the given cellProcessors | 800 | 17 |
41,125 | 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 . toStr... | Formats parsed Date as LocalDateTime string at zone UTC to express that we don t know the timezone . | 86 | 23 |
41,126 | 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 . i... | Gets the uri which is currently visible in the browser . | 131 | 13 |
41,127 | private void injectExistingEntityTypeAttributeIdentifiers ( List < ? extends EntityType > entityTypes ) { Map < String , EntityType > existingEntityTypeMap = dataService . findAll ( ENTITY_TYPE_META_DATA , EntityType . class ) . collect ( toMap ( EntityType :: getId , entityType -> entityType ) ) ; entityTypes . forEac... | Inject existing attribute identifiers in system entity types | 255 | 9 |
41,128 | private void addAttributeInternal ( EntityType entityType , Attribute attr ) { if ( ! isPersisted ( attr ) ) { return ; } if ( isMultipleReferenceType ( attr ) ) { createJunctionTable ( entityType , attr ) ; if ( attr . getDefaultValue ( ) != null && ! attr . isNillable ( ) ) { @ SuppressWarnings ( "unchecked" ) Iterab... | Add attribute to entityType . | 177 | 6 |
41,129 | private static boolean isPersisted ( Attribute attr ) { return ! attr . hasExpression ( ) && attr . getDataType ( ) != COMPOUND && ! ( attr . getDataType ( ) == ONE_TO_MANY && attr . isMappedBy ( ) ) ; } | Indicates if the attribute is persisted in the database . Compound attributes computed attributes with an expression and one - to - many mappedBy attributes are not persisted . | 66 | 32 |
41,130 | private void updateColumn ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { // nullable changes if ( ! Objects . equals ( attr . isNillable ( ) , updatedAttr . isNillable ( ) ) ) { updateNillable ( entityType , attr , updatedAttr ) ; } // unique changes if ( ! Objects . equals ( attr . isUnique ( ) ,... | Updates database column based on attribute changes . | 388 | 9 |
41,131 | private void updateRefEntity ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { if ( isSingleReferenceType ( attr ) && isSingleReferenceType ( updatedAttr ) ) { dropForeignKey ( entityType , attr ) ; if ( attr . getRefEntity ( ) . getIdAttribute ( ) . getDataType ( ) != updatedAttr . getRefEntity ( ) ... | Updates foreign keys based on referenced entity changes . | 260 | 10 |
41,132 | private void updateEnumOptions ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { if ( attr . getDataType ( ) == ENUM ) { if ( updatedAttr . getDataType ( ) == ENUM ) { // update check constraint dropCheckConstraint ( entityType , attr ) ; createCheckConstraint ( entityType , updatedAttr ) ; } else { ... | Updates check constraint based on enum value changes . | 143 | 10 |
41,133 | private void updateDataType ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { Attribute idAttr = entityType . getIdAttribute ( ) ; if ( idAttr != null && idAttr . getName ( ) . equals ( attr . getName ( ) ) ) { throw new MolgenisDataException ( format ( "Data type of entity [%s] attribute [%s] cannot... | Updates column data type and foreign key constraints based on data type update . | 417 | 15 |
41,134 | private void updateUnique ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { if ( attr . isUnique ( ) && ! updatedAttr . isUnique ( ) ) { Attribute idAttr = entityType . getIdAttribute ( ) ; if ( idAttr != null && idAttr . getName ( ) . equals ( attr . getName ( ) ) ) { throw new MolgenisDataException... | Updates unique constraint based on attribute unique changes . | 183 | 10 |
41,135 | private void updateReadonly ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { Map < String , Attribute > readonlyTableAttrs = getTableAttributesReadonly ( entityType ) . collect ( toLinkedMap ( Attribute :: getName , Function . identity ( ) ) ) ; if ( ! readonlyTableAttrs . isEmpty ( ) ) { dropTableT... | Updates triggers and functions based on attribute readonly changes . | 218 | 12 |
41,136 | private void registerRefEntityIndexActions ( ) { // bidirectional attribute: register indexing actions for other side getEntityType ( ) . getMappedByAttributes ( ) . forEach ( mappedByAttr -> { EntityType refEntity = mappedByAttr . getRefEntity ( ) ; indexActionRegisterService . register ( refEntity , null ) ; } ) ; ge... | Register index actions for entity types with bidirectional attribute values . | 140 | 13 |
41,137 | private void registerRefEntityIndexActions ( Entity entity ) { // bidirectional attribute: register indexing actions for other side getEntityType ( ) . getMappedByAttributes ( ) . forEach ( mappedByAttr -> { EntityType mappedByAttrRefEntity = mappedByAttr . getRefEntity ( ) ; entity . getEntities ( mappedByAttr . getNa... | Register index actions for the given entity for entity types with bidirectional attribute values . | 231 | 17 |
41,138 | private Multimap < Object , Object > selectMrefIDsForAttribute ( EntityType entityType , AttributeType idAttributeDataType , Attribute mrefAttr , Set < Object > ids , AttributeType refIdDataType ) { Stopwatch stopwatch = null ; if ( LOG . isTraceEnabled ( ) ) stopwatch = createStarted ( ) ; String junctionTableSelect =... | Selects MREF IDs for an MREF attribute from the junction table in the order of the MREF attribute value . | 257 | 24 |
41,139 | void appendLog ( String formattedMessage ) { if ( logTruncated ) return ; String combined = join ( getLog ( ) , formattedMessage ) ; if ( combined . length ( ) > MAX_LOG_LENGTH ) { String truncated = abbreviate ( combined , MAX_LOG_LENGTH - TRUNCATION_BANNER . length ( ) * 2 - 2 ) ; combined = join ( new String [ ] { T... | Appends a log message to the execution log . The first time the log exceeds MAX_LOG_LENGTH it gets truncated and the TRUNCATION_BANNER gets added . Subsequent calls to appendLog will be ignored . | 133 | 49 |
41,140 | public ScriptResult runScript ( String scriptName , Map < String , Object > parameters ) { Script script = dataService . query ( SCRIPT , Script . class ) . eq ( ScriptMetadata . NAME , scriptName ) . findOne ( ) ; if ( script == null ) { throw new UnknownEntityException ( SCRIPT , scriptName ) ; } if ( script . getPar... | Run a script with parameters . | 404 | 6 |
41,141 | private void convertIdtoLabelLabels ( List < Object > idLabels , EntityType entityType , DataService dataService ) { final int nrLabels = idLabels . size ( ) ; if ( nrLabels > 0 ) { // Get entities for ids // Use Iterables.transform to work around List<String> to Iterable<Object> cast error Stream < Object > idLabelsWi... | Convert matrix labels that contain ids to label attribute values . Keeps in mind that the last label on a axis is Total . | 290 | 27 |
41,142 | public static @ Nullable @ CheckForNull String getCurrentUsername ( ) { Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication == null ) { return null ; } return getUsername ( authentication ) ; } | Returns the username of the current authentication . | 56 | 8 |
41,143 | public static boolean currentUserHasRole ( String ... roles ) { if ( roles == null || roles . length == 0 ) return false ; Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication != null ) { Collection < ? extends GrantedAuthority > authorities = authenticati... | Returns whether the current user has at least one of the given roles | 139 | 13 |
41,144 | public static boolean currentUserIsAuthenticated ( ) { Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; return authentication != null && authentication . isAuthenticated ( ) && ! currentUserIsAnonymous ( ) ; } | Returns whether the current user is authenticated and not the anonymous user | 52 | 12 |
41,145 | @ Override public Entity findOneById ( Object id ) { if ( cacheable && ! transactionInformation . isEntireRepositoryDirty ( getEntityType ( ) ) && ! transactionInformation . isEntityDirty ( EntityKey . create ( getEntityType ( ) , id ) ) ) { return l2Cache . get ( delegate ( ) , id ) ; } return delegate ( ) . findOneBy... | Retrieves a single entity by id . | 90 | 9 |
41,146 | private List < Entity > findAllBatch ( List < Object > ids ) { String entityTypeId = getEntityType ( ) . getId ( ) ; Multimap < Boolean , Object > partitionedIds = Multimaps . index ( ids , id -> transactionInformation . isEntityDirty ( EntityKey . create ( entityTypeId , id ) ) ) ; Collection < Object > cleanIds = par... | Retrieves a batch of Entity IDs . | 227 | 9 |
41,147 | public void evictAll ( EntityType entityType ) { cache . asMap ( ) . keySet ( ) . stream ( ) . filter ( e -> e . getEntityTypeId ( ) . equals ( entityType . getId ( ) ) ) . forEach ( cache :: invalidate ) ; } | Evicts all entries from the cache that belong to a certain entityType . | 62 | 15 |
41,148 | public Optional < CacheHit < Entity > > getIfPresent ( EntityType entityType , Object id ) { EntityKey key = EntityKey . create ( entityType , id ) ; return Optional . ofNullable ( cache . getIfPresent ( key ) ) . map ( cacheHit -> hydrate ( cacheHit , entityType ) ) ; } | Retrieves an entity from the cache if present . | 71 | 11 |
41,149 | public void put ( Entity entity ) { EntityType entityType = entity . getEntityType ( ) ; cache . put ( EntityKey . create ( entityType , entity . getIdValue ( ) ) , CacheHit . of ( entityHydration . dehydrate ( entity ) ) ) ; } | Inserts an entity into the cache . | 60 | 8 |
41,150 | public static File saveToTempFile ( Part part ) throws IOException { String filename = getOriginalFileName ( part ) ; if ( filename == null ) { return null ; } File file = File . createTempFile ( "molgenis-" , "." + StringUtils . getFilenameExtension ( filename ) ) ; FileCopyUtils . copy ( part . getInputStream ( ) , n... | Saves an uploaded file to a tempfile with prefix molgenis - keeps the original file extension | 96 | 20 |
41,151 | public static File saveToTempFolder ( Part part ) throws IOException { String filename = getOriginalFileName ( part ) ; if ( filename == null ) { return null ; } File file = new File ( FileUtils . getTempDirectory ( ) , filename ) ; FileCopyUtils . copy ( part . getInputStream ( ) , new FileOutputStream ( file ) ) ; re... | Save an Uploaded file to the temp folder keeping it original name | 84 | 13 |
41,152 | public static String getOriginalFileName ( Part part ) { String contentDisposition = part . getHeader ( "content-disposition" ) ; if ( contentDisposition != null ) { for ( String cd : contentDisposition . split ( ";" ) ) { if ( cd . trim ( ) . startsWith ( "filename" ) ) { String path = cd . substring ( cd . indexOf ( ... | Get the filename of an uploaded file | 155 | 7 |
41,153 | @ Bean public JobFactory < ScriptJobExecution > scriptJobFactory ( ) { return new JobFactory < ScriptJobExecution > ( ) { @ Override public Job < ScriptResult > createJob ( ScriptJobExecution scriptJobExecution ) { final String name = scriptJobExecution . getName ( ) ; final String parameterString = scriptJobExecution ... | The Script JobFactory bean . | 249 | 6 |
41,154 | @ PreAuthorize ( "hasAnyRole('ROLE_SU')" ) @ PostMapping ( "/upload-logo" ) public String uploadLogo ( @ RequestParam ( "logo" ) Part part , Model model ) throws IOException { String contentType = part . getContentType ( ) ; if ( ( contentType == null ) || ! contentType . startsWith ( "image" ) ) { model . addAttribute... | Upload a new molgenis logo | 284 | 7 |
41,155 | public Stream < EntityType > getCompatibleEntityTypes ( EntityType target ) { return dataService . getMeta ( ) . getEntityTypes ( ) . filter ( candidate -> ! candidate . isAbstract ( ) ) . filter ( isCompatible ( target ) ) ; } | Public for testability | 56 | 4 |
41,156 | private Set < Impact > collectResult ( List < Impact > singleEntityChanges , List < Impact > wholeRepoActions , Set < String > dependentEntityIds ) { Set < String > wholeRepoIds = union ( wholeRepoActions . stream ( ) . map ( Impact :: getEntityTypeId ) . collect ( toImmutableSet ( ) ) , dependentEntityIds ) ; Immutabl... | Combines the results . | 192 | 5 |
41,157 | public Object eval ( Bindings bindings , String expression ) throws ScriptException { CompiledScript compiledExpression = requireNonNull ( expressions . get ( expression ) ) ; Object returnValue = compiledExpression . eval ( bindings ) ; return convertNashornValue ( returnValue ) ; } | Evaluates an expression using the given bindings . | 59 | 10 |
41,158 | public void addFileRepositoryCollectionClass ( Class < ? extends FileRepositoryCollection > clazz , Set < String > fileExtensions ) { for ( String extension : fileExtensions ) { fileRepositoryCollections . put ( extension . toLowerCase ( ) , clazz ) ; } } | Add a FileRepositorySource so it can be used by the createFileRepositySource factory method | 62 | 20 |
41,159 | public FileRepositoryCollection createFileRepositoryCollection ( File file ) { Class < ? extends FileRepositoryCollection > clazz ; String extension = FileExtensionUtils . findExtensionFromPossibilities ( file . getName ( ) , fileRepositoryCollections . keySet ( ) ) ; clazz = fileRepositoryCollections . get ( extension... | Factory method for creating a new FileRepositorySource | 281 | 10 |
41,160 | private static boolean hasNewMappedByAttrs ( EntityType entityType , EntityType existingEntityType ) { Set < String > mappedByAttrs = entityType . getOwnMappedByAttributes ( ) . map ( Attribute :: getName ) . collect ( toSet ( ) ) ; Set < String > existingMappedByAttrs = existingEntityType . getOwnMappedByAttributes ( ... | Returns true if entity meta contains mapped by attributes that do not exist in the existing entity meta . | 120 | 19 |
41,161 | private void upsertAttributes ( EntityType entityType , EntityType existingEntityType ) { // analyze both compound and atomic attributes owned by the entity Map < String , Attribute > attrsMap = stream ( entityType . getOwnAllAttributes ( ) ) . collect ( toMap ( Attribute :: getName , Function . identity ( ) ) ) ; Map ... | Add and update entity attributes | 450 | 5 |
41,162 | public EntityImportReport doImport ( EmxImportJob job ) { try { return writer . doImport ( job ) ; } catch ( Exception e ) { LOG . error ( "Error handling EmxImportJob" , e ) ; throw e ; } } | Does the import in a transaction . Manually rolls back schema changes if something goes wrong . Refreshes the metadata . | 53 | 24 |
41,163 | private Optional < String > tryGetEntityTypeName ( String tableName ) { EntityTypeDescription entityTypeDescription = entityTypeRegistry . getEntityTypeDescription ( tableName ) ; String entityTypeId = entityTypeDescription != null ? entityTypeDescription . getId ( ) : null ; return Optional . ofNullable ( entityTypeId... | Tries to determine the entity type identifier for this table name | 72 | 12 |
41,164 | private Optional < String > tryGetAttributeName ( String tableName , String colName ) { String attributeName ; EntityTypeDescription entityTypeDescription = entityTypeRegistry . getEntityTypeDescription ( tableName ) ; if ( entityTypeDescription != null ) { AttributeDescription attrDescription = entityTypeDescription .... | Tries to determine the attribute name for this table column name | 128 | 12 |
41,165 | private void assignUniqueLabel ( Package pack , Package targetPackage ) { Set < String > existingLabels ; if ( targetPackage != null ) { existingLabels = stream ( targetPackage . getChildren ( ) ) . map ( Package :: getLabel ) . collect ( toSet ( ) ) ; } else { existingLabels = dataService . query ( PACKAGE , Package .... | Checks if there s a Package in the target location with the same label . If so keeps adding a postfix until the label is unique . | 138 | 29 |
41,166 | public Map < String , Object > dehydrate ( Entity entity ) { LOG . trace ( "Dehydrating entity {}" , entity ) ; Map < String , Object > dehydratedEntity = newHashMap ( ) ; EntityType entityType = entity . getEntityType ( ) ; entityType . getAtomicAttributes ( ) . forEach ( attribute -> { // Only dehydrate if the attrib... | Creates a Map containing the values required to rebuild this entity . For references to other entities only stores the ids . | 151 | 24 |
41,167 | public void move ( String sourceDir , String targetDir ) throws IOException { validatePathname ( sourceDir ) ; validatePathname ( targetDir ) ; Files . move ( Paths . get ( getStorageDir ( ) + File . separator + sourceDir ) , Paths . get ( getStorageDir ( ) + File . separator + targetDir ) ) ; } | Move directories in FileStore Pleae provide the path from the relative root of the fileStore | 78 | 18 |
41,168 | private boolean hasAttributeThatReferences ( EntityType candidate , String entityTypeId ) { Iterable < Attribute > attributes = candidate . getOwnAtomicAttributes ( ) ; return stream ( attributes ) . filter ( Attribute :: hasRefEntity ) . map ( attribute -> attribute . getRefEntity ( ) . getId ( ) ) . anyMatch ( entity... | Determines if an entityType has an attribute that references another entity | 80 | 14 |
41,169 | public QueryRule createDisMaxQueryRuleForAttribute ( Set < String > searchTerms , Collection < OntologyTerm > ontologyTerms ) { List < String > queryTerms = new ArrayList <> ( ) ; if ( searchTerms != null ) { queryTerms . addAll ( searchTerms . stream ( ) . filter ( StringUtils :: isNotBlank ) . map ( this :: processQu... | Create a disMaxJunc query rule based on the given search terms as well as the information from given ontology terms | 278 | 24 |
41,170 | public QueryRule createDisMaxQueryRuleForTerms ( List < String > queryTerms ) { List < QueryRule > rules = new ArrayList <> ( ) ; queryTerms . stream ( ) . filter ( StringUtils :: isNotEmpty ) . map ( this :: escapeCharsExcludingCaretChar ) . forEach ( query -> { rules . add ( new QueryRule ( AttributeMetadata . LABEL ... | Create disMaxJunc query rule based a list of queryTerm . All queryTerms are lower cased and stop words are removed | 176 | 27 |
41,171 | public QueryRule createBoostedDisMaxQueryRuleForTerms ( List < String > queryTerms , Double boostValue ) { QueryRule finalDisMaxQuery = createDisMaxQueryRuleForTerms ( queryTerms ) ; if ( boostValue != null && boostValue . intValue ( ) != 0 ) { finalDisMaxQuery . setValue ( boostValue ) ; } return finalDisMaxQuery ; } | Create a disMaxQueryRule with corresponding boosted value | 86 | 10 |
41,172 | public QueryRule createShouldQueryRule ( String multiOntologyTermIri ) { QueryRule shouldQueryRule = new QueryRule ( new ArrayList <> ( ) ) ; shouldQueryRule . setOperator ( Operator . SHOULD ) ; for ( String ontologyTermIri : multiOntologyTermIri . split ( COMMA_CHAR ) ) { OntologyTerm ontologyTerm = ontologyService .... | Create a boolean should query for composite tags containing multiple ontology terms | 176 | 13 |
41,173 | public List < String > parseOntologyTermQueries ( OntologyTerm ontologyTerm ) { List < String > queryTerms = getOtLabelAndSynonyms ( ontologyTerm ) . stream ( ) . map ( this :: processQueryString ) . collect ( Collectors . toList ( ) ) ; for ( OntologyTerm childOt : ontologyService . getChildren ( ontologyTerm ) ) { do... | Create a list of string queries based on the information collected from current ontologyterm including label synonyms and child ontologyterms | 165 | 25 |
41,174 | public Set < String > getOtLabelAndSynonyms ( OntologyTerm ontologyTerm ) { Set < String > allTerms = Sets . newLinkedHashSet ( ontologyTerm . getSynonyms ( ) ) ; allTerms . add ( ontologyTerm . getLabel ( ) ) ; return allTerms ; } | A helper function to collect synonyms as well as label of ontologyterm | 70 | 15 |
41,175 | public List < String > getAttributeIdentifiers ( EntityType sourceEntityType ) { Entity entityTypeEntity = dataService . findOne ( ENTITY_TYPE_META_DATA , new QueryImpl <> ( ) . eq ( EntityTypeMetadata . ID , sourceEntityType . getId ( ) ) ) ; if ( entityTypeEntity == null ) throw new MolgenisDataAccessException ( "Cou... | A helper function that gets identifiers of all the attributes from one EntityType | 161 | 14 |
41,176 | private Entity toEntity ( EntityType entityType , Entity emxEntity ) { Entity entity = entityManager . create ( entityType , POPULATE ) ; for ( Attribute attr : entityType . getAtomicAttributes ( ) ) { if ( attr . getExpression ( ) == null && ! attr . isMappedBy ( ) ) { String attrName = attr . getName ( ) ; Object emx... | Create an entity from the EMX entity | 488 | 8 |
41,177 | private Column createColumnFromCell ( Sheet sheet , Cell cell ) { if ( cell . getCellTypeEnum ( ) == CellType . STRING ) { return Column . create ( cell . getStringCellValue ( ) , cell . getColumnIndex ( ) , getColumnDataFromSheet ( sheet , cell . getColumnIndex ( ) ) ) ; } else { throw new MolgenisDataException ( Stri... | Specific columntypes are permitted in the import . The supported columntypes are specified in the method . | 118 | 23 |
41,178 | private Object getCellValue ( Cell cell ) { Object value ; // Empty cells are null, instead of BLANK if ( cell == null ) { return null ; } switch ( cell . getCellTypeEnum ( ) ) { case STRING : value = cell . getStringCellValue ( ) ; break ; case NUMERIC : if ( isCellDateFormatted ( cell ) ) { try { // Excel dates are L... | Retrieves the proper Java type instance based on the Excel CellTypeEnum | 245 | 16 |
41,179 | public void validate ( EntityType entityType ) { validateEntityId ( entityType ) ; validateEntityLabel ( entityType ) ; validatePackage ( entityType ) ; validateExtends ( entityType ) ; validateOwnAttributes ( entityType ) ; Map < String , Attribute > ownAllAttrMap = stream ( entityType . getOwnAllAttributes ( ) ) . co... | Validates entity meta data | 160 | 5 |
41,180 | void validateBackend ( EntityType entityType ) { // Validate backend exists String backendName = entityType . getBackend ( ) ; if ( ! dataService . getMeta ( ) . hasBackend ( backendName ) ) { throw new MolgenisValidationException ( new ConstraintViolation ( format ( "Unknown backend [%s]" , backendName ) ) ) ; } } | Validate that the entity meta data backend exists | 83 | 9 |
41,181 | static void validateOwnLookupAttributes ( EntityType entityType , Map < String , Attribute > ownAllAttrMap ) { // Validate lookup attributes entityType . getOwnLookupAttributes ( ) . forEach ( ownLookupAttr -> { // Validate that lookup attribute is in the attributes list Attribute ownAttr = ownAllAttrMap . get ( ownLoo... | Validate that the lookup attributes owned by this entity are part of the owned attributes . | 252 | 17 |
41,182 | static void validateOwnLabelAttribute ( EntityType entityType , Map < String , Attribute > ownAllAttrMap ) { // Validate label attribute Attribute ownLabelAttr = entityType . getOwnLabelAttribute ( ) ; if ( ownLabelAttr != null ) { // Validate that label attribute is in the attributes list Attribute ownAttr = ownAllAtt... | Validate that the label attribute owned by this entity is part of the owned attributes . | 253 | 17 |
41,183 | static void validateOwnIdAttribute ( EntityType entityType , Map < String , Attribute > ownAllAttrMap ) { // Validate ID attribute Attribute ownIdAttr = entityType . getOwnIdAttribute ( ) ; if ( ownIdAttr != null ) { // Validate that ID attribute is in the attributes list Attribute ownAttr = ownAllAttrMap . get ( ownId... | Validate that the ID attribute owned by this entity is part of the owned attributes . | 517 | 17 |
41,184 | static void validateExtends ( EntityType entityType ) { EntityType entityTypeExtends = entityType . getExtends ( ) ; if ( entityTypeExtends != null && ! entityTypeExtends . isAbstract ( ) ) { throw new MolgenisValidationException ( new ConstraintViolation ( format ( "EntityType [%s] is not abstract; EntityType [%s] can... | Validates if this entityType extends another entityType . If so checks whether that parent entityType is abstract . | 113 | 22 |
41,185 | void validatePackage ( EntityType entityType ) { Package pack = entityType . getPackage ( ) ; if ( pack != null && isSystemPackage ( pack ) && ! systemEntityTypeRegistry . hasSystemEntityType ( entityType . getId ( ) ) ) { throw new MolgenisValidationException ( new ConstraintViolation ( format ( "Adding entity [%s] to... | Validate that non - system entities are not assigned to a system package | 113 | 14 |
41,186 | void register ( String repoFullName ) { lock . writeLock ( ) . lock ( ) ; try { if ( ! entityListenersByRepo . containsKey ( requireNonNull ( repoFullName ) ) ) { entityListenersByRepo . put ( repoFullName , HashMultimap . create ( ) ) ; } } finally { lock . writeLock ( ) . unlock ( ) ; } } | Register a repository to the entity listeners service once | 86 | 9 |
41,187 | Stream < Entity > updateEntities ( String repoFullName , Stream < Entity > entities ) { lock . readLock ( ) . lock ( ) ; try { verifyRepoRegistered ( repoFullName ) ; SetMultimap < Object , EntityListener > entityListeners = this . entityListenersByRepo . get ( repoFullName ) ; return entities . filter ( entity -> { Se... | Update all registered listeners of the entities | 149 | 7 |
41,188 | void updateEntity ( String repoFullName , Entity entity ) { lock . readLock ( ) . lock ( ) ; try { verifyRepoRegistered ( repoFullName ) ; SetMultimap < Object , EntityListener > entityListeners = this . entityListenersByRepo . get ( repoFullName ) ; Set < EntityListener > entityEntityListeners = entityListeners . get ... | Update all registered listeners of an entity | 128 | 7 |
41,189 | public void addEntityListener ( String repoFullName , EntityListener entityListener ) { lock . writeLock ( ) . lock ( ) ; try { verifyRepoRegistered ( repoFullName ) ; SetMultimap < Object , EntityListener > entityListeners = this . entityListenersByRepo . get ( repoFullName ) ; entityListeners . put ( entityListener .... | Adds an entity listener for a entity of the given class that listens to entity changes | 105 | 16 |
41,190 | public boolean removeEntityListener ( String repoFullName , EntityListener entityListener ) { lock . writeLock ( ) . lock ( ) ; try { verifyRepoRegistered ( repoFullName ) ; SetMultimap < Object , EntityListener > entityListeners = this . entityListenersByRepo . get ( repoFullName ) ; if ( entityListeners . containsKey... | Removes an entity listener for a entity of the given class | 132 | 12 |
41,191 | boolean isEmpty ( String repoFullName ) { lock . readLock ( ) . lock ( ) ; try { verifyRepoRegistered ( repoFullName ) ; return entityListenersByRepo . get ( repoFullName ) . isEmpty ( ) ; } finally { lock . readLock ( ) . unlock ( ) ; } } | Check if a repository has no listeners Repository must be registered | 70 | 12 |
41,192 | private void verifyRepoRegistered ( String repoFullName ) { lock . readLock ( ) . lock ( ) ; try { if ( ! entityListenersByRepo . containsKey ( requireNonNull ( repoFullName ) ) ) { LOG . error ( "Repository [{}] is not registered in the entity listeners service" , repoFullName ) ; throw new MolgenisDataException ( "Re... | Verify that the repository is registered | 123 | 7 |
41,193 | @ Transactional public void populateLocalizationStrings ( AllPropertiesMessageSource source ) { source . getAllMessageIds ( ) . asMap ( ) . forEach ( ( namespace , messageIds ) -> updateNamespace ( source , namespace , ImmutableSet . copyOf ( messageIds ) ) ) ; } | Adds all values in all namespaces from those specified in the property files for that namespace . | 69 | 18 |
41,194 | @ SuppressWarnings ( "squid:S3752" ) // multiple methods required @ RequestMapping ( method = { RequestMethod . GET , RequestMethod . POST } ) public String forwardDefaultMenuDefaultPlugin ( Model model ) { Menu menu = menuReaderService . getMenu ( ) . orElseThrow ( ( ) -> new RuntimeException ( "main menu does not exi... | Forwards to the first plugin of the first menu that the user can read since no menu path is provided . | 248 | 22 |
41,195 | private EntityPermission getPermission ( Action operation ) { EntityPermission result ; switch ( operation ) { case COUNT : case READ : result = EntityPermission . READ ; break ; case UPDATE : result = EntityPermission . UPDATE ; break ; case DELETE : result = EntityPermission . DELETE ; break ; case CREATE : throw new... | Finds out what permission to check for an operation that is being performed on this repository . | 108 | 18 |
41,196 | @ Bean public JobFactory < MappingJobExecution > mappingJobFactory ( ) { return new JobFactory < MappingJobExecution > ( ) { @ Override public Job createJob ( MappingJobExecution mappingJobExecution ) { final String mappingProjectId = mappingJobExecution . getMappingProjectId ( ) ; final String targetEntityTypeId = map... | The MappingJob Factory bean . | 218 | 7 |
41,197 | public static Object convert ( Object source , Attribute attr ) { try { return convert ( source , attr . getDataType ( ) ) ; } catch ( DataConversionException e ) { throw new AttributeValueConversionException ( format ( "Conversion failure in entity type [%s] attribute [%s]; %s" , attr . getEntity ( ) . getId ( ) , att... | Convert value to the type based on the given attribute . | 106 | 12 |
41,198 | @ GetMapping ( value = "/{entityTypeId}/exist" , produces = APPLICATION_JSON_VALUE ) public boolean entityExists ( @ PathVariable ( "entityTypeId" ) String entityTypeId ) { return dataService . hasRepository ( entityTypeId ) ; } | Checks if an entity exists . | 62 | 7 |
41,199 | @ GetMapping ( value = "/{entityTypeId}/meta" , produces = APPLICATION_JSON_VALUE ) public EntityTypeResponse retrieveEntityType ( @ PathVariable ( "entityTypeId" ) String entityTypeId , @ RequestParam ( value = "attributes" , required = false ) String [ ] attributes , @ RequestParam ( value = "expand" , required = fal... | Gets the metadata for an entity | 170 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.