idx
int64 0
41.2k
| question
stringlengths 74
4.21k
| target
stringlengths 5
888
|
|---|---|---|
2,000
|
public static < T > ExampleExpression exampleExpression ( EbeanServer ebeanServer , Example < T > example ) { LikeType likeType ; switch ( example . getMatcher ( ) . getDefaultStringMatcher ( ) ) { case EXACT : likeType = LikeType . EQUAL_TO ; break ; case CONTAINING : likeType = LikeType . CONTAINS ; break ; case STARTING : likeType = LikeType . STARTS_WITH ; break ; case ENDING : likeType = LikeType . ENDS_WITH ; break ; default : likeType = LikeType . RAW ; break ; } return ebeanServer . getExpressionFactory ( ) . exampleLike ( example . getProbe ( ) , example . getMatcher ( ) . isIgnoreCaseEnabled ( ) , likeType ) ; }
|
Return a ExampleExpression from Spring data Example
|
2,001
|
private void resetSettings ( FeedbackPanel feedbackPanel , Component component , Widget widget , AjaxRequestTarget target ) { try { UserWidgetParameters wp = dashboardService . getUserWidgetParameters ( widget . getId ( ) ) ; if ( wp != null ) { storageService . removeEntityById ( wp . getId ( ) ) ; dashboardService . resetCache ( widget . getId ( ) ) ; final WidgetPanel widgetPanel = component . findParent ( WidgetPanel . class ) ; ModalWindow . closeCurrent ( target ) ; widgetPanel . refresh ( target ) ; return ; } } catch ( NotFoundException ex ) { Log . error ( ex . getMessage ( ) , ex ) ; } if ( ( widget instanceof DrillDownWidget ) && ( ( ( DrillDownWidget ) widget ) . getEntity ( ) instanceof Chart ) ) { final WidgetPanel widgetPanel = component . findParent ( WidgetPanel . class ) ; ChartUtil . updateWidget ( widget , ChartUtil . getRuntimeModel ( storageService . getSettings ( ) , ( EntityWidget ) widget , reportService , dataSourceService , false ) ) ; try { if ( component . findParent ( DashboardPanel . class ) == null ) { errorRefresh ( ) ; target . add ( feedbackPanel ) ; return ; } else { ModalWindow . closeCurrent ( target ) ; } dashboardService . modifyWidget ( getDashboardId ( widget . getId ( ) ) , widget ) ; } catch ( NotFoundException e ) { } widgetPanel . refresh ( target ) ; } else if ( widget instanceof ChartWidget ) { final WidgetPanel widgetPanel = component . findParent ( WidgetPanel . class ) ; if ( component . findParent ( DashboardPanel . class ) == null ) { errorRefresh ( ) ; target . add ( feedbackPanel ) ; return ; } else { ModalWindow . closeCurrent ( target ) ; } ChartUtil . updateWidget ( widget , ChartUtil . getDefaultRuntimeModel ( storageService . getSettings ( ) , ( ChartWidget ) widget , reportService , dataSourceService ) ) ; try { dashboardService . modifyWidget ( getDashboardId ( widget . getId ( ) ) , widget ) ; } catch ( NotFoundException e ) { } widgetPanel . refresh ( target ) ; } }
|
return true if we reset settings for a dashboard link with UserWidgetParameters
|
2,002
|
public void syncUsers ( boolean createUsers , boolean deleteUsers ) { List < String > realmUserNames = externalUsersService . getUserNames ( ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Synchronize for realm=" + realm + " users=" + realmUserNames . size ( ) + " (createUsers = " + createUsers + ", deleteUsers = " + deleteUsers + ")" ) ; } for ( String username : realmUserNames ) { User user = externalUsersService . getUser ( username ) ; applyPatch ( user ) ; if ( createUsers ) { createOrUpdateUser ( user ) ; } else if ( userExists ( user . getUsername ( ) ) ) { updateUser ( user ) ; } List < String > groupNames = externalUsersService . getGroupNames ( username ) ; updateUserGroups ( username , groupNames ) ; } if ( deleteUsers ) { deleteAsyncUsers ( realmUserNames ) ; } }
|
from NextServerSession doesn t work
|
2,003
|
public static < T > ExpressionList < T > containsIfNoneBlank ( ExpressionList < T > expressionList , String propertyName , String value ) { Assert . notNull ( expressionList , "expressionList must not null" ) ; Assert . hasText ( propertyName , "propertyName must not blank" ) ; if ( StringUtils . hasText ( value ) ) { return expressionList . contains ( propertyName , value ) ; } return expressionList ; }
|
Return a ExpressionList specifying propertyName contains value .
|
2,004
|
public static < T > ExpressionList < T > eqIfNotNull ( ExpressionList < T > expressionList , String propertyName , Object value ) { Assert . notNull ( expressionList , "expressionList must not null" ) ; Assert . hasText ( propertyName , "propertyName must not null" ) ; if ( value != null ) { return expressionList . eq ( propertyName , value ) ; } return expressionList ; }
|
Return a ExpressionList specifying propertyName equals value .
|
2,005
|
public static < T > ExpressionList < T > betweenIfNotNull ( ExpressionList < T > expressionList , String propertyName , Object start , Object end ) { Assert . notNull ( expressionList , "expressionList must not null" ) ; Assert . hasText ( propertyName , "propertyName must not null" ) ; if ( start != null && end != null ) { return expressionList . between ( propertyName , start , end ) ; } return expressionList ; }
|
Return a ExpressionList specifying propertyName between start and end .
|
2,006
|
public static < T > ExpressionList < T > orContains ( ExpressionList < T > expressionList , List < String > propertyNames , String value ) { Assert . notNull ( expressionList , "expressionList must not null" ) ; Assert . notEmpty ( propertyNames , "propertyNames must not empty" ) ; if ( StringUtils . hasText ( value ) ) { Junction < T > junction = expressionList . or ( ) ; ExpressionList < T > exp = null ; for ( String propertyName : propertyNames ) { if ( exp == null ) { exp = junction . contains ( propertyName , value ) ; } else { exp = exp . contains ( propertyName , value ) ; } } if ( exp != null ) { exp . endOr ( ) ; return exp ; } } return expressionList ; }
|
Return a ExpressionList specifying propertyNames contains value .
|
2,007
|
public static < T > Query < T > queryWithPage ( ExpressionList < T > expressionList , Pageable pageable ) { Assert . notNull ( expressionList , "expressionList must not null" ) ; Assert . notNull ( pageable , "pageable must not null" ) ; return expressionList . setMaxRows ( pageable . getPageSize ( ) ) . setFirstRow ( ( int ) pageable . getOffset ( ) ) . setOrder ( Converters . convertToEbeanOrderBy ( pageable . getSort ( ) ) ) ; }
|
Return query specifying page .
|
2,008
|
public < T > Query < T > createQuery ( Class < T > entityType , String eql ) { Assert . notNull ( entityType , "entityType must not null" ) ; Assert . hasText ( eql , "eql must has text" ) ; return ebeanServer . createQuery ( entityType , eql ) ; }
|
Return a query using Ebean ORM query .
|
2,009
|
public SqlQuery createSqlQuery ( String sql ) { Assert . hasText ( sql , "sql must has text" ) ; return ebeanServer . createSqlQuery ( sql ) ; }
|
Return an SqlQuery for performing native SQL queries that return SqlRow s .
|
2,010
|
public < T > Query < T > createSqlQuery ( Class < T > entityType , String sql ) { Assert . notNull ( entityType , "entityType must not null" ) ; Assert . hasText ( sql , "sql must has text" ) ; RawSqlBuilder rawSqlBuilder = RawSqlBuilder . parse ( sql ) ; return ebeanServer . find ( entityType ) . setRawSql ( rawSqlBuilder . create ( ) ) ; }
|
Return a query using native SQL .
|
2,011
|
public < T > Query < T > createSqlQueryMappingColumns ( Class < T > entityType , String sql , Map < String , String > columnMapping ) { Assert . notNull ( entityType , "entityType must not null" ) ; Assert . hasText ( sql , "sql must has text" ) ; Assert . notEmpty ( columnMapping , "columnMapping must not empty" ) ; RawSqlBuilder rawSqlBuilder = RawSqlBuilder . parse ( sql ) ; columnMapping . entrySet ( ) . forEach ( entry -> { rawSqlBuilder . columnMapping ( entry . getKey ( ) , entry . getValue ( ) ) ; } ) ; return ebeanServer . find ( entityType ) . setRawSql ( rawSqlBuilder . create ( ) ) ; }
|
Return a query using native SQL and column mapping .
|
2,012
|
public < T > Query < T > createNamedQuery ( Class < T > entityType , String queryName ) { return ebeanServer . createNamedQuery ( entityType , queryName ) ; }
|
Return a query using query name .
|
2,013
|
public < T > DtoQuery < T > createDtoQuery ( Class < T > dtoType , String sql ) { return ebeanServer . findDto ( dtoType , sql ) . setRelaxedMode ( ) ; }
|
Return a dto query using sql .
|
2,014
|
public < T > DtoQuery < T > createNamedDtoQuery ( Class < T > dtoType , String namedQuery ) { return ebeanServer . createNamedDtoQuery ( dtoType , namedQuery ) . setRelaxedMode ( ) ; }
|
Return a named dto query .
|
2,015
|
public ExampleExpression exampleOf ( Object example , boolean caseInsensitive , LikeType likeType ) { return ebeanServer . getExpressionFactory ( ) . exampleLike ( example , caseInsensitive , likeType ) ; }
|
Return a ExampleExpression specifying more options .
|
2,016
|
private String getResizeJavaScript ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "$(window).bind(\'resizeEnd\',function(){" ) ; sb . append ( getAlarmCall ( ) ) ; sb . append ( "});" ) ; return sb . toString ( ) ; }
|
alarm call will be made only when resize event finished!
|
2,017
|
protected < T extends DomainEvent > T registerEvent ( T event ) { Assert . notNull ( event , "Domain event must not be null!" ) ; this . domainEvents . add ( event ) ; return event ; }
|
Registers the given event object for publication on a call to a Spring Data repository s save methods .
|
2,018
|
public static boolean hasIntervalParameters ( Settings settings , Report report ) { if ( ! ReportConstants . NEXT . equals ( report . getType ( ) ) ) { return false ; } ro . nextreports . engine . Report nextReport = NextUtil . getNextReport ( settings , report ) ; Map < String , QueryParameter > parameters = ParameterUtil . getUsedParametersMap ( nextReport ) ; boolean hasStart = false ; boolean hasEnd = false ; for ( QueryParameter qp : parameters . values ( ) ) { if ( QueryParameter . INTERVAL_START_DATE_NAME . equals ( qp . getName ( ) ) ) { if ( ! ParameterUtil . isDateTime ( qp ) ) { return false ; } if ( ! qp . getSelection ( ) . equals ( QueryParameter . SINGLE_SELECTION ) ) { return false ; } hasStart = true ; } else if ( QueryParameter . INTERVAL_END_DATE_NAME . equals ( qp . getName ( ) ) ) { if ( ! ParameterUtil . isDateTime ( qp ) ) { return false ; } if ( ! qp . getSelection ( ) . equals ( QueryParameter . SINGLE_SELECTION ) ) { return false ; } hasEnd = true ; } } return ( hasStart && hasEnd ) ; }
|
Test if a report has two parameters with names start_date and end_date of type date and with single selection
|
2,019
|
public static Properties parseURL ( String url , Properties info ) { if ( ( url == null ) || ! url . toLowerCase ( ) . startsWith ( driverPrefix ) ) { return null ; } Properties props = new Properties ( info ) ; Enumeration < ? > en = info . propertyNames ( ) ; while ( en . hasMoreElements ( ) ) { String key = ( String ) en . nextElement ( ) ; String value = info . getProperty ( key ) ; if ( value != null ) { props . setProperty ( key . toUpperCase ( ) , value ) ; } } String tmp = url . substring ( driverPrefix . length ( ) ) ; String [ ] tokens = tmp . split ( ";" ) ; if ( tokens . length != 2 ) { return null ; } try { new URL ( tokens [ 0 ] ) ; } catch ( MalformedURLException e ) { return null ; } props . setProperty ( SERVER_URL , tokens [ 0 ] ) ; props . setProperty ( DATASOURCE_PATH , tokens [ 1 ] ) ; return props ; }
|
Parse the driver URL and extract the properties .
|
2,020
|
public boolean accept ( File file ) { String name = file . getName ( ) ; if ( file . isDirectory ( ) ) { return true ; } return ( name . startsWith ( "theme" ) && name . endsWith ( ".properties" ) ) ; }
|
Returns true .
|
2,021
|
@ Transactional ( readOnly = true ) public Settings getSettings ( ) { try { return ( Settings ) getEntity ( StorageConstants . SETTINGS_ROOT ) ; } catch ( NotFoundException e ) { e . printStackTrace ( ) ; LOG . error ( "Could not read Settings node" , e ) ; return new Settings ( ) ; } }
|
An Authentication object was not found in the SecurityContext
|
2,022
|
protected Component newAddAllComponent ( ) { return new PaletteButton ( "addAllButton" ) { private static final long serialVersionUID = 1L ; protected void onComponentTag ( ComponentTag tag ) { super . onComponentTag ( tag ) ; tag . getAttributes ( ) . put ( "onclick" , getAddAllOnClickJS ( ) ) ; } } ; }
|
factory method for the addAll component
|
2,023
|
protected Component newRemoveAllComponent ( ) { return new PaletteButton ( "removeAllButton" ) { private static final long serialVersionUID = 1L ; protected void onComponentTag ( ComponentTag tag ) { super . onComponentTag ( tag ) ; tag . getAttributes ( ) . put ( "onclick" , getRemoveAllOnClickJS ( ) ) ; } } ; }
|
factory method for the removeAll component
|
2,024
|
protected Component newRemoveComponent ( ) { return new PaletteButton ( "removeButton" ) { private static final long serialVersionUID = 1L ; protected void onComponentTag ( ComponentTag tag ) { super . onComponentTag ( tag ) ; tag . getAttributes ( ) . put ( "onclick" , getRemoveOnClickJS ( ) ) ; } } ; }
|
factory method for the remove component
|
2,025
|
protected Component newAddComponent ( ) { return new PaletteButton ( "addButton" ) { private static final long serialVersionUID = 1L ; protected void onComponentTag ( ComponentTag tag ) { super . onComponentTag ( tag ) ; tag . getAttributes ( ) . put ( "onclick" , getAddOnClickJS ( ) ) ; } } ; }
|
factory method for the addcomponent
|
2,026
|
private String encodeFileName ( String fileName ) { String result = Normalizer . normalize ( fileName , Normalizer . Form . NFD ) . replaceAll ( "\\s+" , "-" ) . replaceAll ( "[^A-Za-z0-9_\\-\\.]" , "" ) ; if ( result . isEmpty ( ) ) { result = "report" ; } return result ; }
|
All characters different from a standard set are deleted
|
2,027
|
protected Component newButtonBar ( String s ) { buttonBar = new AjaxWizardButtonBar ( s , this ) { public void onCancel ( AjaxRequestTarget target ) { EntityBrowserPanel panel = findParent ( EntityBrowserPanel . class ) ; panel . backwardWorkspace ( target ) ; } } ; buttonBar . setFinishSteps ( finishSteps ) ; return buttonBar ; }
|
Job step and Destination step are allowed to finish
|
2,028
|
protected boolean checkForSignIn ( ) { Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( ( authentication != null ) && authentication . isAuthenticated ( ) ) { LOG . debug ( "Security context contains CAS authentication" ) ; return true ; } return false ; }
|
used in NextServerApplication . addSecurityStrategy
|
2,029
|
private void addRuntimeNameProperty ( ) throws RepositoryException { String statement = "/jcr:root" + ISO9075 . encodePath ( StorageConstants . REPORTS_ROOT ) + "//*[@className='ro.nextreports.server.domain.Report']" + "//*[fn:name()='parametersValues']" ; QueryResult queryResult = getTemplate ( ) . query ( statement ) ; NodeIterator nodes = queryResult . getNodes ( ) ; LOG . info ( "RuntimeHistory : Found " + nodes . getSize ( ) + " parameterValues nodes" ) ; while ( nodes . hasNext ( ) ) { Node node = nodes . nextNode ( ) ; NodeIterator childrenIt = node . getNodes ( ) ; while ( childrenIt . hasNext ( ) ) { Node child = childrenIt . nextNode ( ) ; child . setProperty ( "runtimeName" , child . getName ( ) ) ; } } getTemplate ( ) . save ( ) ; }
|
add runtimeName property to ParameterValue
|
2,030
|
private void convertOldIdNameClass ( ) throws RepositoryException { String searchRoot = "/jcr:root" + ISO9075 . encodePath ( StorageConstants . NEXT_SERVER_ROOT ) ; String searchPropertyName = "className" ; String searchPropertyValue = "com.asf.nextserver.domain.ParameterValue" ; String statement = searchRoot + "//*[@" + searchPropertyName + "='" + searchPropertyValue + "']" ; QueryResult queryResult = getTemplate ( ) . query ( statement ) ; NodeIterator nodes = queryResult . getNodes ( ) ; LOG . info ( "Found " + nodes . getSize ( ) + " parameter value nodes" ) ; while ( nodes . hasNext ( ) ) { Node node = nodes . nextNode ( ) ; Property property = null ; try { property = node . getProperty ( "value" ) ; } catch ( PathNotFoundException ex ) { continue ; } try { Object value = deserialize ( property . getBinary ( ) . getStream ( ) ) ; if ( value instanceof Object [ ] ) { Object [ ] values = ( Object [ ] ) value ; Object [ ] convertedValues = new Object [ values . length ] ; boolean converted = false ; for ( int i = 0 ; i < values . length ; i ++ ) { Object tmp = values [ i ] ; if ( tmp instanceof com . asf . nextreports . engine . queryexec . IdName ) { com . asf . nextreports . engine . queryexec . IdName oldIdName = ( com . asf . nextreports . engine . queryexec . IdName ) tmp ; IdName idName = new IdName ( ) ; idName . setId ( oldIdName . getId ( ) ) ; idName . setName ( oldIdName . getName ( ) ) ; convertedValues [ i ] = idName ; converted = true ; } else { convertedValues [ i ] = tmp ; } } if ( converted ) { ValueFactory valueFactory = node . getSession ( ) . getValueFactory ( ) ; Binary binary = valueFactory . createBinary ( new ByteArrayInputStream ( serialize ( convertedValues ) ) ) ; property . setValue ( binary ) ; } } else if ( value instanceof com . asf . nextreports . engine . queryexec . IdName ) { com . asf . nextreports . engine . queryexec . IdName oldIdName = ( com . asf . nextreports . engine . queryexec . IdName ) value ; IdName idName = new IdName ( ) ; idName . setId ( oldIdName . getId ( ) ) ; idName . setName ( oldIdName . getName ( ) ) ; ValueFactory valueFactory = node . getSession ( ) . getValueFactory ( ) ; Binary binary = valueFactory . createBinary ( new ByteArrayInputStream ( serialize ( idName ) ) ) ; property . setValue ( binary ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } } getTemplate ( ) . save ( ) ; }
|
IdName values can be found in ParameterValue entities which are used in Dashboards widget parameters or Scheduler report runtime parameters
|
2,031
|
public String getMailServerIp ( ) { Settings settings = getSettings ( ) ; if ( settings . getMailServer ( ) == null ) { return "127.0.0.1" ; } return settings . getMailServer ( ) . getIp ( ) ; }
|
helper methods used in Spring xml files with SpEL
|
2,032
|
private void clearParentsCache ( Entity entity ) { try { String xpath = null ; if ( entity instanceof DataSource ) { xpath = "//nextServer//*[@dataSource='" + entity . getId ( ) + "']" ; } else if ( entity instanceof Report ) { xpath = "//nextServer/scheduler/*[@report='" + entity . getId ( ) + "']" ; } if ( xpath != null ) { NodeIterator nodes = getTemplate ( ) . query ( xpath ) . getNodes ( ) ; while ( nodes . hasNext ( ) ) { entitiesCache . remove ( nodes . nextNode ( ) . getIdentifier ( ) ) ; } } if ( ( entity instanceof Report ) || ( entity instanceof Chart ) ) { xpath = " //nextServer//drillDownEntities/*[@entity='" + entity . getId ( ) + "']" ; if ( xpath != null ) { NodeIterator nodes = getTemplate ( ) . query ( xpath ) . getNodes ( ) ; while ( nodes . hasNext ( ) ) { entitiesCache . remove ( nodes . nextNode ( ) . getParent ( ) . getParent ( ) . getIdentifier ( ) ) ; } } } } catch ( RepositoryException e ) { throw convertJcrAccessException ( e ) ; } }
|
clear all parents from cache
|
2,033
|
private Connection getDerbyConnection ( String wkpDir ) { wkpDir = wkpDir . replaceAll ( "\\\\" , "/" ) ; System . err . println ( wkpDir ) ; String DB_CONN_STRING = "jdbc:derby:" + wkpDir + "/db;create=false" ; String DRIVER_CLASS_NAME = "org.apache.derby.jdbc.EmbeddedDriver" ; String USER_NAME = null ; String PASSWORD = null ; Connection result = null ; try { Class . forName ( DRIVER_CLASS_NAME ) . newInstance ( ) ; } catch ( Exception ex ) { LOG . debug ( "Check classpath. Cannot load db driver: " + DRIVER_CLASS_NAME ) ; } try { result = DriverManager . getConnection ( DB_CONN_STRING , USER_NAME , PASSWORD ) ; } catch ( SQLException e ) { LOG . debug ( "Driver loaded, but cannot connect to db: " + DB_CONN_STRING ) ; } return result ; }
|
Uses DriverManager .
|
2,034
|
public static DateFormat getAlignedFormat ( ) { if ( DATE_FORMAT instanceof SimpleDateFormat ) { SimpleDateFormat sdf = ( SimpleDateFormat ) DATE_FORMAT ; String pattern = sdf . toPattern ( ) . replaceAll ( "M+" , "MM" ) . replaceAll ( "d+" , "dd" ) . replaceAll ( "h+" , "hh" ) . replaceAll ( "H+" , "HH" ) ; sdf . applyPattern ( pattern ) ; return sdf ; } else { return DATE_FORMAT ; } }
|
we need to take the pattern and modify it
|
2,035
|
public List < Serializable > getValues ( String text , String type ) throws NumberFormatException { List < Serializable > list = new ArrayList < Serializable > ( ) ; String [ ] values = text . split ( DELIM ) ; for ( String v : values ) { Serializable value ; if ( QueryParameter . INTEGER_VALUE . equals ( type ) ) { value = Integer . parseInt ( v ) ; } else if ( QueryParameter . BYTE_VALUE . equals ( type ) ) { value = Byte . parseByte ( v ) ; } else if ( QueryParameter . SHORT_VALUE . equals ( type ) ) { value = Short . parseShort ( v ) ; } else if ( QueryParameter . LONG_VALUE . equals ( type ) ) { value = Long . parseLong ( v ) ; } else if ( QueryParameter . FLOAT_VALUE . equals ( type ) ) { value = Float . parseFloat ( v ) ; } else if ( QueryParameter . DOUBLE_VALUE . equals ( type ) ) { value = Double . parseDouble ( v ) ; } else if ( QueryParameter . BIGDECIMAL_VALUE . equals ( type ) ) { value = new BigDecimal ( v ) ; } else { value = v ; } list . add ( value ) ; } return list ; }
|
number and string values can be separated by semicolon delimiter
|
2,036
|
private List < Serializable > getSelectedValues ( List < IdName > values , List < Serializable > defaultValues ) { List < Serializable > selectedValues = new ArrayList < Serializable > ( ) ; if ( defaultValues == null ) { return selectedValues ; } for ( Serializable s : defaultValues ) { for ( IdName in : values ) { if ( s instanceof IdName ) { if ( ( in . getId ( ) != null ) && in . getId ( ) . equals ( ( ( IdName ) s ) . getId ( ) ) ) { selectedValues . add ( in ) ; break ; } } else if ( ( in . getId ( ) != null ) && in . getId ( ) . equals ( s ) ) { selectedValues . add ( in ) ; break ; } } } return selectedValues ; }
|
a default value must be simple java object or an IdName but only with the id
|
2,037
|
private AjaxFormComponentUpdatingBehavior createAjax ( final QueryParameter parameter , final IModel model , final Component component , final String time ) { return new AjaxFormComponentUpdatingBehavior ( "onchange" ) { @ SuppressWarnings ( "unchecked" ) protected void onUpdate ( AjaxRequestTarget target ) { if ( ( model == null ) || ( model . getObject ( ) == null ) ) { return ; } Date date = ( Date ) model . getObject ( ) ; if ( "hours" . equals ( time ) ) { date = DateUtil . setHours ( date , ( Integer ) component . getDefaultModelObject ( ) ) ; } else if ( "minutes" . equals ( time ) ) { date = DateUtil . setMinutes ( date , ( Integer ) component . getDefaultModelObject ( ) ) ; } model . setObject ( date ) ; populateDependentParameters ( parameter , target , false ) ; } } ; }
|
used to update hours and minutes
|
2,038
|
public static ReplacedString replaceString ( String s , String find , String replace ) { if ( replace == null ) replace = "-" ; int index = - 1 ; int l = find . length ( ) ; boolean replaced = false ; do { index = s . indexOf ( find , index ) ; if ( index >= 0 ) { replaced = true ; s = s . substring ( 0 , index ) + replace + s . substring ( index + l ) ; } } while ( index >= 0 ) ; return new ReplacedString ( s , replaced ) ; }
|
Replace a string with another
|
2,039
|
public static void writeToClipboard ( String text ) { Clipboard systemClipboard = Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) ; Transferable transferableText = new StringSelection ( text ) ; systemClipboard . setContents ( transferableText , null ) ; }
|
Write a text to system clipboard
|
2,040
|
public static EntityTreeExpansionState get ( ) { EntityTreeExpansionState expansion = Session . get ( ) . getMetaData ( KEY ) ; if ( expansion == null ) { expansion = new EntityTreeExpansionState ( ) ; Session . get ( ) . setMetaData ( KEY , expansion ) ; } return expansion ; }
|
Get the expansion for the session .
|
2,041
|
private String getResizeJavaScript ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "$(window).bind(\'resizeEnd\',function(){" ) ; sb . append ( getIndicatorCall ( ) ) ; sb . append ( "});" ) ; return sb . toString ( ) ; }
|
indicator call will be made only when resize event finished!
|
2,042
|
public String getJsonData ( Chart chart ) throws ReportRunnerException , NoDataFoundException , TimeoutException { return getJsonData ( chart , null , null ) ; }
|
Methods with chart do not now anything about settings!!
|
2,043
|
public boolean isSingleWidget ( String widgetId ) { try { WidgetState state = ( WidgetState ) storageService . getEntityById ( widgetId ) ; DashboardState dState = getDashboardState ( state ) ; if ( dState . getColumnCount ( ) > 1 ) { return false ; } if ( dState . getWidgetStates ( ) . size ( ) > 1 ) { return false ; } return true ; } catch ( NotFoundException e ) { return false ; } }
|
just a single widget in a dashboard with a single column
|
2,044
|
private void resetDrillDownableCache ( String entityId ) { try { if ( entityId == null ) { return ; } Entity entity = storageService . getEntityById ( entityId ) ; if ( entity instanceof Chart ) { if ( ( ( Chart ) entity ) . isDrillDownable ( ) ) { resetCache ( entityId ) ; } } } catch ( NotFoundException ex ) { LOG . error ( "Reset cache - not found" , ex ) ; } }
|
for drill down reports there is no need to reset cache when we move the widget
|
2,045
|
public Method getTargetMethod ( Exchange exchange ) { Object o = exchange . getBindingOperationInfo ( ) . getOperationInfo ( ) . getProperty ( Method . class . getName ( ) ) ; if ( o != null && o instanceof Method ) { return ( Method ) o ; } else { throw new RuntimeException ( "Target method not found on OperationInfo" ) ; } }
|
Utility method for getting the method which is going to be invoked on the service by underlying invoker .
|
2,046
|
public void reset ( ) { this . errorType = ErrorType . NONE ; this . message = null ; this . columnName = null ; this . columnValue = null ; this . columnType = null ; this . line = null ; this . lineNumber = 0 ; this . linePos = 0 ; }
|
Resets all of the fields to non - error status . This is used internally so we can reuse an instance of this class .
|
2,047
|
public T getValue ( Object obj ) throws IllegalAccessException , InvocationTargetException { if ( field == null ) { @ SuppressWarnings ( "unchecked" ) T cast = ( T ) getMethod . invoke ( obj ) ; return cast ; } else { @ SuppressWarnings ( "unchecked" ) T cast = ( T ) field . get ( obj ) ; return cast ; } }
|
Get the value associated with this field from the object parameter either by getting from the field or calling the get method .
|
2,048
|
public void setValue ( Object obj , T value ) throws IllegalAccessException , InvocationTargetException { if ( field == null ) { setMethod . invoke ( obj , value ) ; } else { field . set ( obj , value ) ; } }
|
Set the value associated with this field from the object parameter either by setting via the field or calling the set method .
|
2,049
|
public Invoker create ( Object service , Invoker rootInvoker , SessionFactory sessionFactory ) { ImmutableMap . Builder < String , UnitOfWork > unitOfWorkMethodsBuilder = new ImmutableMap . Builder < > ( ) ; for ( Method m : service . getClass ( ) . getMethods ( ) ) { if ( m . isAnnotationPresent ( UnitOfWork . class ) ) { unitOfWorkMethodsBuilder . put ( m . getName ( ) , m . getAnnotation ( UnitOfWork . class ) ) ; } } ImmutableMap < String , UnitOfWork > unitOfWorkMethods = unitOfWorkMethodsBuilder . build ( ) ; Invoker invoker = rootInvoker ; if ( unitOfWorkMethods . size ( ) > 0 ) { invoker = new UnitOfWorkInvoker ( invoker , unitOfWorkMethods , sessionFactory ) ; } return invoker ; }
|
Factory method for creating UnitOfWorkInvoker .
|
2,050
|
@ SuppressWarnings ( "unchecked" ) public AbstractBuilder cxfOutFaultInterceptors ( Interceptor < ? extends Message > ... interceptors ) { this . cxfOutFaultInterceptors = ImmutableList . < Interceptor < ? extends Message > > builder ( ) . add ( interceptors ) . build ( ) ; return this ; }
|
Add CXF interceptors to the outgoing fault interceptor chain .
|
2,051
|
public static void addInternalConverters ( Map < Class < ? > , Converter < ? , ? > > converterMap ) { converterMap . put ( BigDecimal . class , BigDecimalConverter . getSingleton ( ) ) ; converterMap . put ( BigInteger . class , BigIntegerConverter . getSingleton ( ) ) ; converterMap . put ( Boolean . class , BooleanConverter . getSingleton ( ) ) ; converterMap . put ( boolean . class , BooleanConverter . getSingleton ( ) ) ; converterMap . put ( Byte . class , ByteConverter . getSingleton ( ) ) ; converterMap . put ( byte . class , ByteConverter . getSingleton ( ) ) ; converterMap . put ( Character . class , CharacterConverter . getSingleton ( ) ) ; converterMap . put ( char . class , CharacterConverter . getSingleton ( ) ) ; converterMap . put ( Date . class , DateConverter . getSingleton ( ) ) ; converterMap . put ( Double . class , DoubleConverter . getSingleton ( ) ) ; converterMap . put ( double . class , DoubleConverter . getSingleton ( ) ) ; converterMap . put ( Enum . class , EnumConverter . getSingleton ( ) ) ; converterMap . put ( Float . class , FloatConverter . getSingleton ( ) ) ; converterMap . put ( float . class , FloatConverter . getSingleton ( ) ) ; converterMap . put ( Integer . class , IntegerConverter . getSingleton ( ) ) ; converterMap . put ( int . class , IntegerConverter . getSingleton ( ) ) ; converterMap . put ( Long . class , LongConverter . getSingleton ( ) ) ; converterMap . put ( long . class , LongConverter . getSingleton ( ) ) ; converterMap . put ( Short . class , ShortConverter . getSingleton ( ) ) ; converterMap . put ( short . class , ShortConverter . getSingleton ( ) ) ; converterMap . put ( String . class , StringConverter . getSingleton ( ) ) ; converterMap . put ( UUID . class , UuidConverter . getSingleton ( ) ) ; }
|
Add internal converters to the map .
|
2,052
|
public static Converter < ? , ? > constructConverter ( Class < ? extends Converter < ? , ? > > clazz ) { Constructor < ? extends Converter < ? , ? > > constructor ; try { constructor = clazz . getConstructor ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Could not find public no-arg constructor for CSV converter class: " + clazz , e ) ; } try { return constructor . newInstance ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Could not construct new CSV converter: " + clazz , e ) ; } }
|
Construct a converter instance .
|
2,053
|
public Endpoint publishEndpoint ( EndpointBuilder endpointBuilder ) { checkArgument ( endpointBuilder != null , "EndpointBuilder is null" ) ; return this . jaxwsEnvironment . publishEndpoint ( endpointBuilder ) ; }
|
Publish JAX - WS endpoint . Endpoint will be published relative to the CXF servlet path .
|
2,054
|
public < T > T getClient ( ClientBuilder < T > clientBuilder ) { checkArgument ( clientBuilder != null , "ClientBuilder is null" ) ; return jaxwsEnvironment . getClient ( clientBuilder ) ; }
|
Factory method for creating JAX - WS clients .
|
2,055
|
private Invoker timed ( Invoker invoker , List < Method > timedMethods ) { ImmutableMap . Builder < String , Timer > timers = new ImmutableMap . Builder < > ( ) ; for ( Method m : timedMethods ) { Timed annotation = m . getAnnotation ( Timed . class ) ; final String name = chooseName ( annotation . name ( ) , annotation . absolute ( ) , m ) ; Timer timer = metricRegistry . timer ( name ) ; timers . put ( m . getName ( ) , timer ) ; } return new InstrumentedInvokers . TimedInvoker ( invoker , timers . build ( ) ) ; }
|
Factory method for TimedInvoker .
|
2,056
|
private Invoker metered ( Invoker invoker , List < Method > meteredMethods ) { ImmutableMap . Builder < String , Meter > meters = new ImmutableMap . Builder < > ( ) ; for ( Method m : meteredMethods ) { Metered annotation = m . getAnnotation ( Metered . class ) ; final String name = chooseName ( annotation . name ( ) , annotation . absolute ( ) , m ) ; Meter meter = metricRegistry . meter ( name ) ; meters . put ( m . getName ( ) , meter ) ; } return new InstrumentedInvokers . MeteredInvoker ( invoker , meters . build ( ) ) ; }
|
Factory method for MeteredInvoker .
|
2,057
|
private Invoker exceptionMetered ( Invoker invoker , List < Method > meteredMethods ) { ImmutableMap . Builder < String , InstrumentedInvokers . ExceptionMeter > meters = new ImmutableMap . Builder < > ( ) ; for ( Method m : meteredMethods ) { ExceptionMetered annotation = m . getAnnotation ( ExceptionMetered . class ) ; final String name = chooseName ( annotation . name ( ) , annotation . absolute ( ) , m , ExceptionMetered . DEFAULT_NAME_SUFFIX ) ; Meter meter = metricRegistry . meter ( name ) ; meters . put ( m . getName ( ) , new InstrumentedInvokers . ExceptionMeter ( meter , annotation . cause ( ) ) ) ; } return new InstrumentedInvokers . ExceptionMeteredInvoker ( invoker , meters . build ( ) ) ; }
|
Factory method for ExceptionMeteredInvoker .
|
2,058
|
public Invoker create ( Object service , Invoker rootInvoker ) { List < Method > timedmethods = new ArrayList < > ( ) ; List < Method > meteredmethods = new ArrayList < > ( ) ; List < Method > exceptionmeteredmethods = new ArrayList < > ( ) ; for ( Method m : service . getClass ( ) . getMethods ( ) ) { if ( m . isAnnotationPresent ( Timed . class ) ) { timedmethods . add ( m ) ; } if ( m . isAnnotationPresent ( Metered . class ) ) { meteredmethods . add ( m ) ; } if ( m . isAnnotationPresent ( ExceptionMetered . class ) ) { exceptionmeteredmethods . add ( m ) ; } } Invoker invoker = rootInvoker ; if ( timedmethods . size ( ) > 0 ) { invoker = this . timed ( invoker , timedmethods ) ; } if ( meteredmethods . size ( ) > 0 ) { invoker = this . metered ( invoker , meteredmethods ) ; } if ( exceptionmeteredmethods . size ( ) > 0 ) { invoker = this . exceptionMetered ( invoker , exceptionmeteredmethods ) ; } return invoker ; }
|
Factory method for creating instrumented invoker chain .
|
2,059
|
public Endpoint publishEndpoint ( EndpointBuilder endpointBuilder ) { checkArgument ( endpointBuilder != null , "EndpointBuilder is null" ) ; EndpointImpl cxfendpoint = new EndpointImpl ( bus , endpointBuilder . getService ( ) ) ; if ( endpointBuilder . publishedEndpointUrl ( ) != null ) { cxfendpoint . setPublishedEndpointUrl ( endpointBuilder . publishedEndpointUrl ( ) ) ; } else if ( publishedEndpointUrlPrefix != null ) { cxfendpoint . setPublishedEndpointUrl ( publishedEndpointUrlPrefix + endpointBuilder . getPath ( ) ) ; } cxfendpoint . publish ( endpointBuilder . getPath ( ) ) ; if ( endpointBuilder . isMtomEnabled ( ) ) { ( ( SOAPBinding ) cxfendpoint . getBinding ( ) ) . setMTOMEnabled ( true ) ; } Invoker invoker = cxfendpoint . getService ( ) . getInvoker ( ) ; ValidatorFactory vf = Validation . buildDefaultValidatorFactory ( ) ; invoker = this . createValidatingInvoker ( invoker , vf . getValidator ( ) ) ; if ( endpointBuilder . getSessionFactory ( ) != null ) { invoker = unitOfWorkInvokerBuilder . create ( endpointBuilder . getService ( ) , invoker , endpointBuilder . getSessionFactory ( ) ) ; cxfendpoint . getService ( ) . setInvoker ( invoker ) ; } invoker = instrumentedInvokerBuilder . create ( endpointBuilder . getService ( ) , invoker ) ; cxfendpoint . getService ( ) . setInvoker ( invoker ) ; if ( endpointBuilder . getAuthentication ( ) != null ) { BasicAuthenticationInterceptor basicAuthInterceptor = this . createBasicAuthenticationInterceptor ( ) ; basicAuthInterceptor . setAuthenticator ( endpointBuilder . getAuthentication ( ) ) ; cxfendpoint . getInInterceptors ( ) . add ( basicAuthInterceptor ) ; } if ( endpointBuilder . getCxfInInterceptors ( ) != null ) { cxfendpoint . getInInterceptors ( ) . addAll ( endpointBuilder . getCxfInInterceptors ( ) ) ; } if ( endpointBuilder . getCxfInFaultInterceptors ( ) != null ) { cxfendpoint . getInFaultInterceptors ( ) . addAll ( endpointBuilder . getCxfInFaultInterceptors ( ) ) ; } if ( endpointBuilder . getCxfOutInterceptors ( ) != null ) { cxfendpoint . getOutInterceptors ( ) . addAll ( endpointBuilder . getCxfOutInterceptors ( ) ) ; } if ( endpointBuilder . getCxfOutFaultInterceptors ( ) != null ) { cxfendpoint . getOutFaultInterceptors ( ) . addAll ( endpointBuilder . getCxfOutFaultInterceptors ( ) ) ; } if ( endpointBuilder . getProperties ( ) != null ) { cxfendpoint . getProperties ( ) . putAll ( endpointBuilder . getProperties ( ) ) ; } return cxfendpoint ; }
|
Publish JAX - WS server side endpoint . Returns javax . xml . ws . Endpoint to enable further customization .
|
2,060
|
public < T > T getClient ( ClientBuilder < T > clientBuilder ) { JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean ( ) ; proxyFactory . setServiceClass ( clientBuilder . getServiceClass ( ) ) ; proxyFactory . setAddress ( clientBuilder . getAddress ( ) ) ; if ( clientBuilder . getHandlers ( ) != null ) { for ( Handler h : clientBuilder . getHandlers ( ) ) { proxyFactory . getHandlers ( ) . add ( h ) ; } } if ( clientBuilder . getBindingId ( ) != null ) { proxyFactory . setBindingId ( clientBuilder . getBindingId ( ) ) ; } if ( clientBuilder . getCxfInInterceptors ( ) != null ) { proxyFactory . getInInterceptors ( ) . addAll ( clientBuilder . getCxfInInterceptors ( ) ) ; } if ( clientBuilder . getCxfInFaultInterceptors ( ) != null ) { proxyFactory . getInFaultInterceptors ( ) . addAll ( clientBuilder . getCxfInFaultInterceptors ( ) ) ; } if ( clientBuilder . getCxfOutInterceptors ( ) != null ) { proxyFactory . getOutInterceptors ( ) . addAll ( clientBuilder . getCxfOutInterceptors ( ) ) ; } if ( clientBuilder . getCxfOutFaultInterceptors ( ) != null ) { proxyFactory . getOutFaultInterceptors ( ) . addAll ( clientBuilder . getCxfOutFaultInterceptors ( ) ) ; } T proxy = clientBuilder . getServiceClass ( ) . cast ( proxyFactory . create ( ) ) ; if ( clientBuilder . isMtomEnabled ( ) ) { BindingProvider bp = ( BindingProvider ) proxy ; SOAPBinding binding = ( SOAPBinding ) bp . getBinding ( ) ; binding . setMTOMEnabled ( true ) ; } HTTPConduit http = ( HTTPConduit ) ClientProxy . getClient ( proxy ) . getConduit ( ) ; HTTPClientPolicy client = http . getClient ( ) ; client . setConnectionTimeout ( clientBuilder . getConnectTimeout ( ) ) ; client . setReceiveTimeout ( clientBuilder . getReceiveTimeout ( ) ) ; return proxy ; }
|
JAX - WS client factory
|
2,061
|
public List < T > readAll ( File file , Collection < ParseError > parseErrors ) throws IOException , ParseException { checkEntityConfig ( ) ; return readAll ( new FileReader ( file ) , parseErrors ) ; }
|
Read in all of the entities in the file passed in .
|
2,062
|
public List < T > readAll ( Reader reader , Collection < ParseError > parseErrors ) throws IOException , ParseException { checkEntityConfig ( ) ; BufferedReader bufferedReader = new BufferedReaderLineCounter ( reader ) ; try { ParseError parseError = null ; if ( parseErrors != null ) { parseError = new ParseError ( ) ; } if ( firstLineHeader ) { if ( readHeader ( bufferedReader , parseError ) == null ) { if ( parseError != null && parseError . isError ( ) ) { parseErrors . add ( parseError ) ; } return null ; } } return readRows ( bufferedReader , parseErrors ) ; } finally { bufferedReader . close ( ) ; } }
|
Read in all of the entities in the reader passed in . It will use an internal buffered reader .
|
2,063
|
public String [ ] readHeader ( BufferedReader bufferedReader , ParseError parseError ) throws ParseException , IOException { checkEntityConfig ( ) ; String header = bufferedReader . readLine ( ) ; if ( header == null ) { if ( parseError == null ) { throw new ParseException ( "no header line read" , 0 ) ; } else { parseError . setErrorType ( ErrorType . NO_HEADER ) ; parseError . setLineNumber ( getLineNumber ( bufferedReader ) ) ; return null ; } } String [ ] columns = processHeader ( header , parseError , getLineNumber ( bufferedReader ) ) ; if ( columns == null ) { return null ; } else if ( headerValidation && ! validateHeaderColumns ( columns , parseError , getLineNumber ( bufferedReader ) ) ) { if ( parseError == null ) { throw new ParseException ( "header line is not valid: " + header , 0 ) ; } else { return null ; } } return columns ; }
|
Read in a line and process it as a CSV header .
|
2,064
|
public List < T > readRows ( BufferedReader bufferedReader , Collection < ParseError > parseErrors ) throws IOException , ParseException { checkEntityConfig ( ) ; ParseError parseError = null ; if ( parseErrors != null ) { parseError = new ParseError ( ) ; } List < T > results = new ArrayList < T > ( ) ; while ( true ) { if ( parseError != null ) { parseError . reset ( ) ; } T result = readRow ( bufferedReader , parseError ) ; if ( result != null ) { results . add ( result ) ; } else if ( parseError != null && parseError . isError ( ) ) { parseErrors . add ( parseError ) ; parseError = new ParseError ( ) ; } else { return results ; } } }
|
Read in all of the entities in the reader passed in but without the header .
|
2,065
|
public T readRow ( BufferedReader bufferedReader , ParseError parseError ) throws ParseException , IOException { checkEntityConfig ( ) ; String line = bufferedReader . readLine ( ) ; if ( line == null ) { return null ; } else { return processRow ( line , bufferedReader , parseError , getLineNumber ( bufferedReader ) ) ; } }
|
Read an entity line from the reader .
|
2,066
|
public boolean validateHeader ( String line , ParseError parseError ) throws ParseException { checkEntityConfig ( ) ; String [ ] columns = processHeader ( line , parseError ) ; return validateHeaderColumns ( columns , parseError , 1 ) ; }
|
Validate the header row against the configured header columns .
|
2,067
|
public String [ ] processHeader ( String line , ParseError parseError ) throws ParseException { checkEntityConfig ( ) ; try { return processHeader ( line , parseError , 1 ) ; } catch ( IOException e ) { return null ; } }
|
Process a header line and divide it up into a series of quoted columns .
|
2,068
|
public T processRow ( String line , ParseError parseError ) throws ParseException { checkEntityConfig ( ) ; try { return processRow ( line , null , parseError , 1 ) ; } catch ( IOException e ) { return null ; } }
|
Read and process a line and return the associated entity .
|
2,069
|
public void writeAll ( File file , Collection < T > entities , boolean writeHeader ) throws IOException { writeAll ( new FileWriter ( file ) , entities , writeHeader ) ; }
|
Write a collection of entities to the writer .
|
2,070
|
public void writeAll ( Writer writer , Collection < T > entities , boolean writeHeader ) throws IOException { checkEntityConfig ( ) ; BufferedWriter bufferedWriter = new BufferedWriter ( writer ) ; try { if ( writeHeader ) { writeHeader ( bufferedWriter , true ) ; } for ( T entity : entities ) { writeRow ( bufferedWriter , entity , true ) ; } } finally { bufferedWriter . close ( ) ; } }
|
Write a header and then the collection of entities to the writer .
|
2,071
|
public void writeHeader ( BufferedWriter bufferedWriter , boolean appendLineTermination ) throws IOException { checkEntityConfig ( ) ; bufferedWriter . write ( buildHeaderLine ( appendLineTermination ) ) ; }
|
Write the header line to the writer .
|
2,072
|
public void writeRow ( BufferedWriter bufferedWriter , T entity , boolean appendLineTermination ) throws IOException { checkEntityConfig ( ) ; String line = buildLine ( entity , appendLineTermination ) ; bufferedWriter . write ( line ) ; }
|
Write an entity row to the writer .
|
2,073
|
public String buildHeaderLine ( boolean appendLineTermination ) { checkEntityConfig ( ) ; StringBuilder sb = new StringBuilder ( ) ; boolean first = true ; for ( ColumnInfo < ? > columnInfo : allColumnInfos ) { if ( first ) { first = false ; } else { sb . append ( columnSeparator ) ; } String header = columnInfo . getColumnName ( ) ; if ( header . indexOf ( columnQuote ) >= 0 ) { writeQuoted ( sb , header ) ; continue ; } sb . append ( columnQuote ) ; sb . append ( header ) ; sb . append ( columnQuote ) ; } if ( appendLineTermination ) { sb . append ( lineTermination ) ; } return sb . toString ( ) ; }
|
Build and return a header string made up of quoted column names .
|
2,074
|
public String buildLine ( T entity , boolean appendLineTermination ) { checkEntityConfig ( ) ; StringBuilder sb = new StringBuilder ( ) ; boolean first = true ; for ( ColumnInfo < Object > columnInfo : allColumnInfos ) { if ( first ) { first = false ; } else { sb . append ( columnSeparator ) ; } Object value ; try { value = columnInfo . getValue ( entity ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Could not get value from entity field: " + columnInfo ) ; } @ SuppressWarnings ( "unchecked" ) Converter < Object , Object > castConverter = ( Converter < Object , Object > ) columnInfo . getConverter ( ) ; String str = castConverter . javaToString ( columnInfo , value ) ; boolean needsQuotes = columnInfo . isNeedsQuotes ( ) ; if ( str == null ) { if ( needsQuotes ) { sb . append ( columnQuote ) . append ( columnQuote ) ; } continue ; } if ( str . indexOf ( columnQuote ) >= 0 ) { writeQuoted ( sb , str ) ; continue ; } if ( ! needsQuotes ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; if ( ch == columnSeparator || ch == '\r' || ch == '\n' || ch == '\t' || ch == '\b' ) { needsQuotes = true ; break ; } } } if ( needsQuotes ) { sb . append ( columnQuote ) ; } sb . append ( str ) ; if ( needsQuotes ) { sb . append ( columnQuote ) ; } } if ( appendLineTermination ) { sb . append ( lineTermination ) ; } return sb . toString ( ) ; }
|
Convert the entity into a string of column values .
|
2,075
|
private void extractAndAssignValue ( String line , int lineNumber , ColumnInfo < Object > columnInfo , String columnStr , int linePos , Object target , ParseError parseError ) { Object value = extractValue ( line , lineNumber , columnInfo , columnStr , linePos , target , parseError ) ; if ( value == null ) { assignParseErrorFields ( parseError , columnInfo , columnStr ) ; return ; } try { columnInfo . setValue ( target , value ) ; } catch ( Exception e ) { parseError . setErrorType ( ErrorType . INTERNAL_ERROR ) ; parseError . setMessage ( "setting value for field '" + columnInfo . getFieldName ( ) + "' error: " + e . getMessage ( ) ) ; assignParseErrorFields ( parseError , columnInfo , columnStr ) ; parseError . setLinePos ( linePos ) ; } }
|
Extract a value from the line convert it into its java equivalent and assign it to our target object .
|
2,076
|
private Object extractValue ( String line , int lineNumber , ColumnInfo < Object > columnInfo , String columnStr , int linePos , Object target , ParseError parseError ) { Converter < Object , ? > converter = columnInfo . getConverter ( ) ; if ( alwaysTrimInput || columnInfo . isTrimInput ( ) || converter . isAlwaysTrimInput ( ) ) { columnStr = columnStr . trim ( ) ; } if ( columnStr . isEmpty ( ) && columnInfo . getDefaultValue ( ) != null ) { columnStr = columnInfo . getDefaultValue ( ) ; } if ( columnStr . isEmpty ( ) && columnInfo . isMustNotBeBlank ( ) ) { parseError . setErrorType ( ErrorType . MUST_NOT_BE_BLANK ) ; parseError . setMessage ( "field '" + columnInfo . getFieldName ( ) + "' must not be blank" ) ; assignParseErrorFields ( parseError , columnInfo , columnStr ) ; parseError . setLinePos ( linePos ) ; return null ; } try { return converter . stringToJava ( line , lineNumber , linePos , columnInfo , columnStr , parseError ) ; } catch ( ParseException e ) { parseError . setErrorType ( ErrorType . INVALID_FORMAT ) ; parseError . setMessage ( "field '" + columnInfo . getFieldName ( ) + "' parse-error: " + e . getMessage ( ) ) ; parseError . setLinePos ( linePos ) ; return null ; } catch ( Exception e ) { parseError . setErrorType ( ErrorType . INTERNAL_ERROR ) ; parseError . setMessage ( "field '" + columnInfo . getFieldName ( ) + "' error: " + e . getMessage ( ) ) ; parseError . setLinePos ( linePos ) ; return null ; } }
|
Extract a value from the line and convert it into its java equivalent .
|
2,077
|
public ClientBuilder < T > handlers ( Handler ... handlers ) { this . handlers = ImmutableList . < Handler > builder ( ) . add ( handlers ) . build ( ) ; return this ; }
|
Add client side JAX - WS handlers .
|
2,078
|
public static void premain ( String args , Instrumentation inst ) { GagTransformer transformer = new GagTransformer ( ) ; if ( args == null || args . length ( ) == 0 ) { transformer . addAllGenerators ( ) ; } else { for ( String key : args . split ( "," ) ) { transformer . addGeneratorForKey ( key ) ; } } inst . addTransformer ( transformer ) ; }
|
An instrumentation agent needs to have a premain method .
|
2,079
|
public void initialize ( ) { deviceDirectory = getDeviceDirectory ( ) ; for ( int PortType = CommPortIdentifier . PORT_SERIAL ; PortType <= CommPortIdentifier . PORT_PARALLEL ; PortType ++ ) { if ( ! registerSpecifiedPorts ( PortType ) ) { if ( ! registerKnownPorts ( PortType ) ) { registerScannedPorts ( PortType ) ; } } } }
|
Determine the OS and where the OS has the devices located
|
2,080
|
private static void AddIdentifierToList ( CommPortIdentifier cpi ) { LOGGER . fine ( "CommPortIdentifier:AddIdentifierToList()" ) ; synchronized ( Sync ) { if ( CommPortIndex == null ) { CommPortIndex = cpi ; LOGGER . fine ( "CommPortIdentifier:AddIdentifierToList() null" ) ; } else { CommPortIdentifier index = CommPortIndex ; while ( index . next != null ) { index = index . next ; LOGGER . fine ( "CommPortIdentifier:AddIdentifierToList() index.next" ) ; } index . next = cpi ; } } }
|
by implementing its own linked list functionallity
|
2,081
|
static public CommPortIdentifier getPortIdentifier ( CommPort p ) throws NoSuchPortException { LOGGER . fine ( "CommPortIdentifier:getPortIdentifier(CommPort)" ) ; CommPortIdentifier c ; synchronized ( Sync ) { c = CommPortIndex ; while ( c != null && c . commPort != p ) { c = c . next ; } } if ( c != null ) { return ( c ) ; } LOGGER . fine ( "not found!" + p . getName ( ) ) ; throw new NoSuchPortException ( ) ; }
|
Gets communication port identifier
|
2,082
|
static public Enumeration < CommPortIdentifier > getPortIdentifiers ( ) { LOGGER . fine ( "static CommPortIdentifier:getPortIdentifiers()" ) ; synchronized ( Sync ) { HashMap oldPorts = new HashMap ( ) ; CommPortIdentifier p = CommPortIndex ; while ( p != null ) { oldPorts . put ( p . portName , p ) ; p = p . next ; } CommPortIndex = null ; try { CommDriver RXTXDriver = ( CommDriver ) Class . forName ( "gnu.io.RXTXCommDriver" ) . newInstance ( ) ; RXTXDriver . initialize ( ) ; CommPortIdentifier curPort = CommPortIndex ; CommPortIdentifier prevPort = null ; while ( curPort != null ) { CommPortIdentifier matchingOldPort = ( CommPortIdentifier ) oldPorts . get ( curPort . portName ) ; if ( matchingOldPort != null && matchingOldPort . portType == curPort . portType ) { matchingOldPort . RXTXDriver = curPort . RXTXDriver ; matchingOldPort . next = curPort . next ; if ( prevPort == null ) { CommPortIndex = matchingOldPort ; } else { prevPort . next = matchingOldPort ; } prevPort = matchingOldPort ; } else { prevPort = curPort ; } curPort = curPort . next ; } } catch ( Throwable e ) { System . err . println ( e + " thrown while loading " + "gnu.io.RXTXCommDriver" ) ; System . err . flush ( ) ; } } return new CommPortEnumerator ( ) ; }
|
Returns an enumeration of port identifiers which represent the communication ports currently available on the system .
|
2,083
|
public CommPort open ( String TheOwner , int i ) throws gnu . io . PortInUseException { LOGGER . fine ( "CommPortIdentifier:open(" + TheOwner + ", " + i + ")" ) ; boolean isAvailable ; synchronized ( this ) { isAvailable = this . Available ; if ( isAvailable ) { this . Available = false ; this . Owner = TheOwner ; } } if ( ! isAvailable ) { long waitTimeEnd = System . currentTimeMillis ( ) + i ; fireOwnershipEvent ( CommPortOwnershipListener . PORT_OWNERSHIP_REQUESTED ) ; long waitTimeCurr ; synchronized ( this ) { while ( ! Available && ( waitTimeCurr = System . currentTimeMillis ( ) ) < waitTimeEnd ) { try { wait ( waitTimeEnd - waitTimeCurr ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; break ; } } isAvailable = this . Available ; if ( isAvailable ) { this . Available = false ; this . Owner = TheOwner ; } } } if ( ! isAvailable ) { throw new gnu . io . PortInUseException ( getCurrentOwner ( ) ) ; } try { if ( commPort == null ) { commPort = RXTXDriver . getCommPort ( portName , portType ) ; } if ( commPort != null ) { fireOwnershipEvent ( CommPortOwnershipListener . PORT_OWNED ) ; return commPort ; } else { String err_msg ; try { err_msg = native_psmisc_report_owner ( portName ) ; } catch ( Throwable t ) { err_msg = "Port " + portName + " already owned... unable to open." ; } throw new gnu . io . PortInUseException ( err_msg ) ; } } finally { if ( commPort == null ) { synchronized ( this ) { this . Available = true ; this . Owner = null ; } } } }
|
not written in java? I can t see where this request is done .
|
2,084
|
public void removePortOwnershipListener ( CommPortOwnershipListener c ) { LOGGER . fine ( "CommPortIdentifier:removePortOwnershipListener()" ) ; if ( ownershipListener != null ) { ownershipListener . removeElement ( c ) ; } }
|
removes PortOwnership listener
|
2,085
|
void internalClosePort ( ) { synchronized ( this ) { LOGGER . fine ( "CommPortIdentifier:internalClosePort()" ) ; Owner = null ; Available = true ; commPort = null ; notifyAll ( ) ; } fireOwnershipEvent ( CommPortOwnershipListener . PORT_UNOWNED ) ; }
|
clean up the Ownership information and send the event
|
2,086
|
public void removeEventListener ( ) { logger . fine ( "RXTXPort:removeEventListener() called" ) ; waitForTheNativeCodeSilly ( ) ; if ( monThreadisInterrupted == true ) { logger . fine ( " RXTXPort:removeEventListener() already interrupted" ) ; monThread = null ; SPEventListener = null ; return ; } else if ( monThread != null && monThread . isAlive ( ) ) { logger . fine ( " RXTXPort:Interrupt=true" ) ; monThreadisInterrupted = true ; logger . fine ( " RXTXPort:calling interruptEventLoop" ) ; interruptEventLoop ( ) ; logger . fine ( " RXTXPort:calling monThread.join()" ) ; try { monThread . join ( 3000 ) ; } catch ( InterruptedException ex ) { Thread . currentThread ( ) . interrupt ( ) ; return ; } { logger . fine ( " MonThread is still alive!" ) ; } } monThread = null ; SPEventListener = null ; MonitorThreadLock = false ; MonitorThreadAlive = false ; monThreadisInterrupted = true ; logger . fine ( "RXTXPort:removeEventListener() returning" ) ; }
|
Remove the serial port event listener
|
2,087
|
public static String [ ] getSerialPortList ( ) { Enumeration portList ; portList = CommPortIdentifier . getPortIdentifiers ( ) ; int serialPortCount = 0 ; while ( portList . hasMoreElements ( ) ) { CommPortIdentifier portId = ( CommPortIdentifier ) portList . nextElement ( ) ; if ( portId . getPortType ( ) == CommPortIdentifier . PORT_SERIAL ) { serialPortCount ++ ; } } String [ ] retVal = new String [ serialPortCount ] ; serialPortCount = 0 ; portList = CommPortIdentifier . getPortIdentifiers ( ) ; while ( portList . hasMoreElements ( ) ) { CommPortIdentifier portId = ( CommPortIdentifier ) portList . nextElement ( ) ; if ( portId . getPortType ( ) == CommPortIdentifier . PORT_SERIAL ) { retVal [ serialPortCount ++ ] = portId . getName ( ) ; } } return retVal ; }
|
Zwraca liste portow szeregowych
|
2,088
|
public static String [ ] getParallelPortList ( ) { Enumeration portList ; portList = CommPortIdentifier . getPortIdentifiers ( ) ; int serialPortCount = 0 ; while ( portList . hasMoreElements ( ) ) { CommPortIdentifier portId = ( CommPortIdentifier ) portList . nextElement ( ) ; if ( portId . getPortType ( ) == CommPortIdentifier . PORT_PARALLEL ) { serialPortCount ++ ; } } String [ ] retVal = new String [ serialPortCount ] ; serialPortCount = 0 ; portList = CommPortIdentifier . getPortIdentifiers ( ) ; while ( portList . hasMoreElements ( ) ) { CommPortIdentifier portId = ( CommPortIdentifier ) portList . nextElement ( ) ; if ( portId . getPortType ( ) == CommPortIdentifier . PORT_PARALLEL ) { retVal [ serialPortCount ++ ] = portId . getName ( ) ; } } return retVal ; }
|
Zwraca liste portow rownoleglych
|
2,089
|
public TokenSyncDate getTokenSyncDate ( Integer subscriptionId ) { EntityManager entityManager = getEntityManager ( ) ; try { List < TokenSyncDate > list = entityManager . createQuery ( "SELECT syncDate FROM TokenSyncDate AS syncDate WHERE subscriptionId = :subscriptionId" , TokenSyncDate . class ) . setMaxResults ( 1 ) . setParameter ( "subscriptionId" , subscriptionId ) . getResultList ( ) ; if ( ! list . isEmpty ( ) ) { return list . get ( 0 ) ; } return null ; } finally { entityManager . close ( ) ; } }
|
get the date the tokens where last synced for the subscriptionId passed as argument
|
2,090
|
public void changeConfiguration ( ChargingStationId chargingStationId , ConfigurationItem configurationItem , CorrelationToken correlationToken ) { Changeconfiguration changeConfigurationRequest = new Changeconfiguration ( ) ; changeConfigurationRequest . setKey ( configurationItem . getKey ( ) ) ; changeConfigurationRequest . setValue ( configurationItem . getValue ( ) ) ; responseHandlers . put ( correlationToken . getToken ( ) , new ChangeConfigurationResponseHandler ( configurationItem , correlationToken ) ) ; WampMessage wampMessage = new WampMessage ( WampMessage . CALL , correlationToken . getToken ( ) , MessageProcUri . CHANGE_CONFIGURATION , changeConfigurationRequest ) ; sendWampMessage ( wampMessage , chargingStationId ) ; }
|
Send a request to a charging station to change a configuration item .
|
2,091
|
private IdTagInfo_ . Status convertAuthenticationStatus ( IdentifyingToken . AuthenticationStatus status ) { IdTagInfo_ . Status result ; switch ( status ) { case ACCEPTED : result = IdTagInfo_ . Status . ACCEPTED ; break ; case EXPIRED : result = IdTagInfo_ . Status . EXPIRED ; break ; case DELETED : result = IdTagInfo_ . Status . EXPIRED ; break ; case CONCURRENT_TX : result = IdTagInfo_ . Status . CONCURRENT_TX ; break ; case BLOCKED : result = IdTagInfo_ . Status . BLOCKED ; break ; default : result = IdTagInfo_ . Status . INVALID ; break ; } return result ; }
|
Converts the AuthenticationStatus into an OCPPJ specific status
|
2,092
|
public ChargePoint getVasRepresentation ( ChargingStation chargingStation ) { ChargePoint chargePoint = new ChargePoint ( ) ; chargePoint . setAddress ( chargingStation . getAddress ( ) ) ; chargePoint . getChargingCapabilities ( ) . addAll ( getChargingCapabilities ( chargingStation ) ) ; chargePoint . setChargingMode ( getVasChargingMode ( chargingStation . getChargeMode ( ) ) ) ; chargePoint . setCity ( chargingStation . getCity ( ) ) ; chargePoint . setConnectors ( chargingStation . getNumberOfEvses ( ) ) ; chargePoint . setConnectorsFree ( chargingStation . getNumberOfFreeEvses ( ) ) ; chargePoint . getConnectorTypes ( ) . addAll ( getConnectorTypes ( chargingStation ) ) ; chargePoint . setCoordinates ( getCoordinates ( chargingStation ) ) ; chargePoint . setCountry ( chargingStation . getCountry ( ) ) ; chargePoint . setHasFixedCable ( chargingStation . isHasFixedCable ( ) ) ; chargePoint . setIsReservable ( chargingStation . isReservable ( ) ) ; chargePoint . getOpeningPeriod ( ) . addAll ( getOpeningPeriod ( chargingStation ) ) ; chargePoint . setOperator ( chargingStation . getOperator ( ) ) ; chargePoint . setPostalCode ( chargingStation . getPostalCode ( ) ) ; chargePoint . setPublic ( getPublic ( chargingStation ) ) ; chargePoint . setRegion ( chargingStation . getRegion ( ) ) ; chargePoint . setStatus ( getStatus ( chargingStation ) ) ; chargePoint . setUid ( chargingStation . getId ( ) ) ; return chargePoint ; }
|
Creates a VAS representation of a charging station .
|
2,093
|
private void updateReservableForChargingStation ( ChargingStationId chargingStationId , boolean reservable ) { ChargingStation chargingStation = getChargingStation ( chargingStationId ) ; if ( chargingStation != null ) { chargingStation . setReservable ( reservable ) ; chargingStationRepository . createOrUpdate ( chargingStation ) ; } }
|
Updates the reservable property of the charging station . If the charging station cannot be found in the repository an error is logged .
|
2,094
|
private boolean reset ( ChargingStationId id , ResetType type ) { ChargePointService chargePointService = this . createChargingStationService ( id ) ; ResetRequest request = new ResetRequest ( ) ; request . setType ( type ) ; ResetResponse response = chargePointService . reset ( request , id . getId ( ) ) ; boolean hasReset ; switch ( response . getStatus ( ) ) { case ACCEPTED : LOG . info ( "Reset was accepted" ) ; hasReset = true ; break ; case REJECTED : LOG . info ( "Reset was rejected" ) ; hasReset = false ; break ; default : throw new AssertionError ( "Unknown ResetStatus: " + response . getStatus ( ) ) ; } return hasReset ; }
|
Reset a charging station .
|
2,095
|
private void updateEvseStatus ( ChargingStation chargingStation , String componentId , ComponentStatus status ) { for ( Evse evse : chargingStation . getEvses ( ) ) { if ( evse . getEvseId ( ) . equals ( componentId ) ) { evse . setStatus ( status ) ; } } }
|
Updates the status of a Evse in the charging station object if the evse id matches the component id .
|
2,096
|
private void updateChargingStationAvailability ( ChargingStationId chargingStationId , Availability availability ) { ChargingStation chargingStation = repository . findOne ( chargingStationId . getId ( ) ) ; if ( chargingStation != null ) { chargingStation . setAvailability ( availability ) ; repository . createOrUpdate ( chargingStation ) ; } }
|
Updates the charging station s availability .
|
2,097
|
private void updateComponentAvailability ( ChargingStationId chargingStationId , ComponentId componentId , ChargingStationComponent component , Availability availability ) { if ( ! component . equals ( ChargingStationComponent . EVSE ) || ! ( componentId instanceof EvseId ) ) { return ; } ChargingStation chargingStation = repository . findOne ( chargingStationId . getId ( ) ) ; if ( chargingStation != null ) { for ( Evse evse : chargingStation . getEvses ( ) ) { if ( evse . getEvseId ( ) . equals ( componentId . getId ( ) ) ) { evse . setAvailability ( availability ) ; break ; } } repository . createOrUpdate ( chargingStation ) ; } }
|
Updates a charging station s component availability .
|
2,098
|
private boolean updateChargingStationOpeningTimes ( ChargingStationOpeningTimesChangedEvent event , boolean clear ) { ChargingStation chargingStation = repository . findOne ( event . getChargingStationId ( ) . getId ( ) ) ; if ( chargingStation != null ) { if ( ! event . getOpeningTimes ( ) . isEmpty ( ) ) { if ( clear ) { chargingStation . getOpeningTimes ( ) . clear ( ) ; } for ( OpeningTime coreOpeningTime : event . getOpeningTimes ( ) ) { Day dayOfWeek = coreOpeningTime . getDay ( ) ; String timeStart = String . format ( TIME_FORMAT , coreOpeningTime . getTimeStart ( ) . getHourOfDay ( ) , coreOpeningTime . getTimeStart ( ) . getMinutesInHour ( ) ) ; String timeStop = String . format ( TIME_FORMAT , coreOpeningTime . getTimeStop ( ) . getHourOfDay ( ) , coreOpeningTime . getTimeStop ( ) . getMinutesInHour ( ) ) ; io . motown . operatorapi . viewmodel . persistence . entities . OpeningTime openingTime = new io . motown . operatorapi . viewmodel . persistence . entities . OpeningTime ( dayOfWeek , timeStart , timeStop ) ; chargingStation . getOpeningTimes ( ) . add ( openingTime ) ; } repository . createOrUpdate ( chargingStation ) ; } } else { LOG . error ( "operator api repo COULD NOT FIND CHARGEPOINT {} and update its opening times" , event . getChargingStationId ( ) ) ; } return chargingStation != null ; }
|
Updates the opening times of the charging station .
|
2,099
|
private boolean updateChargingStationLocation ( ChargingStationLocationChangedEvent event ) { ChargingStation chargingStation = repository . findOne ( event . getChargingStationId ( ) . getId ( ) ) ; if ( chargingStation != null ) { if ( event . getCoordinates ( ) != null ) { chargingStation . setLatitude ( event . getCoordinates ( ) . getLatitude ( ) ) ; chargingStation . setLongitude ( event . getCoordinates ( ) . getLongitude ( ) ) ; } if ( event . getAddress ( ) != null ) { chargingStation . setAddressLine1 ( event . getAddress ( ) . getAddressLine1 ( ) ) ; chargingStation . setAddressLine2 ( event . getAddress ( ) . getAddressLine2 ( ) ) ; chargingStation . setPostalCode ( event . getAddress ( ) . getPostalCode ( ) ) ; chargingStation . setCity ( event . getAddress ( ) . getCity ( ) ) ; chargingStation . setRegion ( event . getAddress ( ) . getRegion ( ) ) ; chargingStation . setCountry ( event . getAddress ( ) . getCountry ( ) ) ; } chargingStation . setAccessibility ( event . getAccessibility ( ) ) ; repository . createOrUpdate ( chargingStation ) ; } else { LOG . error ( "operator api repo COULD NOT FIND CHARGEPOINT {} and update its location" , event . getChargingStationId ( ) ) ; } return chargingStation != null ; }
|
Updates the location of the charging station .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.