idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
35,000 | public static CharSequence truncate ( CharSequence s , int len ) { if ( s . length ( ) == len ) return ( s ) ; if ( s . length ( ) > len ) return ( s . subSequence ( 0 , len ) ) ; StringBuilder result = new StringBuilder ( s ) ; while ( result . length ( ) < len ) result . append ( ' ' ) ; return ( result ) ; } | Returns a string of the given length fills with spaces if necessary |
35,001 | public static String capitalize ( String s ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( i == 0 || i > 0 && ! Character . isLetterOrDigit ( s . charAt ( i - 1 ) ) ) c = Character . toUpperCase ( c ) ; else c = Character . toLowerCase ... | Capitalizes words and lowercases the rest |
35,002 | public static boolean endsWith ( CharSequence s , String end ) { return ( s . length ( ) >= end . length ( ) && s . subSequence ( s . length ( ) - end . length ( ) , s . length ( ) ) . equals ( end ) ) ; } | TRUE if the Charsequence ends with the string |
35,003 | public static StructrOAuthClient getServer ( final String name ) { String configuredOauthServers = Settings . OAuthServers . getValue ( ) ; String [ ] authServers = configuredOauthServers . split ( " " ) ; for ( String authServer : authServers ) { if ( authServer . equals ( name ) ) { String authLocation = Settings . g... | Build an OAuth2 server from the configured values for the given name . |
35,004 | public static < T extends File > T transformFile ( final SecurityContext securityContext , final String uuid , final Class < T > fileType ) throws FrameworkException , IOException { AbstractFile existingFile = getFileByUuid ( securityContext , uuid ) ; if ( existingFile != null ) { existingFile . unlockSystemProperties... | Transform an existing file into the target class . |
35,005 | public static < T extends File > T createFileBase64 ( final SecurityContext securityContext , final String rawData , final Class < T > t ) throws FrameworkException , IOException { Base64URIData uriData = new Base64URIData ( rawData ) ; return createFile ( securityContext , uriData . getBinaryData ( ) , uriData . getCo... | Create a new image node from image data encoded in base64 format . |
35,006 | public static < T extends File > T createFile ( final SecurityContext securityContext , final InputStream fileStream , final String contentType , final Class < T > fileType , final String name ) throws FrameworkException , IOException { return createFile ( securityContext , fileStream , contentType , fileType , name , ... | Create a new file node from the given input stream |
35,007 | public static void decodeAndSetFileData ( final File file , final String rawData ) throws FrameworkException , IOException { Base64URIData uriData = new Base64URIData ( rawData ) ; setFileData ( file , uriData . getBinaryData ( ) , uriData . getContentType ( ) , true ) ; } | Decodes base64 - encoded raw data into binary data and writes it to the given file . |
35,008 | public static void setFileData ( final File file , final InputStream fileStream , final String contentType ) throws FrameworkException , IOException { FileHelper . writeToFile ( file , fileStream ) ; setFileProperties ( file , contentType ) ; } | Write image data from the given InputStream to the given file node and set checksum and size . |
35,009 | public static void setFileProperties ( final File file , final String contentType ) throws IOException , FrameworkException { final java . io . File fileOnDisk = file . getFileOnDisk ( false ) ; final PropertyMap map = new PropertyMap ( ) ; map . put ( StructrApp . key ( File . class , "contentType" ) , contentType != ... | Set the contentType checksum size and version properties of the given fileNode |
35,010 | public static void setFileProperties ( File fileNode ) throws FrameworkException { final PropertyMap properties = new PropertyMap ( ) ; String id = fileNode . getProperty ( GraphObject . id ) ; if ( id == null ) { final String newUuid = UUID . randomUUID ( ) . toString ( ) . replaceAll ( "[\\-]+" , "" ) ; id = newUuid ... | Set the uuid and the path of a newly created fileNode |
35,011 | private static PropertyMap getChecksums ( final File file , final java . io . File fileOnDisk ) throws IOException { final PropertyMap propertiesWithChecksums = new PropertyMap ( ) ; Folder parentFolder = file . getParent ( ) ; String checksums = null ; while ( parentFolder != null && checksums == null ) { checksums = ... | Calculate checksums that are configured in settings of parent folder . |
35,012 | public static void updateMetadata ( final File file , final PropertyMap map ) throws FrameworkException { updateMetadata ( file , map , false ) ; } | Update checksums content type size and additional properties of the given file |
35,013 | public static void writeToFile ( final File fileNode , final InputStream data ) throws FrameworkException , IOException { setFileProperties ( fileNode ) ; try ( final FileOutputStream out = new FileOutputStream ( fileNode . getFileOnDisk ( ) ) ) { IOUtils . copy ( data , out ) ; } } | Write binary data from FileInputStream to a file and reference the file on disk at the given file node |
35,014 | public static AbstractFile getFileByAbsolutePath ( final SecurityContext securityContext , final String absolutePath ) { try { return StructrApp . getInstance ( securityContext ) . nodeQuery ( AbstractFile . class ) . and ( StructrApp . key ( AbstractFile . class , "path" ) , absolutePath ) . getFirst ( ) ; } catch ( F... | Find a file by its absolute ancestor path . |
35,015 | public static Folder createFolderPath ( final SecurityContext securityContext , final String path ) throws FrameworkException { final App app = StructrApp . getInstance ( securityContext ) ; if ( path == null ) { return null ; } Folder folder = ( Folder ) FileHelper . getFileByAbsolutePath ( securityContext , path ) ; ... | Create one folder per path item and return the last folder . |
35,016 | public static boolean noLatin ( String s ) { return ( s . indexOf ( 'h' ) > 0 || s . indexOf ( 'j' ) > 0 || s . indexOf ( 'k' ) > 0 || s . indexOf ( 'w' ) > 0 || s . indexOf ( 'y' ) > 0 || s . indexOf ( 'z' ) > 0 || s . indexOf ( "ou" ) > 0 || s . indexOf ( "sh" ) > 0 || s . indexOf ( "ch" ) > 0 || s . endsWith ( "aus"... | Returns true if a word is probably not Latin |
35,017 | public void updateChangeLog ( final Principal user , final Verb verb , final PropertyKey key , final Object previousValue , final Object newValue ) { if ( ( Settings . ChangelogEnabled . getValue ( ) || Settings . UserChangelogEnabled . getValue ( ) ) && key != null ) { final String name = key . jsonName ( ) ; if ( ! h... | Update changelog for Verb . change |
35,018 | public void updateChangeLog ( final Principal user , final Verb verb , final String object ) { if ( ( Settings . ChangelogEnabled . getValue ( ) || Settings . UserChangelogEnabled . getValue ( ) ) ) { final JsonObject obj = new JsonObject ( ) ; obj . add ( "time" , toElement ( System . currentTimeMillis ( ) ) ) ; if ( ... | Update changelog for Verb . create and Verb . delete |
35,019 | public Comparable convertForSorting ( S source ) throws FrameworkException { if ( source != null ) { if ( source instanceof Comparable ) { return ( Comparable ) source ; } return source . toString ( ) ; } return null ; } | Convert from source type to Comparable to allow a more fine - grained control over the sorted results . Override this method to modify sorting behaviour of entities . |
35,020 | public ClassLoader getClassLoader ( final Location location ) { return new SecureClassLoader ( ) { protected Class < ? > findClass ( String name ) throws ClassNotFoundException { final JavaClassObject obj = objects . get ( name ) ; if ( obj != null ) { byte [ ] b = obj . getBytes ( ) ; return super . defineClass ( name... | Will be used by us to get the class loader for our compiled class . It creates an anonymous class extending the SecureClassLoader which uses the byte code created by the compiler and stored in the JavaClassObject and returns the Class for it |
35,021 | public JavaFileObject getJavaFileForOutput ( final Location location , final String className , final Kind kind , final FileObject sibling ) throws IOException { JavaClassObject obj = new JavaClassObject ( className , kind ) ; objects . put ( className , obj ) ; return obj ; } | Gives the compiler an instance of the JavaClassObject so that the compiler can write the byte code into it . |
35,022 | public boolean startJob ( final Long jobId ) { final ScheduledJob job = removeFromQueueInternal ( jobId ) ; if ( job != null ) { activeJobs . put ( jobId , job ) ; job . startJob ( ) ; return true ; } else { return false ; } } | Starts an import job if it exists . Returns true if it is started . |
35,023 | private List < Class < ? extends RelationshipInterface > > getRelationClassCandidatesForRelType ( final String relType ) { List < Class < ? extends RelationshipInterface > > candidates = new ArrayList ( ) ; for ( final Class < ? extends RelationshipInterface > candidate : getRelationshipEntities ( ) . values ( ) ) { Re... | Return a list of all relation entity classes filtered by relationship type . |
35,024 | private Class findNearestMatchingRelationClass ( final String sourceTypeName , final String relType , final String targetTypeName ) { final Class sourceType = getNodeEntityClass ( sourceTypeName ) ; final Class targetType = getNodeEntityClass ( targetTypeName ) ; final Map < Integer , Class > candidates = new TreeMap <... | Find the most specialized relation class matching the given parameters . |
35,025 | public void registerEntityCreationTransformation ( Class type , Transformation < GraphObject > transformation ) { final Set < Transformation < GraphObject > > transformations = getEntityCreationTransformationsForType ( type ) ; if ( ! transformations . contains ( transformation ) ) { transformations . add ( transformat... | Register a transformation that will be applied to every newly created entity of a given type . |
35,026 | public void registerPropertyGroup ( Class type , PropertyKey key , PropertyGroup propertyGroup ) { getPropertyGroupMapForType ( type ) . put ( key . dbName ( ) , propertyGroup ) ; } | Registers a property group for the given key of the given entity type . A property group can be used to combine a set of properties into an object . |
35,027 | private Set < String > getResourcesToScan ( ) { final String classPath = System . getProperty ( "java.class.path" ) ; final Set < String > modules = new TreeSet < > ( ) ; final Pattern pattern = Pattern . compile ( ".*(structr).*(war|jar)" ) ; final Matcher matcher = pattern . matcher ( "" ) ; for ( final String jarPat... | Scans the class path and returns a Set containing all structr modules . |
35,028 | private void unzip ( final File file , final String outputDir ) throws IOException { try ( final ZipFile zipFile = new ZipFile ( file ) ) { final Enumeration < ? extends ZipEntry > entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { final ZipEntry entry = entries . nextElement ( ) ; final File t... | Unzip given file to given output directory . |
35,029 | public static List < Resource > parsePath ( final SecurityContext securityContext , final HttpServletRequest request , final Map < Pattern , Class < ? extends Resource > > resourceMap , final Value < String > propertyView ) throws FrameworkException { final String path = request . getPathInfo ( ) ; if ( StringUtils . i... | Parse the request path and match with possible resource patterns |
35,030 | public static Resource optimizeNestedResourceChain ( final SecurityContext securityContext , final HttpServletRequest request , final Map < Pattern , Class < ? extends Resource > > resourceMap , final Value < String > propertyView ) throws FrameworkException { final List < Resource > resourceChain = ResourceHelper . pa... | Optimize the resource chain by trying to combine two resources to a new one |
35,031 | protected void logException ( final Object caller , final Throwable t , final Object [ ] parameters ) { logException ( t , "{}: Exception in '{}' for parameters: {}" , new Object [ ] { getReplacement ( ) , caller , getParametersAsString ( parameters ) } ) ; } | Logging of an Exception in a function with a simple message outputting the name and call parameters of the function |
35,032 | protected void logException ( final Throwable t , final String msg , final Object [ ] messageParams ) { logger . error ( msg , messageParams , t ) ; } | Logging of an Exception in a function with custom message and message parameters . |
35,033 | protected void assertArrayHasLengthAndAllElementsNotNull ( final Object [ ] array , final Integer length ) throws ArgumentCountException , ArgumentNullException { if ( array . length != length ) { throw ArgumentCountException . notEqual ( array . length , length ) ; } for ( final Object element : array ) { if ( element... | Test if the given object array has exact the given length and all its elements are not null . |
35,034 | public static Location createLocation ( final GeoCodingResult coords ) throws FrameworkException { final PropertyMap props = new PropertyMap ( ) ; double latitude = coords . getLatitude ( ) ; double longitude = coords . getLongitude ( ) ; String type = Location . class . getSimpleName ( ) ; props . put ( AbstractNode .... | Creates a Location entity for the given geocoding result and returns it . |
35,035 | public static GeoCodingResult geocode ( final String street , final String house , String postalCode , final String city , final String state , final String country ) throws FrameworkException { final String language = Settings . GeocodingLanguage . getValue ( ) ; final String cacheKey = cacheKey ( street , house , pos... | Tries do find a geo location for the given address using the GeoCodingProvider specified in the configuration file . |
35,036 | public static boolean isConfirmationKeyValid ( final String confirmationKey , final Integer validityPeriod ) { final String [ ] parts = confirmationKey . split ( "!" ) ; if ( parts . length == 2 ) { final long confirmationKeyCreated = Long . parseLong ( parts [ 1 ] ) ; final long maxValidity = confirmationKeyCreated + ... | Determines if the key is valid or not . If the key has no timestamp the configuration setting for keys without timestamp is used |
35,037 | public static void writeCsv ( final ResultStream < GraphObject > result , final Writer out , final String propertyView ) throws IOException { final StringBuilder row = new StringBuilder ( ) ; boolean headerWritten = false ; for ( final GraphObject obj : result ) { if ( ! headerWritten ) { row . setLength ( 0 ) ; for ( ... | Write list of objects to output |
35,038 | public void init ( SecurityContext securityContext , Node dbNode , Class type , final long transactionId ) { throw new UnsupportedOperationException ( "Not supported by this container." ) ; } | dummy implementation of NodeInterface |
35,039 | private File extractFileAttachment ( final Mailbox mb , final Part p ) { File file = null ; try { final Class fileClass = p . getContentType ( ) . toLowerCase ( ) . startsWith ( "image/" ) ? Image . class : File . class ; final App app = StructrApp . getInstance ( ) ; try ( final Tx tx = app . tx ( ) ) { org . structr ... | Returns attachment UUID to append to the mail to be created |
35,040 | public void setSecurityContext ( final SecurityContext sc ) { if ( securityContext == null ) { if ( sc . isSuperUserSecurityContext ( ) == Boolean . FALSE ) { securityContext = sc ; } } } | Allow setting the securityContext if it was null . Important for Login transactions . |
35,041 | private long findInterval ( final String dateFormat ) { final long max = TimeUnit . DAYS . toMillis ( 365 ) ; final long step = TimeUnit . SECONDS . toMillis ( 60 ) ; try { final SimpleDateFormat format = new SimpleDateFormat ( dateFormat ) ; final long initial = format . parse ( format . format ( 3600 ) ) . getTime ( ... | This method takes a date format and finds the time interval that it represents . |
35,042 | public Locale getEffectiveLocale ( ) { Locale locale = Locale . getDefault ( ) ; boolean userHasLocaleString = false ; if ( cachedUser != null ) { final String userLocaleString = cachedUser . getLocale ( ) ; if ( userLocaleString != null ) { userHasLocaleString = true ; try { locale = LocaleUtils . toLocale ( userLocal... | Determine the effective locale for this request . |
35,043 | public final void setArgument ( final String key , final Object value ) { if ( key != null && value != null ) { this . arguments . put ( key , value ) ; } } | Sets an argument for this command . |
35,044 | public static String getHash ( final String password , final String salt ) { if ( StringUtils . isEmpty ( salt ) ) { return getSimpleHash ( password ) ; } return DigestUtils . sha512Hex ( DigestUtils . sha512Hex ( password ) . concat ( salt ) ) ; } | Calculate a SHA - 512 hash of the given password string . |
35,045 | private Page notFound ( final HttpServletResponse response , final SecurityContext securityContext ) throws IOException , FrameworkException { final List < Page > errorPages = StructrApp . getInstance ( securityContext ) . nodeQuery ( Page . class ) . and ( StructrApp . key ( Page . class , "showOnErrorCodes" ) , "404"... | Handle 404 Not Found |
35,046 | private AbstractNode findFirstNodeByName ( final SecurityContext securityContext , final HttpServletRequest request , final String path ) throws FrameworkException { final String name = PathHelper . getName ( path ) ; if ( ! name . isEmpty ( ) ) { logger . debug ( "Requested name: {}" , name ) ; final Query query = Str... | Find first node whose name matches the last part of the given path |
35,047 | private AbstractNode findNodeByUuid ( final SecurityContext securityContext , final String uuid ) throws FrameworkException { if ( ! uuid . isEmpty ( ) ) { logger . debug ( "Requested id: {}" , uuid ) ; return ( AbstractNode ) StructrApp . getInstance ( securityContext ) . getNodeById ( uuid ) ; } return null ; } | Find node by uuid |
35,048 | private File findFile ( final SecurityContext securityContext , final HttpServletRequest request , final String path ) throws FrameworkException { List < Linkable > entryPoints = findPossibleEntryPoints ( securityContext , request , path ) ; if ( entryPoints . isEmpty ( ) ) { entryPoints = findPossibleEntryPoints ( sec... | Find a file with its name matching last path part |
35,049 | private Page findPage ( final SecurityContext securityContext , List < Page > pages , final String path , final EditMode edit ) throws FrameworkException { if ( pages == null ) { pages = StructrApp . getInstance ( securityContext ) . nodeQuery ( Page . class ) . getAsList ( ) ; Collections . sort ( pages , new GraphObj... | Find a page with matching path . |
35,050 | private Page findIndexPage ( final SecurityContext securityContext , List < Page > pages , final EditMode edit ) throws FrameworkException { final PropertyKey < Integer > positionKey = StructrApp . key ( Page . class , "position" ) ; if ( pages == null ) { pages = StructrApp . getInstance ( securityContext ) . nodeQuer... | Find the page with the lowest non - empty position value which is visible in the current security context and for the given site . |
35,051 | private boolean checkRegistration ( final Authenticator auth , final HttpServletRequest request , final HttpServletResponse response , final String path ) throws FrameworkException , IOException { logger . debug ( "Checking registration ..." ) ; final String key = request . getParameter ( CONFIRM_KEY_KEY ) ; if ( Strin... | This method checks if the current request is a user registration confirmation usually triggered by a user clicking on a confirmation link in an e - mail . |
35,052 | private boolean isVisibleForSite ( final HttpServletRequest request , final Page page ) { final Site site = page . getSite ( ) ; if ( site == null ) { return true ; } final String serverName = request . getServerName ( ) ; final int serverPort = request . getServerPort ( ) ; if ( StringUtils . isNotBlank ( serverName )... | Check if the given page is visible for the requested site defined by a hostname and a port . |
35,053 | public static void clearSession ( final String sessionId ) { if ( StringUtils . isBlank ( sessionId ) ) { return ; } final App app = StructrApp . getInstance ( ) ; final PropertyKey < String [ ] > sessionIdKey = StructrApp . key ( Principal . class , "sessionIds" ) ; final Query < Principal > query = app . nodeQuery ( ... | Make sure the given sessionId is not set for any user . |
35,054 | public static void clearInvalidSessions ( final Principal user ) { logger . info ( "Clearing invalid sessions for user {} ({})" , user . getName ( ) , user . getUuid ( ) ) ; final PropertyKey < String [ ] > sessionIdKey = StructrApp . key ( Principal . class , "sessionIds" ) ; final String [ ] sessionIds = user . getPr... | Remove old sessionIds of the given user |
35,055 | public boolean evaluateCustomQuery ( final String customQuery , final Map < String , Object > parameters ) { final SessionTransaction tx = db . getCurrentTransaction ( ) ; boolean result = false ; try { result = tx . getBoolean ( customQuery , parameters ) ; } catch ( Exception ignore ) { } return result ; } | Evaluate a custom query and return result as a boolean value |
35,056 | private void ensureCorrectChildPositions ( ) throws FrameworkException { final List < Relation < T , T , OneStartpoint < T > , ManyEndpoint < T > > > childRels = treeGetChildRelationships ( ) ; int position = 0 ; for ( Relation < T , T , OneStartpoint < T > , ManyEndpoint < T > > childRel : childRels ) { childRel . set... | Ensures that the position attributes of the AbstractChildren of this node are correct . Please note that this method needs to run in the same transaction as any modifiying operation that changes the order of child nodes and therefore this method does _not_ create its own transaction . However it will not raise a NotInT... |
35,057 | public Set < T > getAllChildNodes ( ) { Set < T > allChildNodes = new HashSet ( ) ; List < T > childNodes = treeGetChildren ( ) ; for ( final T child : childNodes ) { allChildNodes . add ( child ) ; if ( child instanceof LinkedTreeNode ) { final LinkedTreeNode treeNode = ( LinkedTreeNode ) child ; allChildNodes . addAl... | Return a set containing all child nodes of this node . |
35,058 | protected PropertyMap getNotionProperties ( final SecurityContext securityContext , final Class type , final String storageKey ) { final Map < String , PropertyMap > notionPropertyMap = ( Map < String , PropertyMap > ) securityContext . getAttribute ( "notionProperties" ) ; if ( notionPropertyMap != null ) { final Set ... | Loads a PropertyMap from the current security context that was previously stored there by one of the Notions that was executed before this relationship creation . |
35,059 | protected List < NodeInterface > getNodesAt ( final NodeInterface locationNode ) { final List < NodeInterface > nodes = new LinkedList < > ( ) ; for ( RelationshipInterface rel : locationNode . getIncomingRelationships ( NodeHasLocation . class ) ) { NodeInterface startNode = rel . getSourceNode ( ) ; nodes . add ( sta... | Return all nodes which are connected by an incoming IS_AT relationships |
35,060 | private File fileExists ( final String path , final long checksum ) throws FrameworkException { final PropertyKey < Long > checksumKey = StructrApp . key ( File . class , "checksum" ) ; final PropertyKey < String > pathKey = StructrApp . key ( File . class , "path" ) ; return app . nodeQuery ( File . class ) . and ( pa... | Check whether a file with given path and checksum already exists |
35,061 | public static < T > List < T > subList ( final List < T > list , int pageSize , int page ) { if ( pageSize <= 0 || page == 0 ) { return Collections . EMPTY_LIST ; } int size = list . size ( ) ; int fromIndex = page > 0 ? ( page - 1 ) * pageSize : size + ( page * pageSize ) ; int toIndex = fromIndex + pageSize ; int fin... | Return a single page of the list with the given paging parameters . |
35,062 | public static String getRelativeNodePath ( String basePath , String targetPath ) { if ( basePath . equals ( targetPath ) ) { return "." ; } if ( basePath . equals ( PATH_SEP ) && ( targetPath . length ( ) > 1 ) ) { return targetPath . substring ( 1 ) ; } String [ ] baseAncestors = FilenameUtils . normalizeNoEndSeparato... | Assemble a relative path for the given absolute paths |
35,063 | public static String getName ( final String path ) { String cleanedPath = clean ( path ) ; if ( cleanedPath != null && cleanedPath . contains ( PATH_SEP ) ) { return StringUtils . substringAfterLast ( cleanedPath , PATH_SEP ) ; } else { return cleanedPath ; } } | Return last part of the given path after separator or the path if no path separator was found . |
35,064 | public static String [ ] getParts ( final String path ) { String cleanedPath = clean ( path ) ; return StringUtils . splitByWholeSeparator ( cleanedPath , PATH_SEP ) ; } | Return array of path parts . |
35,065 | public void finish ( ) { try { FileChannel channel = getChannel ( false ) ; if ( channel != null && channel . isOpen ( ) ) { channel . force ( true ) ; channel . close ( ) ; this . privateFileChannel = null ; file . notifyUploadCompletion ( ) ; } } catch ( IOException e ) { logger . warn ( "Unable to finish file upload... | Called when the WebSocket connection is closed |
35,066 | public int indexOf ( T x ) { int r = Arrays . binarySearch ( data , x ) ; return ( r >= 0 ? r : - 1 ) ; } | Returns the position in the array or - 1 |
35,067 | public static boolean endsWithUuid ( final String name ) { if ( name . length ( ) > 32 ) { return pattern . matcher ( name . substring ( name . length ( ) - 32 ) ) . matches ( ) ; } else { return false ; } } | Checks if the given string ends with a uuid |
35,068 | public int contentHashCode ( Set < PropertyKey > comparableKeys , boolean includeSystemProperties ) { Map < PropertyKey , Object > sortedMap = new TreeMap < > ( new PropertyKeyComparator ( ) ) ; int hashCode = 42 ; sortedMap . putAll ( properties ) ; if ( comparableKeys == null ) { for ( Entry < PropertyKey , Object > ... | Calculates a hash code for the contents of this PropertyMap . |
35,069 | public List < RelationshipInterface > execute ( NodeInterface sourceNode , RelationshipType relType , Direction dir ) throws FrameworkException { RelationshipFactory factory = new RelationshipFactory ( securityContext ) ; List < RelationshipInterface > result = new LinkedList < > ( ) ; Node node = sourceNode . getNode ... | Fetch relationships for the given source node . |
35,070 | public static Date parse ( String source , final String pattern ) { if ( StringUtils . isBlank ( pattern ) ) { return parseISO8601DateString ( source ) ; } else { try { if ( StringUtils . contains ( source , "Z" ) ) { source = StringUtils . replace ( source , "Z" , "+0000" ) ; } return new SimpleDateFormat ( pattern ) ... | Static method to catch parse exception |
35,071 | public static Date parseISO8601DateString ( String source ) { final String [ ] supportedFormats = new String [ ] { "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" , "yyyy-MM-dd'T'HH:mm:ssXXX" , "yyyy-MM-dd'T'HH:mm:ssZ" , "yyyy-MM-dd'T'HH:mm:ss.SSSZ" } ; if ( StringUtils . contains ( source , "Z" ) ) { source = StringUtils . replace ( s... | Try to parse source string as a ISO8601 date . |
35,072 | public static String format ( final Date date , String format ) { if ( date != null ) { if ( StringUtils . isBlank ( format ) ) { format = DateProperty . getDefaultFormat ( ) ; } return new SimpleDateFormat ( format ) . format ( date ) ; } return null ; } | Central method to format a date into a string . |
35,073 | public GraphObject getGraphObject ( final String id , final String nodeId ) { if ( isValidUuid ( id ) ) { final AbstractNode node = getNode ( id ) ; if ( node != null ) { return node ; } else { if ( nodeId == null ) { logger . warn ( "Relationship access by UUID is deprecated and not supported by Neo4j, this can take a... | Returns the graph object with the given id . |
35,074 | public AbstractNode getNode ( final String id ) { final SecurityContext securityContext = getWebSocket ( ) . getSecurityContext ( ) ; final App app = StructrApp . getInstance ( securityContext ) ; try ( final Tx tx = app . tx ( ) ) { final AbstractNode node = ( AbstractNode ) app . getNodeById ( id ) ; tx . success ( )... | Returns the node with the given id . |
35,075 | public AbstractRelationship getRelationship ( final String id , final String nodeId ) { if ( id == null ) { return null ; } if ( nodeId == null ) { return getRelationship ( id ) ; } final SecurityContext securityContext = getWebSocket ( ) . getSecurityContext ( ) ; final App app = StructrApp . getInstance ( securityCon... | Returns the relationship with the given id by looking up a node with the given nodeId and filtering the relationships . |
35,076 | public AbstractRelationship getRelationship ( final String id ) { if ( id == null ) { return null ; } final SecurityContext securityContext = getWebSocket ( ) . getSecurityContext ( ) ; final App app = StructrApp . getInstance ( securityContext ) ; try ( final Tx tx = app . tx ( ) ) { final AbstractRelationship rel = (... | Returns the relationship to which the uuid parameter of this command refers to . |
35,077 | protected void moveChildNodes ( final DOMNode sourceNode , final DOMNode targetNode ) { DOMNode child = ( DOMNode ) sourceNode . getFirstChild ( ) ; while ( child != null ) { DOMNode next = ( DOMNode ) child . getNextSibling ( ) ; targetNode . appendChild ( child ) ; child = next ; } } | Make child nodes of the source nodes child nodes of the target node . |
35,078 | private void fixDocumentElements ( final Page page ) { final NodeList heads = page . getElementsByTagName ( "head" ) ; if ( heads . getLength ( ) > 1 ) { final Node head1 = heads . item ( 0 ) ; final Node head2 = heads . item ( 1 ) ; final Node parent = head1 . getParentNode ( ) ; final boolean h1 = head1 . hasChildNod... | Remove duplicate Head element from import process . |
35,079 | public CMISInfo getCMISInfo ( final Class < ? extends GraphObject > type ) { try { return type . newInstance ( ) . getCMISInfo ( ) ; } catch ( Throwable t ) { } return null ; } | Returns the CMIS info that is defined in the given Structr type or null . |
35,080 | public BaseTypeId getBaseTypeId ( final Class < ? extends GraphObject > type ) { final CMISInfo info = getCMISInfo ( type ) ; if ( info != null ) { return info . getBaseTypeId ( ) ; } return null ; } | Returns the baseTypeId that is defined in the given Structr type or null . |
35,081 | public BaseTypeId getBaseTypeId ( final String typeId ) { try { return BaseTypeId . fromValue ( typeId ) ; } catch ( IllegalArgumentException iex ) { } return null ; } | Returns the enum value for the given typeId or null if no such value exists . |
35,082 | public Class typeFromObjectTypeId ( final String objectTypeId , final BaseTypeId defaultType , final Class defaultClass ) { if ( defaultType . value ( ) . equals ( objectTypeId ) ) { return defaultClass ; } return StructrApp . getConfiguration ( ) . getNodeEntityClass ( objectTypeId ) ; } | Returns the Structr type for the given objectTypeId or the defaultClass of the objectTypeId matches the given baseTypeId . |
35,083 | public void registerServiceClass ( Class serviceClass ) { registeredServiceClasses . put ( serviceClass . getSimpleName ( ) , serviceClass ) ; Settings . Services . addAvailableOption ( serviceClass . getSimpleName ( ) ) ; } | Registers a service enabling the service layer to automatically start autorun servies . |
35,084 | public boolean isReady ( final Class serviceClass ) { Service service = serviceCache . get ( serviceClass ) ; return ( service != null && service . isRunning ( ) ) ; } | Return true if the given service is ready to be used means initialized and running . |
35,085 | public static String replacePlaceHoldersInTemplate ( final String template , final Map < String , String > replacementMap ) { List < String > toReplace = new ArrayList < > ( ) ; List < String > replaceBy = new ArrayList < > ( ) ; for ( Entry < String , String > property : replacementMap . entrySet ( ) ) { toReplace . a... | Parse the template and replace any of the keys in the replacement map by the given values |
35,086 | public void indexSourceTree ( final Folder rootFolder ) { logger . info ( "Starting indexing of source tree " + rootFolder . getPath ( ) ) ; final SecurityContext securityContext = rootFolder . getSecurityContext ( ) ; app = StructrApp . getInstance ( securityContext ) ; structrTypeSolver . parseRoot ( rootFolder ) ; f... | Create an index containing all compilation units of Java files from the source tree under the given root folder . |
35,087 | public Iterable < T > bulkInstantiate ( final Iterable < S > input ) throws FrameworkException { return Iterables . map ( this , input ) ; } | Create structr nodes from all given underlying database nodes No paging but security check |
35,088 | public static void exportToFile ( final DatabaseService graphDb , final String fileName , final String query , final boolean includeFiles ) throws FrameworkException { final App app = StructrApp . getInstance ( ) ; try ( final Tx tx = app . tx ( ) ) { final NodeFactory nodeFactory = new NodeFactory ( SecurityContext . ... | Exports the whole structr database to a file with the given name . |
35,089 | public static void exportToFile ( final String fileName , final Iterable < ? extends NodeInterface > nodes , final Iterable < ? extends RelationshipInterface > relationships , final Iterable < String > filePaths , final boolean includeFiles ) throws FrameworkException { try ( final Tx tx = StructrApp . getInstance ( ) ... | Exports the given part of the structr database to a file with the given name . |
35,090 | public static void exportToStream ( final OutputStream outputStream , final Iterable < ? extends NodeInterface > nodes , final Iterable < ? extends RelationshipInterface > relationships , final Iterable < String > filePaths , final boolean includeFiles ) throws FrameworkException { try ( final ZipOutputStream zos = new... | Exports the given part of the structr database to the given output stream . |
35,091 | public static void serializeData ( DataOutputStream outputStream , byte [ ] data ) throws IOException { outputStream . writeInt ( data . length ) ; outputStream . write ( data ) ; outputStream . flush ( ) ; } | Serializes the given object into the given writer . The following format will be used to serialize objects . The first two characters are the type index see typeMap above . After that a single digit that indicates the length of the following length field follows . After that the length field is serialized followed by t... |
35,092 | private String getFirstPartOfString ( final String source ) { final int pos = source . indexOf ( "." ) ; if ( pos > - 1 ) { return source . substring ( 0 , pos ) ; } return source ; } | Returns the first part of the given source string when it contains a . |
35,093 | public SecurityContext initializeAndExamineRequest ( final HttpServletRequest request , final HttpServletResponse response ) throws FrameworkException { logger . warn ( "KAI: RestAuthenticator.initializeAndExamineRequest" ) ; SecurityContext securityContext ; Principal user = SessionHelper . checkSessionAuthentication ... | Examine request and try to find a user . |
35,094 | private int calculateSexCode ( Person . Sex sex ) { return SEX_FIELDS [ baseProducer . randomInt ( SEX_FIELDS . length - 1 ) ] + ( sex == Person . Sex . MALE ? 1 : 0 ) ; } | This should be tested |
35,095 | public static String getRandomNumStr ( BaseProducer baseProducer , int max , int paddingSize ) { int rndNum = baseProducer . randomBetween ( 1 , max ) ; String numStr = "" + rndNum ; while ( numStr . length ( ) < paddingSize ) { numStr = "0" + numStr ; } return numStr ; } | Get random number from 1 to max in 0 leading string format . |
35,096 | public static Fairy create ( Locale locale , String dataFilePrefix ) { return builder ( ) . withLocale ( locale ) . withFilePrefix ( dataFilePrefix ) . build ( ) ; } | Use this factory method to create your own dataset overriding bundled one |
35,097 | private static FairyModule getFairyModuleForLocale ( DataMaster dataMaster , Locale locale , RandomGenerator randomGenerator ) { LanguageCode code ; try { code = LanguageCode . valueOf ( locale . getLanguage ( ) . toUpperCase ( ) ) ; } catch ( IllegalArgumentException e ) { LOG . warn ( "Uknown locale " + locale ) ; co... | Support customized language config |
35,098 | public void readResources ( String path ) throws IOException { Enumeration < URL > resources = getClass ( ) . getClassLoader ( ) . getResources ( path ) ; if ( ! resources . hasMoreElements ( ) ) { throw new IllegalArgumentException ( String . format ( "File %s was not found on classpath" , path ) ) ; } Yaml yaml = new... | fixme - should be package - private |
35,099 | public < T > T randomElement ( List < T > elements ) { return elements . get ( randomBetween ( 0 , elements . size ( ) - 1 ) ) ; } | Returns random element from passed List |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.