idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
9,800
ComapiConfig buildComapiConfig ( ) { return new ComapiConfig ( ) . apiSpaceId ( apiSpaceId ) . authenticator ( authenticator ) . logConfig ( logConfig ) . apiConfiguration ( apiConfig ) . logSizeLimitKilobytes ( logSizeLimit ) . pushMessageListener ( pushMessageListener ) . fcmEnabled ( fcmEnabled ) ; }
Build config for foundation SDK initialisation .
9,801
int matchLength ( List < CharRange > prefix ) { DFAState < T > state = this ; int len = 0 ; for ( CharRange range : prefix ) { state = state . transit ( range ) ; if ( state == null ) { break ; } len ++ ; } return len ; }
Returns true if dfa starting from this state can accept a prefix constructed from a list of ranges
9,802
public int getTransitionSelectivity ( ) { int count = 0 ; for ( Transition < DFAState < T > > t : transitions . values ( ) ) { CharRange range = t . getCondition ( ) ; count += range . getTo ( ) - range . getFrom ( ) ; } return count / transitions . size ( ) ; }
Calculates a value of how selective transitions are from this state . Returns 1 if all ranges accept exactly one character . Greater number means less selectivity
9,803
public boolean hasBoundaryMatches ( ) { for ( Transition < DFAState < T > > t : transitions . values ( ) ) { CharRange range = t . getCondition ( ) ; if ( range . getFrom ( ) < 0 ) { return true ; } } return false ; }
Return true if one of transition ranges is a boundary match .
9,804
void optimizeTransitions ( ) { HashMap < DFAState < T > , RangeSet > hml = new HashMap < > ( ) ; for ( Transition < DFAState < T > > t : transitions . values ( ) ) { RangeSet rs = hml . get ( t . getTo ( ) ) ; if ( rs == null ) { rs = new RangeSet ( ) ; hml . put ( t . getTo ( ) , rs ) ; } rs . add ( t . getCondition ( ) ) ; } transitions . clear ( ) ; for ( DFAState < T > dfa : hml . keySet ( ) ) { RangeSet rs = RangeSet . merge ( hml . get ( dfa ) ) ; for ( CharRange r : rs ) { addTransition ( r , dfa ) ; } } }
Optimizes transition by merging ranges
9,805
RangeSet possibleMoves ( ) { List < RangeSet > list = new ArrayList < > ( ) ; for ( NFAState < T > nfa : nfaSet ) { list . add ( nfa . getConditions ( ) ) ; } return RangeSet . split ( list ) ; }
Return a RangeSet containing all ranges
9,806
void removeDeadEndTransitions ( ) { Iterator < CharRange > it = transitions . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { CharRange r = it . next ( ) ; if ( transitions . get ( r ) . getTo ( ) . isDeadEnd ( ) ) { it . remove ( ) ; } } }
Removes transition to states that doesn t contain any outbound transition and that are not accepting states
9,807
boolean isDeadEnd ( ) { if ( isAccepting ( ) ) { return false ; } for ( Transition < DFAState < T > > next : transitions . values ( ) ) { if ( next . getTo ( ) != this ) { return false ; } } return true ; }
Returns true if state doesn t contain any outbound transition and is not accepting state
9,808
Set < NFAState < T > > nfaTransitsFor ( CharRange condition ) { Set < NFAState < T > > nset = new NumSet < > ( ) ; for ( NFAState < T > nfa : nfaSet ) { nset . addAll ( nfa . transit ( condition ) ) ; } return nset ; }
Returns a set of nfA states to where it is possible to move by nfa transitions .
9,809
void addTransition ( CharRange condition , DFAState < T > to ) { Transition < DFAState < T > > t = new Transition < > ( condition , this , to ) ; t = transitions . put ( t . getCondition ( ) , t ) ; assert t == null ; edges . add ( to ) ; to . inStates . add ( this ) ; }
Adds a new transition
9,810
private void load ( ) throws EFapsException { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminCommon . MsgPhraseConfigAbstract ) ; queryBldr . addWhereAttrEqValue ( CIAdminCommon . MsgPhraseConfigAbstract . AbstractLink , getId ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . CompanyLink , CIAdminCommon . MsgPhraseConfigAbstract . LanguageLink , CIAdminCommon . MsgPhraseConfigAbstract . Value , CIAdminCommon . MsgPhraseConfigAbstract . Int1 ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { AbstractConfig conf = null ; if ( multi . getCurrentInstance ( ) . getType ( ) . isCIType ( CIAdminCommon . MsgPhraseArgument ) ) { conf = new Argument ( ) ; ( ( Argument ) conf ) . setIndex ( multi . < Integer > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . Int1 ) ) ; arguments . add ( ( Argument ) conf ) ; } else if ( multi . getCurrentInstance ( ) . getType ( ) . isCIType ( CIAdminCommon . MsgPhraseLabel ) ) { conf = new Label ( ) ; labels . add ( ( Label ) conf ) ; } if ( conf == null ) { LOG . error ( "Wrong type: " , this ) ; } else { conf . setCompanyId ( multi . < Long > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . CompanyLink ) ) ; conf . setLanguageId ( multi . < Long > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . LanguageLink ) ) ; conf . setValue ( multi . < String > getAttribute ( CIAdminCommon . MsgPhraseConfigAbstract . Value ) ) ; } } }
load the phrase .
9,811
void processBatchWaitTasks ( ) { Channel channel = context . registry . getChannelOrSystem ( Model . CHANNEL_BATCH ) ; int maxTask = context . taskManager . calcChannelBufferFree ( channel ) ; Map < String , Integer > channelSizes = new HashMap < String , Integer > ( ) ; channelSizes . put ( Model . CHANNEL_BATCH , maxTask ) ; List < TaskRec > batches = context . tedDao . reserveTaskPortion ( channelSizes ) ; if ( batches . isEmpty ( ) ) return ; for ( final TaskRec batchTask : batches ) { channel . workers . execute ( new TedRunnable ( batchTask ) { public void run ( ) { processBatchWaitTask ( batchTask ) ; } } ) ; } }
if finished then move this batchTask to his channel and then will be processed as regular task
9,812
public boolean send ( Whisper < ? > whisper ) { if ( isShutdown . get ( ) ) return false ; final ArrayDeque < Whisper < ? > > localQueue = ref . get ( ) ; if ( ! localQueue . isEmpty ( ) ) { localQueue . addLast ( whisper ) ; return true ; } localQueue . addLast ( whisper ) ; while ( ( whisper = localQueue . peekFirst ( ) ) != null ) { final Integer type = whisper . dest ; final Set < Talker > set = map . get ( type ) ; if ( set != null ) { for ( final Talker talker : set ) { final TalkerContext ctx = talker . getState ( ) ; switch ( ctx . type ) { case INPLACE_UNSYNC : talker . newMessage ( whisper ) ; break ; case INPLACE_SYNC : synchronized ( talker ) { talker . newMessage ( whisper ) ; } break ; case QUEUED_UNBOUNDED : case QUEUED_BOUNDED : while ( ! ctx . queueMessage ( whisper ) ) ; break ; } } } localQueue . pollFirst ( ) ; } return true ; }
Send message and optionally wait response
9,813
public void shutdown ( ) { singleton = null ; log . info ( "Shuting down GossipMonger" ) ; isShutdown . set ( true ) ; threadPool . shutdown ( ) ; shutdownAndAwaitTermination ( threadPool ) ; ref . remove ( ) ; }
Shutdown GossipMonger and associated Threads
9,814
public RegexMatcher addExpression ( String expr , T attach , Option ... options ) { if ( nfa == null ) { nfa = parser . createNFA ( nfaScope , expr , attach , options ) ; } else { NFA < T > nfa2 = parser . createNFA ( nfaScope , expr , attach , options ) ; nfa = new NFA < > ( nfaScope , nfa , nfa2 ) ; } return this ; }
Add expression .
9,815
public T match ( CharSequence text , boolean matchPrefix ) { if ( root == null ) { throw new IllegalStateException ( "not compiled" ) ; } int length = text . length ( ) ; for ( int ii = 0 ; ii < length ; ii ++ ) { switch ( match ( text . charAt ( ii ) ) ) { case Error : return null ; case Ok : if ( matchPrefix ) { T uniqueMatch = state . getUniqueMatch ( ) ; if ( uniqueMatch != null ) { state = root ; return uniqueMatch ; } } break ; case Match : return getMatched ( ) ; } } return null ; }
Matches given text . Returns associated token if match otherwise null . If matchPrefix is true returns also the only possible match .
9,816
public T match ( OfInt text ) { if ( root == null ) { throw new IllegalStateException ( "not compiled" ) ; } while ( text . hasNext ( ) ) { switch ( match ( text . nextInt ( ) ) ) { case Error : return null ; case Match : return getMatched ( ) ; } } return null ; }
Matches given text as int - iterator . Returns associated token if match otherwise null .
9,817
public static Stream < CharSequence > split ( CharSequence seq , String regex , Option ... options ) { return StreamSupport . stream ( new SpliteratorImpl ( seq , regex , options ) , false ) ; }
Returns stream that contains subsequences delimited by given regex
9,818
public boolean checkAndIncrease ( ) { long newTimestamp = System . currentTimeMillis ( ) ; if ( isShutdown ) { if ( newTimestamp > shutdownEndTime ) { isShutdown = false ; largeLimitCalls = 0 ; smallLimitCalls = 0 ; } else { return false ; } } if ( newTimestamp - smallLimitTimestamp > smallTimeFrame ) { smallLimitCalls = 0 ; smallLimitTimestamp = newTimestamp ; } else { if ( smallLimitCalls >= smallCallLimit ) { return false ; } else { smallLimitCalls += 1 ; } } if ( newTimestamp - largeLimitTimestamp > largeTimeFrame ) { largeLimitCalls = 0 ; largeLimitTimestamp = newTimestamp ; } else { if ( largeLimitCalls >= largeCallsLimit ) { isShutdown = true ; shutdownEndTime = newTimestamp + shutdownPeriod ; return false ; } else { largeLimitCalls += 1 ; } } return true ; }
Check if next call is allowed and increase the counts .
9,819
public static Method findMethod ( String name , Class < ? > cls ) { for ( Method method : cls . getDeclaredMethods ( ) ) { if ( method . getName ( ) . equals ( name ) ) { return method ; } } throw new ExecutionException ( "invalid auto-function: no '" + name + "' method declared" , null ) ; }
Finds a named declared method on the given class .
9,820
public static Object exec ( Method method , String [ ] paramNames , Map < String , ? > params , Object instance ) throws Throwable { Object [ ] paramValues = new Object [ paramNames . length ] ; for ( int c = 0 ; c < paramNames . length ; ++ c ) { paramValues [ c ] = params . get ( paramNames [ c ] ) ; } try { return method . invoke ( instance , paramValues ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalArgumentException e ) { throw new InvocationException ( "invalid arguments" , e , null ) ; } catch ( InvocationTargetException e ) { throw e . getTargetException ( ) ; } }
Invokes the given method mapping named parameters to positions based on a given list of parameter names .
9,821
protected void setLinkProperty ( final UUID _linkTypeUUID , final long _toId , final UUID _toTypeUUID , final String _toName ) throws EFapsException { setDirty ( ) ; }
Sets the link properties for this object .
9,822
public void addEvent ( final EventType _eventtype , final EventDefinition _eventdef ) throws CacheReloadException { List < EventDefinition > evenList = this . events . get ( _eventtype ) ; if ( evenList == null ) { evenList = new ArrayList < > ( ) ; this . events . put ( _eventtype , evenList ) ; } if ( ! evenList . contains ( _eventdef ) ) { evenList . add ( _eventdef ) ; } if ( evenList . size ( ) > 1 ) { Collections . sort ( evenList , new Comparator < EventDefinition > ( ) { public int compare ( final EventDefinition _eventDef0 , final EventDefinition _eventDef1 ) { return Long . compare ( _eventDef0 . getIndexPos ( ) , _eventDef1 . getIndexPos ( ) ) ; } } ) ; } setDirty ( ) ; }
Adds a new event to this AdminObject .
9,823
public List < EventDefinition > getEvents ( final EventType _eventType ) { if ( ! this . eventChecked ) { this . eventChecked = true ; try { EventDefinition . addEvents ( this ) ; } catch ( final EFapsException e ) { AbstractAdminObject . LOG . error ( "Could not read events for Name:; {}', UUID: {}" , this . name , this . uuid ) ; } } return this . events . get ( _eventType ) ; }
Returns the list of events defined for given event type .
9,824
public boolean hasEvents ( final EventType _eventtype ) { if ( ! this . eventChecked ) { this . eventChecked = true ; try { EventDefinition . addEvents ( this ) ; } catch ( final EFapsException e ) { AbstractAdminObject . LOG . error ( "Could not read events for Name:; {}', UUID: {}" , this . name , this . uuid ) ; } } return this . events . get ( _eventtype ) != null ; }
Does this instance have Event for the specified EventType ?
9,825
public Object call ( Map < String , ? > params ) throws Throwable { return AnnotatedExtensions . exec ( getCallMethod ( ) , getParameterNames ( ) , params , this ) ; }
Executes a method named doCall by mapping parameters by name to parameters annotated with the Named annotation
9,826
private Long getLanguageId ( final String _language ) { Long ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( CIAdmin . Language ) ; queryBldr . addWhereAttrEqValue ( CIAdmin . Language . Language , _language ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) . getId ( ) ; } else { ret = insertNewLanguage ( _language ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getLanguageId()" , e ) ; } return ret ; }
find out the Id of the language used for this properties .
9,827
private long insertNewLanguage ( final String _language ) { Long ret = null ; try { final Insert insert = new Insert ( CIAdmin . Language ) ; insert . add ( CIAdmin . Language . Language , _language ) ; insert . executeWithoutAccessCheck ( ) ; ret = insert . getId ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "insertNewLanguage()" , e ) ; } return ret ; }
inserts a new language into the Database .
9,828
private Instance insertNewBundle ( ) { Instance ret = null ; try { final Insert insert = new Insert ( DBPropertiesUpdate . TYPE_PROPERTIES_BUNDLE ) ; insert . add ( "Name" , this . bundlename ) ; insert . add ( "UUID" , this . bundeluuid ) ; insert . add ( "Sequence" , this . bundlesequence ) ; insert . add ( "CacheOnStart" , this . cacheOnStart ) ; insert . executeWithoutAccessCheck ( ) ; ret = insert . getInstance ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "insertNewBundle()" , e ) ; } return ret ; }
Insert a new Bundle into the Database .
9,829
private void importFromProperties ( final URL _url ) { try { final InputStream propInFile = _url . openStream ( ) ; final Properties props = new Properties ( ) ; props . load ( propInFile ) ; final Iterator < Entry < Object , Object > > iter = props . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { final Entry < Object , Object > element = iter . next ( ) ; final Instance existing = getExistingKey ( element . getKey ( ) . toString ( ) ) ; if ( existing == null ) { insertNewProp ( element . getKey ( ) . toString ( ) , element . getValue ( ) . toString ( ) ) ; } else { updateDefault ( existing , element . getValue ( ) . toString ( ) ) ; } } } catch ( final IOException e ) { DBPropertiesUpdate . LOG . error ( "ImportFromProperties() - I/O failed." , e ) ; } }
Import Properties from a Properties - File as default if the key is already existing the default will be replaced with the new default .
9,830
private Instance getExistingLocale ( final long _propertyid , final String _language ) { Instance ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( DBPropertiesUpdate . TYPE_PROPERTIES_LOCAL ) ) ; queryBldr . addWhereAttrEqValue ( "PropertyID" , _propertyid ) ; queryBldr . addWhereAttrEqValue ( "LanguageID" , getLanguageId ( _language ) ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getExistingLocale(String)" , e ) ; } return ret ; }
Is a localized value already existing .
9,831
private void insertNewLocal ( final long _propertyid , final String _value , final String _language ) { try { final Insert insert = new Insert ( DBPropertiesUpdate . TYPE_PROPERTIES_LOCAL ) ; insert . add ( "Value" , _value ) ; insert . add ( "PropertyID" , _propertyid ) ; insert . add ( "LanguageID" , getLanguageId ( _language ) ) ; insert . executeWithoutAccessCheck ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "insertNewLocal(String)" , e ) ; } }
Insert a new localized Value .
9,832
private void updateLocale ( final Instance _localeInst , final String _value ) { try { final Update update = new Update ( _localeInst ) ; update . add ( "Value" , _value ) ; update . execute ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "updateLocale(String, String)" , e ) ; } }
Update a localized Value .
9,833
private Instance getExistingKey ( final String _key ) { Instance ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( DBPropertiesUpdate . TYPE_PROPERTIES ) ) ; queryBldr . addWhereAttrEqValue ( "Key" , _key ) ; queryBldr . addWhereAttrEqValue ( "BundleID" , this . bundleInstance ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getExisting()" , e ) ; } return ret ; }
Is a key already existing .
9,834
private void updateDefault ( final Instance _inst , final String _value ) { try { final Update update = new Update ( _inst ) ; update . add ( "Default" , _value ) ; update . execute ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "updateDefault(String, String)" , e ) ; } }
Update a Default .
9,835
private Instance insertNewProp ( final String _key , final String _value ) { Instance ret = null ; try { final Insert insert = new Insert ( DBPropertiesUpdate . TYPE_PROPERTIES ) ; insert . add ( "BundleID" , this . bundleInstance ) ; insert . add ( "Key" , _key ) ; insert . add ( "Default" , _value ) ; insert . executeWithoutAccessCheck ( ) ; ret = insert . getInstance ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "InsertNew(String, String)" , e ) ; } return ret ; }
Insert a new Property .
9,836
private Instance getExistingBundle ( final String _uuid ) { Instance ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( DBPropertiesUpdate . TYPE_PROPERTIES_BUNDLE ) ) ; queryBldr . addWhereAttrEqValue ( "UUID" , _uuid ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getExistingBundle(String)" , e ) ; } return ret ; }
Is the Bundle allready existing .
9,837
public boolean setPassword ( final String _name , final String _newpasswd , final String _oldpasswd ) throws LoginException { boolean ret = false ; final LoginContext login = new LoginContext ( this . application , new SetPasswordCallbackHandler ( ActionCallback . Mode . SET_PASSWORD , _name , _newpasswd , _oldpasswd ) ) ; login . login ( ) ; ret = true ; return ret ; }
Set the password .
9,838
@ Action ( invokeOn = InvokeOn . OBJECT_AND_COLLECTION ) @ ActionLayout ( describedAs = "Toggle, for testing (direct) bulk actions" ) public void toggleForBulkActions ( ) { boolean flag = getFlag ( ) != null ? getFlag ( ) : false ; setFlag ( ! flag ) ; }
region > toggleForBulkActions
9,839
public boolean addMeasureToVerb ( Map < String , Object > properties ) { String [ ] pathKeys = { "verb" } ; return addChild ( "measure" , properties , pathKeys ) ; }
Add an arbitrary map of key - value pairs as a measure to the verb
9,840
public boolean addMeasureToVerb ( String measureType , Number value , Number scaleMin , Number scaleMax , Number sampleSize ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( measureType != null ) { container . put ( "measureType" , measureType ) ; } else { return false ; } if ( value != null ) { container . put ( "value" , value ) ; } else { return false ; } if ( scaleMin != null ) { container . put ( "scaleMin" , scaleMin ) ; } if ( scaleMax != null ) { container . put ( "scaleMax" , scaleMax ) ; } if ( sampleSize != null ) { container . put ( "sampleSize" , sampleSize ) ; } return addMeasureToVerb ( container ) ; }
Add a mesure object to the verb within this activity
9,841
public boolean addContextToVerb ( String objectType , String id , String description ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } if ( id != null ) { container . put ( "id" , id ) ; } if ( description != null ) { container . put ( "description" , description ) ; } String [ ] pathKeys = { "verb" } ; return addChild ( "context" , container , pathKeys ) ; }
Add a context object to the verb within this activity
9,842
public boolean addVerb ( String action , Date dateStart , Date dateEnd , String [ ] description , String comment ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( action != null ) { container . put ( "action" , action ) ; } else { return false ; } if ( dateStart != null && dateEnd != null ) { container . put ( "date" , df . format ( dateStart ) + "/" + df . format ( dateEnd ) ) ; } else if ( dateStart != null ) { container . put ( "date" , df . format ( dateStart ) ) ; } if ( description != null && description . length > 0 ) { container . put ( "description" , description ) ; } if ( comment != null ) { container . put ( "comment" , comment ) ; } return addChild ( "verb" , container , null ) ; }
Add a verb object to this activity
9,843
public boolean addActor ( String objectType , String displayName , String url , String [ ] description ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } else { return false ; } if ( displayName != null ) { container . put ( "displayName" , displayName ) ; } if ( url != null ) { container . put ( "url" , url ) ; } if ( description != null && description . length > 0 ) { container . put ( "description" , description ) ; } return addChild ( "actor" , container , null ) ; }
Add an actor object to this activity
9,844
public boolean addObject ( String objectType , String id , String content ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } if ( id != null ) { container . put ( "id" , id ) ; } if ( content != null ) { container . put ( "content" , content ) ; } return addChild ( "object" , container , null ) ; }
Add an object to this activity
9,845
public boolean addRelatedObject ( String objectType , String id , String content ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } else { return false ; } if ( id != null ) { container . put ( "id" , id ) ; } if ( content != null ) { container . put ( "content" , content ) ; } related . add ( container ) ; return true ; }
Add a related object to this activity
9,846
private Map < String , Object > getMap ( String [ ] pathKeys ) { if ( pathKeys == null ) { return ( Map < String , Object > ) resourceData ; } Map < String , Object > selected = ( Map < String , Object > ) resourceData ; for ( int i = 0 ; i < pathKeys . length ; i ++ ) { if ( selected . containsKey ( pathKeys [ i ] ) && selected . get ( pathKeys [ i ] ) . getClass ( ) . equals ( resourceData . getClass ( ) ) ) { selected = ( Map < String , Object > ) selected . get ( pathKeys [ i ] ) ; } else { return null ; } } return selected ; }
Get a map embedded in the activity following a set of keys
9,847
private boolean addChild ( String name , Object value , String [ ] pathKeys ) { Map < String , Object > selected = ( Map < String , Object > ) resourceData ; if ( pathKeys != null ) { selected = getMap ( pathKeys ) ; } if ( selected != null && ! selected . containsKey ( name ) ) { selected . put ( name , value ) ; return true ; } return false ; }
Add a child object to the activity at the specified path
9,848
public void process ( TemplateImpl template , Writer out ) throws IOException { Environment env = new Environment ( template . getPath ( ) , out ) ; currentScope . declaringEnvironment = env ; Environment prevEnv = switchEnvironment ( env ) ; TemplateContext tmpl = template . getContext ( ) ; HeaderContext hdr = tmpl . hdr ; if ( hdr != null && hdr . hdrSig != null && hdr . hdrSig . callSig != null && hdr . hdrSig . callSig . paramDecls != null ) { for ( ParameterDeclContext paramDecl : hdr . hdrSig . callSig . paramDecls ) { String paramId = paramDecl . id . getText ( ) ; if ( ! currentScope . values . containsKey ( paramId ) ) { currentScope . declare ( paramId , eval ( paramDecl . expr ) ) ; } } } try { tmpl . accept ( visitor ) ; } finally { switchEnvironment ( prevEnv ) ; } }
Processes a template into its text representation
9,849
private TemplateImpl load ( String path , ParserRuleContext errCtx ) { path = Paths . resolvePath ( currentEnvironment . path , path ) ; try { return ( TemplateImpl ) engine . load ( path ) ; } catch ( IOException | ParseException e ) { throw new ExecutionException ( "error importing " + path , e , getLocation ( errCtx ) ) ; } }
Loads a template from the supplied template loader .
9,850
private Environment switchEnvironment ( Environment env ) { Environment prev = currentEnvironment ; currentEnvironment = env ; return prev ; }
Switch to a new environment
9,851
private Scope switchScope ( Scope scope ) { Scope prev = currentScope ; currentScope = scope ; return prev ; }
Switch to a completely new scope stack
9,852
private Map < String , Object > bindBlocks ( PrepareSignatureContext sig , PrepareInvocationContext inv ) { if ( inv == null ) { return Collections . emptyMap ( ) ; } BlockDeclContext allDecl = null ; BlockDeclContext unnamedDecl = null ; List < NamedOutputBlockContext > namedBlocks = new ArrayList < > ( inv . namedBlocks ) ; Map < String , Object > blocks = new HashMap < > ( ) ; for ( BlockDeclContext blockDecl : sig . blockDecls ) { if ( blockDecl . flag != null ) { if ( blockDecl . flag . getText ( ) . equals ( "*" ) ) { if ( allDecl != null ) { throw new ExecutionException ( "only a single parameter can be marked with '*'" , getLocation ( blockDecl ) ) ; } allDecl = blockDecl ; } else if ( blockDecl . flag . getText ( ) . equals ( "+" ) ) { if ( unnamedDecl != null ) { throw new ExecutionException ( "only a single parameter can be marked with '+'" , getLocation ( blockDecl ) ) ; } unnamedDecl = blockDecl ; } else { throw new ExecutionException ( "unknown block declaration flag" , getLocation ( blockDecl ) ) ; } continue ; } ParserRuleContext paramBlock = findAndRemoveBlock ( namedBlocks , name ( blockDecl ) ) ; BoundParamOutputBlock boundBlock = bindBlock ( paramBlock ) ; blocks . put ( name ( blockDecl ) , boundBlock ) ; } if ( unnamedDecl != null ) { UnnamedOutputBlockContext unnamedBlock = inv . unnamedBlock ; BoundParamOutputBlock boundUnnamedBlock = bindBlock ( unnamedBlock ) ; blocks . put ( unnamedDecl . id . getText ( ) , boundUnnamedBlock ) ; } if ( allDecl != null ) { Map < String , Block > otherBlocks = new HashMap < > ( ) ; if ( inv . unnamedBlock != null && unnamedDecl == null ) { UnnamedOutputBlockContext unnamedBlock = inv . unnamedBlock ; BoundParamOutputBlock boundUnnamedBlock = new BoundParamOutputBlock ( unnamedBlock , mode ( unnamedBlock ) , currentScope ) ; otherBlocks . put ( "" , boundUnnamedBlock ) ; } for ( NamedOutputBlockContext namedBlock : namedBlocks ) { String blockName = nullToEmpty ( name ( namedBlock ) ) ; BoundParamOutputBlock boundNamedBlock = new BoundParamOutputBlock ( namedBlock , mode ( namedBlock ) , currentScope ) ; otherBlocks . put ( blockName , boundNamedBlock ) ; } blocks . put ( allDecl . id . getText ( ) , otherBlocks ) ; } return blocks ; }
Bind block values to names based on prepare signature
9,853
private NamedOutputBlockContext findAndRemoveBlock ( List < NamedOutputBlockContext > blocks , String name ) { if ( blocks == null ) { return null ; } Iterator < NamedOutputBlockContext > blockIter = blocks . iterator ( ) ; while ( blockIter . hasNext ( ) ) { NamedOutputBlockContext block = blockIter . next ( ) ; String blockName = name ( block ) ; if ( name . equals ( blockName ) ) { blockIter . remove ( ) ; return block ; } } return null ; }
Find and remove block with specific name
9,854
private ExpressionContext findAndRemoveValue ( List < NamedValueContext > namedValues , String name ) { Iterator < NamedValueContext > namedValueIter = namedValues . iterator ( ) ; while ( namedValueIter . hasNext ( ) ) { NamedValueContext namedValue = namedValueIter . next ( ) ; if ( name . equals ( value ( namedValue . name ) ) ) { namedValueIter . remove ( ) ; return namedValue . expr ; } } return null ; }
Find and remove named value with specific name
9,855
private Object eval ( ExpressionContext expr ) { Object res = expr ; while ( res instanceof ExpressionContext ) res = ( ( ExpressionContext ) res ) . accept ( visitor ) ; if ( res instanceof LValue ) res = ( ( LValue ) res ) . get ( expr ) ; return res ; }
Evaluate an expression into a value
9,856
private List < Object > eval ( Iterable < ExpressionContext > expressions ) { List < Object > results = new ArrayList < Object > ( ) ; for ( ExpressionContext expression : expressions ) { results . add ( eval ( expression ) ) ; } return results ; }
Evaluates a list of expressions into their values
9,857
private Object exec ( StatementContext statement ) { if ( statement == null ) return null ; return statement . accept ( visitor ) ; }
Execute a statement block until the first return statement is reached .
9,858
ExecutionLocation getLocation ( ParserRuleContext object ) { Token start = object . getStart ( ) ; return new ExecutionLocation ( currentScope . declaringEnvironment . path , start . getLine ( ) , start . getCharPositionInLine ( ) + 1 ) ; }
Retrieves location information for a model object
9,859
public T find ( String text ) { T match = matcher . match ( text , true ) ; if ( match != null ) { String name = match . name ( ) ; if ( name . substring ( 0 , Math . min ( name . length ( ) , text . length ( ) ) ) . equalsIgnoreCase ( text ) ) { return match ; } } return null ; }
Returns enum for text if it is unique prefix .
9,860
public static void stop ( ) throws EFapsException { for ( final QueueConnection queCon : JmsHandler . QUEUE2QUECONN . values ( ) ) { try { queCon . close ( ) ; } catch ( final JMSException e ) { throw new EFapsException ( "JMSException" , e ) ; } } for ( final TopicConnection queCon : JmsHandler . TOPIC2QUECONN . values ( ) ) { try { queCon . close ( ) ; } catch ( final JMSException e ) { throw new EFapsException ( "JMSException" , e ) ; } } JmsHandler . TOPIC2QUECONN . clear ( ) ; JmsHandler . QUEUE2QUECONN . clear ( ) ; JmsHandler . NAME2DEF . clear ( ) ; }
Stop the jms .
9,861
public static String getTimeoutMessage ( long timeout , TimeUnit unit ) { return String . format ( "Timeout of %d %s reached" , timeout , requireNonNull ( unit , "unit" ) ) ; }
Utility method that produce the message of the timeout .
9,862
protected void checkAccess ( ) throws EFapsException { for ( final Instance instance : getInstances ( ) ) { if ( ! instance . getType ( ) . hasAccess ( instance , AccessTypeEnums . DELETE . getAccessType ( ) , null ) ) { LOG . error ( "Delete not permitted for Person: {} on Instance: {}" , Context . getThreadContext ( ) . getPerson ( ) , instance ) ; throw new EFapsException ( getClass ( ) , "execute.NoAccess" , instance ) ; } } }
Check access for all Instances . If one does not have access an error will be thrown .
9,863
public void set ( double eyeX , double eyeY , double eyeZ , double centerX , double centerY , double centerZ , double upX , double upY , double upZ ) { this . eyeX = eyeX ; this . eyeY = eyeY ; this . eyeZ = eyeZ ; this . centerX = centerX ; this . centerY = centerY ; this . centerZ = centerZ ; this . upX = upX ; this . upY = upY ; this . upZ = upZ ; }
Sets the eye position the center of the scene and which axis is facing upward .
9,864
public void setEye ( double eyeX , double eyeY , double eyeZ ) { this . eyeX = eyeX ; this . eyeY = eyeY ; this . eyeZ = eyeZ ; }
Sets the eye position of this Camera .
9,865
public void setCenter ( double centerX , double centerY , double centerZ ) { this . centerX = centerX ; this . centerY = centerY ; this . centerZ = centerZ ; }
Sets the center of the scene of this Camera .
9,866
public void setOrientation ( double upX , double upY , double upZ ) { this . upX = upX ; this . upY = upY ; this . upZ = upZ ; }
Sets which axis is facing upward .
9,867
public double [ ] getCameraDirection ( ) { double [ ] cameraDirection = new double [ 3 ] ; double l = Math . sqrt ( Math . pow ( this . eyeX - this . centerX , 2.0 ) + Math . pow ( this . eyeZ - this . centerZ , 2.0 ) + Math . pow ( this . eyeZ - this . centerZ , 2.0 ) ) ; cameraDirection [ 0 ] = ( this . centerX - this . eyeX ) / l ; cameraDirection [ 1 ] = ( this . centerY - this . eyeY ) / l ; cameraDirection [ 2 ] = ( this . centerZ - this . eyeZ ) / l ; return cameraDirection ; }
Gets the eye direction of this Camera .
9,868
protected boolean hasAccess ( ) throws EFapsException { return Context . getThreadContext ( ) . getPerson ( ) . isAssigned ( Role . get ( UUID . fromString ( "2d142645-140d-46ad-af67-835161a8d732" ) ) ) ; }
Check if the logged in users has access to rest . User must be assigned to the Role Admin_Rest .
9,869
protected String getJSONReply ( final Object _jsonObject ) { String ret = "" ; final ObjectMapper mapper = new ObjectMapper ( ) ; if ( LOG . isDebugEnabled ( ) ) { mapper . enable ( SerializationFeature . INDENT_OUTPUT ) ; } mapper . configure ( SerializationFeature . WRITE_DATES_AS_TIMESTAMPS , false ) ; mapper . registerModule ( new JodaModule ( ) ) ; try { ret = mapper . writeValueAsString ( _jsonObject ) ; } catch ( final JsonProcessingException e ) { LOG . error ( "Catched JsonProcessingException" , e ) ; } return ret ; }
Gets the JSON reply .
9,870
public static String login ( final String _userName , final String _passwd , final String _applicationKey ) throws EFapsException { String ret = null ; if ( JmsSession . checkLogin ( _userName , _passwd , _applicationKey ) ) { final JmsSession session = new JmsSession ( _userName ) ; JmsSession . CACHE . put ( session . getSessionKey ( ) , session ) ; ret = session . getSessionKey ( ) ; } return ret ; }
Login and create a Session .
9,871
void update ( long index , int b ) { if ( size > 0 ) { assert index <= hi ; if ( index < lo ) { throw new IllegalStateException ( "lookaheadLength() too small in ChecksumProvider implementation" ) ; } hi = index ; if ( ( lo == hi - size ) ) { checksum . update ( lookahead [ ( int ) ( lo % size ) ] ) ; lo ++ ; } lookahead [ ( int ) ( hi ++ % size ) ] = b ; } else { if ( index == hi ) { checksum . update ( b ) ; hi = index + 1 ; } else { if ( index != hi - 1 ) { throw new IllegalStateException ( "lookahead needed for checksum" ) ; } } } }
Update with character index .
9,872
public void execute ( ) throws InstallationException { Instance instance = searchInstance ( ) ; if ( instance == null ) { instance = createInstance ( ) ; } updateDB ( instance ) ; }
Import related source code into the eFaps DataBase . If the source code does not exists the source code is created in eFaps .
9,873
protected Instance createInstance ( ) throws InstallationException { final Insert insert ; try { insert = new Insert ( getCiType ( ) ) ; insert . add ( "Name" , this . programName ) ; if ( getEFapsUUID ( ) != null ) { insert . add ( "UUID" , getEFapsUUID ( ) . toString ( ) ) ; } insert . execute ( ) ; } catch ( final EFapsException e ) { throw new InstallationException ( "Could not create " + getCiType ( ) + " " + getProgramName ( ) , e ) ; } return insert . getInstance ( ) ; }
Creates an instance of a source object in eFaps for given name .
9,874
public void updateDB ( final Instance _instance ) throws InstallationException { try { final InputStream is = newCodeInputStream ( ) ; final Checkin checkin = new Checkin ( _instance ) ; checkin . executeWithoutAccessCheck ( getProgramName ( ) , is , is . available ( ) ) ; } catch ( final UnsupportedEncodingException e ) { throw new InstallationException ( "Encoding failed for " + this . programName , e ) ; } catch ( final EFapsException e ) { throw new InstallationException ( "Could not check in " + this . programName , e ) ; } catch ( final IOException e ) { throw new InstallationException ( "Reading from inoutstream faild for " + this . programName , e ) ; } }
Stores the read source code in eFaps . This is done with a check in .
9,875
public static void startup ( final String _classDBType , final String _classDSFactory , final String _propConnection , final String _classTM , final String _classTSR , final String _eFapsProps ) throws StartupException { StartupDatabaseConnection . startup ( _classDBType , _classDSFactory , StartupDatabaseConnection . convertToMap ( _propConnection ) , _classTM , _classTSR , StartupDatabaseConnection . convertToMap ( _eFapsProps ) ) ; }
Initialize the database information set for given parameter values .
9,876
protected static void configureEFapsProperties ( final Context _compCtx , final Map < String , String > _eFapsProps ) throws StartupException { try { Util . bind ( _compCtx , "env/" + INamingBinds . RESOURCE_CONFIGPROPERTIES , _eFapsProps ) ; } catch ( final NamingException e ) { throw new StartupException ( "could not bind eFaps Properties '" + _eFapsProps + "'" , e ) ; } catch ( final Exception e ) { throw new StartupException ( "could not bind eFaps Properties '" + _eFapsProps + "'" , e ) ; } }
Add the eFaps Properties to the JNDI binding .
9,877
public static void shutdown ( ) throws StartupException { final Context compCtx ; try { final InitialContext context = new InitialContext ( ) ; compCtx = ( javax . naming . Context ) context . lookup ( "java:comp" ) ; } catch ( final NamingException e ) { throw new StartupException ( "Could not initialize JNDI" , e ) ; } try { Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_DATASOURCE ) ; Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_DBTYPE ) ; Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_CONFIGPROPERTIES ) ; Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_TRANSMANAG ) ; } catch ( final NamingException e ) { throw new StartupException ( "unbind of the database connection failed" , e ) ; } }
Shutdowns the connection to the database .
9,878
@ SuppressWarnings ( "unchecked" ) public STMT columnWithCurrentTimestamp ( final String _columnName ) { this . columnWithSQLValues . add ( new AbstractSQLInsertUpdate . ColumnWithSQLValue ( _columnName , Context . getDbType ( ) . getCurrentTimeStamp ( ) ) ) ; return ( STMT ) this ; }
Adds a new column which will have the current time stamp to append .
9,879
public static EQLInvoker getInvoker ( ) { final EQLInvoker ret = new EQLInvoker ( ) { protected AbstractPrintStmt getPrint ( ) { return new PrintStmt ( ) ; } protected AbstractInsertStmt getInsert ( ) { return new InsertStmt ( ) ; } protected AbstractExecStmt getExec ( ) { return new ExecStmt ( ) ; } protected AbstractUpdateStmt getUpdate ( ) { return new UpdateStmt ( ) ; } protected AbstractDeleteStmt getDelete ( ) { return new DeleteStmt ( ) ; } protected INestedQueryStmtPart getNestedQuery ( ) { return super . getNestedQuery ( ) ; } protected AbstractCIPrintStmt getCIPrint ( ) { return new CIPrintStmt ( ) ; } } ; ret . getValidator ( ) . setDiagnosticClazz ( EFapsDiagnostic . class ) ; ret . getValidator ( ) . addValidation ( "EQLJavaValidator.type" , new TypeValidation ( ) ) ; return ret ; }
Gets the invoker .
9,880
public void append2SQLSelect ( final SQLSelect _sqlSelect ) { if ( iWhere != null ) { final SQLWhere sqlWhere = _sqlSelect . getWhere ( ) ; for ( final IWhereTerm < ? > term : iWhere . getTerms ( ) ) { if ( term instanceof IWhereElementTerm ) { final IWhereElement element = ( ( IWhereElementTerm ) term ) . getElement ( ) ; if ( element . getAttribute ( ) != null ) { final String attrName = element . getAttribute ( ) ; for ( final Type type : types ) { final Attribute attr = type . getAttribute ( attrName ) ; if ( attr != null ) { addAttr ( _sqlSelect , sqlWhere , attr , term , element ) ; break ; } } } else if ( element . getSelect ( ) != null ) { final IWhereSelect select = element . getSelect ( ) ; for ( final ISelectElement ele : select . getElements ( ) ) { if ( ele instanceof IBaseSelectElement ) { switch ( ( ( IBaseSelectElement ) ele ) . getElement ( ) ) { case STATUS : for ( final Type type : types ) { final Attribute attr = type . getStatusAttribute ( ) ; if ( attr != null ) { addAttr ( _sqlSelect , sqlWhere , attr , term , element ) ; break ; } } break ; default : break ; } } else if ( ele instanceof IAttributeSelectElement ) { final String attrName = ( ( IAttributeSelectElement ) ele ) . getName ( ) ; for ( final Type type : types ) { addAttr ( _sqlSelect , sqlWhere , type . getAttribute ( attrName ) , term , element ) ; } } } } } } } if ( iOrder != null ) { final SQLOrder sqlOrder = _sqlSelect . getOrder ( ) ; for ( final IOrderElement element : iOrder . getElements ( ) ) { for ( final Type type : types ) { final Attribute attr = type . getAttribute ( element . getKey ( ) ) ; if ( attr != null ) { final SQLTable table = attr . getTable ( ) ; final String tableName = table . getSqlTable ( ) ; final TableIdx tableidx = _sqlSelect . getIndexer ( ) . getTableIdx ( tableName ) ; sqlOrder . addElement ( tableidx . getIdx ( ) , attr . getSqlColNames ( ) , element . isDesc ( ) ) ; break ; } } } } }
Append two SQL select .
9,881
void init ( ) { if ( ! isEnabled ( ) ) { loggerConfig . info ( "Ted prime instance check is disabled" ) ; return ; } this . primeTaskId = context . tedDaoExt . findPrimeTaskId ( ) ; int periodMs = context . config . intervalDriverMs ( ) ; this . postponeSec = ( int ) Math . round ( ( 1.0 * periodMs * TICK_SKIP_COUNT + 500 + 500 ) / 1000 ) ; becomePrime ( ) ; loggerConfig . info ( "Ted prime instance check is enabled, primeTaskId={} isPrime={} postponeSec={}" , primeTaskId , isPrime , postponeSec ) ; initiated = true ; }
after configs read
9,882
public TemplateSource find ( String path ) throws IOException { return new URLTemplateSource ( new URL ( "file" , null , path ) ) ; }
Maps the given path to a file URL and builds a URLTemplateSource for it .
9,883
public static void initialize ( ) throws CacheReloadException { if ( InfinispanCache . get ( ) . exists ( BundleMaker . NAMECACHE ) ) { InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . NAMECACHE ) . clear ( ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLE ) . clear ( ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLEMAP ) . clear ( ) ; } else { InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . NAMECACHE ) . addListener ( new CacheLogListener ( BundleMaker . LOG ) ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLE ) . addListener ( new CacheLogListener ( BundleMaker . LOG ) ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLEMAP ) . addListener ( new CacheLogListener ( BundleMaker . LOG ) ) ; } }
Init this class .
9,884
public static boolean containsKey ( final String _key ) { final Cache < String , BundleInterface > cache = InfinispanCache . get ( ) . < String , BundleInterface > getIgnReCache ( BundleMaker . CACHE4BUNDLE ) ; return cache . containsKey ( _key ) ; }
Does a Bundle for the Key exist .
9,885
private static String createNewKey ( final List < String > _names , final Class < ? > _bundleclass ) throws EFapsException { final StringBuilder builder = new StringBuilder ( ) ; final List < String > oids = new ArrayList < > ( ) ; String ret = null ; try { for ( final String name : _names ) { if ( builder . length ( ) > 0 ) { builder . append ( "-" ) ; } final Cache < String , StaticCompiledSource > cache = InfinispanCache . get ( ) . < String , StaticCompiledSource > getIgnReCache ( BundleMaker . NAMECACHE ) ; if ( ! cache . containsKey ( name ) ) { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminProgram . StaticCompiled ) ; queryBldr . addWhereAttrEqValue ( CIAdminProgram . StaticCompiled . Name , name ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminProgram . StaticCompiled . Name ) ; multi . execute ( ) ; while ( multi . next ( ) ) { final String statName = multi . < String > getAttribute ( CIAdminProgram . StaticCompiled . Name ) ; final StaticCompiledSource source = new StaticCompiledSource ( multi . getCurrentInstance ( ) . getOid ( ) , statName ) ; cache . put ( source . getName ( ) , source ) ; } } if ( cache . containsKey ( name ) ) { final String oid = cache . get ( name ) . getOid ( ) ; builder . append ( oid ) ; oids . add ( oid ) ; } } ret = builder . toString ( ) ; final BundleInterface bundle = ( BundleInterface ) _bundleclass . newInstance ( ) ; bundle . setKey ( ret , oids ) ; final Cache < String , BundleInterface > cache = InfinispanCache . get ( ) . < String , BundleInterface > getIgnReCache ( BundleMaker . CACHE4BUNDLE ) ; cache . put ( ret , bundle ) ; } catch ( final InstantiationException e ) { throw new EFapsException ( BundleMaker . class , "createNewKey.InstantiationException" , e , _bundleclass ) ; } catch ( final IllegalAccessException e ) { throw new EFapsException ( BundleMaker . class , "createNewKey.IllegalAccessException" , e , _bundleclass ) ; } return ret ; }
Creates a new Key and instantiates the BundleInterface .
9,886
public static void init ( final String _runLevel ) throws EFapsException { RunLevel . ALL_RUNLEVELS . clear ( ) ; RunLevel . RUNLEVEL = new RunLevel ( _runLevel ) ; }
The static method first removes all values in the caches . Then the cache is initialized automatically depending on the desired RunLevel
9,887
private List < String > getAllInitializers ( ) { final List < String > ret = new ArrayList < > ( ) ; for ( final CacheMethod cacheMethod : this . cacheMethods ) { ret . add ( cacheMethod . className ) ; } if ( this . parent != null ) { ret . addAll ( this . parent . getAllInitializers ( ) ) ; } return ret ; }
Returns the list of all initializers .
9,888
protected void initialize ( final String _sql ) throws EFapsException { Connection con = null ; try { con = Context . getConnection ( ) ; Statement stmt = null ; long parentId = 0 ; try { stmt = con . createStatement ( ) ; ResultSet rs = stmt . executeQuery ( _sql ) ; if ( rs . next ( ) ) { this . id = rs . getLong ( 1 ) ; parentId = rs . getLong ( 2 ) ; } else { RunLevel . LOG . error ( "RunLevel not found" ) ; } rs . close ( ) ; rs = stmt . executeQuery ( RunLevel . SELECT_DEF_PRE . getCopy ( ) . addPart ( SQLPart . WHERE ) . addColumnPart ( 0 , "RUNLEVELID" ) . addPart ( SQLPart . EQUAL ) . addValuePart ( this . id ) . addPart ( SQLPart . ORDERBY ) . addColumnPart ( 0 , "PRIORITY" ) . getSQL ( ) ) ; while ( rs . next ( ) ) { if ( rs . getString ( 3 ) != null ) { this . cacheMethods . add ( new CacheMethod ( rs . getString ( 1 ) . trim ( ) , rs . getString ( 2 ) . trim ( ) , rs . getString ( 3 ) . trim ( ) ) ) ; } else { this . cacheMethods . add ( new CacheMethod ( rs . getString ( 1 ) . trim ( ) , rs . getString ( 2 ) . trim ( ) ) ) ; } } rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; con . close ( ) ; RunLevel . ALL_RUNLEVELS . put ( this . id , this ) ; if ( parentId != 0 ) { this . parent = RunLevel . ALL_RUNLEVELS . get ( parentId ) ; if ( this . parent == null ) { this . parent = new RunLevel ( parentId ) ; } } } catch ( final EFapsException e ) { RunLevel . LOG . error ( "initialise()" , e ) ; } catch ( final SQLException e ) { RunLevel . LOG . error ( "initialise()" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "Cannot read a type for an attribute." , e ) ; } } }
Reads the id and the parent id of this RunLevel . All defined methods for this run level are loaded . If a parent id is defined the parent is initialized .
9,889
static Integer getInteger ( Properties properties , String key , Integer defaultValue ) { if ( properties == null ) return defaultValue ; String value = properties . getProperty ( key ) ; if ( value == null || value . isEmpty ( ) ) return defaultValue ; int intVal ; try { intVal = Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { logger . warn ( "Cannot read property '" + key + "'. Expected integer, but got '" + value + "'. Setting default value = '" + defaultValue + "'" , e . getMessage ( ) ) ; return defaultValue ; } logger . trace ( "Read property '" + key + "' value '" + intVal + "'" ) ; return intVal ; }
returns int value of property or defaultValue if not found or invalid
9,890
public void execute ( T target ) throws Throwable { try { for ( Invokation invokation : queue ) { invokation . invoke ( target ) ; } } catch ( InvocationTargetException ex ) { throw ex . getCause ( ) ; } catch ( ReflectiveOperationException ex ) { throw new RuntimeException ( ex ) ; } }
Executes delayed invocations
9,891
protected Map < String , Object > getSignableData ( ) { final Map < String , Object > doc = getSendableData ( ) ; for ( int i = 0 ; i < excludedFields . length ; i ++ ) { doc . remove ( excludedFields [ i ] ) ; } return doc ; }
Builds and returns a map of the envelope data suitable for signing with the included signer
9,892
protected Map < String , Object > getSendableData ( ) { Map < String , Object > doc = new LinkedHashMap < String , Object > ( ) ; MapUtil . put ( doc , docTypeField , docType ) ; MapUtil . put ( doc , docVersionField , docVersion ) ; MapUtil . put ( doc , activeField , true ) ; MapUtil . put ( doc , resourceDataTypeField , resourceDataType ) ; Map < String , Object > docId = new HashMap < String , Object > ( ) ; MapUtil . put ( docId , submitterTypeField , submitterType ) ; MapUtil . put ( docId , submitterField , submitter ) ; MapUtil . put ( docId , curatorField , curator ) ; MapUtil . put ( docId , ownerField , owner ) ; MapUtil . put ( docId , signerField , signer ) ; MapUtil . put ( doc , identityField , docId ) ; MapUtil . put ( doc , submitterTTLField , submitterTTL ) ; Map < String , Object > docTOS = new HashMap < String , Object > ( ) ; MapUtil . put ( docTOS , submissionTOSField , submissionTOS ) ; MapUtil . put ( docTOS , submissionAttributionField , submissionAttribution ) ; MapUtil . put ( doc , TOSField , docTOS ) ; MapUtil . put ( doc , resourceLocatorField , resourceLocator ) ; MapUtil . put ( doc , payloadPlacementField , payloadPlacement ) ; MapUtil . put ( doc , payloadSchemaField , payloadSchema ) ; MapUtil . put ( doc , payloadSchemaLocatorField , payloadSchemaLocator ) ; MapUtil . put ( doc , keysField , tags ) ; MapUtil . put ( doc , resourceDataField , getEncodedResourceData ( ) ) ; MapUtil . put ( doc , replacesField , replaces ) ; if ( signed ) { Map < String , Object > sig = new HashMap < String , Object > ( ) ; String [ ] keys = { publicKeyLocation } ; MapUtil . put ( sig , keyLocationField , keys ) ; MapUtil . put ( sig , signingMethodField , signingMethod ) ; MapUtil . put ( sig , signatureField , clearSignedMessage ) ; MapUtil . put ( doc , digitalSignatureField , sig ) ; } return doc ; }
Builds and returns a map of the envelope data including any signing data suitable for sending to a Learning Registry node
9,893
public void addSigningData ( String signingMethod , String publicKeyLocation , String clearSignedMessage ) { this . signingMethod = signingMethod ; this . publicKeyLocation = publicKeyLocation ; this . clearSignedMessage = clearSignedMessage ; this . signed = true ; }
Adds signing data to the envelope
9,894
public String getUrl ( String email ) { if ( email == null ) { throw new IllegalArgumentException ( "Email can't be null." ) ; } String emailHash = DigestUtils . md5Hex ( email . trim ( ) . toLowerCase ( ) ) ; boolean firstParameter = true ; StringBuilder builder = new StringBuilder ( 91 ) . append ( https ? HTTPS_URL : URL ) . append ( emailHash ) . append ( FILE_TYPE_EXTENSION ) ; if ( size != DEFAULT_SIZE ) { addParameter ( builder , "s" , Integer . toString ( size ) , firstParameter ) ; firstParameter = false ; } if ( forceDefault ) { addParameter ( builder , "f" , "y" , firstParameter ) ; firstParameter = false ; } if ( rating != DEFAULT_RATING ) { addParameter ( builder , "r" , rating . getKey ( ) , firstParameter ) ; firstParameter = false ; } if ( customDefaultImage != null ) { addParameter ( builder , "d" , customDefaultImage , firstParameter ) ; } else if ( standardDefaultImage != null ) { addParameter ( builder , "d" , standardDefaultImage . getKey ( ) , firstParameter ) ; } return builder . toString ( ) ; }
Retrieve the gravatar URL for the given email .
9,895
private void setProperties ( final Instance _instance ) throws EFapsException { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminCommon . Property ) ; queryBldr . addWhereAttrEqValue ( CIAdminCommon . Property . Abstract , _instance . getId ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminCommon . Property . Name , CIAdminCommon . Property . Value ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { super . setProperty ( multi . < String > getAttribute ( CIAdminCommon . Property . Name ) , multi . < String > getAttribute ( CIAdminCommon . Property . Value ) ) ; } }
Set the properties in the superclass .
9,896
private void checkProgramInstance ( ) { try { if ( EventDefinition . LOG . isDebugEnabled ( ) ) { EventDefinition . LOG . debug ( "checking Instance: {} - {}" , this . resourceName , this . methodName ) ; } if ( ! EFapsClassLoader . getInstance ( ) . isOffline ( ) ) { final Class < ? > cls = Class . forName ( this . resourceName , true , EFapsClassLoader . getInstance ( ) ) ; final Method method = cls . getMethod ( this . methodName , new Class [ ] { Parameter . class } ) ; final Object progInstance = cls . newInstance ( ) ; if ( EventDefinition . LOG . isDebugEnabled ( ) ) { EventDefinition . LOG . debug ( "found Class: {} and method {}" , progInstance , method ) ; } } } catch ( final ClassNotFoundException e ) { EventDefinition . LOG . error ( "could not find Class: '{}'" , this . resourceName , e ) ; } catch ( final InstantiationException e ) { EventDefinition . LOG . error ( "could not instantiat Class: '{}'" , this . resourceName , e ) ; } catch ( final IllegalAccessException e ) { EventDefinition . LOG . error ( "could not access Class: '{}'" , this . resourceName , e ) ; } catch ( final SecurityException e ) { EventDefinition . LOG . error ( "could not access Class: '{}'" , this . resourceName , e ) ; } catch ( final NoSuchMethodException e ) { EventDefinition . LOG . error ( "could not find method: '{}' in class '{}'" , new Object [ ] { this . methodName , this . resourceName , e } ) ; } }
Method to check if the instance of the esjp is valid .
9,897
public Return execute ( final Parameter _parameter ) throws EFapsException { Return ret = null ; _parameter . put ( ParameterValues . PROPERTIES , new HashMap < > ( super . evalProperties ( ) ) ) ; try { EventDefinition . LOG . debug ( "Invoking method '{}' for Resource '{}'" , this . methodName , this . resourceName ) ; final Class < ? > cls = Class . forName ( this . resourceName , true , EFapsClassLoader . getInstance ( ) ) ; final Method method = cls . getMethod ( this . methodName , new Class [ ] { Parameter . class } ) ; ret = ( Return ) method . invoke ( cls . newInstance ( ) , _parameter ) ; EventDefinition . LOG . debug ( "Terminated invokation of method '{}' for Resource '{}'" , this . methodName , this . resourceName ) ; } catch ( final SecurityException e ) { EventDefinition . LOG . error ( "security wrong: '{}'" , this . resourceName , e ) ; } catch ( final IllegalArgumentException e ) { EventDefinition . LOG . error ( "arguments invalid : '{}'- '{}'" , this . resourceName , this . methodName , e ) ; } catch ( final IllegalAccessException e ) { EventDefinition . LOG . error ( "could not access class: '{}'" , this . resourceName , e ) ; } catch ( final InvocationTargetException e ) { EventDefinition . LOG . error ( "could not invoke method: '{}' in class: '{}'" , this . methodName , this . resourceName , e ) ; throw ( EFapsException ) e . getCause ( ) ; } catch ( final ClassNotFoundException e ) { EventDefinition . LOG . error ( "class not found: '{}" + this . resourceName , e ) ; } catch ( final NoSuchMethodException e ) { EventDefinition . LOG . error ( "could not find method: '{}' in class '{}'" , new Object [ ] { this . methodName , this . resourceName , e } ) ; } catch ( final InstantiationException e ) { EventDefinition . LOG . error ( "could not instantiat Class: '{}'" , this . resourceName , e ) ; } return ret ; }
Method to execute the esjp .
9,898
public String getOid ( ) { String ret = null ; if ( isValid ( ) ) { ret = getType ( ) . getId ( ) + "." + getId ( ) ; } return ret ; }
The string representation which is defined by this instance is returned .
9,899
public boolean checkEventId ( String conversationId , long conversationEventId , MissingEventsListener missingEventsListener ) { if ( ! idsPerConversation . containsKey ( conversationId ) ) { TreeSet < Long > ids = new TreeSet < > ( ) ; boolean added = ids . add ( conversationEventId ) ; idsPerConversation . put ( conversationId , ids ) ; return ! added ; } else { TreeSet < Long > ids = idsPerConversation . get ( conversationId ) ; long last = ids . last ( ) ; boolean added = ids . add ( conversationEventId ) ; if ( last < conversationEventId - 1 ) { missingEventsListener . missingEvents ( conversationId , last + 1 , ( int ) ( conversationEventId - last ) ) ; } while ( ids . size ( ) > 10 ) { ids . pollFirst ( ) ; } return ! added ; } }
Check conversation event id for duplicates or missing events .