idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
10,200 | private static String recursiveSearch ( java . io . File dir , String fileName ) { for ( String name : dir . list ( ) ) { java . io . File file = new java . io . File ( dir . getAbsolutePath ( ) + "/" + name ) ; if ( name . compareTo ( fileName ) == 0 ) return file . getAbsolutePath ( ) ; if ( file . isDirectory ( ) ) { String filePath = recursiveSearch ( file , fileName ) ; if ( filePath != null ) return filePath ; } } return null ; } | Recursive method for searching file path . |
10,201 | public static void touch ( File file ) throws FileNotFoundException { if ( ! file . exists ( ) ) { OutputStream out = new FileOutputStream ( file ) ; try { out . close ( ) ; } catch ( IOException e ) { } } file . setLastModified ( System . currentTimeMillis ( ) ) ; } | Implements the same behavior as the touch utility on Unix . It creates a new file with size 0 byte or if the file exists already it is opened and closed without modifying it but updating the file date and time . |
10,202 | public boolean isType ( final org . efaps . admin . datamodel . Type _type ) { return getType ( ) . equals ( _type ) ; } | Tests if this type the type in the parameter . |
10,203 | public void rotation ( TextureRotationMode mode ) { float [ ] [ ] tmp = corner . clone ( ) ; switch ( mode ) { case HALF : corner [ 0 ] = tmp [ 2 ] ; corner [ 1 ] = tmp [ 3 ] ; corner [ 2 ] = tmp [ 0 ] ; corner [ 3 ] = tmp [ 1 ] ; break ; case CLOCKWIZE : corner [ 0 ] = tmp [ 3 ] ; corner [ 1 ] = tmp [ 0 ] ; corner [ 2 ] = tmp [ 1 ] ; corner [ 3 ] = tmp [ 2 ] ; break ; case COUNTERCLOCKWIZE : corner [ 0 ] = tmp [ 1 ] ; corner [ 1 ] = tmp [ 2 ] ; corner [ 2 ] = tmp [ 3 ] ; corner [ 3 ] = tmp [ 0 ] ; break ; default : break ; } } | Rotates the way of mapping the texture . |
10,204 | public void flip ( TextureFlipMode mode ) { float [ ] [ ] tmp = corner . clone ( ) ; switch ( mode ) { case VERTICAL : corner [ 0 ] = tmp [ 1 ] ; corner [ 1 ] = tmp [ 0 ] ; corner [ 2 ] = tmp [ 3 ] ; corner [ 3 ] = tmp [ 2 ] ; break ; case HORIZONTAL : corner [ 0 ] = tmp [ 3 ] ; corner [ 1 ] = tmp [ 2 ] ; corner [ 2 ] = tmp [ 1 ] ; corner [ 3 ] = tmp [ 0 ] ; break ; default : break ; } } | Flips the way of mapping the texture . |
10,205 | public void addObject ( final Object [ ] _row ) throws EFapsException { this . objects . add ( this . elements . get ( 0 ) . getObject ( _row ) ) ; } | Adds the object . |
10,206 | public void resolve ( ) throws InstallationException { final IvySettings ivySettings = new IvySettings ( ) ; try { ivySettings . load ( this . getClass ( ) . getResource ( "/org/efaps/update/version/ivy.xml" ) ) ; } catch ( final IOException e ) { throw new InstallationException ( "IVY setting file could not be read" , e ) ; } catch ( final ParseException e ) { throw new InstallationException ( "IVY setting file could not be parsed" , e ) ; } final Ivy ivy = Ivy . newInstance ( ivySettings ) ; ivy . getLoggerEngine ( ) . pushLogger ( new IvyOverSLF4JLogger ( ) ) ; final Map < String , String > attr = new HashMap < String , String > ( ) ; attr . put ( "changing" , "true" ) ; final ModuleRevisionId modRevId = ModuleRevisionId . newInstance ( this . groupId , this . artifactId , this . version , attr ) ; final ResolveOptions options = new ResolveOptions ( ) ; options . setConfs ( new String [ ] { "runtime" } ) ; final ResolvedModuleRevision resModRev = ivy . findModule ( modRevId ) ; Artifact dw = null ; for ( final Artifact artifact : resModRev . getDescriptor ( ) . getAllArtifacts ( ) ) { if ( "jar" . equals ( artifact . getType ( ) ) ) { dw = artifact ; break ; } } final DownloadOptions dwOptions = new DownloadOptions ( ) ; final ArtifactOrigin ao = resModRev . getArtifactResolver ( ) . locate ( dw ) ; resModRev . getArtifactResolver ( ) . getRepositoryCacheManager ( ) . clean ( ) ; final ArtifactDownloadReport adw = resModRev . getArtifactResolver ( ) . download ( ao , dwOptions ) ; this . jarFile = adw . getLocalFile ( ) ; } | Resolves this dependency . |
10,207 | private void compileJasperReport ( final Instance _instSource , final Instance _instCompiled ) throws EFapsException { final String sep = System . getProperty ( "os.name" ) . startsWith ( "Windows" ) ? ";" : ":" ; final StringBuilder classPath = new StringBuilder ( ) ; for ( final String classPathElement : this . classPathElements ) { classPath . append ( classPathElement ) . append ( sep ) ; } final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext . getInstance ( ) ; reportContext . setProperty ( JRCompiler . COMPILER_CLASSPATH , classPath . toString ( ) ) ; reportContext . setProperty ( "net.sf.jasperreports.compiler.groovy" , JasperGroovyCompiler . class . getName ( ) ) ; reportContext . setProperty ( "net.sf.jasperreports.query.executer.factory.eFaps" , FakeQueryExecuterFactory . class . getName ( ) ) ; try { final JasperDesign jasperDesign = JasperUtil . getJasperDesign ( _instSource ) ; if ( jasperDesign . getLanguage ( ) == null ) { jasperDesign . setLanguage ( JRReport . LANGUAGE_JAVA ) ; } final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; JasperCompileManager . compileReportToStream ( jasperDesign , out ) ; final ByteArrayInputStream in = new ByteArrayInputStream ( out . toByteArray ( ) ) ; final Checkin checkin = new Checkin ( _instCompiled ) ; checkin . executeWithoutAccessCheck ( jasperDesign . getName ( ) + ".jasper" , in , in . available ( ) ) ; out . close ( ) ; in . close ( ) ; } catch ( final JRException e ) { throw new EFapsException ( JasperReportCompiler . class , "JRException" , e ) ; } catch ( final IOException e ) { throw new EFapsException ( JasperReportCompiler . class , "IOException" , e ) ; } } | Method to compile one JasperReport . |
10,208 | protected void registerEQLStmt ( final String _origin , final String _stmt ) throws EFapsException { final Insert insert = new Insert ( UUID . fromString ( "c96c63b5-2d4c-4bf9-9627-f335fd9c7a84" ) ) ; insert . add ( "Origin" , "REST: " + ( _origin == null ? "" : _origin ) ) ; insert . add ( "EQLStatement" , _stmt ) ; insert . execute ( ) ; } | Register eql stmt . |
10,209 | public Object getValue ( final Object _object ) throws EFapsException { final Instance inst = ( Instance ) super . getValue ( _object ) ; if ( this . esjp == null ) { try { final Class < ? > clazz = Class . forName ( this . className , false , EFapsClassLoader . getInstance ( ) ) ; this . esjp = ( IEsjpSelect ) clazz . newInstance ( ) ; final List < Instance > instances = new ArrayList < > ( ) ; for ( final Object obj : getOneSelect ( ) . getObjectList ( ) ) { instances . add ( ( Instance ) super . getValue ( obj ) ) ; } if ( this . parameters . isEmpty ( ) ) { this . esjp . initialize ( instances ) ; } else { this . esjp . initialize ( instances , this . parameters . toArray ( new String [ this . parameters . size ( ) ] ) ) ; } } catch ( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) { LOG . error ( "Catched error" , e ) ; } } return this . esjp . getValue ( inst ) ; } | Method to get the value for the current object . |
10,210 | protected String evalApplication ( ) { String ret = null ; final Pattern revisionPattern = Pattern . compile ( "@eFapsApplication[\\s].*" ) ; final Matcher revisionMatcher = revisionPattern . matcher ( getCode ( ) ) ; if ( revisionMatcher . find ( ) ) { ret = revisionMatcher . group ( ) . replaceFirst ( "^@eFapsApplication" , "" ) ; } return ret == null ? null : ret . trim ( ) ; } | This Method extracts the Revision from the program . |
10,211 | protected UUID evalUUID ( ) { UUID uuid = null ; final Pattern uuidPattern = Pattern . compile ( "@eFapsUUID[\\s]*[0-9a-z\\-]*" ) ; final Matcher uuidMatcher = uuidPattern . matcher ( getCode ( ) ) ; if ( uuidMatcher . find ( ) ) { final String uuidStr = uuidMatcher . group ( ) . replaceFirst ( "^@eFapsUUID" , "" ) ; uuid = UUID . fromString ( uuidStr . trim ( ) ) ; } return uuid ; } | This Method extracts the UUID from the source . |
10,212 | protected String evalExtends ( ) { String ret = null ; final Pattern exPattern = Pattern . compile ( "@eFapsExtends[\\s]*[a-zA-Z\\._-]*\\b" ) ; final Matcher exMatcher = exPattern . matcher ( getCode ( ) ) ; if ( exMatcher . find ( ) ) { ret = exMatcher . group ( ) . replaceFirst ( "^@eFapsExtends" , "" ) ; } return ret == null ? null : ret . trim ( ) ; } | This Method extracts the extend from the source . |
10,213 | public void setBackground ( float x , float y , float z , float a ) { gl . glClearColor ( x / 255 , y / 255 , z / 255 , a / 255 ) ; } | Sets the background to a RGB and alpha value . |
10,214 | public void setBackgroud ( Color color ) { gl . glClearColor ( ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) ( color . getAlpha ( ) * getAlpha ( ) ) ) ; } | Sets the background to a RGB or HSB and alpha value . |
10,215 | public void matrixMode ( MatrixMode mode ) { switch ( mode ) { case PROJECTION : gl . glMatrixMode ( GL2 . GL_PROJECTION ) ; break ; case MODELVIEW : gl . glMatrixMode ( GL2 . GL_MODELVIEW ) ; break ; default : break ; } } | Sets the MatrixMode . |
10,216 | public void setAmbientLight ( float r , float g , float b ) { float ambient [ ] = { r , g , b , 255 } ; normalize ( ambient ) ; gl . glEnable ( GL2 . GL_LIGHTING ) ; gl . glEnable ( GL2 . GL_LIGHT0 ) ; gl . glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_AMBIENT , ambient , 0 ) ; } | Sets the RGB value of the ambientLight |
10,217 | public void setAmbientLight ( int i , Color color , boolean enableColor ) { float ambient [ ] = { ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) color . getAlpha ( ) } ; gl . glEnable ( GL2 . GL_LIGHTING ) ; gl . glEnable ( GL2 . GL_LIGHT0 + i ) ; if ( enableColor ) gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_AMBIENT , ambient , 0 ) ; } | Sets the color value of the No . i ambientLight |
10,218 | public void setAmbientLight ( int i , Color color , boolean enableColor , Vector3D v ) { float ambient [ ] = { ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) color . getAlpha ( ) } ; float position [ ] = { ( float ) v . getX ( ) , ( float ) v . getY ( ) , ( float ) v . getZ ( ) , 1.0f } ; gl . glEnable ( GL2 . GL_LIGHTING ) ; gl . glEnable ( GL2 . GL_LIGHT0 + i ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_POSITION , position , 0 ) ; if ( enableColor ) gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_AMBIENT , ambient , 0 ) ; } | Sets the color value and the position of the No . i ambientLight |
10,219 | public void setSpotLight ( int i , Color color , boolean enableColor , Vector3D v , float nx , float ny , float nz , float angle ) { float spotColor [ ] = { ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) color . getAlpha ( ) } ; float pos [ ] = { ( float ) v . getX ( ) , ( float ) v . getY ( ) , ( float ) v . getZ ( ) , 0.0f } ; float direction [ ] = { nx , ny , nz } ; float a [ ] = { angle } ; gl . glEnable ( GL2 . GL_LIGHTING ) ; gl . glEnable ( GL2 . GL_LIGHT0 + i ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_POSITION , pos , 0 ) ; if ( enableColor ) gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_DIFFUSE , spotColor , 0 ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_SPOT_DIRECTION , direction , 0 ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_SPOT_CUTOFF , a , 0 ) ; } | Sets the color value position direction and the angle of the spotlight cone of the No . i spotLight |
10,220 | public void setLightAttenuation ( int i , float constant , float liner , float quadratic ) { float c [ ] = { constant } ; float l [ ] = { liner } ; float q [ ] = { quadratic } ; gl . glEnable ( GL2 . GL_LIGHTING ) ; gl . glEnable ( GL2 . GL_LIGHT0 + i ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_CONSTANT_ATTENUATION , c , 0 ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_LINEAR_ATTENUATION , l , 0 ) ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_QUADRATIC_ATTENUATION , q , 0 ) ; } | Set attenuation rates for point lights spot lights and ambient lights . |
10,221 | public void setLightSpecular ( int i , Color color ) { float [ ] tmpColor = { ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) color . getAlpha ( ) } ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_SPECULAR , tmpColor , 0 ) ; } | Sets the specular color for No . i light . |
10,222 | public void setLightDiffuse ( int i , Color color ) { float [ ] tmpColor = { ( float ) color . getRed ( ) , ( float ) color . getGreen ( ) , ( float ) color . getBlue ( ) , ( float ) color . getAlpha ( ) } ; gl . glLightfv ( GL2 . GL_LIGHT0 + i , GL2 . GL_DIFFUSE , tmpColor , 0 ) ; } | Sets the diffuse color for No . i light . |
10,223 | private static float [ ] normalize ( float [ ] in ) { float [ ] out = new float [ in . length ] ; for ( int i = 0 ; i < in . length ; i ++ ) { out [ i ] = ( in [ i ] / 255.0f ) ; } return out ; } | Returns the array normalized from 0 - 255 to 0 - 1 . 0 . |
10,224 | public void setPerspective ( double fov , double aspect , double zNear , double zFar ) { matrixMode ( MatrixMode . PROJECTION ) ; resetMatrix ( ) ; glu . gluPerspective ( fov , aspect , zNear , zFar ) ; matrixMode ( MatrixMode . MODELVIEW ) ; resetMatrix ( ) ; } | Sets a perspective projection applying foreshortening making distant objects appear smaller than closer ones . The parameters define a viewing volume with the shape of truncated pyramid . Objects near to the front of the volume appear their actual size while farther objects appear smaller . This projection simulates the perspective of the world more accurately than orthographic projection . |
10,225 | public void setPerspective ( ) { double cameraZ = ( ( height / 2.0 ) / Math . tan ( Math . PI * 60.0 / 360.0 ) ) ; matrixMode ( MatrixMode . PROJECTION ) ; resetMatrix ( ) ; glu . gluPerspective ( Math . PI / 3.0 , this . width / this . height , cameraZ / 10.0 , cameraZ * 10.0 ) ; matrixMode ( MatrixMode . MODELVIEW ) ; resetMatrix ( ) ; } | Sets a default perspective . |
10,226 | public void setOrtho ( double left , double right , double bottom , double top , double near , double far ) { matrixMode ( MatrixMode . PROJECTION ) ; resetMatrix ( ) ; gl . glOrtho ( left , right , bottom , top , near , far ) ; matrixMode ( MatrixMode . MODELVIEW ) ; resetMatrix ( ) ; } | Sets an orthographic projection and defines a parallel clipping volume . All objects with the same dimension appear the same size regardless of whether they are near or far from the camera . The parameters to this function specify the clipping volume where left and right are the minimum and maximum x values top and bottom are the minimum and maximum y values and near and far are the minimum and maximum z values . |
10,227 | public void setOrtho ( ) { matrixMode ( MatrixMode . PROJECTION ) ; resetMatrix ( ) ; gl . glOrtho ( 0 , this . width , 0 , this . height , - 1.0e10 , 1.0e10 ) ; matrixMode ( MatrixMode . MODELVIEW ) ; resetMatrix ( ) ; } | Sets the default orthographic projection . |
10,228 | public void setFrustum ( double left , double right , double bottom , double top , double near , double far ) { matrixMode ( MatrixMode . PROJECTION ) ; resetMatrix ( ) ; gl . glFrustum ( left , right , bottom , top , near , far ) ; matrixMode ( MatrixMode . MODELVIEW ) ; resetMatrix ( ) ; } | Sets a perspective matrix defined through the parameters . Works like glFrustum except it wipes out the current perspective matrix rather than multiplying itself with it . |
10,229 | public void setCamera ( ) { glu . gluLookAt ( width / 2.0 , height / 2.0 , ( height / 2.0 ) / Math . tan ( Math . PI * 60.0 / 360.0 ) , width / 2.0 , height / 2.0 , 0 , 0 , 1 , 0 ) ; } | Sets the default camera position . |
10,230 | public Key getKey ( ) { final Key ret = new Key ( ) . setPersonId ( getPersonId ( ) ) . setCompanyId ( getCompanyId ( ) ) . setTypeId ( getTypeId ( ) ) ; return ret ; } | Gets the key . |
10,231 | public String getTag ( ) throws IOException { URLConnection urlConnection = url . openConnection ( ) ; String tag = urlConnection . getHeaderField ( ETAG ) ; if ( tag == null ) { String key = url . toString ( ) + "@" + urlConnection . getLastModified ( ) ; tag = md5Cache . getIfPresent ( key ) ; if ( tag == null ) { try ( InputStream urlStream = urlConnection . getInputStream ( ) ) { byte [ ] data = ByteStreams . toByteArray ( urlConnection . getInputStream ( ) ) ; tag = Hashing . md5 ( ) . hashBytes ( data ) . toString ( ) ; md5Cache . put ( key , tag ) ; } } } return tag ; } | Gets the tag using either the ETAG header of the URL connection or calculates it and caches it based on the URL & last modified date |
10,232 | private List < Pair < Id , GuiceSupplier > > getSuppliers ( ) { ImmutableList . Builder < Pair < Id , GuiceSupplier > > suppliersBuilder = ImmutableList . builder ( ) ; for ( Binding < GuiceRegistration > registrationBinding : injector . findBindingsByType ( TypeLiteral . get ( GuiceRegistration . class ) ) ) { Key < ? > key = registrationBinding . getProvider ( ) . get ( ) . key ( ) ; suppliersBuilder . add ( newPair ( key ) ) ; } return suppliersBuilder . build ( ) ; } | enforce load all providers before register them |
10,233 | public SQLSelect column ( final String _name ) { columns . add ( new Column ( tablePrefix , null , _name ) ) ; return this ; } | Appends a selected column . |
10,234 | public int columnIndex ( final int _tableIndex , final String _columnName ) { final Optional < Column > colOpt = getColumns ( ) . stream ( ) . filter ( column -> column . tableIndex == _tableIndex && column . columnName . equals ( _columnName ) ) . findFirst ( ) ; final int ret ; if ( colOpt . isPresent ( ) ) { ret = getColumns ( ) . indexOf ( colOpt . get ( ) ) ; } else { columns . add ( new Column ( tablePrefix , _tableIndex , _columnName ) ) ; ret = getColumnIdx ( ) ; } return ret ; } | Column index . |
10,235 | public String getSQL ( ) { final StringBuilder cmd = new StringBuilder ( ) . append ( " " ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . SELECT ) ) . append ( " " ) ; if ( distinct ) { cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . DISTINCT ) ) . append ( " " ) ; } boolean first = true ; for ( final Column column : columns ) { if ( first ) { first = false ; } else { cmd . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . COMMA ) ) ; } column . appendSQL ( cmd ) ; } cmd . append ( " " ) . append ( Context . getDbType ( ) . getSQLPart ( SQLPart . FROM ) ) . append ( " " ) ; first = true ; for ( final FromTable fromTable : fromTables ) { fromTable . appendSQL ( first , cmd ) ; if ( first ) { first = false ; } } cmd . append ( " " ) ; boolean whereAdded = false ; for ( final SQLSelectPart part : parts ) { part . appendSQL ( cmd ) ; cmd . append ( " " ) ; whereAdded = whereAdded || ! whereAdded && SQLPart . WHERE . equals ( part . sqlpart ) ; } if ( where != null ) { where . setStarted ( whereAdded ) ; where . appendSQL ( tablePrefix , cmd ) ; } if ( order != null ) { order . appendSQL ( tablePrefix , cmd ) ; } return cmd . toString ( ) ; } | Returns the depending SQL statement . |
10,236 | public SQLSelect addColumnPart ( final Integer _tableIndex , final String _columnName ) { parts . add ( new Column ( tablePrefix , _tableIndex , _columnName ) ) ; return this ; } | Add a column as part . |
10,237 | public SQLSelect addTablePart ( final String _tableName , final Integer _tableIndex ) { parts . add ( new FromTable ( tablePrefix , _tableName , _tableIndex ) ) ; return this ; } | Add a table as part . |
10,238 | public SQLSelect addTimestampValue ( final String _isoDateTime ) { parts . add ( new Value ( Context . getDbType ( ) . getTimestampValue ( _isoDateTime ) ) ) ; return this ; } | Add a timestamp value to the select . |
10,239 | public static CachedPrintQuery get4Request ( final Instance _instance ) throws EFapsException { return new CachedPrintQuery ( _instance , Context . getThreadContext ( ) . getRequestId ( ) ) . setLifespan ( 5 ) . setLifespanUnit ( TimeUnit . MINUTES ) ; } | Get a CachedPrintQuery that will only cache during a request . |
10,240 | protected void prepare ( final AbstractSQLInsertUpdate < ? > _insertUpdate , final Attribute _attribute , final Object ... _values ) throws SQLException { checkSQLColumnSize ( _attribute , 1 ) ; try { _insertUpdate . column ( _attribute . getSqlColNames ( ) . get ( 0 ) , Context . getThreadContext ( ) . getPerson ( ) . getId ( ) ) ; } catch ( final EFapsException e ) { throw new SQLException ( "could not fetch current context person id" , e ) ; } } | The instance method sets the value in the insert statement to the id of the current context user . |
10,241 | protected void addMapping ( final ColumnType _columnType , final String _writeTypeName , final String _nullValueSelect , final String ... _readTypeNames ) { this . writeColTypeMap . put ( _columnType , _writeTypeName ) ; this . nullValueColTypeMap . put ( _columnType , _nullValueSelect ) ; for ( final String readTypeName : _readTypeNames ) { Set < AbstractDatabase . ColumnType > colTypes = this . readColTypeMap . get ( readTypeName ) ; if ( colTypes == null ) { colTypes = new HashSet < > ( ) ; this . readColTypeMap . put ( readTypeName , colTypes ) ; } colTypes . add ( _columnType ) ; } } | Adds a new mapping for given eFaps column type used for mapping from and to the SQL database . |
10,242 | public boolean existsView ( final Connection _con , final String _viewName ) throws SQLException { boolean ret = false ; final DatabaseMetaData metaData = _con . getMetaData ( ) ; final ResultSet rs = metaData . getTables ( null , null , _viewName . toLowerCase ( ) , new String [ ] { "VIEW" } ) ; if ( rs . next ( ) ) { ret = true ; } rs . close ( ) ; if ( ! ret ) { final ResultSet rsUC = metaData . getTables ( null , null , _viewName . toUpperCase ( ) , new String [ ] { "VIEW" } ) ; if ( rsUC . next ( ) ) { ret = true ; } rsUC . close ( ) ; } return ret ; } | The method tests if a view with given name exists . |
10,243 | public T updateColumn ( final Connection _con , final String _tableName , final String _columnName , final ColumnType _columnType , final int _length , final int _scale ) throws SQLException { final StringBuilder cmd = new StringBuilder ( ) ; cmd . append ( "alter table " ) . append ( getTableQuote ( ) ) . append ( _tableName ) . append ( getTableQuote ( ) ) . append ( getAlterColumn ( _columnName , _columnType ) ) ; if ( _length > 0 ) { cmd . append ( "(" ) . append ( _length ) ; if ( _scale > 0 ) { cmd . append ( "," ) . append ( _scale ) ; } cmd . append ( ")" ) ; } AbstractDatabase . LOG . debug ( " ..SQL> " + cmd . toString ( ) ) ; final Statement stmt = _con . createStatement ( ) ; try { stmt . execute ( cmd . toString ( ) ) ; } finally { stmt . close ( ) ; } @ SuppressWarnings ( "unchecked" ) final T ret = ( T ) this ; return ret ; } | Adds a column to a SQL table . |
10,244 | public T addUniqueKey ( final Connection _con , final String _tableName , final String _uniqueKeyName , final String _columns ) throws SQLException { final StringBuilder cmd = new StringBuilder ( ) ; cmd . append ( "alter table " ) . append ( _tableName ) . append ( " " ) . append ( "add constraint " ) . append ( _uniqueKeyName ) . append ( " " ) . append ( "unique(" ) . append ( _columns ) . append ( ")" ) ; AbstractDatabase . LOG . debug ( " ..SQL> " + cmd . toString ( ) ) ; final Statement stmt = _con . createStatement ( ) ; try { stmt . execute ( cmd . toString ( ) ) ; } finally { stmt . close ( ) ; } @ SuppressWarnings ( "unchecked" ) final T ret = ( T ) this ; return ret ; } | Adds a new unique key to given table name . |
10,245 | public T addForeignKey ( final Connection _con , final String _tableName , final String _foreignKeyName , final String _key , final String _reference , final boolean _cascade ) throws InstallationException { final StringBuilder cmd = new StringBuilder ( ) . append ( "alter table " ) . append ( _tableName ) . append ( " " ) . append ( "add constraint " ) . append ( _foreignKeyName ) . append ( " " ) . append ( "foreign key(" ) . append ( _key ) . append ( ") " ) . append ( "references " ) . append ( _reference ) ; if ( _cascade ) { cmd . append ( " on delete cascade" ) ; } AbstractDatabase . LOG . debug ( " ..SQL> " + cmd . toString ( ) ) ; try { final Statement stmt = _con . createStatement ( ) ; try { stmt . execute ( cmd . toString ( ) ) ; } finally { stmt . close ( ) ; } } catch ( final SQLException e ) { throw new InstallationException ( "Foreign key could not be created. SQL statement was:\n" + cmd . toString ( ) , e ) ; } @ SuppressWarnings ( "unchecked" ) final T ret = ( T ) this ; return ret ; } | Adds a foreign key to given SQL table . |
10,246 | public void addCheckKey ( final Connection _con , final String _tableName , final String _checkKeyName , final String _condition ) throws SQLException { final StringBuilder cmd = new StringBuilder ( ) . append ( "alter table " ) . append ( _tableName ) . append ( " " ) . append ( "add constraint " ) . append ( _checkKeyName ) . append ( " " ) . append ( "check(" ) . append ( _condition ) . append ( ")" ) ; AbstractDatabase . LOG . debug ( " ..SQL> " + cmd . toString ( ) ) ; final Statement stmt = _con . createStatement ( ) ; try { stmt . execute ( cmd . toString ( ) ) ; } finally { stmt . close ( ) ; } } | Adds a new check key to given SQL table . |
10,247 | public static AbstractDatabase < ? > findByClassName ( final String _dbClassName ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { return ( AbstractDatabase < ? > ) Class . forName ( _dbClassName ) . newInstance ( ) ; } | Instantiate the given DB class name and returns them . |
10,248 | private Collection < Observable < Attachment > > upload ( RxComapiClient client , List < Attachment > data ) { Collection < Observable < Attachment > > obsList = new ArrayList < > ( ) ; for ( Attachment a : data ) { obsList . add ( upload ( client , a ) ) ; } return obsList ; } | Create list of upload attachment observables . |
10,249 | private Observable < Attachment > upload ( RxComapiClient client , Attachment a ) { return client . service ( ) . messaging ( ) . uploadContent ( a . getFolder ( ) , a . getData ( ) ) . map ( response -> a . updateWithUploadDetails ( response . getResult ( ) ) ) . doOnError ( t -> log . e ( "Error uploading attachment. " + t . getLocalizedMessage ( ) ) ) . onErrorReturn ( a :: setError ) ; } | Upload single attachment and update the details in it from the response . |
10,250 | public void set ( double left , double right , double bottom , double top , double near , double far ) { this . left = left ; this . right = right ; this . bottom = bottom ; this . top = top ; this . near = near ; this . far = far ; } | Sets the clipping plane . |
10,251 | public static AbstractStmt getStatement ( final CharSequence _stmt ) { AbstractStmt ret = null ; final IStatement < ? > stmt = parse ( _stmt ) ; if ( stmt instanceof IPrintStatement ) { ret = PrintStmt . get ( ( IPrintStatement < ? > ) stmt ) ; } else if ( stmt instanceof IDeleteStatement ) { ret = DeleteStmt . get ( ( IDeleteStatement < ? > ) stmt ) ; } else if ( stmt instanceof IInsertStatement ) { ret = InsertStmt . get ( ( IInsertStatement ) stmt ) ; } else if ( stmt instanceof IUpdateStatement ) { ret = UpdateStmt . get ( ( IUpdateStatement < ? > ) stmt ) ; } return ret ; } | Parses the stmt . |
10,252 | public static List < Instance > getInstances ( final AbstractQueryPart _queryPart ) throws EFapsException { return getQueryBldr ( _queryPart ) . getQuery ( ) . execute ( ) ; } | Gets the instances . |
10,253 | public static BigDecimal parseLocalized ( final String _value ) throws EFapsException { final DecimalFormat format = ( DecimalFormat ) NumberFormat . getInstance ( Context . getThreadContext ( ) . getLocale ( ) ) ; format . setParseBigDecimal ( true ) ; try { return ( BigDecimal ) format . parse ( _value ) ; } catch ( final ParseException e ) { throw new EFapsException ( DecimalType . class , "ParseException" , e ) ; } } | Method to parse a localized String to an BigDecimal . |
10,254 | public void update ( String cacheName , Cache cache ) { cacheManager . enableManagement ( cacheName , cache . isManagementEnabled ( ) ) ; updateStatistics ( cacheName , cache ) ; } | Update mutable information of cache configuration such as management and statistics support |
10,255 | public void setStatistics ( boolean enabled ) { all ( ) . forEach ( cache -> updateStatistics ( cache . getName ( ) , new Cache ( false , enabled ) ) ) ; } | Enable or disable statistics for all caches |
10,256 | public Optional < CacheStatistics > getStatistics ( String cacheName ) { javax . cache . Cache cache = cacheManager . getCache ( cacheName ) ; if ( cache == null ) { return Optional . empty ( ) ; } if ( ( ( CompleteConfiguration ) cache . getConfiguration ( CompleteConfiguration . class ) ) . isStatisticsEnabled ( ) && cache instanceof ICache ) { com . hazelcast . cache . CacheStatistics stats = ( ( ICache ) cache ) . getLocalCacheStatistics ( ) ; CacheStatistics statistics = new CacheStatistics ( stats . getCacheHits ( ) , stats . getCacheMisses ( ) , stats . getCacheHitPercentage ( ) , stats . getCacheMissPercentage ( ) , stats . getCacheGets ( ) , stats . getCachePuts ( ) , stats . getCacheRemovals ( ) , stats . getCacheEvictions ( ) , stats . getAverageGetTime ( ) , stats . getAveragePutTime ( ) , stats . getAverageRemoveTime ( ) ) ; return Optional . of ( statistics ) ; } return Optional . empty ( ) ; } | Get a cache statistic information if available |
10,257 | private void setAttrValue ( final AttrName _attrName , final String _value ) { synchronized ( this . attrValues ) { this . attrValues . put ( _attrName , _value ) ; } } | The method sets the attribute values in the cache for given attribute name to given new attribute value . |
10,258 | public Locale getLocale ( ) { final Locale ret ; if ( this . attrValues . get ( Person . AttrName . LOCALE ) != null ) { final String localeStr = this . attrValues . get ( Person . AttrName . LOCALE ) ; final String [ ] countries = localeStr . split ( "_" ) ; if ( countries . length == 2 ) { ret = new Locale ( countries [ 0 ] , countries [ 1 ] ) ; } else if ( countries . length == 3 ) { ret = new Locale ( countries [ 0 ] , countries [ 1 ] , countries [ 2 ] ) ; } else { ret = new Locale ( localeStr ) ; } } else { ret = Locale . ENGLISH ; } return ret ; } | Method to get the Locale of this Person . Default is the English Locale . |
10,259 | public String getLanguage ( ) { return this . attrValues . get ( Person . AttrName . LANGUAGE ) != null ? this . attrValues . get ( Person . AttrName . LANGUAGE ) : Locale . ENGLISH . getISO3Language ( ) ; } | Method to get the Language of the UserInterface for this Person . Default is english . |
10,260 | public DateTimeZone getTimeZone ( ) { return this . attrValues . get ( Person . AttrName . TIMZONE ) != null ? DateTimeZone . forID ( this . attrValues . get ( Person . AttrName . TIMZONE ) ) : DateTimeZone . UTC ; } | Method to get the Timezone of this Person . Default is the UTC Timezone . |
10,261 | public ChronologyType getChronologyType ( ) { final String chronoKey = this . attrValues . get ( Person . AttrName . CHRONOLOGY ) ; final ChronologyType chronoType ; if ( chronoKey != null ) { chronoType = ChronologyType . getByKey ( chronoKey ) ; } else { chronoType = ChronologyType . ISO8601 ; } return chronoType ; } | Method to get the ChronologyType of this Person . Default is the ISO8601 ChronologyType . |
10,262 | public boolean checkPassword ( final String _passwd ) throws EFapsException { boolean ret = false ; final PrintQuery query = new PrintQuery ( CIAdminUser . Person . getType ( ) , getId ( ) ) ; query . addAttribute ( CIAdminUser . Person . Password , CIAdminUser . Person . LastLogin , CIAdminUser . Person . LoginTry , CIAdminUser . Person . LoginTriesCounter , CIAdminUser . Person . Status ) ; if ( query . executeWithoutAccessCheck ( ) ) { final PasswordStore pwd = query . < PasswordStore > getAttribute ( CIAdminUser . Person . Password ) ; if ( pwd . checkCurrent ( _passwd ) ) { ret = query . < Boolean > getAttribute ( CIAdminUser . Person . Status ) ; } else { setFalseLogin ( query . < DateTime > getAttribute ( CIAdminUser . Person . LoginTry ) , query . < Integer > getAttribute ( CIAdminUser . Person . LoginTriesCounter ) ) ; } } return ret ; } | The instance method checks if the given password is the same password as the password in the database . |
10,263 | private void setFalseLogin ( final DateTime _logintry , final int _count ) throws EFapsException { if ( _count > 0 ) { final DateTime now = new DateTime ( DateTimeUtil . getCurrentTimeFromDB ( ) . getTime ( ) ) ; final SystemConfiguration kernelConfig = EFapsSystemConfiguration . get ( ) ; final int minutes = kernelConfig . getAttributeValueAsInteger ( KernelSettings . LOGIN_TIME_RETRY ) ; final int maxtries = kernelConfig . getAttributeValueAsInteger ( KernelSettings . LOGIN_MAX_TRIES ) ; final int count = _count + 1 ; if ( minutes > 0 && _logintry . minusMinutes ( minutes ) . isBefore ( now ) ) { updateFalseLoginDB ( 1 ) ; } else { updateFalseLoginDB ( count ) ; } if ( maxtries > 0 && count > maxtries && getStatus ( ) ) { setStatusInDB ( false ) ; } } else { updateFalseLoginDB ( 1 ) ; } } | Method that sets the time and the number of failed logins . |
10,264 | private void updateFalseLoginDB ( final int _tries ) throws EFapsException { Connection con = null ; try { con = Context . getConnection ( ) ; Statement stmt = null ; final StringBuilder cmd = new StringBuilder ( ) ; try { cmd . append ( "update T_USERPERSON " ) . append ( "set LOGINTRY=" ) . append ( Context . getDbType ( ) . getCurrentTimeStamp ( ) ) . append ( ", LOGINTRIES=" ) . append ( _tries ) . append ( " where ID=" ) . append ( getId ( ) ) ; stmt = con . createStatement ( ) ; final int rows = stmt . executeUpdate ( cmd . toString ( ) ) ; if ( rows == 0 ) { Person . LOG . error ( "could not execute '" + cmd . toString ( ) + "' to update last login information for person '" + toString ( ) + "'" ) ; throw new EFapsException ( getClass ( ) , "updateLastLogin.NotUpdated" , cmd . toString ( ) , getName ( ) ) ; } } catch ( final SQLException e ) { Person . LOG . error ( "could not execute '" + cmd . toString ( ) + "' to update last login information for person '" + toString ( ) + "'" , e ) ; throw new EFapsException ( getClass ( ) , "updateLastLogin.SQLException" , e , cmd . toString ( ) , getName ( ) ) ; } finally { try { if ( stmt != null ) { stmt . close ( ) ; } } catch ( final SQLException e ) { throw new EFapsException ( getClass ( ) , "updateLastLogin.SQLException" , e , cmd . toString ( ) , getName ( ) ) ; } } con . commit ( ) ; con . close ( ) ; } catch ( final SQLException e ) { e . printStackTrace ( ) ; } } | Method to set the number of false Login tries in the eFaps - DataBase . |
10,265 | public Status setPassword ( final String _newPasswd ) throws EFapsException { final Type type = CIAdminUser . Person . getType ( ) ; if ( _newPasswd . length ( ) == 0 ) { throw new EFapsException ( getClass ( ) , "PassWordLength" , 1 , _newPasswd . length ( ) ) ; } final Update update = new Update ( type , "" + getId ( ) ) ; final Status status = update . add ( CIAdminUser . Person . Password , _newPasswd ) ; if ( status . isOk ( ) ) { update . execute ( ) ; update . close ( ) ; } else { Person . LOG . error ( "Password could not be set by the Update, due to restrictions " + "e.g. length???" ) ; throw new EFapsException ( getClass ( ) , "TODO" ) ; } return status ; } | The instance method sets the new password for the current context user . Before the new password is set some checks are made . |
10,266 | protected void readFromDB ( ) throws EFapsException { readFromDBAttributes ( ) ; this . roles . clear ( ) ; for ( final Role role : getRolesFromDB ( ) ) { add ( role ) ; } this . groups . clear ( ) ; for ( final Group group : getGroupsFromDB ( null ) ) { add ( group ) ; } this . companies . clear ( ) ; for ( final Company company : getCompaniesFromDB ( null ) ) { add ( company ) ; } this . associations . clear ( ) ; for ( final Association association : getAssociationsFromDB ( null ) ) { add ( association ) ; } } | The instance method reads all information from the database . |
10,267 | private void readFromDBAttributes ( ) throws EFapsException { Connection con = null ; try { con = Context . getConnection ( ) ; Statement stmt = null ; try { stmt = con . createStatement ( ) ; final StringBuilder cmd = new StringBuilder ( "select " ) ; for ( final AttrName attrName : Person . AttrName . values ( ) ) { cmd . append ( attrName . sqlColumn ) . append ( "," ) ; } cmd . append ( "0 as DUMMY " ) . append ( "from V_USERPERSON " ) . append ( "where V_USERPERSON.ID=" ) . append ( getId ( ) ) ; final ResultSet resultset = stmt . executeQuery ( cmd . toString ( ) ) ; if ( resultset . next ( ) ) { for ( final AttrName attrName : Person . AttrName . values ( ) ) { final String tmp = resultset . getString ( attrName . sqlColumn ) ; setAttrValue ( attrName , tmp == null ? null : tmp . trim ( ) ) ; } } resultset . close ( ) ; } catch ( final SQLException e ) { Person . LOG . error ( "read attributes for person with SQL statement is not " + "possible" , e ) ; throw new EFapsException ( Person . class , "readFromDBAttributes.SQLException" , e , getName ( ) , getId ( ) ) ; } finally { try { if ( stmt != null ) { stmt . close ( ) ; } con . commit ( ) ; } catch ( final SQLException e ) { Person . LOG . error ( "close of SQL statement is not possible" , e ) ; } } } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "could not read child type ids" , e ) ; } } } | All attributes from this person are read from the database . |
10,268 | public void setGroups ( final JAASSystem _jaasSystem , final Set < Group > _groups ) throws EFapsException { if ( _jaasSystem == null ) { throw new EFapsException ( getClass ( ) , "setGroups.nojaasSystem" , getName ( ) ) ; } if ( _groups == null ) { throw new EFapsException ( getClass ( ) , "setGroups.noGroups" , getName ( ) ) ; } for ( final Group group : _groups ) { add ( group ) ; } final Set < Group > groupsInDb = getGroupsFromDB ( _jaasSystem ) ; for ( final Group group : _groups ) { if ( ! groupsInDb . contains ( group ) ) { assignGroupInDb ( _jaasSystem , group ) ; } } for ( final Group group : groupsInDb ) { if ( ! _groups . contains ( group ) ) { unassignGroupInDb ( _jaasSystem , group ) ; } } } | The depending groups for the user are set for the given JAAS system . All groups are added to the loaded groups in the cache of this person . |
10,269 | public void assignGroupInDb ( final JAASSystem _jaasSystem , final Group _group ) throws EFapsException { assignToUserObjectInDb ( CIAdminUser . Person2Group . getType ( ) , _jaasSystem , _group ) ; } | For this person a group is assigned for the given JAAS system . |
10,270 | public void unassignGroupInDb ( final JAASSystem _jaasSystem , final Group _group ) throws EFapsException { unassignFromUserObjectInDb ( CIAdminUser . Person2Group . getType ( ) , _jaasSystem , _group ) ; } | The given group is unassigned for the given JAAS system from this person . |
10,271 | public static void reset ( final String _key ) throws EFapsException { final Person person ; if ( UUIDUtil . isUUID ( _key ) ) { person = Person . get ( UUID . fromString ( _key ) ) ; } else { person = Person . get ( _key ) ; } if ( person != null ) { InfinispanCache . get ( ) . < Long , Person > getCache ( Person . IDCACHE ) . remove ( person . getId ( ) ) ; InfinispanCache . get ( ) . < String , Person > getCache ( Person . NAMECACHE ) . remove ( person . getName ( ) ) ; if ( person . getUUID ( ) != null ) { InfinispanCache . get ( ) . < UUID , Person > getCache ( Person . UUIDCACHE ) . remove ( person . getUUID ( ) ) ; } } } | Reset a person . Meaning ti will be removed from all Caches . |
10,272 | public void preparePostUpload ( final List < Attachment > attachments ) { tempParts . clear ( ) ; if ( ! attachments . isEmpty ( ) ) { for ( Attachment a : attachments ) { if ( a . getError ( ) != null ) { errorParts . add ( createErrorPart ( a ) ) ; } else { publicParts . add ( createPart ( a ) ) ; } } } } | Replace temporary attachment parts with final parts with upload details or error message . |
10,273 | private Part createErrorPart ( Attachment a ) { return Part . builder ( ) . setName ( String . valueOf ( a . hashCode ( ) ) ) . setSize ( 0 ) . setType ( Attachment . LOCAL_PART_TYPE_ERROR ) . setUrl ( null ) . setData ( a . getError ( ) . getLocalizedMessage ( ) ) . build ( ) ; } | Create message part based on attachment upload error details . |
10,274 | private Part createTempPart ( Attachment a ) { return Part . builder ( ) . setName ( String . valueOf ( a . hashCode ( ) ) ) . setSize ( 0 ) . setType ( Attachment . LOCAL_PART_TYPE_UPLOADING ) . setUrl ( null ) . setData ( null ) . build ( ) ; } | Create message part based on attachment upload . This is a temporary message to indicate that one of the attachments for this message is being uploaded . |
10,275 | private Part createPart ( Attachment a ) { return Part . builder ( ) . setName ( a . getName ( ) != null ? a . getName ( ) : a . getId ( ) ) . setSize ( a . getSize ( ) ) . setType ( a . getType ( ) ) . setUrl ( a . getUrl ( ) ) . build ( ) ; } | Create message part based on attachment details . |
10,276 | public MessageToSend prepareMessageToSend ( ) { originalMessage . getParts ( ) . clear ( ) ; originalMessage . getParts ( ) . addAll ( publicParts ) ; return originalMessage ; } | Prepare message to be sent through messaging service . |
10,277 | public ChatMessage createFinalMessage ( MessageSentResponse response ) { return ChatMessage . builder ( ) . setMessageId ( response . getId ( ) ) . setSentEventId ( response . getEventId ( ) ) . setConversationId ( conversationId ) . setSentBy ( sender ) . setFromWhom ( new Sender ( sender , sender ) ) . setSentOn ( System . currentTimeMillis ( ) ) . setParts ( getAllParts ( ) ) . setMetadata ( originalMessage . getMetadata ( ) ) . build ( ) ; } | Create a final message for a conversation . At this point we know message id and sent event id . |
10,278 | private void addTables ( ) { for ( final SQLTable table : getType ( ) . getTables ( ) ) { if ( ! getTable2values ( ) . containsKey ( table ) ) { getTable2values ( ) . put ( table , new ArrayList < Value > ( ) ) ; } } } | Add all tables of the type to the expressions because for the type an insert must be made for all tables!!! |
10,279 | private void addCreateUpdateAttributes ( ) throws EFapsException { final Iterator < ? > iter = getType ( ) . getAttributes ( ) . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { final Map . Entry < ? , ? > entry = ( Map . Entry < ? , ? > ) iter . next ( ) ; final Attribute attr = ( Attribute ) entry . getValue ( ) ; final AttributeType attrType = attr . getAttributeType ( ) ; if ( attrType . isCreateUpdate ( ) ) { addInternal ( attr , false , ( Object ) null ) ; } if ( attr . getDefaultValue ( ) != null ) { addInternal ( attr , false , attr . getDefaultValue ( ) ) ; } } } | Add all attributes of the type which must be always updated and the default values . |
10,280 | public Insert setExchangeIds ( final Long _exchangeSystemId , final Long _exchangeId ) { this . exchangeSystemId = _exchangeSystemId ; this . exchangeId = _exchangeId ; return this ; } | Set the exchangeids for the new object . |
10,281 | public void executeWithoutTrigger ( ) throws EFapsException { final Context context = Context . getThreadContext ( ) ; ConnectionResource con = null ; try { con = context . getConnectionResource ( ) ; final SQLTable mainTable = getType ( ) . getMainTable ( ) ; final long id = executeOneStatement ( con , mainTable , getTable2values ( ) . get ( mainTable ) , 0 ) ; setInstance ( Instance . get ( getInstance ( ) . getType ( ) , id ) ) ; getInstance ( ) . setExchangeId ( this . exchangeId ) ; getInstance ( ) . setExchangeSystemId ( this . exchangeSystemId ) ; GeneralInstance . insert ( getInstance ( ) , con ) ; for ( final Entry < SQLTable , List < Value > > entry : getTable2values ( ) . entrySet ( ) ) { final SQLTable table = entry . getKey ( ) ; if ( ! table . equals ( mainTable ) && ! table . isReadOnly ( ) ) { executeOneStatement ( con , table , entry . getValue ( ) , id ) ; } } Queue . registerUpdate ( getInstance ( ) ) ; } finally { } } | The insert is done without calling triggers and check of access rights . |
10,282 | public static final Vector3D randVertex2d ( ) { float theta = random ( ( float ) ( Math . PI * 2.0 ) ) ; return new Vector3D ( Math . cos ( theta ) , Math . sin ( theta ) ) ; } | returns a random Vertex that represents a point on the unit circle |
10,283 | @ SuppressLint ( "UseSparseArrays" ) public void addStatusUpdate ( ChatMessageStatus status ) { int unique = ( status . getMessageId ( ) + status . getProfileId ( ) + status . getMessageStatus ( ) . name ( ) ) . hashCode ( ) ; if ( statusUpdates == null ) { statusUpdates = new HashMap < > ( ) ; } statusUpdates . put ( unique , status ) ; } | Update status list with a new status . |
10,284 | public static void put ( Map < String , Object > structure , String name , Object object ) { if ( name != null && object != null ) { structure . put ( name , object ) ; } } | Puts an object into a map |
10,285 | protected long createTaskInternal ( final String name , final String channel , final String data , final String key1 , final String key2 , final Long batchId , int postponeSec , TedStatus status ) { final String sqlLogId = "create_task" ; if ( status == null ) status = TedStatus . NEW ; String nextts = ( status == TedStatus . NEW ? dbType . sql . now ( ) + " + " + dbType . sql . intervalSeconds ( postponeSec ) : "null" ) ; String sql = " insert into tedtask (taskId, `system`, name, channel, bno, status, createTs, nextTs, retries, data, key1, key2, batchId)" + " values(null, '$sys', ?, ?, null, '$status', $now, $nextts, 0, ?, ?, ?, ?)" + " " ; sql = sql . replace ( "$nextTaskId" , dbType . sql . sequenceSql ( "SEQ_TEDTASK_ID" ) ) ; sql = sql . replace ( "$now" , dbType . sql . now ( ) ) ; sql = sql . replace ( "$sys" , thisSystem ) ; sql = sql . replace ( "$nextts" , nextts ) ; sql = sql . replace ( "$status" , status . toString ( ) ) ; final String finalSql = sql ; Long taskId = JdbcSelectTed . runInConn ( dataSource , new ExecInConn < Long > ( ) { public Long execute ( Connection connection ) throws SQLException { int res = JdbcSelectTedImpl . executeUpdate ( connection , finalSql , asList ( sqlParam ( name , JetJdbcParamType . STRING ) , sqlParam ( channel , JetJdbcParamType . STRING ) , sqlParam ( data , JetJdbcParamType . STRING ) , sqlParam ( key1 , JetJdbcParamType . STRING ) , sqlParam ( key2 , JetJdbcParamType . STRING ) , sqlParam ( batchId , JetJdbcParamType . LONG ) ) ) ; if ( res != 1 ) throw new IllegalStateException ( "expected 1 insert" ) ; String sql = "select last_insert_id()" ; return JdbcSelectTedImpl . selectSingleLong ( connection , sql , Collections . < SqlParam > emptyList ( ) ) ; } } ) ; logger . trace ( "Task {} {} created successfully. " , name , taskId ) ; return taskId ; } | taskid is autonumber in MySql |
10,286 | public static String escape ( String literal ) { StringBuilder sb = new StringBuilder ( ) ; for ( int ii = 0 ; ii < literal . length ( ) ; ii ++ ) { char cc = literal . charAt ( ii ) ; switch ( cc ) { case '[' : case ']' : case '(' : case ')' : case '\\' : case '-' : case '^' : case '*' : case '+' : case '?' : case '|' : case '.' : case '{' : case '}' : case '&' : case '$' : case ',' : sb . append ( "\\" ) . append ( cc ) ; break ; default : sb . append ( cc ) ; break ; } } return sb . toString ( ) ; } | Escapes all regex control characters returning expression suitable for literal parsing . |
10,287 | public boolean isMatch ( CharSequence text ) { try { if ( text . length ( ) == 0 ) { return acceptEmpty ; } InputReader reader = Input . getInstance ( text ) ; return isMatch ( reader ) ; } catch ( IOException ex ) { throw new IllegalArgumentException ( "can't happen" ) ; } } | Return true if text matches the regex |
10,288 | public boolean isMatch ( PushbackReader input , int size ) throws IOException { InputReader reader = Input . getInstance ( input , size ) ; return isMatch ( reader ) ; } | Return true if input matches the regex |
10,289 | public boolean isMatch ( InputReader reader ) throws IOException { int rc = match ( reader ) ; return ( rc == 1 && reader . read ( ) == - 1 ) ; } | Return true if input matches the regex . |
10,290 | public String match ( CharSequence text ) { try { if ( text . length ( ) == 0 ) { if ( acceptEmpty ) { return "" ; } else { throw new SyntaxErrorException ( "empty string not accepted" ) ; } } InputReader reader = Input . getInstance ( text ) ; int rc = match ( reader ) ; if ( rc == 1 && reader . read ( ) == - 1 ) { return reader . getString ( ) ; } else { throw new SyntaxErrorException ( "syntax error" + "\n" + reader . getLineNumber ( ) + ": " + reader . getLine ( ) + "\n" + pointer ( reader . getColumnNumber ( ) + 2 ) ) ; } } catch ( IOException ex ) { throw new IllegalArgumentException ( "can't happen" ) ; } } | Attempts to match input to regex |
10,291 | public String lookingAt ( CharSequence text ) { try { if ( text . length ( ) == 0 ) { if ( acceptEmpty ) { return "" ; } else { throw new SyntaxErrorException ( "empty string not accepted" ) ; } } InputReader reader = Input . getInstance ( text ) ; return lookingAt ( reader ) ; } catch ( IOException ex ) { throw new IllegalArgumentException ( "can't happen" ) ; } } | Matches the start of text and returns the matched string |
10,292 | public String replace ( CharSequence text , CharSequence replacement ) { try { if ( text . length ( ) == 0 ) { if ( acceptEmpty ) { return "" ; } } CharArrayWriter caw = new CharArrayWriter ( ) ; InputReader reader = Input . getInstance ( text ) ; ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer ( replacement ) ; replace ( reader , caw , fsp ) ; return caw . toString ( ) ; } catch ( IOException ex ) { throw new IllegalArgumentException ( "can't happen" , ex ) ; } } | Replaces regular expression matches in text with replacement string |
10,293 | public String replace ( CharSequence text , ObsoleteReplacer replacer ) throws IOException { if ( text . length ( ) == 0 ) { return "" ; } CharArrayWriter caw = new CharArrayWriter ( ) ; InputReader reader = Input . getInstance ( text ) ; replace ( reader , caw , replacer ) ; return caw . toString ( ) ; } | Replaces regular expression matches in text using replacer |
10,294 | public void replace ( PushbackReader in , int bufferSize , Writer out , String format ) throws IOException { InputReader reader = Input . getInstance ( in , bufferSize ) ; ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer ( format ) ; replace ( reader , out , fsp ) ; } | Writes in to out replacing every match with a string |
10,295 | public void replace ( PushbackReader in , int bufferSize , Writer out , ObsoleteReplacer replacer ) throws IOException { InputReader reader = Input . getInstance ( in , bufferSize ) ; replace ( reader , out , replacer ) ; } | Replaces regular expression matches in input using replacer |
10,296 | public static Regex literal ( String expression , Option ... options ) throws IOException { return compile ( escape ( expression ) , options ) ; } | Compiles a literal string into RegexImpl class . This is ok for testing . use RegexBuilder ant task for release classes |
10,297 | public static DFA < Integer > createDFA ( String expression , int reducer , Option ... options ) { NFA < Integer > nfa = createNFA ( new Scope < NFAState < Integer > > ( expression ) , expression , reducer , options ) ; DFA < Integer > dfa = nfa . constructDFA ( new Scope < DFAState < Integer > > ( expression ) ) ; return dfa ; } | Creates a DFA from regular expression |
10,298 | static < T > List < T > executeOraBlock ( Connection connection , String sql , Class < T > clazz , List < SqlParam > sqlParams ) throws SQLException { String cursorParam = null ; List < T > list = new ArrayList < T > ( ) ; CallableStatement stmt = null ; ResultSet resultSet = null ; try { stmt = connection . prepareCall ( sql ) ; cursorParam = stmtAssignSqlParams ( stmt , sqlParams ) ; boolean hasRs = stmt . execute ( ) ; if ( cursorParam != null ) { resultSet = ( ResultSet ) stmt . getObject ( cursorParam ) ; list = resultSetToList ( resultSet , clazz ) ; } } finally { try { if ( resultSet != null ) resultSet . close ( ) ; } catch ( Exception e ) { logger . error ( "Cannot close resultSet" , e ) ; } ; try { if ( stmt != null ) stmt . close ( ) ; } catch ( Exception e ) { logger . error ( "Cannot close statement" , e ) ; } ; } return list ; } | Execute sql block or stored procedure . If exists output parameter with type CURSOR then return resultSet as List of clazz type objects . |
10,299 | Observable < List < ChatConversationBase > > loadAllConversations ( ) { return Observable . create ( emitter -> storeFactory . execute ( new StoreTransaction < ChatStore > ( ) { protected void execute ( ChatStore store ) { store . open ( ) ; List < ChatConversationBase > conversations = store . getAllConversations ( ) ; store . close ( ) ; emitter . onNext ( conversations ) ; emitter . onCompleted ( ) ; } } ) , Emitter . BackpressureMode . LATEST ) ; } | Wraps loading all conversations from store implementation into an Observable . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.