Importing errors track conflicting local and remote content now.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-09 18:12:15 -05:00
parent 2a238ae2c2
commit fd3b4d7925

View File

@ -2,36 +2,35 @@ Extension { #name : #LeDatabase }
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocation [ LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
| remoteMetadata divSnippets snippets page | | remoteMetadata divSnippets snippets page |
divSnippets := (markdeepDocTree xpath: '//div[@st-class]') divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection
asOrderedCollection collect: [ :xmlElement | xmlElement postCopy ]. collect: [ :xmlElement | xmlElement postCopy ].
snippets := divSnippets collect: [ :xmlElement | snippets := divSnippets
(xmlElement attributes at: 'st-class') = 'LeTextSnippet' collect: [ :xmlElement |
ifTrue: [ LeTextSnippet new contentFrom: xmlElement ] (xmlElement attributes at: 'st-class') = 'LeTextSnippet'
ifFalse: [ (xmlElement attributes at: 'st-class') = 'LePharoSnippet' ifTrue: [ LeTextSnippet new contentFrom: xmlElement ]
ifTrue: [ LePharoSnippet new contentFrom: xmlElement ] ifFalse: [ (xmlElement attributes at: 'st-class') = 'LePharoSnippet'
] ifTrue: [ LePharoSnippet new contentFrom: xmlElement ] ] ].
].
remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree. remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree.
page := LePage new page := LePage new
title: (remoteMetadata at: 'title'); title: (remoteMetadata at: 'title');
basicUid: (UUID fromString36: (remoteMetadata at: 'id')); basicUid: (UUID fromString36: (remoteMetadata at: 'id'));
createTime: (LeTime new time: ((remoteMetadata at: 'created') asDateAndTime)); createTime: (LeTime new time: (remoteMetadata at: 'created') asDateAndTime);
editTime: (LeTime new time: ((remoteMetadata at: 'modified') asDateAndTime)); editTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
latestEditTime: (LeTime new time: ((remoteMetadata at: 'modified') asDateAndTime)); latestEditTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
createEmail: (LeEmail new email:(remoteMetadata at: 'creator')); createEmail: (LeEmail new email: (remoteMetadata at: 'creator'));
editEmail: (LeEmail new email:(remoteMetadata at: 'modifier')). editEmail: (LeEmail new email: (remoteMetadata at: 'modifier')).
snippets do: [ :snippet | page addSnippet: snippet ]. snippets do: [ :snippet | page addSnippet: snippet ].
page children do: [ :snippet | page children
(self hasBlockUID: (snippet uid)) do: [ :snippet |
ifTrue: [ | existingPage | (self hasBlockUID: snippet uid)
existingPage := self pages detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ]. ifTrue: [ | existingPage |
self importErrorMessage: existingPage. existingPage := self pages
^ self ] detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
ifFalse: [ self importErrorForLocal: existingPage withRemote: externalDocLocation.
snippet database: self. ^ self ]
self registerSnippet: snippet ] ]. ifFalse: [ snippet database: self.
self registerSnippet: snippet ] ].
self addPage: page. self addPage: page.
^ page ^ page
] ]
@ -42,7 +41,7 @@ LeDatabase >> addPageFromMarkdeepUrl: aString [
page := self detectLocalPageForRemote: aString. page := self detectLocalPageForRemote: aString.
page page
ifNotNil: [ :arg | ifNotNil: [ :arg |
self importErrorMessage: page. self importErrorForLocal: page withRemote: aString.
^ self ]. ^ self ].
^ self addPageFromMarkdeep: (self docTreeForLink: aString) withRemote: aString ^ self addPageFromMarkdeep: (self docTreeForLink: aString) withRemote: aString
] ]
@ -121,7 +120,7 @@ LeDatabase >> gtViewErrorDetailsOn: aView [
] ]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LeDatabase >> importErrorMessage: page [ LeDatabase >> importErrorForLocal: page withRemote: externalDocLocation [
| message id | | message id |
id := page uidString. id := page uidString.
@ -137,7 +136,10 @@ LeDatabase >> importErrorMessage: page [
nextPut: Character lf; nextPut: Character lf;
nextPutAll: 'already exists in this database and includes overlapping contents'; nextPutAll: 'already exists in this database and includes overlapping contents';
nextPut: Character lf; nextPut: Character lf;
nextPutAll: 'with the page you are trying to import.'; nextPutAll: 'with the page you are trying to import from:
';
nextPut: Character lf;
nextPutAll: externalDocLocation;
nextPut: Character lf; nextPut: Character lf;
nextPut: Character lf; nextPut: Character lf;
nextPutAll: nextPutAll: