Revision 49184
Added by Sandro La Bruzzo over 6 years ago
DMFResolverParser.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.resolver.parser; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 | 3 |
import com.google.common.collect.Lists; |
8 | 4 |
import com.ximpleware.AutoPilot; |
9 | 5 |
import com.ximpleware.VTDGen; |
10 | 6 |
import com.ximpleware.VTDNav; |
11 |
|
|
7 |
import eu.dnetlib.data.transform.VtdUtilityParser; |
|
8 |
import eu.dnetlib.data.transform.VtdUtilityParser.Node; |
|
12 | 9 |
import eu.dnetlib.dli.DLIUtils; |
13 | 10 |
import eu.dnetlib.dli.resolver.model.*; |
14 |
import eu.dnetlib.data.transform.VtdUtilityParser; |
|
15 |
import eu.dnetlib.data.transform.VtdUtilityParser.Node; |
|
11 |
import eu.dnetlib.pid.resolver.model.ObjectType; |
|
16 | 12 |
import org.apache.commons.lang3.StringUtils; |
17 | 13 |
import org.apache.commons.logging.Log; |
18 | 14 |
import org.apache.commons.logging.LogFactory; |
19 | 15 |
|
16 |
import java.util.ArrayList; |
|
17 |
import java.util.Arrays; |
|
18 |
import java.util.List; |
|
19 |
|
|
20 | 20 |
/** |
21 | 21 |
* Created by sandro on 9/13/16. |
22 | 22 |
*/ |
... | ... | |
25 | 25 |
private static final Log log = LogFactory.getLog(DMFResolverParser.class); |
26 | 26 |
|
27 | 27 |
@Override |
28 |
public ResolvedObject parseObject(final String record) {
|
|
29 |
try {
|
|
30 |
final ResolvedObject parsedObject = new ResolvedObject();
|
|
31 |
final VTDGen vg = new VTDGen();
|
|
28 |
public DLIResolvedObject parseObject(final String record) {
|
|
29 |
try {
|
|
30 |
final DLIResolvedObject parsedObject = new DLIResolvedObject();
|
|
31 |
final VTDGen vg = new VTDGen();
|
|
32 | 32 |
vg.setDoc(record.getBytes()); |
33 | 33 |
vg.parse(true); |
34 | 34 |
|
... | ... | |
48 | 48 |
final String publisher = VtdUtilityParser.getSingleValue(ap, vn, "//*[local-name()='resource']/*[local-name()='publisher']"); |
49 | 49 |
|
50 | 50 |
|
51 |
final ObjectProvenance provenance = new ObjectProvenance();
|
|
51 |
final DLIObjectProvenance provenance = new DLIObjectProvenance();
|
|
52 | 52 |
provenance.setDatasourceId(DLIUtils.getIdFromDataSourcePrefix(datasourcePrefix)); |
53 | 53 |
provenance.setDatasource(DLIUtils.getNameFromDataSourcePrefix(datasourcePrefix)); |
54 | 54 |
provenance.setCompletionStatus(completionStatus); |
... | ... | |
75 | 75 |
VtdUtilityParser.getTextValuesWithAttributes(ap, vn, "//*[local-name()='resource']//*[local-name()='relatedIdentifier']", Arrays.asList("relatedIdentifierType", "relationType", "inverseRelationType")); |
76 | 76 |
|
77 | 77 |
if (relations != null && relations.size() > 0) { |
78 |
final List<ObjectRelation> relationsResult = new ArrayList<>();
|
|
79 |
relations.forEach(relationMap -> {
|
|
78 |
final List<DLIObjectRelation> relationsResult = new ArrayList<>();
|
|
79 |
relations.forEach(relationMap -> {
|
|
80 | 80 |
final String relationType = relationMap.getAttributes().get("relationType"); |
81 | 81 |
final String inverseRelationType = relationMap.getAttributes().get("inverseRelationType"); |
82 | 82 |
final String relatedIdentifierType = relationMap.getAttributes().get("relatedIdentifierType"); |
83 | 83 |
final String relatedPid = relationMap.getTextValue(); |
84 |
final ObjectRelation currentRelation = new ObjectRelation();
|
|
85 |
currentRelation.setTargetPID(new PID(relatedPid, relatedIdentifierType));
|
|
84 |
final DLIObjectRelation currentRelation = new DLIObjectRelation();
|
|
85 |
currentRelation.setTargetPID(new PID(relatedPid, relatedIdentifierType));
|
|
86 | 86 |
currentRelation.setRelationSemantics(relationType); |
87 | 87 |
currentRelation.setInverseRelation(inverseRelationType); |
88 | 88 |
currentRelation.setCompletionStatus(CompletionStatus.incomplete.toString()); |
Also available in: Unified diff
Refactored Pid resolver