idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
8,600
private OtherDirectCosts getOtherDirectCosts ( BudgetPeriodDto periodInfo ) { OtherDirectCosts otherDirectCosts = OtherDirectCosts . Factory . newInstance ( ) ; if ( periodInfo != null && periodInfo . getOtherDirectCosts ( ) . size ( ) > 0 ) { if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getpublications ( ) != null ) { otherDirectCosts . setPublicationCosts ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getpublications ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getmaterials ( ) != null ) { otherDirectCosts . setMaterialsSupplies ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getmaterials ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getConsultants ( ) != null ) { otherDirectCosts . setConsultantServices ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getConsultants ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getcomputer ( ) != null ) { otherDirectCosts . setADPComputerServices ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getcomputer ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getsubAwards ( ) != null ) { otherDirectCosts . setSubawardConsortiumContractualCosts ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getsubAwards ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getAlterations ( ) != null ) { otherDirectCosts . setAlterationsRenovations ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getAlterations ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getEquipRental ( ) != null ) { otherDirectCosts . setEquipmentRentalFee ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . getEquipRental ( ) . bigDecimalValue ( ) ) ; } otherDirectCosts . setOthers ( getOthersForOtherDirectCosts ( periodInfo ) ) ; if ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . gettotalOtherDirect ( ) != null ) { otherDirectCosts . setTotalOtherDirectCost ( periodInfo . getOtherDirectCosts ( ) . get ( 0 ) . gettotalOtherDirect ( ) . bigDecimalValue ( ) ) ; } } return otherDirectCosts ; }
This method gets OtherDirectCosts details such as PublicationCosts MaterialsSupplies ConsultantServices ADPComputerServices SubawardConsortiumContractualCosts EquipmentRentalFee AlterationsRenovations and TotalOtherDirectCost in BudgetYearDataType based on BudgetPeriodInfo for the RRBudget .
665
64
8,601
private Others getOthersForOtherDirectCosts ( BudgetPeriodDto periodInfo ) { Others others = Others . Factory . newInstance ( ) ; if ( periodInfo != null && periodInfo . getOtherDirectCosts ( ) != null ) { Others . Other otherArray [ ] = new Others . Other [ periodInfo . getOtherDirectCosts ( ) . size ( ) ] ; int Otherscount = 0 ; for ( OtherDirectCostInfoDto otherDirectCostInfo : periodInfo . getOtherDirectCosts ( ) ) { Others . Other other = Others . Other . Factory . newInstance ( ) ; if ( otherDirectCostInfo . getOtherCosts ( ) != null && otherDirectCostInfo . getOtherCosts ( ) . size ( ) > 0 ) { other . setCost ( new BigDecimal ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COST ) ) ) ; } other . setDescription ( OTHERCOST_DESCRIPTION ) ; otherArray [ Otherscount ] = other ; Otherscount ++ ; } others . setOtherArray ( otherArray ) ; } return others ; }
This method is to get Other type description and total cost OtherDirectCosts details in BudgetYearDataType based on BudgetPeriodInfo for the RRBudget .
250
33
8,602
public static void status ( String statusText ) { try { getEventManager ( ) . fireLocalEvent ( STATUS_EVENT , statusText == null ? "" : statusText ) ; } catch ( Throwable e ) { log . error ( e ) ; } }
Fires a generic event of type STATUS to update any object that subscribes to it .
56
19
8,603
public static void ping ( String responseEvent , List < PingFilter > filters , Recipient ... recipients ) { IEventManager eventManager = getEventManager ( ) ; IGlobalEventDispatcher ged = ( ( ILocalEventDispatcher ) eventManager ) . getGlobalEventDispatcher ( ) ; if ( ged != null ) { ged . Ping ( responseEvent , filters , recipients ) ; } }
Fires a ping request to specified or all recipients .
88
11
8,604
public static String getChannelName ( String eventName ) { return eventName == null ? null : EVENT_PREFIX + eventName . split ( "\\." , 2 ) [ 0 ] ; }
Returns the messaging channel name from the event name .
42
10
8,605
public static String getEventName ( String channelName ) { int i = channelName . indexOf ( EVENT_PREFIX ) ; return i < 0 ? channelName : channelName . substring ( i + EVENT_PREFIX . length ( ) ) ; }
Returns the event name from the channel name .
56
9
8,606
@ Override public void refresh ( ) { String url = mockupTypes . getUrl ( mockupType ) ; if ( mockupId == null || url == null ) { iframe . setSrc ( null ) ; return ; } iframe . setSrc ( String . format ( url , mockupId , System . currentTimeMillis ( ) ) ) ; }
Refreshes the iframe content .
79
8
8,607
public String getPath ( ) { if ( path == null ) { HelpModule module = HelpModule . getModule ( id ) ; path = module == null ? "" : module . getTitle ( ) ; } return path ; }
Returns the path that determines where the associated menu item will appear under the help submenu . If this value has not been explicitly set and a help module has been specified its value will be determined from the help module .
47
43
8,608
public String getAction ( ) { if ( action == null ) { HelpModule module = HelpModule . getModule ( id ) ; action = module == null ? "" : "groovy:" + CareWebUtil . class . getName ( ) + ".showHelpTopic(\"" + id + "\",\"" + ( topic == null ? "" : topic ) + "\",\"" + module . getTitle ( ) + "\");" ; } return action ; }
Returns the action that will be invoked when the associated menu item is clicked . For externally derived help content this value must be explicitly set . Otherwise it will be determined automatically from the specified help module .
99
39
8,609
public static ApplicationContext createAppContext ( Page page ) { XmlWebApplicationContext appContext = new FrameworkAppContext ( ) ; new AppContextInitializer ( page ) . initialize ( appContext ) ; appContext . refresh ( ) ; return appContext ; }
Creates an application context as a child of the root application context and associates it with the specified page . In this way any objects managed by the root application context are available to the framework context .
54
39
8,610
public static void destroyAppContext ( Page page ) { XmlWebApplicationContext appContext = getAppContext ( page ) ; if ( appContext != null ) { appContext . close ( ) ; } }
Destroys the application context associated with the specified page .
43
12
8,611
@ Override public ApplicationContext getChildAppContext ( ) { ApplicationContext appContext = getAppContext ( ExecutionContext . getPage ( ) ) ; return appContext == null ? getRootAppContext ( ) : appContext ; }
Returns the application context for the current scope . If no page exists or no application context is associated with the page looks for an application context registered to the current thread . Failing that returns the root application context .
48
42
8,612
public static XmlWebApplicationContext getAppContext ( Page page ) { return page == null ? null : ( XmlWebApplicationContext ) page . getAttribute ( APP_CONTEXT_ATTRIB ) ; }
Returns the application context associated with the given page .
45
10
8,613
private String firstUpper ( String value ) { return value == null ? null : value . substring ( 0 , 1 ) . toUpperCase ( ) + value . substring ( 1 ) ; }
Convert first character of a string to upper case .
43
11
8,614
public Object getPropertyValue ( Object instance , boolean forceDirect ) { try { if ( instance == null ) { return dflt == null || ! isSerializable ( ) ? null : getPropertyType ( ) . getSerializer ( ) . deserialize ( dflt ) ; } if ( ! forceDirect && instance instanceof IPropertyAccessor ) { return ( ( IPropertyAccessor ) instance ) . getPropertyValue ( this ) ; } Method method = PropertyUtil . findGetter ( getter , instance , null ) ; return method == null ? null : method . invoke ( instance ) ; } catch ( Exception e ) { throw MiscUtil . toUnchecked ( e ) ; } }
Returns the property value for a specified object instance .
147
10
8,615
public void setPropertyValue ( Object instance , Object value , boolean forceDirect ) { try { if ( ! forceDirect && instance instanceof IPropertyAccessor ) { ( ( IPropertyAccessor ) instance ) . setPropertyValue ( this , value ) ; return ; } Method method = null ; try { method = PropertyUtil . findSetter ( setter , instance , value == null ? null : value . getClass ( ) ) ; } catch ( Exception e ) { if ( value != null ) { PropertySerializer < ? > serializer = getPropertyType ( ) . getSerializer ( ) ; value = value instanceof String ? serializer . deserialize ( ( String ) value ) : serializer . serialize ( value ) ; method = PropertyUtil . findSetter ( setter , instance , value . getClass ( ) ) ; } else { throw e ; } } if ( method != null ) { method . invoke ( instance , value ) ; } } catch ( Exception e ) { throw MiscUtil . toUnchecked ( e ) ; } }
Sets the property value for a specified object instance .
225
11
8,616
public Integer getConfigValueInt ( String key , Integer dflt ) { try { return Integer . parseInt ( getConfigValue ( key ) ) ; } catch ( Exception e ) { return dflt ; } }
This is a convenience method for returning a named configuration value that is expected to be an integer .
44
19
8,617
public Double getConfigValueDouble ( String key , Double dflt ) { try { return Double . parseDouble ( getConfigValue ( key ) ) ; } catch ( Exception e ) { return dflt ; } }
This is a convenience method for returning a named configuration value that is expected to be a double floating point number .
44
22
8,618
public Boolean getConfigValueBoolean ( String key , Boolean dflt ) { try { String value = getConfigValue ( key ) ; return value == null ? dflt : Boolean . parseBoolean ( value ) ; } catch ( Exception e ) { return dflt ; } }
This is a convenience method for returning a named configuration value that is expected to be a Boolean value .
58
20
8,619
public String [ ] getConfigValueArray ( String key , String delimiter ) { return StringUtils . split ( getConfigValue ( key ) , delimiter ) ; }
This is a convenience method for returning a named configuration value that is expected to be a list of array elements .
36
22
8,620
@ Override public boolean include ( T result ) { return getDateRange ( ) . inRange ( DateUtil . stripTime ( dateTypeExtractor . getDateByType ( result , dateType ) ) , true , true ) ; }
Filter result based on selected date range .
51
8
8,621
public static void appendResponse ( StringBuilder buffer , String response ) { if ( response != null && ! response . isEmpty ( ) ) { if ( buffer . length ( ) > 0 ) { buffer . append ( "\r\n" ) ; } buffer . append ( response ) ; } }
Accumulate response values in string buffer .
61
9
8,622
public void ccowJoin ( ) { if ( ccowIsActive ( ) ) { return ; } if ( ccowContextManager == null && ccowEnabled ) { ccowContextManager = new CCOWContextManager ( ) ; ccowContextManager . subscribe ( this ) ; ccowContextManager . run ( "CareWebFramework#" , "" , true , "*" ) ; } if ( ccowContextManager != null ) { if ( ! ccowContextManager . isActive ( ) ) { ccowContextManager . resume ( ) ; } init ( response -> { if ( response . rejected ( ) ) { ccowContextManager . suspend ( ) ; } updateCCOWStatus ( ) ; } ) ; } }
Joins the CCOW common context if available .
153
10
8,623
public void init ( IManagedContext < ? > item , ISurveyCallback callback ) { contextItems . clear ( ) ; if ( ccowIsActive ( ) ) { contextItems . addItems ( ccowContextManager . getCCOWContext ( ) ) ; } if ( item != null ) { initItem ( item , callback ) ; } else { SurveyResponse response = new SurveyResponse ( ) ; initItem ( managedContexts . iterator ( ) , response , callback ) ; } }
Initializes one or all managed contexts to their default state .
103
12
8,624
private void initItem ( IManagedContext < ? > item , ISurveyCallback callback ) { try { localChangeBegin ( item ) ; if ( hasSubject ( item . getContextName ( ) ) ) { item . setContextItems ( contextItems ) ; } else { item . init ( ) ; } localChangeEnd ( item , callback ) ; } catch ( ContextException e ) { log . error ( "Error initializing context." , e ) ; execCallback ( callback , new SurveyResponse ( e . toString ( ) ) ) ; } }
Initializes the managed context .
116
6
8,625
private boolean hasSubject ( String subject ) { boolean result = false ; String s = subject + "." ; int c = s . length ( ) ; for ( String propName : contextItems . getItemNames ( ) ) { result = s . equalsIgnoreCase ( propName . substring ( 0 , c ) ) ; if ( result ) { break ; } } return result ; }
Returns true if the CCOW context contains context settings pertaining to the named subject .
81
16
8,626
private void commitContexts ( boolean accept , boolean all ) { Stack < IManagedContext < ? > > stack = commitStack ; commitStack = new Stack <> ( ) ; // First, commit or cancel all pending context changes. for ( IManagedContext < ? > managedContext : stack ) { if ( managedContext . isPending ( ) ) { managedContext . commit ( accept ) ; } } // Then notify subscribers of the changes. while ( ! stack . isEmpty ( ) ) { stack . pop ( ) . notifySubscribers ( accept , all ) ; } }
Commit or cancel all pending context changes .
123
9
8,627
public void setCCOWEnabled ( boolean ccowEnabled ) { this . ccowEnabled = ccowEnabled ; if ( ! ccowEnabled && ccowContextManager != null ) { ccowContextManager . suspend ( ) ; ccowContextManager = null ; } updateCCOWStatus ( ) ; }
Enables or disables CCOW support .
63
9
8,628
public ContextItems getMarshaledContext ( ) { ContextItems marshaledContext = new ContextItems ( ) ; for ( IManagedContext < ? > managedContext : managedContexts ) { marshaledContext . addItems ( managedContext . getContextItems ( false ) ) ; } return marshaledContext ; }
Returns the marshaled context representing the state of all shared contexts .
64
13
8,629
private CCOWStatus getCCOWStatus ( ) { if ( ccowContextManager == null ) { return ccowEnabled ? CCOWStatus . NONE : CCOWStatus . DISABLED ; } else if ( ccowTransaction ) { return CCOWStatus . CHANGING ; } else { switch ( ccowContextManager . getState ( ) ) { case csParticipating : return CCOWStatus . JOINED ; case csSuspended : return CCOWStatus . BROKEN ; default : return CCOWStatus . NONE ; } } }
Returns the current status of the CCOW common context . Return values correspond to possible states of the standard CCOW status icon .
117
25
8,630
private void updateCCOWStatus ( ) { if ( ccowEnabled && eventManager != null ) { eventManager . fireLocalEvent ( "CCOW" , Integer . toString ( getCCOWStatus ( ) . ordinal ( ) ) ) ; } }
Notifies subscribers of a change in the CCOW status via a generic event .
54
16
8,631
@ Override public void registerObject ( Object object ) { if ( object instanceof IManagedContext ) { managedContexts . add ( ( IManagedContext < ? > ) object ) ; } }
Register an object with the context manager if it implements the IManagedContext interface .
43
17
8,632
@ Override public void unregisterObject ( Object object ) { if ( object instanceof IContextEvent ) { for ( IManagedContext < ? > managedContext : managedContexts ) { managedContext . removeSubscriber ( ( IContextEvent ) object ) ; } } if ( object instanceof IManagedContext ) { managedContexts . remove ( object ) ; } }
Unregister an object from the context manager .
80
9
8,633
private void localChangeEnd ( IManagedContext < ? > managedContext , boolean silent , boolean deferCommit , ISurveyCallback callback ) throws ContextException { if ( pendingStack . isEmpty ( ) || pendingStack . peek ( ) != managedContext ) { throw new ContextException ( "Illegal context change nesting." ) ; } if ( ! managedContext . isPending ( ) ) { pendingStack . pop ( ) ; return ; } commitStack . push ( managedContext ) ; managedContext . surveySubscribers ( silent , response -> { boolean accept = ! response . rejected ( ) ; if ( ! accept && log . isDebugEnabled ( ) ) { log . debug ( "Survey of managed context " + managedContext . getContextName ( ) + " returned '" + response + "'." ) ; } pendingStack . remove ( managedContext ) ; if ( ! deferCommit && ( ! accept || pendingStack . isEmpty ( ) ) ) { commitContexts ( accept , accept ) ; } execCallback ( callback , response ) ; } ) ; }
Commits a pending context change .
224
7
8,634
private void resetItem ( IManagedContext < ? > item , boolean silent , ISurveyCallback callback ) { try { localChangeBegin ( item ) ; item . reset ( ) ; localChangeEnd ( item , silent , true , callback ) ; } catch ( ContextException e ) { execCallback ( callback , e ) ; } }
Resets the managed context .
70
6
8,635
@ Override public void ccowPending ( CCOWContextManager sender , ContextItems contextItems ) { ccowTransaction = true ; updateCCOWStatus ( ) ; setMarshaledContext ( contextItems , false , response -> { if ( response . rejected ( ) ) { sender . setSurveyResponse ( response . toString ( ) ) ; } ccowTransaction = false ; updateCCOWStatus ( ) ; } ) ; }
Callback to handle a polling request from the CCOW context manager .
90
13
8,636
private void initTopicTree ( ) { try { Object data = view . getViewData ( ) ; if ( ! ( data instanceof TopicTree ) ) { return ; } TopicTree topicTree = ( TopicTree ) data ; HelpTopicNode baseNode ; if ( helpViewType == HelpViewType . TOC ) { HelpTopic topic = new HelpTopic ( null , hs . getName ( ) , hs . getName ( ) ) ; baseNode = new HelpTopicNode ( topic ) ; rootNode . addChild ( baseNode ) ; } else { baseNode = rootNode ; } initTopicTree ( baseNode , topicTree . getRoot ( ) ) ; } catch ( IOException e ) { return ; } }
Initialize the topic tree .
153
6
8,637
private void parseResources ( Element element , BeanDefinitionBuilder builder , ManagedList < AbstractBeanDefinition > resourceList ) { NodeList resources = element . getChildNodes ( ) ; for ( int i = 0 ; i < resources . getLength ( ) ; i ++ ) { Node node = resources . item ( i ) ; if ( ! ( node instanceof Element ) ) { continue ; } Element resource = ( Element ) resources . item ( i ) ; Class < ? extends IPluginResource > resourceClass = null ; switch ( getResourceType ( getNodeName ( resource ) ) ) { case button : resourceClass = PluginResourceButton . class ; break ; case help : resourceClass = PluginResourceHelp . class ; break ; case menu : resourceClass = PluginResourceMenu . class ; break ; case property : resourceClass = PluginResourcePropertyGroup . class ; break ; case css : resourceClass = PluginResourceCSS . class ; break ; case bean : resourceClass = PluginResourceBean . class ; break ; case command : resourceClass = PluginResourceCommand . class ; break ; case action : resourceClass = PluginResourceAction . class ; break ; } if ( resourceClass != null ) { BeanDefinitionBuilder resourceBuilder = BeanDefinitionBuilder . genericBeanDefinition ( resourceClass ) ; addProperties ( resource , resourceBuilder ) ; resourceList . add ( resourceBuilder . getBeanDefinition ( ) ) ; } } }
Parse the resource list .
296
6
8,638
private void parseAuthorities ( Element element , BeanDefinitionBuilder builder , ManagedList < AbstractBeanDefinition > authorityList ) { NodeList authorities = element . getChildNodes ( ) ; for ( int i = 0 ; i < authorities . getLength ( ) ; i ++ ) { Node node = authorities . item ( i ) ; if ( ! ( node instanceof Element ) ) { continue ; } Element authority = ( Element ) node ; BeanDefinitionBuilder authorityBuilder = BeanDefinitionBuilder . genericBeanDefinition ( PluginDefinition . Authority . class ) ; addProperties ( authority , authorityBuilder ) ; authorityList . add ( authorityBuilder . getBeanDefinition ( ) ) ; } }
Parse the authority list .
142
6
8,639
private void parseProperties ( Element element , BeanDefinitionBuilder builder , ManagedList < AbstractBeanDefinition > propertyList ) { NodeList properties = element . getChildNodes ( ) ; for ( int i = 0 ; i < properties . getLength ( ) ; i ++ ) { Node node = properties . item ( i ) ; if ( ! ( node instanceof Element ) ) { continue ; } Element property = ( Element ) node ; BeanDefinitionBuilder propertyBuilder = BeanDefinitionBuilder . genericBeanDefinition ( PropertyInfo . class ) ; addProperties ( property , propertyBuilder ) ; parseConfig ( property , propertyBuilder ) ; propertyList . add ( propertyBuilder . getBeanDefinition ( ) ) ; } }
Parse the property list .
150
6
8,640
private void parseConfig ( Element property , BeanDefinitionBuilder propertyBuilder ) { Element config = ( Element ) getTagChildren ( "config" , property ) . item ( 0 ) ; if ( config != null ) { Properties properties = new Properties ( ) ; NodeList entries = getTagChildren ( "entry" , config ) ; for ( int i = 0 ; i < entries . getLength ( ) ; i ++ ) { Element entry = ( Element ) entries . item ( i ) ; String key = entry . getAttribute ( "key" ) ; String value = entry . getTextContent ( ) . trim ( ) ; properties . put ( key , value ) ; } propertyBuilder . addPropertyValue ( "config" , properties ) ; } }
Parses out configuration settings for current property descriptor .
154
11
8,641
private ResourceType getResourceType ( String resourceTag ) { if ( resourceTag == null || ! resourceTag . endsWith ( "-resource" ) ) { return ResourceType . unknown ; } try { return ResourceType . valueOf ( resourceTag . substring ( 0 , resourceTag . length ( ) - 9 ) ) ; } catch ( Exception e ) { return ResourceType . unknown ; } }
Returns the ResourceType enum value corresponding to the resource tag .
82
12
8,642
public Fixture getFixture ( String name , String ... params ) throws Throwable { Type < ? > type = loadType ( name ) ; Object target = type . newInstanceUsingCoercion ( params ) ; return new DefaultFixture ( target ) ; }
Creates a new instance of a fixture class using a set of parameters .
55
15
8,643
protected int readWord ( InputStream inputStream ) throws IOException { byte [ ] bytes = new byte [ 2 ] ; boolean success = inputStream . read ( bytes ) == 2 ; return ! success ? - 1 : readWord ( bytes , 0 ) ; }
Reads a two - byte integer from the input stream .
54
12
8,644
protected int readWord ( byte [ ] data , int offset ) { int low = data [ offset ] & 0xff ; int high = data [ offset + 1 ] & 0xff ; return high << 8 | low ; }
Reads a two - byte integer from a byte array at the specified offset .
46
16
8,645
protected String getString ( byte [ ] data , int offset ) { if ( offset < 0 ) { return "" ; } int i = offset ; while ( data [ i ++ ] != 0x00 ) { ; } return getString ( data , offset , i - offset - 1 ) ; }
Returns a string value from a zero - terminated byte array at the specified offset .
61
16
8,646
protected String getString ( byte [ ] data , int offset , int length ) { return new String ( data , offset , length , CS_WIN1252 ) ; }
Returns a string value from the byte array .
35
9
8,647
protected byte [ ] loadBinaryFile ( String file ) throws IOException { try ( InputStream is = resource . getInputStream ( file ) ) { return IOUtils . toByteArray ( is ) ; } }
Loads the entire contents of a binary file into a byte array .
47
14
8,648
public static < T > IQueryResult < T > abortResult ( String reason ) { return packageResult ( null , CompletionStatus . ABORTED , reason == null ? null : Collections . singletonMap ( "reason" , ( Object ) reason ) ) ; }
Returns a query result for an aborted operation .
56
9
8,649
public static < T > IQueryResult < T > errorResult ( Throwable exception ) { return packageResult ( null , CompletionStatus . ERROR , exception == null ? null : Collections . singletonMap ( "exception" , ( Object ) exception ) ) ; }
Returns a query result for an error .
56
8
8,650
public List < T > filter ( List < T > results ) { if ( filters . isEmpty ( ) || results == null ) { return results ; } List < T > include = new ArrayList <> ( ) ; for ( T result : results ) { if ( include ( result ) ) { include . add ( result ) ; } } return results . size ( ) == include . size ( ) ? results : include ; }
Filters a list of results based on the member filters .
89
12
8,651
@ Override protected void updateVisibility ( boolean visible , boolean activated ) { tab . setVisible ( visible ) ; tab . setSelected ( visible && activated ) ; }
Sets the visibility and selection state of the tab .
37
11
8,652
private void init ( ) { add ( "text" , PropertySerializer . STRING , PropertyEditorText . class ) ; add ( "color" , PropertySerializer . STRING , PropertyEditorColor . class ) ; add ( "choice" , PropertySerializer . STRING , PropertyEditorChoiceList . class ) ; add ( "action" , PropertySerializer . STRING , PropertyEditorAction . class ) ; add ( "icon" , PropertySerializer . STRING , PropertyEditorIcon . class ) ; add ( "integer" , PropertySerializer . INTEGER , PropertyEditorInteger . class ) ; add ( "double" , PropertySerializer . DOUBLE , PropertyEditorDouble . class ) ; add ( "boolean" , PropertySerializer . BOOLEAN , PropertyEditorBoolean . class ) ; add ( "date" , PropertySerializer . DATE , PropertyEditorDate . class ) ; }
Add built - in property types .
194
7
8,653
private void computeInputParatemeter ( final EntryPoint entryPoint , final String [ ] parameterNames , final Set < Class < ? > > consolidatedTypeBlacklist , final Set < String > consolidatedNameBlacklist , MethodParameter methodParameter ) { // If the type is part of the blacklist, we discard it if ( consolidatedTypeBlacklist . contains ( methodParameter . getParameterType ( ) ) ) { LOGGER . debug ( "Ignoring parameter type [{}]. It is on the blacklist." , methodParameter . getParameterType ( ) ) ; return ; } // If we have a simple parameter type (primitives, wrappers, collections, arrays of primitives), we just get the name and we are done if ( ExternalEntryPointHelper . isSimpleRequestParameter ( methodParameter . getParameterType ( ) ) ) { // We need to look for @RequestParam in order to define its name final String parameterRealName = parameterNames [ methodParameter . getParameterIndex ( ) ] ; LOGGER . debug ( "Parameter Real Name [{}]" , parameterRealName ) ; // If the real name is part of the blacklist, we don't need to go any further if ( consolidatedNameBlacklist . contains ( parameterRealName ) ) { LOGGER . debug ( "Ignoring parameter name [{}]. It is on the blacklist." , parameterRealName ) ; return ; } final EntryPointParameter entryPointParameter = new EntryPointParameter ( ) ; entryPointParameter . setName ( parameterRealName ) ; entryPointParameter . setType ( methodParameter . getParameterType ( ) ) ; // Look for a change of names and the required attribute, true by default if ( methodParameter . hasParameterAnnotation ( RequestParam . class ) ) { final RequestParam requestParam = methodParameter . getParameterAnnotation ( RequestParam . class ) ; final String definedName = StringUtils . trimToEmpty ( requestParam . value ( ) ) ; // If the defined name is part of the blacklist, we don't need to go any further if ( consolidatedNameBlacklist . contains ( definedName ) ) { LOGGER . debug ( "Ignoring parameter @RequestParam defined name [{}]. It is on the blacklist." , definedName ) ; return ; } entryPointParameter . setName ( StringUtils . isNotBlank ( definedName ) ? definedName : entryPointParameter . getName ( ) ) ; entryPointParameter . setRequired ( requestParam . required ( ) ) ; entryPointParameter . setDefaultValue ( StringUtils . equals ( ValueConstants . DEFAULT_NONE , requestParam . defaultValue ( ) ) ? "" : requestParam . defaultValue ( ) ) ; } entryPoint . getParameters ( ) . add ( entryPointParameter ) ; } else if ( ! methodParameter . getParameterType ( ) . isArray ( ) ) { // Here we have an object, that we need to deep dive and get all its attributes, object arrays are not supported entryPoint . getParameters ( ) . addAll ( ExternalEntryPointHelper . getInternalEntryPointParametersRecursively ( methodParameter . getParameterType ( ) , consolidatedTypeBlacklist , consolidatedNameBlacklist , maxDeepLevel ) ) ; } }
Checks whether or not the supplied parameter should be part of the response or not . It adds to the entry point if necessary .
673
26
8,654
public static Method findSetter ( String methodName , Object instance , Class < ? > valueClass ) throws NoSuchMethodException { return findMethod ( methodName , instance , valueClass , true ) ; }
Returns the requested setter method from an object instance .
43
11
8,655
public static Method findGetter ( String methodName , Object instance , Class < ? > valueClass ) throws NoSuchMethodException { return findMethod ( methodName , instance , valueClass , false ) ; }
Returns the requested getter method from an object instance .
43
11
8,656
private static Method findMethod ( String methodName , Object instance , Class < ? > valueClass , boolean setter ) throws NoSuchMethodException { if ( methodName == null ) { return null ; } int paramCount = setter ? 1 : 0 ; for ( Method method : instance . getClass ( ) . getMethods ( ) ) { if ( method . getName ( ) . equals ( methodName ) && method . getParameterTypes ( ) . length == paramCount ) { Class < ? > targetClass = setter ? method . getParameterTypes ( ) [ 0 ] : method . getReturnType ( ) ; if ( valueClass == null || TypeUtils . isAssignable ( targetClass , valueClass ) ) { return method ; } } } throw new NoSuchMethodException ( "Compatible method not found: " + methodName ) ; }
Returns the requested method from an object instance .
180
9
8,657
protected ScaleTwoDecimal getTotalCost ( BudgetModularContract budgetModular ) { ScaleTwoDecimal totalCost = ScaleTwoDecimal . ZERO ; if ( budgetModular . getTotalDirectCost ( ) != null ) { totalCost = budgetModular . getTotalDirectCost ( ) ; } for ( BudgetModularIdcContract budgetModularIdc : budgetModular . getBudgetModularIdcs ( ) ) { if ( budgetModularIdc . getFundsRequested ( ) != null ) { totalCost = totalCost . add ( budgetModularIdc . getFundsRequested ( ) ) ; } } return totalCost ; }
This method is used to get total cost as sum of totalDirectCost and total sum of fundRequested .
142
22
8,658
protected String getCognizantFederalAgency ( RolodexContract rolodex ) { StringBuilder agency = new StringBuilder ( ) ; if ( rolodex . getOrganization ( ) != null ) { agency . append ( rolodex . getOrganization ( ) ) ; } agency . append ( COMMA_SEPERATOR ) ; if ( rolodex . getFirstName ( ) != null ) { agency . append ( rolodex . getFirstName ( ) ) ; } agency . append ( EMPTY_STRING ) ; if ( rolodex . getLastName ( ) != null ) { agency . append ( rolodex . getLastName ( ) ) ; } agency . append ( EMPTY_STRING ) ; if ( rolodex . getPhoneNumber ( ) != null ) { agency . append ( rolodex . getPhoneNumber ( ) ) ; } return agency . toString ( ) ; }
This method is used to get rolodex Organization FirstName LastName and PhoneNumber as a single string
207
22
8,659
@ Override public boolean transform ( IResource resource ) throws Exception { String path = resource . getSourcePath ( ) ; if ( path . startsWith ( "META-INF/" ) ) { return false ; } if ( hsFile == null && loader . isHelpSetFile ( path ) ) { hsFile = getResourceBase ( ) + resource . getTargetPath ( ) ; } return super . transform ( resource ) ; }
Excludes resources under the META - INF folder and checks the resource against the help set pattern saving a path reference if it matches .
93
27
8,660
@ Provides public VCSConfiguration loadConfiguration ( Gson gson ) { try { URL resource = ResourceUtils . getResourceAsURL ( VCS_CONFIG_JSON ) ; if ( null == resource ) { throw new IncorrectConfigurationException ( "Unable to find VCS configuration" ) ; } return gson . fromJson ( Resources . asCharSource ( resource , Charsets . UTF_8 ) . openStream ( ) , VCSConfiguration . class ) ; } catch ( IOException e ) { throw new IncorrectConfigurationException ( "Unable to read VCS configuration" , e ) ; } }
Loads VCS configuration
131
5
8,661
protected IQueueMessage < ID , DATA > takeFromQueue ( ) { KafkaMessage kMsg = kafkaClient . consumeMessage ( consumerGroupId , true , topicName , 1000 , TimeUnit . MILLISECONDS ) ; return kMsg != null ? deserialize ( kMsg . content ( ) ) : null ; }
Takes a message from Kafka queue .
70
8
8,662
public ParticipantListener createSessionListener ( String sessionId , ISessionUpdate callback ) { return SessionService . create ( self , sessionId , eventManager , callback ) ; }
Creates a session listener .
35
6
8,663
public void createSession ( String sessionId ) { boolean newSession = sessionId == null ; sessionId = newSession ? newSessionId ( ) : sessionId ; SessionController controller = sessions . get ( sessionId ) ; if ( controller == null ) { controller = SessionController . create ( sessionId , newSession ) ; sessions . put ( sessionId , controller ) ; } }
Creates a new session with the specified session id .
79
11
8,664
public void setActive ( boolean active ) { if ( this . active != active ) { this . active = active ; inviteListener . setActive ( active ) ; acceptListener . setActive ( active ) ; participants . clear ( ) ; participants . add ( self ) ; participantListener . setActive ( active ) ; } }
Sets the listening state of the service . When set to false the service stops listening to all events .
66
21
8,665
public void invite ( String sessionId , Collection < IPublisherInfo > invitees , boolean cancel ) { if ( invitees == null || invitees . isEmpty ( ) ) { return ; } List < Recipient > recipients = new ArrayList <> ( ) ; for ( IPublisherInfo invitee : invitees ) { recipients . add ( new Recipient ( RecipientType . SESSION , invitee . getSessionId ( ) ) ) ; } String eventData = sessionId + ( cancel ? "" : "^" + self . getUserName ( ) ) ; Recipient [ ] recips = new Recipient [ recipients . size ( ) ] ; eventManager . fireRemoteEvent ( EVENT_INVITE , eventData , recipients . toArray ( recips ) ) ; }
Sends an invitation request to the specified invitees .
166
11
8,666
public static void store ( String absolutePath , Properties configs ) throws IOException { OutputStream outStream = null ; try { outStream = new FileOutputStream ( new File ( absolutePath ) ) ; configs . store ( outStream , null ) ; } finally { try { if ( outStream != null ) { outStream . close ( ) ; } } catch ( IOException ignore ) { // do nothing. } } }
Write into properties file .
89
5
8,667
@ Override public void registerObject ( Object object ) { if ( object instanceof ICareWebStartup ) { startupRoutines . add ( ( ICareWebStartup ) object ) ; } }
Register a startup routine .
43
5
8,668
public void execute ( ) { List < ICareWebStartup > temp = new ArrayList <> ( startupRoutines ) ; for ( ICareWebStartup startupRoutine : temp ) { try { if ( startupRoutine . execute ( ) ) { unregisterObject ( startupRoutine ) ; } } catch ( Throwable t ) { log . error ( "Error executing startup routine." , t ) ; unregisterObject ( startupRoutine ) ; } } }
Execute registered startup routines .
99
6
8,669
public void setStretch ( boolean stretch ) { this . stretch = stretch ; image . setWidth ( stretch ? "100%" : null ) ; image . setHeight ( stretch ? "100%" : null ) ; }
Sets whether or not to stretch the image to fill its parent .
44
14
8,670
public static < T > T getBean ( Class < T > clazz ) { ApplicationContext appContext = getAppContext ( ) ; try { return appContext == null ? null : appContext . getBean ( clazz ) ; } catch ( Exception e ) { return null ; } }
Return the bean of the specified class .
62
8
8,671
public static String getProperty ( String name ) { if ( propertyProvider == null ) { initPropertyProvider ( ) ; } return propertyProvider . getProperty ( name ) ; }
Returns a property value from the application context .
36
9
8,672
public static Resource getResource ( String location ) { Resource resource = resolver . getResource ( location ) ; return resource . exists ( ) ? resource : null ; }
Returns the resource at the specified location . Supports classpath references .
34
13
8,673
public static Resource [ ] getResources ( String locationPattern ) { try { return resolver . getResources ( locationPattern ) ; } catch ( IOException e ) { throw MiscUtil . toUnchecked ( e ) ; } }
Returns an array of resources matching the location pattern .
48
10
8,674
protected static void setShell ( CareWebShell shell ) { if ( getShell ( ) != null ) { throw new RuntimeException ( "A CareWeb shell instance has already been registered." ) ; } ExecutionContext . getPage ( ) . setAttribute ( Constants . SHELL_INSTANCE , shell ) ; }
Sets the active instance of the CareWeb shell . An exception is raised if an active instance has already been set .
65
24
8,675
public static void showMessage ( String message , String caption ) { getShell ( ) . getMessageWindow ( ) . showMessage ( message , caption ) ; }
Sends an informational message for display by desktop .
33
10
8,676
public static void showHelpTopic ( String module , String topic , String label ) { getShell ( ) . getHelpViewer ( ) ; HelpUtil . show ( module , topic , label ) ; }
Shows help topic in help viewer .
43
8
8,677
public static String getUrlMapping ( String url , Map < String , String > urlMappings ) { if ( urlMappings != null ) { for ( String pattern : urlMappings . keySet ( ) ) { if ( urlMatcher . match ( pattern , url ) ) { return urlMappings . get ( pattern ) ; } } } return null ; }
Returns the target of a url pattern mapping .
77
9
8,678
public static String generateRandomPassword ( int minLength , int maxLength , String [ ] constraints ) { if ( constraints == null || constraints . length == 0 || minLength <= 0 || maxLength < minLength ) { throw new IllegalArgumentException ( ) ; } int pwdLength = RandomUtils . nextInt ( maxLength - minLength + 1 ) + minLength ; int [ ] min = new int [ constraints . length ] ; String [ ] chars = new String [ constraints . length ] ; char [ ] pwd = new char [ pwdLength ] ; int totalRequired = 0 ; for ( int i = 0 ; i < constraints . length ; i ++ ) { String [ ] pcs = constraints [ i ] . split ( "\\," , 2 ) ; min [ i ] = Integer . parseInt ( pcs [ 0 ] ) ; chars [ i ] = pcs [ 1 ] ; totalRequired += min [ i ] ; } if ( totalRequired > maxLength ) { throw new IllegalArgumentException ( "Maximum length and constraints in conflict." ) ; } int grp = 0 ; while ( pwdLength -- > 0 ) { if ( min [ grp ] <= 0 ) { grp = totalRequired > 0 ? grp + 1 : RandomUtils . nextInt ( constraints . length ) ; } int i = RandomUtils . nextInt ( pwd . length ) ; while ( pwd [ i ] != 0 ) { i = ++ i % pwd . length ; } pwd [ i ] = chars [ grp ] . charAt ( RandomUtils . nextInt ( chars [ grp ] . length ( ) ) ) ; min [ grp ] -- ; totalRequired -- ; } return new String ( pwd ) ; }
Generates a random password within the specified parameters .
372
10
8,679
public String [ ] getMessageWithParams ( ) { String [ ] messageWithParams = new String [ getParams ( ) . length + 1 ] ; messageWithParams [ 0 ] = errorMessage ; System . arraycopy ( params , 0 , messageWithParams , 1 , messageWithParams . length - 1 ) ; return messageWithParams ; }
This method returns the message as the first element followed by all params .
78
14
8,680
@ Override public boolean validateName ( String name ) { return name != null && ! name . isEmpty ( ) && StringUtils . isAlphanumericSpace ( name . replace ( ' ' , ' ' ) ) ; }
Validates a layout name .
48
6
8,681
@ Override public boolean layoutExists ( LayoutIdentifier layout ) { return getLayouts ( layout . shared ) . contains ( layout . name ) ; }
Returns true if the specified layout exists .
33
8
8,682
@ Override public void saveLayout ( LayoutIdentifier layout , String content ) { propertyService . saveValue ( getPropertyName ( layout . shared ) , layout . name , layout . shared , content ) ; }
Saves a layout with the specified name and content .
44
11
8,683
@ Override public void renameLayout ( LayoutIdentifier layout , String newName ) { String text = getLayoutContent ( layout ) ; saveLayout ( new LayoutIdentifier ( newName , layout . shared ) , text ) ; deleteLayout ( layout ) ; }
Rename a layout .
54
5
8,684
@ Override public void cloneLayout ( LayoutIdentifier layout , LayoutIdentifier layout2 ) { String text = getLayoutContent ( layout ) ; saveLayout ( layout2 , text ) ; }
Clone a layout .
40
5
8,685
@ Override public String getLayoutContent ( LayoutIdentifier layout ) { return propertyService . getValue ( getPropertyName ( layout . shared ) , layout . name ) ; }
Returns the layout content .
37
5
8,686
@ Override public String getLayoutContentByAppId ( String appId ) { String value = propertyService . getValue ( PROPERTY_LAYOUT_ASSOCIATION , appId ) ; return value == null ? null : getLayoutContent ( new LayoutIdentifier ( value , true ) ) ; }
Load the layout associated with the specified application id .
66
10
8,687
@ Override public List < String > getLayouts ( boolean shared ) { List < String > layouts = propertyService . getInstances ( getPropertyName ( shared ) , shared ) ; Collections . sort ( layouts , String . CASE_INSENSITIVE_ORDER ) ; return layouts ; }
Returns a list of saved layouts .
62
7
8,688
@ Override public CWFAuthenticationDetails buildDetails ( HttpServletRequest request ) { log . trace ( "Building details" ) ; CWFAuthenticationDetails details = new CWFAuthenticationDetails ( request ) ; return details ; }
Returns an instance of a CWFAuthenticationDetails object .
54
13
8,689
protected void init ( String classifier , String moduleBase ) throws MojoExecutionException { this . classifier = classifier ; this . moduleBase = moduleBase ; stagingDirectory = new File ( buildDirectory , classifier + "-staging" ) ; configTemplate = new ConfigTemplate ( classifier + "-spring.xml" ) ; exclusionFilter = exclusions == null || exclusions . isEmpty ( ) ? null : new WildcardFileFilter ( exclusions ) ; archiveConfig . setAddMavenDescriptor ( false ) ; }
Subclasses must call this method early in their execute method .
113
12
8,690
protected String getModuleVersion ( ) { StringBuilder sb = new StringBuilder ( ) ; int pcs = 0 ; for ( String pc : projectVersion . split ( "\\." ) ) { if ( pcs ++ > 3 ) { break ; } else { appendVersionPiece ( sb , pc ) ; } } appendVersionPiece ( sb , buildNumber ) ; return sb . toString ( ) ; }
Form a version string from the project version and build number .
90
12
8,691
public File newStagingFile ( String entryName , long modTime ) { File file = new File ( stagingDirectory , entryName ) ; if ( modTime != 0 ) { file . setLastModified ( modTime ) ; } file . getParentFile ( ) . mkdirs ( ) ; return file ; }
Creates a new file in the staging directory . Ensures that all folders in the path are also created .
67
22
8,692
public void throwMojoException ( String msg , Throwable e ) throws MojoExecutionException { if ( failOnError ) { throw new MojoExecutionException ( msg , e ) ; } else { getLog ( ) . error ( msg , e ) ; } }
If failOnError is enabled throws a MojoExecutionException . Otherwise logs the exception and resumes execution .
58
22
8,693
protected void assembleArchive ( ) throws Exception { getLog ( ) . info ( "Assembling " + classifier + " archive" ) ; if ( resources != null && ! resources . isEmpty ( ) ) { getLog ( ) . info ( "Copying additional resources." ) ; new ResourceProcessor ( this , moduleBase , resources ) . transform ( ) ; } if ( configTemplate != null ) { getLog ( ) . info ( "Creating config file." ) ; configTemplate . addEntry ( "info" , pluginDescriptor . getName ( ) , pluginDescriptor . getVersion ( ) , new Date ( ) . toString ( ) ) ; configTemplate . createFile ( stagingDirectory ) ; } try { File archive = createArchive ( ) ; if ( "war" . equalsIgnoreCase ( mavenProject . getPackaging ( ) ) && this . warInclusion ) { webappLibDirectory . mkdirs ( ) ; File webappLibArchive = new File ( this . webappLibDirectory , archive . getName ( ) ) ; Files . copy ( archive , webappLibArchive ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Exception occurred assembling archive." , e ) ; } }
Assembles the archive file . Optionally copies to the war application directory if the packaging type is war .
267
22
8,694
private File createArchive ( ) throws Exception { getLog ( ) . info ( "Creating archive." ) ; Artifact artifact = mavenProject . getArtifact ( ) ; String clsfr = noclassifier ? "" : ( "-" + classifier ) ; String archiveName = artifact . getArtifactId ( ) + "-" + artifact . getVersion ( ) + clsfr + ".jar" ; File jarFile = new File ( mavenProject . getBuild ( ) . getDirectory ( ) , archiveName ) ; MavenArchiver archiver = new MavenArchiver ( ) ; jarArchiver . addDirectory ( stagingDirectory ) ; archiver . setArchiver ( jarArchiver ) ; archiver . setOutputFile ( jarFile ) ; archiver . createArchive ( mavenSession , mavenProject , archiveConfig ) ; if ( noclassifier ) { artifact . setFile ( jarFile ) ; } else { projectHelper . attachArtifact ( mavenProject , jarFile , classifier ) ; } FileUtils . deleteDirectory ( stagingDirectory ) ; return jarFile ; }
Creates the archive from data in the staging directory .
235
11
8,695
public static void startThread ( Thread thread ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Starting background thread: " + thread ) ; } ExecutorService executor = getTaskExecutor ( ) ; if ( executor != null ) { executor . execute ( thread ) ; } else { thread . start ( ) ; } }
Starts a thread . If an executor service is available that is used . Otherwise the thread s start method is called .
76
25
8,696
protected static SessionService create ( IPublisherInfo self , String sessionId , IEventManager eventManager , ISessionUpdate callback ) { String sendEvent = StrUtil . formatMessage ( EVENT_SEND , sessionId ) ; String joinEvent = StrUtil . formatMessage ( EVENT_JOIN , sessionId ) ; String leaveEvent = StrUtil . formatMessage ( EVENT_LEAVE , sessionId ) ; return new SessionService ( self , sendEvent , joinEvent , leaveEvent , eventManager , callback ) ; }
Creates a service handler for a chat session .
112
10
8,697
public ChatMessage sendMessage ( String text ) { if ( text != null && ! text . isEmpty ( ) ) { ChatMessage message = new ChatMessage ( self , text ) ; eventManager . fireRemoteEvent ( sendEvent , message ) ; return message ; } return null ; }
Sends a message to a chat session .
59
9
8,698
@ Override public int compareTo ( HelpSearchHit hit ) { int result = - NumUtil . compare ( confidence , hit . confidence ) ; return result != 0 ? result : topic . compareTo ( hit . topic ) ; }
Used to sort hits by confidence level .
49
8
8,699
protected static byte toUnsignedByte ( int intVal ) { byte byteVal ; if ( intVal > 127 ) { int temp = intVal - 256 ; byteVal = ( byte ) temp ; } else { byteVal = ( byte ) intVal ; } return byteVal ; }
convert int to unsigned byte
59
6