forked from D-Net/dnet-hadoop
replace existing attributes when loading default configuration
This commit is contained in:
parent
f1c68d8ba3
commit
968cd47436
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
import eu.dnetlib.pace.util.PaceException;
|
import eu.dnetlib.pace.util.PaceException;
|
||||||
import org.antlr.stringtemplate.StringTemplate;
|
import org.antlr.stringtemplate.StringTemplate;
|
||||||
|
@ -73,7 +74,11 @@ public class DedupConfig implements Config, Serializable {
|
||||||
template.setAttribute(e.getKey(), e.getValue());
|
template.setAttribute(e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
for (final Entry<String, String> e : params.entrySet()) {
|
for (final Entry<String, String> e : params.entrySet()) {
|
||||||
template.setAttribute(e.getKey(), e.getValue());
|
if (template.getAttribute(e.getKey()) != null) {
|
||||||
|
template.getAttributes().computeIfPresent(e.getKey(), (o, o2) -> e.getValue());
|
||||||
|
} else {
|
||||||
|
template.setAttribute(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String json = template.toString();
|
final String json = template.toString();
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package eu.dnetlib.pace.config;
|
package eu.dnetlib.pace.config;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import eu.dnetlib.pace.AbstractPaceTest;
|
import eu.dnetlib.pace.AbstractPaceTest;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
@ -36,7 +40,22 @@ public class ConfigTest extends AbstractPaceTest {
|
||||||
|
|
||||||
DedupConfig load = DedupConfig.load(readFromClasspath("result.pace.conf.json"));
|
DedupConfig load = DedupConfig.load(readFromClasspath("result.pace.conf.json"));
|
||||||
|
|
||||||
|
assertNotNull(load);
|
||||||
System.out.println(load.toString());
|
System.out.println(load.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoadDefaults() throws IOException {
|
||||||
|
|
||||||
|
final Map<String, String> config = Maps.newHashMap();
|
||||||
|
config.put("entityType", "organization");
|
||||||
|
config.put("configurationId", "dedup-organization-simple");
|
||||||
|
final DedupConfig dedupConf = DedupConfig.loadDefault(config);
|
||||||
|
|
||||||
|
System.out.println("dedupConf = " + dedupConf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue