forked from D-Net/dnet-hadoop
propagate exceptions in case of serialization errors, removed configuration pretty printing, removed unused class ScoredResult
This commit is contained in:
parent
f7616c7a8a
commit
478ad72cb8
|
@ -101,9 +101,9 @@ public class DedupConfig implements Config, Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (IOException e) {
|
||||
return e.getStackTrace().toString();
|
||||
throw new PaceException("unable to serialise configuration", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import eu.dnetlib.pace.util.PaceException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
||||
|
@ -252,9 +253,9 @@ public class WfConfig implements Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (IOException e) {
|
||||
return e.getStackTrace().toString();
|
||||
throw new PaceException("unable to serialise " + this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.pace.distance.eval;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import eu.dnetlib.pace.util.PaceException;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -54,9 +54,9 @@ public class ScoreResult implements Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (IOException e) {
|
||||
return e.getStackTrace().toString();
|
||||
throw new PaceException("unable to serialise " + this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ClusteringDef implements Serializable {
|
|||
try {
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (IOException e) {
|
||||
return e.getStackTrace().toString();
|
||||
throw new PaceException("unable to serialise " + this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
|
||||
import eu.dnetlib.pace.condition.*;
|
||||
import eu.dnetlib.pace.config.PaceConfig;
|
||||
import eu.dnetlib.pace.util.PaceException;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
||||
public class CondDef implements Serializable {
|
||||
|
@ -41,7 +42,7 @@ public class CondDef implements Serializable {
|
|||
try {
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (IOException e) {
|
||||
return e.getStackTrace().toString();
|
||||
throw new PaceException("unable to serialise " + this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,4 +135,15 @@ public class FieldDef implements Serializable {
|
|||
this.params = params;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setIgnoreMissing(boolean ignoreMissing) {
|
||||
this.ignoreMissing = ignoreMissing;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package eu.dnetlib.pace.model.gt;
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ScoredResult extends Result {
|
||||
|
||||
private double meanDistance;
|
||||
|
||||
public ScoredResult() {
|
||||
super();
|
||||
}
|
||||
|
||||
public double getMeanDistance() {
|
||||
return meanDistance;
|
||||
}
|
||||
|
||||
public void setMeanDistance(final double meanDistance) {
|
||||
this.meanDistance = meanDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (IOException e) {
|
||||
return e.getStackTrace().toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
package eu.dnetlib.pace.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import eu.dnetlib.pace.AbstractPaceTest;
|
||||
import eu.dnetlib.pace.model.MapDocument;
|
||||
import eu.dnetlib.pace.model.MapDocumentSerializer;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -15,23 +10,25 @@ public class ConfigTest extends AbstractPaceTest {
|
|||
|
||||
@Test
|
||||
public void dedupConfigSerializationTest() {
|
||||
final DedupConfig cfgFromClasspath = DedupConfig.load(readFromClasspath("result.pace.conf.json"));
|
||||
String fromClasspath = readFromClasspath("result.pace.conf.json");
|
||||
System.out.println("fromClasspath = " + fromClasspath);
|
||||
|
||||
final String conf = cfgFromClasspath.toString();
|
||||
final DedupConfig conf = DedupConfig.load(fromClasspath);
|
||||
|
||||
// System.out.println("*****SERIALIZED*****");
|
||||
// System.out.println(conf);
|
||||
// System.out.println("*****FROM CLASSPATH*****");
|
||||
// System.out.println(readFromClasspath("result.pace.conf.json"));
|
||||
|
||||
final DedupConfig cfgFromSerialization = DedupConfig.load(conf);
|
||||
|
||||
assertEquals(cfgFromClasspath.toString(), cfgFromSerialization.toString());
|
||||
|
||||
assertNotNull(cfgFromClasspath);
|
||||
assertNotNull(cfgFromSerialization);
|
||||
assertNotNull(conf);
|
||||
|
||||
|
||||
String parsed = conf.toString();
|
||||
|
||||
System.out.println("parsed = " + parsed);
|
||||
|
||||
DedupConfig conf2 = DedupConfig.load(parsed);
|
||||
|
||||
assertNotNull(conf2);
|
||||
|
||||
System.out.println("conf2 = " + conf2);
|
||||
|
||||
assertEquals(parsed, conf2.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue