idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
10,300
public void addGenInstSelectPart ( ) throws EFapsException { final Type type ; // if a previous select exists it is based on the previous select, // else it is based on the basic table if ( this . selectParts . size ( ) > 0 ) { type = this . selectParts . get ( this . selectParts . size ( ) - 1 ) . getType ( ) ; } else { type = this . query . getMainType ( ) ; } final GenInstSelectPart linkto = new GenInstSelectPart ( type ) ; this . selectParts . add ( linkto ) ; }
Add the select part to connect the general instances .
126
10
10,301
public void addAttributeSetSelectPart ( final String _attributeSet , final String _where ) throws EFapsException { final Type type ; // if a previous select exists it is based on the previous select, // else it is based on the basic table if ( this . selectParts . size ( ) > 0 ) { type = this . selectParts . get ( this . selectParts . size ( ) - 1 ) . getType ( ) ; } else { type = this . query . getMainType ( ) ; } try { final AttributeSet set = AttributeSet . find ( type . getName ( ) , _attributeSet ) ; final String linkFrom = set . getName ( ) + "#" + set . getAttributeName ( ) ; this . fromSelect = new LinkFromSelect ( linkFrom , getQuery ( ) . isCacheEnabled ( ) ? getQuery ( ) . getKey ( ) : null ) ; this . fromSelect . addWhere ( _where ) ; } catch ( final CacheReloadException e ) { OneSelect . LOG . error ( "Could not find AttributeSet for Type: {}, attribute: {}" , type . getName ( ) , _attributeSet ) ; } }
Adds the attribute set select part .
254
7
10,302
public void append2SQLFrom ( final SQLSelect _select ) throws EFapsException { // for attributes it must be evaluated if the attribute is inside a child table if ( this . valueSelect != null && "attribute" . equals ( this . valueSelect . getValueType ( ) ) ) { final Type type ; if ( this . selectParts . size ( ) > 0 ) { type = this . selectParts . get ( this . selectParts . size ( ) - 1 ) . getType ( ) ; } else { type = this . query . getMainType ( ) ; } Attribute attr = this . valueSelect . getAttribute ( ) ; if ( attr == null ) { attr = type . getAttribute ( ( ( AttributeValueSelect ) this . valueSelect ) . getAttrName ( ) ) ; } // if the attr is still null that means that the type does not have this attribute, so last // chance to find the attribute is to search in the child types if ( attr == null ) { for ( final Type childType : type . getChildTypes ( ) ) { attr = childType . getAttribute ( ( ( AttributeValueSelect ) this . valueSelect ) . getAttrName ( ) ) ; if ( attr != null ) { ( ( AttributeValueSelect ) this . valueSelect ) . setAttribute ( attr ) ; break ; } } } if ( attr != null && attr . getTable ( ) != null && ! attr . getTable ( ) . equals ( type . getMainTable ( ) ) ) { final ChildTableSelectPart childtable = new ChildTableSelectPart ( type , attr . getTable ( ) ) ; this . selectParts . add ( childtable ) ; } } for ( final ISelectPart sel : this . selectParts ) { this . tableIndex = sel . join ( this , _select , this . tableIndex ) ; } }
Method used to append to the from part of an SQL statement .
409
13
10,303
public int append2SQLSelect ( final SQLSelect _select , final int _colIndex ) throws EFapsException { final Type type ; if ( this . selectParts . size ( ) > 0 ) { type = this . selectParts . get ( this . selectParts . size ( ) - 1 ) . getType ( ) ; } else { type = this . query . getMainType ( ) ; } final int ret ; if ( this . valueSelect == null ) { ret = this . fromSelect . getMainOneSelect ( ) . getValueSelect ( ) . append2SQLSelect ( type , _select , this . tableIndex , _colIndex ) ; } else { ret = this . valueSelect . append2SQLSelect ( type , _select , this . tableIndex , _colIndex ) ; } return ret ; }
Method used to append to the select part of an SQL statement .
173
13
10,304
public void append2SQLWhere ( final SQLSelect _select ) throws EFapsException { for ( final ISelectPart part : this . selectParts ) { part . add2Where ( this , _select ) ; } }
Method used to append to the where part of an SQL statement .
46
13
10,305
private Object getObject ( final Object _object ) throws EFapsException { final Object ret ; // inside a fromobject the correct value must be set if ( this . fromSelect != null && _object instanceof Number ) { final List < Object > tmpList = new ArrayList <> ( ) ; final Long id = ( ( Number ) _object ) . longValue ( ) ; Iterator < Long > relIter = this . relIdList . iterator ( ) ; // chained linkfroms if ( ! getSelectParts ( ) . isEmpty ( ) && getSelectParts ( ) . get ( 0 ) instanceof LinkFromSelect . LinkFromSelectPart && ! ( ( ( LinkFromSelect . LinkFromSelectPart ) getSelectParts ( ) . get ( 0 ) ) . getType ( ) instanceof AttributeSet ) ) { relIter = this . idList . iterator ( ) ; } else { relIter = this . relIdList . iterator ( ) ; } final Iterator < Object > objIter = this . objectList . iterator ( ) ; while ( relIter . hasNext ( ) ) { final Long rel = relIter . next ( ) ; final Object obj = objIter . next ( ) ; if ( rel . equals ( id ) ) { tmpList . add ( obj ) ; } } if ( this . valueSelect == null ) { final List < Object > retTmp = new ArrayList <> ( ) ; for ( final Object obj : tmpList ) { retTmp . add ( this . fromSelect . getMainOneSelect ( ) . getObject ( obj ) ) ; } ret = retTmp . size ( ) > 0 ? retTmp . size ( ) > 1 ? retTmp : retTmp . get ( 0 ) : null ; } else { ret = this . valueSelect . getValue ( tmpList ) ; } } else { ret = this . getObject ( ) ; } return ret ; }
Get an object from a n to 1 Relation . Therefore the given object is used to filter only the valid values from the by the Database returned objects .
409
31
10,306
public Object getObject ( ) throws EFapsException { Object ret = null ; if ( this . valueSelect == null ) { // if the fromSelect has data if ( this . fromSelect . hasResult ( ) ) { // and there are more than one id the current object must not be null if ( this . idList . size ( ) > 1 && this . currentObject != null ) { ret = this . fromSelect . getMainOneSelect ( ) . getObject ( this . currentObject ) ; // or if there is only one id the first objectvalue must not be null } else if ( this . idList . size ( ) == 1 && this . objectList . get ( 0 ) != null ) { ret = this . fromSelect . getMainOneSelect ( ) . getObject ( this . currentObject ) ; } } } else { // if the currentObject is not null it means that the values are // retrieved by iteration through the object list if ( this . currentId != null ) { ret = this . valueSelect . getValue ( this . currentObject ) ; } else { ret = this . valueSelect . getValue ( this . objectList ) ; } } return ret ; }
Method to get the Object for this OneSelect .
250
10
10,307
@ SuppressWarnings ( "unchecked" ) public List < Instance > getInstances ( ) throws EFapsException { final List < Instance > ret = new ArrayList <> ( ) ; // no value select means, that the from select must be asked if ( this . valueSelect == null ) { ret . addAll ( this . fromSelect . getMainOneSelect ( ) . getInstances ( ) ) ; } else { // if an oid select was given the oid is evaluated if ( "oid" . equals ( this . valueSelect . getValueType ( ) ) ) { for ( final Object object : this . objectList ) { final Instance inst = Instance . get ( ( String ) this . valueSelect . getValue ( object ) ) ; if ( inst . isValid ( ) ) { ret . add ( inst ) ; } } } else { final List < Long > idTmp ; if ( this . valueSelect . getParentSelectPart ( ) != null && this . valueSelect . getParentSelectPart ( ) instanceof LinkToSelectPart ) { idTmp = ( List < Long > ) this . valueSelect . getParentSelectPart ( ) . getObject ( ) ; } else { idTmp = this . idList ; } for ( final Long id : idTmp ) { if ( id != null ) { ret . add ( Instance . get ( this . valueSelect . getAttribute ( ) . getParent ( ) , String . valueOf ( id ) ) ) ; } } } } return ret ; }
Method returns the instances this OneSelect has returned .
331
10
10,308
public void sortByInstanceList ( final List < Instance > _targetList , final Map < Instance , Integer > _currentList ) { final List < Long > idListNew = new ArrayList <> ( ) ; final List < Object > objectListNew = new ArrayList <> ( ) ; for ( final Instance instance : _targetList ) { if ( _currentList . containsKey ( instance ) ) { final Integer i = _currentList . get ( instance ) ; idListNew . add ( this . idList . get ( i ) ) ; objectListNew . add ( this . objectList . get ( i ) ) ; } } this . idList . clear ( ) ; this . idList . addAll ( idListNew ) ; this . objectList . clear ( ) ; this . objectList . addAll ( objectListNew ) ; }
Method sorts the object and idList .
183
8
10,309
public Long createTask ( String taskName , String data ) { return tedDriverImpl . createTask ( taskName , data , null , null , null ) ; }
create task - simple version
34
5
10,310
public Long createBatch ( String batchTaskName , String data , String key1 , String key2 , List < TedTask > tedTasks ) { return tedDriverImpl . createBatch ( batchTaskName , data , key1 , key2 , tedTasks ) ; }
create tasks by list and batch task for them . return batch taskId
59
14
10,311
public Long createEvent ( String taskName , String queueId , String data , String key2 ) { return tedDriverImpl . createEvent ( taskName , queueId , data , key2 ) ; }
create event in queue
42
4
10,312
public Long createEventAndTryExecute ( String taskName , String queueId , String data , String key2 ) { return tedDriverImpl . createEventAndTryExecute ( taskName , queueId , data , key2 ) ; }
create event in queue . If possible try to execute
50
10
10,313
public Long sendNotification ( String taskName , String data ) { return tedDriverImpl . sendNotification ( taskName , data ) ; }
send notification to instances
30
4
10,314
public void set ( double x , double y , double r , double radStart , double radEnd ) { this . x = x ; this . y = y ; this . w = r * 2 ; this . h = r * 2 ; this . radStart = radStart ; this . radEnd = radEnd ; }
Sets a Arc object using x and y - coordinate of the Arc width height start and end points of degree properties .
67
24
10,315
public void setCenterColor ( ColorSet colorSet ) { if ( this . centerColor == null ) { this . centerColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; } setGradation ( true ) ; this . centerColor = RGBColor . color ( colorSet ) ; }
Sets the colorSet of the center of this Arc .
69
12
10,316
public void setEdgeColor ( Color color ) { if ( edgeColor == null ) edgeColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; setGradation ( true ) ; this . edgeColor = color ; }
Sets the color of the edge of this Arc .
53
11
10,317
public void setEdgeColor ( ColorSet colorSet ) { if ( edgeColor == null ) edgeColor = new RGBColor ( 0.0 , 0.0 , 0.0 ) ; setGradation ( true ) ; this . edgeColor = RGBColor . color ( colorSet ) ; }
Sets the colorSet of the edge of this Arc .
63
12
10,318
private void addSubDimension ( final Facets _facets , final DimValue _dimValue , final String _dim , final String _path ) throws IOException { final FacetResult result = _facets . getTopChildren ( 1000 , _dim , _path ) ; if ( result != null ) { LOG . debug ( "FacetResult {}." , result ) ; for ( final LabelAndValue labelValue : result . labelValues ) { final DimValue dimValue = new DimValue ( ) . setLabel ( labelValue . label ) . setValue ( labelValue . value . intValue ( ) ) ; dimValue . setPath ( ArrayUtils . addAll ( _dimValue . getPath ( ) , result . path ) ) ; _dimValue . getChildren ( ) . add ( dimValue ) ; addSubDimension ( _facets , dimValue , _dim , _path + "/" + labelValue . label ) ; } } }
Recursive method to get the sub dimension .
202
9
10,319
private void checkAccess ( ) throws EFapsException { // check the access for the given instances final Map < Instance , Boolean > accessmap = new HashMap < Instance , Boolean > ( ) ; for ( final Entry < Type , List < Instance > > entry : this . typeMapping . entrySet ( ) ) { accessmap . putAll ( entry . getKey ( ) . checkAccess ( entry . getValue ( ) , AccessTypeEnums . SHOW . getAccessType ( ) ) ) ; } this . elements . entrySet ( ) . removeIf ( entry -> accessmap . size ( ) > 0 && ( ! accessmap . containsKey ( entry . getKey ( ) ) || ! accessmap . get ( entry . getKey ( ) ) ) ) ; }
Check access .
164
3
10,320
protected void recordMetricsForPool ( final MemoryPoolMXBean pool , final Metrics metrics ) { final MemoryUsage usage = pool . getUsage ( ) ; metrics . setGauge ( String . join ( "/" , ROOT_NAMESPACE , memoryTypeSegment ( pool . getType ( ) ) , MetricsUtil . convertToSnakeCase ( pool . getName ( ) ) , MEMORY_USED ) , usage . getUsed ( ) , Units . BYTE ) ; final long memoryMax = usage . getMax ( ) ; if ( memoryMax != - 1 ) { metrics . setGauge ( String . join ( "/" , ROOT_NAMESPACE , memoryTypeSegment ( pool . getType ( ) ) , MetricsUtil . convertToSnakeCase ( pool . getName ( ) ) , MEMORY_MAX ) , memoryMax , Units . BYTE ) ; } }
Records the metrics for a given pool . Useful if a deriving class filters the list of pools to collect .
198
23
10,321
public void setNode ( int number , double x , double y ) { if ( number <= 0 ) number = 0 ; if ( number >= 3 ) number = 3 ; this . points [ number * 3 ] = ( float ) x ; this . points [ number * 3 + 1 ] = ( float ) y ; this . points [ number * 3 + 2 ] = 0 ; set ( ) ; }
Sets x y z - coordinate of nodes of this Curve .
83
13
10,322
public void setNode ( int number , Vector3D v ) { if ( number <= 0 ) { number = 0 ; } else if ( 3 <= number ) { number = 3 ; } this . points [ number * 3 ] = ( float ) v . getX ( ) ; this . points [ number * 3 + 1 ] = ( float ) v . getY ( ) ; this . points [ number * 3 + 2 ] = ( float ) v . getZ ( ) ; set ( ) ; }
Sets coordinate of nodes of this Curve .
105
9
10,323
public double curvePoint ( XYZ vec , float t ) { double tmp = 0 ; switch ( vec ) { case X : tmp = catmullRom ( points [ 0 ] , points [ 3 ] , points [ 6 ] , points [ 9 ] , t ) ; break ; case Y : tmp = catmullRom ( points [ 1 ] , points [ 4 ] , points [ 7 ] , points [ 10 ] , t ) ; break ; default : break ; } return tmp ; }
Evaluates the curve at point t .
102
9
10,324
@ SuppressWarnings ( "unchecked" ) public < T > T getAttribute ( final Attribute _attribute ) throws EFapsException { return ( T ) getAttribute ( _attribute . getName ( ) ) ; }
Get the object returned by the given Attribute .
48
10
10,325
public AbstractPrintQuery addAttributeSet ( final String _setName ) throws EFapsException { final Type type = getMainType ( ) ; if ( type != null ) { final AttributeSet set = AttributeSet . find ( type . getName ( ) , _setName ) ; addAttributeSet ( set ) ; } return this ; }
Add an AttributeSet to the PrintQuery . It is used to get editable values from the eFaps DataBase .
72
26
10,326
public AbstractPrintQuery addAttributeSet ( final AttributeSet _set ) throws EFapsException { final String key = "linkfrom[" + _set . getName ( ) + "#" + _set . getAttributeName ( ) + "]" ; final OneSelect oneselect = new OneSelect ( this , key ) ; this . allSelects . add ( oneselect ) ; this . attr2OneSelect . put ( _set . getAttributeName ( ) , oneselect ) ; oneselect . analyzeSelectStmt ( ) ; for ( final String setAttrName : _set . getSetAttributes ( ) ) { if ( ! setAttrName . equals ( _set . getAttributeName ( ) ) ) { oneselect . getFromSelect ( ) . addOneSelect ( new OneSelect ( this , _set . getAttribute ( setAttrName ) ) ) ; } } oneselect . getFromSelect ( ) . getMainOneSelect ( ) . setAttribute ( _set . getAttribute ( _set . getAttributeName ( ) ) ) ; return this ; }
Add an AttributeSet to the PrintQuery . It is used to get editable values from the eFaps DataBase . The AttributeSet is internally transformed into an linkfrom query .
233
39
10,327
@ SuppressWarnings ( "unchecked" ) public < T > T getAttributeSet ( final String _setName ) throws EFapsException { final OneSelect oneselect = this . attr2OneSelect . get ( _setName ) ; Map < String , Object > ret = null ; if ( oneselect == null || oneselect . getFromSelect ( ) == null ) { AbstractPrintQuery . LOG . error ( "Could not get an AttributeSet for the name: '{}' in PrintQuery '{]'" , _setName , this ) ; } else if ( oneselect . getFromSelect ( ) . hasResult ( ) ) { ret = new HashMap <> ( ) ; // in an attributset the first one is fake boolean first = true ; for ( final OneSelect onsel : oneselect . getFromSelect ( ) . getAllSelects ( ) ) { if ( first ) { first = false ; } else { final ArrayList < Object > list = new ArrayList <> ( ) ; final Object object = onsel . getObject ( ) ; if ( object instanceof List < ? > ) { list . addAll ( ( List < ? > ) object ) ; } else { list . add ( object ) ; } ret . put ( onsel . getAttribute ( ) . getName ( ) , list ) ; } } } return ( T ) ret ; }
Get the object returned by the given name of an AttributeSet .
301
14
10,328
public Attribute getAttribute4Select ( final String _selectStmt ) { final OneSelect oneselect = this . selectStmt2OneSelect . get ( _selectStmt ) ; return oneselect == null ? null : oneselect . getAttribute ( ) ; }
Method to get the Attribute used for an select .
59
11
10,329
public List < Instance > getInstances4Select ( final String _selectStmt ) throws EFapsException { final OneSelect oneselect = this . selectStmt2OneSelect . get ( _selectStmt ) ; return oneselect == null ? new ArrayList <> ( ) : oneselect . getInstances ( ) ; }
Method to get the instances used for an select .
74
10
10,330
public boolean isList4Select ( final String _selectStmt ) throws EFapsException { final OneSelect oneselect = this . selectStmt2OneSelect . get ( _selectStmt ) ; return oneselect == null ? false : oneselect . isMultiple ( ) ; }
Method to determine it the select statement returns more than one value .
62
13
10,331
public Integer getNewTableIndex ( final String _tableName , final String _column , final Integer _relIndex , final Long _clazzId ) { this . tableIndex ++ ; this . sqlTable2Index . put ( _relIndex + "__" + _tableName + "__" + _column + ( _clazzId == null ? "" : "__" + _clazzId ) , this . tableIndex ) ; return this . tableIndex ; }
Get a new table index and add the table to the map of existing table indexes .
99
17
10,332
@ Override public void generate ( final Module module , final Element parent ) { final AppModule m = ( AppModule ) module ; if ( m . getDraft ( ) != null ) { final String draft = m . getDraft ( ) . booleanValue ( ) ? "yes" : "no" ; final Element control = new Element ( "control" , APP_NS ) ; control . addContent ( generateSimpleElement ( "draft" , draft ) ) ; parent . addContent ( control ) ; } if ( m . getEdited ( ) != null ) { final Element edited = new Element ( "edited" , APP_NS ) ; // Inclulde millis in date/time final SimpleDateFormat dateFormater = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" , Locale . US ) ; dateFormater . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; edited . addContent ( dateFormater . format ( m . getEdited ( ) ) ) ; parent . addContent ( edited ) ; } }
Generate JDOM element for module and add it to parent element
236
13
10,333
public void setCursor ( CursorMode cursorMode ) { Cursor c = CursorMode . getAWTCursor ( cursorMode ) ; if ( c . getType ( ) == panel . getCursor ( ) . getType ( ) ) return ; panel . setCursor ( c ) ; }
Change mouse cursor image
64
4
10,334
public static Key get4Instance ( final Instance _instance ) throws EFapsException { Key . LOG . debug ( "Retrieving Key for {}" , _instance ) ; final Key ret = new Key ( ) ; ret . setPersonId ( Context . getThreadContext ( ) . getPersonId ( ) ) ; final Type type = _instance . getType ( ) ; ret . setTypeId ( type . getId ( ) ) ; if ( type . isCompanyDependent ( ) ) { ret . setCompanyId ( Context . getThreadContext ( ) . getCompany ( ) . getId ( ) ) ; } Key . LOG . debug ( "Retrieved Key {}" , ret ) ; return ret ; }
Gets the for instance .
150
6
10,335
public T execute ( ) throws ApiException , IOException { return client . executeRequest ( this . builder , expectedCode , responseClass , needAuth ) ; }
Execute the REST request synchronously on the calling thread returning the result when the operation completes .
34
19
10,336
public Future < T > executeAsync ( final RestCallback < T > handler ) { return client . submit ( new Callable < T > ( ) { @ Override public T call ( ) throws Exception { try { final T result = execute ( ) ; handler . completed ( result , RestRequest . this ) ; return result ; } catch ( Exception e ) { handler . failed ( e , RestRequest . this ) ; throw e ; } } } ) ; }
Execute the REST request asynchronously and call the given handler when the operation completes . The handler runs on the REST client s executor service .
95
30
10,337
public Future < T > executeAsync ( ) { return client . submit ( new Callable < T > ( ) { @ Override public T call ( ) throws Exception { return execute ( ) ; } } ) ; }
Execute the REST request asynchronously .
45
9
10,338
public static Image getTypeIcon ( final Type _type ) throws EFapsException { Image ret = null ; if ( _type != null ) { ret = _type . getTypeIcon ( ) ; } return ret ; }
Returns for given type the type tree menu . If no type tree menu is defined for the type it is searched if for parent type a menu is defined .
46
31
10,339
protected void addAlwaysUpdateAttributes ( ) throws EFapsException { final Iterator < ? > iter = getInstance ( ) . 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 . isAlwaysUpdate ( ) ) { addInternal ( attr , false , ( Object [ ] ) null ) ; } } }
Add all attributes of the type which must be always updated .
148
12
10,340
public void executeWithoutTrigger ( ) throws EFapsException { if ( Update . STATUSOK . getStati ( ) . isEmpty ( ) ) { final Context context = Context . getThreadContext ( ) ; ConnectionResource con = null ; try { con = context . getConnectionResource ( ) ; for ( final Entry < SQLTable , List < Value > > entry : this . table2values . entrySet ( ) ) { final SQLUpdate update = Context . getDbType ( ) . newUpdate ( entry . getKey ( ) . getSqlTable ( ) , entry . getKey ( ) . getSqlColId ( ) , getInstance ( ) . getId ( ) ) ; // iterate in reverse order and only execute the ones that are not added yet, permitting // to overwrite the value for attributes by adding them later final ReverseListIterator < Value > iterator = new ReverseListIterator <> ( entry . getValue ( ) ) ; final Set < String > added = new HashSet <> ( ) ; while ( iterator . hasNext ( ) ) { final Value value = iterator . next ( ) ; final String colKey = value . getAttribute ( ) . getSqlColNames ( ) . toString ( ) ; if ( ! added . contains ( colKey ) ) { value . getAttribute ( ) . prepareDBUpdate ( update , value . getValues ( ) ) ; added . add ( colKey ) ; } } final Set < String > updatedColumns = update . execute ( con ) ; final Iterator < Entry < Attribute , Value > > attrIter = this . trigRelevantAttr2values . entrySet ( ) . iterator ( ) ; while ( attrIter . hasNext ( ) ) { final Entry < Attribute , Value > trigRelEntry = attrIter . next ( ) ; if ( trigRelEntry . getKey ( ) . getTable ( ) . equals ( entry . getKey ( ) ) ) { boolean updated = false ; for ( final String colName : trigRelEntry . getKey ( ) . getSqlColNames ( ) ) { if ( updatedColumns . contains ( colName ) ) { updated = true ; break ; } } if ( ! updated ) { attrIter . remove ( ) ; } } } } AccessCache . registerUpdate ( getInstance ( ) ) ; Queue . registerUpdate ( getInstance ( ) ) ; } catch ( final SQLException e ) { Update . LOG . error ( "Update of '" + this . instance + "' not possible" , e ) ; throw new EFapsException ( getClass ( ) , "executeWithoutTrigger.SQLException" , e , this . instance ) ; } } else { throw new EFapsException ( getClass ( ) , "executeWithout.StatusInvalid" , Update . STATUSOK . getStati ( ) ) ; } }
The update is done without calling triggers and check of access rights .
607
13
10,341
public boolean updateSearchFunctionIfNecessary ( CouchDbConnector db , String viewName , String searchFunction , String javascriptIndexFunctionBody ) { boolean updatePerformed = false ; String designDocName = viewName . startsWith ( DesignDocument . ID_PREFIX ) ? viewName : ( DesignDocument . ID_PREFIX + viewName ) ; Checksum chk = new CRC32 ( ) ; byte [ ] bytes = javascriptIndexFunctionBody . getBytes ( ) ; chk . update ( bytes , 0 , bytes . length ) ; long actualChk = chk . getValue ( ) ; if ( ! db . contains ( designDocName ) ) { // it doesn't exist, let's put one in DesignDocument doc = new DesignDocument ( designDocName ) ; db . create ( doc ) ; updateSearchFunction ( db , doc , searchFunction , javascriptIndexFunctionBody , actualChk ) ; updatePerformed = true ; } else { // make sure it's up to date DesignDocument doc = db . get ( DesignDocument . class , designDocName ) ; Number docChk = ( Number ) doc . getAnonymous ( ) . get ( getChecksumFieldName ( searchFunction ) ) ; if ( docChk == null || ! ( docChk . longValue ( ) == actualChk ) ) { log . info ( "Updating the index function" ) ; updateSearchFunction ( db , doc , searchFunction , javascriptIndexFunctionBody , actualChk ) ; updatePerformed = true ; } } return updatePerformed ; }
Ensures taht the given body of the index function matches that in the database otherwise update it .
331
22
10,342
private void updateSearchFunction ( CouchDbConnector db , DesignDocument doc , String searchFunctionName , String javascript , long jsChecksum ) { // get the 'fulltext' object from the design document, this is what couchdb-lucene uses to index couch Map < String , Map < String , String > > fullText = ( Map < String , Map < String , String > > ) doc . getAnonymous ( ) . get ( "fulltext" ) ; if ( fullText == null ) { fullText = new HashMap < String , Map < String , String > > ( ) ; doc . setAnonymous ( "fulltext" , fullText ) ; } // now grab the search function that the user wants to use to index couch Map < String , String > searchObject = fullText . get ( searchFunctionName ) ; if ( searchObject == null ) { searchObject = new HashMap < String , String > ( ) ; fullText . put ( searchFunctionName , searchObject ) ; } // now set the contents of the index function searchObject . put ( "index" , javascript ) ; // now set the checksum, so that we can make sure that we only update it when we need to doc . setAnonymous ( getChecksumFieldName ( searchFunctionName ) , jsChecksum ) ; // save out the document db . update ( doc ) ; }
Creates the design document that we use when searching . This contains the index function that is used by lucene in the future we will probably want to support customer specific instances as well as adding a checksum to the object so that we can test if an index needs to be upgraded
289
56
10,343
public void connect ( ) throws Exception { logger . debug ( "[connect] initializing new connection" ) ; synchronized ( webSocketHandler . getNotifyConnectionObject ( ) ) { webSocketConnectionManager . start ( ) ; try { webSocketHandler . getNotifyConnectionObject ( ) . wait ( TimeUnit . SECONDS . toMillis ( WEBSOCKET_TIMEOUT ) ) ; } catch ( InterruptedException e ) { throw new Exception ( "websocket connection not open" ) ; } if ( ! isConnected ( ) ) { throw new Exception ( "websocket connection timeout (uri = " + uriTemplate + ")" ) ; } } }
Initiate connection to Neo4j server .
143
10
10,344
public boolean isUsable ( ) { return isConnected ( ) && TimeUnit . MILLISECONDS . toMinutes ( new Date ( ) . getTime ( ) - lastUsage . getTime ( ) ) <= MAXIMUM_AGE_IN_MINUTES ; }
Gets whether this connection may still be used .
60
10
10,345
public void add ( long timestamp , String column , Object value ) { if ( ! ( value instanceof Long ) && ! ( value instanceof Integer ) && ! ( value instanceof Double ) && ! ( value instanceof Float ) && ! ( value instanceof Boolean ) && ! ( value instanceof String ) ) { throw new IllegalArgumentException ( "value must be of type: Long, Integer, Double, Float, Boolean, or String" ) ; } Map < String , Object > temp = new HashMap < String , Object > ( ) ; temp . put ( column , value ) ; add ( timestamp , temp ) ; }
Add a data row consisting of one column to the store at a particular time .
131
16
10,346
public void add ( String column , Object value ) { add ( System . currentTimeMillis ( ) , column , value ) ; }
Add a data row consisting of one column to the store at the current time .
28
16
10,347
public void add ( String [ ] columns , Object [ ] values ) { add ( System . currentTimeMillis ( ) , columns , values ) ; }
Add a data row to the batch with the current time .
32
12
10,348
public void add ( long timestamp , Map < String , Object > data ) { for ( String k : data . keySet ( ) ) { if ( ! columns . contains ( k ) ) { throw new UnknownFieldException ( k ) ; } } Map < String , Object > curr = this . rows . get ( timestamp ) ; if ( curr == null ) { this . rows . put ( timestamp , new HashMap < String , Object > ( data ) ) ; } else { curr . putAll ( data ) ; } }
Add a data row to the batch at a particular timestamp merging with previous values if needed .
112
18
10,349
public void merge ( DataStore other ) { if ( ! this . hasSameColumns ( other ) ) { throw new IllegalArgumentException ( "DataStore must have the same columns to merge" ) ; } this . rows . putAll ( other . rows ) ; }
Add the entirety of another DataStore into this one .
57
11
10,350
public TreeMap < Long , Map < String , Object > > getRows ( ) { return new TreeMap < Long , Map < String , Object > > ( this . rows ) ; }
Return the rows of this batch as a Map from time to a Map from column to value .
40
19
10,351
public boolean hasColumns ( Collection < String > columns ) { return columns != null && this . columns . equals ( new TreeSet < String > ( columns ) ) ; }
Check if this DataStore has the given columns .
36
10
10,352
public static DataStore fromJson ( final JSONObject json ) throws ParseException { DataStore ret ; JSONArray jsonCols = json . getJSONArray ( "fields" ) ; if ( ! "time" . equals ( jsonCols . get ( 0 ) ) ) { throw new JSONException ( "time must be the first item in 'fields'" ) ; } Set < String > cols = new HashSet < String > ( ) ; for ( int i = 1 ; i < jsonCols . length ( ) ; i ++ ) { cols . add ( jsonCols . getString ( i ) ) ; } ret = new DataStore ( cols ) ; JSONArray jsonData = json . getJSONArray ( "data" ) ; for ( int i = 0 ; i < jsonData . length ( ) ; i ++ ) { JSONArray row = jsonData . getJSONArray ( i ) ; Long ts = row . getLong ( 0 ) ; Map < String , Object > vals = new HashMap < String , Object > ( ) ; for ( int j = 1 ; j < row . length ( ) ; j ++ ) { vals . put ( jsonCols . getString ( j ) , row . get ( j ) ) ; } ret . rows . put ( ts , vals ) ; } return ret ; }
Create a DataStore object from JSON .
283
8
10,353
public JSONObject toJson ( ) { JSONObject ret = new JSONObject ( ) ; JSONArray columns = new JSONArray ( Arrays . asList ( new String [ ] { "time" } ) ) ; for ( String f : this . columns ) { columns . put ( f ) ; } ret . put ( KEY_COLUMNS , columns ) ; JSONArray data = new JSONArray ( ) ; ret . put ( KEY_ROWS , data ) ; for ( Long ts : rows . keySet ( ) ) { JSONArray row = new JSONArray ( ) ; row . put ( ts ) ; Map < String , Object > temp = rows . get ( ts ) ; for ( String f : this . columns ) { Object val = temp . get ( f ) ; row . put ( val != null ? val : JSONObject . NULL ) ; } data . put ( row ) ; } return ret ; }
Convert this batch into a JSON representation .
192
9
10,354
public void add ( final Field _field ) { this . fields . put ( _field . getId ( ) , _field ) ; this . fieldName2Field . put ( _field . getName ( ) , _field ) ; if ( _field . getReference ( ) != null && _field . getReference ( ) . length ( ) > 0 ) { final String ref = _field . getReference ( ) ; int index ; int end = 0 ; while ( ( index = ref . indexOf ( "$<" , end ) ) > 0 ) { index += 2 ; end = ref . indexOf ( ">" , index ) ; addFieldExpr ( ref . substring ( index , end ) ) ; } } _field . setCollectionUUID ( getUUID ( ) ) ; }
Method to add a Field to this Collection .
168
9
10,355
protected int addFieldExpr ( final String _expr ) { int ret = - 1 ; if ( getAllFieldExpr ( ) . containsKey ( _expr ) ) { ret = getFieldExprIndex ( _expr ) ; } else { getAllFieldExpr ( ) . put ( _expr , Integer . valueOf ( getSelIndexLen ( ) ) ) ; if ( getSelect ( ) == null ) { setSelect ( _expr ) ; } else { setSelect ( getSelect ( ) + "," + _expr ) ; } ret = getSelIndexLen ( ) ; this . selIndexLen ++ ; } return ret ; }
Add a field expression to the select statement and the hash table of all field expressions . The method returns the index of the field expression . If the field expression is already added the old index is returned so a expression is only added once .
137
47
10,356
private void readFromDB4Fields ( ) throws CacheReloadException { try { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminUserInterface . Field ) ; queryBldr . addWhereAttrEqValue ( CIAdminUserInterface . Field . Collection , getId ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminUserInterface . Field . Type , CIAdminUserInterface . Field . Name ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { final long id = multi . getCurrentInstance ( ) . getId ( ) ; final String name = multi . < String > getAttribute ( CIAdminUserInterface . Field . Name ) ; final Type type = multi . < Type > getAttribute ( CIAdminUserInterface . Field . Type ) ; final Field field ; if ( type . equals ( CIAdminUserInterface . FieldCommand . getType ( ) ) ) { field = new FieldCommand ( id , null , name ) ; } else if ( type . equals ( CIAdminUserInterface . FieldHeading . getType ( ) ) ) { field = new FieldHeading ( id , null , name ) ; } else if ( type . equals ( CIAdminUserInterface . FieldTable . getType ( ) ) ) { field = new FieldTable ( id , null , name ) ; } else if ( type . equals ( CIAdminUserInterface . FieldGroup . getType ( ) ) ) { field = new FieldGroup ( id , null , name ) ; } else if ( type . equals ( CIAdminUserInterface . FieldSet . getType ( ) ) ) { field = new FieldSet ( id , null , name ) ; } else if ( type . equals ( CIAdminUserInterface . FieldClassification . getType ( ) ) ) { field = new FieldClassification ( id , null , name ) ; } else if ( type . equals ( CIAdminUserInterface . FieldPicker . getType ( ) ) ) { field = new FieldPicker ( id , null , name ) ; } else { field = new Field ( id , null , name ) ; } field . readFromDB ( ) ; add ( field ) ; } } catch ( final EFapsException e ) { throw new CacheReloadException ( "could not read fields for '" + getName ( ) + "'" , e ) ; } }
Read all fields related to this collection object .
514
9
10,357
@ Path ( "setCompany" ) @ GET @ Produces ( { MediaType . APPLICATION_JSON , MediaType . TEXT_PLAIN } ) @ SuppressWarnings ( "checkstyle:illegalcatch" ) public Response setCompany ( @ QueryParam ( "company" ) final String _companyStr ) { try { final Company company ; if ( UUIDUtil . isUUID ( _companyStr ) ) { company = Company . get ( UUID . fromString ( _companyStr ) ) ; } else if ( StringUtils . isNumeric ( _companyStr ) ) { company = Company . get ( Long . parseLong ( _companyStr ) ) ; } else { company = Company . get ( _companyStr ) ; } if ( company != null && company . hasChildPerson ( Context . getThreadContext ( ) . getPerson ( ) ) ) { Context . getThreadContext ( ) . setUserAttribute ( Context . CURRENTCOMPANY , String . valueOf ( company . getId ( ) ) ) ; Context . getThreadContext ( ) . getUserAttributes ( ) . storeInDb ( ) ; Context . getThreadContext ( ) . setCompany ( company ) ; } } catch ( final NumberFormatException | EFapsException e ) { RestContext . LOG . error ( "Catched error" , e ) ; } return confirm ( ) ; }
Sets the company .
291
5
10,358
public synchronized void onServerAvailable ( final String id , final String role ) { logger . debug ( "[onServerAvailable] id = {}, role = {}" , id , role ) ; Server server = getServerById ( id ) ; boolean isMaster = role . equals ( "master" ) ; boolean isSlave = role . equals ( "slave" ) ; if ( server == null ) { return ; } if ( server . isAvailable ( ) ) { if ( server . isMaster ( ) && isMaster ) return ; if ( ! server . isMaster ( ) && isSlave ) return ; } if ( isMaster || isSlave ) { server . setAvailable ( true ) ; try { server . connect ( ) ; } catch ( Exception e ) { logger . error ( "[onServerAvailable]" , e ) ; } } server . setAvailable ( true ) ; if ( isMaster ) { setWriteServer ( server ) ; } refreshServers ( ) ; }
Adds a server to the list of available servers .
204
10
10,359
public synchronized void onServerUnavailable ( final String id ) { logger . debug ( "[onServerUnavailable] id = {}" , id ) ; Server server = getServerById ( id ) ; if ( server != null ) { server . setAvailable ( false ) ; refreshServers ( ) ; } }
Removes a server from the list of available servers .
64
11
10,360
public synchronized void onServerReconnected ( final String id , final String uri ) { logger . debug ( "[onServerReconnected] id = {}, uri = {}" , id , uri ) ; if ( id . length ( ) == 0 ) { Server server = getServerByUri ( uri ) ; server . register ( ) ; server . setAvailable ( true ) ; } refreshServers ( ) ; }
Add a server to the list of available servers .
94
10
10,361
protected Server getReadServer ( ) { Server [ ] servers = readServers ; return servers [ readSequence . incrementAndGet ( servers . length ) ] ; }
Gets an read server from the list of available servers using round robing load balancing .
35
18
10,362
@ Override public int [ ] calculateInDegrees ( ) { final int [ ] in_degrees = new int [ size ( ) ] ; for ( int i = 0 ; i < size ( ) ; ++ i ) { final IAdjacencyListPair < TVertex > p = pairAt ( i ) ; final TVertex d = p . getVertex ( ) ; for ( int j = 0 ; j < size ( ) ; ++ j ) { for ( IVertex dep : pairAt ( j ) . getOutNeighbors ( ) ) { if ( d . equals ( dep ) ) ++ in_degrees [ i ] ; } } } return in_degrees ; }
Calculates an integer array where the value at each index is the number of times that vertex is referenced elsewhere .
150
23
10,363
@ Override public void afterConnectionEstablished ( final WebSocketSession webSocketSession ) { logger . debug ( "[afterConnectionEstablished] id = {}" , webSocketSession . getId ( ) ) ; this . session = webSocketSession ; synchronized ( notifyConnectionObject ) { notifyConnectionObject . notifyAll ( ) ; } }
Is called after a websocket session was established .
70
10
10,364
@ Override public void afterConnectionClosed ( final WebSocketSession webSocketSession , final CloseStatus status ) { logger . debug ( "[afterConnectionClosed] id = " , webSocketSession . getId ( ) ) ; this . session = null ; if ( connectionListener != null ) { connectionListener . onConnectionClosed ( ) ; } }
Is called after a websocket session was closed .
74
10
10,365
@ Override public void handleTransportError ( final WebSocketSession webSocketSession , final Throwable exception ) throws Exception { if ( exception != null ) { logger . error ( "[handleTransportError]" , exception ) ; } }
Handles websocket transport errors
49
6
10,366
public void sendMessage ( final String message ) { try { session . sendMessage ( new TextMessage ( message ) ) ; } catch ( IOException e ) { logger . error ( "[sendTextMessage]" , e ) ; } }
Sends a text message using this object s websocket session .
48
13
10,367
public void sendMessage ( final byte [ ] message ) { try { session . sendMessage ( new BinaryMessage ( message ) ) ; } catch ( IOException e ) { logger . error ( "[sendBinaryMessage]" , e ) ; } }
Sends a binary message using this object s websocket session .
51
13
10,368
public Resource getStoreResource ( final Instance _instance , final Resource . StoreEvent _event ) throws EFapsException { Resource storeRsrc = null ; final Store store = Store . get ( _instance . getType ( ) . getStoreId ( ) ) ; storeRsrc = store . getResource ( _instance ) ; storeRsrc . open ( _event ) ; this . storeStore . add ( storeRsrc ) ; return storeRsrc ; }
Method to get the sore resource .
96
7
10,369
public String getParameter ( final String _key ) { String value = null ; if ( this . parameters != null ) { final String [ ] values = this . parameters . get ( _key ) ; if ( values != null && values . length > 0 ) { value = values [ 0 ] ; } } return value ; }
Method to get a parameter from the context .
67
9
10,370
public Object setRequestAttribute ( final String _key , final Object _value ) { return this . requestAttributes . put ( _key , _value ) ; }
Associates the specified value with the specified key in the request attributes . If the request attributes previously contained a mapping for this key the old value is replaced by the specified value .
33
36
10,371
public Object setSessionAttribute ( final String _key , final Object _value ) { return this . sessionAttributes . put ( _key , _value ) ; }
Associates the specified value with the specified key in the session attributes . If the session attributes previously contained a mapping for this key the old value is replaced by the specified value .
33
36
10,372
public UserAttributesSet getUserAttributes ( ) throws EFapsException { if ( containsSessionAttribute ( UserAttributesSet . CONTEXTMAPKEY ) ) { return ( UserAttributesSet ) getSessionAttribute ( UserAttributesSet . CONTEXTMAPKEY ) ; } else { throw new EFapsException ( Context . class , "getUserAttributes.NoSessionAttribute" ) ; } }
Method to get the UserAttributesSet of the user of this context .
77
14
10,373
public void setCompany ( final Company _company ) throws CacheReloadException { if ( _company == null ) { this . companyId = null ; } else { this . companyId = _company . getId ( ) ; } }
Set the Company currently valid for this context .
49
9
10,374
public static Context getThreadContext ( ) throws EFapsException { Context context = Context . THREADCONTEXT . get ( ) ; if ( context == null ) { context = Context . INHERITTHREADCONTEXT . get ( ) ; } if ( context == null ) { throw new EFapsException ( Context . class , "getThreadContext.NoContext4ThreadDefined" ) ; } return context ; }
The method checks if for the current thread a context object is defined . This found context object is returned .
87
21
10,375
public static void save ( ) throws EFapsException { try { Context . TRANSMANAG . commit ( ) ; Context . TRANSMANAG . begin ( ) ; final Context context = Context . getThreadContext ( ) ; context . connectionResource = null ; context . setTransaction ( Context . TRANSMANAG . getTransaction ( ) ) ; } catch ( final SecurityException e ) { throw new EFapsException ( Context . class , "save.SecurityException" , e ) ; } catch ( final IllegalStateException e ) { throw new EFapsException ( Context . class , "save.IllegalStateException" , e ) ; } catch ( final RollbackException e ) { throw new EFapsException ( Context . class , "save.RollbackException" , e ) ; } catch ( final HeuristicMixedException e ) { throw new EFapsException ( Context . class , "save.HeuristicMixedException" , e ) ; } catch ( final HeuristicRollbackException e ) { throw new EFapsException ( Context . class , "save.HeuristicRollbackException" , e ) ; } catch ( final SystemException e ) { throw new EFapsException ( Context . class , "save.SystemException" , e ) ; } catch ( final NotSupportedException e ) { throw new EFapsException ( Context . class , "save.NotSupportedException" , e ) ; } }
Save the Context by committing and beginning a new Transaction .
293
11
10,376
public static boolean isTMActive ( ) throws EFapsException { try { return Context . TRANSMANAG . getStatus ( ) == Status . STATUS_ACTIVE ; } catch ( final SystemException e ) { throw new EFapsException ( Context . class , "isTMActive.SystemException" , e ) ; } }
Is the status of transaction manager active?
70
8
10,377
public static boolean isTMNoTransaction ( ) throws EFapsException { try { return Context . TRANSMANAG . getStatus ( ) == Status . STATUS_NO_TRANSACTION ; } catch ( final SystemException e ) { throw new EFapsException ( Context . class , "isTMNoTransaction.SystemException" , e ) ; } }
Is a transaction associated with a target object for transaction manager?
73
12
10,378
public static boolean isTMMarkedRollback ( ) throws EFapsException { try { return Context . TRANSMANAG . getStatus ( ) == Status . STATUS_MARKED_ROLLBACK ; } catch ( final SystemException e ) { throw new EFapsException ( Context . class , "isTMMarkedRollback.SystemException" , e ) ; } }
Is the status of transaction manager marked roll back?
79
10
10,379
public static void reset ( ) throws StartupException { try { final InitialContext initCtx = new InitialContext ( ) ; final javax . naming . Context envCtx = ( javax . naming . Context ) initCtx . lookup ( "java:comp/env" ) ; Context . DBTYPE = ( AbstractDatabase < ? > ) envCtx . lookup ( INamingBinds . RESOURCE_DBTYPE ) ; Context . DATASOURCE = ( DataSource ) envCtx . lookup ( INamingBinds . RESOURCE_DATASOURCE ) ; Context . TRANSMANAG = ( TransactionManager ) envCtx . lookup ( INamingBinds . RESOURCE_TRANSMANAG ) ; try { Context . TRANSMANAGTIMEOUT = 0 ; final Map < ? , ? > props = ( Map < ? , ? > ) envCtx . lookup ( INamingBinds . RESOURCE_CONFIGPROPERTIES ) ; if ( props != null ) { final String transactionTimeoutString = ( String ) props . get ( IeFapsProperties . TRANSACTIONTIMEOUT ) ; if ( transactionTimeoutString != null ) { Context . TRANSMANAGTIMEOUT = Integer . parseInt ( transactionTimeoutString ) ; } } } catch ( final NamingException e ) { // this is actual no error, so nothing is presented Context . TRANSMANAGTIMEOUT = 0 ; } } catch ( final NamingException e ) { throw new StartupException ( "eFaps context could not be initialized" , e ) ; } }
Resets the context to current defined values in the Javax naming environment .
328
15
10,380
public boolean execute ( final OneSelect _onesel ) throws EFapsException { this . hasResult = executeOneCompleteStmt ( createSQLStatement ( _onesel ) , getAllSelects ( ) ) ; if ( this . hasResult ) { for ( final OneSelect onesel : getAllSelects ( ) ) { if ( onesel . getFromSelect ( ) != null && ! onesel . getFromSelect ( ) . equals ( this ) ) { onesel . getFromSelect ( ) . execute ( onesel ) ; } } } return this . hasResult ; }
Execute the from select for the given instance .
122
10
10,381
private List < Type > getAllChildTypes ( final Type _parent ) throws CacheReloadException { final List < Type > ret = new ArrayList <> ( ) ; for ( final Type child : _parent . getChildTypes ( ) ) { ret . addAll ( getAllChildTypes ( child ) ) ; ret . add ( child ) ; } return ret ; }
Recursive method to get all child types for a type .
78
12
10,382
public static JasperDesign getJasperDesign ( final Instance _instance ) throws EFapsException { final Checkout checkout = new Checkout ( _instance ) ; final InputStream source = checkout . execute ( ) ; JasperDesign jasperDesign = null ; try { JasperUtil . LOG . debug ( "Loading JasperDesign for :{}" , _instance ) ; final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext . getInstance ( ) ; final JRXmlLoader loader = new JRXmlLoader ( reportContext , JRXmlDigesterFactory . createDigester ( reportContext ) ) ; jasperDesign = loader . loadXML ( source ) ; } catch ( final ParserConfigurationException e ) { throw new EFapsException ( JasperUtil . class , "getJasperDesign" , e ) ; } catch ( final SAXException e ) { throw new EFapsException ( JasperUtil . class , "getJasperDesign" , e ) ; } catch ( final JRException e ) { throw new EFapsException ( JasperUtil . class , "getJasperDesign" , e ) ; } return jasperDesign ; }
Get a JasperDesign for an instance .
245
8
10,383
@ SuppressWarnings ( "unckecked" ) public static Class < ? > getRawType ( Type type ) { if ( type instanceof Class < ? > ) { // type is a normal class. return ( Class < ? > ) type ; } else if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; // I'm not exactly sure why getRawType() returns Type instead of Class. // Neal isn't either but suspects some pathological case related // to nested classes exists. Type rawType = parameterizedType . getRawType ( ) ; checkArgument ( rawType instanceof Class , "Expected a Class, but <%s> is of type %s" , type , type . getClass ( ) . getName ( ) ) ; //noinspection ConstantConditions return ( Class < ? > ) rawType ; } else if ( type instanceof GenericArrayType ) { Type componentType = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; return Array . newInstance ( getRawType ( componentType ) , 0 ) . getClass ( ) ; } else if ( type instanceof TypeVariable ) { // we could use the variable's bounds, but that'll won't work if there are multiple. // having a raw type that's more general than necessary is okay return Object . class ; } else { throw new IllegalArgumentException ( "Expected a Class, ParameterizedType, or " + "GenericArrayType, but <" + type + "> is of type " + type . getClass ( ) . getName ( ) ) ; } }
Copy paste from Guice MoreTypes
352
7
10,384
public TaskRec eventQueueReserveTask ( long taskId ) { String sqlLogId = "reserve_task" ; String sql = "update tedtask set status = 'WORK', startTs = $now, nextTs = null" + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid in (" + " select taskid from tedtask " + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid = ?" + " for update skip locked" + ") returning tedtask.*" ; sql = sql . replace ( "$now" , dbType . sql . now ( ) ) ; sql = sql . replace ( "$sys" , thisSystem ) ; List < TaskRec > tasks = selectData ( sqlLogId , sql , TaskRec . class , asList ( sqlParam ( taskId , JetJdbcParamType . LONG ) ) ) ; return tasks . isEmpty ( ) ? null : tasks . get ( 0 ) ; }
used in eventQueue
220
4
10,385
public static void initialize ( ) { if ( InfinispanCache . get ( ) . exists ( Field . IDCACHE ) ) { InfinispanCache . get ( ) . < Long , Field > getCache ( Field . IDCACHE ) . clear ( ) ; } else { InfinispanCache . get ( ) . < Long , Field > getCache ( Field . IDCACHE ) ; InfinispanCache . get ( ) . < Long , Field > getCache ( Field . IDCACHE ) . addListener ( new CacheLogListener ( Field . LOG ) ) ; } }
Reset the cache .
127
5
10,386
public void configure ( ) throws LRException { // Trim or nullify strings nodeHost = StringUtil . nullifyBadInput ( nodeHost ) ; publishAuthUser = StringUtil . nullifyBadInput ( publishAuthUser ) ; publishAuthPassword = StringUtil . nullifyBadInput ( publishAuthPassword ) ; // Throw an exception if any of the required fields are null if ( nodeHost == null ) { throw new LRException ( LRException . NULL_FIELD ) ; } // Throw an error if the batch size is zero if ( batchSize == 0 ) { throw new LRException ( LRException . BATCH_ZERO ) ; } this . batchSize = batchSize ; this . publishFullUrl = publishProtocol + "://" + nodeHost + publishServiceUrl ; this . publishAuthUser = publishAuthUser ; this . publishAuthPassword = publishAuthPassword ; this . configured = true ; }
Attempt to configure the exporter with the values used in the constructor This must be called before an exporter can be used and after any setting of configuration values
202
31
10,387
public void addDocument ( LREnvelope envelope ) throws LRException { if ( ! configured ) { throw new LRException ( LRException . NOT_CONFIGURED ) ; } docs . add ( envelope . getSendableData ( ) ) ; }
Adds an envelope to the exporter
60
7
10,388
public void forward ( String controllerName ) throws Throwable { SilentGo instance = SilentGo . me ( ) ; ( ( ActionChain ) instance . getConfig ( ) . getActionChain ( ) . getObject ( ) ) . doAction ( instance . getConfig ( ) . getCtx ( ) . get ( ) . getActionParam ( ) ) ; }
forward to another controller
75
4
10,389
@ Override public void characters ( char [ ] ch , int start , int length ) throws SAXException { if ( vIsOpen ) { value . append ( ch , start , length ) ; } if ( fIsOpen ) { formula . append ( ch , start , length ) ; } if ( hfIsOpen ) { headerFooter . append ( ch , start , length ) ; } }
Captures characters only if a suitable element is open . Originally was just v ; extended for inlineStr also .
84
22
10,390
private void checkForEmptyCellComments ( XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType type ) { if ( commentCellRefs != null && ! commentCellRefs . isEmpty ( ) ) { // If we've reached the end of the sheet data, output any // comments we haven't yet already handled if ( type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . END_OF_SHEET_DATA ) { while ( ! commentCellRefs . isEmpty ( ) ) { outputEmptyCellComment ( commentCellRefs . remove ( ) ) ; } return ; } // At the end of a row, handle any comments for "missing" rows before us if ( this . cellRef == null ) { if ( type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . END_OF_ROW ) { while ( ! commentCellRefs . isEmpty ( ) ) { if ( commentCellRefs . peek ( ) . getRow ( ) == rowNum ) { outputEmptyCellComment ( commentCellRefs . remove ( ) ) ; } else { return ; } } return ; } else { throw new IllegalStateException ( "Cell ref should be null only if there are only empty cells in the row; rowNum: " + rowNum ) ; } } CellAddress nextCommentCellRef ; do { CellAddress cellRef = new CellAddress ( this . cellRef ) ; CellAddress peekCellRef = commentCellRefs . peek ( ) ; if ( type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . CELL && cellRef . equals ( peekCellRef ) ) { // remove the comment cell ref from the list if we're about to handle it alongside the cell content commentCellRefs . remove ( ) ; return ; } else { // fill in any gaps if there are empty cells with comment mixed in with non-empty cells int comparison = peekCellRef . compareTo ( cellRef ) ; if ( comparison > 0 && type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . END_OF_ROW && peekCellRef . getRow ( ) <= rowNum ) { nextCommentCellRef = commentCellRefs . remove ( ) ; outputEmptyCellComment ( nextCommentCellRef ) ; } else if ( comparison < 0 && type == XSSFSheetXMLHandlerPlus . EmptyCellCommentsCheckType . CELL && peekCellRef . getRow ( ) <= rowNum ) { nextCommentCellRef = commentCellRefs . remove ( ) ; outputEmptyCellComment ( nextCommentCellRef ) ; } else { nextCommentCellRef = null ; } } } while ( nextCommentCellRef != null && ! commentCellRefs . isEmpty ( ) ) ; } }
Do a check for and output comments in otherwise empty cells .
596
12
10,391
private void outputEmptyCellComment ( CellAddress cellRef ) { XSSFComment comment = commentsTable . findCellComment ( cellRef ) ; output . cell ( cellRef . formatAsString ( ) , null , comment ) ; }
Output an empty - cell comment .
50
7
10,392
public String format ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return "geometry" + index . getValue ( ) + "." + format ( index . getChild ( ) ) ; } switch ( index . getType ( ) ) { case TYPE_VERTEX : return "vertex" + index . getValue ( ) ; case TYPE_EDGE : return "edge" + index . getValue ( ) ; default : return "geometry" + index . getValue ( ) ; } }
Format a given geometry index creating something like geometry2 . vertex1 .
111
14
10,393
public Coordinate getVertex ( Geometry geometry , GeometryIndex index ) throws GeometryIndexNotFoundException { if ( index . hasChild ( ) ) { if ( geometry . getGeometries ( ) != null && geometry . getGeometries ( ) . length > index . getValue ( ) ) { return getVertex ( geometry . getGeometries ( ) [ index . getValue ( ) ] , index . getChild ( ) ) ; } throw new GeometryIndexNotFoundException ( "Could not match index with given geometry" ) ; } if ( index . getType ( ) == GeometryIndexType . TYPE_VERTEX && geometry . getCoordinates ( ) != null && geometry . getCoordinates ( ) . length > index . getValue ( ) && index . getValue ( ) >= 0 ) { return geometry . getCoordinates ( ) [ index . getValue ( ) ] ; } throw new GeometryIndexNotFoundException ( "Could not match index with given geometry" ) ; }
Given a certain geometry get the vertex the index points to . This only works if the index actually points to a vertex .
216
24
10,394
public boolean isVertex ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return isVertex ( index . getChild ( ) ) ; } return index . getType ( ) == GeometryIndexType . TYPE_VERTEX ; }
Does the given index point to a vertex or not? We look at the deepest level to check this .
55
21
10,395
public boolean isEdge ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return isEdge ( index . getChild ( ) ) ; } return index . getType ( ) == GeometryIndexType . TYPE_EDGE ; }
Does the given index point to an edge or not? We look at the deepest level to check this .
53
21
10,396
public boolean isGeometry ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return isGeometry ( index . getChild ( ) ) ; } return index . getType ( ) == GeometryIndexType . TYPE_GEOMETRY ; }
Does the given index point to a sub - geometry or not? We look at the deepest level to check this .
57
23
10,397
public GeometryIndexType getType ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return getType ( index . getChild ( ) ) ; } return index . getType ( ) ; }
Get the type of sub - part the given index points to . We look at the deepest level to check this .
46
23
10,398
public String getGeometryType ( Geometry geometry , GeometryIndex index ) throws GeometryIndexNotFoundException { if ( index != null && index . getType ( ) == GeometryIndexType . TYPE_GEOMETRY ) { if ( geometry . getGeometries ( ) != null && geometry . getGeometries ( ) . length > index . getValue ( ) ) { return getGeometryType ( geometry . getGeometries ( ) [ index . getValue ( ) ] , index . getChild ( ) ) ; } else { throw new GeometryIndexNotFoundException ( "Can't find the geometry referred to in the given index." ) ; } } return geometry . getGeometryType ( ) ; }
What is the geometry type of the sub - geometry pointed to by the given index? If the index points to a vertex or edge the geometry type at the parent level is returned .
153
36
10,399
public int getValue ( GeometryIndex index ) { if ( index . hasChild ( ) ) { return getValue ( index . getChild ( ) ) ; } return index . getValue ( ) ; }
Returns the value of the innermost child index .
43
10