2024-02-05 15:43:40 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024.
|
|
|
|
* SPDX-FileCopyrightText: © 2023 Consiglio Nazionale delle Ricerche
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
package eu.dnetlib.dhp.actionmanager.promote;
|
|
|
|
|
|
|
|
/** Encodes the Actionset promotion strategies */
|
|
|
|
public class PromoteAction {
|
|
|
|
|
|
|
|
/** The supported actionset promotion strategies
|
|
|
|
*
|
|
|
|
* ENRICH: promotes only records in the actionset matching another record in the
|
|
|
|
* graph and enriches them applying the given MergeAndGet strategy
|
|
|
|
* UPSERT: promotes all the records in an actionset, matching records are updated
|
|
|
|
* using the given MergeAndGet strategy, the non-matching record as inserted as they are.
|
|
|
|
*/
|
|
|
|
public enum Strategy {
|
|
|
|
ENRICH, UPSERT
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the string representation of the join type implementing the given PromoteAction.
|
|
|
|
*
|
|
|
|
* @param strategy the strategy to be used to promote the Actionset contents
|
|
|
|
* @return the join type used to implement the promotion strategy
|
|
|
|
*/
|
|
|
|
public static String joinTypeForStrategy(PromoteAction.Strategy strategy) {
|
|
|
|
switch (strategy) {
|
|
|
|
case ENRICH:
|
2024-02-05 15:55:36 +01:00
|
|
|
return "left_outer";
|
2024-02-05 15:43:40 +01:00
|
|
|
case UPSERT:
|
|
|
|
return "full_outer";
|
|
|
|
default:
|
|
|
|
throw new IllegalStateException("unsupported PromoteAction: " + strategy.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|