idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
21,100 | public void write ( ) { logger . info ( "writing " + users . size ( ) + " users in " + userfilename ) ; try { Backup . backup ( userfilename ) ; } catch ( IOException e ) { logger . error ( "Problem backing up old copy of user file" , e ) ; } try ( FileOutputStream fstream = new FileOutputStream ( userfilename ) ; BufferedOutputStream bstream = new BufferedOutputStream ( fstream ) ) { writeTheLines ( bstream ) ; } catch ( IOException e ) { logger . error ( "Problem writing user file" , e ) ; } } | Write the users file . |
21,101 | private void appendUserInfoFields ( final StringBuilder builder , final User user ) { append ( builder , user . getUsername ( ) , "," ) ; append ( builder , user . getFirstname ( ) , "," ) ; append ( builder , user . getLastname ( ) , "," ) ; append ( builder , user . getEmail ( ) , "," ) ; append ( builder , user . getPassword ( ) , "" ) ; } | Append the core fields of the user to the string . |
21,102 | private void append ( final StringBuilder builder , final String string , final String separator ) { if ( string != null ) { builder . append ( string ) ; } builder . append ( separator ) ; } | Append a token and separator to the builder . |
21,103 | private void appendRoles ( final StringBuilder builder , final User user ) { for ( final UserRoleName role : user . getRoles ( ) ) { append ( builder , "," , role . name ( ) ) ; } } | Append roles to the builder . |
21,104 | private RootDocument save ( final Root root ) { final RootDocumentMongo rootdoc = ( RootDocumentMongo ) toDocConverter . createGedDocument ( root ) ; try { repositoryManager . getRootDocumentRepository ( ) . save ( rootdoc ) ; } catch ( DataAccessException e ) { logger . error ( "Could not save root: " + root . getDbName ( ) , e ) ; return null ; } return rootdoc ; } | Save the root to the database . |
21,105 | public final void reloadAll ( ) { final List < String > list = new ArrayList < > ( ) ; for ( final RootDocument mongo : repositoryManager . getRootDocumentRepository ( ) . findAll ( ) ) { list . add ( mongo . getDbName ( ) ) ; } reset ( ) ; for ( final String dbname : list ) { loadDocument ( dbname ) ; } } | Reload all of the data sets . |
21,106 | public static Feature createBounds ( final String id ) { final Feature feature = new Feature ( ) ; feature . setId ( id ) ; feature . setGeometry ( new Polygon ( ) ) ; return feature ; } | Build a bounding box feature . In this case it has a name but is empty . |
21,107 | public static Feature createBounds ( final String id , final LngLatAlt southwest , final LngLatAlt northeast ) { final Feature feature = new Feature ( ) ; feature . setId ( id ) ; if ( northeast == null || southwest == null ) { throw new IllegalArgumentException ( "Must have a proper bounding box" ) ; } final double [ ] bbox = { southwest . getLongitude ( ) , southwest . getLatitude ( ) , northeast . getLongitude ( ) , northeast . getLatitude ( ) } ; final Polygon polygon = new Polygon ( ) ; feature . setGeometry ( polygon ) ; polygon . setBbox ( bbox ) ; final List < LngLatAlt > elements = new ArrayList < > ( 5 ) ; elements . add ( new LngLatAlt ( bbox [ SW_LNG ] , bbox [ SW_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ NE_LNG ] , bbox [ SW_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ NE_LNG ] , bbox [ NE_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ SW_LNG ] , bbox [ NE_LAT ] ) ) ; elements . add ( new LngLatAlt ( bbox [ SW_LNG ] , bbox [ SW_LAT ] ) ) ; polygon . add ( elements ) ; feature . setBbox ( bbox ) ; return feature ; } | Build a bounding box feature . |
21,108 | @ SuppressWarnings ( "unchecked" ) public final FindableDocument < ? extends GedObject , ? extends GedDocument < ? > > get ( final Class < ? extends GedObject > clazz ) { return ( FindableDocument < ? extends GedObject , ? extends GedDocument < ? > > ) classToRepoMap . get ( clazz ) ; } | Get a repository based on the class of ged object we are working with . |
21,109 | public void visit ( final Person person ) { visitedNameable = person ; for ( final GedObject gob : person . getAttributes ( ) ) { gob . accept ( this ) ; } } | Visit a Person . This is could be primary focus of the visitation . From here interesting information is gathered from the attributes . |
21,110 | public void visit ( final Submitter submitter ) { visitedNameable = submitter ; for ( final GedObject gob : submitter . getAttributes ( ) ) { gob . accept ( this ) ; } } | Visit a Submitter . This is could be primary focus of the visitation . From here interesting information is gathered from the attributes . |
21,111 | private Collection < PersonDocument > copy ( final Collection < PersonDocumentMongo > in ) { final List < PersonDocument > out = new ArrayList < > ( in ) ; Collections . sort ( out , new PersonDocumentComparator ( ) ) ; return out ; } | Correct the type of the collection . |
21,112 | public Person getChild ( ) { final Person toPerson = ( Person ) find ( getToString ( ) ) ; if ( toPerson == null ) { return new Person ( ) ; } return toPerson ; } | Get the person that this object points to . If not found return an unset Person object . |
21,113 | public static final String escapeString ( final String delimiter , final String input ) { final String escaped = escapeString ( input ) ; if ( escaped . isEmpty ( ) ) { return escaped ; } return delimiter + escaped ; } | Convert the string for use in HTML or URLs . |
21,114 | private String findCharsetInHeader ( final GedObject gob ) { for ( final GedObject hgob : gob . getAttributes ( ) ) { if ( "Character Set" . equals ( hgob . getString ( ) ) ) { return ( ( Attribute ) hgob ) . getTail ( ) ; } } return "UTF-8" ; } | Find the GEDCOM charset in the attributes of the header . |
21,115 | private static Family findFamily ( final Child child ) { if ( ! child . isSet ( ) ) { return new Family ( ) ; } final Family foundFamily = ( Family ) child . find ( child . getFromString ( ) ) ; if ( foundFamily == null ) { return new Family ( ) ; } return foundFamily ; } | Get the family for this child to build the navigator with . |
21,116 | private static Family findFamily ( final FamC famc ) { if ( ! famc . isSet ( ) ) { return new Family ( ) ; } final Family foundFamily = ( Family ) famc . find ( famc . getToString ( ) ) ; if ( foundFamily == null ) { return new Family ( ) ; } return foundFamily ; } | Get the family for this famc to build the navigator with . |
21,117 | private static Family findFamily ( final FamS fams ) { if ( ! fams . isSet ( ) ) { return new Family ( ) ; } final Family foundFamily = ( Family ) fams . find ( fams . getToString ( ) ) ; if ( foundFamily == null ) { return new Family ( ) ; } return foundFamily ; } | Get the family for this fams to build the navigator with . |
21,118 | public Person getSpouse ( final GedObject person ) { final List < Person > spouses = visitor . getSpouses ( ) ; if ( person != null && ! spouses . contains ( person ) ) { return new Person ( ) ; } for ( final Person spouse : spouses ) { if ( ! spouse . equals ( person ) ) { return spouse ; } } return new Person ( ) ; } | Get the person in this family who is the spouse of the person passed in . |
21,119 | protected final LocalDate createLocalDate ( final Attribute attribute ) { final GetDateVisitor visitor = new GetDateVisitor ( ) ; attribute . accept ( visitor ) ; return createLocalDate ( visitor . getDate ( ) ) ; } | Create a local date from the attribute s date . |
21,120 | public static LocalDate minDate ( final LocalDate date0 , final LocalDate date1 ) { if ( date1 == null ) { return date0 ; } if ( date0 == null ) { return date1 ; } if ( date1 . isBefore ( date0 ) ) { return date1 ; } else { return date0 ; } } | Return the earlier of the 2 dates . If either is null return the other . |
21,121 | private void initLevel0FactoryTokens ( ) { put ( "ROOT" , "Root" , AbstractGedObjectFactory . ROOT_FACTORY ) ; put ( "HEAD" , "Header" , AbstractGedObjectFactory . HEAD_FACTORY ) ; put ( "FAM" , "Family" , AbstractGedObjectFactory . FAMILY_FACTORY ) ; put ( "INDI" , "Person" , AbstractGedObjectFactory . PERSON_FACTORY ) ; put ( "NOTE" , "Note" , AbstractGedObjectFactory . NOTE_FACTORY ) ; put ( "OBJE" , "Multimedia" , AbstractGedObjectFactory . MULTIMEDIA_FACTORY ) ; put ( "SOUR" , "Source" , AbstractGedObjectFactory . SOURCE_FACTORY ) ; put ( "SUBM" , "Submitter" , AbstractGedObjectFactory . SUBMITTER_FACTORY ) ; put ( "SUBN" , "Submission" , AbstractGedObjectFactory . SUBMISSION_FACTORY ) ; put ( "TRLR" , "Trailer" , AbstractGedObjectFactory . TRAILER_FACTORY ) ; } | Method to initialize the tokens for top level items . |
21,122 | private void initSpecialFactoryTokens ( ) { put ( "CHIL" , "Child" , AbstractGedObjectFactory . CHILD_FACTORY ) ; put ( "CONC" , "Concatenate" , AbstractGedObjectFactory . CONCAT_FACTORY ) ; put ( "CONT" , "Continuation" , AbstractGedObjectFactory . CONTIN_FACTORY ) ; put ( "DATE" , "Date" , AbstractGedObjectFactory . DATE_FACTORY ) ; put ( "FAMC" , "Child of Family" , AbstractGedObjectFactory . FAMC_FACTORY ) ; put ( "FAMS" , "Spouse of Family" , AbstractGedObjectFactory . FAMS_FACTORY ) ; put ( "HUSB" , "Husband" , AbstractGedObjectFactory . HUSBAND_FACTORY ) ; put ( "LINK" , "Link" , AbstractGedObjectFactory . LINK_FACTORY ) ; put ( "NAME" , "Name" , AbstractGedObjectFactory . NAME_FACTORY ) ; put ( "PLAC" , "Place" , AbstractGedObjectFactory . PLACE_FACTORY ) ; put ( "PLACE" , "Place" , AbstractGedObjectFactory . PLACE_FACTORY ) ; put ( "WIFE" , "Wife" , AbstractGedObjectFactory . WIFE_FACTORY ) ; } | Method to initialize the tokens that use something other than the attribute factory . |
21,123 | private void analyzeFamily ( final Family family ) { Person prevChild = null ; final FamilyNavigator navigator = new FamilyNavigator ( family ) ; for ( final Person child : navigator . getChildren ( ) ) { prevChild = analyzeChild ( child , prevChild ) ; } } | Analyze the order of children in one family . |
21,124 | private Person analyzeChild ( final Person child , final Person prevChild ) { Person retChild = prevChild ; if ( retChild == null ) { return child ; } final LocalDate birthDate = getNearBirthEventDate ( child ) ; if ( birthDate == null ) { return retChild ; } final LocalDate prevDate = getNearBirthEventDate ( prevChild ) ; if ( prevDate == null ) { return child ; } if ( birthDate . isBefore ( prevDate ) ) { final String message = String . format ( CHILD_ORDER_FORMAT , child . getName ( ) . getString ( ) , birthDate , prevChild . getName ( ) . getString ( ) , prevDate ) ; getResult ( ) . addMismatch ( message ) ; } retChild = child ; return retChild ; } | Check the order of one child against the previous dated child . |
21,125 | private String getNameHtml ( final Submitter submitter ) { final GedRenderer < ? extends GedObject > renderer = new SimpleNameRenderer ( submitter . getName ( ) , submitterRenderer . getRendererFactory ( ) , submitterRenderer . getRenderingContext ( ) ) ; return renderer . getNameHtml ( ) ; } | Handle the messy getting of the name ready for HTML formatting . |
21,126 | public void visit ( final Attribute attribute ) { if ( "Title" . equals ( attribute . getString ( ) ) ) { titleString = attribute . getTail ( ) ; } } | Visit an Attribute . Specific Attributes provide interesting data for the Source that is the primary focus . |
21,127 | public void visit ( final Source source ) { titleString = source . getString ( ) ; for ( final GedObject gob : source . getAttributes ( ) ) { gob . accept ( this ) ; } } | Visit a Source . This is the primary focus of the visitation . From here interesting information is gathered . |
21,128 | private Feature getLocation ( ) { if ( geometry == null ) { return null ; } final List < Feature > features = geometry . getFeatures ( ) ; if ( features == null || features . isEmpty ( ) ) { return null ; } return features . get ( 0 ) ; } | Return the location . It is in the form of a GeoJSON feature . Much of the descriptive data from Google is in the properties of that feature . |
21,129 | public static void backup ( final String filename ) throws IOException { final File dest = createFile ( filename ) ; if ( dest . exists ( ) ) { final File backupFile = generateBackupFilename ( filename ) ; LOGGER . debug ( "backing up file from " + filename + " to " + backupFile . getName ( ) ) ; if ( ! dest . renameTo ( backupFile ) ) { throw new IOException ( "Could not rename file from " + dest . getName ( ) + " to " + backupFile . getName ( ) ) ; } } } | Save the existing version of the file by renaming it to something ending with . < ; number> ; . |
21,130 | private LocalDate parentDateIncrement ( final LocalDate date ) { final int years = typicals . ageAtMarriage ( ) + typicals . gapBetweenChildren ( ) ; return plusYearsAdjustToBegin ( date , years ) ; } | Adjust the given date by age of parent at first child . |
21,131 | public void write ( ) { root . accept ( visitor ) ; try { Backup . backup ( root . getFilename ( ) ) ; } catch ( IOException e ) { logger . error ( "Problem backing up old copy of GEDCOM file" , e ) ; } final String filename = root . getFilename ( ) ; final String charset = new CharsetScanner ( ) . charset ( root ) ; try ( FileOutputStream fstream = new FileOutputStream ( filename ) ; BufferedOutputStream bstream = new BufferedOutputStream ( fstream ) ) { writeTheLines ( bstream , charset ) ; } catch ( IOException e ) { logger . error ( "Problem writing GEDCOM file" , e ) ; } } | Write the file as directed . |
21,132 | public static AbstractGedLine createGedLine ( final AbstractGedLine parent , final String inLine ) { GedLineSource sour ; if ( parent == null ) { sour = new NullSource ( ) ; } else { sour = parent . source ; } return sour . createGedLine ( parent , inLine ) ; } | Create a GedLine from the provided string . |
21,133 | public final AbstractGedLine readToNext ( ) throws IOException { AbstractGedLine gedLine = source . createGedLine ( this ) ; while ( true ) { if ( gedLine == null || gedLine . getLevel ( ) == - 1 ) { break ; } if ( gedLine . getLevel ( ) <= this . getLevel ( ) ) { return gedLine ; } children . add ( gedLine ) ; gedLine = gedLine . readToNext ( ) ; } return null ; } | Read the source data until the a line is encountered at the same level as this one . That allows the reading of children . |
21,134 | public Family createFamily ( final String idString ) { if ( idString == null ) { return new Family ( ) ; } final Family family = new Family ( getRoot ( ) , new ObjectId ( idString ) ) ; getRoot ( ) . insert ( family ) ; return family ; } | Encapsulate creating family with the given ID . |
21,135 | public Attribute createFamilyEvent ( final Family family , final String type , final String dateString ) { if ( family == null || type == null || dateString == null ) { return gedObjectBuilder . createAttribute ( ) ; } final Attribute event = gedObjectBuilder . createAttribute ( family , type ) ; event . insert ( new Date ( event , dateString ) ) ; return event ; } | Create a dated event . |
21,136 | public Attribute createFamilyEvent ( final Family family , final String type ) { return gedObjectBuilder . createAttribute ( family , type ) ; } | Create an undated event . |
21,137 | public Wife addWifeToFamily ( final Family family , final Person person ) { if ( family == null || person == null ) { return new Wife ( ) ; } final FamS famS = new FamS ( person , "FAMS" , new ObjectId ( family . getString ( ) ) ) ; final Wife wife = new Wife ( family , "Wife" , new ObjectId ( person . getString ( ) ) ) ; family . insert ( wife ) ; person . insert ( famS ) ; return wife ; } | Add a person as the wife in a family . |
21,138 | public Child addChildToFamily ( final Family family , final Person person ) { if ( family == null || person == null ) { return new Child ( ) ; } final FamC famC = new FamC ( person , "FAMC" , new ObjectId ( family . getString ( ) ) ) ; final Child child = new Child ( family , "Child" , new ObjectId ( person . getString ( ) ) ) ; family . insert ( child ) ; person . insert ( famC ) ; return child ; } | Add a person as a child in a family . |
21,139 | public Trailer createTrailer ( ) { final Trailer trailer = new Trailer ( getRoot ( ) , "Trailer" ) ; getRoot ( ) . insert ( trailer ) ; return trailer ; } | Create a trailer for the data set . |
21,140 | public Head createHead ( ) { final Head head = new Head ( getRoot ( ) , "Head" ) ; getRoot ( ) . insert ( head ) ; return head ; } | Create a head for the data set . |
21,141 | public SubmissionLink createSubmissionLink ( final Submission submission ) { Head head = getRoot ( ) . find ( "Head" , Head . class ) ; if ( head == null ) { head = createHead ( ) ; } final SubmissionLink submissionLink = new SubmissionLink ( head , "Submission" , new ObjectId ( submission . getString ( ) ) ) ; head . insert ( submissionLink ) ; return submissionLink ; } | Create a link to the submission in the head . If head doesn t already exist create it . |
21,142 | protected void addAttributes ( final GedDocument < ? > document ) { for ( final GedDocument < ? extends GedObject > attribute : document . getAttributes ( ) ) { final DocumentToApiModelVisitor v = createVisitor ( ) ; attribute . accept ( v ) ; baseObject . getAttributes ( ) . add ( convertToAttribute ( v . getBaseObject ( ) ) ) ; } } | Recurse into the child documents converting and adding to the list . |
21,143 | protected void addSplitAttributes ( final GedDocument < ? > document ) { for ( final GedDocument < ? extends GedObject > attribute : document . getAttributes ( ) ) { final DocumentToApiModelVisitor v = createVisitor ( ) ; attribute . accept ( v ) ; ( ( ApiHasImages ) baseObject ) . addAttribute ( convertToAttribute ( v . getBaseObject ( ) ) ) ; } } | Recurse into the child documents converting and adding to the list . Several document types require special processing because they have split lists . |
21,144 | protected final boolean ignoreable ( final Attribute event ) { if ( "Sex" . equals ( event . getString ( ) ) ) { return true ; } if ( "Changed" . equals ( event . getString ( ) ) ) { return true ; } if ( "Ancestral File Number" . equals ( event . getString ( ) ) ) { return true ; } if ( "Title" . equals ( event . getString ( ) ) ) { return true ; } if ( "Attribute" . equals ( event . getString ( ) ) ) { final GetDateVisitor visitor = new GetDateVisitor ( ) ; event . accept ( visitor ) ; return "" . equals ( visitor . getDate ( ) ) ; } if ( "Note" . equals ( event . getString ( ) ) ) { final GetDateVisitor visitor = new GetDateVisitor ( ) ; event . accept ( visitor ) ; return "" . equals ( visitor . getDate ( ) ) ; } return "Reference Number" . equals ( event . getString ( ) ) ; } | Certain events have no time basis on the person . |
21,145 | public void visit ( final Attribute attribute ) { final String string = attribute . getString ( ) ; if ( "File" . equals ( string ) ) { filePath = attribute . getTail ( ) ; for ( final GedObject subObject : attribute . getAttributes ( ) ) { subObject . accept ( this ) ; } } if ( "Format" . equals ( string ) ) { format = attribute . getTail ( ) ; } if ( "Title" . equals ( string ) ) { title = attribute . getTail ( ) ; } } | Visit an Attribute . The values of specific attributes are gathered for later use . |
21,146 | public void visit ( final Multimedia multimedia ) { for ( final GedObject gedObject : multimedia . getAttributes ( ) ) { gedObject . accept ( this ) ; } } | Visit a Multimedia . This is the primary focus of the visitation . From here interesting information is gathered from the attributes . |
21,147 | private String validateFile ( final MultipartFile file ) { final String filename = StringUtils . cleanPath ( file . getOriginalFilename ( ) ) ; if ( file . isEmpty ( ) ) { throw new StorageException ( "Failed to store empty file " + filename ) ; } if ( filename . contains ( ".." ) ) { throw new StorageException ( "Cannot store file with relative path outside current" + " directory " + filename ) ; } return filename ; } | Extract the filename and validate it . |
21,148 | private int compareChunks ( final String thisChunk , final String thatChunk ) { final int thisChunkLength = thisChunk . length ( ) ; for ( int i = 0 ; i < thisChunkLength ; i ++ ) { final int result = thisChunk . charAt ( i ) - thatChunk . charAt ( i ) ; if ( result != 0 ) { return result ; } } return 0 ; } | Compare two chunks based on assumed same length . 0 if the same . |
21,149 | private HttpSecurity handleCsrf ( final HttpSecurity http ) throws Exception { if ( "test" . equals ( activeProfile ) ) { return http . csrf ( ) . disable ( ) ; } else { return http . csrf ( ) . ignoringAntMatchers ( "/gedbrowserng/v1/login" , "/gedbrowserng/v1/signup" ) . csrfTokenRepository ( CookieCsrfTokenRepository . withHttpOnlyFalse ( ) ) . and ( ) ; } } | Work from the http security object and enable or disable CSRF handling as requested in the application properties . |
21,150 | private void addByType ( final ApiAttribute apiParent , final String string ) { for ( final ApiAttribute object : apiParent . getAttributes ( ) ) { if ( object . isType ( string ) ) { final ApiModelToGedObjectVisitor visitor = createVisitor ( ) ; object . accept ( visitor ) ; } } } | Add the attributes if they match the given type . |
21,151 | private void addIfNotTypes ( final ApiAttribute apiParent , final String ... types ) { for ( final ApiAttribute object : apiParent . getAttributes ( ) ) { if ( ! matchOne ( object , types ) ) { final ApiModelToGedObjectVisitor visitor = createVisitor ( ) ; object . accept ( visitor ) ; } } } | Add the attributes that don t match any of the selected types . |
21,152 | private void addToAttributes ( final List < ApiAttribute > attributes ) { for ( final ApiObject object : attributes ) { final ApiModelToGedObjectVisitor visitor = createVisitor ( ) ; object . accept ( visitor ) ; } } | Add to the attributes of the parent for saving . |
21,153 | private Calendar getSortCalendar ( ) { if ( sortDate == null ) { final DateParser parser = new DateParser ( getDate ( ) ) ; sortDate = parser . getSortCalendar ( ) ; } return sortDate ; } | Return the sortable date in the form of a Calendar . |
21,154 | public String getEstimateDate ( ) { final DateParser parser = new DateParser ( getDate ( ) ) ; if ( estimateDate == null ) { estimateDate = parser . getEstimateCalendar ( ) ; } final SimpleDateFormat formatter = new SimpleDateFormat ( "yyyyMMdd" , Locale . US ) ; return format ( formatter , estimateDate ) ; } | Like sort date only we are starting in on correcting the problems with approximations . |
21,155 | public final GedObject create ( final GedObject parent , final String xref , final String tag , final String tail ) { return getFactory ( tag ) . create ( parent , new ObjectId ( xref ) , fullstring ( tag ) , tail ) ; } | Factory method creates the appropriate GedObject from the provided strings . |
21,156 | private GedToken getToken ( final String tag ) { GedToken gedToken = tokens . get ( tag ) ; if ( gedToken == null ) { gedToken = new GedToken ( tag , ATTR_FACTORY ) ; } return gedToken ; } | Find the token processor for this tag . Defaults to attribute . |
21,157 | public final String fullstring ( final String tag ) { String fullstring = getToken ( tag ) . getFullString ( ) ; if ( fullstring == null ) { fullstring = tag ; } return fullstring ; } | Get the full string for this tag . If not found return the tag . |
21,158 | public LocalDate estimateFromSiblings ( final LocalDate localDate ) { if ( localDate != null ) { return localDate ; } boolean beforePerson = true ; LocalDate date = null ; int increment = typicals . gapBetweenChildren ( ) ; final PersonNavigator navigator = new PersonNavigator ( person ) ; final List < Family > families = navigator . getFamiliesC ( ) ; for ( final Family family : families ) { for ( final Person sibling : getChildren ( family ) ) { if ( person . equals ( sibling ) ) { beforePerson = false ; if ( date != null ) { break ; } increment = 0 ; continue ; } final String siblingString = getBirthDate ( sibling ) ; if ( ! validDateString ( siblingString ) ) { increment = incrementWhenEmptyDate ( beforePerson , increment ) ; continue ; } date = createLocalDate ( siblingString ) ; increment = incrementWhenDate ( beforePerson , increment ) ; if ( ! beforePerson ) { break ; } } } if ( date != null ) { date = firstDayOfMonth ( plusYears ( date , increment ) ) ; } return date ; } | Try estimating from sibling dates . Null if no siblings or siblings also don t have dates . |
21,159 | public Calendar getEstimateCalendar ( ) { final String dateString = stripApproximationKeywords ( ) ; if ( dateString . isEmpty ( ) ) { return null ; } return applyEstimationRules ( dateString ) ; } | Returns a sortable version of this date with estimation rules applied . |
21,160 | public Calendar getSortCalendar ( ) { final String dateString = stripApproximationKeywords ( ) ; if ( dateString . isEmpty ( ) ) { return null ; } return parseCalendar ( dateString ) ; } | Returns the sort version of the date . Does not have estimation rules applied . |
21,161 | private boolean startsWithIgnoreCase ( final String dateString , final String startString ) { final String prefix = dateString . substring ( 0 , startString . length ( ) ) ; return prefix . equalsIgnoreCase ( startString ) ; } | Does startsWith but ignoring the case . |
21,162 | private String handleFTMBizzareDateFormat ( final String dateString ) { approximation = DateParser . Approximation . BETWEEN ; String string = stripPrefix ( dateString , "(" ) . trim ( ) ; string = stripSuffix ( string , ")" ) . trim ( ) ; if ( "BIC" . equals ( string ) ) { return "" ; } if ( startsWithIgnoreCase ( string , ABT ) ) { string = stripPrefix ( string , ABT ) . trim ( ) ; approximation = DateParser . Approximation . ABOUT ; } if ( startsWithIgnoreCase ( string , AFT ) ) { string = stripPrefix ( string , AFT ) . trim ( ) ; approximation = DateParser . Approximation . AFTER ; } if ( startsWithIgnoreCase ( string , BEF ) ) { string = stripPrefix ( string , BEF ) . trim ( ) ; approximation = DateParser . Approximation . BEFORE ; } if ( startsWithIgnoreCase ( string , FROM ) ) { string = stripPrefix ( string , FROM ) . trim ( ) ; } string = truncateAt ( string , "-" ) ; string = truncateAt ( string , " TO " ) ; if ( string . length ( ) <= 2 ) { string = stripPrefix ( dateString , "(" ) . trim ( ) ; string = stripSuffix ( string , ")" ) . trim ( ) ; string = removeBeginningAt ( string , "-" ) ; string = removeBeginningAt ( string , " TO " ) ; } return string ; } | Handle some odd dates from family tree maker . |
21,163 | private String handleBetween ( final String input ) { final String outString = input . replace ( "BETWEEN " , "" ) . replace ( "BET " , "" ) . replace ( "FROM " , "" ) ; return truncateAt ( truncateAt ( outString , " AND " ) , " TO " ) . trim ( ) ; } | Process between syntax . Just leave the beginning date . |
21,164 | private String truncateAt ( final String input , final String searchString ) { final int i = input . indexOf ( searchString ) ; if ( i != - 1 ) { return input . substring ( 0 , i ) ; } return input ; } | Truncate the input string after the first occurrence of the searchString . |
21,165 | private String removeBeginningAt ( final String input , final String searchString ) { final int i = input . indexOf ( searchString ) ; if ( i != - 1 ) { return input . substring ( i + 1 , input . length ( ) ) ; } return input ; } | Lop off the beginning of the string up through the searchString . |
21,166 | public Cookie getCookieValueByName ( final HttpServletRequest request , final String name ) { if ( request . getCookies ( ) == null ) { return null ; } for ( int i = 0 ; i < request . getCookies ( ) . length ; i ++ ) { if ( request . getCookies ( ) [ i ] . getName ( ) . equals ( name ) ) { return request . getCookies ( ) [ i ] ; } } return null ; } | Find a specific HTTP cookie in a request . |
21,167 | private void setHeaders ( final HttpServletResponse response , final Root root ) { response . setHeader ( "content-type" , "application/octet-stream" ) ; response . setHeader ( "content-disposition" , "attachment; filename=" + getSaveFilename ( root ) ) ; } | Fill in response headers to make this save the file instead of displaying it . |
21,168 | private void logPlaces ( final List < PlaceInfo > places ) { if ( logger . isDebugEnabled ( ) ) { for ( final PlaceInfo place : places ) { this . logger . debug ( place ) ; } } } | Dump the places to debug log . |
21,169 | @ GetMapping ( value = "/v1/dbs" ) public List < String > dbs ( ) { logger . info ( "Gettting list of DBs" ) ; final List < String > list = new ArrayList < > ( ) ; for ( final RootDocument mongo : repositoryManager . getRootDocumentRepository ( ) . findAll ( ) ) { list . add ( mongo . getDbName ( ) ) ; } logger . info ( "length: " + list . size ( ) ) ; return list ; } | Controller to get the currently loaded data sets . |
21,170 | private String wrap ( final String before , final String string , final String after ) { if ( string . isEmpty ( ) ) { return "" ; } return before + string + after ; } | If the middle string has contents append the strings . |
21,171 | public static RenderingContext anonymous ( final ApplicationInfo appInfo , final CalendarProvider provider ) { final UserImpl user2 = new UserImpl ( ) ; user2 . setUsername ( "Anonymous" ) ; user2 . setFirstname ( "Al" ) ; user2 . setLastname ( "Anonymous" ) ; user2 . clearRoles ( ) ; user2 . setEmail ( "anon@gmail.com" ) ; return new RenderingContext ( user2 , appInfo , provider ) ; } | Special case anonymous context . |
21,172 | private String nameHtml ( final RenderingContext context , final Person person ) { return nameRenderer ( context , person ) . getNameHtml ( ) ; } | Get the name string in an html fragment format . |
21,173 | public List < Family > getFamilies ( ) { final List < Family > families = new ArrayList < > ( ) ; for ( final FamilyNavigator nav : familySNavigators ) { families . add ( nav . getFamily ( ) ) ; } return families ; } | Get the families that the person is a spouse of . |
21,174 | public Person getFather ( ) { if ( familyCNavigators == null || familyCNavigators . isEmpty ( ) ) { return new Person ( ) ; } return familyCNavigators . get ( 0 ) . getFather ( ) ; } | Find the father of this person . If not found return an unset Person . |
21,175 | public Person getMother ( ) { if ( familyCNavigators == null || familyCNavigators . isEmpty ( ) ) { return new Person ( ) ; } return familyCNavigators . get ( 0 ) . getMother ( ) ; } | Find the mother of this person . If not found return an unset Person . |
21,176 | public List < Person > getChildren ( ) { final List < Person > children = new ArrayList < > ( ) ; for ( final FamilyNavigator nav : familySNavigators ) { children . addAll ( nav . getChildren ( ) ) ; } return children ; } | Get the list of all of children of this person . |
21,177 | public List < Person > getSpouses ( ) { final List < Person > spouses = new ArrayList < > ( ) ; for ( final FamilyNavigator nav : familySNavigators ) { final Person spouse = nav . getSpouse ( visitedPerson ) ; if ( spouse . isSet ( ) ) { spouses . add ( spouse ) ; } } return spouses ; } | Get the list of all of the spouses of this person . |
21,178 | public void visit ( final FamS fams ) { final FamilyNavigator navigator = new FamilyNavigator ( fams ) ; final Family family = navigator . getFamily ( ) ; if ( family . isSet ( ) ) { familySNavigators . add ( navigator ) ; } } | Visit a FamS . We will build up a collection of Navigators to the FamSs . |
21,179 | @ RequestMapping ( method = GET , value = "/foo" ) public Map < String , String > getFoo ( ) { final Map < String , String > fooObj = new HashMap < > ( ) ; fooObj . put ( "foo" , "bar" ) ; return fooObj ; } | Controller to just support pinging . |
21,180 | public void visit ( final Date date ) { dateString = date . getDate ( ) ; yearString = date . getYear ( ) ; sortDateString = date . getSortDate ( ) ; final GetTimeVisitor timeVisitor = new GetTimeVisitor ( ) ; for ( final GedObject gob : date . getAttributes ( ) ) { gob . accept ( timeVisitor ) ; if ( ! timeVisitor . getTimeString ( ) . isEmpty ( ) ) { dateString += " " + timeVisitor . getTimeString ( ) ; break ; } } } | Visit a Date . Record the interesting information from that date . |
21,181 | public void visit ( final Person person ) { for ( final GedObject gob : person . getAttributes ( ) ) { gob . accept ( this ) ; if ( ! dateString . isEmpty ( ) ) { break ; } } } | Visit a Person . This is the primary focus of the visitation . From here interesting information is gathered from the attributes . Once a date string is found quit . |
21,182 | private Map < String , Set < PersonRenderer > > createWholeIndex ( ) { logger . info ( "In getWholeIndex" ) ; final Map < String , Set < PersonRenderer > > aMap = new TreeMap < > ( ) ; if ( ! getRenderingContext ( ) . isUser ( ) ) { logger . info ( "Leaving getWholeIndex not logged in" ) ; return aMap ; } final Collection < Person > persons = getGedObject ( ) . find ( Person . class ) ; for ( final Person person : persons ) { if ( isHidden ( person ) ) { continue ; } locatePerson ( aMap , person ) ; } logger . info ( "Leaving getWholeIndex" ) ; return aMap ; } | Build the index . |
21,183 | private void locatePerson ( final Map < String , Set < PersonRenderer > > aMap , final Person person ) { final PersonRenderer renderer = new PersonRenderer ( person , getRendererFactory ( ) , getRenderingContext ( ) ) ; for ( final String place : getPlaces ( person ) ) { placePerson ( aMap , renderer , place ) ; } } | Add a person s locations to the map . |
21,184 | private void placePerson ( final Map < String , Set < PersonRenderer > > aMap , final PersonRenderer renderer , final String place ) { final Set < PersonRenderer > locatedPersons = personRendererSet ( aMap , place ) ; locatedPersons . add ( renderer ) ; } | Add a person to a particular location in the map . |
21,185 | public static void main ( final String [ ] args ) throws InterruptedException { SpringApplication . run ( Application . class , args ) ; Thread . sleep ( TWENTY_SECONDS ) ; } | Allow us to run gedbrowser as a standalone application with an embedded application server . |
21,186 | protected final void beginOfMonth ( final Calendar c ) { c . set ( Calendar . DAY_OF_MONTH , c . getActualMinimum ( Calendar . DAY_OF_MONTH ) ) ; } | Adjust calendar to the beginning of the current month . |
21,187 | protected final void endOfMonth ( final Calendar c ) { c . set ( Calendar . DAY_OF_MONTH , c . getActualMaximum ( Calendar . DAY_OF_MONTH ) ) ; } | Adjust calendar to the end of the current month . |
21,188 | protected final void firstMonth ( final Calendar c ) { c . set ( Calendar . MONTH , c . getMinimum ( Calendar . MONTH ) ) ; } | Adjust calendar to the first month of the year . |
21,189 | protected final void lastMonth ( final Calendar c ) { c . set ( Calendar . MONTH , c . getMaximum ( Calendar . MONTH ) ) ; } | Adjust calendar to the last month of the year . |
21,190 | protected final List < Person > getChildren ( final Family family ) { final FamilyNavigator navigator = new FamilyNavigator ( family ) ; return navigator . getChildren ( ) ; } | Get the list of children from a family . |
21,191 | protected final Person getFather ( final Family family ) { final FamilyNavigator navigator = new FamilyNavigator ( family ) ; return navigator . getFather ( ) ; } | Get the father from a family . |
21,192 | protected final Person getMother ( final Family family ) { final FamilyNavigator navigator = new FamilyNavigator ( family ) ; return navigator . getMother ( ) ; } | Get the mother from a family . |
21,193 | protected final String getBirthDate ( final Person person ) { final GetDateVisitor visitor = new GetDateVisitor ( "Birth" ) ; person . accept ( visitor ) ; return visitor . getDate ( ) ; } | Get the birth date string of a person . |
21,194 | protected final String getDate ( final Attribute attr ) { final GetDateVisitor visitor = new GetDateVisitor ( ) ; attr . accept ( visitor ) ; return visitor . getDate ( ) ; } | Get the date string for an attribute . |
21,195 | protected final LocalDate plusYearsAdjustToBegin ( final LocalDate date , final int years ) { final LocalDate adjustedYears = plusYears ( date , years ) ; final LocalDate firstMonth = firstMonth ( adjustedYears ) ; return firstDayOfMonth ( firstMonth ) ; } | Add years to the date and then adjust to the beginning of the resultant year . |
21,196 | protected final LocalDate minusYearsAdjustToBegin ( final LocalDate date , final int years ) { final LocalDate adjustedYears = minusYears ( date , years ) ; final LocalDate firstMonth = firstMonth ( adjustedYears ) ; return firstDayOfMonth ( firstMonth ) ; } | Subtract years from the date and then adjust to the beginning of the resultant year . |
21,197 | protected final LocalDate createLocalDate ( final String dateString ) { if ( dateString == null || dateString . isEmpty ( ) ) { return null ; } final DateParser parser = new DateParser ( dateString ) ; return new LocalDate ( parser . getEstimateCalendar ( ) ) ; } | Create a LocalDate from the given date string . Returns null for an empty or null date string . |
21,198 | public final void change ( ) { final ApiAttribute chanAttr = new ApiAttribute ( "attribute" , "Changed" ) ; chanAttr . getAttributes ( ) . add ( new DateUtil ( ) . todayDateAttribute ( ) ) ; final ArrayList < ApiAttribute > chanList = new ArrayList < > ( ) ; chanList . add ( chanAttr ) ; this . changed . clear ( ) ; this . changed . addAll ( chanList ) ; } | Mark the person as changed today . |
21,199 | public void changePassword ( final String oldPassword , final String newPassword ) { final Authentication currentUser = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; final String username = currentUser . getName ( ) ; if ( authenticationManager == null ) { logger . debug ( "No authentication manager set. can't change Password!" ) ; return ; } else { logger . debug ( "Re-authenticating user '" + username + "' for password change request." ) ; authenticationManager . authenticate ( new UsernamePasswordAuthenticationToken ( username , oldPassword ) ) ; } logger . debug ( "Changing password for user '" + username + "'" ) ; final SecurityUser user = ( SecurityUser ) loadUserByUsername ( username ) ; user . setPassword ( passwordEncoder . encode ( newPassword ) ) ; users . add ( user ) ; } | Change password of current user . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.