Revision 49096
Added by Claudio Atzori over 6 years ago
XmlRecordFactory.java | ||
---|---|---|
26 | 26 |
import eu.dnetlib.data.proto.FieldTypeProtos.*; |
27 | 27 |
import eu.dnetlib.data.proto.OafProtos.OafEntity; |
28 | 28 |
import eu.dnetlib.data.proto.OafProtos.OafRel; |
29 |
import eu.dnetlib.data.proto.PersonProtos.Person; |
|
30 | 29 |
import eu.dnetlib.data.proto.ProjectProtos.Project; |
31 | 30 |
import eu.dnetlib.data.proto.RelMetadataProtos.RelMetadata; |
32 | 31 |
import eu.dnetlib.data.proto.ResultProtos.Result; |
... | ... | |
69 | 68 |
protected Transformer transformer; |
70 | 69 |
|
71 | 70 |
protected static Predicate<String> instanceFilter = new Predicate<String>() { |
72 |
final Set<String> instanceFieldFilter = Sets.newHashSet("instancetype", "hostedby", "licence", "collectedfrom", "dateofacceptance");
|
|
71 |
final Set<String> instanceFieldFilter = Sets.newHashSet("instancetype", "hostedby", "license", "accessright", "collectedfrom", "dateofacceptance");
|
|
73 | 72 |
@Override |
74 | 73 |
public boolean apply(final String s) { |
75 | 74 |
return instanceFieldFilter.contains(s); |
... | ... | |
204 | 203 |
metadata.addAll(listFields(decoder.getOafEntity(), filter, defaults, expandingRel)); |
205 | 204 |
|
206 | 205 |
if ((decoder.getEntity() instanceof Result) && !expandingRel) { |
207 |
metadata.add(asXmlElement("bestlicense", "", getBestLicense(), null));
|
|
206 |
metadata.add(asXmlElement("bestaccessright", "", getBestAccessright(), null));
|
|
208 | 207 |
|
209 | 208 |
metadata.addAll(listFields(decoder.getEntity(), filter, defaults, expandingRel)); |
210 | 209 |
} |
211 |
if ((decoder.getEntity() instanceof Person) && !expandingRel) { |
|
212 |
metadata.addAll(listFields(decoder.getEntity(), filter, defaults, expandingRel)); |
|
213 |
} |
|
214 | 210 |
if ((decoder.getEntity() instanceof Project) && !expandingRel) { |
215 | 211 |
metadata.addAll(listFields(decoder.getEntity(), filter, defaults, expandingRel)); |
216 | 212 |
} |
... | ... | |
218 | 214 |
return metadata; |
219 | 215 |
} |
220 | 216 |
|
221 |
private Qualifier getBestLicense() {
|
|
222 |
Qualifier bestLicense = getQualifier("UNKNOWN", "not available", "dnet:access_modes");
|
|
217 |
private Qualifier getBestAccessright() {
|
|
218 |
Qualifier bestAccessRight = getQualifier("UNKNOWN", "not available", "dnet:access_modes");
|
|
223 | 219 |
final LicenseComparator lc = new LicenseComparator(); |
224 | 220 |
for (final Instance instance : ((Result) mainEntity.decodeEntity().getEntity()).getInstanceList()) { |
225 |
if (lc.compare(bestLicense, instance.getLicence()) > 0) {
|
|
226 |
bestLicense = instance.getLicence();
|
|
221 |
if (lc.compare(bestAccessRight, instance.getAccessright()) > 0) {
|
|
222 |
bestAccessRight = instance.getAccessright();
|
|
227 | 223 |
} |
228 | 224 |
} |
229 |
return bestLicense;
|
|
225 |
return bestAccessRight;
|
|
230 | 226 |
} |
231 | 227 |
|
232 | 228 |
public Qualifier getQualifier(final String classid, final String classname, final String schemename) { |
Also available in: Unified diff
fixing mapping for license vs accessright #3128, cleanup