idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
41,200 | 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 |
41,201 | 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 . |
41,202 | 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 . |
41,203 | private void updateColumn ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { if ( ! Objects . equals ( attr . isNillable ( ) , updatedAttr . isNillable ( ) ) ) { updateNillable ( entityType , attr , updatedAttr ) ; } if ( ! Objects . equals ( attr . isUnique ( ) , updatedAttr . isUnique ( ) ) ) { upda... | Updates database column based on attribute changes . |
41,204 | 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 . |
41,205 | private void updateEnumOptions ( EntityType entityType , Attribute attr , Attribute updatedAttr ) { if ( attr . getDataType ( ) == ENUM ) { if ( updatedAttr . getDataType ( ) == ENUM ) { dropCheckConstraint ( entityType , attr ) ; createCheckConstraint ( entityType , updatedAttr ) ; } else { dropCheckConstraint ( entit... | Updates check constraint based on enum value changes . |
41,206 | 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 . |
41,207 | 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 . |
41,208 | 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 . |
41,209 | private void registerRefEntityIndexActions ( ) { getEntityType ( ) . getMappedByAttributes ( ) . forEach ( mappedByAttr -> { EntityType refEntity = mappedByAttr . getRefEntity ( ) ; indexActionRegisterService . register ( refEntity , null ) ; } ) ; getEntityType ( ) . getInversedByAttributes ( ) . forEach ( inversedByA... | Register index actions for entity types with bidirectional attribute values . |
41,210 | private void registerRefEntityIndexActions ( Entity entity ) { getEntityType ( ) . getMappedByAttributes ( ) . forEach ( mappedByAttr -> { EntityType mappedByAttrRefEntity = mappedByAttr . getRefEntity ( ) ; entity . getEntities ( mappedByAttr . getName ( ) ) . forEach ( refEntity -> indexActionRegisterService . regist... | Register index actions for the given entity for entity types with bidirectional attribute values . |
41,211 | 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 . |
41,212 | 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 . |
41,213 | 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 . |
41,214 | private void convertIdtoLabelLabels ( List < Object > idLabels , EntityType entityType , DataService dataService ) { final int nrLabels = idLabels . size ( ) ; if ( nrLabels > 0 ) { Stream < Object > idLabelsWithoutNull = idLabels . stream ( ) . filter ( Objects :: nonNull ) . map ( untypedIdLabel -> EntityUtils . getT... | Convert matrix labels that contain ids to label attribute values . Keeps in mind that the last label on a axis is Total . |
41,215 | public static String getCurrentUsername ( ) { Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication == null ) { return null ; } return getUsername ( authentication ) ; } | Returns the username of the current authentication . |
41,216 | 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 |
41,217 | 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 |
41,218 | public Entity findOneById ( Object id ) { if ( cacheable && ! transactionInformation . isEntireRepositoryDirty ( getEntityType ( ) ) && ! transactionInformation . isEntityDirty ( EntityKey . create ( getEntityType ( ) , id ) ) ) { return l2Cache . get ( delegate ( ) , id ) ; } return delegate ( ) . findOneById ( id ) ;... | Retrieves a single entity by id . |
41,219 | 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 . |
41,220 | 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 . |
41,221 | 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 . |
41,222 | 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 . |
41,223 | 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 |
41,224 | 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 |
41,225 | 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 |
41,226 | public JobFactory < ScriptJobExecution > scriptJobFactory ( ) { return new JobFactory < ScriptJobExecution > ( ) { public Job < ScriptResult > createJob ( ScriptJobExecution scriptJobExecution ) { final String name = scriptJobExecution . getName ( ) ; final String parameterString = scriptJobExecution . getParameters ( ... | The Script JobFactory bean . |
41,227 | @ 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 |
41,228 | public Stream < EntityType > getCompatibleEntityTypes ( EntityType target ) { return dataService . getMeta ( ) . getEntityTypes ( ) . filter ( candidate -> ! candidate . isAbstract ( ) ) . filter ( isCompatible ( target ) ) ; } | Public for testability |
41,229 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.