Testing and fixes

This commit is contained in:
Fabio Sinibaldi 2021-03-08 17:39:24 +01:00
parent 81048172b2
commit d3b599033a
6 changed files with 37 additions and 34 deletions

View File

@ -1 +1 @@
{"metadata":{"upload_type":"other","creators":[{"name":"Rossi, Pietro, pietro.rossi@acme.org"},{"name":"Verdi, Luca, lica.verdi@amce.org"},{"name":"Bianchi, Elena"}],"contributors":[{"name":"Ferrari, Paolo, paolo.ferrari@acme.org","type":"Other"},{"name":"Russo, Pietro, pietro.russo@amce.org","type":"Other"},{"name":"Giorgino, Giorgio","type":"Other"}],"communities":[{"identifier":"blue-cloud"}],"grants":[{"id":"862409"}]},"doiurl":"https://doi.org/null"} {"metadata":{"upload_type":"other","publication_date":"2021-03-08T16:30:21.000774+0000","title":"A sample deliverable 4 Zenodo","creators":[{"name":"Candela Leonardo"},{"name":"Candela Leonardo"}],"description":"This is a sample deliverable created for testing the publish2Zenodo \r\nfacility","access_right":"open","license":"CC-BY-SA-4.0","keywords":["Text mining"],"related_identifiers":[{"identifier":"https://data-pre.d4science.org/ctlg/preVRE/a_sample_deliverable_4_zenodo","relation":"isCompiledBy"}],"contributors":[{"name":"Candela Leonardo","type":"Producer"},{"name":"Candela Leonardo","type":"DataCurator"},{"name":"D4Science","type":"HostingInstitution"}],"version":"1"},"doiurl":"https://doi.org/null"}

View File

@ -294,12 +294,15 @@ public class Translator {
JsonPath path=JsonPath.compile(mapping.getTargetPath().getValue()); JsonPath path=JsonPath.compile(mapping.getTargetPath().getValue());
switch(mapping.getTargetPath().getType()) { switch(mapping.getTargetPath().getType()) {
case array : case array :
targetCtx.set(path, resultingValueList); targetCtx=targetCtx.set(path, resultingValueList);
break; break;
case map : case map :
for(Map<String,Object> resultingTargetElements : resultingValueList) { for(Map<String,Object> resultingTargetElements : resultingValueList) {
log.debug("Applying "+resultingTargetElements+ " to "+mapping.getTargetPath()); log.debug("Applying "+resultingTargetElements+ " to "+mapping.getTargetPath());
targetCtx.set(path, resultingTargetElements); for(Entry<String,Object> e:resultingTargetElements.entrySet())
targetCtx=targetCtx.put(path, e.getKey(),e.getValue());
} }
break; break;
} }

View File

@ -24,7 +24,7 @@ public class TargetPath {
private ElementType type=ElementType.map; private ElementType type=ElementType.map;
@XmlAttribute(required=false) @XmlAttribute(required=false)
private Boolean append=false; private Boolean append=true;
@XmlValue @XmlValue
private String value; private String value;

View File

@ -55,7 +55,7 @@ public class OneHitTest {
System.out.println("Publishing.. "); System.out.println("Publishing.. ");
//Finalize //Finalize
// System.out.println("DONE : "+client.publish(preview, item)); System.out.println("DONE : "+client.publish(preview, item));
} }

View File

@ -24,43 +24,43 @@
<targetElement>upload_type</targetElement> <targetElement>upload_type</targetElement>
</mapping> </mapping>
<mapping> <!-- <mapping> -->
<source> <!-- $.store.book[?(@.price < 10)] --> <!-- <source> -->
<value type="jsonPath">$.extras[?(@.key=='Deliverable Author')].value</value> <!-- <value type="jsonPath">$.extras[?(@.key=='Deliverable Author')].value</value> -->
</source> <!-- </source> -->
<targetPath append="false" type="array">$.metadata.creators</targetPath> <!-- <targetPath append="false" type="array">$.metadata.creators</targetPath> -->
<targetElement>name</targetElement> <!-- <targetElement>name</targetElement> -->
</mapping> <!-- </mapping> -->
<!-- Contributor -> {name : ... , type : 'other'} --> <!-- Contributor -> {name : ... , type : 'other'} -->
<mapping> <!-- <mapping> -->
<source> <!-- <source> -->
<value type="jsonPath">$.extras[?(@.key=='Deliverable Contributor')].value</value> <!-- <value type="jsonPath">$.extras[?(@.key=='Deliverable Contributor')].value</value> -->
</source> <!-- </source> -->
<targetPath append="false" type="array">$.metadata.contributors</targetPath> <!-- <targetPath append="false" type="array">$.metadata.contributors</targetPath> -->
<targetElement>name</targetElement> <!-- <targetElement>name</targetElement> -->
<targetElement constant="Other">type</targetElement> <!-- <targetElement constant="Other">type</targetElement> -->
</mapping> <!-- </mapping> -->
<mapping> <!-- <mapping> -->
<source> <!-- <source> -->
<value type="constant">862409</value> <!-- <value type="constant">862409</value> -->
</source> <!-- </source> -->
<targetPath type="array">$.metadata.grants</targetPath> <!-- <targetPath type="array">$.metadata.grants</targetPath> -->
<targetElement>id</targetElement> <!-- <targetElement>id</targetElement> -->
</mapping> <!-- </mapping> -->
<mapping> <!-- <mapping> -->
<source> <!-- <source> -->
<value type="constant">blue-cloud</value> <!-- <value type="constant">blue-cloud</value> -->
</source> <!-- </source> -->
<targetPath type="array">$.metadata.communities</targetPath> <!-- <targetPath type="array">$.metadata.communities</targetPath> -->
<targetElement>identifier</targetElement> <!-- <targetElement>identifier</targetElement> -->
</mapping> <!-- </mapping> -->
</mappings> </mappings>