idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
9,700 | public final boolean abort ( ) { boolean ret = false ; if ( UserLoginModule . LOG . isDebugEnabled ( ) ) { UserLoginModule . LOG . debug ( "Abort of " + this . principal ) ; } // If our authentication was successful, just return false if ( this . principal != null ) { // Clean up if overall authentication failed if ( this . committed ) { this . subject . getPrincipals ( ) . remove ( this . principal ) ; } this . committed = false ; this . principal = null ; ret = true ; } return ret ; } | Abort the login . | 120 | 5 |
9,701 | @ Override public void readXML ( final List < String > _tags , final Map < String , String > _attributes , final String _text ) throws SAXException , EFapsException { if ( _tags . size ( ) == 1 ) { final String value = _tags . get ( 0 ) ; if ( "uuid" . equals ( value ) ) { this . uuid = _text ; } else if ( "file-application" . equals ( value ) ) { this . fileApplication = _text ; } else if ( "definition" . equals ( value ) ) { this . definitions . add ( newDefinition ( ) ) ; } } else if ( "definition" . equals ( _tags . get ( 0 ) ) ) { final AbstractDefinition curDef = this . definitions . get ( this . definitions . size ( ) - 1 ) ; curDef . readXML ( _tags . subList ( 1 , _tags . size ( ) ) , _attributes , _text ) ; } else { throw new SAXException ( "Unknown XML Tag: " + _tags + " for: " + this . installFile ) ; } } | Read event for given tags path with attributes and text . | 244 | 11 |
9,702 | protected void registerRevision ( final String _application , final InstallFile _installFile , final Instance _objInst ) throws InstallationException { try { if ( CIAdminCommon . Application . getType ( ) != null && CIAdminCommon . Application . getType ( ) . getAttributes ( ) . size ( ) > 4 ) { final QueryBuilder appQueryBldr = new QueryBuilder ( CIAdminCommon . Application ) ; appQueryBldr . addWhereAttrEqValue ( CIAdminCommon . Application . Name , _application ) ; final CachedInstanceQuery appQuery = appQueryBldr . getCachedQuery4Request ( ) ; appQuery . execute ( ) ; if ( appQuery . next ( ) ) { final Instance appInst = appQuery . getCurrentValue ( ) ; final QueryBuilder queryBldr = new QueryBuilder ( CIAdminCommon . ApplicationRevision ) ; queryBldr . addWhereAttrEqValue ( CIAdminCommon . ApplicationRevision . ApplicationLink , appInst ) ; queryBldr . addWhereAttrEqValue ( CIAdminCommon . ApplicationRevision . Revision , _installFile . getRevision ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminCommon . ApplicationRevision . Date ) ; multi . execute ( ) ; final Instance appRevInst ; if ( multi . next ( ) ) { appRevInst = multi . getCurrentInstance ( ) ; if ( _installFile . getDate ( ) . isAfter ( multi . < DateTime > getAttribute ( CIAdminCommon . ApplicationRevision . Date ) ) ) { AbstractUpdate . LOG . debug ( "Updated Revision {} - {} with Date {] " , _installFile . getRevision ( ) , _application , _installFile . getDate ( ) ) ; final Update update = new Update ( appRevInst ) ; update . add ( CIAdminCommon . ApplicationRevision . Date , _installFile . getDate ( ) ) ; update . executeWithoutTrigger ( ) ; } } else { final Insert insert = new Insert ( CIAdminCommon . ApplicationRevision ) ; insert . add ( CIAdminCommon . ApplicationRevision . ApplicationLink , appInst ) ; insert . add ( CIAdminCommon . ApplicationRevision . Revision , _installFile . getRevision ( ) ) ; insert . add ( CIAdminCommon . ApplicationRevision . Date , _installFile . getDate ( ) ) ; insert . execute ( ) ; appRevInst = insert . getInstance ( ) ; } if ( _objInst . getType ( ) . getAttribute ( CIAdmin . Abstract . RevisionLink . name ) != null ) { final Update update = new Update ( _objInst ) ; update . add ( CIAdmin . Abstract . RevisionLink . name , appRevInst ) ; update . executeWithoutTrigger ( ) ; } } } } catch ( final EFapsException e ) { throw new InstallationException ( "Exception" , e ) ; } } | Register revision . | 641 | 3 |
9,703 | public static BlogConnection getBlogConnection ( final String type , final String url , final String username , final String password ) throws BlogClientException { BlogConnection blogConnection = null ; if ( type == null || type . equals ( "metaweblog" ) ) { blogConnection = createBlogConnection ( METAWEBLOG_IMPL_CLASS , url , username , password ) ; } else if ( type . equals ( "atom" ) ) { blogConnection = createBlogConnection ( ATOMPROTOCOL_IMPL_CLASS , url , username , password ) ; } else { throw new BlogClientException ( "Type must be 'atom' or 'metaweblog'" ) ; } return blogConnection ; } | Create a connection to a blog server . | 151 | 8 |
9,704 | @ SuppressWarnings ( "unchecked" ) public < G > OrFuture < G , BAD > future ( CheckedFunction0 < ? extends Or < ? extends G , ? extends BAD > > task ) { OrFutureImpl < G , BAD > future = new OrFutureImpl <> ( this ) ; executor . execute ( ( ) -> { try { future . complete ( ( Or < G , BAD > ) task . apply ( ) ) ; } catch ( Throwable t ) { future . complete ( Bad . of ( converter . apply ( t ) ) ) ; } } ) ; return future ; } | Creates an OrFuture that will execute the given task using this context s executor . | 129 | 18 |
9,705 | @ SafeVarargs public final < G , ERR > OrFuture < G , Every < ERR > > when ( OrFuture < ? extends G , ? extends Every < ? extends ERR > > or , Function < ? super G , ? extends Validation < ERR > > ... validations ) { OrPromise < G , Every < ERR > > promise = promise ( ) ; or . onComplete ( o -> promise . complete ( Accumulation . when ( o , validations ) ) ) ; return promise . future ( ) ; } | Enables further validation on an existing accumulating OrFuture by passing validation functions . | 115 | 15 |
9,706 | public < A , B , ERR , RESULT > OrFuture < RESULT , Every < ERR > > withGood ( OrFuture < ? extends A , ? extends Every < ? extends ERR > > fa , OrFuture < ? extends B , ? extends Every < ? extends ERR > > fb , BiFunction < ? super A , ? super B , ? extends RESULT > function ) { return withPromise ( this , promise -> fa . onComplete ( ora -> fb . onComplete ( orb -> promise . complete ( Accumulation . withGood ( ora , orb , function ) ) ) ) ) ; } | Combines two accumulating OrFutures into a single one using the given function . The resulting OrFuture will complete with a Good if both OrFutures complete with Goods otherwise it will complete with a Bad containing every error in the Bads . | 134 | 50 |
9,707 | public < G , ERR > OrFuture < G , ERR > firstCompletedOf ( Iterable < ? extends OrFuture < ? extends G , ? extends ERR > > input ) { OrPromise < G , ERR > promise = promise ( ) ; input . forEach ( future -> future . onComplete ( promise :: tryComplete ) ) ; return promise . future ( ) ; } | Returns an OrFuture that will complete as soon as the first OrFuture from the given Iterable completes . | 82 | 21 |
9,708 | public < A , B , ERR > OrFuture < Tuple2 < A , B > , Every < ERR > > zip ( OrFuture < ? extends A , ? extends Every < ? extends ERR > > a , OrFuture < ? extends B , ? extends Every < ? extends ERR > > b ) { return withGood ( a , b , Tuple :: of ) ; } | Zips two accumulating OrFutures together . If both complete with Goods returns an OrFuture that completes with a Good tuple containing both original Good values . Otherwise returns an OrFuture that completes with a Bad containing every error message . | 83 | 46 |
9,709 | public < A , B , C , ERR > OrFuture < Tuple3 < A , B , C > , Every < ERR > > zip3 ( OrFuture < ? extends A , ? extends Every < ? extends ERR > > a , OrFuture < ? extends B , ? extends Every < ? extends ERR > > b , OrFuture < ? extends C , ? extends Every < ? extends ERR > > c ) { return withGood ( a , b , c , Tuple :: of ) ; } | Zips three accumulating OrFutures together . If all complete with Goods returns an OrFuture that completes with a Good tuple containing all original Good values . Otherwise returns an OrFuture that completes with a Bad containing every error message . | 109 | 46 |
9,710 | @ Override public long getNewId ( final ConnectionResource _con , final String _table , final String _column ) throws SQLException { throw new SQLException ( "The database driver uses auto generated keys and " + "a new id could not returned without making " + "a new insert." ) ; } | This method normally returns for given table and column a new id . Because this database driver support auto generated keys an SQL exception is always thrown . | 68 | 28 |
9,711 | public void execute ( final OutputStream _out ) throws EFapsException { final boolean hasAccess = super . getInstance ( ) . getType ( ) . hasAccess ( super . getInstance ( ) , AccessTypeEnums . CHECKOUT . getAccessType ( ) ) ; if ( ! hasAccess ) { throw new EFapsException ( this . getClass ( ) , "execute.NoAccess" ) ; } this . executeWithoutAccessCheck ( _out ) ; } | Executes the checkout with an output stream . | 99 | 9 |
9,712 | public void executeWithoutTrigger ( final OutputStream _out ) throws EFapsException { Resource storeRsrc = null ; try { storeRsrc = Context . getThreadContext ( ) . getStoreResource ( getInstance ( ) , Resource . StoreEvent . READ ) ; storeRsrc . read ( _out ) ; this . fileLength = storeRsrc . getFileLength ( ) ; this . fileName = storeRsrc . getFileName ( ) ; } catch ( final EFapsException e ) { Checkout . LOG . error ( "could not checkout " + super . getInstance ( ) , e ) ; throw e ; } } | Executes the checkout for output streams without checking the access rights and without triggers . | 133 | 16 |
9,713 | public static Timestamp getCurrentTimeFromDB ( ) throws EFapsException { Timestamp now = null ; final ConnectionResource rsrc = Context . getThreadContext ( ) . getConnectionResource ( ) ; final Statement stmt ; try { stmt = rsrc . createStatement ( ) ; final ResultSet resultset = stmt . executeQuery ( "SELECT " + Context . getDbType ( ) . getCurrentTimeStamp ( ) ) ; resultset . next ( ) ; now = resultset . getTimestamp ( 1 ) ; resultset . close ( ) ; stmt . close ( ) ; } catch ( final SQLException e ) { DateTimeUtil . LOG . error ( "could not execute SQL-Statement" , e ) ; } return now ; } | Static method to get the current time stamp from the eFaps database . | 163 | 15 |
9,714 | void start ( long currentTime ) { this . readyTime = currentTime ; this . startTime = this . readyTime + this . delayTime ; this . endTime = this . startTime + getDuration ( ) ; this . status = TweenAnimationStatus . RUNNING ; } | Starts and Restart the interpolation . Using this method can lead to some side - effects if you call it multiple times . | 59 | 26 |
9,715 | final void render ( long currentTime ) { if ( this . getStatus ( ) != TweenAnimationStatus . RUNNING ) { return ; } if ( currentTime >= endTime && this . getStatus ( ) != TweenAnimationStatus . WAIT ) { this . status = TweenAnimationStatus . WAIT ; return ; } value = equation . compute ( currentTime - startTime , getStartValue ( ) , getEndValue ( ) - getStartValue ( ) , getDuration ( ) ) ; } | Updates the tween state . Using this method can be unsafe if tween pooling was first enabled . | 106 | 22 |
9,716 | @ Override public BlogEntry next ( ) { try { final ClientEntry entry = iterator . next ( ) ; if ( entry instanceof ClientMediaEntry ) { return new AtomResource ( collection , ( ClientMediaEntry ) entry ) ; } else { return new AtomEntry ( collection , entry ) ; } } catch ( final Exception e ) { LOG . error ( "An error occured while fetching entry" , e ) ; } return null ; } | Get next entry . | 93 | 4 |
9,717 | public String getPhraseValue ( final Instance _instance ) throws EFapsException { final StringBuilder buf = new StringBuilder ( ) ; boolean added = false ; for ( final Token token : this . valueList . getTokens ( ) ) { switch ( token . getType ( ) ) { case EXPRESSION : final OneSelect oneselect = this . selectStmt2OneSelect . get ( token . getValue ( ) ) ; final Object value = oneselect . getObject ( ) ; if ( oneselect . getAttribute ( ) != null ) { final UIValue uiValue = UIValue . get ( null , oneselect . getAttribute ( ) , value ) ; final String val = uiValue . getUIProvider ( ) . getStringValue ( uiValue ) ; if ( val != null ) { added = true ; buf . append ( uiValue . getUIProvider ( ) . getStringValue ( uiValue ) ) ; } } else if ( value != null ) { added = true ; buf . append ( value ) ; } break ; case TEXT : buf . append ( token . getValue ( ) ) ; break ; default : break ; } } return added ? buf . toString ( ) : "" ; } | Method to get the parsed value for this phrase . | 267 | 10 |
9,718 | public static void index ( ) throws EFapsException { final List < IndexDefinition > defs = IndexDefinition . get ( ) ; for ( final IndexDefinition def : defs ) { final QueryBuilder queryBldr = new QueryBuilder ( def . getUUID ( ) ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; index ( query . execute ( ) ) ; } } | Index or reindex using the Indexdefinitions . | 86 | 10 |
9,719 | public static boolean VerifyStrings ( String signature , String message , String publicKey ) throws LRException { // Check that none of the inputs are null if ( signature == null || message == null || publicKey == null ) { throw new LRException ( LRException . NULL_FIELD ) ; } // Convert all inputs into input streams InputStream isSignature = null ; InputStream isMessage = null ; InputStream isPublicKey = null ; try { isSignature = new ByteArrayInputStream ( signature . getBytes ( ) ) ; isMessage = new ByteArrayInputStream ( message . getBytes ( ) ) ; isPublicKey = new ByteArrayInputStream ( publicKey . getBytes ( ) ) ; } catch ( Exception e ) { throw new LRException ( LRException . INPUT_STREAM_FAILED ) ; } // Feed the input streams into the primary verify function return Verify ( isSignature , isMessage , isPublicKey ) ; } | Converts input strings to input streams for the main verify function | 209 | 12 |
9,720 | private static boolean Verify ( InputStream isSignature , InputStream isMessage , InputStream isPublicKey ) throws LRException { // Get the public key ring collection from the public key input stream PGPPublicKeyRingCollection pgpRings = null ; try { pgpRings = new PGPPublicKeyRingCollection ( PGPUtil . getDecoderStream ( isPublicKey ) ) ; } catch ( Exception e ) { throw new LRException ( LRException . INVALID_PUBLIC_KEY ) ; } // Add the Bouncy Castle security provider Security . addProvider ( new BouncyCastleProvider ( ) ) ; // Build an output stream from the message for verification boolean verify = false ; int ch ; ByteArrayOutputStream bOut = new ByteArrayOutputStream ( ) ; ArmoredInputStream aIn = null ; try { aIn = new ArmoredInputStream ( isMessage ) ; // We are making no effort to clean the input for this example // If this turns into a fully-featured verification utility in a future version, this will need to be handled while ( ( ch = aIn . read ( ) ) >= 0 && aIn . isClearText ( ) ) { bOut . write ( ( byte ) ch ) ; } bOut . close ( ) ; } catch ( Exception e ) { throw new LRException ( LRException . MESSAGE_INVALID ) ; } // Build an object factory from the signature input stream and try to get an object out of it Object o = null ; try { PGPObjectFactory pgpFact = new PGPObjectFactory ( PGPUtil . getDecoderStream ( isSignature ) ) ; o = pgpFact . nextObject ( ) ; } catch ( Exception e ) { throw new LRException ( LRException . SIGNATURE_INVALID ) ; } // Check if the object we fetched is a signature list and if it is, get the signature and use it to verfiy try { if ( o instanceof PGPSignatureList ) { PGPSignatureList list = ( PGPSignatureList ) o ; if ( list . size ( ) > 0 ) { PGPSignature sig = list . get ( 0 ) ; PGPPublicKey publicKey = pgpRings . getPublicKey ( sig . getKeyID ( ) ) ; sig . init ( new JcaPGPContentVerifierBuilderProvider ( ) . setProvider ( "BC" ) , publicKey ) ; sig . update ( bOut . toByteArray ( ) ) ; verify = sig . verify ( ) ; } } } catch ( Exception e ) { throw new LRException ( LRException . SIGNATURE_NOT_FOUND ) ; } return verify ; } | Verfies that the provided message and signature using the public key | 590 | 13 |
9,721 | public void setGlobalScopes ( Iterable < GlobalScope > globalScopes ) { this . globalScopes = Lists . newArrayList ( Iterables . concat ( globalScopes , serviceGlobalScopes ) ) ; } | Sets the active global scopes | 48 | 7 |
9,722 | public void render ( String path , Map < String , Object > parameters , Writer out , GlobalScope ... extraGlobalScopes ) throws IOException , ParseException { render ( load ( path ) , parameters , out ) ; } | Renders template loaded from the given path with provided parameters to the given character stream . | 47 | 17 |
9,723 | public void renderInline ( String text , Map < String , Object > parameters , Writer out , GlobalScope ... extraGlobalScopes ) throws IOException , ParseException { render ( loadInline ( text ) , parameters , out , extraGlobalScopes ) ; } | Renders given text with the provided parameters to the given character stream . | 56 | 14 |
9,724 | public void render ( Template template , Map < String , Object > parameters , Writer out , GlobalScope ... extraGlobalScopes ) throws IOException { newInterpreter ( extraGlobalScopes ) . declare ( parameters ) . process ( ( TemplateImpl ) template , out ) ; } | Renders given template with provided parameters to the given character stream . | 58 | 13 |
9,725 | public void render ( Template template , Writer out , GlobalScope ... extraGlobalScopes ) throws IOException { newInterpreter ( extraGlobalScopes ) . process ( ( TemplateImpl ) template , out ) ; } | Renders given template to the given character stream . | 45 | 10 |
9,726 | public String render ( Template template , Map < String , Object > parameters , GlobalScope ... extraGlobalScopes ) throws IOException { StringWriter out = new StringWriter ( ) ; render ( template , parameters , out , extraGlobalScopes ) ; return out . toString ( ) ; } | Renders given template with the provided parameters and returns the rendered text . | 60 | 14 |
9,727 | public String render ( String path , GlobalScope ... extraGlobalScopes ) throws IOException , ParseException { return render ( load ( path ) , extraGlobalScopes ) ; } | Renders template loaded from path and returns rendered text . | 38 | 11 |
9,728 | public String renderInline ( String text , GlobalScope ... extraGlobalScopes ) throws IOException , ParseException { return render ( loadInline ( text ) , extraGlobalScopes ) ; } | Renders given text and returns rendered text . | 42 | 9 |
9,729 | public String render ( Template template , GlobalScope ... extraGlobalScopes ) throws IOException { StringWriter out = new StringWriter ( ) ; render ( template , out , extraGlobalScopes ) ; return out . toString ( ) ; } | Renders given template and returns rendered text . | 50 | 9 |
9,730 | public Template loadInline ( String text ) throws IOException , ParseException { try ( InlineTemplateSource templateSource = new InlineTemplateSource ( text ) ) { return load ( "inline" , templateSource ) ; } } | Loads the given text as a template | 49 | 8 |
9,731 | public Template load ( String path ) throws IOException , ParseException { try ( TemplateSource source = sourceLoader . find ( path ) ) { if ( source != null ) { return load ( path , source ) ; } } return null ; } | Loads a template from the given path | 51 | 8 |
9,732 | public boolean next ( ) throws EFapsException { boolean ret = false ; if ( this . iterator == null ) { this . iterator = this . instances . iterator ( ) ; } if ( this . iterator . hasNext ( ) ) { this . current = this . iterator . next ( ) ; ret = true ; } if ( ret ) { for ( final OneSelect oneSelect : getAllSelects ( ) ) { ret = oneSelect . next ( ) ; if ( ! ret ) { break ; } } } return ret ; } | Method to move the iterator to the next value . | 111 | 10 |
9,733 | protected Object executeEvents ( final EventType _eventType , final TargetMode _targetMode ) throws EFapsException { Object ret = null ; if ( this . fieldId > 0 && getField ( ) . hasEvents ( _eventType ) ) { final List < EventDefinition > events = getField ( ) . getEvents ( _eventType ) ; final StringBuilder html = new StringBuilder ( ) ; if ( events != null ) { final Parameter parameter = new Parameter ( ) ; parameter . put ( ParameterValues . ACCESSMODE , _targetMode ) ; parameter . put ( ParameterValues . INSTANCE , this . instance ) ; parameter . put ( ParameterValues . CLASS , this . classObject ) ; parameter . put ( ParameterValues . UIOBJECT , this ) ; parameter . put ( ParameterValues . CALL_INSTANCE , getCallInstance ( ) ) ; parameter . put ( ParameterValues . REQUEST_INSTANCES , getRequestInstances ( ) ) ; if ( parameter . get ( ParameterValues . PARAMETERS ) == null ) { parameter . put ( ParameterValues . PARAMETERS , Context . getThreadContext ( ) . getParameters ( ) ) ; } for ( final EventDefinition evenDef : events ) { final Return retu = evenDef . execute ( parameter ) ; if ( retu . get ( ReturnValues . SNIPLETT ) != null ) { html . append ( retu . get ( ReturnValues . SNIPLETT ) ) ; } else if ( retu . get ( ReturnValues . VALUES ) != null ) { ret = retu . get ( ReturnValues . VALUES ) ; if ( retu . get ( ReturnValues . INSTANCE ) != null ) { final Instance inst = ( Instance ) retu . get ( ReturnValues . INSTANCE ) ; if ( inst != null && inst . isValid ( ) ) { setInstance ( inst ) ; } else { setInstance ( null ) ; } } } } } if ( html . length ( ) > 0 ) { ret = html . toString ( ) ; } } return ret ; } | Executes the field value events for a field . | 450 | 10 |
9,734 | public void setPosition ( double x , double y , double z ) { this . x = x ; this . y = y ; this . z = z ; } | Sets the position of the Element in 3D . | 34 | 11 |
9,735 | public void setPosition ( Vector3D v ) { this . x = v . getX ( ) ; this . y = v . getY ( ) ; this . z = v . getZ ( ) ; } | Sets the position of the Element in 2D . | 45 | 11 |
9,736 | public void setRotation ( double angle , double x , double y , double z ) { this . rotateX = angle * x ; this . rotateY = angle * y ; this . rotate = angle * z ; } | Sets the rotation angle of the Element . This method wraps the glRotate method . | 46 | 18 |
9,737 | public void setScale ( double scaleX , double scaleY , double scaleZ ) { this . scaleX = scaleX ; this . scaleY = scaleY ; this . scaleZ = scaleZ ; } | Sets the scale of the Element | 43 | 7 |
9,738 | public void addMouseEventCallback ( MouseEventCallback callback ) { if ( mouseEventCallbacks == null ) { mouseEventCallbacks = new ArrayList < MouseEventCallback > ( ) ; } mouseEventCallbacks . add ( callback ) ; } | Add a mouse event callback to a element | 51 | 8 |
9,739 | @ SuppressWarnings ( "unchecked" ) protected Result < JsonNode > writeDataWithResult ( final ObjectNode message , final ObjectMapper objectMapper ) { Result < JsonNode > result ; byte [ ] binaryResultMessage = null ; String textResultMessage = null ; // convert json into map try { if ( ThreadBinary . isBinary ( ) ) { binaryResultMessage = database . sendWriteMessageWithResult ( objectMapper . writeValueAsBytes ( message ) ) ; } else { textResultMessage = database . sendWriteMessageWithResult ( objectMapper . writeValueAsString ( message ) ) ; } } catch ( Exception e ) { logger . error ( "[writeDataWithResult] could not read from database" , e ) ; return new Result <> ( new Error ( Error . NO_DATABASE_REPLY , ExceptionConverter . toString ( e ) ) ) ; } try { if ( ThreadBinary . isBinary ( ) ) { result = jsonObjectMapper . getObjectMapper ( ) . readValue ( binaryResultMessage , Result . class ) ; } else { result = jsonObjectMapper . getObjectMapper ( ) . readValue ( textResultMessage , Result . class ) ; } } catch ( Exception e ) { if ( ThreadBinary . isBinary ( ) ) { logger . error ( "[writeDataWithResult] could not convert message to json: '{}'" , binaryResultMessage , e ) ; } else { logger . error ( "[writeDataWithResult] could not convert message to json: '{}'" , textResultMessage , e ) ; } return new Result <> ( new Error ( Error . MESSAGE_TO_JSON_FAILURE , ExceptionConverter . toString ( e ) ) ) ; } return result ; } | Sends a write message to a Neo4j cluster and returns the data server s answer . | 394 | 19 |
9,740 | public void addSyntheticRule ( ExecutableElement reducer , String nonterminal , String ... rhs ) { addRule ( reducer , nonterminal , "" , true , Arrays . asList ( rhs ) ) ; } | Adds new rule if the same rule doesn t exist already . Rhs is added as - is . Sequences choices or quantifiers are not parsed . | 51 | 30 |
9,741 | public void addAnonymousTerminal ( String expression , Option ... options ) { addTerminal ( null , "'" + expression + "'" , expression , "" , 0 , 10 , options ) ; } | Adds anonymous terminal . Anonymous terminals name is expression | 41 | 9 |
9,742 | public LALRKParserGenerator getParserGenerator ( ParseMethod parseMethod ) { Grammar g = new Grammar ( parseMethod . start ( ) , this , parseMethod . eof ( ) , parseMethod . whiteSpace ( ) ) ; try { return g . createParserGenerator ( parseMethod . start ( ) , ParserFeature . get ( parseMethod ) ) ; } catch ( Throwable t ) { throw new GrammarException ( "problem with " + parseMethod , t ) ; } } | Return a parser generator from grammar . The same grammar can produce different parsers depending for example on start rhs . | 109 | 23 |
9,743 | public void add ( CharRange cond ) { if ( set . isEmpty ( ) ) { set . add ( cond ) ; } else { List < CharRange > remlist = new ArrayList < CharRange > ( ) ; List < CharRange > addlist = new ArrayList < CharRange > ( ) ; boolean is = false ; for ( CharRange r : set ) { if ( r . intersect ( cond ) ) { remlist . add ( r ) ; addlist . addAll ( CharRange . removeOverlap ( cond , r ) ) ; is = true ; } } if ( ! is ) { set . add ( cond ) ; } set . removeAll ( remlist ) ; set . addAll ( addlist ) ; } } | Adds a CharRange | 156 | 4 |
9,744 | public static RangeSet split ( Collection < RangeSet > rangeSets ) { RangeSet result = new RangeSet ( ) ; SortedSet < Integer > ss = new TreeSet < Integer > ( ) ; for ( RangeSet rs : rangeSets ) { for ( CharRange r : rs ) { ss . add ( r . getFrom ( ) ) ; ss . add ( r . getTo ( ) ) ; } } Iterator < Integer > i = ss . iterator ( ) ; if ( i . hasNext ( ) ) { int from = i . next ( ) ; while ( i . hasNext ( ) ) { int to = i . next ( ) ; if ( from != to ) { for ( RangeSet rs : rangeSets ) { if ( rs . contains ( from , to ) ) { result . add ( from , to ) ; break ; } } } from = to ; } } return result ; } | Converts a possibly overlapping collection of RangesSet s into a non overlapping RangeSet that accepts the same characters . | 194 | 23 |
9,745 | public boolean isIntersecting ( Collection < RangeSet > rangeSets ) { for ( RangeSet rs : rangeSets ) { for ( CharRange r1 : rs ) { for ( CharRange r2 : this ) { if ( r1 . intersect ( r2 ) ) { return true ; } } } } return false ; } | Returns true only if any two of RangeSet s is intersecting with each other . | 71 | 17 |
9,746 | public static RangeSet merge ( RangeSet rs ) { RangeSet result = new RangeSet ( ) ; int from = - 1 ; int to = - 1 ; for ( CharRange r : rs ) { if ( from == - 1 ) // first { from = r . getFrom ( ) ; to = r . getTo ( ) ; } else { if ( r . getFrom ( ) == to ) { to = r . getTo ( ) ; } else { result . add ( from , to ) ; from = r . getFrom ( ) ; to = r . getTo ( ) ; } } } result . add ( from , to ) ; return result ; } | Returns a new RangeSet that accepts the same characters as argument . Ranges that are followinf each other are concatenated . | 140 | 26 |
9,747 | public RangeSet complement ( ) { SortedSet < CharRange > nset = new TreeSet < CharRange > ( ) ; int from = 0 ; for ( CharRange r : set ) { int to = r . getFrom ( ) ; if ( from < to ) { nset . add ( new CharRange ( from , to ) ) ; } from = r . getTo ( ) ; } if ( from < Integer . MAX_VALUE ) { nset . add ( new CharRange ( from , Integer . MAX_VALUE ) ) ; } return new RangeSet ( nset ) ; } | Return a complement RangeSet . In other words a RangeSet doesn t accept any of this rangesets characters and accepts all other characters . | 125 | 27 |
9,748 | public TableIdx getTableIdx ( final String _tableName , final String ... _keys ) { TableIdx ret = null ; final String key = _tableName + "-" + StringUtils . join ( _keys , "-" ) ; final Optional < TableIdx > val = this . tableidxs . stream ( ) . filter ( t -> t . getKey ( ) . equals ( key ) ) . findFirst ( ) ; if ( val . isPresent ( ) ) { ret = val . get ( ) ; ret . setCreated ( false ) ; } else { ret = new TableIdx ( ) . setCreated ( true ) . setTable ( _tableName ) . setIdx ( this . currentIdx ++ ) . setKey ( key ) ; this . tableidxs . add ( ret ) ; } return ret ; } | Gets the table idx . | 180 | 7 |
9,749 | public static void compileAll ( final List < String > _classPathElements ) throws EFapsException { new JasperReportCompiler ( _classPathElements ) . compile ( ) ; new CSSCompiler ( ) . compile ( ) ; new JavaScriptCompiler ( ) . compile ( ) ; new WikiCompiler ( ) . compile ( ) ; } | Static Method that executes the method compile for the SubClasses CSSCompiler and JavaScriptCompiler . | 73 | 20 |
9,750 | protected Map < String , String > readCompiledSources ( ) throws EFapsException { final Map < String , String > ret = new HashMap <> ( ) ; final QueryBuilder queryBldr = new QueryBuilder ( getClassName4TypeCompiled ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminProgram . StaticCompiled . Name ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { final String name = multi . < String > getAttribute ( CIAdminProgram . StaticCompiled . Name ) ; ret . put ( name , multi . getCurrentInstance ( ) . getOid ( ) ) ; } return ret ; } | This method reads all compiled Sources from the eFaps - DataBase and returns a map with name to oid relation . | 157 | 25 |
9,751 | protected List < T > readSources ( ) throws EFapsException { final List < T > ret = new ArrayList <> ( ) ; final QueryBuilder queryBldr = new QueryBuilder ( getClassName4Type ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminProgram . Abstract . Name ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { final String name = multi . < String > getAttribute ( CIAdminProgram . StaticCompiled . Name ) ; ret . add ( getNewSource ( name , multi . getCurrentInstance ( ) ) ) ; } return ret ; } | This method reads all Sources from the eFapsDataBase and returns for each Source a Instance of AbstractSource in a List . | 146 | 27 |
9,752 | protected List < Instance > getSuper ( final Instance _instance ) throws EFapsException { final List < Instance > ret = new ArrayList <> ( ) ; final QueryBuilder queryBldr = new QueryBuilder ( getClassName4Type2Type ( ) ) ; queryBldr . addWhereAttrEqValue ( CIAdminProgram . Program2Program . From , _instance . getId ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminProgram . Program2Program . To ) ; multi . execute ( ) ; if ( multi . next ( ) ) { final Instance instance = Instance . get ( getClassName4Type ( ) . getType ( ) , multi . < Long > getAttribute ( CIAdminProgram . Program2Program . To ) ) ; ret . add ( instance ) ; ret . addAll ( getSuper ( instance ) ) ; } return ret ; } | Recursive method that searches the SuperSource for the current Instance identified by the oid . | 205 | 19 |
9,753 | public static String getSourceByClass ( Class < ? > koanClass ) { File file = new File ( getKoanFileLocation ( koanClass ) ) ; StringBuilder contents = new StringBuilder ( ) ; BufferedReader reader = null ; try { reader = new BufferedReader ( new FileReader ( file ) ) ; String text = null ; while ( ( text = reader . readLine ( ) ) != null ) { contents . append ( text ) . append ( System . lineSeparator ( ) ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { try { if ( reader != null ) { reader . close ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } return contents . toString ( ) ; } | Gets source for a class . | 174 | 7 |
9,754 | public static FileInputStream getInputStreamByClass ( Class < ? > koanClass ) { FileInputStream in = null ; try { in = new FileInputStream ( getKoanFileLocation ( koanClass ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } return in ; } | Gets an input stream by class . | 72 | 8 |
9,755 | public static String getSolutionFromFile ( Class < ? > koanClass , String methodName ) { return getSourceFromFile ( koanClass , methodName , SOLUTION_EXTENSION ) ; } | Gets solution for a koan by method name . | 43 | 11 |
9,756 | public static String getProblemFromFile ( Class < ? > koanClass , String methodName ) { return getSourceFromFile ( koanClass , methodName , PROBLEM_EXTENSION ) ; } | Gets problem for a koan by method name . | 45 | 11 |
9,757 | public Instance updateInDB ( final Instance _instance , final String _typeName ) { Instance ret = null ; try { final long typeID = _instance . getId ( ) ; final long progID = getProgID ( _typeName ) ; final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( this . event . getName ( ) ) ) ; queryBldr . addWhereAttrEqValue ( "Abstract" , typeID ) ; queryBldr . addWhereAttrEqValue ( "Name" , this . name ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; final Update update ; if ( query . next ( ) ) { update = new Update ( query . getCurrentValue ( ) ) ; } else { update = new Insert ( this . event . getName ( ) ) ; update . add ( "Abstract" , typeID ) ; update . add ( "IndexPosition" , this . index ) ; update . add ( "Name" , this . name ) ; } update . add ( "JavaProg" , progID ) ; update . add ( "Method" , this . method ) ; update . executeWithoutAccessCheck ( ) ; ret = update . getInstance ( ) ; update . close ( ) ; } catch ( final EFapsException e ) { Event . LOG . error ( "updateInDB(Instance, String)" , e ) ; //CHECKSTYLE:OFF } catch ( final Exception e ) { //CHECKSTYLE:ON Event . LOG . error ( "updateInDB(Instance, String)" , e ) ; } return ret ; } | For given type defined with the instance parameter this trigger is searched by typeID and index position . If the trigger exists the trigger is updated . Otherwise the trigger is created . | 362 | 34 |
9,758 | private long getProgID ( final String _typeName ) throws EFapsException { long id = 0 ; final QueryBuilder queryBldr = new QueryBuilder ( CIAdminProgram . Java ) ; queryBldr . addWhereAttrEqValue ( CIAdminProgram . Java . Name , this . program ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { id = query . getCurrentValue ( ) . getId ( ) ; } else { Event . LOG . error ( "type[" + _typeName + "]." + "Program [" + this . program + "]: " + "' not found" ) ; } return id ; } | Get the id of the program . | 160 | 7 |
9,759 | public void addPropertiesOverwrite ( final String _sytemConfig , final String _attribute ) { this . properties . put ( Overwrite . SYSTEMCONFIG . value ( ) , _sytemConfig ) ; this . properties . put ( Overwrite . ATTRIBUTE . value ( ) , _attribute ) ; } | Adds the properties overwrite . | 67 | 5 |
9,760 | public String getMessage ( ) { if ( code == NO_DATA ) return "A document cannot be added without resource data." ; else if ( code == NO_LOCATOR ) return "A document cannot be added without a resource locator." ; else if ( code == INVALID_JSON ) return "The provided JSON could not be compiled. Check that the JSON provided is valid." ; else if ( code == NOT_CONFIGURED ) return "The exporter must be configured before this action can be taken." ; else if ( code == BENCODE_FAILED ) return "The document could not be bencoded. The resource data may be an invalid structure." ; else if ( code == SIGNING_FAILED ) return "The document could not be digitally signed. Check that the private key data is correct." ; else if ( code == NO_KEY ) return "No private key could be found in the provided private key data." ; else if ( code == NO_KEY_STREAM ) return "The private key data could not be accessed. Check that a valid local file or valid private key dump is provided." ; else if ( code == NULL_FIELD ) return "A required field was not provided with valid input." ; else if ( code == BATCH_ZERO ) return "Batch size must be larger than zero." ; else if ( code == NO_DOCUMENTS ) return "At least one document must be included in order to send data." ; else if ( code == NO_RESPONSE ) return "The Learning Registry node did not return a response to the request." ; else if ( code == INVALID_RESPONSE ) return "The response from the Learning Registry node did not match the form of an expected response." ; else if ( code == JSON_FAILED ) return "The batch of documents could not be converted to a JSON string. Check that no invalid characters were included in the data of any document." ; else if ( code == JSON_IMPORT_FAILED ) return "The batch of documents could not be converted to a JSON string. Check that the node did not return an error or invalid JSON." ; else if ( code == IMPORT_FAILED ) return "Capturing data from the node failed. Please check that the node is running and returning results properly." ; else if ( code == INPUT_STREAM_FAILED ) return "The provided inputs could not be converted into input streams." ; else if ( code == SIGNATURE_NOT_FOUND ) return "A signature matching the provided key could not be found." ; else if ( code == SIGNATURE_INVALID ) return "The signature stream does not contain a valid signature." ; else if ( code == MESSAGE_INVALID ) return "The message stream could not be parsed." ; else if ( code == INVALID_PUBLIC_KEY ) return "The public key stream does not contain a valid public key." ; else return "An unknown error has ocurred." ; } | Get the message attached to the exception | 638 | 7 |
9,761 | public void resetDatabase ( ) { String dropOrphanedEvents = "DROP TABLE IF EXISTS " + DbOrphanedEvent . TABLE_NAME ; SQLiteDatabase writable = dbHelper . getWritableDatabase ( ) ; writable . beginTransaction ( ) ; try { writable . execSQL ( dropOrphanedEvents ) ; writable . execSQL ( DatabaseHelper . SQL_CREATE_ORPHANED_EVENTS_TABLE ) ; writable . setTransactionSuccessful ( ) ; } finally { writable . endTransaction ( ) ; log . d ( "Chat database reset." ) ; } } | Recreates empty database . | 133 | 6 |
9,762 | @ SuppressWarnings ( "unchecked" ) private < T > List < WatcherRegistration < T > > getWatcherRegistrations ( Id < T > id ) { return ( List < WatcherRegistration < T > > ) ( ( Container ) watcherRegistry ) . getAll ( id . type ( ) ) ; } | returns all the watchers associated to the type of the given id . | 72 | 15 |
9,763 | public Integer getIndex4SqlTable ( final SQLTable _sqlTable ) { final Integer ret ; if ( this . sqlTable2Index . containsKey ( _sqlTable ) ) { ret = this . sqlTable2Index . get ( _sqlTable ) ; } else { Integer max = 0 ; for ( final Integer index : this . sqlTable2Index . values ( ) ) { if ( index > max ) { max = index ; } } ret = max + 1 ; this . sqlTable2Index . put ( _sqlTable , ret ) ; } return ret ; } | Get the index for a SQLTable if the table is not existing the table is added and a new index given . | 121 | 23 |
9,764 | public boolean next ( ) { if ( this . iter == null ) { this . iter = new ArrayList <> ( this . values ) . iterator ( ) ; } final boolean ret = this . iter . hasNext ( ) ; if ( ret ) { this . current = this . iter . next ( ) ; } return ret ; } | Move the current instance to the next instance in the list . | 70 | 12 |
9,765 | @ Override public URL findResource ( final String _name ) { URL ret = null ; final String name = _name . replaceAll ( System . getProperty ( "file.separator" ) , "." ) . replaceAll ( ".class" , "" ) ; final byte [ ] data = loadClassData ( name ) ; if ( data != null && data . length > 0 ) { final File file = FileUtils . getFile ( EFapsClassLoader . getTempFolder ( ) , name ) ; try { if ( ! file . exists ( ) || FileUtils . isFileOlder ( file , new DateTime ( ) . minusHours ( 1 ) . toDate ( ) ) ) { FileUtils . writeByteArrayToFile ( file , data ) ; } ret = file . toURI ( ) . toURL ( ) ; } catch ( final IOException e ) { EFapsClassLoader . LOG . error ( "Could not geneate File for reading from URL: {}" , name ) ; } } return ret ; } | In case of jbpm this is necessary for compiling because they search the classes with URL . | 219 | 19 |
9,766 | protected byte [ ] loadClassData ( final String _resourceName ) { EFapsClassLoader . LOG . debug ( "Loading Class '{}' from Database." , _resourceName ) ; final byte [ ] x = read ( _resourceName ) ; return x ; } | Loads the wanted Resource with the EFapsResourceStore into a byte - Array to pass it on to findClass . | 57 | 24 |
9,767 | void sendTaskListToChannels ( List < TaskRec > tasks ) { // group by type // Map < String , List < TaskRec > > grouped = new HashMap < String , List < TaskRec > > ( ) ; for ( TaskRec taskRec : tasks ) { List < TaskRec > tlist = grouped . get ( taskRec . name ) ; if ( tlist == null ) { tlist = new ArrayList < TaskRec > ( ) ; grouped . put ( taskRec . name , tlist ) ; } tlist . add ( taskRec ) ; } // execute // for ( String taskName : grouped . keySet ( ) ) { final List < TaskRec > taskList = grouped . get ( taskName ) ; TaskRec trec1 = taskList . get ( 0 ) ; Channel channel = context . registry . getChannel ( trec1 . channel ) ; if ( channel == null ) { // should never happen logger . warn ( "Task channel '{}' not exists. Use channel MAIN (task={} taskId={})" , trec1 . channel , trec1 . name , trec1 . taskId ) ; channel = context . registry . getChannel ( Model . CHANNEL_MAIN ) ; } TaskConfig taskConfig = context . registry . getTaskConfig ( trec1 . name ) ; if ( taskConfig == null ) { handleUnknownTasks ( taskList ) ; continue ; } for ( final TaskRec taskRec : taskList ) { logger . debug ( "got task: " + taskRec ) ; context . stats . metrics . loadTask ( taskRec . taskId , taskRec . name , taskRec . channel ) ; channel . workers . execute ( new TedRunnable ( taskRec ) { @ Override public void run ( ) { processTask ( taskRec ) ; } } ) ; } } } | will send task to their channels for execution | 396 | 8 |
9,768 | void handleUnknownTasks ( List < TaskRec > taskRecList ) { long nowMs = System . currentTimeMillis ( ) ; for ( TaskRec taskRec : taskRecList ) { if ( taskRec . createTs . getTime ( ) < nowMs - UNKNOWN_TASK_CANCEL_AFTER_MS ) { logger . warn ( "Task is unknown and was not processed during 24 hours, mark as error: {}" , taskRec ) ; changeTaskStatus ( taskRec . taskId , TedStatus . ERROR , "unknown task" ) ; } else { logger . warn ( "Task is unknown, mark as new, postpone: {}" , taskRec ) ; changeTaskStatusPostponed ( taskRec . taskId , TedStatus . NEW , "unknown task. postpone" , new Date ( nowMs + UNKNOWN_TASK_POSTPONE_MS ) ) ; } } } | can be called from eventQueue also | 196 | 7 |
9,769 | private void calcChannelsStats ( List < TaskRec > tasks ) { for ( ChannelWorkContext wc : channelContextMap . values ( ) ) { wc . lastGotCount = 0 ; } for ( TaskRec taskRec : tasks ) { ChannelWorkContext wc = channelContextMap . get ( taskRec . channel ) ; if ( wc == null ) { wc = new ChannelWorkContext ( taskRec . channel ) ; channelContextMap . put ( taskRec . channel , wc ) ; } wc . lastGotCount ++ ; } // update next portion - double if found something, clear to minimum if not for ( ChannelWorkContext wc : channelContextMap . values ( ) ) { if ( wc . lastGotCount > 0 ) { wc . nextSlowLimit = Math . min ( wc . nextSlowLimit * 2 , MAX_TASK_COUNT ) ; logger . debug ( "Channel " + wc . channelName + " nextSlowLimit=" + wc . nextSlowLimit ) ; } else { wc . dropNextSlowLimit ( ) ; } } } | refresh channels work info . is not thread safe | 235 | 10 |
9,770 | @ Koan public void makeTheProductOfIAndJ ( ) { int i = 10 ; int j = 5 ; int product = 0 ; /* (@_@) */ product = i * j ; /* (^_^) */ assertThat ( product , is ( 50 ) ) ; } | In this exercise students will learn how to use the multiplication operator in Java | 61 | 14 |
9,771 | @ Koan @ Vex public void provideTheStartingProblemForCalculatingAFibonacciNumberUsingALoop ( ) { int seventhFibonacciNumber = 0 ; /* (@_@) */ int previous1 = 1 ; int previous2 = 1 ; int currentFibonacci = 1 ; for ( int i = 3 ; i <= 7 ; i ++ ) { } seventhFibonacciNumber = currentFibonacci ; /* (^_^) */ assertThat ( seventhFibonacciNumber , is ( 13 ) ) ; } | In this exercise students will learn how to use | 117 | 9 |
9,772 | @ Action ( ) public SomeNotAuditedObject updateNameAndNumber ( @ ParameterLayout ( named = "Name" ) final String name , @ Parameter ( optionality = Optionality . OPTIONAL ) @ ParameterLayout ( named = "Number" ) final Integer number ) { setName ( name ) ; setNumber ( number ) ; return this ; } | region > updateNameAndNumber | 76 | 6 |
9,773 | public void setCorner ( int index , double x , double y ) { if ( index <= 0 ) { this . x1 = x ; this . y1 = y ; } else if ( index == 1 ) { this . x2 = x ; this . y2 = y ; } else if ( index == 2 ) { this . x3 = x ; this . y3 = y ; } else if ( index >= 3 ) { this . x4 = x ; this . y4 = y ; } calcG ( ) ; } | Sets x y - coordinate of a corner . | 113 | 10 |
9,774 | public void setConer ( int index , Vector3D v ) { if ( index <= 0 ) { this . x1 = v . getX ( ) ; this . y1 = v . getY ( ) ; } else if ( index == 1 ) { this . x2 = v . getX ( ) ; this . y2 = v . getY ( ) ; } else if ( index == 2 ) { this . x3 = v . getX ( ) ; this . y3 = v . getY ( ) ; } else if ( 3 <= index ) { this . x4 = v . getX ( ) ; this . y4 = v . getY ( ) ; } calcG ( ) ; } | Sets coordinates of a corner . | 152 | 7 |
9,775 | public Vector3D getConer ( int index ) { Vector3D v = new Vector3D ( 0 , 0 , 0 ) ; if ( index <= 0 ) { v . set ( this . x1 , this . y1 ) ; } else if ( index == 1 ) { v . set ( this . x2 , this . y2 ) ; } else if ( index == 2 ) { v . set ( this . x3 , this . y3 ) ; } else if ( 3 <= index ) { v . set ( this . x4 , this . y4 ) ; } return v ; } | Gets coordinates of a corner . | 128 | 7 |
9,776 | public void setCornerColor ( int index , Color color ) { if ( ! isGradation ( ) ) { for ( int i = 0 ; i < 4 ; i ++ ) { cornerColor [ i ] = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; cornerColor [ i ] = this . fillColor ; } setGradation ( true ) ; } cornerColor [ index ] = color ; } | Sets the color of a corner for gradation . | 92 | 11 |
9,777 | private AbstractQValue getValue ( final Object _value ) throws EFapsException { AbstractQValue ret = null ; if ( _value == null ) { ret = new QNullValue ( ) ; } else if ( _value instanceof Number ) { ret = new QNumberValue ( ( Number ) _value ) ; } else if ( _value instanceof String ) { ret = new QStringValue ( ( String ) _value ) ; } else if ( _value instanceof DateTime ) { ret = new QDateTimeValue ( ( DateTime ) _value ) ; } else if ( _value instanceof Boolean ) { ret = new QBooleanValue ( ( Boolean ) _value ) ; } else if ( _value instanceof Status ) { ret = new QNumberValue ( ( ( Status ) _value ) . getId ( ) ) ; } else if ( _value instanceof CIStatus ) { ret = new QNumberValue ( Status . find ( ( CIStatus ) _value ) . getId ( ) ) ; } else if ( _value instanceof Instance ) { if ( ! ( ( Instance ) _value ) . isValid ( ) ) { QueryBuilder . LOG . error ( "the given Instance was not valid and cannot be used as filter criteria" , _value ) ; throw new EFapsException ( QueryBuilder . class , "invalid Instance given" ) ; } ret = new QNumberValue ( ( ( Instance ) _value ) . getId ( ) ) ; } else if ( _value instanceof UoM ) { ret = new QNumberValue ( ( ( UoM ) _value ) . getId ( ) ) ; } else if ( _value instanceof IBitEnum ) { ret = new QBitValue ( ( IBitEnum ) _value ) ; } else if ( _value instanceof IEnum ) { ret = new QNumberValue ( ( ( IEnum ) _value ) . getInt ( ) ) ; } else if ( _value instanceof AbstractQValue ) { ret = ( AbstractQValue ) _value ; } else { throw new EFapsException ( QueryBuilder . class , "notsuported" ) ; } return ret ; } | Get the QAbstractValue for a value . | 467 | 9 |
9,778 | public AttributeQuery getAttributeQuery ( final String _attributeName ) { if ( this . query == null ) { try { final String attribute = getAttr4Select ( _attributeName ) ; this . query = new AttributeQuery ( this . typeUUID , attribute . isEmpty ( ) ? _attributeName : attribute ) . setCompanyDependent ( isCompanyDependent ( ) ) ; prepareQuery ( ) ; } catch ( final EFapsException e ) { QueryBuilder . LOG . error ( "Could not open AttributeQuery for uuid: {}" , this . typeUUID ) ; } } return ( AttributeQuery ) this . query ; } | Method to get an Attribute Query . | 139 | 8 |
9,779 | protected AttributeQuery getAttributeQuery ( ) throws EFapsException { AttributeQuery ret = this . getAttributeQuery ( getSelectAttributeName ( ) ) ; // check if in the linkto chain is one before this one if ( ! this . attrQueryBldrs . isEmpty ( ) ) { final QueryBuilder queryBldr = this . attrQueryBldrs . values ( ) . iterator ( ) . next ( ) ; queryBldr . addWhereAttrInQuery ( queryBldr . getLinkAttributeName ( ) , ret ) ; ret = queryBldr . getAttributeQuery ( ) ; } return ret ; } | Method to get an Attribute Query in case of a Select where criteria . | 138 | 15 |
9,780 | private void prepareQuery ( ) throws EFapsException { for ( final QueryBuilder queryBldr : this . attrQueryBldrs . values ( ) ) { final AttributeQuery attrQuery = queryBldr . getAttributeQuery ( ) ; this . addWhereAttrInQuery ( queryBldr . getLinkAttributeName ( ) , attrQuery ) ; } if ( ! this . types . isEmpty ( ) ) { // force the include this . query . setIncludeChildTypes ( true ) ; final Type baseType = Type . get ( this . typeUUID ) ; final QEqual eqPart = new QEqual ( new QAttribute ( baseType . getTypeAttribute ( ) ) ) ; for ( final UUID type : this . types ) { eqPart . addValue ( new QNumberValue ( Type . get ( type ) . getId ( ) ) ) ; } this . compares . add ( eqPart ) ; } if ( ! this . compares . isEmpty ( ) ) { final QAnd and = this . or ? new QOr ( ) : new QAnd ( ) ; for ( final AbstractQAttrCompare compare : this . compares ) { and . addPart ( compare ) ; } this . query . setWhere ( new QWhereSection ( and ) ) ; } if ( ! this . orders . isEmpty ( ) ) { final QOrderBySection orderBy = new QOrderBySection ( this . orders . toArray ( new AbstractQPart [ this . orders . size ( ) ] ) ) ; this . query . setOrderBy ( orderBy ) ; } if ( this . limit > 0 ) { this . query . setLimit ( this . limit ) ; } } | Prepare the Query . | 364 | 5 |
9,781 | public CachedMultiPrintQuery getCachedPrint ( final String _key ) throws EFapsException { return new CachedMultiPrintQuery ( getCachedQuery ( _key ) . execute ( ) , _key ) ; } | Method to get a CachedMultiPrintQuery . | 47 | 10 |
9,782 | public static AbstractQPart getQPart ( final AbstractWhere _where ) throws EFapsException { AbstractQPart ret = null ; if ( _where instanceof SelectWhere ) { switch ( _where . getComparison ( ) ) { case EQUAL : final QueryBuilder queryBldr = new QueryBuilder ( ( UUID ) null ) ; ret = queryBldr . addWhereSelectEqValue ( ( ( SelectWhere ) _where ) . getSelect ( ) , ( ( SelectWhere ) _where ) . getValues ( ) . toArray ( ) ) ; break ; default : break ; } } return ret ; } | Gets the q part . | 132 | 6 |
9,783 | ComapiConfig buildComapiConfig ( ) { return new ComapiConfig ( ) . apiSpaceId ( apiSpaceId ) . authenticator ( authenticator ) . logConfig ( logConfig ) . apiConfiguration ( apiConfig ) . logSizeLimitKilobytes ( logSizeLimit ) . pushMessageListener ( pushMessageListener ) . fcmEnabled ( fcmEnabled ) ; } | Build config for foundation SDK initialisation . | 80 | 8 |
9,784 | int matchLength ( List < CharRange > prefix ) { DFAState < T > state = this ; int len = 0 ; for ( CharRange range : prefix ) { state = state . transit ( range ) ; if ( state == null ) { break ; } len ++ ; } return len ; } | Returns true if dfa starting from this state can accept a prefix constructed from a list of ranges | 63 | 19 |
9,785 | public int getTransitionSelectivity ( ) { int count = 0 ; for ( Transition < DFAState < T > > t : transitions . values ( ) ) { CharRange range = t . getCondition ( ) ; count += range . getTo ( ) - range . getFrom ( ) ; } return count / transitions . size ( ) ; } | Calculates a value of how selective transitions are from this state . Returns 1 if all ranges accept exactly one character . Greater number means less selectivity | 73 | 30 |
9,786 | public boolean hasBoundaryMatches ( ) { for ( Transition < DFAState < T > > t : transitions . values ( ) ) { CharRange range = t . getCondition ( ) ; if ( range . getFrom ( ) < 0 ) { return true ; } } return false ; } | Return true if one of transition ranges is a boundary match . | 62 | 12 |
9,787 | void optimizeTransitions ( ) { HashMap < DFAState < T > , RangeSet > hml = new HashMap <> ( ) ; for ( Transition < DFAState < T > > t : transitions . values ( ) ) { RangeSet rs = hml . get ( t . getTo ( ) ) ; if ( rs == null ) { rs = new RangeSet ( ) ; hml . put ( t . getTo ( ) , rs ) ; } rs . add ( t . getCondition ( ) ) ; } transitions . clear ( ) ; for ( DFAState < T > dfa : hml . keySet ( ) ) { RangeSet rs = RangeSet . merge ( hml . get ( dfa ) ) ; for ( CharRange r : rs ) { addTransition ( r , dfa ) ; } } } | Optimizes transition by merging ranges | 179 | 7 |
9,788 | RangeSet possibleMoves ( ) { List < RangeSet > list = new ArrayList <> ( ) ; for ( NFAState < T > nfa : nfaSet ) { list . add ( nfa . getConditions ( ) ) ; } return RangeSet . split ( list ) ; } | Return a RangeSet containing all ranges | 64 | 7 |
9,789 | void removeDeadEndTransitions ( ) { Iterator < CharRange > it = transitions . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { CharRange r = it . next ( ) ; if ( transitions . get ( r ) . getTo ( ) . isDeadEnd ( ) ) { it . remove ( ) ; } } } | Removes transition to states that doesn t contain any outbound transition and that are not accepting states | 78 | 19 |
9,790 | boolean isDeadEnd ( ) { if ( isAccepting ( ) ) { return false ; } for ( Transition < DFAState < T > > next : transitions . values ( ) ) { if ( next . getTo ( ) != this ) { return false ; } } return true ; } | Returns true if state doesn t contain any outbound transition and is not accepting state | 62 | 16 |
9,791 | Set < NFAState < T > > nfaTransitsFor ( CharRange condition ) { Set < NFAState < T >> nset = new NumSet <> ( ) ; for ( NFAState < T > nfa : nfaSet ) { nset . addAll ( nfa . transit ( condition ) ) ; } return nset ; } | Returns a set of nfA states to where it is possible to move by nfa transitions . | 76 | 20 |
9,792 | void addTransition ( CharRange condition , DFAState < T > to ) { Transition < DFAState < T >> t = new Transition <> ( condition , this , to ) ; t = transitions . put ( t . getCondition ( ) , t ) ; assert t == null ; edges . add ( to ) ; to . inStates . add ( this ) ; } | Adds a new transition | 79 | 4 |
9,793 | private void load ( ) throws EFapsException { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminCommon . MsgPhraseConfigAbstract ) ; queryBldr . addWhereAttrEqValue ( CIAdminCommon . MsgPhraseConfigAbstract . AbstractLink , getId ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . CompanyLink , CIAdminCommon . MsgPhraseConfigAbstract . LanguageLink , CIAdminCommon . MsgPhraseConfigAbstract . Value , CIAdminCommon . MsgPhraseConfigAbstract . Int1 ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { AbstractConfig conf = null ; if ( multi . getCurrentInstance ( ) . getType ( ) . isCIType ( CIAdminCommon . MsgPhraseArgument ) ) { conf = new Argument ( ) ; ( ( Argument ) conf ) . setIndex ( multi . < Integer > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . Int1 ) ) ; arguments . add ( ( Argument ) conf ) ; } else if ( multi . getCurrentInstance ( ) . getType ( ) . isCIType ( CIAdminCommon . MsgPhraseLabel ) ) { conf = new Label ( ) ; labels . add ( ( Label ) conf ) ; } if ( conf == null ) { LOG . error ( "Wrong type: " , this ) ; } else { conf . setCompanyId ( multi . < Long > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . CompanyLink ) ) ; conf . setLanguageId ( multi . < Long > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . LanguageLink ) ) ; conf . setValue ( multi . < String > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . Value ) ) ; } } } | load the phrase . | 419 | 4 |
9,794 | void processBatchWaitTasks ( ) { Channel channel = context . registry . getChannelOrSystem ( Model . CHANNEL_BATCH ) ; // channel TedBW or TedSS int maxTask = context . taskManager . calcChannelBufferFree ( channel ) ; Map < String , Integer > channelSizes = new HashMap < String , Integer > ( ) ; channelSizes . put ( Model . CHANNEL_BATCH , maxTask ) ; List < TaskRec > batches = context . tedDao . reserveTaskPortion ( channelSizes ) ; if ( batches . isEmpty ( ) ) return ; for ( final TaskRec batchTask : batches ) { channel . workers . execute ( new TedRunnable ( batchTask ) { @ Override public void run ( ) { processBatchWaitTask ( batchTask ) ; } } ) ; } } | if finished then move this batchTask to his channel and then will be processed as regular task | 182 | 18 |
9,795 | public boolean send ( Whisper < ? > whisper ) { if ( isShutdown . get ( ) ) return false ; // Internal Queue (Local Thread) for INPLACE multiple recursive calls final ArrayDeque < Whisper < ? > > localQueue = ref . get ( ) ; if ( ! localQueue . isEmpty ( ) ) { localQueue . addLast ( whisper ) ; return true ; } localQueue . addLast ( whisper ) ; while ( ( whisper = localQueue . peekFirst ( ) ) != null ) { final Integer type = whisper . dest ; final Set < Talker > set = map . get ( type ) ; if ( set != null ) { for ( final Talker talker : set ) { final TalkerContext ctx = talker . getState ( ) ; switch ( ctx . type ) { case INPLACE_UNSYNC : talker . newMessage ( whisper ) ; break ; case INPLACE_SYNC : synchronized ( talker ) { talker . newMessage ( whisper ) ; } break ; case QUEUED_UNBOUNDED : case QUEUED_BOUNDED : while ( ! ctx . queueMessage ( whisper ) ) ; break ; } } } localQueue . pollFirst ( ) ; } return true ; } | Send message and optionally wait response | 273 | 6 |
9,796 | public void shutdown ( ) { singleton = null ; log . info ( "Shuting down GossipMonger" ) ; isShutdown . set ( true ) ; threadPool . shutdown ( ) ; // Disable new tasks from being submitted // TODO: Wait for messages to end processing shutdownAndAwaitTermination ( threadPool ) ; // Clean ThreadLocal ref . remove ( ) ; } | Shutdown GossipMonger and associated Threads | 82 | 11 |
9,797 | public RegexMatcher addExpression ( String expr , T attach , Option ... options ) { if ( nfa == null ) { nfa = parser . createNFA ( nfaScope , expr , attach , options ) ; } else { NFA < T > nfa2 = parser . createNFA ( nfaScope , expr , attach , options ) ; nfa = new NFA <> ( nfaScope , nfa , nfa2 ) ; } return this ; } | Add expression . | 103 | 3 |
9,798 | public T match ( CharSequence text , boolean matchPrefix ) { if ( root == null ) { throw new IllegalStateException ( "not compiled" ) ; } int length = text . length ( ) ; for ( int ii = 0 ; ii < length ; ii ++ ) { switch ( match ( text . charAt ( ii ) ) ) { case Error : return null ; case Ok : if ( matchPrefix ) { T uniqueMatch = state . getUniqueMatch ( ) ; if ( uniqueMatch != null ) { state = root ; return uniqueMatch ; } } break ; case Match : return getMatched ( ) ; } } return null ; } | Matches given text . Returns associated token if match otherwise null . If matchPrefix is true returns also the only possible match . | 137 | 26 |
9,799 | public T match ( OfInt text ) { if ( root == null ) { throw new IllegalStateException ( "not compiled" ) ; } while ( text . hasNext ( ) ) { switch ( match ( text . nextInt ( ) ) ) { case Error : return null ; case Match : return getMatched ( ) ; } } return null ; } | Matches given text as int - iterator . Returns associated token if match otherwise null . | 74 | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.