fixed path reports
This commit is contained in:
parent
8d85c1e97e
commit
e254720377
|
@ -48,8 +48,7 @@ public class BaseAnalyzerJob {
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
|
|
||||||
final String jsonConfiguration = IOUtils
|
final String jsonConfiguration = IOUtils
|
||||||
.toString(
|
.toString(BaseAnalyzerJob.class
|
||||||
BaseAnalyzerJob.class
|
|
||||||
.getResourceAsStream("/eu/dnetlib/dhp/collection/plugin/base/action_set_parameters.json"));
|
.getResourceAsStream("/eu/dnetlib/dhp/collection/plugin/base/action_set_parameters.json"));
|
||||||
|
|
||||||
final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration);
|
final ArgumentApplicationParser parser = new ArgumentApplicationParser(jsonConfiguration);
|
||||||
|
@ -124,27 +123,28 @@ public class BaseAnalyzerJob {
|
||||||
|
|
||||||
final List<String> recTypes = new ArrayList<>();
|
final List<String> recTypes = new ArrayList<>();
|
||||||
|
|
||||||
for (final Object o : record.selectNodes("//*[local-name()='metadata']//*")) {
|
for (final Object o : record.selectNodes("//*|//@*")) {
|
||||||
|
|
||||||
incrementMapCounter(fields, ((Node) o).getPath());
|
incrementMapCounter(fields, ((Node) o).getPath());
|
||||||
|
|
||||||
final String nodeName = ((Node) o).getName();
|
final String nodeName = ((Node) o).getName();
|
||||||
|
|
||||||
if ("collection".equals(nodeName)) {
|
if (o instanceof Element) {
|
||||||
final Element n = (Element) o;
|
final Element n = (Element) o;
|
||||||
|
if ("collection".equals(nodeName)) {
|
||||||
final String collName = n.getText().trim();
|
final String collName = n.getText().trim();
|
||||||
if (StringUtils.isNotBlank(collName)) {
|
if (StringUtils.isNotBlank(collName)) {
|
||||||
final Map<String, String> map = new HashMap<>();
|
final Map<String, String> map = new HashMap<>();
|
||||||
for (final Object ao : n.attributes()) {
|
for (final Object ao : n.attributes()) {
|
||||||
map.put(((Attribute) ao).getName(), ((Attribute) ao).getValue());
|
map.put(((Attribute) ao).getName(), ((Attribute) ao).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
incrementMapCounter(collections, collName + ": " + OBJECT_MAPPER.writeValueAsString(map));
|
incrementMapCounter(collections, collName + ": " + OBJECT_MAPPER.writeValueAsString(map));
|
||||||
}
|
}
|
||||||
} else if ("type".equals(nodeName)) {
|
} else if ("type".equals(nodeName)) {
|
||||||
recTypes.add("TYPE: " + nodeName);
|
recTypes.add("TYPE: " + n.getText().trim());
|
||||||
} else if ("typenorm".equals(nodeName)) {
|
} else if ("typenorm".equals(nodeName)) {
|
||||||
recTypes.add("TYPE_NORM: " + nodeName);
|
recTypes.add("TYPE_NORM: " + n.getText().trim());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,12 +165,9 @@ public class BaseAnalyzerJob {
|
||||||
private static void saveReport(final FileSystem fs, final String outputPath, final Map<String, AtomicLong> fields)
|
private static void saveReport(final FileSystem fs, final String outputPath, final Map<String, AtomicLong> fields)
|
||||||
throws JsonProcessingException, IOException {
|
throws JsonProcessingException, IOException {
|
||||||
try (final SequenceFile.Writer writer = SequenceFile
|
try (final SequenceFile.Writer writer = SequenceFile
|
||||||
.createWriter(
|
.createWriter(fs.getConf(), SequenceFile.Writer.file(new Path(outputPath)), SequenceFile.Writer
|
||||||
fs.getConf(), SequenceFile.Writer.file(new Path(outputPath)), SequenceFile.Writer
|
.keyClass(IntWritable.class), SequenceFile.Writer
|
||||||
.keyClass(IntWritable.class),
|
.valueClass(Text.class), SequenceFile.Writer.compression(SequenceFile.CompressionType.BLOCK, new DeflateCodec()))) {
|
||||||
SequenceFile.Writer
|
|
||||||
.valueClass(Text.class),
|
|
||||||
SequenceFile.Writer.compression(SequenceFile.CompressionType.BLOCK, new DeflateCodec()))) {
|
|
||||||
|
|
||||||
final Text key = new Text();
|
final Text key = new Text();
|
||||||
final Text value = new Text();
|
final Text value = new Text();
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class BaseCollectorIteratorTest {
|
||||||
|
|
||||||
// System.out.println(record.asXML());
|
// System.out.println(record.asXML());
|
||||||
|
|
||||||
for (final Object o : record.selectNodes("//*[local-name()='metadata']//*")) {
|
for (final Object o : record.selectNodes("//*|//@*")) {
|
||||||
final String path = ((Node) o).getPath();
|
final String path = ((Node) o).getPath();
|
||||||
|
|
||||||
if (fields.containsKey(path)) {
|
if (fields.containsKey(path)) {
|
||||||
|
@ -56,8 +56,10 @@ public class BaseCollectorIteratorTest {
|
||||||
fields.put(path, new AtomicInteger(1));
|
fields.put(path, new AtomicInteger(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("collection".equals(((Node) o).getName())) {
|
if (o instanceof Element) {
|
||||||
final Element n = (Element) o;
|
final Element n = (Element) o;
|
||||||
|
|
||||||
|
if ("collection".equals(n.getName())) {
|
||||||
final String collName = n.getText().trim();
|
final String collName = n.getText().trim();
|
||||||
if (StringUtils.isNotBlank(collName) && !collections.containsKey(collName)) {
|
if (StringUtils.isNotBlank(collName) && !collections.containsKey(collName)) {
|
||||||
final Map<String, String> collAttrs = new HashMap<>();
|
final Map<String, String> collAttrs = new HashMap<>();
|
||||||
|
@ -66,12 +68,11 @@ public class BaseCollectorIteratorTest {
|
||||||
}
|
}
|
||||||
collections.put(collName, collAttrs);
|
collections.put(collName, collAttrs);
|
||||||
}
|
}
|
||||||
|
} else if ("type".equals(n.getName())) {
|
||||||
|
types.add(n.getText().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("type".equals(((Node) o).getName())) {
|
|
||||||
types.add(((Element) o).getText().trim());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue