idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
21,100
public Attribute createFamilyEvent ( final Family family , final String type ) { return gedObjectBuilder . createAttribute ( family , type ) ; }
Create an undated event .
31
6
21,101
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 .
111
10
21,102
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 .
110
10
21,103
public Trailer createTrailer ( ) { final Trailer trailer = new Trailer ( getRoot ( ) , "Trailer" ) ; getRoot ( ) . insert ( trailer ) ; return trailer ; }
Create a trailer for the data set .
40
8
21,104
public Head createHead ( ) { final Head head = new Head ( getRoot ( ) , "Head" ) ; getRoot ( ) . insert ( head ) ; return head ; }
Create a head for the data set .
38
8
21,105
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 .
90
19
21,106
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 .
87
13
21,107
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 .
92
25
21,108
protected final boolean ignoreable ( final Attribute event ) { // Layed out like this because it is easier to understand // coverage. No performance differences expected compared // to tighter layout. 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 ( ) ) ) { // Only care about random attributes if they are dated final GetDateVisitor visitor = new GetDateVisitor ( ) ; event . accept ( visitor ) ; return "" . equals ( visitor . getDate ( ) ) ; } if ( "Note" . equals ( event . getString ( ) ) ) { // Only care about notes if they are dated 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 .
267
10
21,109
@ Override 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 .
121
16
21,110
@ Override 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 .
42
24
21,111
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 ( ".." ) ) { // This is a security check throw new StorageException ( "Cannot store file with relative path outside current" + " directory " + filename ) ; } return filename ; }
Extract the filename and validate it .
108
8
21,112
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 .
92
14
21,113
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 .
114
20
21,114
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 .
74
10
21,115
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 .
77
13
21,116
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 .
54
10
21,117
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 .
50
12
21,118
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 .
82
17
21,119
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 .
56
13
21,120
private GedToken getToken ( final String tag ) { GedToken gedToken = tokens . get ( tag ) ; if ( gedToken == null ) { // Any unknown token is an attribute, retaining its tag. gedToken = new GedToken ( tag , ATTR_FACTORY ) ; } return gedToken ; }
Find the token processor for this tag . Defaults to attribute .
73
13
21,121
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 .
46
15
21,122
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 .
241
18
21,123
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 .
50
13
21,124
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 .
48
15
21,125
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 .
52
8
21,126
private String handleFTMBizzareDateFormat ( final String dateString ) { approximation = DateParser . Approximation . BETWEEN ; String string = stripPrefix ( dateString , "(" ) . trim ( ) ; string = stripSuffix ( string , ")" ) . trim ( ) ; if ( "BIC" . equals ( string ) ) { // BIC refers to LDS status "born in the covenant". Such a date can // be treated as a plain string with no approximation semantics. 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 ) { // Probably like 10-11 Nov 2017 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 .
377
9
21,127
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 .
76
10
21,128
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 .
53
15
21,129
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 .
59
14
21,130
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 .
104
9
21,131
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 .
68
15
21,132
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 .
48
8
21,133
@ GetMapping ( value = "/v1/dbs" ) @ ResponseBody 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 .
118
9
21,134
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 .
39
10
21,135
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 .
107
5
21,136
private String nameHtml ( final RenderingContext context , final Person person ) { return nameRenderer ( context , person ) . getNameHtml ( ) ; }
Get the name string in an html fragment format .
36
10
21,137
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 .
58
11
21,138
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 .
51
16
21,139
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 .
51
16
21,140
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 .
57
11
21,141
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 .
77
12
21,142
@ Override 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 .
65
20
21,143
@ 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 .
65
7
21,144
@ Override 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 .
126
12
21,145
@ Override 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 .
52
31
21,146
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 .
167
4
21,147
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 .
87
9
21,148
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 .
69
11
21,149
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 .
42
17
21,150
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 .
44
10
21,151
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 .
44
10
21,152
protected final void firstMonth ( final Calendar c ) { c . set ( Calendar . MONTH , c . getMinimum ( Calendar . MONTH ) ) ; }
Adjust calendar to the first month of the year .
33
10
21,153
protected final void lastMonth ( final Calendar c ) { c . set ( Calendar . MONTH , c . getMaximum ( Calendar . MONTH ) ) ; }
Adjust calendar to the last month of the year .
33
10
21,154
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 .
39
9
21,155
protected final Person getFather ( final Family family ) { final FamilyNavigator navigator = new FamilyNavigator ( family ) ; return navigator . getFather ( ) ; }
Get the father from a family .
36
7
21,156
protected final Person getMother ( final Family family ) { final FamilyNavigator navigator = new FamilyNavigator ( family ) ; return navigator . getMother ( ) ; }
Get the mother from a family .
36
7
21,157
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 .
46
9
21,158
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 .
45
8
21,159
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 .
58
16
21,160
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 .
58
18
21,161
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 .
64
20
21,162
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 .
109
7
21,163
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 .
183
6
21,164
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 .
74
29
21,165
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 .
63
11
21,166
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 .
226
17
21,167
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 .
118
14
21,168
@ RequestMapping ( value = "/v1/upload" , method = RequestMethod . POST , consumes = "multipart/form-data" ) @ ResponseBody 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 .
152
9
21,169
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 .
61
10
21,170
@ Override 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 .
42
21
21,171
@ 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 .
287
12
21,172
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 .
131
24
21,173
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 .
138
13
21,174
private LocalDate estimateFromParentMarriage ( final Person parent ) { final BirthDateEstimator bde = createEstimator ( parent ) ; return estimateFromParentMarriage ( bde ) ; }
Estimate birth date from parent s marriage .
43
9
21,175
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 .
67
17
21,176
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 .
57
12
21,177
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 .
42
30
21,178
@ Override 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 .
57
17
21,179
@ Override 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 .
37
23
21,180
@ Override 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 .
48
18
21,181
@ Override 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 .
47
17
21,182
@ Override 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 .
67
9
21,183
@ Override 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 .
55
11
21,184
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 .
77
11
21,185
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 ( ) ; // This is safe because the gs object returns a copy of its array. result . postcodeLocalities = gsResult . getPostcodeLocalities ( ) ; // This is safe because the gs object returns a copy of its array. result . types = gsResult . getTypes ( ) ; return result ; }
Create a GeocodingResult from a GeoServiceGeocodingResult .
282
15
21,186
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 .
67
24
21,187
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 .
63
11
21,188
private LocationType toLocationType ( final Object property ) { if ( property == null ) { return null ; } return LocationType . valueOf ( property . toString ( ) ) ; }
Convert a property to a Google LocationType .
39
10
21,189
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 .
73
11
21,190
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 .
90
15
21,191
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 .
119
11
21,192
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 .
60
18
21,193
@ Override public void visit ( final Attribute attribute ) { for ( final GedObject gob : attribute . getAttributes ( ) ) { gob . accept ( this ) ; } }
Visit an Attributes . Look at Attributes to find Places .
38
11
21,194
@ Override 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 .
77
13
21,195
@ Override public void visit ( final Place place ) { placeStrings . add ( place . getString ( ) ) ; places . add ( place ) ; }
Visit a Place . The names of Places are collected .
34
11
21,196
@ Override 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 .
80
29
21,197
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 .
116
15
21,198
public void init ( ) { surnameIndex . clear ( ) ; final RootVisitor visitor = new RootVisitor ( ) ; mRoot . accept ( visitor ) ; for ( final Person person : visitor . getPersons ( ) ) { final String key = person . getString ( ) ; // Surname for inclusion in the index. // This is the string by which the person will be indexed. 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 .
174
10
21,199
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 .
106
34