idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
2,300
public static BigDecimal decimalPart ( final BigDecimal val ) { return BigDecimalUtil . subtract ( val , val . setScale ( 0 , BigDecimal . ROUND_DOWN ) ) ; }
Return the decimal part of the value .
2,301
private static BigDecimal sqrtNewtonRaphson ( final BigDecimal c , final BigDecimal xn , final BigDecimal precision ) { BigDecimal fx = xn . pow ( 2 ) . add ( c . negate ( ) ) ; BigDecimal fpx = xn . multiply ( new BigDecimal ( 2 ) ) ; BigDecimal xn1 = fx . divide ( fpx , 2 * SQRT_DIG . intValue ( ) , RoundingMode . HA...
Private utility method used to compute the square root of a BigDecimal .
2,302
public static BigDecimal bigSqrt ( final BigDecimal c ) { if ( c == null ) { return null ; } return c . signum ( ) == 0 ? BigDecimal . ZERO : sqrtNewtonRaphson ( c , BigDecimal . ONE , BigDecimal . ONE . divide ( SQRT_PRE ) ) ; }
Uses Newton Raphson to compute the square root of a BigDecimal .
2,303
public void addMenuItem ( final String menuDisplay , final String methodName , final boolean repeat ) { menu . add ( menuDisplay ) ; methods . add ( methodName ) ; askForRepeat . add ( Boolean . valueOf ( repeat ) ) ; }
add an entry in the menu sequentially
2,304
public void displayMenu ( ) { while ( true ) { ConsoleMenu . println ( "" ) ; ConsoleMenu . println ( "Menu Options" ) ; final int size = menu . size ( ) ; displayMenu ( size ) ; int opt ; do { opt = ConsoleMenu . getInt ( "Enter your choice:" , - 1 ) ; } while ( ( opt <= 0 || opt > methods . size ( ) ) && opt != EXIT_...
display the menu the application goes into a loop which provides the menu and fires the entries selected . It automatically adds an entry to exit .
2,305
public static int getInt ( final String title , final int defaultValue ) { int opt ; do { try { final String val = ConsoleMenu . getString ( title + DEFAULT_TITLE + defaultValue + ")" ) ; if ( val . length ( ) == 0 ) { opt = defaultValue ; } else { opt = Integer . parseInt ( val ) ; } } catch ( final NumberFormatExcept...
Gets an int from the System . in
2,306
public static boolean getBoolean ( final String title , final boolean defaultValue ) { final String val = ConsoleMenu . selectOne ( title , new String [ ] { "Yes" , "No" } , new String [ ] { Boolean . TRUE . toString ( ) , Boolean . FALSE . toString ( ) } , defaultValue ? 1 : 2 ) ; return Boolean . valueOf ( val ) ; }
Gets a boolean from the System . in
2,307
public static BigDecimal getBigDecimal ( final String title , final BigDecimal defaultValue ) { BigDecimal opt ; do { try { final String val = ConsoleMenu . getString ( title + DEFAULT_TITLE + defaultValue + ")" ) ; if ( val . length ( ) == 0 ) { opt = defaultValue ; } else { opt = new BigDecimal ( val ) ; } } catch ( ...
Gets an BigDecimal from the System . in
2,308
public static String getString ( final String msg ) { ConsoleMenu . print ( msg ) ; BufferedReader bufReader = null ; String opt = null ; try { bufReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; opt = bufReader . readLine ( ) ; } catch ( final IOException ex ) { log ( ex ) ; System . exit ( 1 ) ...
Gets a String from the System . in .
2,309
public static String getString ( final String msg , final String defaultVal ) { String s = getString ( msg + "(default:" + defaultVal + "):" ) ; if ( StringUtils . isBlank ( s ) ) { s = defaultVal ; } return s ; }
Gets a String from the System . in
2,310
public static String selectOne ( final String title , final String [ ] optionNames , final String [ ] optionValues , final int defaultOption ) { if ( optionNames . length != optionValues . length ) { throw new IllegalArgumentException ( "option names and values must have same length" ) ; } ConsoleMenu . println ( "Plea...
Generates a menu with a list of options and return the value selected .
2,311
public String selectMajorCurrency ( final String ccy1 , final String ccy2 ) { return ranks . getOrDefault ( StringUtil . toUpperCase ( ccy1 ) , DEFAULT_UNRANKED_VALUE ) . intValue ( ) <= ranks . getOrDefault ( StringUtil . toUpperCase ( ccy2 ) , DEFAULT_UNRANKED_VALUE ) . intValue ( ) ? ccy1 : ccy2 ; }
Given 2 currencies return the major one if there is one otherwise returns the first currency .
2,312
public String selectMajorCurrency ( final CurrencyPair pair ) { return selectMajorCurrency ( pair . getCcy1 ( ) , pair . getCcy2 ( ) ) ; }
Given a CurrencyPair return the major Currency if there is one otherwise returns the first currency .
2,313
public boolean isMarketConvention ( final String ccy1 , final String ccy2 ) { return selectMajorCurrency ( ccy1 , ccy2 ) . equals ( ccy1 ) ; }
returns true if the ccy1 is the major one for the given currency pair .
2,314
public void setCurrenciesSubjectToCrossCcyForT1 ( final Map < String , Set < String > > currenciesSubjectToCrossCcyForT1 ) { final Map < String , Set < String > > copy = new HashMap < > ( ) ; if ( currenciesSubjectToCrossCcyForT1 != null ) { copy . putAll ( currenciesSubjectToCrossCcyForT1 ) ; } this . currenciesSubjec...
Will take a copy of a non null set but doing so by replacing the internal one in one go for consistency .
2,315
public void setWorkingWeeks ( final Map < String , WorkingWeek > workingWeeks ) { final Map < String , WorkingWeek > ww = new HashMap < > ( ) ; ww . putAll ( workingWeeks ) ; this . workingWeeks = ww ; }
Will take a copy of a non null map but doing so by replacing the internal one in one go for consistency .
2,316
public WorkingWeek withWorkingDayFromCalendar ( final boolean working , final int dayOfWeek ) { final int day = adjustDay ( dayOfWeek ) ; WorkingWeek ret = this ; if ( working && ! isWorkingDayFromCalendar ( dayOfWeek ) ) { ret = new WorkingWeek ( ( byte ) ( workingDays + WORKING_WEEK_DAYS_OFFSET [ day ] ) ) ; } else i...
If the value for the given day has changed return a NEW WorkingWeek .
2,317
public static boolean anyNull ( final Object ... o1s ) { if ( o1s != null && o1s . length > 0 ) { for ( final Object o1 : o1s ) { if ( o1 == null ) { return true ; } } } else { return true ; } return false ; }
Return true if any of the given objects are null .
2,318
public static boolean allNull ( final Object ... o1s ) { if ( o1s != null && o1s . length > 0 ) { for ( final Object o1 : o1s ) { if ( o1 != null ) { return false ; } } } return true ; }
Return true if ALL of the given objects are null .
2,319
public static boolean atLeastOneNotNull ( final Object ... o1s ) { if ( o1s != null && o1s . length > 0 ) { for ( final Object o1 : o1s ) { if ( o1 != null ) { return true ; } } } return false ; }
Return true if at least one of the given objects is not null .
2,320
protected void setHolidays ( final String name , final DateCalculator < E > dc ) { if ( name != null ) { dc . setHolidayCalendar ( holidays . get ( name ) ) ; } }
Used by extensions to set holidays in a DateCalculator .
2,321
protected CurrencyDateCalculatorBuilder < E > configureCurrencyCalculatorBuilder ( final CurrencyDateCalculatorBuilder < E > builder ) { return builder . ccy1Calendar ( getHolidayCalendar ( builder . getCcy1 ( ) ) ) . ccy1Week ( getCurrencyCalculatorConfig ( ) . getWorkingWeek ( builder . getCcy1 ( ) ) ) . ccy2Calendar...
Method that may be called by the specialised factory methods and will fetch the registered holidayCalendar for all 3 currencies and the working weeks via the currencyCalculatorConfig and assigning currencyCalculatorConfig to the builder using the DefaultCurrencyCalculatorConfig if not modified .
2,322
public static FxRate calculateCross ( final CurrencyPair targetPair , final FxRate fx1 , final FxRate fx2 , final int precision , final int precisionForInverseFxRate , final MajorCurrencyRanking ranking , final int bidRounding , final int askRounding , CurrencyProvider currencyProvider ) { final Optional < String > cro...
Calculate the cross rate use this only if required .
2,323
public static String buildStackTraceString ( final Throwable ex ) { final StringBuilder context = new StringBuilder ( ex . toString ( ) ) ; final StringWriter sw = new StringWriter ( ) ; ex . printStackTrace ( new PrintWriter ( sw , true ) ) ; context . append ( '\n' ) ; context . append ( sw . toString ( ) ) ; return ...
finds out the stack trace up to where the exception was thrown .
2,324
public static String dumpThreads ( ) { final StringWriter sout = new StringWriter ( ) ; final PrintWriter out = new PrintWriter ( sout ) ; Util . listAllThreads ( out ) ; out . flush ( ) ; return sout . toString ( ) ; }
Finds information about the threads and dumps them into a String .
2,325
private static void listAllThreads ( final PrintWriter out ) { final ThreadGroup currentThreadGroup = Thread . currentThread ( ) . getThreadGroup ( ) ; ThreadGroup rootThreadGroup = currentThreadGroup ; ThreadGroup parent = rootThreadGroup . getParent ( ) ; while ( parent != null ) { rootThreadGroup = parent ; parent =...
Find the root thread group and list it recursively
2,326
private static void printGroupInfo ( final PrintWriter out , final ThreadGroup group , final String indent ) { if ( group == null ) { return ; } final int numThreads = group . activeCount ( ) ; final int numGroups = group . activeGroupCount ( ) ; final Thread [ ] threads = new Thread [ numThreads ] ; final ThreadGroup ...
Display info about a thread group and its threads and groups
2,327
public static String replaceToken ( final String original , final String token , final String replacement ) { final StringBuilder tok = new StringBuilder ( TOKEN ) ; tok . append ( token ) . append ( TOKEN ) ; final String toReplace = replaceCRToken ( original ) ; return StringUtil . replace ( tok . toString ( ) , repl...
Replaces the token surrounded by % within a string with new value . Also replaces any %CR% tokens with the newline character .
2,328
public static String replaceCRToken ( final String original ) { String toReplace = original ; if ( original != null && original . indexOf ( NEWLINE_TOKEN ) >= 0 ) { toReplace = StringUtil . replace ( NEWLINE_TOKEN , NEW_LINE , original ) ; } return toReplace ; }
Replaces any %CR% tokens with the newline character .
2,329
public static String wrapText ( final String inString , final String newline , final int wrapColumn ) { if ( inString == null ) { return null ; } final StringTokenizer lineTokenizer = new StringTokenizer ( inString , newline , true ) ; final StringBuilder builder = new StringBuilder ( ) ; while ( lineTokenizer . hasMor...
Takes a block of text which might have long lines in it and wraps the long lines based on the supplied wrapColumn parameter . It was initially implemented for use by VelocityEmail . If there are tabs in inString you are going to get results that are a bit strange since tabs are a single character but are displayed as 4...
2,330
public static String singleQuote ( final String text ) { final StringBuilder b = new StringBuilder ( ( text != null ? text . length ( ) : 0 ) + 2 ) ; b . append ( SINGLE_QUOTE ) ; if ( text != null ) { b . append ( text ) ; } b . append ( SINGLE_QUOTE ) ; return b . toString ( ) ; }
Add single quotes around the text .
2,331
public static boolean allEquals ( final String value , final String ... strings ) { if ( strings != null ) { for ( final String s : strings ) { if ( s == null && value != null || s != null && ! s . equals ( value ) ) { return false ; } } } else { return value == null ; } return true ; }
Return true if all strings are the same .
2,332
public static String prepareForNumericParsing ( final String inputStr ) { if ( inputStr == null ) { return EMPTY ; } final Matcher matcher = PATTERN_FOR_NUM_PARSING_PREP . matcher ( inputStr ) ; return matcher . replaceAll ( "" ) ; }
Remove and spaces from the input string .
2,333
public static int compareTo ( final String s1 , final String s2 ) { int ret ; if ( s1 != null && s2 != null ) { ret = s1 . compareTo ( s2 ) ; } else if ( s1 == null && s2 == null ) { ret = 0 ; } else if ( s2 == null ) { ret = 1 ; } else { ret = - 1 ; } return ret ; }
Handle null .
2,334
public static String boxify ( final char boxing , final String text ) { if ( boxing != 0 && StringUtils . isNotBlank ( text ) ) { final StringBuilder b = new StringBuilder ( ) ; b . append ( NEW_LINE ) ; final String line = StringUtils . repeat ( String . valueOf ( boxing ) , text . length ( ) + 4 ) ; b . append ( line...
Returns a String which is surrounded by a box made of boxing char .
2,335
public static Integer assign ( final Integer value , final Integer defaultValueIfNull ) { return value != null ? value : defaultValueIfNull ; }
Return the value unless it is null in which case it returns the default value .
2,336
public static void setInternalComments ( Node node , ParserRuleContext parserRuleContext , AdapterParameters adapterParameters ) { BufferedTokenStream tokens = adapterParameters . getTokens ( ) ; if ( node == null || parserRuleContext == null || tokens == null ) { throw new IllegalArgumentException ( "Parameters must n...
If there are no statements within a block we need a special method to grab any comments that might exist between braces .
2,337
public static CompilationUnit parse ( String javaSource ) throws IOException , ParseException { ByteArrayInputStream inputStream = new ByteArrayInputStream ( javaSource . getBytes ( "UTF-8" ) ) ; return parse ( inputStream ) ; }
Parses a UTF - 8 encoded string as java source .
2,338
public String format ( Comment comment , int indentLevel , CommentLocation commentLocation ) { if ( comment == null || comment . getContent ( ) == null ) { return null ; } return format ( comment . getContent ( ) , indentLevel , commentLocation ) ; }
Format a given comment with the indent level specified .
2,339
public String format ( String comment , int indentLevel , CommentLocation commentLocation ) { if ( comment == null ) { return null ; } final StringBuilder indentString = new StringBuilder ( ) ; for ( int i = 0 ; i < indentLevel ; i ++ ) { indentString . append ( " " ) ; } boolean endsWithNewline = ( comment . endsWi...
Format a given comment string with the indent level specified .
2,340
public void animateOpen ( ) { prepareContent ( ) ; if ( onDrawerScrollListener != null ) { onDrawerScrollListener . onScrollStarted ( ) ; } animateOpen ( vertical ? viewHandle . getTop ( ) : viewHandle . getLeft ( ) ) ; sendAccessibilityEvent ( AccessibilityEvent . TYPE_WINDOW_STATE_CHANGED ) ; if ( onDrawerScrollListe...
Opens the drawer with an animation .
2,341
public void animateClose ( ) { prepareContent ( ) ; if ( onDrawerScrollListener != null ) { onDrawerScrollListener . onScrollStarted ( ) ; } animateClose ( vertical ? viewHandle . getTop ( ) : viewHandle . getLeft ( ) ) ; if ( onDrawerScrollListener != null ) { onDrawerScrollListener . onScrollEnded ( ) ; } }
Closes the drawer with an animation .
2,342
public static ManifestBuilder builder ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { ManifestModel manifestModel = implementationModel != null ? implementationModel . getManifest ( ) : null ; return new ManifestBuilder ( classLoader , manifestModel ) ; }
Creates a ManifestBuilder .
2,343
public static void registerOperations ( KnowledgeComponentImplementationModel model , Map < String , KnowledgeOperation > operations , KnowledgeOperation defaultOperation ) { OperationsModel operationsModel = model . getOperations ( ) ; if ( operationsModel != null ) { for ( OperationModel operationModel : operationsMo...
Registers operations .
2,344
public static void setGlobals ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime , boolean singleton ) { Globals globals = runtime . getSessionGlobals ( ) ; if ( globals != null ) { Map < String , Object > globalsMap = new HashMap < String , Object > ( ) ; globalsMap . put ( GLOBALS , new...
Sets the globals .
2,345
public static boolean containsGlobals ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { Map < String , Object > expressionMap = getMap ( message , operation . getGlobalExpressionMappings ( ) , null ) ; return expressionMap != null && expressionMap . size ( ) > 0 ; }
Contains the globals .
2,346
public static Object getInput ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { List < Object > list = getList ( message , operation . getInputExpressionMappings ( ) ) ; switch ( list . size ( ) ) { case 0 : return filterRemoteDefaultInputContent ( message . getContent ( ) , runtime ...
Gets the input .
2,347
public static List < Object > getInputOnlyList ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { return getInputList ( message , operation . getInputOnlyExpressionMappings ( ) , runtime ) ; }
Gets an input - only list .
2,348
public static Map < String , Object > getInputOutputMap ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { Map < String , Object > map = new LinkedHashMap < String , Object > ( ) ; Map < String , ExpressionMapping > inputs = operation . getInputOutputExpressionMappings ( ) ; for ( Ent...
Gets an input - output map .
2,349
public static Map < String , Object > getInputMap ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { Map < String , Object > map = new HashMap < String , Object > ( ) ; List < ExpressionMapping > inputs = operation . getInputExpressionMappings ( ) ; if ( inputs . size ( ) > 0 ) { map ...
Gets an input map .
2,350
public static void setOutputs ( Message message , KnowledgeOperation operation , Map < String , Object > contextOverrides ) { try { setOutputsOrFaults ( message , operation . getOutputExpressionMappings ( ) , contextOverrides , RESULT , false ) ; } catch ( Exception e ) { setOutputsOrFaults ( message , operation . getO...
Sets the outputs .
2,351
public static void setFaults ( Message message , KnowledgeOperation operation , Map < String , Object > contextOverrides ) { setOutputsOrFaults ( message , operation . getFaultExpressionMappings ( ) , contextOverrides , FAULT , false ) ; }
Sets the faults .
2,352
public static Map < String , List < Object > > getListMap ( Message message , List < ExpressionMapping > expressionMappings , boolean expand , String undefinedVariable ) { return getListMap ( message , expressionMappings , expand , undefinedVariable , null ) ; }
Gets a list map .
2,353
@ Transformer ( to = "{urn:switchyard-quickstart-demo:helpdesk:1.0}openTicketResponse" ) public Element transformToElement ( TicketAck ticketAck ) { StringBuilder ackXml = new StringBuilder ( ) . append ( "<helpdesk:openTicketResponse xmlns:helpdesk=\"urn:switchyard-quickstart-demo:helpdesk:1.0\">" ) . append ( "<ticke...
Transform to element .
2,354
public Ticket transformToTicket ( TicketAck ticketAck ) { Ticket ticket = new Ticket ( ) ; ticket . setId ( ticketAck . getId ( ) ) ; return ticket ; }
Transform to ticket .
2,355
private String getElementValue ( Element parent , String elementName ) { String value = null ; NodeList nodes = parent . getElementsByTagName ( elementName ) ; if ( nodes . getLength ( ) > 0 ) { value = nodes . item ( 0 ) . getChildNodes ( ) . item ( 0 ) . getNodeValue ( ) ; } return value ; }
Gets the element value .
2,356
private Element toElement ( String xml ) { DOMResult dom = new DOMResult ( ) ; try { TransformerFactory . newInstance ( ) . newTransformer ( ) . transform ( new StreamSource ( new StringReader ( xml ) ) , dom ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return ( ( Document ) dom . getNode ( ) ) . getDocume...
To element .
2,357
public void generateCommand ( Exchange exchange ) throws Exception { System . out . println ( ">> We will fire all rules commands" ) ; FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand ( ) ; exchange . getIn ( ) . setBody ( fireAllRulesCommand ) ; }
Generate command .
2,358
public void insertAndFireAll ( Exchange exchange ) { final Message in = exchange . getIn ( ) ; final Object body = in . getBody ( ) ; BatchExecutionCommandImpl command = new BatchExecutionCommandImpl ( ) ; final List < GenericCommand < ? > > commands = command . getCommands ( ) ; commands . add ( new InsertObjectComman...
Insert and fire all .
2,359
@ Transformer ( from = "{urn:switchyard-quickstart:rules-interview-dtable:0.1.0}verify" ) public Applicant transformVerifyToApplicant ( Element e ) { String name = getElementValue ( e , "name" ) ; int age = Integer . valueOf ( getElementValue ( e , "age" ) ) . intValue ( ) ; return new Applicant ( name , age ) ; }
Transform verify to applicant .
2,360
public ExtendedRegisterableItemsFactory build ( ) { return new NoopExtendedRegisterableItemsFactory ( ) { private RuntimeEngine _runtime ; private List < EventListener > _listeners = new ArrayList < EventListener > ( ) ; private synchronized List < EventListener > listeners ( RuntimeEngine runtime ) { if ( _runtime != ...
Builds a ExtendedRegisterableItemsFactory .
2,361
public UserGroupCallback build ( ) { UserGroupCallback callback = null ; Properties properties = _propertiesBuilder . build ( ) ; if ( _userGroupCallbackClass != null ) { callback = construct ( properties ) ; } if ( callback == null && USER_CALLBACK_IMPL != null ) { try { if ( "props" . equalsIgnoreCase ( USER_CALLBACK...
Builds a UserGroupCallback .
2,362
public static UserGroupCallbackBuilder builder ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { UserGroupCallbackModel userGroupCallbackModel = implementationModel != null ? implementationModel . getUserGroupCallback ( ) : null ; return new UserGroupCallbackBuilder ( classLoader...
Creates a UserGroupCallbackBuilder .
2,363
public static final synchronized BPMTaskService getTaskService ( QName serviceDomainName , QName serviceName ) { KnowledgeRuntimeManager runtimeManager = KnowledgeRuntimeManagerRegistry . getRuntimeManager ( serviceDomainName , serviceName ) ; if ( runtimeManager != null ) { RuntimeEngine runtimeEngine = runtimeManager...
Gets a task service .
2,364
@ Transformer ( to = "{urn:switchyard-quickstart:rules-interview:0.1.0}verifyResponse" ) public Element transformBooleanToVerifyResponse ( boolean b ) { String xml = new StringBuilder ( ) . append ( "<urn:verifyResponse xmlns:urn='urn:switchyard-quickstart:rules-interview:0.1.0'>" ) . append ( "<return>" ) . append ( b...
Transform boolean to verify response .
2,365
public SwitchYardServiceResponse invoke ( SwitchYardServiceRequest request ) { Map < String , Object > contextOut = new HashMap < String , Object > ( ) ; Object contentOut = null ; Object fault = null ; try { QName serviceName = request . getServiceName ( ) ; if ( serviceName == null ) { throw CommonKnowledgeMessages ....
Invokes the request and returns the response .
2,366
public static final synchronized KnowledgeRuntimeManager getRuntimeManager ( QName serviceDomainName , QName serviceName ) { if ( serviceDomainName == null ) { serviceDomainName = ROOT_DOMAIN ; } Map < QName , KnowledgeRuntimeManager > reg = REGISTRY . get ( serviceDomainName ) ; return reg != null ? reg . get ( servic...
Gets a runtime manager .
2,367
public static final synchronized void putRuntimeManager ( QName serviceDomainName , QName serviceName , KnowledgeRuntimeManager runtimeManager ) { if ( serviceDomainName == null ) { serviceDomainName = ROOT_DOMAIN ; } Map < QName , KnowledgeRuntimeManager > reg = REGISTRY . get ( serviceDomainName ) ; if ( reg == null ...
Puts a runtime manager .
2,368
public WorkItemHandler build ( ProcessRuntime processRuntime , RuntimeManager runtimeManager ) { WorkItemHandler workItemHandler = construct ( processRuntime , runtimeManager ) ; if ( workItemHandler instanceof SwitchYardServiceTaskHandler ) { SwitchYardServiceTaskHandler systh = ( SwitchYardServiceTaskHandler ) workIt...
Builds a WorkItemHandler .
2,369
public static List < WorkItemHandlerBuilder > builders ( ClassLoader classLoader , ServiceDomain serviceDomain , KnowledgeComponentImplementationModel implementationModel ) { List < WorkItemHandlerBuilder > builders = new ArrayList < WorkItemHandlerBuilder > ( ) ; Set < String > registeredNames = new HashSet < String >...
Creates WorkItemHandlerBuilders .
2,370
public KieRuntimeLogger build ( KieRuntimeEventManager runtimeEventManager ) { KieRuntimeLogger logger = null ; if ( _loggerType != null && runtimeEventManager != null ) { KieLoggers loggers = KieServices . Factory . get ( ) . getLoggers ( ) ; switch ( _loggerType ) { case CONSOLE : logger = loggers . newConsoleLogger ...
Builds a KieRuntimeLogger .
2,371
public static List < LoggerBuilder > builders ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { List < LoggerBuilder > builders = new ArrayList < LoggerBuilder > ( ) ; if ( implementationModel != null ) { LoggersModel loggersModel = implementationModel . getLoggers ( ) ; if ( log...
Creates LoggerBuilders .
2,372
public String getFaultMessage ( ) { String fmsg = null ; Object fault = getFault ( ) ; if ( fault != null ) { if ( fault instanceof Throwable ) { fmsg = String . format ( CommonKnowledgeMessages . MESSAGES . faultEncountered ( ) + " [%s(message=%s)]: %s" , fault . getClass ( ) . getName ( ) , ( ( Throwable ) fault ) . ...
Gets a fault message if a fault exists .
2,373
public String getGroupId ( ) { List < String > groups = USERS_GROUPS . get ( _userId ) ; return ( groups != null && groups . size ( ) > 0 ) ? groups . get ( 0 ) : null ; }
Gets the group id .
2,374
public Map < String , String > getUsersGroups ( ) { Map < String , String > usersGroups = new LinkedHashMap < String , String > ( ) ; for ( Map . Entry < String , List < String > > entry : USERS_GROUPS . entrySet ( ) ) { String key = entry . getKey ( ) ; usersGroups . put ( key + " (" + entry . getValue ( ) . get ( 0 )...
Gets the users groups .
2,375
private void fetchTasks ( ) { synchronized ( _userTasks ) { _userTasks . clear ( ) ; _userTickets . clear ( ) ; List < TaskSummary > tasks = _taskService . getTasksAssignedAsPotentialOwner ( _userId , EN_UK ) ; for ( TaskSummary task : tasks ) { _userTasks . add ( task ) ; Map < String , Object > params = _taskService ...
Fetch tasks .
2,376
private void completeTasks ( ) { synchronized ( _userTasks ) { if ( _userTasks . size ( ) > 0 ) { for ( TaskSummary task : _userTasks ) { _taskService . claim ( task . getId ( ) , _userId ) ; _taskService . start ( task . getId ( ) , _userId ) ; Map < String , Object > results = new HashMap < String , Object > ( ) ; Ti...
Complete tasks .
2,377
public PropertiesBuilder setModelProperties ( PropertiesModel propertiesModel ) { _modelProperties = propertiesModel != null ? propertiesModel . toProperties ( ) : null ; return this ; }
Sets the model properties .
2,378
public Properties build ( ) { Properties buildProperties = new Properties ( ) ; merge ( _defaultProperties , buildProperties ) ; merge ( _modelProperties , buildProperties ) ; merge ( _overrideProperties , buildProperties ) ; return buildProperties ; }
Builds a Properties .
2,379
public static PropertiesBuilder builder ( KnowledgeComponentImplementationModel implementationModel ) { PropertiesModel propertiesModel = null ; if ( implementationModel != null ) { propertiesModel = implementationModel . getProperties ( ) ; } return new PropertiesBuilder ( propertiesModel ) ; }
Creates a PropertiesBuilder .
2,380
public List < Resource > buildResources ( ) { List < Resource > resources = new ArrayList < Resource > ( ) ; for ( ResourceBuilder builder : _resourceBuilders ) { Resource resource = builder . build ( ) ; if ( resource != null ) { resources . add ( resource ) ; } } return resources ; }
Builds the Resources .
2,381
public Channel build ( ) { Channel channel = null ; if ( _channelClass != null ) { channel = Construction . construct ( _channelClass ) ; if ( channel instanceof SwitchYardServiceChannel ) { SwitchYardServiceChannel sysc = ( SwitchYardServiceChannel ) channel ; sysc . setServiceName ( _serviceName ) ; sysc . setOperati...
Builds a Channel .
2,382
public static List < ChannelBuilder > builders ( ClassLoader classLoader , ServiceDomain serviceDomain , KnowledgeComponentImplementationModel implementationModel ) { List < ChannelBuilder > builders = new ArrayList < ChannelBuilder > ( ) ; if ( implementationModel != null ) { ChannelsModel channelsModel = implementati...
Creates ChannelBuilders .
2,383
private void addBook ( String isbn , String title , String synopsis , int quantity ) { Book book = new Book ( ) ; book . setIsbn ( isbn ) ; book . setTitle ( title ) ; book . setSynopsis ( synopsis ) ; isbns_to_books . put ( isbn , book ) ; isbns_to_quantities . put ( isbn , quantity ) ; }
Adds the book .
2,384
public Collection < Book > getAvailableBooks ( ) { synchronized ( librarian ) { Collection < Book > books = new LinkedList < Book > ( ) ; for ( Entry < String , Integer > entry : isbns_to_quantities . entrySet ( ) ) { if ( entry . getValue ( ) > 0 ) { books . add ( getBook ( entry . getKey ( ) ) ) ; } } return books ; ...
Gets the available books .
2,385
public Loan attemptLoan ( String isbn , String loanId ) { Loan loan = new Loan ( ) ; loan . setId ( loanId ) ; Book book = getBook ( isbn ) ; if ( book != null ) { synchronized ( librarian ) { int quantity = getQuantity ( book ) ; if ( quantity > 0 ) { quantity -- ; isbns_to_quantities . put ( isbn , quantity ) ; loan ...
Attempt loan .
2,386
public boolean returnLoan ( Loan loan ) { if ( loan != null ) { Book book = loan . getBook ( ) ; if ( book != null ) { String isbn = book . getIsbn ( ) ; if ( isbn != null ) { synchronized ( librarian ) { Integer quantity = isbns_to_quantities . get ( isbn ) ; if ( quantity != null ) { quantity = new Integer ( quantity...
Return loan .
2,387
public Resource build ( ) { Resource resource = null ; if ( _url != null ) { resource = _kieResources . newUrlResource ( _url ) ; if ( resource != null ) { if ( _resourceType != null ) { resource . setResourceType ( _resourceType ) ; } if ( _resourceConfiguration != null ) { resource . setConfiguration ( _resourceConfi...
Builds a Resource .
2,388
public RuntimeEnvironmentBuilder entityManagerFactory ( Object emf ) { if ( emf == null ) { return this ; } if ( ! ( emf instanceof EntityManagerFactory ) ) { throw new IllegalArgumentException ( "Argument is not of type EntityManagerFactory" ) ; } _runtimeEnvironment . setEmf ( ( EntityManagerFactory ) emf ) ; return ...
Sets entityManagerFactory .
2,389
public RuntimeEnvironmentBuilder addAsset ( Resource asset , ResourceType type ) { if ( asset == null || type == null ) { return this ; } _runtimeEnvironment . addAsset ( asset , type ) ; return this ; }
Adds and asset .
2,390
public RuntimeEnvironmentBuilder schedulerService ( Object globalScheduler ) { if ( globalScheduler == null ) { return this ; } if ( ! ( globalScheduler instanceof GlobalSchedulerService ) ) { throw new IllegalArgumentException ( "Argument is not of type GlobalSchedulerService" ) ; } _runtimeEnvironment . setSchedulerS...
Sets the schedulerService .
2,391
public KnowledgeRuntimeManager newRuntimeManager ( KnowledgeRuntimeManagerType type ) { RuntimeManager runtimeManager ; final String identifier = _identifierRoot + IDENTIFIER_COUNT . incrementAndGet ( ) ; final ClassLoader origTCCL = Classes . setTCCL ( _classLoader ) ; try { runtimeManager = _runtimeManagerBuilder . b...
Creates a new KnowledgeRuntimeManager .
2,392
public static List < ListenerBuilder > builders ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { List < ListenerBuilder > builders = new ArrayList < ListenerBuilder > ( ) ; if ( implementationModel != null ) { ListenersModel listenersModel = implementationModel . getListeners ( ...
Creates ListenerBuilders .
2,393
protected boolean isBoolean ( Exchange exchange , Message message , String name ) { Boolean b = getBoolean ( exchange , message , name ) ; return b != null && b . booleanValue ( ) ; }
Gets a primitive boolean context property .
2,394
protected Boolean getBoolean ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof Boolean ) { return ( Boolean ) value ; } else if ( value instanceof String ) { return Boolean . valueOf ( ( ( String ) value ) . trim ( ) ) ; } return false...
Gets a Boolean context property .
2,395
protected Integer getInteger ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof Integer ) { return ( Integer ) value ; } else if ( value instanceof Number ) { return Integer . valueOf ( ( ( Number ) value ) . intValue ( ) ) ; } else if ...
Gets an Integer context property .
2,396
protected Long getLong ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof Long ) { return ( Long ) value ; } else if ( value instanceof Number ) { return Long . valueOf ( ( ( Number ) value ) . longValue ( ) ) ; } else if ( value instan...
Gets a Long context property .
2,397
protected String getString ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof String ) { return ( String ) value ; } else if ( value != null ) { return String . valueOf ( value ) ; } return null ; }
Gets a String context property .
2,398
protected Object getObject ( Exchange exchange , Message message , String name ) { Context context = message != null ? exchange . getContext ( message ) : exchange . getContext ( ) ; return context . getPropertyValue ( name ) ; }
Gets an Object context property .
2,399
protected Map < String , Object > getGlobalVariables ( KnowledgeRuntimeEngine runtimeEngine ) { Map < String , Object > globalVariables = new HashMap < String , Object > ( ) ; if ( runtimeEngine != null ) { Globals globals = runtimeEngine . getSessionGlobals ( ) ; if ( globals != null ) { for ( String key : globals . g...
Gets the global variables from the knowledge runtime engine .