diff --git a/src/main/java/eu/dnetlib/app/directindex/input/ResultEntry.java b/src/main/java/eu/dnetlib/app/directindex/input/ResultEntry.java index 226e67c..0c6aad6 100644 --- a/src/main/java/eu/dnetlib/app/directindex/input/ResultEntry.java +++ b/src/main/java/eu/dnetlib/app/directindex/input/ResultEntry.java @@ -40,7 +40,7 @@ public class ResultEntry implements Serializable { @Schema(allowableValues = { "publication", "dataset", "software", "other" }) private String type = "publication"; - @Schema(requiredMode = RequiredMode.REQUIRED, description = "Use 001 for articles, 021 for datasets, 0029 for software. See: http://api.openaire.eu/vocabularies/dnet:publication_resource for all the available resource types.") + @Schema(requiredMode = RequiredMode.REQUIRED, description = "Use 0001 for articles, 0021 for datasets, 0029 for software. See: http://api.openaire.eu/vocabularies/dnet:publication_resource for all the available resource types.") private String resourceType; @Schema(requiredMode = RequiredMode.REQUIRED) diff --git a/src/main/java/eu/dnetlib/app/directindex/mapping/InstanceWithTypeCode.java b/src/main/java/eu/dnetlib/app/directindex/mapping/InstanceWithTypeCode.java new file mode 100644 index 0000000..c6ccadb --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/mapping/InstanceWithTypeCode.java @@ -0,0 +1,20 @@ +package eu.dnetlib.app.directindex.mapping; + +import eu.dnetlib.dhp.schema.solr.Instance; + +// TODO: To delete after the dismission of the XML +public class InstanceWithTypeCode extends Instance { + + private static final long serialVersionUID = -5415824868827493090L; + + private String instancetypeCode; + + public String getInstancetypeCode() { + return instancetypeCode; + } + + public void setInstancetypeCode(final String instancetypeCode) { + this.instancetypeCode = instancetypeCode; + } + +} diff --git a/src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java b/src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java index bab5ca3..40e519e 100644 --- a/src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java +++ b/src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java @@ -264,10 +264,10 @@ public class SolrRecordMapper { r.setBestaccessright(BestAccessRight.newInstance("UNKNOWN", "not available")); } - final Instance instance = new Instance(); - - // TODO verificare il valore (dovrebbe essere classid="0004" classname="Conference object") - instance.setInstancetype(re.getResourceType()); + // TODO: To replace with Instance after the dismission of the XML + final InstanceWithTypeCode instance = new InstanceWithTypeCode(); + instance.setInstancetype(vocClient.findTermLabel("dnet:publication_resource", re.getResourceType())); + instance.setInstancetypeCode(re.getResourceType()); instance.setCollectedfrom(collectedFrom); instance.setHostedby(hostedBy); instance.setPid(pids); diff --git a/src/main/java/eu/dnetlib/app/directindex/solr/XMLSolrSerializer.java b/src/main/java/eu/dnetlib/app/directindex/solr/XMLSolrSerializer.java index da9ff01..2c2e941 100644 --- a/src/main/java/eu/dnetlib/app/directindex/solr/XMLSolrSerializer.java +++ b/src/main/java/eu/dnetlib/app/directindex/solr/XMLSolrSerializer.java @@ -6,6 +6,7 @@ import org.dom4j.Element; import org.dom4j.Namespace; import org.dom4j.QName; +import eu.dnetlib.app.directindex.mapping.InstanceWithTypeCode; import eu.dnetlib.dhp.schema.common.ModelConstants; import eu.dnetlib.dhp.schema.solr.BestAccessRight; import eu.dnetlib.dhp.schema.solr.Instance; @@ -135,8 +136,9 @@ public class XMLSolrSerializer { private static void addResultInstance(final Element childrenNode, final Instance i) { final Element instanceNode = childrenNode.addElement("instance"); - //TODO manca il code o il name - addStructuredField(instanceNode, "instancetype", i.getInstancetype(), ModelConstants.DNET_PUBLICATION_RESOURCE, null); + if (i instanceof InstanceWithTypeCode) { + addStructuredField(instanceNode, "instancetype", ((InstanceWithTypeCode) i).getInstancetypeCode(), i.getInstancetype(), ModelConstants.DNET_PUBLICATION_RESOURCE, null); + } addStructuredField(instanceNode, "accessright", i.getAccessright().getCode(), i.getAccessright().getLabel(), ModelConstants.DNET_ACCESS_MODES, null);