ml-modules.root.data-hub.5.builtins.steps.mastering.default.manual-merge.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-data-hub Show documentation
Show all versions of marklogic-data-hub Show documentation
Library for Creating an Operational Data Hub on MarkLogic
import hubUtils from "/data-hub/5/impl/hub-utils.mjs";
import Mergeable from "/data-hub/5/mastering/merging/mergeable.mjs";
import masteringStepLib from "/data-hub/5/builtins/steps/mastering/default/lib.mjs";
import {ThresholdDefinition} from "/data-hub/5/mastering/matching/matchable.mjs";
const quickStartRequiredOptionProperty = 'mergeOptions';
const hubCentralRequiredOptionProperty = 'mergeRules';
function main(content, options) {
masteringStepLib.checkOptions(null, options, null, [[quickStartRequiredOptionProperty,hubCentralRequiredOptionProperty]]);
const mergeable = new Mergeable(options);
const thresholdObj = {action: "merge"};
const threshold = new ThresholdDefinition(thresholdObj, null);
let contentArray = hubUtils.normalizeToArray(content);
const uri = threshold.generateActionURI(contentArray);
let mergedDocument = {
uri: uri,
previousUri: contentArray.map(c => c.uri),
value: mergeable.buildMergeDocument(contentArray),
context: {
collections: [],
permissions: []
}}
for (const contentToArchive of contentArray) {
contentToArchive.context.collections = [];
mergeable.applyDocumentContext(contentToArchive, {action: "archive"});
}
mergeable.applyDocumentContext(mergedDocument, thresholdObj);
let filteredContent = contentArray.filter((item) => item.uri !== mergedDocument.uri);
return Sequence.from(filteredContent.concat([mergedDocument]));
}
export default {
main
};
© 2015 - 2024 Weber Informatics LLC | Privacy Policy