idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
21,200
public final void load ( final String filename ) { logger . debug ( "Loading the cache from places file: " + filename ) ; try ( InputStream fis = new FileInputStream ( filename ) ; ) { load ( fis ) ; } catch ( IOException e ) { logger . error ( "Problem reading places file" , e ) ; } }
Read places from a data file . The file is | separated . It may contain just a historical place name or both historical and modern places names .
21,201
private static Feature createLocation ( final Point point , final LocationType locationType ) { final Feature location = new Feature ( ) ; location . setGeometry ( point ) ; location . setProperty ( "locationType" , locationType ) ; location . setId ( "location" ) ; return location ; }
Convert a Point and LocationType into a Feature .
21,202
public void checkFamily ( final Family family ) { final LocalDate familyDate = analyzeDates ( family ) ; final LocalDate seenDate = earliestDate ( seenFamily ) ; if ( seenDate == null ) { if ( familyDate != null ) { seenFamily = family ; } } else { if ( familyDate != null ) { if ( familyDate . isBefore ( seenDate ) ) { final Person spouse = ( new FamilyNavigator ( family ) ) . getSpouse ( person ) ; final Person seenSpouse = ( new FamilyNavigator ( seenFamily ) ) . getSpouse ( person ) ; final String message = String . format ( "Family order: family with spouse %s (%s) is after " + "family with spouse %s (%s)" , spouse . getName ( ) . getString ( ) , familyDate . toString ( ) , seenSpouse . getName ( ) . getString ( ) , seenDate . toString ( ) ) ; getResult ( ) . addMismatch ( message ) ; } seenFamily = family ; } } }
Check this family for internal order and relative order to the other families for this person .
21,203
private LocalDate analyzeDates ( final Family family ) { if ( family == null ) { return null ; } LocalDate earliestDate = null ; final FamilyAnalysisVisitor visitor = new FamilyAnalysisVisitor ( ) ; family . accept ( visitor ) ; for ( final Attribute attribute : visitor . getTrimmedAttributes ( ) ) { basicOrderCheck ( attribute ) ; setSeenEvent ( attribute ) ; final LocalDate date = createLocalDate ( attribute ) ; earliestDate = minDate ( earliestDate , date ) ; } return earliestDate ( visitor ) ; }
Analyze the family . Add any date order problems to the analysis .
21,204
@ RequestMapping ( value = "/v1/upload" , method = RequestMethod . POST , consumes = "multipart/form-data" ) public final ApiHead upload ( @ RequestParam ( "file" ) final MultipartFile file ) { if ( file == null ) { logger . info ( "in file upload: file is null" ) ; return null ; } logger . info ( "in file upload: " + file . getOriginalFilename ( ) ) ; storageService . store ( file ) ; final String name = file . getOriginalFilename ( ) . replaceAll ( "\\.ged" , "" ) ; return crud ( ) . readOne ( name , "" ) ; }
Controller for uploading new GEDCOM files .
21,205
protected static final StringBuilder renderPad ( final StringBuilder builder , final int pad , final boolean newLine ) { renderNewLine ( builder , newLine ) ; for ( int i = 0 ; i < pad ; i ++ ) { builder . append ( ' ' ) ; } return builder ; }
Render some leading spaces onto a line of html .
21,206
public final void visit ( final Attribute attribute ) { attributes . add ( attribute ) ; if ( ignoreable ( attribute ) ) { return ; } trimmedAttributes . add ( attribute ) ; }
Visit an Attribute . Track the complete list of Attributes and a list trimmed by removing ignoreable attributes .
21,207
@ RequestMapping ( "/submission" ) public final String submission ( @ RequestParam ( value = "id" , required = false , defaultValue = "SUBN1" ) final String idString , @ RequestParam ( value = "db" , required = false , defaultValue = "schoeller" ) final String dbName , final Model model ) { logger . debug ( "Entering source" ) ; final Root root = fetchRoot ( dbName ) ; final RenderingContext context = createRenderingContext ( ) ; final Submission submission = ( Submission ) root . find ( idString ) ; if ( submission == null ) { throw new SubmissionNotFoundException ( "Submission " + idString + " not found" , idString , dbName , context ) ; } final GedRenderer < ? > submissionRenderer = new GedRendererFactory ( ) . create ( submission , context ) ; model . addAttribute ( "filename" , gedbrowserHome + "/" + dbName + ".ged" ) ; model . addAttribute ( "submissionString" , submission . getString ( ) ) ; model . addAttribute ( "model" , submissionRenderer ) ; model . addAttribute ( "appInfo" , appInfo ) ; logger . debug ( "Exiting submission" ) ; return "submission" ; }
Connects HTML template file with data for the submission page .
21,208
private String loginDestinationUrl ( final HttpServletRequest request ) { final HttpSession session = request . getSession ( ) ; final String requestReferer = request . getHeader ( "referer" ) ; final String sessionReferer = ( String ) session . getAttribute ( SESSION_REFERER_KEY ) ; if ( useReferer ( requestReferer ) ) { return requestReferer ; } else if ( useReferer ( sessionReferer ) ) { return sessionReferer ; } else { return servletPath + "/person?db=schoeller&id=I1" ; } }
Try to figure out where to go after login . We have to do a few tricks in order to carry that around .
21,209
public LocalDate estimateFromMarriage ( final LocalDate localDate ) { if ( localDate != null ) { return localDate ; } final PersonNavigator navigator = new PersonNavigator ( person ) ; final List < Family > families = navigator . getFamiliesC ( ) ; LocalDate date = null ; for ( final Family family : families ) { date = processMarriageDate ( date , family ) ; date = childAdjustment ( date ) ; date = estimateFromFatherMarriage ( date , family ) ; date = estimateFromMotherMarriage ( date , family ) ; if ( date != null ) { break ; } } return date ; }
Try recursing through the ancestors to find a marriage date .
21,210
private LocalDate estimateFromParentMarriage ( final Person parent ) { final BirthDateEstimator bde = createEstimator ( parent ) ; return estimateFromParentMarriage ( bde ) ; }
Estimate birth date from parent s marriage .
21,211
private LocalDate ancestorAdjustment ( final LocalDate date ) { if ( date == null ) { return null ; } return date . plusYears ( typicals . ageAtMarriage ( ) + typicals . gapBetweenChildren ( ) ) . withMonthOfYear ( 1 ) . withDayOfMonth ( 1 ) ; }
Apply a standard adjustment from an ancestor s marriage date to a person s birth date .
21,212
private LocalDate childAdjustment ( final LocalDate date ) { if ( date == null ) { return date ; } return date . plusYears ( typicals . gapBetweenChildren ( ) ) . withMonthOfYear ( 1 ) . withDayOfMonth ( 1 ) ; }
Adjust by the gap between children and to beginning of month .
21,213
private static String buildParentString ( final String tag , final String tail ) { if ( tail . isEmpty ( ) ) { return tag ; } else { return tag + " " + tail ; } }
The parent can only take one string . If we need to concatenate the strings . The argument tag should never be empty but tail could be .
21,214
public void visit ( final Child child ) { final Person person = child . getChild ( ) ; if ( child . isSet ( ) && person . isSet ( ) ) { childList . add ( child ) ; children . add ( person ) ; } }
Visit a Child . We track this and if set the Person who is the child .
21,215
public void visit ( final Family family ) { for ( final GedObject gob : family . getAttributes ( ) ) { gob . accept ( this ) ; } }
Visit a Family . This is the primary focus of the visitation . From here interesting information is gathered from the attributes .
21,216
public void visit ( final Husband husband ) { this . husbandFound = husband ; if ( husband . isSet ( ) ) { father = husband . getFather ( ) ; spouses . add ( father ) ; } }
Visit a Husband . We track this and if set the Person who is the father .
21,217
public void visit ( final Wife wife ) { this . wifeFound = wife ; if ( wife . isSet ( ) ) { mother = wife . getMother ( ) ; spouses . add ( mother ) ; } }
Visit a Wife . We track this and if set the Person who is the mother .
21,218
public ApiPerson createOne ( final String db , final ApiPerson person ) { logger . info ( "Entering create person in db: " + db ) ; return create ( readRoot ( db ) , person , ( i , id ) -> new ApiPerson ( i , id ) ) ; }
Create a new person from the passed object .
21,219
public void visit ( final Attribute attribute ) { if ( "Restriction" . equals ( attribute . getString ( ) ) && "confidential" . equals ( attribute . getTail ( ) ) ) { isConfidential = true ; } }
Visit an Attribute . Certain Attributes contribute interest data .
21,220
public GeoCodeItem toGeoCodeItem ( final GeoServiceItem gsItem ) { if ( gsItem == null ) { return null ; } return new GeoCodeItem ( gsItem . getPlaceName ( ) , gsItem . getModernPlaceName ( ) , toGeocodingResult ( gsItem . getResult ( ) ) ) ; }
Create a GeoCodeItem from a GeoServiceItem .
21,221
public GeocodingResult toGeocodingResult ( final GeoServiceGeocodingResult gsResult ) { if ( gsResult == null ) { return null ; } final GeocodingResult result = new GeocodingResult ( ) ; final AddressComponent [ ] addressComponents = gsResult . getAddressComponents ( ) ; if ( addressComponents == null ) { result . addressComponents = null ; } else { result . addressComponents = new AddressComponent [ addressComponents . length ] ; for ( int i = 0 ; i < addressComponents . length ; i ++ ) { result . addressComponents [ i ] = copy ( addressComponents [ i ] ) ; } } result . formattedAddress = gsResult . getFormattedAddress ( ) ; result . geometry = toGeometry ( gsResult . getGeometry ( ) ) ; result . partialMatch = gsResult . isPartialMatch ( ) ; result . placeId = gsResult . getPlaceId ( ) ; result . postcodeLocalities = gsResult . getPostcodeLocalities ( ) ; result . types = gsResult . getTypes ( ) ; return result ; }
Create a GeocodingResult from a GeoServiceGeocodingResult .
21,222
private AddressComponent copy ( final AddressComponent in ) { final AddressComponent out = new AddressComponent ( ) ; out . longName = in . longName ; out . shortName = in . shortName ; out . types = Arrays . copyOf ( in . types , in . types . length ) ; return out ; }
Copy an address component . Since they are NOT immutable I don t want to mess with the variability of the damn things .
21,223
public Geometry toGeometry ( final FeatureCollection featureCollection ) { if ( featureCollection == null ) { return null ; } final Geometry geometry = new Geometry ( ) ; final Feature location = populateBoundaries ( geometry , featureCollection ) ; populateLocation ( geometry , location ) ; return geometry ; }
Create a Geometry from a GeoServiceGeometry .
21,224
private LocationType toLocationType ( final Object property ) { if ( property == null ) { return null ; } return LocationType . valueOf ( property . toString ( ) ) ; }
Convert a property to a Google LocationType .
21,225
public GeoServiceItem toGeoServiceItem ( final GeoCodeItem item ) { if ( item == null ) { return null ; } return new GeoServiceItem ( item . getPlaceName ( ) , item . getModernPlaceName ( ) , toGeoServiceGeocodingResult ( item . getGeocodingResult ( ) ) ) ; }
Create a GeoServiceItem from a GeoCodeItem .
21,226
public GeoServiceGeocodingResult toGeoServiceGeocodingResult ( final GeocodingResult result ) { if ( result == null ) { return null ; } return new GeoServiceGeocodingResult ( result . addressComponents , result . formattedAddress , result . postcodeLocalities , toGeoServiceGeometry ( result . geometry ) , result . types , result . partialMatch , result . placeId ) ; }
Create a GeoServiceGeocodingResult from a GeocodingResult .
21,227
public FeatureCollection toGeoServiceGeometry ( final Geometry geometry ) { if ( geometry == null ) { return GeoServiceGeometry . createFeatureCollection ( toLocationFeature ( new LatLng ( Double . NaN , Double . NaN ) , LocationType . UNKNOWN ) , null , null ) ; } return GeoServiceGeometry . createFeatureCollection ( toLocationFeature ( geometry . location , geometry . locationType ) , toBox ( "bounds" , geometry . bounds ) , toBox ( "viewport" , geometry . viewport ) ) ; }
Create a GeoServiceGeometry from a Geometry .
21,228
public Person getMother ( ) { if ( ! isSet ( ) ) { return new Person ( ) ; } final Person mother = ( Person ) find ( getToString ( ) ) ; if ( mother == null ) { return new Person ( ) ; } else { return mother ; } }
Get the person that this object points to . If not found return an unset Person .
21,229
public void visit ( final Attribute attribute ) { for ( final GedObject gob : attribute . getAttributes ( ) ) { gob . accept ( this ) ; } }
Visit an Attributes . Look at Attributes to find Places .
21,230
public void visit ( final Person person ) { for ( final GedObject gob : person . getAttributes ( ) ) { gob . accept ( this ) ; } final PersonNavigator navigator = new PersonNavigator ( person ) ; for ( final Family family : navigator . getFamilies ( ) ) { family . accept ( this ) ; } }
Visit a Person . Look at Attributes and Families to find Places .
21,231
public void visit ( final Place place ) { placeStrings . add ( place . getString ( ) ) ; places . add ( place ) ; }
Visit a Place . The names of Places are collected .
21,232
public void visit ( final Root root ) { for ( final String letter : root . findSurnameInitialLetters ( ) ) { for ( final String surname : root . findBySurnamesBeginWith ( letter ) ) { for ( final Person person : root . findBySurname ( surname ) ) { person . accept ( this ) ; } } } }
Visit the Root . From here we will look through the top level objects for Persons . Persons direct to Places and Places are what we really want .
21,233
public void init ( ) { final String string = getString ( ) ; final int bpos = string . indexOf ( '/' ) ; if ( bpos == - 1 ) { prefix = string ; surname = "" ; suffix = "" ; } else { final int epos = string . indexOf ( '/' , bpos + 1 ) ; prefix = string . substring ( 0 , bpos ) ; surname = string . substring ( bpos + 1 , epos ) ; suffix = string . substring ( epos + 1 ) ; } }
Parse the name string from GEDCOM normal into its component parts .
21,234
public void init ( ) { surnameIndex . clear ( ) ; final RootVisitor visitor = new RootVisitor ( ) ; mRoot . accept ( visitor ) ; for ( final Person person : visitor . getPersons ( ) ) { final String key = person . getString ( ) ; final String indexName = person . getIndexName ( ) ; if ( ! indexName . isEmpty ( ) ) { final SortedMap < String , SortedSet < String > > names = findNamesPerSurname ( person . getSurname ( ) ) ; final SortedSet < String > ids = findIdsPerName ( indexName , names ) ; ids . add ( key ) ; } } }
Initialize the index from the root s objects .
21,235
private SortedMap < String , SortedSet < String > > findNamesPerSurname ( final String surname ) { if ( surnameIndex . containsKey ( surname ) ) { return surnameIndex . get ( surname ) ; } final SortedMap < String , SortedSet < String > > namesPerSurname = new TreeMap < String , SortedSet < String > > ( ) ; surnameIndex . put ( surname , namesPerSurname ) ; return namesPerSurname ; }
Find the map of full names to a sets of IDs for the given surname . If the surname is not already present create a new map and add it to the index .
21,236
private SortedSet < String > findIdsPerName ( final String indexName , final SortedMap < String , SortedSet < String > > names ) { if ( names . containsKey ( indexName ) ) { return names . get ( indexName ) ; } final TreeSet < String > idsPerName = new TreeSet < String > ( ) ; names . put ( indexName , idsPerName ) ; return idsPerName ; }
Find the set of IDs associated with a full name in the provided map .
21,237
public Set < String > getNamesPerSurname ( final String surname ) { if ( surname == null ) { return Collections . emptySet ( ) ; } if ( ! surnameIndex . containsKey ( surname ) ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( surnameIndex . get ( surname ) . keySet ( ) ) ; }
Get the set of full names that occur for a given surname .
21,238
private Map < String , SortedSet < String > > getNamesPerSurnameMap ( final String surname ) { if ( ! surnameIndex . containsKey ( surname ) ) { return Collections . emptyMap ( ) ; } return surnameIndex . get ( surname ) ; }
Get map of full names to sets of IDs for the provided surname .
21,239
public Set < String > getIdsPerName ( final String surname , final String name ) { if ( surname == null || name == null ) { return Collections . emptySet ( ) ; } final Map < String , SortedSet < String > > namesPerSurname = getNamesPerSurnameMap ( surname ) ; if ( ! namesPerSurname . containsKey ( name ) ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( namesPerSurname . get ( name ) ) ; }
Get the set of IDs for the given surname and full name .
21,240
protected final LocalDate estimateFromOtherEvents ( final LocalDate localDate ) { if ( localDate != null ) { return localDate ; } final PersonAnalysisVisitor visitor = new PersonAnalysisVisitor ( ) ; person . accept ( visitor ) ; for ( final Attribute attr : visitor . getAttributes ( ) ) { final String dateString = getDate ( attr ) ; final LocalDate date = estimateFromEvent ( attr , dateString ) ; if ( date != null ) { return date ; } } return null ; }
Try other lifecycle events .
21,241
public Person getFather ( ) { if ( ! isSet ( ) ) { return new Person ( ) ; } final Person father = ( Person ) find ( getToString ( ) ) ; if ( father == null ) { return new Person ( ) ; } else { return father ; } }
Get the person that this object refers to . If not found return an unset Person .
21,242
public static PrimitiveMatrix toCorrelations ( Access2D < ? > covariances , boolean clean ) { int size = Math . toIntExact ( Math . min ( covariances . countRows ( ) , covariances . countColumns ( ) ) ) ; MatrixStore < Double > covarianceMtrx = MatrixStore . PRIMITIVE . makeWrapper ( covariances ) . get ( ) ; if ( clean ) { Eigenvalue < Double > evd = Eigenvalue . PRIMITIVE . make ( covarianceMtrx , true ) ; evd . decompose ( covarianceMtrx ) ; MatrixStore < Double > mtrxV = evd . getV ( ) ; PhysicalStore < Double > mtrxD = evd . getD ( ) . copy ( ) ; double largest = evd . getEigenvalues ( ) . get ( 0 ) . norm ( ) ; double limit = largest * size * PrimitiveMath . RELATIVELY_SMALL ; for ( int ij = 0 ; ij < size ; ij ++ ) { if ( mtrxD . doubleValue ( ij , ij ) < limit ) { mtrxD . set ( ij , ij , limit ) ; } } covarianceMtrx = mtrxV . multiply ( mtrxD ) . multiply ( mtrxV . transpose ( ) ) ; } PrimitiveMatrix . DenseReceiver retVal = PrimitiveMatrix . FACTORY . makeDense ( size , size ) ; double [ ] volatilities = new double [ size ] ; for ( int ij = 0 ; ij < size ; ij ++ ) { volatilities [ ij ] = PrimitiveMath . SQRT . invoke ( covarianceMtrx . doubleValue ( ij , ij ) ) ; } for ( int j = 0 ; j < size ; j ++ ) { double colVol = volatilities [ j ] ; retVal . set ( j , j , PrimitiveMath . ONE ) ; for ( int i = j + 1 ; i < size ; i ++ ) { double rowVol = volatilities [ i ] ; if ( ( rowVol <= PrimitiveMath . ZERO ) || ( colVol <= PrimitiveMath . ZERO ) ) { retVal . set ( i , j , PrimitiveMath . ZERO ) ; retVal . set ( j , i , PrimitiveMath . ZERO ) ; } else { double covariance = covarianceMtrx . doubleValue ( i , j ) ; double correlation = covariance / ( rowVol * colVol ) ; retVal . set ( i , j , correlation ) ; retVal . set ( j , i , correlation ) ; } } } return retVal . get ( ) ; }
Will extract the correlation coefficients from the input covariance matrix . If cleaning is enabled small and negative eigenvalues of the covariance matrix will be replaced with a new minimal value .
21,243
static ResourceLocator . Request buildChallengeRequest ( ResourceLocator . Session session , String symbol ) { return session . request ( ) . host ( FINANCE_YAHOO_COM ) . path ( "/quote/" + symbol + "/options" ) ; }
A request that requires consent and will set the B cookie but not the crumb
21,244
protected PrimitiveMatrix calculateAssetWeights ( ) { if ( this . getOptimisationOptions ( ) . logger_appender != null ) { BasicLogger . debug ( ) ; BasicLogger . debug ( "###################################################" ) ; BasicLogger . debug ( "BEGIN RAF: {} MarkowitzModel optimisation" , this . getRiskAversion ( ) ) ; BasicLogger . debug ( "###################################################" ) ; BasicLogger . debug ( ) ; } Optimisation . Result tmpResult ; if ( ( myTargetReturn != null ) || ( myTargetVariance != null ) ) { final double tmpTargetValue ; if ( myTargetVariance != null ) { tmpTargetValue = myTargetVariance . doubleValue ( ) ; } else if ( myTargetReturn != null ) { tmpTargetValue = myTargetReturn . doubleValue ( ) ; } else { tmpTargetValue = _0_0 ; } tmpResult = this . generateOptimisationModel ( _0_0 ) . minimise ( ) ; double tmpTargetNow = _0_0 ; double tmpTargetDiff = _0_0 ; double tmpTargetLast = _0_0 ; if ( tmpResult . getState ( ) . isFeasible ( ) ) { double tmpCurrent ; double tmpLow ; double tmpHigh ; if ( this . isDefaultRiskAversion ( ) ) { tmpCurrent = INIT ; tmpLow = MAX ; tmpHigh = MIN ; } else { tmpCurrent = this . getRiskAversion ( ) . doubleValue ( ) ; tmpLow = tmpCurrent * INIT ; tmpHigh = tmpCurrent / INIT ; } do { final ExpressionsBasedModel tmpModel = this . generateOptimisationModel ( tmpCurrent ) ; tmpResult = tmpModel . minimise ( ) ; tmpTargetLast = tmpTargetNow ; if ( myTargetVariance != null ) { tmpTargetNow = this . calculatePortfolioVariance ( tmpResult ) . doubleValue ( ) ; } else if ( myTargetReturn != null ) { tmpTargetNow = this . calculatePortfolioReturn ( tmpResult , this . calculateAssetReturns ( ) ) . doubleValue ( ) ; } else { tmpTargetNow = tmpTargetValue ; } tmpTargetDiff = tmpTargetNow - tmpTargetValue ; if ( this . getOptimisationOptions ( ) . logger_appender != null ) { BasicLogger . debug ( ) ; BasicLogger . debug ( "RAF: {}" , tmpCurrent ) ; BasicLogger . debug ( "Last: {}" , tmpTargetLast ) ; BasicLogger . debug ( "Now: {}" , tmpTargetNow ) ; BasicLogger . debug ( "Target: {}" , tmpTargetValue ) ; BasicLogger . debug ( "Diff: {}" , tmpTargetDiff ) ; BasicLogger . debug ( "Iteration: {}" , tmpResult ) ; BasicLogger . debug ( ) ; } if ( tmpTargetDiff < _0_0 ) { tmpLow = tmpCurrent ; } else if ( tmpTargetDiff > _0_0 ) { tmpHigh = tmpCurrent ; } tmpCurrent = PrimitiveMath . SQRT . invoke ( tmpLow * tmpHigh ) ; } while ( ! TARGET_CONTEXT . isSmall ( tmpTargetValue , tmpTargetDiff ) && TARGET_CONTEXT . isDifferent ( tmpHigh , tmpLow ) ) ; } } else { tmpResult = this . generateOptimisationModel ( this . getRiskAversion ( ) . doubleValue ( ) ) . minimise ( ) ; } return this . handle ( tmpResult ) ; }
Constrained optimisation .
21,245
public static Scalar < ? > calculatePortfolioReturn ( final PrimitiveMatrix assetWeights , final PrimitiveMatrix assetReturns ) { return PrimitiveScalar . valueOf ( assetWeights . dot ( assetReturns ) ) ; }
Calculates the portfolio return using the input asset weights and returns .
21,246
public PrimitiveMatrix calculateAssetReturns ( final PrimitiveMatrix assetWeights ) { final PrimitiveMatrix tmpAssetWeights = myRiskAversion . compareTo ( DEFAULT_RISK_AVERSION ) == 0 ? assetWeights : assetWeights . multiply ( myRiskAversion ) ; return myCovariances . multiply ( tmpAssetWeights ) ; }
If the input vector of asset weights are the weights of the market portfolio then the ouput is the equilibrium excess returns .
21,247
public PrimitiveMatrix calculateAssetWeights ( final PrimitiveMatrix assetReturns ) { final PrimitiveMatrix tmpAssetWeights = myCovariances . solve ( assetReturns ) ; if ( myRiskAversion . compareTo ( DEFAULT_RISK_AVERSION ) == 0 ) { return tmpAssetWeights ; } else { return tmpAssetWeights . divide ( myRiskAversion ) ; } }
If the input vector of returns are the equilibrium excess returns then the output is the market portfolio weights . This is unconstrained optimisation - there are no constraints on the resulting instrument weights .
21,248
public Scalar < ? > calculatePortfolioVariance ( final PrimitiveMatrix assetWeights ) { PrimitiveMatrix tmpLeft ; PrimitiveMatrix tmpRight ; if ( assetWeights . countColumns ( ) == 1L ) { tmpLeft = assetWeights . transpose ( ) ; tmpRight = assetWeights ; } else { tmpLeft = assetWeights ; tmpRight = assetWeights . transpose ( ) ; } return tmpLeft . multiply ( myCovariances . multiply ( tmpRight ) ) . toScalar ( 0 , 0 ) ; }
Calculates the portfolio variance using the input instrument weights .
21,249
public MarketEquilibrium clean ( ) { final PrimitiveMatrix tmpAssetVolatilities = FinanceUtils . toVolatilities ( myCovariances , true ) ; final PrimitiveMatrix tmpCleanedCorrelations = FinanceUtils . toCorrelations ( myCovariances , true ) ; final PrimitiveMatrix tmpCovariances = FinanceUtils . toCovariances ( tmpAssetVolatilities , tmpCleanedCorrelations ) ; return new MarketEquilibrium ( myAssetKeys , tmpCovariances , myRiskAversion ) ; }
Equivalent to copying but additionally the covariance matrix will be cleaned of negative and very small eigenvalues to make it positive definite .
21,250
protected PrimitiveMatrix getViewReturns ( ) { final int tmpRowDim = myViews . size ( ) ; final int tmpColDim = 1 ; final PrimitiveMatrix . DenseReceiver retVal = MATRIX_FACTORY . makeDense ( tmpRowDim , tmpColDim ) ; double tmpRet ; final double tmpRAF = this . getRiskAversion ( ) . doubleValue ( ) ; for ( int i = 0 ; i < tmpRowDim ; i ++ ) { tmpRet = myViews . get ( i ) . getMeanReturn ( ) ; retVal . set ( i , 0 , PrimitiveMath . DIVIDE . invoke ( tmpRet , tmpRAF ) ) ; } return retVal . build ( ) ; }
Scaled by risk aversion factor .
21,251
public User initialize ( String authCode , String redirectUri ) throws WorkspaceApiException { return initialize ( authCode , redirectUri , null , null ) ; }
Initialize the API using the provided authorization code and redirect URI . The authorization code comes from using the Authorization Code Grant flow to authenticate with the Authentication API .
21,252
public User initialize ( String token ) throws WorkspaceApiException { return initialize ( null , null , null , token ) ; }
Initialize the API using the provided access token .
21,253
public void destroy ( long disconnectRequestTimeout ) throws WorkspaceApiException { try { if ( this . workspaceInitialized ) { notifications . disconnect ( disconnectRequestTimeout ) ; sessionApi . logout ( ) ; } } catch ( Exception e ) { throw new WorkspaceApiException ( "destroy failed." , e ) ; } finally { this . workspaceInitialized = false ; } }
Ends the current agent s session . This request logs out the agent on all activated channels ends the HTTP session and cleans up related resources . After you end the session you ll need to make a login request before making any new calls to the API .
21,254
public void setAgentReady ( KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicereadyData readyData = new VoicereadyData ( ) ; readyData . setReasons ( Util . toKVList ( reasons ) ) ; readyData . setExtensions ( Util . toKVList ( extensions ) ) ; ReadyData data = new ReadyData ( ) ; data . data ( readyData ) ; ApiSuccessResponse response = this . voiceApi . setAgentStateReady ( data ) ; throwIfNotOk ( "setAgentReady" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "setAgentReady failed." , e ) ; } }
Set the current agent s state to Ready on the voice channel .
21,255
public void dndOn ( ) throws WorkspaceApiException { try { ApiSuccessResponse response = this . voiceApi . setDNDOn ( null ) ; throwIfNotOk ( "dndOn" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "dndOn failed." , e ) ; } }
Set the current agent s state to Do Not Disturb on the voice channel .
21,256
public void dndOff ( ) throws WorkspaceApiException { try { ApiSuccessResponse response = this . voiceApi . setDNDOff ( null ) ; throwIfNotOk ( "dndOff" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "dndOff failed." , e ) ; } }
Turn off Do Not Disturb for the current agent on the voice channel .
21,257
public void setForward ( String destination ) throws WorkspaceApiException { try { VoicesetforwardData forwardData = new VoicesetforwardData ( ) ; forwardData . setForwardTo ( destination ) ; ForwardData data = new ForwardData ( ) ; data . data ( forwardData ) ; ApiSuccessResponse response = this . voiceApi . forward ( data ) ; throwIfNotOk ( "setForward" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "setForward failed." , e ) ; } }
Set call forwarding on the current agent s DN to the specified destination .
21,258
public void cancelForward ( ) throws WorkspaceApiException { try { ApiSuccessResponse response = this . voiceApi . cancelForward ( null ) ; throwIfNotOk ( "cancelForward" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "cancelForward failed." , e ) ; } }
Cancel call forwarding for the current agent .
21,259
public void answerCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData answerData = new VoicecallsidanswerData ( ) ; answerData . setReasons ( Util . toKVList ( reasons ) ) ; answerData . setExtensions ( Util . toKVList ( extensions ) ) ; AnswerData data = new AnswerData ( ) ; data . setData ( answerData ) ; ApiSuccessResponse response = this . voiceApi . answer ( connId , data ) ; throwIfNotOk ( "answerCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "answerCall failed." , e ) ; } }
Answer the specified call .
21,260
public void holdCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData holdData = new VoicecallsidanswerData ( ) ; holdData . setReasons ( Util . toKVList ( reasons ) ) ; holdData . setExtensions ( Util . toKVList ( extensions ) ) ; HoldData data = new HoldData ( ) ; data . data ( holdData ) ; ApiSuccessResponse response = this . voiceApi . hold ( connId , data ) ; throwIfNotOk ( "holdCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "holdCall failed." , e ) ; } }
Place the specified call on hold .
21,261
public void retrieveCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData retrieveData = new VoicecallsidanswerData ( ) ; retrieveData . setReasons ( Util . toKVList ( reasons ) ) ; retrieveData . setExtensions ( Util . toKVList ( extensions ) ) ; RetrieveData data = new RetrieveData ( ) ; data . data ( retrieveData ) ; ApiSuccessResponse response = this . voiceApi . retrieve ( connId , data ) ; throwIfNotOk ( "retrieveCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "retrieveCall failed." , e ) ; } }
Retrieve the specified call from hold .
21,262
public void releaseCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData releaseData = new VoicecallsidanswerData ( ) ; releaseData . setReasons ( Util . toKVList ( reasons ) ) ; releaseData . setExtensions ( Util . toKVList ( extensions ) ) ; ReleaseData data = new ReleaseData ( ) ; data . data ( releaseData ) ; ApiSuccessResponse response = this . voiceApi . release ( connId , data ) ; throwIfNotOk ( "releaseCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "releaseCall failed." , e ) ; } }
Release the specified call .
21,263
public void initiateConference ( String connId , String destination , String location , String outboundCallerId , KeyValueCollection userData , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidinitiateconferenceData initData = new VoicecallsidinitiateconferenceData ( ) ; initData . setDestination ( destination ) ; initData . setLocation ( location ) ; initData . setOutboundCallerId ( outboundCallerId ) ; initData . setUserData ( Util . toKVList ( userData ) ) ; initData . setReasons ( Util . toKVList ( reasons ) ) ; initData . setExtensions ( Util . toKVList ( extensions ) ) ; InitiateConferenceData data = new InitiateConferenceData ( ) ; data . data ( initData ) ; ApiSuccessResponse response = this . voiceApi . initiateConference ( connId , data ) ; throwIfNotOk ( "initiateConference" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "initiateConference failed." , e ) ; } }
Initiate a two - step conference to the specified destination . This places the existing call on hold and creates a new call in the dialing state . After initiating the conference you can use completeConference to complete the conference and bring all parties into the same call .
21,264
public void completeConference ( String connId , String parentConnId ) throws WorkspaceApiException { this . completeConference ( connId , parentConnId , null , null ) ; }
Complete a previously initiated two - step conference identified by the provided IDs . Once completed the two separate calls are brought together so that all three parties are participating in the same call .
21,265
public void attachUserData ( String connId , KeyValueCollection userData ) throws WorkspaceApiException { try { VoicecallsidcompleteData completeData = new VoicecallsidcompleteData ( ) ; completeData . setUserData ( Util . toKVList ( userData ) ) ; UserDataOperationId data = new UserDataOperationId ( ) ; data . data ( completeData ) ; ApiSuccessResponse response = this . voiceApi . attachUserData ( connId , data ) ; throwIfNotOk ( "attachUserData" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "attachUserData failed." , e ) ; } }
Attach the provided data to the call . This adds the data to the call even if data already exists with the provided keys .
21,266
public void deleteUserDataPair ( String connId , String key ) throws WorkspaceApiException { try { VoicecallsiddeleteuserdatapairData deletePairData = new VoicecallsiddeleteuserdatapairData ( ) ; deletePairData . setKey ( key ) ; KeyData data = new KeyData ( ) ; data . data ( deletePairData ) ; ApiSuccessResponse response = this . voiceApi . deleteUserDataPair ( connId , data ) ; throwIfNotOk ( "deleteUserDataPair" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "deleteUserDataPair failed." , e ) ; } }
Delete data with the specified key from the call s user data .
21,267
public void redirectCall ( String connId , String destination ) throws WorkspaceApiException { this . redirectCall ( connId , destination , null , null ) ; }
Redirect a call to the specified destination .
21,268
public void redirectCall ( String connId , String destination , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidredirectData redirectData = new VoicecallsidredirectData ( ) ; redirectData . setDestination ( destination ) ; redirectData . setReasons ( Util . toKVList ( reasons ) ) ; redirectData . setExtensions ( Util . toKVList ( extensions ) ) ; RedirectData data = new RedirectData ( ) ; data . data ( redirectData ) ; ApiSuccessResponse response = this . voiceApi . redirect ( connId , data ) ; throwIfNotOk ( "redirectCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "redirectCall failed." , e ) ; } }
Redirect a call to the specified destination
21,269
public void clearCall ( String connId , KeyValueCollection reasons , KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData clearData = new VoicecallsidanswerData ( ) ; clearData . setReasons ( Util . toKVList ( reasons ) ) ; clearData . setExtensions ( Util . toKVList ( extensions ) ) ; ClearData data = new ClearData ( ) ; data . data ( clearData ) ; ApiSuccessResponse response = this . voiceApi . clear ( connId , data ) ; throwIfNotOk ( "clearCall" , response ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "clearCall failed." , e ) ; } }
End the conference call for all parties . This can be performed by any agent participating in the conference .
21,270
public ApiResponse < CurrentSession > getCurrentSessionWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = getCurrentSessionValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < CurrentSession > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; }
Get information about the current user Get information about the current user including any existing media logins calls and interactions . The returned user information includes state recovery information about the active session . You can make this request at startup to check for an existing session .
21,271
public ApiResponse < CurrentSession > getUserInfoWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = getUserInfoValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < CurrentSession > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; }
Retrieve encrypted data about the current user This request can be used to retrieve encrypted data about the user to use with other services
21,272
public List < StatisticValue > peek ( String subscriptionId ) throws WorkspaceApiException { try { InlineResponse2002 resp = api . peek ( subscriptionId ) ; Util . throwIfNotOk ( resp . getStatus ( ) ) ; InlineResponse2002Data data = resp . getData ( ) ; if ( data == null ) { throw new WorkspaceApiException ( "Response data is empty" ) ; } return data . getStatistics ( ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot peek" , ex ) ; } }
Get the statistics for the specified subscription ID .
21,273
public void unsubscribe ( String subscriptionId ) throws WorkspaceApiException { try { ApiSuccessResponse resp = api . unsubscribe ( subscriptionId ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot unsubscribe" , ex ) ; } }
Unsubscribe from the specified group of statistics .
21,274
public ApiResponse < ApiSuccessResponse > ackRecentMissedCallsWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = ackRecentMissedCallsValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < ApiSuccessResponse > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; }
Acknowledge missed calls Acknowledge missed calls in the list of recent targets .
21,275
public ApiResponse < Void > swaggerDocWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = swaggerDocValidateBeforeCall ( null , null ) ; return apiClient . execute ( call ) ; }
Returns API description in Swagger format Returns API description in Swagger format
21,276
public ApiResponse < Info > versionInfoWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = versionInfoValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < Info > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; }
Returns version information Returns version information
21,277
public ApiResponse < Void > notificationsWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = notificationsValidateBeforeCall ( null , null ) ; return apiClient . execute ( call ) ; }
CometD endpoint Subscribe to the CometD notification API .
21,278
public SearchResult < Target > search ( String searchTerm , TargetsSearchOptions options ) throws WorkspaceApiException { try { String types = null ; List < String > typesArray = null ; if ( options . getTypes ( ) != null ) { typesArray = new ArrayList < > ( 10 ) ; for ( TargetType targetType : options . getTypes ( ) ) { typesArray . add ( targetType . getValue ( ) ) ; } types = StringUtil . join ( typesArray . toArray ( new String [ typesArray . size ( ) ] ) , "," ) ; } String excludeGroups = options . getExcludeGroups ( ) != null ? StringUtil . join ( options . getExcludeGroups ( ) , "," ) : null ; String restrictGroups = options . getRestrictGroups ( ) != null ? StringUtil . join ( options . getRestrictGroups ( ) , "," ) : null ; String excludeFromGroups = options . getExcludeFromGroups ( ) != null ? StringUtil . join ( options . getExcludeFromGroups ( ) , "," ) : null ; String restrictToGroups = options . getRestrictToGroups ( ) != null ? StringUtil . join ( options . getRestrictToGroups ( ) , "," ) : null ; TargetsResponse response = this . targetsApi . getTargets ( searchTerm , options . getFilterName ( ) , types , excludeGroups , restrictGroups , excludeFromGroups , restrictToGroups , options . isDesc ( ) ? "desc" : null , options . getLimit ( ) < 1 ? null : new BigDecimal ( options . getLimit ( ) ) , options . isExact ( ) ? "exact" : null ) ; TargetsResponseData data = response . getData ( ) ; List < Target > targets = new ArrayList < > ( ) ; if ( data . getTargets ( ) != null ) { for ( com . genesys . internal . workspace . model . Target t : data . getTargets ( ) ) { Target target = Target . fromTarget ( t ) ; targets . add ( target ) ; } } return new SearchResult < > ( data . getTotalMatches ( ) , targets ) ; } catch ( ApiException e ) { throw new WorkspaceApiException ( "searchTargets failed." , e ) ; } }
Search for targets by the specified search term .
21,279
public Target getTarget ( long id , TargetType type ) throws WorkspaceApiException { try { TargetsResponse resp = targetsApi . getTarget ( new BigDecimal ( id ) , type . getValue ( ) ) ; Util . throwIfNotOk ( resp . getStatus ( ) ) ; Target target = null ; if ( resp . getData ( ) != null ) { List < com . genesys . internal . workspace . model . Target > targets = resp . getData ( ) . getTargets ( ) ; if ( targets != null && targets . size ( ) > 0 ) { target = Target . fromTarget ( targets . get ( 0 ) ) ; } } return target ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot get target" , ex ) ; } }
Get a specific target by type and ID . Targets can be agents agent groups queues route points skills and custom contacts .
21,280
public void deletePersonalFavorite ( Target target ) throws WorkspaceApiException { try { ApiSuccessResponse resp = targetsApi . deletePersonalFavorite ( String . valueOf ( target . getId ( ) ) , target . getType ( ) . getValue ( ) ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot delete personal favorite" , ex ) ; } }
Delete the target from the agent s personal favorites .
21,281
public SearchResult < Target > getPersonalFavorites ( int limit ) throws WorkspaceApiException { try { TargetsResponse resp = targetsApi . getPersonalFavorites ( limit > 0 ? new BigDecimal ( limit ) : null ) ; Util . throwIfNotOk ( resp . getStatus ( ) ) ; TargetsResponseData data = resp . getData ( ) ; int total = 0 ; List < Target > list = new ArrayList < > ( ) ; if ( data != null ) { total = data . getTotalMatches ( ) ; if ( data . getTargets ( ) != null ) { for ( com . genesys . internal . workspace . model . Target t : data . getTargets ( ) ) { Target target = Target . fromTarget ( t ) ; list . add ( target ) ; } } } return new SearchResult < > ( total , list ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot personal favorites" , ex ) ; } }
Get the agent s personal favorites .
21,282
public void savePersonalFavorite ( Target target , String category ) throws WorkspaceApiException { TargetspersonalfavoritessaveData data = new TargetspersonalfavoritessaveData ( ) ; data . setCategory ( category ) ; data . setTarget ( toInformation ( target ) ) ; PersonalFavoriteData favData = new PersonalFavoriteData ( ) ; favData . setData ( data ) ; try { ApiSuccessResponse resp = targetsApi . savePersonalFavorite ( favData ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot save personal favorites" , ex ) ; } }
Save a target to the agent s personal favorites in the specified category .
21,283
public void ackRecentMissedCalls ( ) throws WorkspaceApiException { try { ApiSuccessResponse resp = targetsApi . ackRecentMissedCalls ( ) ; Util . throwIfNotOk ( resp ) ; } catch ( ApiException ex ) { throw new WorkspaceApiException ( "Cannot ack recent missed calls" , ex ) ; } }
Acknowledge missed calls in the list of recent targets .
21,284
public ApiResponse < InlineResponse200 > getCallsWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = getCallsValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < InlineResponse200 > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; }
Get all calls Get all active calls for the current agent .
21,285
public ApiSuccessResponse switchToBargeIn ( String id , MonitoringScopeData monitoringScopeData ) throws ApiException { ApiResponse < ApiSuccessResponse > resp = switchToBargeInWithHttpInfo ( id , monitoringScopeData ) ; return resp . getData ( ) ; }
Switch to barge - in Switch to the barge - in monitoring mode . If the agent is currently on a call and T - Server is configured to allow barge - in the supervisor is immediately added to the call . Both the monitored agent and the customer are able to hear and speak with the supervisor . If the target agent is not on a call at the time of the request the supervisor is brought into the call when the agent receives a new call .
21,286
public ApiSuccessResponse switchToCoaching ( String id , MonitoringScopeData monitoringScopeData ) throws ApiException { ApiResponse < ApiSuccessResponse > resp = switchToCoachingWithHttpInfo ( id , monitoringScopeData ) ; return resp . getData ( ) ; }
Switch to coach Switch to the coach monitoring mode . When coaching is enabled and the agent receives a call the supervisor is brought into the call . Only the agent can hear the supervisor .
21,287
private List < DependencyError > checkAllowedSection ( final Dependencies dependencies , final Package < DependsOn > allowedPkg , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > it = classInfo . getImports ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final String importedPkg = it . next ( ) ; if ( ! importedPkg . equals ( allowedPkg . getName ( ) ) && ! dependencies . isAlwaysAllowed ( importedPkg ) ) { final DependsOn dep = Utils . findAllowedByName ( allowedPkg . getDependencies ( ) , importedPkg ) ; if ( dep == null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , allowedPkg . getComment ( ) ) ) ; } } } return errors ; }
Checks the dependencies for a package from the allowed section .
21,288
private static List < DependencyError > checkForbiddenSection ( final Dependencies dependencies , final Package < NotDependsOn > forbiddenPkg , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > it = classInfo . getImports ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final String importedPkg = it . next ( ) ; if ( ! importedPkg . equals ( classInfo . getPackageName ( ) ) ) { final NotDependsOn ndo = Utils . findForbiddenByName ( dependencies . getAlwaysForbidden ( ) , importedPkg ) ; if ( ndo != null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , ndo . getComment ( ) ) ) ; } else { final NotDependsOn dep = Utils . findForbiddenByName ( forbiddenPkg . getDependencies ( ) , importedPkg ) ; if ( dep != null ) { final String comment ; if ( dep . getComment ( ) == null ) { comment = forbiddenPkg . getComment ( ) ; } else { comment = dep . getComment ( ) ; } errors . add ( new DependencyError ( classInfo . getName ( ) , importedPkg , comment ) ) ; } } } } return errors ; }
Checks the dependencies for a package from the forbidden section .
21,289
private static String nameOnly ( final String filename ) { final int p = filename . lastIndexOf ( '.' ) ; if ( p == - 1 ) { return filename ; } return filename . substring ( 0 , p ) ; }
Returns the name of the file without path an extension .
21,290
private static List < DependencyError > checkAlwaysForbiddenSection ( final Dependencies dependencies , final ClassInfo classInfo ) { final List < DependencyError > errors = new ArrayList < DependencyError > ( ) ; final Iterator < String > importedPackages = classInfo . getImports ( ) . iterator ( ) ; while ( importedPackages . hasNext ( ) ) { final String importedPackage = importedPackages . next ( ) ; final NotDependsOn ndo = Utils . findForbiddenByName ( dependencies . getAlwaysForbidden ( ) , importedPackage ) ; if ( ndo != null ) { errors . add ( new DependencyError ( classInfo . getName ( ) , importedPackage , ndo . getComment ( ) ) ) ; } } return errors ; }
Checks if any of the imports is listed in the alwaysForbidden section .
21,291
public final void analyze ( final File classesDir ) { final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { public final FileHandlerResult handleFile ( final File classFile ) { if ( ! classFile . getName ( ) . endsWith ( ".class" ) ) { return FileHandlerResult . CONTINUE ; } try { final ClassInfo classInfo = new ClassInfo ( classFile ) ; final Package < DependsOn > allowedPkg = dependencies . findAllowedByName ( classInfo . getPackageName ( ) ) ; if ( allowedPkg == null ) { final Package < NotDependsOn > forbiddenPkg = dependencies . findForbiddenByName ( classInfo . getPackageName ( ) ) ; if ( forbiddenPkg == null ) { dependencyErrors . addAll ( checkAlwaysForbiddenSection ( dependencies , classInfo ) ) ; } else { dependencyErrors . addAll ( checkForbiddenSection ( dependencies , forbiddenPkg , classInfo ) ) ; } } else { dependencyErrors . addAll ( checkAllowedSection ( dependencies , allowedPkg , classInfo ) ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( "Error handling file: " + classFile , ex ) ; } return FileHandlerResult . CONTINUE ; } } ) ; dependencyErrors . clear ( ) ; fileProcessor . process ( classesDir ) ; }
Analyze the dependencies for all classes in the directory and it s sub directories .
21,292
static void analyzeDir ( final Set < Class < ? > > classes , final File baseDir , final File srcDir , final boolean recursive , final ClassFilter classFilter ) { final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { public final FileHandlerResult handleFile ( final File file ) { if ( file . isDirectory ( ) ) { if ( recursive ) { return FileHandlerResult . CONTINUE ; } return FileHandlerResult . SKIP_SUBDIRS ; } final String name = file . getName ( ) ; if ( name . endsWith ( ".java" ) && ! name . equals ( "package-info.java" ) ) { final String packageName = Utils4J . getRelativePath ( baseDir , file . getParentFile ( ) ) . replace ( File . separatorChar , '.' ) ; final String simpleName = name . substring ( 0 , name . length ( ) - 5 ) ; final String className = packageName + "." + simpleName ; final Class < ? > clasz = classForName ( className ) ; if ( isInclude ( clasz , classFilter ) ) { classes . add ( clasz ) ; } } return FileHandlerResult . CONTINUE ; } } ) ; fileProcessor . process ( srcDir ) ; }
Populates a list of classes from a given java source directory . All source files must have a . class file in the class path .
21,293
static EntityManager bind ( EntityManager entityManager ) { return entityManagerMap ( true ) . put ( entityManager . getEntityManagerFactory ( ) , entityManager ) ; }
Binds the given EntityManager to the current context for its EntityManagerFactory .
21,294
static EntityManager unbind ( EntityManagerFactory factory ) { final Map < EntityManagerFactory , EntityManager > entityManagerMap = entityManagerMap ( false ) ; EntityManager existing = null ; if ( entityManagerMap != null ) { existing = entityManagerMap . remove ( factory ) ; doCleanup ( ) ; } return existing ; }
Unbinds the EntityManager if any currently associated with the context for the given EntityManagerFactory .
21,295
static void unBindAll ( Consumer < EntityManager > function ) { final Map < EntityManagerFactory , EntityManager > entityManagerMap = entityManagerMap ( false ) ; if ( entityManagerMap != null ) { Iterator < EntityManager > iterator = entityManagerMap . values ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { EntityManager entityManager = iterator . next ( ) ; function . accept ( entityManager ) ; iterator . remove ( ) ; } doCleanup ( ) ; } }
Unbinds all EntityManagers regardless of EntityManagerFactory currently associated with the context .
21,296
EntityManager build ( EntityManagerContext entityManagerContext ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; return ( EntityManager ) Proxy . newProxyInstance ( classLoader , new Class [ ] { EntityManager . class } , new SharedEntityManagerInvocationHandler ( entityManagerContext ) ) ; }
Create an EntityManager proxy for the given EntityManagerContext .
21,297
public static boolean hasAnnotation ( final List < AnnotationInstance > annotations , final String annotationClaszName ) { final DotName annotationName = DotName . createSimple ( annotationClaszName ) ; for ( final AnnotationInstance annotation : annotations ) { if ( annotation . name ( ) . equals ( annotationName ) ) { return true ; } } return false ; }
Verifies if a list of annotations contains a given one .
21,298
public static List < MethodInfo > findOverrideMethods ( final Index index , final MethodInfo method ) { return findOverrideMethods ( index , method . declaringClass ( ) , method , 0 ) ; }
Returns a list of all methods the given one overrides . Such methods can be found in interfaces and super classes .
21,299
public static void setPrivateField ( final Object obj , final String name , final Object value ) { try { final Field field = obj . getClass ( ) . getDeclaredField ( name ) ; field . setAccessible ( true ) ; field . set ( obj , value ) ; } catch ( final Exception ex ) { throw new RuntimeException ( "Couldn't set field '" + name + "' in class '" + obj . getClass ( ) + "'" , ex ) ; } }
Sets a private field in an object by using reflection .