|
@@ -29,7 +29,7 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
next: obsTrigger => {
|
|
next: obsTrigger => {
|
|
console.log(obsTrigger.message)// just checking the message
|
|
console.log(obsTrigger.message)// just checking the message
|
|
|
|
|
|
- let missingMsg : Observable<MessageLog> = this.synchronize()
|
|
|
|
|
|
+ let missingMsg: Observable<MessageLog> = this.synchronize()
|
|
missingMsg.subscribe({
|
|
missingMsg.subscribe({
|
|
next: element => {
|
|
next: element => {
|
|
msg.next(element)
|
|
msg.next(element)
|
|
@@ -44,25 +44,19 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
|
|
|
|
/* This is where the 'synching' operation takes place. */
|
|
/* This is where the 'synching' operation takes place. */
|
|
private synchronize(): Subject<MessageLog> {
|
|
private synchronize(): Subject<MessageLog> {
|
|
- let subjectOutput : Subject<MessageLog> = new Subject()
|
|
|
|
|
|
+ let subjectOutput: Subject<MessageLog> = new Subject()
|
|
// Acquire the data from both location and return them as an array respectively.
|
|
// Acquire the data from both location and return them as an array respectively.
|
|
this.acquireData().then((data: { arr1: MessageLog[], arr2: MessageLog[] }) => {
|
|
this.acquireData().then((data: { arr1: MessageLog[], arr2: MessageLog[] }) => {
|
|
- // Check for length first. If the length matches, then there's no need to sync
|
|
|
|
- // since there's nothing missing.
|
|
|
|
- if (data.arr1.length === data.arr2.length) {
|
|
|
|
- console.log(`No synchronization needed`)
|
|
|
|
- } else {
|
|
|
|
- // In the case where there are differences in the array length, then extensive comparison
|
|
|
|
- // will be carried out to filter out the differences. Differences are the missing data.
|
|
|
|
- this.checkArrayDifferences(data).then((data: MessageLog[]) => {
|
|
|
|
- data.forEach(msgElement => {
|
|
|
|
- let refined = JSON.parse(JSON.stringify(msgElement))
|
|
|
|
- // Once the missing data has been weeded out, it is then passed into the Subject
|
|
|
|
- // to be returned for the subscribe method.
|
|
|
|
- subjectOutput.next(refined)
|
|
|
|
- })
|
|
|
|
|
|
+ // In the case where there are differences in the array length, then extensive comparison
|
|
|
|
+ // will be carried out to filter out the differences. Differences are the missing data.
|
|
|
|
+ this.checkArrayDifferences(data).then((data: MessageLog[]) => {
|
|
|
|
+ data.forEach(msgElement => {
|
|
|
|
+ let refined = JSON.parse(JSON.stringify(msgElement))
|
|
|
|
+ // Once the missing data has been weeded out, it is then passed into the Subject
|
|
|
|
+ // to be returned for the subscribe method.`
|
|
|
|
+ subjectOutput.next(refined)
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
+ })
|
|
}).catch((e) => console.error(e))
|
|
}).catch((e) => console.error(e))
|
|
return subjectOutput
|
|
return subjectOutput
|
|
}
|
|
}
|
|
@@ -78,15 +72,15 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
arr1: [],
|
|
arr1: [],
|
|
arr2: []
|
|
arr2: []
|
|
}
|
|
}
|
|
- let set1 : MessageLog[]
|
|
|
|
- let set2 : MessageLog[]
|
|
|
|
|
|
+ let set1: MessageLog[]
|
|
|
|
+ let set2: MessageLog[]
|
|
|
|
|
|
// Initiate the source to find the location of the targeted data to be synched.
|
|
// Initiate the source to find the location of the targeted data to be synched.
|
|
this.sourceSrc.init(this.settings.incomingSource).then(() => {
|
|
this.sourceSrc.init(this.settings.incomingSource).then(() => {
|
|
this.targetSrc.init(this.settings.target).then(() => {
|
|
this.targetSrc.init(this.settings.target).then(() => {
|
|
// Filter also carries out the query aspect of the operation, allowing it to acquire all the relevant data.
|
|
// Filter also carries out the query aspect of the operation, allowing it to acquire all the relevant data.
|
|
this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] }).then((data: MessageLog[]) => {
|
|
this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] }).then((data: MessageLog[]) => {
|
|
- set1 = data
|
|
|
|
|
|
+ set1 = data
|
|
}).then(() => {
|
|
}).then(() => {
|
|
this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
|
|
this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
|
|
set2 = data
|
|
set2 = data
|