idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
41,000 | public static MortarScope getScope ( Context context ) { //noinspection ResourceType Object scope = context . getSystemService ( MORTAR_SERVICE ) ; if ( scope == null ) { // Essentially a workaround for the lifecycle interval where an Activity's // base context is not yet set to the Application, but the Application // ... | Retrieves a MortarScope from the given context . If none is found retrieves a MortarScope from the application context . | 127 | 27 |
41,001 | public boolean hasService ( String serviceName ) { return serviceName . equals ( MORTAR_SERVICE ) || findService ( serviceName , false ) != null ; } | Returns true if the service associated with the given name is provided by mortar . It is safe to call this method on destroyed scopes . | 36 | 27 |
41,002 | public < T > T getService ( String serviceName ) { T service = findService ( serviceName , true ) ; if ( service == null ) { throw new IllegalArgumentException ( format ( "No service found named \"%s\"" , serviceName ) ) ; } return service ; } | Returns the service associated with the given name . | 62 | 9 |
41,003 | private MortarScope searchFromRoot ( Scoped scoped ) { // Ascend to the root. MortarScope root = this ; while ( root . parent != null ) { root = root . parent ; } // Do the non-recursive search. List < MortarScope > scopes = new LinkedList <> ( ) ; scopes . add ( root ) ; while ( ! scopes . isEmpty ( ) ) { // Check fir... | Find the scope from the root of the hierarchy in which the scoped object is registered . | 173 | 18 |
41,004 | @ SuppressWarnings ( "unchecked" ) // public static < T > T getDaggerComponent ( Context context ) { //noinspection ResourceType return ( T ) context . getSystemService ( SERVICE_NAME ) ; } | Caller is required to know the type of the component for this context . | 50 | 15 |
41,005 | public static < T > T createComponent ( Class < T > componentClass , Object ... dependencies ) { String fqn = componentClass . getName ( ) ; String packageName = componentClass . getPackage ( ) . getName ( ) ; // Accounts for inner classes, ie MyApplication$Component String simpleName = fqn . substring ( packageName . ... | Magic method that creates a component with its dependencies set by reflection . Relies on Dagger2 naming conventions . | 292 | 21 |
41,006 | static final DocumentFragment createContent ( Document doc , String text ) { // [#150] Text might hold XML content, which can be leniently identified by the presence // of either < or & characters (other entities, like >, ", ' are not stricly XML content) if ( text != null && ( text . contains ( "<" ) || text . contain... | Create some content in the context of a given document | 429 | 10 |
41,007 | static final String xpath ( Element element ) { StringBuilder sb = new StringBuilder ( ) ; Node iterator = element ; while ( iterator . getNodeType ( ) == Node . ELEMENT_NODE ) { sb . insert ( 0 , "]" ) ; sb . insert ( 0 , siblingIndex ( ( Element ) iterator ) + 1 ) ; sb . insert ( 0 , "[" ) ; sb . insert ( 0 , ( ( Ele... | Return an XPath expression describing an element | 139 | 8 |
41,008 | static final java . util . Date parseDate ( String formatted ) { if ( formatted == null || formatted . trim ( ) . equals ( "" ) ) return null ; try { DatatypeFactory factory = DatatypeFactory . newInstance ( ) ; XMLGregorianCalendar calendar = factory . newXMLGregorianCalendar ( formatted ) ; return calendar . toGregor... | Parse any date format | 616 | 5 |
41,009 | Client createClient ( ) throws InterruptedException { Client client = retryTemplate . execute ( this :: tryCreateClient ) ; LOG . info ( "Connected to Elasticsearch cluster '{}'." , clusterName ) ; return client ; } | Tries to create a Client connecting to cluster on the given adresses . | 50 | 15 |
41,010 | public Ontology getOntology ( String iri ) { org . molgenis . ontology . core . meta . Ontology ontology = dataService . query ( ONTOLOGY , org . molgenis . ontology . core . meta . Ontology . class ) . eq ( ONTOLOGY_IRI , iri ) . findOne ( ) ; return toOntology ( ontology ) ; } | Retrieves an ontology with a specific IRI . | 86 | 12 |
41,011 | @ SuppressWarnings ( "squid:S2083" ) @ PostMapping ( "/importByUrl" ) @ ResponseBody public ResponseEntity < String > importFileByUrl ( HttpServletRequest request , @ RequestParam ( "url" ) String url , @ RequestParam ( value = "entityTypeId" , required = false ) String entityTypeId , @ RequestParam ( value = "packageI... | Imports entities present in a file from a URL | 340 | 10 |
41,012 | @ PostMapping ( "/importFile" ) public ResponseEntity < String > importFile ( HttpServletRequest request , @ RequestParam ( value = "file" ) MultipartFile file , @ RequestParam ( value = "entityTypeId" , required = false ) String entityTypeId , @ RequestParam ( value = "packageId" , required = false ) String packageId ... | Imports entities present in the submitted file | 359 | 8 |
41,013 | public void populate ( Entity entity ) { stream ( entity . getEntityType ( ) . getAllAttributes ( ) ) . filter ( Attribute :: hasDefaultValue ) . forEach ( attr -> populateDefaultValues ( entity , attr ) ) ; } | Populates an entity with default values | 53 | 7 |
41,014 | private Map < String , String > getEnvironmentAttributes ( ) { Map < String , String > environmentAttributes = new HashMap <> ( ) ; environmentAttributes . put ( ATTRIBUTE_ENVIRONMENT_TYPE , environment ) ; return environmentAttributes ; } | Make sure Spring does not add the attributes as query parameters to the url when doing a redirect . You can do this by introducing an object instead of a string key value pair . | 56 | 35 |
41,015 | public MyEntitiesValidationReport addEntity ( String entityTypeId , boolean importable ) { sheetsImportable . put ( entityTypeId , importable ) ; valid = valid && importable ; if ( importable ) { fieldsImportable . put ( entityTypeId , new ArrayList <> ( ) ) ; fieldsUnknown . put ( entityTypeId , new ArrayList <> ( ) )... | Creates a new report with an entity added to it . | 135 | 12 |
41,016 | public MyEntitiesValidationReport addAttribute ( String attributeName , AttributeState state ) { if ( getImportOrder ( ) . isEmpty ( ) ) { throw new IllegalStateException ( "Must add entity first" ) ; } String entityTypeId = getImportOrder ( ) . get ( getImportOrder ( ) . size ( ) - 1 ) ; valid = valid && state . isVal... | Creates a new report with an attribute added to the last added entity ; | 194 | 15 |
41,017 | private < R > R tryTwice ( Supplier < R > action ) { try { return action . get ( ) ; } catch ( UnknownIndexException e ) { waitForIndexToBeStable ( ) ; try { return action . get ( ) ; } catch ( UnknownIndexException e1 ) { throw new MolgenisDataException ( format ( "Error executing query, index for entity type '%s' wit... | Executes an action on an index that may be unstable . | 125 | 12 |
41,018 | private boolean querySupported ( Query < Entity > q ) { return ! containsAnyOperator ( q , unsupportedOperators ) && ! containsComputedAttribute ( q , getEntityType ( ) ) && ! containsNestedQueryRuleField ( q ) ; } | Checks if the underlying repository can handle this query . Queries with unsupported operators queries that use attributes with computed values or queries with nested query rule field are delegated to the index . | 53 | 36 |
41,019 | private void updateEntityTypeEntityWithNewAttributeEntity ( String entity , String attribute , Entity attributeEntity ) { EntityType entityEntity = dataService . getEntityType ( entity ) ; Iterable < Attribute > attributes = entityEntity . getOwnAllAttributes ( ) ; entityEntity . set ( ATTRIBUTES , stream ( attributes ... | The attribute just got updated but the entity does not know this yet . To reindex this document in elasticsearch update it . | 125 | 25 |
41,020 | public FileMeta ingest ( String entityTypeId , String url , String loader , String jobExecutionID , Progress progress ) { if ( ! "CSV" . equals ( loader ) ) { throw new FileIngestException ( "Unknown loader '" + loader + "'" ) ; } progress . setProgressMax ( 2 ) ; progress . progress ( 0 , "Downloading url '" + url + "... | Imports a csv file defined in the fileIngest entity | 358 | 13 |
41,021 | public static String createId ( Entity vcfEntity ) { String idStr = StringUtils . strip ( vcfEntity . get ( CHROM ) . toString ( ) ) + "_" + StringUtils . strip ( vcfEntity . get ( POS ) . toString ( ) ) + "_" + StringUtils . strip ( vcfEntity . get ( REF ) . toString ( ) ) + "_" + StringUtils . strip ( vcfEntity . get... | Creates a internal molgenis id from a vcf entity | 341 | 13 |
41,022 | private void updateFailedLoginAttempts ( int numberOfAttempts ) { UserSecret userSecret = getSecret ( ) ; userSecret . setFailedLoginAttempts ( numberOfAttempts ) ; if ( userSecret . getFailedLoginAttempts ( ) >= MAX_FAILED_LOGIN_ATTEMPTS ) { if ( ! ( userSecret . getLastFailedAuthentication ( ) != null && ( Instant . ... | Check if user has 3 or more failed login attempts - > then determine if the user is within the 30 seconds of the last failed login attempt - > if the user is not outside the timeframe than the failed login attempts are set to 1 because it is a failed login attempt When the user has less than 3 failed login attempts - >... | 211 | 73 |
41,023 | public CompletableFuture < Void > submit ( JobExecution jobExecution , ExecutorService executorService ) { overwriteJobExecutionUser ( jobExecution ) ; Job molgenisJob = saveExecutionAndCreateJob ( jobExecution ) ; Progress progress = jobExecutionRegistry . registerJobExecution ( jobExecution ) ; CompletableFuture < Vo... | Saves execution in the current thread then creates a Job and submits that for asynchronous execution to a specific ExecutorService . | 177 | 25 |
41,024 | Object executeScript ( String jsScript , Map < String , Object > parameters ) { EntityType entityType = entityTypeFactory . create ( "entity" ) ; Set < String > attributeNames = parameters . keySet ( ) ; attributeNames . forEach ( key -> entityType . addAttribute ( attributeFactory . create ( ) . setName ( key ) ) ) ; ... | Execute a JavaScript using the Magma API | 157 | 9 |
41,025 | public void writeAttributes ( Iterable < Attribute > attributes ) throws IOException { List < String > attributeNames = Lists . newArrayList ( ) ; List < String > attributeLabels = Lists . newArrayList ( ) ; for ( Attribute attr : attributes ) { attributeNames . add ( attr . getName ( ) ) ; if ( attr . getLabel ( ) != ... | Use attribute labels as column names | 132 | 6 |
41,026 | @ GetMapping public String viewMappingProjects ( Model model ) { model . addAttribute ( "mappingProjects" , mappingService . getAllMappingProjects ( ) ) ; model . addAttribute ( "entityTypes" , getWritableEntityTypes ( ) ) ; model . addAttribute ( "user" , getCurrentUsername ( ) ) ; model . addAttribute ( "admin" , cur... | Initializes the model with all mapping projects and all entities to the model . | 137 | 15 |
41,027 | @ PostMapping ( "/addMappingProject" ) public String addMappingProject ( @ RequestParam ( "mapping-project-name" ) String name , @ RequestParam ( "target-entity" ) String targetEntity , @ RequestParam ( "depth" ) int depth ) { MappingProject newMappingProject = mappingService . addMappingProject ( name , targetEntity ,... | Adds a new mapping project . | 118 | 6 |
41,028 | @ PostMapping ( "/removeMappingProject" ) public String deleteMappingProject ( @ RequestParam ( ) String mappingProjectId ) { MappingProject project = mappingService . getMappingProject ( mappingProjectId ) ; LOG . info ( "Deleting mappingProject {}" , project . getName ( ) ) ; mappingService . deleteMappingProject ( m... | Removes a mapping project | 98 | 5 |
41,029 | @ PostMapping ( "/removeAttributeMapping" ) public String removeAttributeMapping ( @ RequestParam ( ) String mappingProjectId , @ RequestParam ( ) String target , @ RequestParam ( ) String source , @ RequestParam ( ) String attribute ) { MappingProject project = mappingService . getMappingProject ( mappingProjectId ) ;... | Removes a attribute mapping | 140 | 5 |
41,030 | @ 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 . ... | Displays a mapping project . | 256 | 6 |
41,031 | void autoGenerateAlgorithms ( EntityMapping mapping , EntityType sourceEntityType , EntityType targetEntityType , MappingProject project ) { algorithmService . autoGenerateAlgorithm ( sourceEntityType , targetEntityType , mapping ) ; mappingService . updateMappingProject ( project ) ; } | Generate algorithms based on semantic matches between attribute tags and descriptions | 63 | 12 |
41,032 | private List < EntityType > getNewSources ( MappingTarget target ) { return dataService . getEntityTypeIds ( ) . filter ( name -> isValidSource ( target , name ) ) . map ( dataService :: getEntityType ) . collect ( toList ( ) ) ; } | Lists the entities that may be added as new sources to this mapping project s selected target | 61 | 18 |
41,033 | @ 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 ( ... | Serves the Swagger UI which allows you to try out the documented endpoints . Sets the url parameter to the swagger yaml that describes the REST API . Creates an apiKey token for the current user . | 166 | 44 |
41,034 | @ 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 ( ) .... | Serves the Swagger description of the REST API . As host fills in the host where the controller lives . As options for the entity names contains only those entity names that the user can actually see . | 287 | 40 |
41,035 | public static String getLanguageCode ( String name ) { if ( ! isI18n ( name ) ) return null ; return name . substring ( name . indexOf ( ' ' ) + 1 , name . length ( ) ) ; } | Get the language code of a new with language suffix . | 50 | 11 |
41,036 | 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 Python has e... | Execute a python script and wait for it to finish | 542 | 11 |
41,037 | 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 . contain... | Creates a new entity based from a HttpServletRequest . For file attributes persists the file in the file store and persist a file meta data entity . | 176 | 32 |
41,038 | 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 ) { case BOOL : va... | Converts a HTTP request parameter to a entity value of which the type is defined by the attribute . For file attributes persists the file in the file store and persist a file meta data entity . | 353 | 38 |
41,039 | 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 ) ; } } | Loads JSON schema . The schema may contain remote references . | 70 | 12 |
41,040 | public void validate ( String json , String schemaJson ) { Schema schema = loadSchema ( schemaJson ) ; validate ( json , schema ) ; } | Validates that a JSON string conforms to a JSON schema . | 34 | 13 |
41,041 | 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 , Scor... | Wraps the query in a nested query when a query is done on a reference entity . Returns the original query when it is applied to the current entity . | 111 | 31 |
41,042 | 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 ) ) , encodePathSegment ( a... | Create an encoded href for an attribute | 91 | 7 |
41,043 | public static String concatMetaAttributeHref ( String baseUri , String entityParentName , String attributeName ) { return String . format ( "%s/%s/meta/%s" , baseUri , encodePathSegment ( entityParentName ) , encodePathSegment ( attributeName ) ) ; } | Create an encoded href for an attribute meta | 67 | 8 |
41,044 | public static String concatEntityHref ( String baseUri , String qualifiedEntityName , Object entityIdValue ) { if ( null == qualifiedEntityName ) { qualifiedEntityName = "" ; } return String . format ( "%s/%s/%s" , baseUri , encodePathSegment ( qualifiedEntityName ) , encodePathSegment ( DataConverter . toString ( enti... | Create an encoded href for an entity | 91 | 7 |
41,045 | public static String concatMetaEntityHref ( String baseUri , String qualifiedEntityName ) { return String . format ( "%s/%s/meta" , baseUri , encodePathSegment ( qualifiedEntityName ) ) ; } | Create an encoded href for an entity meta | 51 | 8 |
41,046 | 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 ( "%s/%s?q=%s... | Create an encoded href for an entity collection | 126 | 8 |
41,047 | @ 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 ( ) ) ) { try ( Xl... | Isolation level needs to be SERIALIZABLE in case IndexActions are being downloaded . The entities have their own transaction and can change during the download when executed with a default isolation level . | 174 | 39 |
41,048 | 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... | package private for test | 121 | 4 |
41,049 | 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_SEPARATOR )... | Returns the attribute for a query rule field . | 208 | 9 |
41,050 | 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 ( entityType . getOwnAll... | Returns dependencies of the given entity meta data . | 178 | 9 |
41,051 | private static Set < EntityTypeNode > expandEntityTypeDependencies ( EntityTypeNode entityTypeNode ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "expandEntityTypeDependencies(EntityTypeNode entityTypeNode) --- entity: [{}], skip: [{}]" , entityTypeNode . getEntityType ( ) . getId ( ) , entityTypeNode . isSkip ( )... | Returns whole tree dependencies of the given entity meta data . | 389 | 11 |
41,052 | private boolean hasAuthenticatedMolgenisToken ( ) { boolean hasAuthenticatedMolgenisToken = false ; Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication instanceof RestAuthenticationToken ) { hasAuthenticatedMolgenisToken = authentication . isAuthenticated... | Check on authenticated RestAuthenticationToken | 84 | 7 |
41,053 | 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 . getOw... | Deep copy all attributes of an EntityType to its copy . Returns a LinkedMap of the old attribute IDs to the newly copied Attributes . | 298 | 28 |
41,054 | public String getLabel ( String languageCode ) { String i18nLabel = getString ( getI18nAttributeName ( LABEL , languageCode ) ) ; return i18nLabel != null ? i18nLabel : getLabel ( ) ; } | Label of the entity in the requested language | 54 | 8 |
41,055 | @ Nullable @ CheckForNull public String getDescription ( String languageCode ) { String i18nDescription = getString ( getI18nAttributeName ( DESCRIPTION , languageCode ) ) ; return i18nDescription != null ? i18nDescription : getDescription ( ) ; } | Description of the entity in the requested language | 60 | 8 |
41,056 | public Attribute getIdAttribute ( ) { Attribute idAttr = getOwnIdAttribute ( ) ; if ( idAttr == null ) { EntityType extend = getExtends ( ) ; if ( extend != null ) { idAttr = extend . getIdAttribute ( ) ; } } return idAttr ; } | Attribute that is used as unique Id . Id attribute should always be provided . | 68 | 15 |
41,057 | public Attribute getLabelAttribute ( ) { Attribute labelAttr = getOwnLabelAttribute ( ) ; if ( labelAttr == null ) { EntityType extend = getExtends ( ) ; if ( extend != null ) { labelAttr = extend . getLabelAttribute ( ) ; } } return labelAttr ; } | Attribute that is used as unique label . If no label exist returns null . | 68 | 15 |
41,058 | public Attribute getLabelAttribute ( String langCode ) { Attribute labelAttr = getLabelAttribute ( ) ; Attribute i18nLabelAttr = labelAttr != null ? getAttribute ( labelAttr . getName ( ) + ' ' + langCode ) : null ; return i18nLabelAttr != null ? i18nLabelAttr : labelAttr ; } | Gets the correct label attribute for the given language or the default if not found | 82 | 16 |
41,059 | 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 ) ; } } return... | Get attribute by name | 91 | 4 |
41,060 | 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 ) . max ( ) . orElse ( - 1 ) ... | Add a sequence number to the attribute . If the sequence number exists add it ot the attribute . If the sequence number does not exists then find the highest sequence number . If Entity has not attributes with sequence numbers put 0 . | 126 | 44 |
41,061 | public void initialize ( ContextRefreshedEvent event ) { ApplicationContext ctx = event . getApplicationContext ( ) ; Stream < String > languageCodes = LanguageService . getLanguageCodes ( ) ; EntityTypeMetadata entityTypeMeta = ctx . getBean ( EntityTypeMetadata . class ) ; AttributeMetadata attrMetaMeta = ctx . getBe... | Initialize internationalization attributes | 376 | 5 |
41,062 | 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 &... | Populates an entity with auto values | 130 | 7 |
41,063 | public void populateL10nStrings ( ) { AllPropertiesMessageSource allPropertiesMessageSource = new AllPropertiesMessageSource ( ) ; String [ ] namespaces = localizationMessageSources . stream ( ) . map ( PropertiesMessageSource :: getNamespace ) . toArray ( String [ ] :: new ) ; allPropertiesMessageSource . addMolgenisN... | Populates dataService with localization strings from property files on the classpath . | 102 | 15 |
41,064 | 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 Locale ( "nl" ) ) , fal... | Populate data store with default languages | 359 | 7 |
41,065 | 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 ( ) ) ; } | Resolved boolean expressions | 79 | 4 |
41,066 | @ 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 ) throw... | Add a new bootstrap theme theme is passed as a bootstrap css file . It is mandatory to pass a bootstrap3 style file but optional to pass a bootstrap 4 style file | 334 | 38 |
41,067 | 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 ( ... | Unzips a zipfile into the directory it resides in . | 104 | 13 |
41,068 | 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 > stemmedWo... | create n - grams tokens of the string . | 347 | 9 |
41,069 | 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 ( ontology... | Calculate the ngram distance | 194 | 7 |
41,070 | public void addListener ( SettingsEntityListener settingsEntityListener ) { RunAsSystemAspect . runAsSystem ( ( ) -> entityListenersService . addEntityListener ( entityTypeId , new EntityListener ( ) { @ Override public void postUpdate ( Entity entity ) { settingsEntityListener . postUpdate ( entity ) ; } @ Override pu... | Adds a listener for this settings entity that fires on entity updates | 97 | 12 |
41,071 | public void removeListener ( SettingsEntityListener settingsEntityListener ) { RunAsSystemAspect . runAsSystem ( ( ) -> entityListenersService . removeEntityListener ( entityTypeId , new EntityListener ( ) { @ Override public void postUpdate ( Entity entity ) { settingsEntityListener . postUpdate ( entity ) ; } @ Overr... | Removes a listener for this settings entity that fires on entity updates | 97 | 13 |
41,072 | @ 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 = sheet . createRow ( r... | Add a new row to the sheet | 145 | 7 |
41,073 | 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" ) ; ... | Write sheet column headers | 245 | 4 |
41,074 | 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_SYSTEM , codeSystemIRI ) . findOne ( ) ; if ( tag == ... | Fetches a tag from the repository . Creates a new one if it does not yet exist . | 206 | 21 |
41,075 | 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 ( "Pop... | Returns whether the database was populated previously . | 414 | 8 |
41,076 | public void validate ( Query < ? extends Entity > query , EntityType entityType ) { query . getRules ( ) . forEach ( queryRule -> validateQueryRule ( queryRule , entityType ) ) ; } | Validates query based on the given entity type converts query values to the expected type if necessary . | 44 | 19 |
41,077 | public void setValue ( Object value ) { if ( value instanceof Iterable < ? > ) { this . value = stream ( ( Iterable < ? > ) value ) . map ( this :: toValue ) . collect ( toList ( ) ) ; } else { this . value = toValue ( value ) ; } } | Sets a new value for this rule . | 68 | 9 |
41,078 | 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 ( ... | This method is able to recursively collect all the matched words from Elasticsearch Explanation document | 324 | 19 |
41,079 | 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... | This method is able to find the queries that are used in the matching . Only queries that contain all matched words are potential queries . | 167 | 26 |
41,080 | @ 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 ( ... | Serves feedback form . | 192 | 5 |
41,081 | @ 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 . hasEma... | Creates a MimeMessage based on a FeedbackForm . | 227 | 12 |
41,082 | 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 (... | Formats a MolgenisUser s name . | 168 | 10 |
41,083 | private byte [ ] generateRandomBytes ( int nBytes , Random random ) { byte [ ] randomBytes = new byte [ nBytes ] ; random . nextBytes ( randomBytes ) ; return randomBytes ; } | Generates a number of random bytes . | 43 | 8 |
41,084 | 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 ScheduledJo... | Remove a job from the quartzScheduler | 99 | 9 |
41,085 | 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 . getName ( ) , mappedByAttr . getDataType ( ) ) ... | Validate whether the mappedBy attribute is part of the referenced entity . | 192 | 14 |
41,086 | 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 ( refAttrName ) == null... | Validate whether the attribute names defined by the orderBy attribute point to existing attributes in the referenced entity . | 186 | 21 |
41,087 | public ImportService getImportService ( File file , RepositoryCollection source ) { final Map < String , ImportService > importServicesMappedToExtensions = Maps . newHashMap ( ) ; importServices . stream ( ) . filter ( importService -> importService . canImport ( file , source ) ) . forEach ( importService -> { for ( S... | Finds a suitable ImportService for a FileRepositoryCollection . | 205 | 13 |
41,088 | 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 ) { stringB... | Remove illegal characters from the string and stem each single word | 111 | 11 |
41,089 | private String constructNodePath ( String parentNodePath , int currentPosition ) { StringBuilder nodePathStringBuilder = new StringBuilder ( ) ; if ( ! StringUtils . isEmpty ( parentNodePath ) ) nodePathStringBuilder . append ( parentNodePath ) . append ( ' ' ) ; nodePathStringBuilder . append ( currentPosition ) . app... | Constructs the node path string for a child node | 121 | 10 |
41,090 | 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 attributes re... | Convert a string value to a typed value based on a non - entity - referencing attribute data type . | 99 | 21 |
41,091 | 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 = attr . getRefEntity ( )... | Convert a string value to a typed value based on the attribute data type . | 542 | 16 |
41,092 | 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 ... | Returns true if an Iterable equals another Iterable . | 132 | 11 |
41,093 | public List < String > getEnumOptions ( ) { String enumOptionsStr = getString ( ENUM_OPTIONS ) ; return enumOptionsStr != null ? asList ( enumOptionsStr . split ( "," ) ) : emptyList ( ) ; } | For enum fields returns the possible enum values | 55 | 8 |
41,094 | 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 ( attr .... | For a reference type attribute searches the referenced entity for its inversed attribute . This is the one - to - many attribute that has mappedBy set to this attribute . Returns null if this is not a reference type attribute or no inverse attribute exists . | 125 | 50 |
41,095 | public void grantDefaultPermissions ( GroupValue groupValue ) { PackageIdentity packageIdentity = new PackageIdentity ( groupValue . getRootPackage ( ) . getName ( ) ) ; GroupIdentity groupIdentity = new GroupIdentity ( groupValue . getName ( ) ) ; aclService . createAcl ( groupIdentity ) ; groupValue . getRoles ( ) . ... | Grants default permissions on the root package and group to the roles of the group | 212 | 16 |
41,096 | public Fetch field ( String field , Fetch fetch ) { attrFetchMap . put ( field , fetch ) ; return this ; } | Updates this fetch adding a single field . If the field is a reference the reference will be fetched with the Fetch that is provided . | 30 | 29 |
41,097 | 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 ( ) ) { allTr... | Get readable genome entities | 147 | 4 |
41,098 | 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 ... | Retrieves an entity from the cache or the underlying repository . | 87 | 13 |
41,099 | 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 , repository . getEntityType ( ) ... | Retrieves a list of entities from the cache . If the cache doesn t yet exist will create the cache . | 151 | 23 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.